Files
OpenRAM/compiler/modules/precharge_array.py
T

129 lines
4.4 KiB
Python
Raw Normal View History

# See LICENSE for licensing information.
#
2024-01-03 14:32:44 -08:00
# Copyright (c) 2016-2024 Regents of the University of California and The Board
2019-06-14 08:43:41 -07:00
# of Regents for the Oklahoma Agricultural and Mechanical College
# (acting for and on behalf of Oklahoma State University)
# All rights reserved.
#
2022-11-27 13:01:20 -08:00
from openram import debug
from openram.base import design
from openram.base import vector
from openram.sram_factory import factory
from openram import OPTS
2016-11-08 09:57:35 -08:00
2020-03-04 17:39:11 -08:00
2022-07-13 10:57:56 -07:00
class precharge_array(design):
2016-11-08 09:57:35 -08:00
"""
Dynamically generated precharge array of all bitlines. Cols is number
of bit line columns, height is the height of the bit-cell array.
"""
2020-09-11 15:36:22 -07:00
def __init__(self, name, columns, offsets=None, size=1, bitcell_bl="bl", bitcell_br="br", column_offset=0):
2020-08-06 11:33:26 -07:00
super().__init__(name)
debug.info(1, "Creating {0}".format(self.name))
2019-01-25 15:00:00 -08:00
self.add_comment("cols: {0} size: {1} bl: {2} br: {3}".format(columns, size, bitcell_bl, bitcell_br))
2020-11-03 06:29:17 -08:00
2016-11-08 09:57:35 -08:00
self.columns = columns
2020-09-11 15:36:22 -07:00
self.offsets = offsets
self.size = size
self.bitcell_bl = bitcell_bl
self.bitcell_br = bitcell_br
self.column_offset = column_offset
2020-06-29 16:23:25 -07:00
if OPTS.tech_name == "sky130":
self.en_bar_layer = "m3"
else:
self.en_bar_layer = "m1"
2020-11-03 06:29:17 -08:00
self.create_netlist()
if not OPTS.netlist_only:
self.create_layout()
2016-11-08 09:57:35 -08:00
def get_bl_name(self):
bl_name = self.pc_cell.get_bl_names()
return bl_name
def get_br_name(self):
br_name = self.pc_cell.get_br_names()
return br_name
2016-11-08 09:57:35 -08:00
def add_pins(self):
"""Adds pins for spice file"""
for i in range(self.columns):
2019-08-06 14:14:09 -07:00
# These are outputs from the precharge only
self.add_pin("bl_{0}".format(i), "OUTPUT")
self.add_pin("br_{0}".format(i), "OUTPUT")
self.add_pin("en_bar", "INPUT")
self.add_pin("vdd", "POWER")
2016-11-08 09:57:35 -08:00
def create_netlist(self):
self.add_modules()
self.add_pins()
self.create_insts()
2020-11-03 06:29:17 -08:00
2016-11-08 09:57:35 -08:00
def create_layout(self):
2020-09-11 15:36:22 -07:00
self.place_insts()
2020-11-03 06:29:17 -08:00
2020-09-11 15:36:22 -07:00
self.width = self.offsets[-1] + self.pc_cell.width
self.height = self.pc_cell.height
2018-04-04 13:49:55 -07:00
self.add_layout_pins()
2022-03-06 09:56:00 -08:00
self.route_supplies()
self.add_boundary()
self.DRC_LVS()
2018-04-04 13:49:55 -07:00
def add_modules(self):
self.pc_cell = factory.create(module_type=OPTS.precharge,
2019-01-16 16:15:38 -08:00
size=self.size,
bitcell_bl=self.bitcell_bl,
bitcell_br=self.bitcell_br)
2020-11-13 15:55:55 -08:00
self.cell = factory.create(module_type=OPTS.bitcell)
2018-04-04 13:49:55 -07:00
def add_layout_pins(self):
2022-03-06 09:56:00 -08:00
en_pin = self.pc_cell.get_pin("en_bar")
2022-05-02 15:43:14 -07:00
self.route_horizontal_pins("en_bar", layer=self.en_bar_layer)
2022-03-06 09:56:00 -08:00
for inst in self.local_insts:
self.add_via_stack_center(from_layer=en_pin.layer,
to_layer=self.en_bar_layer,
offset=inst.get_pin("en_bar").center())
2020-11-03 06:29:17 -08:00
for i in range(len(self.local_insts)):
inst = self.local_insts[i]
2020-03-04 17:39:11 -08:00
self.copy_layout_pin(inst, "bl", "bl_{0}".format(i))
self.copy_layout_pin(inst, "br", "br_{0}".format(i))
2020-11-03 06:29:17 -08:00
2022-03-06 09:56:00 -08:00
def route_supplies(self):
2022-04-05 13:51:55 -07:00
self.route_horizontal_pins("vdd")
def create_insts(self):
"""Creates a precharge array by horizontally tiling the precharge cell"""
self.local_insts = []
for i in range(self.columns):
name = "pre_column_{0}".format(i)
offset = vector(self.pc_cell.width * i, 0)
inst = self.add_inst(name=name,
mod=self.pc_cell,
offset=offset)
self.local_insts.append(inst)
2018-11-28 15:30:52 -08:00
self.connect_inst(["bl_{0}".format(i), "br_{0}".format(i), "en_bar", "vdd"])
def place_insts(self):
""" Places precharge array by horizontally tiling the precharge cell"""
2020-11-03 06:29:17 -08:00
2020-09-11 15:36:22 -07:00
# Default to single spaced columns
if not self.offsets:
self.offsets = [n * self.pc_cell.width for n in range(self.columns)]
2020-09-11 15:36:22 -07:00
for i, xoffset in enumerate(self.offsets):
2020-11-13 15:55:55 -08:00
if self.cell.mirror.y and (i + self.column_offset) % 2:
mirror = "MY"
2020-09-11 15:36:22 -07:00
tempx = xoffset + self.pc_cell.width
else:
mirror = ""
2020-09-11 15:36:22 -07:00
tempx = xoffset
offset = vector(tempx, 0)
self.local_insts[i].place(offset=offset, mirror=mirror)