2019-06-14 21:15:16 +02:00
|
|
|
# See LICENSE for licensing information.
|
|
|
|
|
#
|
2020-05-28 05:03:11 +02:00
|
|
|
# Copyright (c) 2016-2019 Regents of the University of California
|
2019-06-14 21:15:16 +02:00
|
|
|
# All rights reserved.
|
|
|
|
|
#
|
|
|
|
|
import debug
|
|
|
|
|
import design
|
2020-06-06 00:09:22 +02:00
|
|
|
from tech import cell_properties
|
2019-06-14 21:15:16 +02:00
|
|
|
from sram_factory import factory
|
|
|
|
|
from vector import vector
|
|
|
|
|
from globals import OPTS
|
|
|
|
|
|
2020-06-06 00:09:22 +02:00
|
|
|
|
2019-06-14 21:15:16 +02:00
|
|
|
class replica_column(design.design):
|
|
|
|
|
"""
|
|
|
|
|
Generate a replica bitline column for the replica array.
|
2019-07-11 00:56:51 +02:00
|
|
|
Rows is the total number of rows i the main array.
|
|
|
|
|
Left_rbl and right_rbl are the number of left and right replica bitlines.
|
2020-05-28 05:03:11 +02:00
|
|
|
Replica bit specifies which replica column this is (to determine where to put the
|
2019-07-11 00:56:51 +02:00
|
|
|
replica cell.
|
2019-06-14 21:15:16 +02:00
|
|
|
"""
|
|
|
|
|
|
2020-01-27 17:17:06 +01:00
|
|
|
def __init__(self, name, rows, left_rbl, right_rbl, replica_bit,
|
|
|
|
|
column_offset=0):
|
2019-06-14 21:15:16 +02:00
|
|
|
design.design.__init__(self, name)
|
|
|
|
|
|
2019-07-11 00:56:51 +02:00
|
|
|
self.rows = rows
|
|
|
|
|
self.left_rbl = left_rbl
|
|
|
|
|
self.right_rbl = right_rbl
|
|
|
|
|
self.replica_bit = replica_bit
|
|
|
|
|
# left, right, regular rows plus top/bottom dummy cells
|
2020-06-06 00:09:22 +02:00
|
|
|
self.total_size = self.left_rbl + rows + self.right_rbl + 2
|
2020-01-27 17:17:06 +01:00
|
|
|
self.column_offset = column_offset
|
2020-05-28 05:03:11 +02:00
|
|
|
|
2020-06-06 00:09:22 +02:00
|
|
|
debug.check(replica_bit != 0 and replica_bit != rows,
|
|
|
|
|
"Replica bit cannot be the dummy row.")
|
|
|
|
|
debug.check(replica_bit <= left_rbl or replica_bit >= self.total_size - right_rbl - 1,
|
2020-05-28 05:03:11 +02:00
|
|
|
"Replica bit cannot be in the regular array.")
|
2020-06-19 22:59:33 +02:00
|
|
|
if OPTS.tech_name == "sky130":
|
|
|
|
|
debug.check(rows % 2 == 0 and (left_rbl + 1) % 2 == 0,
|
|
|
|
|
"sky130 currently requires rows to be even and to start with X mirroring"
|
|
|
|
|
+ " (left_rbl must be odd) for LVS.")
|
2019-06-14 21:15:16 +02:00
|
|
|
|
|
|
|
|
self.create_netlist()
|
|
|
|
|
if not OPTS.netlist_only:
|
|
|
|
|
self.create_layout()
|
2020-05-28 05:03:11 +02:00
|
|
|
|
2019-06-14 21:15:16 +02:00
|
|
|
def create_netlist(self):
|
|
|
|
|
self.add_modules()
|
|
|
|
|
self.add_pins()
|
|
|
|
|
self.create_instances()
|
|
|
|
|
|
|
|
|
|
def create_layout(self):
|
2020-06-06 00:09:22 +02:00
|
|
|
self.height = self.total_size * self.cell.height
|
2020-05-28 05:03:11 +02:00
|
|
|
self.width = self.cell.width
|
2019-06-20 01:03:21 +02:00
|
|
|
|
2019-07-11 00:56:51 +02:00
|
|
|
self.place_instances()
|
|
|
|
|
self.add_layout_pins()
|
2019-06-14 21:15:16 +02:00
|
|
|
self.add_boundary()
|
|
|
|
|
self.DRC_LVS()
|
|
|
|
|
|
|
|
|
|
def add_pins(self):
|
2020-05-28 05:03:11 +02:00
|
|
|
|
2019-07-25 01:57:04 +02:00
|
|
|
for bl_name in self.cell.get_all_bitline_names():
|
2019-08-06 23:14:09 +02:00
|
|
|
# In the replica column, these are only outputs!
|
2020-06-06 00:09:22 +02:00
|
|
|
self.add_pin("{0}_{1}".format(bl_name, 0), "OUTPUT")
|
2019-07-25 01:57:04 +02:00
|
|
|
|
2019-07-11 00:56:51 +02:00
|
|
|
for row in range(self.total_size):
|
2019-07-25 01:57:04 +02:00
|
|
|
for wl_name in self.cell.get_all_wl_names():
|
2020-06-06 00:09:22 +02:00
|
|
|
self.add_pin("{0}_{1}".format(wl_name, row), "INPUT")
|
2020-05-28 05:03:11 +02:00
|
|
|
|
2019-08-06 23:14:09 +02:00
|
|
|
self.add_pin("vdd", "POWER")
|
|
|
|
|
self.add_pin("gnd", "GROUND")
|
2019-06-14 21:15:16 +02:00
|
|
|
|
|
|
|
|
def add_modules(self):
|
2020-06-06 00:09:22 +02:00
|
|
|
self.replica_cell = factory.create(module_type="replica_{}".format(OPTS.bitcell))
|
2019-06-14 21:15:16 +02:00
|
|
|
self.add_mod(self.replica_cell)
|
2020-06-06 00:09:22 +02:00
|
|
|
self.dummy_cell = factory.create(module_type="dummy_{}".format(OPTS.bitcell))
|
2019-06-20 01:03:21 +02:00
|
|
|
self.add_mod(self.dummy_cell)
|
2020-05-28 05:03:11 +02:00
|
|
|
try:
|
2020-06-06 00:09:22 +02:00
|
|
|
edge_module_type = ("col_cap" if cell_properties.bitcell.end_caps else "dummy")
|
2020-05-28 05:03:11 +02:00
|
|
|
except AttributeError:
|
2020-06-06 00:09:22 +02:00
|
|
|
edge_module_type = "dummy"
|
|
|
|
|
self.edge_cell = factory.create(module_type=edge_module_type + "_" + OPTS.bitcell)
|
2020-05-28 05:03:11 +02:00
|
|
|
self.add_mod(self.edge_cell)
|
2019-06-14 21:15:16 +02:00
|
|
|
# Used for pin names only
|
|
|
|
|
self.cell = factory.create(module_type="bitcell")
|
2020-05-28 05:03:11 +02:00
|
|
|
|
2019-06-14 21:15:16 +02:00
|
|
|
def create_instances(self):
|
2020-05-28 05:03:11 +02:00
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
end_caps_enabled = cell_properties.bitcell.end_caps
|
|
|
|
|
except AttributeError:
|
|
|
|
|
end_caps_enabled = False
|
|
|
|
|
|
2019-06-14 21:15:16 +02:00
|
|
|
self.cell_inst = {}
|
2019-07-11 00:56:51 +02:00
|
|
|
for row in range(self.total_size):
|
2019-06-14 21:15:16 +02:00
|
|
|
name="rbc_{0}".format(row)
|
2019-07-11 00:56:51 +02:00
|
|
|
# Top/bottom cell are always dummy cells.
|
|
|
|
|
# Regular array cells are replica cells (>left_rbl and <rows-right_rbl)
|
2020-05-28 05:03:11 +02:00
|
|
|
# Replic bit specifies which other bit (in the full range (0,rows) to make a replica cell.
|
2020-06-06 00:09:22 +02:00
|
|
|
if (row > self.left_rbl and row < self.total_size - self.right_rbl - 1):
|
2019-07-11 00:56:51 +02:00
|
|
|
self.cell_inst[row]=self.add_inst(name=name,
|
|
|
|
|
mod=self.replica_cell)
|
2020-05-28 05:03:11 +02:00
|
|
|
self.connect_inst(self.get_bitcell_pins(0, row))
|
2019-07-11 00:56:51 +02:00
|
|
|
elif row==self.replica_bit:
|
2019-06-20 01:03:21 +02:00
|
|
|
self.cell_inst[row]=self.add_inst(name=name,
|
|
|
|
|
mod=self.replica_cell)
|
2020-05-28 05:03:11 +02:00
|
|
|
self.connect_inst(self.get_bitcell_pins(0, row))
|
|
|
|
|
elif (row == 0 or row == self.total_size - 1):
|
|
|
|
|
self.cell_inst[row]=self.add_inst(name=name,
|
|
|
|
|
mod=self.edge_cell)
|
|
|
|
|
if end_caps_enabled:
|
|
|
|
|
self.connect_inst(self.get_bitcell_pins_col_cap(0, row))
|
|
|
|
|
else:
|
|
|
|
|
self.connect_inst(self.get_bitcell_pins(0, row))
|
2019-06-20 01:03:21 +02:00
|
|
|
else:
|
|
|
|
|
self.cell_inst[row]=self.add_inst(name=name,
|
|
|
|
|
mod=self.dummy_cell)
|
2020-05-28 05:03:11 +02:00
|
|
|
self.connect_inst(self.get_bitcell_pins(0, row))
|
|
|
|
|
|
2019-06-20 01:03:21 +02:00
|
|
|
def place_instances(self):
|
2020-01-28 11:03:08 +01:00
|
|
|
from tech import cell_properties
|
2019-07-11 00:56:51 +02:00
|
|
|
# Flip the mirrors if we have an odd number of replica+dummy rows at the bottom
|
|
|
|
|
# so that we will start with mirroring rather than not mirroring
|
2020-06-06 00:09:22 +02:00
|
|
|
rbl_offset = (self.left_rbl + 1) %2
|
2020-01-27 17:17:06 +01:00
|
|
|
|
|
|
|
|
# if our bitcells are mirrored on the y axis, check if we are in global
|
|
|
|
|
# column that needs to be flipped.
|
|
|
|
|
dir_y = False
|
|
|
|
|
xoffset = 0
|
|
|
|
|
if cell_properties.bitcell.mirror.y and self.column_offset % 2:
|
|
|
|
|
dir_y = True
|
|
|
|
|
xoffset = self.replica_cell.width
|
|
|
|
|
|
2019-07-11 00:56:51 +02:00
|
|
|
for row in range(self.total_size):
|
2020-06-06 00:09:22 +02:00
|
|
|
# name = "bit_r{0}_{1}".format(row, "rbl")
|
|
|
|
|
dir_x = cell_properties.bitcell.mirror.x and (row + rbl_offset) % 2
|
2020-01-27 17:17:06 +01:00
|
|
|
|
2020-06-06 00:09:22 +02:00
|
|
|
offset = vector(xoffset, self.cell.height * (row + (row + rbl_offset) % 2))
|
2020-01-27 17:17:06 +01:00
|
|
|
|
|
|
|
|
if dir_x and dir_y:
|
|
|
|
|
dir_key = "XY"
|
|
|
|
|
elif dir_x:
|
2019-06-20 01:03:21 +02:00
|
|
|
dir_key = "MX"
|
2020-01-27 17:17:06 +01:00
|
|
|
elif dir_y:
|
|
|
|
|
dir_key = "MY"
|
2019-07-11 00:56:51 +02:00
|
|
|
else:
|
2020-01-27 17:17:06 +01:00
|
|
|
dir_key = ""
|
2019-06-14 21:15:16 +02:00
|
|
|
|
2019-07-11 00:56:51 +02:00
|
|
|
self.cell_inst[row].place(offset=offset,
|
|
|
|
|
mirror=dir_key)
|
2019-06-14 21:15:16 +02:00
|
|
|
|
|
|
|
|
def add_layout_pins(self):
|
|
|
|
|
""" Add the layout pins """
|
2020-05-28 05:03:11 +02:00
|
|
|
|
2019-07-25 01:57:04 +02:00
|
|
|
for bl_name in self.cell.get_all_bitline_names():
|
2020-05-29 22:50:34 +02:00
|
|
|
bl_pin = self.cell_inst[0].get_pin(bl_name)
|
2019-07-25 01:57:04 +02:00
|
|
|
self.add_layout_pin(text=bl_name,
|
2020-05-28 05:03:11 +02:00
|
|
|
layer=bl_pin.layer,
|
2020-06-10 23:58:55 +02:00
|
|
|
offset=bl_pin.ll().scale(1, 0),
|
2019-06-14 21:15:16 +02:00
|
|
|
width=bl_pin.width(),
|
|
|
|
|
height=self.height)
|
|
|
|
|
|
2020-05-29 22:50:34 +02:00
|
|
|
try:
|
|
|
|
|
end_caps_enabled = cell_properties.bitcell.end_caps
|
|
|
|
|
except AttributeError:
|
|
|
|
|
end_caps_enabled = False
|
|
|
|
|
|
|
|
|
|
if end_caps_enabled:
|
|
|
|
|
row_range_max = self.total_size - 1
|
|
|
|
|
row_range_min = 1
|
|
|
|
|
else:
|
|
|
|
|
row_range_max = self.total_size
|
|
|
|
|
row_range_min = 0
|
|
|
|
|
|
|
|
|
|
for row in range(row_range_min, row_range_max):
|
2019-07-25 01:57:04 +02:00
|
|
|
for wl_name in self.cell.get_all_wl_names():
|
|
|
|
|
wl_pin = self.cell_inst[row].get_pin(wl_name)
|
2020-06-06 00:09:22 +02:00
|
|
|
self.add_layout_pin(text="{0}_{1}".format(wl_name, row),
|
2020-05-28 05:03:11 +02:00
|
|
|
layer=wl_pin.layer,
|
2020-06-06 00:09:22 +02:00
|
|
|
offset=wl_pin.ll().scale(0, 1),
|
2019-06-14 21:15:16 +02:00
|
|
|
width=self.width,
|
|
|
|
|
height=wl_pin.height())
|
|
|
|
|
|
2020-06-29 19:03:24 +02:00
|
|
|
# Supplies are only connected in the ends
|
2020-06-30 00:28:55 +02:00
|
|
|
for (index, inst) in self.cell_inst.items():
|
2019-06-14 21:15:16 +02:00
|
|
|
for pin_name in ["vdd", "gnd"]:
|
2020-06-30 00:28:55 +02:00
|
|
|
if inst in [self.cell_inst[0], self.cell_inst[self.total_size - 1]]:
|
|
|
|
|
self.copy_power_pins(inst, pin_name)
|
|
|
|
|
else:
|
2020-06-25 23:03:59 +02:00
|
|
|
self.copy_layout_pin(inst, pin_name)
|
2019-06-14 21:15:16 +02:00
|
|
|
|
2019-07-15 20:29:29 +02:00
|
|
|
def get_bitcell_pins(self, col, row):
|
2020-05-28 05:03:11 +02:00
|
|
|
""" Creates a list of connections in the bitcell,
|
2019-06-14 21:15:16 +02:00
|
|
|
indexed by column and row, for instance use in bitcell_array """
|
|
|
|
|
|
|
|
|
|
bitcell_pins = []
|
2020-05-28 05:03:11 +02:00
|
|
|
|
2019-07-15 20:29:29 +02:00
|
|
|
pin_names = self.cell.get_all_bitline_names()
|
2019-06-14 21:15:16 +02:00
|
|
|
for pin in pin_names:
|
2020-06-06 00:09:22 +02:00
|
|
|
bitcell_pins.append(pin + "_{0}".format(col))
|
2019-07-15 20:29:29 +02:00
|
|
|
pin_names = self.cell.get_all_wl_names()
|
2019-06-14 21:15:16 +02:00
|
|
|
for pin in pin_names:
|
2020-06-06 00:09:22 +02:00
|
|
|
bitcell_pins.append(pin + "_{0}".format(row))
|
2019-06-14 21:15:16 +02:00
|
|
|
bitcell_pins.append("vdd")
|
|
|
|
|
bitcell_pins.append("gnd")
|
2020-05-28 05:03:11 +02:00
|
|
|
|
2019-06-14 21:15:16 +02:00
|
|
|
return bitcell_pins
|
2020-05-28 05:03:11 +02:00
|
|
|
|
|
|
|
|
def get_bitcell_pins_col_cap(self, col, row):
|
|
|
|
|
""" Creates a list of connections in the bitcell,
|
|
|
|
|
indexed by column and row, for instance use in bitcell_array """
|
|
|
|
|
|
|
|
|
|
bitcell_pins = []
|
|
|
|
|
|
|
|
|
|
pin_names = self.cell.get_all_bitline_names()
|
|
|
|
|
for pin in pin_names:
|
2020-06-06 00:09:22 +02:00
|
|
|
bitcell_pins.append(pin + "_{0}".format(col))
|
2020-05-28 05:03:11 +02:00
|
|
|
bitcell_pins.append("vdd")
|
|
|
|
|
|
|
|
|
|
return bitcell_pins
|
|
|
|
|
|
2019-07-31 05:31:32 +02:00
|
|
|
def exclude_all_but_replica(self):
|
|
|
|
|
"""Excludes all bits except the replica cell (self.replica_bit)."""
|
2020-05-28 05:03:11 +02:00
|
|
|
|
2019-07-17 08:47:34 +02:00
|
|
|
for row, cell in self.cell_inst.items():
|
2019-07-31 05:31:32 +02:00
|
|
|
if row != self.replica_bit:
|
|
|
|
|
self.graph_inst_exclude.add(cell)
|