2019-06-14 12:15:16 -07:00
|
|
|
# See LICENSE for licensing information.
|
|
|
|
|
#
|
2024-01-03 14:32:44 -08:00
|
|
|
# Copyright (c) 2016-2024 Regents of the University of California, Santa Cruz
|
2019-06-14 12:15:16 -07:00
|
|
|
# All rights reserved.
|
|
|
|
|
#
|
2022-11-27 13:01:20 -08:00
|
|
|
from openram import debug
|
|
|
|
|
from openram.base import vector
|
|
|
|
|
from openram.sram_factory import factory
|
|
|
|
|
from openram.tech import layer_properties as layer_props
|
|
|
|
|
from openram import OPTS
|
2022-07-13 10:57:56 -07:00
|
|
|
from .bitcell_base_array import bitcell_base_array
|
2023-08-02 15:19:48 -07:00
|
|
|
from openram.base import geometry
|
|
|
|
|
from openram.modules import pattern
|
2020-06-05 15:09:22 -07:00
|
|
|
|
2020-09-10 12:04:46 -07:00
|
|
|
class replica_column(bitcell_base_array):
|
2019-06-14 12:15:16 -07:00
|
|
|
"""
|
|
|
|
|
Generate a replica bitline column for the replica array.
|
2020-11-20 16:56:07 -08:00
|
|
|
Rows is the total number of rows in the main array.
|
2020-08-18 08:56:24 -07:00
|
|
|
rbl is a tuple with the number of left and right replica bitlines.
|
2020-05-27 20:03:11 -07:00
|
|
|
Replica bit specifies which replica column this is (to determine where to put the
|
2020-08-18 08:56:24 -07:00
|
|
|
replica cell relative to the bottom (including the dummy bit at 0).
|
2019-06-14 12:15:16 -07:00
|
|
|
"""
|
|
|
|
|
|
2020-08-18 08:56:24 -07:00
|
|
|
def __init__(self, name, rows, rbl, replica_bit, column_offset=0):
|
2020-11-20 16:56:07 -08:00
|
|
|
# Used for pin names and properties
|
|
|
|
|
self.cell = factory.create(module_type=OPTS.bitcell)
|
|
|
|
|
# Row size is the number of rows with word lines
|
|
|
|
|
self.row_size = sum(rbl) + rows
|
|
|
|
|
# Start of regular word line rows
|
2022-09-26 14:23:09 -07:00
|
|
|
self.row_start = rbl[0]
|
2020-11-20 16:56:07 -08:00
|
|
|
# End of regular word line rows
|
|
|
|
|
self.row_end = self.row_start + rows
|
2026-04-14 14:48:26 -07:00
|
|
|
super().__init__(rows=self.row_size, cols=1, column_offset=column_offset, row_offset=0, name=name)
|
2019-06-14 12:15:16 -07:00
|
|
|
|
2019-07-10 15:56:51 -07:00
|
|
|
self.rows = rows
|
2020-08-18 08:56:24 -07:00
|
|
|
self.left_rbl = rbl[0]
|
|
|
|
|
self.right_rbl = rbl[1]
|
2019-07-10 15:56:51 -07:00
|
|
|
self.replica_bit = replica_bit
|
2021-11-22 10:51:40 -08:00
|
|
|
|
2022-09-26 14:23:09 -07:00
|
|
|
# Total size includes the replica rows
|
|
|
|
|
self.total_size = self.left_rbl + rows + self.right_rbl
|
2020-11-03 06:29:17 -08:00
|
|
|
|
2020-01-27 17:17:06 +01:00
|
|
|
self.column_offset = column_offset
|
2020-05-27 20:03:11 -07:00
|
|
|
|
2020-11-20 16:56:07 -08:00
|
|
|
debug.check(replica_bit < self.row_start or replica_bit >= self.row_end,
|
2020-05-27 20:03:11 -07:00
|
|
|
"Replica bit cannot be in the regular array.")
|
2022-09-26 14:23:09 -07:00
|
|
|
|
2023-08-24 02:55:45 -07:00
|
|
|
#if layer_props.replica_column.even_rows:
|
|
|
|
|
# debug.check(rows % 2 == 0 and (self.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 12:15:16 -07:00
|
|
|
|
|
|
|
|
self.create_netlist()
|
|
|
|
|
if not OPTS.netlist_only:
|
|
|
|
|
self.create_layout()
|
2020-05-27 20:03:11 -07:00
|
|
|
|
2019-06-14 12:15:16 -07:00
|
|
|
def create_netlist(self):
|
|
|
|
|
self.add_modules()
|
|
|
|
|
self.add_pins()
|
|
|
|
|
self.create_instances()
|
|
|
|
|
|
|
|
|
|
def create_layout(self):
|
2023-08-02 15:19:48 -07:00
|
|
|
self.place_array()
|
2020-11-20 16:56:07 -08:00
|
|
|
|
2019-07-10 15:56:51 -07:00
|
|
|
self.add_layout_pins()
|
2020-11-20 16:56:07 -08:00
|
|
|
|
2022-04-05 13:51:55 -07:00
|
|
|
self.route_supplies()
|
|
|
|
|
|
2019-06-14 12:15:16 -07:00
|
|
|
self.add_boundary()
|
|
|
|
|
self.DRC_LVS()
|
|
|
|
|
|
|
|
|
|
def add_pins(self):
|
2020-08-21 13:44:35 -07:00
|
|
|
|
2020-09-10 12:04:46 -07:00
|
|
|
self.create_all_bitline_names()
|
2020-11-20 16:56:07 -08:00
|
|
|
self.create_all_wordline_names(self.row_size)
|
2020-10-08 14:53:44 -07:00
|
|
|
|
2020-08-21 13:44:35 -07:00
|
|
|
self.add_pin_list(self.all_bitline_names, "OUTPUT")
|
|
|
|
|
self.add_pin_list(self.all_wordline_names, "INPUT")
|
2020-05-27 20:03:11 -07:00
|
|
|
|
2019-08-06 14:14:09 -07:00
|
|
|
self.add_pin("vdd", "POWER")
|
|
|
|
|
self.add_pin("gnd", "GROUND")
|
2019-06-14 12:15:16 -07:00
|
|
|
|
|
|
|
|
def add_modules(self):
|
2020-11-02 16:00:16 -08:00
|
|
|
self.replica_cell = factory.create(module_type=OPTS.replica_bitcell)
|
2021-11-22 10:51:40 -08:00
|
|
|
|
2020-11-02 16:00:16 -08:00
|
|
|
self.dummy_cell = factory.create(module_type=OPTS.dummy_bitcell)
|
2021-11-22 10:51:40 -08:00
|
|
|
|
2020-09-23 04:51:09 -07:00
|
|
|
def create_instances(self):
|
2023-08-02 15:19:48 -07:00
|
|
|
self.cell_inst = {}
|
2023-08-03 00:42:42 -07:00
|
|
|
core_block = [[0 for x in range(1)] for y in range(self.total_size)]
|
2020-11-03 06:29:17 -08:00
|
|
|
|
2023-08-02 15:19:48 -07:00
|
|
|
current_row = self.row_start
|
2020-10-13 04:48:10 -07:00
|
|
|
for row in range(self.total_size):
|
2020-11-20 16:56:07 -08:00
|
|
|
# Regular array cells are replica cells
|
|
|
|
|
# Replic bit specifies which other bit (in the full range (0,total_size) to make a replica cell.
|
2022-09-26 14:23:09 -07:00
|
|
|
# All other cells are dummies
|
2026-04-27 17:24:13 -07:00
|
|
|
|
2022-09-26 14:23:09 -07:00
|
|
|
if (row == self.replica_bit) or (row >= self.row_start and row < self.row_end):
|
2026-04-14 14:48:26 -07:00
|
|
|
if current_row % 2 == 0:
|
2026-04-27 17:24:13 -07:00
|
|
|
core_block[row][0] = geometry.instance("rbc_{}".format(row), mod=self.replica_cell, is_bitcell=True, mirror='MY')
|
2026-04-22 01:33:47 -07:00
|
|
|
else:
|
2026-04-27 17:24:13 -07:00
|
|
|
core_block[row][0] = geometry.instance("rbc_{}".format(row), mod=self.replica_cell, is_bitcell=True, mirror='XY')
|
2020-10-13 04:48:10 -07:00
|
|
|
else:
|
2026-04-14 14:48:26 -07:00
|
|
|
if current_row % 2 == 0:
|
2026-04-27 17:24:13 -07:00
|
|
|
core_block[row][0] = geometry.instance("rbc_{}".format(row), mod=self.dummy_cell, is_bitcell=True, mirror='MY')
|
2026-04-22 01:33:47 -07:00
|
|
|
else:
|
2026-04-27 17:24:13 -07:00
|
|
|
core_block[row][0] = geometry.instance("rbc_{}".format(row), mod=self.dummy_cell, is_bitcell=True, mirror='XY')
|
2020-09-23 06:24:52 -07:00
|
|
|
|
2023-08-02 15:19:48 -07:00
|
|
|
current_row += 1
|
2026-04-27 17:24:13 -07:00
|
|
|
|
2026-05-07 14:18:58 -07:00
|
|
|
if not self.cell.mirror.y or self.column_offset % 2 == 0:
|
2022-09-26 14:23:09 -07:00
|
|
|
for row in range(self.total_size):
|
2026-04-27 17:24:13 -07:00
|
|
|
if core_block[row][0].mirror=='MY':
|
|
|
|
|
core_block[row][0].mirror=''
|
2026-05-07 14:18:58 -07:00
|
|
|
elif core_block[row][0].mirror=='XY':
|
2026-04-27 17:24:13 -07:00
|
|
|
core_block[row][0].mirror='MX'
|
|
|
|
|
|
2026-05-07 14:18:58 -07:00
|
|
|
|
2023-08-03 16:24:24 -07:00
|
|
|
self.pattern = pattern(self, "bitcell_array", core_block, num_rows=self.total_size, num_cols=self.column_size, name_template="rbc_r{0}_c{1}")
|
2023-08-02 15:19:48 -07:00
|
|
|
self.pattern.connect_array()
|
2020-05-27 20:03:11 -07:00
|
|
|
|
2020-07-23 14:43:14 -07:00
|
|
|
def get_bitcell_pins_col_cap(self, row, col):
|
2020-11-03 06:29:17 -08:00
|
|
|
"""
|
2020-09-29 10:26:31 -07:00
|
|
|
Creates a list of connections in the bitcell,
|
|
|
|
|
indexed by column and row, for instance use in bitcell_array
|
|
|
|
|
"""
|
2020-05-27 20:03:11 -07:00
|
|
|
bitcell_pins = []
|
2020-08-25 14:51:49 -07:00
|
|
|
for port in self.all_ports:
|
|
|
|
|
bitcell_pins.extend([x for x in self.get_bitline_names(port) if x.endswith("_{0}".format(col))])
|
2020-10-06 16:27:02 -07:00
|
|
|
if len(self.edge_cell.get_pins("vdd")) > 0:
|
|
|
|
|
bitcell_pins.append("vdd")
|
|
|
|
|
if len(self.edge_cell.get_pins("gnd")) > 0:
|
|
|
|
|
bitcell_pins.append("gnd")
|
2020-05-27 20:03:11 -07:00
|
|
|
|
|
|
|
|
return bitcell_pins
|
|
|
|
|
|
2019-07-30 20:31:32 -07:00
|
|
|
def exclude_all_but_replica(self):
|
2020-09-29 10:26:31 -07:00
|
|
|
"""
|
|
|
|
|
Excludes all bits except the replica cell (self.replica_bit).
|
|
|
|
|
"""
|
2020-05-27 20:03:11 -07:00
|
|
|
|
2020-11-20 17:33:15 -08:00
|
|
|
for row, cell in enumerate(self.cell_inst):
|
2019-07-30 20:31:32 -07:00
|
|
|
if row != self.replica_bit:
|
2023-08-10 00:34:16 -07:00
|
|
|
self.graph_inst_exclude.add(self.cell_inst[cell])
|