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