2019-04-26 21:21:50 +02:00
|
|
|
# See LICENSE for licensing information.
|
|
|
|
|
#
|
2019-06-14 17:43:41 +02:00
|
|
|
# Copyright (c) 2016-2019 Regents of the University of California and The Board
|
|
|
|
|
# of Regents for the Oklahoma Agricultural and Mechanical College
|
|
|
|
|
# (acting for and on behalf of Oklahoma State University)
|
|
|
|
|
# All rights reserved.
|
2019-04-26 21:21:50 +02:00
|
|
|
#
|
2018-07-12 19:30:45 +02:00
|
|
|
import datetime
|
|
|
|
|
import debug
|
2020-09-28 18:53:01 +02:00
|
|
|
from math import log, ceil
|
2018-08-31 21:03:28 +02:00
|
|
|
from importlib import reload
|
2018-07-12 19:30:45 +02:00
|
|
|
from vector import vector
|
|
|
|
|
from globals import OPTS, print_time
|
|
|
|
|
from design import design
|
2019-01-11 23:15:16 +01:00
|
|
|
from verilog import verilog
|
|
|
|
|
from lef import lef
|
2019-01-17 01:15:38 +01:00
|
|
|
from sram_factory import factory
|
2019-01-11 23:15:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class sram_base(design, verilog, lef):
|
2018-07-12 19:30:45 +02:00
|
|
|
"""
|
|
|
|
|
Dynamically generated SRAM by connecting banks to control logic. The
|
|
|
|
|
number of banks should be 1 , 2 or 4
|
|
|
|
|
"""
|
2018-09-04 19:47:24 +02:00
|
|
|
def __init__(self, name, sram_config):
|
2018-07-12 19:30:45 +02:00
|
|
|
design.__init__(self, name)
|
2019-12-17 20:03:36 +01:00
|
|
|
lef.__init__(self, ["m1", "m2", "m3", "m4"])
|
2019-01-11 23:15:16 +01:00
|
|
|
verilog.__init__(self)
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-09-04 19:47:24 +02:00
|
|
|
self.sram_config = sram_config
|
|
|
|
|
sram_config.set_local_config(self)
|
2018-07-12 19:30:45 +02:00
|
|
|
|
2018-09-04 19:47:24 +02:00
|
|
|
self.bank_insts = []
|
2019-07-19 23:58:37 +02:00
|
|
|
|
2019-08-21 23:29:57 +02:00
|
|
|
if self.write_size:
|
2020-09-28 18:53:01 +02:00
|
|
|
self.num_wmasks = int(ceil(self.word_size / self.write_size))
|
2019-07-19 23:58:37 +02:00
|
|
|
else:
|
|
|
|
|
self.num_wmasks = 0
|
|
|
|
|
|
2020-05-14 12:30:29 +02:00
|
|
|
if not self.num_spare_cols:
|
|
|
|
|
self.num_spare_cols = 0
|
|
|
|
|
|
2018-07-12 19:30:45 +02:00
|
|
|
def add_pins(self):
|
|
|
|
|
""" Add pins for entire SRAM. """
|
2019-07-19 23:58:37 +02:00
|
|
|
|
2018-11-08 21:19:40 +01:00
|
|
|
for port in self.write_ports:
|
2020-05-14 12:30:29 +02:00
|
|
|
for bit in range(self.word_size + self.num_spare_cols):
|
2020-03-06 01:27:35 +01:00
|
|
|
self.add_pin("din{0}[{1}]".format(port, bit), "INPUT")
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-11-08 21:19:40 +01:00
|
|
|
for port in self.all_ports:
|
2018-09-04 02:44:32 +02:00
|
|
|
for bit in range(self.addr_size):
|
2020-03-06 01:27:35 +01:00
|
|
|
self.add_pin("addr{0}[{1}]".format(port, bit), "INPUT")
|
2018-07-12 19:30:45 +02:00
|
|
|
|
2018-09-27 04:10:24 +02:00
|
|
|
# These are used to create the physical pins
|
|
|
|
|
self.control_logic_inputs = []
|
|
|
|
|
self.control_logic_outputs = []
|
2018-11-08 21:19:40 +01:00
|
|
|
for port in self.all_ports:
|
|
|
|
|
if port in self.readwrite_ports:
|
2018-09-27 04:10:24 +02:00
|
|
|
self.control_logic_inputs.append(self.control_logic_rw.get_inputs())
|
|
|
|
|
self.control_logic_outputs.append(self.control_logic_rw.get_outputs())
|
2018-11-08 21:19:40 +01:00
|
|
|
elif port in self.write_ports:
|
2018-09-27 04:10:24 +02:00
|
|
|
self.control_logic_inputs.append(self.control_logic_w.get_inputs())
|
|
|
|
|
self.control_logic_outputs.append(self.control_logic_w.get_outputs())
|
|
|
|
|
else:
|
|
|
|
|
self.control_logic_inputs.append(self.control_logic_r.get_inputs())
|
|
|
|
|
self.control_logic_outputs.append(self.control_logic_r.get_outputs())
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-11-08 21:19:40 +01:00
|
|
|
for port in self.all_ports:
|
2020-03-06 01:27:35 +01:00
|
|
|
self.add_pin("csb{}".format(port), "INPUT")
|
2018-11-08 21:19:40 +01:00
|
|
|
for port in self.readwrite_ports:
|
2020-03-06 01:27:35 +01:00
|
|
|
self.add_pin("web{}".format(port), "INPUT")
|
2018-11-08 21:19:40 +01:00
|
|
|
for port in self.all_ports:
|
2020-03-06 01:27:35 +01:00
|
|
|
self.add_pin("clk{}".format(port), "INPUT")
|
2019-06-29 00:43:09 +02:00
|
|
|
# add the optional write mask pins
|
2019-07-19 23:58:37 +02:00
|
|
|
for port in self.write_ports:
|
|
|
|
|
for bit in range(self.num_wmasks):
|
2020-03-06 01:27:35 +01:00
|
|
|
self.add_pin("wmask{0}[{1}]".format(port, bit), "INPUT")
|
2020-05-14 12:30:29 +02:00
|
|
|
for bit in range(self.num_spare_cols):
|
|
|
|
|
self.add_pin("spare_wen{0}[{1}]".format(port, bit), "INPUT")
|
2018-11-08 21:19:40 +01:00
|
|
|
for port in self.read_ports:
|
2020-05-14 12:30:29 +02:00
|
|
|
for bit in range(self.word_size + self.num_spare_cols):
|
2020-03-06 01:27:35 +01:00
|
|
|
self.add_pin("dout{0}[{1}]".format(port, bit), "OUTPUT")
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-10-01 20:10:18 +02:00
|
|
|
self.add_pin("vdd", "POWER")
|
|
|
|
|
self.add_pin("gnd", "GROUND")
|
2018-07-12 19:30:45 +02:00
|
|
|
|
2019-12-18 12:03:13 +01:00
|
|
|
def add_global_pex_labels(self):
|
|
|
|
|
"""
|
|
|
|
|
Add pex labels at the sram level for spice analysis
|
|
|
|
|
"""
|
|
|
|
|
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-10-01 20:10:18 +02:00
|
|
|
|
2020-01-20 13:16:30 +01:00
|
|
|
# add pex labels for bitcells
|
|
|
|
|
for bank_num in range(len(self.bank_insts)):
|
2019-12-18 12:03:13 +01:00
|
|
|
bank = self.bank_insts[bank_num]
|
2020-10-02 22:32:52 +02:00
|
|
|
pex_data = bank.reverse_transformation_bitcell(self.bitcell.name)
|
2020-01-28 01:28:55 +01:00
|
|
|
|
|
|
|
|
bank_offset = pex_data[0] # offset bank relative to sram
|
|
|
|
|
Q_offset = pex_data[1] # offset of storage relative to bank
|
|
|
|
|
Q_bar_offset = pex_data[2] # offset of storage relative to bank
|
|
|
|
|
bl_offsets = pex_data[3]
|
|
|
|
|
br_offsets = pex_data[4]
|
|
|
|
|
bl_meta = pex_data[5]
|
|
|
|
|
br_meta = pex_data[6]
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-01-24 11:24:29 +01:00
|
|
|
bl = []
|
|
|
|
|
br = []
|
|
|
|
|
|
2020-10-02 22:32:52 +02:00
|
|
|
storage_layer_name = "m1"
|
2020-10-01 20:10:18 +02:00
|
|
|
bitline_layer_name = self.bitcell.get_pin("bl").layer
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-01-27 11:03:31 +01:00
|
|
|
for cell in range(len(bank_offset)):
|
2020-10-01 20:10:18 +02:00
|
|
|
Q = [bank_offset[cell][0] + Q_offset[cell][0],
|
|
|
|
|
bank_offset[cell][1] + Q_offset[cell][1]]
|
|
|
|
|
Q_bar = [bank_offset[cell][0] + Q_bar_offset[cell][0],
|
|
|
|
|
bank_offset[cell][1] + Q_bar_offset[cell][1]]
|
2020-05-04 12:05:33 +02:00
|
|
|
OPTS.words_per_row = self.words_per_row
|
2020-10-01 20:10:18 +02:00
|
|
|
row = int(cell % (OPTS.num_words / self.words_per_row))
|
|
|
|
|
col = int(cell / (OPTS.num_words))
|
|
|
|
|
self.add_layout_pin_rect_center("bitcell_Q_b{}_r{}_c{}".format(bank_num,
|
|
|
|
|
row,
|
|
|
|
|
col),
|
|
|
|
|
storage_layer_name,
|
|
|
|
|
Q)
|
|
|
|
|
self.add_layout_pin_rect_center("bitcell_Q_bar_b{}_r{}_c{}".format(bank_num,
|
|
|
|
|
row,
|
|
|
|
|
col),
|
|
|
|
|
storage_layer_name,
|
|
|
|
|
Q_bar)
|
2020-08-04 02:14:34 +02:00
|
|
|
|
2020-01-28 01:28:55 +01:00
|
|
|
for cell in range(len(bl_offsets)):
|
|
|
|
|
col = bl_meta[cell][0][2]
|
2020-01-27 11:03:31 +01:00
|
|
|
for bitline in range(len(bl_offsets[cell])):
|
2020-10-01 20:10:18 +02:00
|
|
|
bitline_location = [float(bank_offset[cell][0]) + bl_offsets[cell][bitline][0],
|
|
|
|
|
float(bank_offset[cell][1]) + bl_offsets[cell][bitline][1]]
|
2020-01-28 01:28:55 +01:00
|
|
|
bl.append([bitline_location, bl_meta[cell][bitline][3], col])
|
2020-01-27 11:03:31 +01:00
|
|
|
|
2020-01-28 01:28:55 +01:00
|
|
|
for cell in range(len(br_offsets)):
|
|
|
|
|
col = br_meta[cell][0][2]
|
|
|
|
|
for bitline in range(len(br_offsets[cell])):
|
2020-10-01 20:10:18 +02:00
|
|
|
bitline_location = [float(bank_offset[cell][0]) + br_offsets[cell][bitline][0],
|
|
|
|
|
float(bank_offset[cell][1]) + br_offsets[cell][bitline][1]]
|
|
|
|
|
br.append([bitline_location, br_meta[cell][bitline][3], col])
|
2020-01-28 01:28:55 +01:00
|
|
|
|
|
|
|
|
for i in range(len(bl)):
|
2020-10-01 20:10:18 +02:00
|
|
|
self.add_layout_pin_rect_center("bl{0}_{1}".format(bl[i][1], bl[i][2]),
|
|
|
|
|
bitline_layer_name, bl[i][0])
|
2020-01-28 01:28:55 +01:00
|
|
|
|
|
|
|
|
for i in range(len(br)):
|
2020-10-01 20:10:18 +02:00
|
|
|
self.add_layout_pin_rect_center("br{0}_{1}".format(br[i][1], br[i][2]),
|
|
|
|
|
bitline_layer_name, br[i][0])
|
2019-12-18 12:03:13 +01:00
|
|
|
|
|
|
|
|
# add pex labels for control logic
|
2020-10-01 20:10:18 +02:00
|
|
|
for i in range(len(self.control_logic_insts)):
|
2019-12-18 13:45:12 +01:00
|
|
|
instance = self.control_logic_insts[i]
|
|
|
|
|
control_logic_offset = instance.offset
|
|
|
|
|
for output in instance.mod.output_list:
|
|
|
|
|
pin = instance.mod.get_pin(output)
|
2020-10-01 20:10:18 +02:00
|
|
|
pin.transform([0, 0], instance.mirror, instance.rotate)
|
|
|
|
|
offset = [control_logic_offset[0] + pin.center()[0],
|
|
|
|
|
control_logic_offset[1] + pin.center()[1]]
|
|
|
|
|
self.add_layout_pin_rect_center("{0}{1}".format(pin.name, i),
|
|
|
|
|
storage_layer_name,
|
|
|
|
|
offset)
|
2018-07-12 19:30:45 +02:00
|
|
|
|
2018-08-27 23:18:32 +02:00
|
|
|
def create_netlist(self):
|
2018-08-28 01:42:48 +02:00
|
|
|
""" Netlist creation """
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-03-06 18:03:52 +01:00
|
|
|
start_time = datetime.datetime.now()
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-08-28 01:42:48 +02:00
|
|
|
# Must create the control logic before pins to get the pins
|
2018-08-27 23:18:32 +02:00
|
|
|
self.add_modules()
|
|
|
|
|
self.add_pins()
|
2018-12-05 18:51:17 +01:00
|
|
|
self.create_modules()
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-08-28 01:42:48 +02:00
|
|
|
# This is for the lib file if we don't create layout
|
|
|
|
|
self.width=0
|
|
|
|
|
self.height=0
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-12-05 18:51:17 +01:00
|
|
|
if not OPTS.is_unit_test:
|
2020-03-06 18:03:52 +01:00
|
|
|
print_time("Submodules", datetime.datetime.now(), start_time)
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-07-12 19:30:45 +02:00
|
|
|
def create_layout(self):
|
2020-03-06 01:27:35 +01:00
|
|
|
""" Layout creation """
|
2020-03-06 18:03:52 +01:00
|
|
|
start_time = datetime.datetime.now()
|
2018-11-15 02:05:23 +01:00
|
|
|
self.place_instances()
|
2018-12-05 18:51:17 +01:00
|
|
|
if not OPTS.is_unit_test:
|
2020-03-06 18:03:52 +01:00
|
|
|
print_time("Placement", datetime.datetime.now(), start_time)
|
2018-11-15 02:05:23 +01:00
|
|
|
|
2020-03-06 18:03:52 +01:00
|
|
|
start_time = datetime.datetime.now()
|
2018-11-15 02:05:23 +01:00
|
|
|
self.route_layout()
|
2020-12-23 00:56:51 +01:00
|
|
|
|
2018-12-05 18:51:17 +01:00
|
|
|
if not OPTS.is_unit_test:
|
2020-03-06 18:03:52 +01:00
|
|
|
print_time("Routing", datetime.datetime.now(), start_time)
|
2018-10-06 23:03:00 +02:00
|
|
|
|
2018-07-18 23:29:04 +02:00
|
|
|
self.add_lvs_correspondence_points()
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-12-23 02:08:53 +01:00
|
|
|
#self.offset_all_coordinates()
|
2018-10-06 23:03:00 +02:00
|
|
|
|
2018-08-28 01:42:48 +02:00
|
|
|
highest_coord = self.find_highest_coords()
|
2019-09-05 01:41:27 +02:00
|
|
|
self.width = highest_coord[0]
|
|
|
|
|
self.height = highest_coord[1]
|
2020-01-24 11:24:29 +01:00
|
|
|
if OPTS.use_pex:
|
|
|
|
|
self.add_global_pex_labels()
|
2020-06-14 23:17:35 +02:00
|
|
|
self.add_boundary(ll=vector(0, 0),
|
|
|
|
|
ur=vector(self.width, self.height))
|
2019-12-18 12:03:13 +01:00
|
|
|
|
2020-03-06 18:03:52 +01:00
|
|
|
start_time = datetime.datetime.now()
|
2018-12-05 18:51:17 +01:00
|
|
|
if not OPTS.is_unit_test:
|
2020-12-15 19:46:55 +01:00
|
|
|
# We only enable final verification if we have routed the design
|
|
|
|
|
# Only run this if not a unit test, because unit test will also verify it.
|
|
|
|
|
self.DRC_LVS(final_verification=OPTS.route_supplies, force_check=OPTS.check_lvsdrc)
|
2020-03-06 18:03:52 +01:00
|
|
|
print_time("Verification", datetime.datetime.now(), start_time)
|
2018-08-28 01:42:48 +02:00
|
|
|
|
2018-12-05 18:51:17 +01:00
|
|
|
def create_modules(self):
|
2020-03-06 01:27:35 +01:00
|
|
|
debug.error("Must override pure virtual function.", -1)
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-10-11 00:15:58 +02:00
|
|
|
def route_supplies(self):
|
2018-10-06 17:30:38 +02:00
|
|
|
""" Route the supply grid and connect the pins to them. """
|
2018-10-08 18:56:39 +02:00
|
|
|
|
2019-05-28 01:38:47 +02:00
|
|
|
# Copy the pins to the top level
|
|
|
|
|
# This will either be used to route or left unconnected.
|
2020-12-18 20:09:10 +01:00
|
|
|
for pin_name in ["vdd", "gnd"]:
|
|
|
|
|
for inst in self.insts:
|
|
|
|
|
self.copy_power_pins(inst, pin_name)
|
2020-06-14 23:17:35 +02:00
|
|
|
|
2019-04-01 18:58:59 +02:00
|
|
|
if not OPTS.route_supplies:
|
2019-05-28 02:38:59 +02:00
|
|
|
# Do not route the power supply (leave as must-connect pins)
|
2019-04-01 18:58:59 +02:00
|
|
|
return
|
2019-07-12 19:34:29 +02:00
|
|
|
|
2020-01-28 11:53:36 +01:00
|
|
|
try:
|
|
|
|
|
from tech import power_grid
|
|
|
|
|
grid_stack = power_grid
|
|
|
|
|
except ImportError:
|
|
|
|
|
# if no power_grid is specified by tech we use sensible defaults
|
2020-12-17 01:42:19 +01:00
|
|
|
# Route a M3/M4 grid
|
|
|
|
|
grid_stack = self.m3_stack
|
|
|
|
|
|
|
|
|
|
if OPTS.route_supplies == "grid":
|
|
|
|
|
from supply_grid_router import supply_grid_router as router
|
|
|
|
|
elif OPTS.route_supplies:
|
|
|
|
|
from supply_tree_router import supply_tree_router as router
|
|
|
|
|
|
2020-01-28 11:53:36 +01:00
|
|
|
rtr=router(grid_stack, self)
|
2018-10-06 17:30:38 +02:00
|
|
|
rtr.route()
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-12-21 22:47:05 +01:00
|
|
|
# Find the lowest leftest pin for vdd and gnd
|
|
|
|
|
for pin_name in ["vdd", "gnd"]:
|
|
|
|
|
# Copy the pin shape to rectangles
|
|
|
|
|
for pin in self.get_pins(pin_name):
|
|
|
|
|
self.add_rect(pin.layer,
|
|
|
|
|
pin.ll(),
|
|
|
|
|
pin.width(),
|
|
|
|
|
pin.height())
|
|
|
|
|
# Remove the pins
|
2020-12-18 20:09:10 +01:00
|
|
|
self.remove_layout_pin(pin_name)
|
2020-12-21 22:47:05 +01:00
|
|
|
|
|
|
|
|
pin = rtr.get_pin(pin_name)
|
|
|
|
|
|
2020-12-18 20:09:10 +01:00
|
|
|
self.add_layout_pin(pin_name,
|
|
|
|
|
pin.layer,
|
|
|
|
|
pin.ll(),
|
|
|
|
|
pin.width(),
|
|
|
|
|
pin.height())
|
|
|
|
|
|
2021-01-15 22:25:57 +01:00
|
|
|
def route_escape_pins(self):
|
|
|
|
|
"""
|
|
|
|
|
Add the top-level pins for a single bank SRAM with control.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
# List of pin to new pin name
|
|
|
|
|
pins_to_route = []
|
|
|
|
|
for port in self.all_ports:
|
|
|
|
|
# Connect the control pins as inputs
|
|
|
|
|
for signal in self.control_logic_inputs[port]:
|
|
|
|
|
if signal.startswith("rbl"):
|
|
|
|
|
continue
|
|
|
|
|
if signal=="clk":
|
|
|
|
|
pins_to_route.append("{0}{1}".format(signal, port))
|
|
|
|
|
else:
|
|
|
|
|
pins_to_route.append("{0}{1}".format(signal, port))
|
|
|
|
|
|
|
|
|
|
if port in self.write_ports:
|
|
|
|
|
for bit in range(self.word_size + self.num_spare_cols):
|
|
|
|
|
pins_to_route.append("din{0}[{1}]".format(port, bit))
|
|
|
|
|
|
|
|
|
|
if port in self.readwrite_ports or port in self.read_ports:
|
|
|
|
|
for bit in range(self.word_size + self.num_spare_cols):
|
|
|
|
|
pins_to_route.append("dout{0}[{1}]".format(port, bit))
|
|
|
|
|
|
|
|
|
|
for bit in range(self.col_addr_size):
|
|
|
|
|
pins_to_route.append("addr{0}[{1}]".format(port, bit))
|
|
|
|
|
|
|
|
|
|
for bit in range(self.row_addr_size):
|
|
|
|
|
pins_to_route.append("addr{0}[{1}]".format(port, bit + self.col_addr_size))
|
|
|
|
|
|
|
|
|
|
if port in self.write_ports:
|
|
|
|
|
if self.write_size:
|
|
|
|
|
for bit in range(self.num_wmasks):
|
|
|
|
|
pins_to_route.append("wmask{0}[{1}]".format(port, bit))
|
|
|
|
|
|
|
|
|
|
if port in self.write_ports:
|
|
|
|
|
for bit in range(self.num_spare_cols):
|
|
|
|
|
pins_to_route.append("spare_wen{0}[{1}]".format(port, bit))
|
|
|
|
|
|
|
|
|
|
from signal_escape_router import signal_escape_router as router
|
|
|
|
|
rtr=router(self.m3_stack, self)
|
|
|
|
|
rtr.escape_route(pins_to_route)
|
|
|
|
|
|
2018-07-12 19:30:45 +02:00
|
|
|
def compute_bus_sizes(self):
|
|
|
|
|
""" Compute the independent bus widths shared between two and four bank SRAMs """
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-07-12 19:30:45 +02:00
|
|
|
# address size + control signals + one-hot bank select signals
|
2020-03-06 01:27:35 +01:00
|
|
|
self.num_vertical_line = self.addr_size + self.control_size + log(self.num_banks, 2) + 1
|
2018-07-12 19:30:45 +02:00
|
|
|
# data bus size
|
|
|
|
|
self.num_horizontal_line = self.word_size
|
|
|
|
|
|
2020-03-06 01:27:35 +01:00
|
|
|
self.vertical_bus_width = self.m2_pitch * self.num_vertical_line
|
2018-07-12 19:30:45 +02:00
|
|
|
# vertical bus height depends on 2 or 4 banks
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-03-06 01:27:35 +01:00
|
|
|
self.data_bus_height = self.m3_pitch * self.num_horizontal_line
|
|
|
|
|
self.data_bus_width = 2 * (self.bank.width + self.bank_to_bus_distance) + self.vertical_bus_width
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-03-06 01:27:35 +01:00
|
|
|
self.control_bus_height = self.m1_pitch * (self.control_size + 2)
|
2018-07-12 19:30:45 +02:00
|
|
|
self.control_bus_width = self.bank.width + self.bank_to_bus_distance + self.vertical_bus_width
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-03-06 01:27:35 +01:00
|
|
|
self.supply_bus_height = self.m1_pitch * 2 # 2 for vdd/gnd placed with control bus
|
2018-07-12 19:30:45 +02:00
|
|
|
self.supply_bus_width = self.data_bus_width
|
|
|
|
|
|
|
|
|
|
# Sanity check to ensure we can fit the control logic above a single bank (0.9 is a hack really)
|
2020-03-06 01:27:35 +01:00
|
|
|
debug.check(self.bank.width + self.vertical_bus_width > 0.9 * self.control_logic.width,
|
2018-07-12 19:30:45 +02:00
|
|
|
"Bank is too small compared to control logic.")
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-07-12 19:30:45 +02:00
|
|
|
def add_busses(self):
|
|
|
|
|
""" Add the horizontal and vertical busses """
|
|
|
|
|
# Vertical bus
|
|
|
|
|
# The order of the control signals on the control bus:
|
2018-09-27 04:10:24 +02:00
|
|
|
self.control_bus_names = []
|
2018-11-08 21:19:40 +01:00
|
|
|
for port in self.all_ports:
|
2018-11-27 03:00:59 +01:00
|
|
|
self.control_bus_names[port] = ["clk_buf{}".format(port)]
|
|
|
|
|
wen = "w_en{}".format(port)
|
|
|
|
|
sen = "s_en{}".format(port)
|
2018-11-27 23:44:55 +01:00
|
|
|
pen = "p_en_bar{}".format(port)
|
2018-11-27 03:00:59 +01:00
|
|
|
if self.port_id[port] == "r":
|
|
|
|
|
self.control_bus_names[port].extend([sen, pen])
|
|
|
|
|
elif self.port_id[port] == "w":
|
2019-08-01 21:21:43 +02:00
|
|
|
self.control_bus_names[port].extend([wen, pen])
|
2018-11-27 03:00:59 +01:00
|
|
|
else:
|
|
|
|
|
self.control_bus_names[port].extend([sen, wen, pen])
|
2019-12-17 20:03:36 +01:00
|
|
|
self.vert_control_bus_positions = self.create_vertical_bus(layer="m2",
|
2018-09-27 04:10:24 +02:00
|
|
|
pitch=self.m2_pitch,
|
|
|
|
|
offset=self.vertical_bus_offset,
|
|
|
|
|
names=self.control_bus_names[port],
|
|
|
|
|
length=self.vertical_bus_height)
|
|
|
|
|
|
2020-03-06 01:27:35 +01:00
|
|
|
self.addr_bus_names=["A{0}[{1}]".format(port, i) for i in range(self.addr_size)]
|
2019-12-17 20:03:36 +01:00
|
|
|
self.vert_control_bus_positions.update(self.create_vertical_pin_bus(layer="m2",
|
2018-09-27 04:10:24 +02:00
|
|
|
pitch=self.m2_pitch,
|
|
|
|
|
offset=self.addr_bus_offset,
|
|
|
|
|
names=self.addr_bus_names,
|
|
|
|
|
length=self.addr_bus_height))
|
2018-07-12 19:30:45 +02:00
|
|
|
|
2020-03-06 01:27:35 +01:00
|
|
|
self.bank_sel_bus_names = ["bank_sel{0}_{1}".format(port, i) for i in range(self.num_banks)]
|
2019-12-17 20:03:36 +01:00
|
|
|
self.vert_control_bus_positions.update(self.create_vertical_pin_bus(layer="m2",
|
2018-09-27 04:10:24 +02:00
|
|
|
pitch=self.m2_pitch,
|
|
|
|
|
offset=self.bank_sel_bus_offset,
|
|
|
|
|
names=self.bank_sel_bus_names,
|
|
|
|
|
length=self.vertical_bus_height))
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-09-27 04:10:24 +02:00
|
|
|
# Horizontal data bus
|
2020-03-06 01:27:35 +01:00
|
|
|
self.data_bus_names = ["DATA{0}[{1}]".format(port, i) for i in range(self.word_size)]
|
2019-12-17 20:03:36 +01:00
|
|
|
self.data_bus_positions = self.create_horizontal_pin_bus(layer="m3",
|
2018-09-27 04:10:24 +02:00
|
|
|
pitch=self.m3_pitch,
|
|
|
|
|
offset=self.data_bus_offset,
|
|
|
|
|
names=self.data_bus_names,
|
|
|
|
|
length=self.data_bus_width)
|
|
|
|
|
|
|
|
|
|
# Horizontal control logic bus
|
|
|
|
|
# vdd/gnd in bus go along whole SRAM
|
|
|
|
|
# FIXME: Fatten these wires?
|
2019-12-17 20:03:36 +01:00
|
|
|
self.horz_control_bus_positions = self.create_horizontal_bus(layer="m1",
|
2018-09-27 04:10:24 +02:00
|
|
|
pitch=self.m1_pitch,
|
|
|
|
|
offset=self.supply_bus_offset,
|
|
|
|
|
names=["vdd"],
|
|
|
|
|
length=self.supply_bus_width)
|
|
|
|
|
# The gnd rail must not be the entire width since we protrude the right-most vdd rail up for
|
|
|
|
|
# the decoder in 4-bank SRAMs
|
2019-12-17 20:03:36 +01:00
|
|
|
self.horz_control_bus_positions.update(self.create_horizontal_bus(layer="m1",
|
2018-09-27 04:10:24 +02:00
|
|
|
pitch=self.m1_pitch,
|
2020-03-06 01:27:35 +01:00
|
|
|
offset=self.supply_bus_offset + vector(0, self.m1_pitch),
|
2018-09-27 04:10:24 +02:00
|
|
|
names=["gnd"],
|
|
|
|
|
length=self.supply_bus_width))
|
2019-12-17 20:03:36 +01:00
|
|
|
self.horz_control_bus_positions.update(self.create_horizontal_bus(layer="m1",
|
2018-09-27 04:10:24 +02:00
|
|
|
pitch=self.m1_pitch,
|
|
|
|
|
offset=self.control_bus_offset,
|
|
|
|
|
names=self.control_bus_names[port],
|
|
|
|
|
length=self.control_bus_width))
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-08-27 23:18:32 +02:00
|
|
|
def add_multi_bank_modules(self):
|
2018-07-12 19:30:45 +02:00
|
|
|
""" Create the multibank address flops and bank decoder """
|
|
|
|
|
from dff_buf_array import dff_buf_array
|
|
|
|
|
self.msb_address = dff_buf_array(name="msb_address",
|
|
|
|
|
rows=1,
|
2020-03-06 01:27:35 +01:00
|
|
|
columns=self.num_banks / 2)
|
2018-07-12 19:30:45 +02:00
|
|
|
self.add_mod(self.msb_address)
|
|
|
|
|
|
|
|
|
|
if self.num_banks>2:
|
|
|
|
|
self.msb_decoder = self.bank.decoder.pre2_4
|
|
|
|
|
self.add_mod(self.msb_decoder)
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-08-27 23:18:32 +02:00
|
|
|
def add_modules(self):
|
2019-01-17 01:15:38 +01:00
|
|
|
self.bitcell = factory.create(module_type=OPTS.bitcell)
|
2019-07-03 22:17:12 +02:00
|
|
|
self.dff = factory.create(module_type="dff")
|
2018-07-12 19:30:45 +02:00
|
|
|
|
|
|
|
|
# Create the address and control flops (but not the clk)
|
2019-12-18 12:00:02 +01:00
|
|
|
self.row_addr_dff = factory.create("dff_array", module_name="row_addr_dff", rows=self.row_addr_size, columns=1)
|
2018-07-13 23:45:46 +02:00
|
|
|
self.add_mod(self.row_addr_dff)
|
|
|
|
|
|
|
|
|
|
if self.col_addr_size > 0:
|
2019-12-18 12:00:02 +01:00
|
|
|
self.col_addr_dff = factory.create("dff_array", module_name="col_addr_dff", rows=1, columns=self.col_addr_size)
|
2018-07-13 23:45:46 +02:00
|
|
|
self.add_mod(self.col_addr_dff)
|
|
|
|
|
else:
|
|
|
|
|
self.col_addr_dff = None
|
|
|
|
|
|
2020-05-14 12:30:29 +02:00
|
|
|
self.data_dff = factory.create("dff_array", module_name="data_dff", rows=1, columns=self.word_size + self.num_spare_cols)
|
2018-07-13 23:45:46 +02:00
|
|
|
self.add_mod(self.data_dff)
|
2019-07-03 22:17:12 +02:00
|
|
|
|
2019-08-21 23:29:57 +02:00
|
|
|
if self.write_size:
|
2019-12-18 12:00:02 +01:00
|
|
|
self.wmask_dff = factory.create("dff_array", module_name="wmask_dff", rows=1, columns=self.num_wmasks)
|
2019-07-12 19:34:29 +02:00
|
|
|
self.add_mod(self.wmask_dff)
|
2019-07-04 20:14:32 +02:00
|
|
|
|
2020-06-03 14:31:30 +02:00
|
|
|
if self.num_spare_cols:
|
|
|
|
|
self.spare_wen_dff = factory.create("dff_array", module_name="spare_wen_dff", rows=1, columns=self.num_spare_cols)
|
|
|
|
|
self.add_mod(self.spare_wen_dff)
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-07-12 19:30:45 +02:00
|
|
|
# Create the bank module (up to four are instantiated)
|
2019-12-18 12:00:02 +01:00
|
|
|
self.bank = factory.create("bank", sram_config=self.sram_config, module_name="bank")
|
2018-07-12 19:30:45 +02:00
|
|
|
self.add_mod(self.bank)
|
|
|
|
|
|
|
|
|
|
# Create bank decoder
|
|
|
|
|
if(self.num_banks > 1):
|
2018-08-27 23:18:32 +02:00
|
|
|
self.add_multi_bank_modules()
|
2018-07-12 19:30:45 +02:00
|
|
|
|
|
|
|
|
self.bank_count = 0
|
|
|
|
|
|
2018-11-14 22:53:27 +01:00
|
|
|
c = reload(__import__(OPTS.control_logic))
|
|
|
|
|
self.mod_control_logic = getattr(c, OPTS.control_logic)
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-11-10 02:14:52 +01:00
|
|
|
# Create the control logic module for each port type
|
2018-11-14 22:53:27 +01:00
|
|
|
if len(self.readwrite_ports)>0:
|
2019-01-23 21:03:52 +01:00
|
|
|
self.control_logic_rw = self.mod_control_logic(num_rows=self.num_rows,
|
2018-11-14 22:53:27 +01:00
|
|
|
words_per_row=self.words_per_row,
|
2019-01-23 21:03:52 +01:00
|
|
|
word_size=self.word_size,
|
2020-05-14 12:30:29 +02:00
|
|
|
spare_columns=self.num_spare_cols,
|
2019-07-19 23:58:37 +02:00
|
|
|
sram=self,
|
2018-11-14 22:53:27 +01:00
|
|
|
port_type="rw")
|
2018-11-10 02:14:52 +01:00
|
|
|
self.add_mod(self.control_logic_rw)
|
2018-11-20 07:20:20 +01:00
|
|
|
if len(self.writeonly_ports)>0:
|
2020-03-06 01:27:35 +01:00
|
|
|
self.control_logic_w = self.mod_control_logic(num_rows=self.num_rows,
|
2018-11-14 22:53:27 +01:00
|
|
|
words_per_row=self.words_per_row,
|
2019-01-23 21:03:52 +01:00
|
|
|
word_size=self.word_size,
|
2020-05-14 12:30:29 +02:00
|
|
|
spare_columns=self.num_spare_cols,
|
2019-07-19 23:58:37 +02:00
|
|
|
sram=self,
|
2018-11-14 22:53:27 +01:00
|
|
|
port_type="w")
|
2018-11-10 02:14:52 +01:00
|
|
|
self.add_mod(self.control_logic_w)
|
2018-11-20 07:20:20 +01:00
|
|
|
if len(self.readonly_ports)>0:
|
2020-03-06 01:27:35 +01:00
|
|
|
self.control_logic_r = self.mod_control_logic(num_rows=self.num_rows,
|
2018-11-14 22:53:27 +01:00
|
|
|
words_per_row=self.words_per_row,
|
2019-01-23 21:03:52 +01:00
|
|
|
word_size=self.word_size,
|
2020-05-14 12:30:29 +02:00
|
|
|
spare_columns=self.num_spare_cols,
|
2019-07-04 19:34:14 +02:00
|
|
|
sram=self,
|
2018-11-14 22:53:27 +01:00
|
|
|
port_type="r")
|
2018-11-10 02:14:52 +01:00
|
|
|
self.add_mod(self.control_logic_r)
|
2018-07-12 19:30:45 +02:00
|
|
|
|
2020-03-06 01:27:35 +01:00
|
|
|
def create_bank(self, bank_num):
|
|
|
|
|
""" Create a bank """
|
2018-08-27 23:18:32 +02:00
|
|
|
self.bank_insts.append(self.add_inst(name="bank{0}".format(bank_num),
|
|
|
|
|
mod=self.bank))
|
|
|
|
|
|
|
|
|
|
temp = []
|
2018-11-08 21:19:40 +01:00
|
|
|
for port in self.read_ports:
|
2020-05-14 12:30:29 +02:00
|
|
|
for bit in range(self.word_size + self.num_spare_cols):
|
2020-03-06 01:27:35 +01:00
|
|
|
temp.append("dout{0}[{1}]".format(port, bit))
|
2019-08-08 02:14:33 +02:00
|
|
|
for port in self.all_ports:
|
2019-07-12 17:42:36 +02:00
|
|
|
temp.append("rbl_bl{0}".format(port))
|
2018-11-08 21:19:40 +01:00
|
|
|
for port in self.write_ports:
|
2020-05-14 12:30:29 +02:00
|
|
|
for bit in range(self.word_size + self.num_spare_cols):
|
2020-03-06 01:27:35 +01:00
|
|
|
temp.append("bank_din{0}[{1}]".format(port, bit))
|
2018-11-08 21:19:40 +01:00
|
|
|
for port in self.all_ports:
|
2018-09-04 02:44:32 +02:00
|
|
|
for bit in range(self.bank_addr_size):
|
2020-03-06 01:27:35 +01:00
|
|
|
temp.append("a{0}[{1}]".format(port, bit))
|
2018-08-27 23:18:32 +02:00
|
|
|
if(self.num_banks > 1):
|
2018-11-08 21:19:40 +01:00
|
|
|
for port in self.all_ports:
|
2020-03-06 01:27:35 +01:00
|
|
|
temp.append("bank_sel{0}[{1}]".format(port, bank_num))
|
2018-11-08 21:19:40 +01:00
|
|
|
for port in self.read_ports:
|
|
|
|
|
temp.append("s_en{0}".format(port))
|
2019-08-01 21:21:43 +02:00
|
|
|
for port in self.all_ports:
|
2018-11-27 23:44:55 +01:00
|
|
|
temp.append("p_en_bar{0}".format(port))
|
2018-11-09 02:40:22 +01:00
|
|
|
for port in self.write_ports:
|
2018-09-04 02:44:32 +02:00
|
|
|
temp.append("w_en{0}".format(port))
|
2019-07-19 23:58:37 +02:00
|
|
|
for bit in range(self.num_wmasks):
|
|
|
|
|
temp.append("bank_wmask{}[{}]".format(port, bit))
|
2020-05-14 12:30:29 +02:00
|
|
|
for bit in range(self.num_spare_cols):
|
2020-06-03 14:31:30 +02:00
|
|
|
temp.append("bank_spare_wen{0}[{1}]".format(port, bit))
|
2018-11-08 21:19:40 +01:00
|
|
|
for port in self.all_ports:
|
2018-11-27 03:00:59 +01:00
|
|
|
temp.append("wl_en{0}".format(port))
|
2018-09-27 04:10:24 +02:00
|
|
|
temp.extend(["vdd", "gnd"])
|
2018-08-27 23:18:32 +02:00
|
|
|
self.connect_inst(temp)
|
|
|
|
|
|
|
|
|
|
return self.bank_insts[-1]
|
|
|
|
|
|
|
|
|
|
def place_bank(self, bank_inst, position, x_flip, y_flip):
|
2018-07-12 19:30:45 +02:00
|
|
|
""" Place a bank at the given position with orientations """
|
|
|
|
|
|
|
|
|
|
# x_flip == 1 --> no flip in x_axis
|
|
|
|
|
# x_flip == -1 --> flip in x_axis
|
|
|
|
|
# y_flip == 1 --> no flip in y_axis
|
|
|
|
|
# y_flip == -1 --> flip in y_axis
|
|
|
|
|
|
|
|
|
|
# x_flip and y_flip are used for position translation
|
|
|
|
|
|
|
|
|
|
if x_flip == -1 and y_flip == -1:
|
|
|
|
|
bank_rotation = 180
|
|
|
|
|
else:
|
|
|
|
|
bank_rotation = 0
|
|
|
|
|
|
|
|
|
|
if x_flip == y_flip:
|
|
|
|
|
bank_mirror = "R0"
|
|
|
|
|
elif x_flip == -1:
|
|
|
|
|
bank_mirror = "MX"
|
|
|
|
|
elif y_flip == -1:
|
|
|
|
|
bank_mirror = "MY"
|
|
|
|
|
else:
|
|
|
|
|
bank_mirror = "R0"
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-08-28 02:25:39 +02:00
|
|
|
bank_inst.place(offset=position,
|
2018-08-27 23:18:32 +02:00
|
|
|
mirror=bank_mirror,
|
|
|
|
|
rotate=bank_rotation)
|
2018-07-12 19:30:45 +02:00
|
|
|
|
|
|
|
|
return bank_inst
|
|
|
|
|
|
2018-08-27 23:18:32 +02:00
|
|
|
def create_row_addr_dff(self):
|
|
|
|
|
""" Add all address flops for the main decoder """
|
2018-09-27 04:10:24 +02:00
|
|
|
insts = []
|
2018-11-08 21:19:40 +01:00
|
|
|
for port in self.all_ports:
|
2018-09-27 04:10:24 +02:00
|
|
|
insts.append(self.add_inst(name="row_address{}".format(port),
|
|
|
|
|
mod=self.row_addr_dff))
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-09-27 04:10:24 +02:00
|
|
|
# inputs, outputs/output/bar
|
|
|
|
|
inputs = []
|
|
|
|
|
outputs = []
|
|
|
|
|
for bit in range(self.row_addr_size):
|
2020-03-06 01:27:35 +01:00
|
|
|
inputs.append("addr{}[{}]".format(port, bit + self.col_addr_size))
|
|
|
|
|
outputs.append("a{}[{}]".format(port, bit + self.col_addr_size))
|
2018-09-27 04:10:24 +02:00
|
|
|
|
|
|
|
|
self.connect_inst(inputs + outputs + ["clk_buf{}".format(port), "vdd", "gnd"])
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-09-27 04:10:24 +02:00
|
|
|
return insts
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-08-27 23:18:32 +02:00
|
|
|
def create_col_addr_dff(self):
|
2018-07-13 23:45:46 +02:00
|
|
|
""" Add and place all address flops for the column decoder """
|
2018-09-27 04:10:24 +02:00
|
|
|
insts = []
|
2018-11-08 21:19:40 +01:00
|
|
|
for port in self.all_ports:
|
2018-09-27 04:10:24 +02:00
|
|
|
insts.append(self.add_inst(name="col_address{}".format(port),
|
|
|
|
|
mod=self.col_addr_dff))
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-09-27 04:10:24 +02:00
|
|
|
# inputs, outputs/output/bar
|
|
|
|
|
inputs = []
|
|
|
|
|
outputs = []
|
|
|
|
|
for bit in range(self.col_addr_size):
|
2020-03-06 01:27:35 +01:00
|
|
|
inputs.append("addr{}[{}]".format(port, bit))
|
|
|
|
|
outputs.append("a{}[{}]".format(port, bit))
|
2018-07-12 19:30:45 +02:00
|
|
|
|
2018-09-27 04:10:24 +02:00
|
|
|
self.connect_inst(inputs + outputs + ["clk_buf{}".format(port), "vdd", "gnd"])
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-09-27 04:10:24 +02:00
|
|
|
return insts
|
|
|
|
|
|
2018-08-27 23:18:32 +02:00
|
|
|
def create_data_dff(self):
|
2018-07-13 23:45:46 +02:00
|
|
|
""" Add and place all data flops """
|
2018-09-27 04:10:24 +02:00
|
|
|
insts = []
|
2018-11-15 02:05:23 +01:00
|
|
|
for port in self.all_ports:
|
|
|
|
|
if port in self.write_ports:
|
|
|
|
|
insts.append(self.add_inst(name="data_dff{}".format(port),
|
|
|
|
|
mod=self.data_dff))
|
|
|
|
|
else:
|
|
|
|
|
insts.append(None)
|
|
|
|
|
continue
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-09-27 04:10:24 +02:00
|
|
|
# inputs, outputs/output/bar
|
|
|
|
|
inputs = []
|
|
|
|
|
outputs = []
|
2020-05-14 12:30:29 +02:00
|
|
|
for bit in range(self.word_size + self.num_spare_cols):
|
2020-03-06 01:27:35 +01:00
|
|
|
inputs.append("din{}[{}]".format(port, bit))
|
|
|
|
|
outputs.append("bank_din{}[{}]".format(port, bit))
|
2018-07-13 23:45:46 +02:00
|
|
|
|
2018-09-27 04:10:24 +02:00
|
|
|
self.connect_inst(inputs + outputs + ["clk_buf{}".format(port), "vdd", "gnd"])
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-09-27 04:10:24 +02:00
|
|
|
return insts
|
2018-07-13 23:45:46 +02:00
|
|
|
|
2019-07-04 19:34:14 +02:00
|
|
|
def create_wmask_dff(self):
|
|
|
|
|
""" Add and place all wmask flops """
|
|
|
|
|
insts = []
|
|
|
|
|
for port in self.all_ports:
|
|
|
|
|
if port in self.write_ports:
|
|
|
|
|
insts.append(self.add_inst(name="wmask_dff{}".format(port),
|
|
|
|
|
mod=self.wmask_dff))
|
|
|
|
|
else:
|
|
|
|
|
insts.append(None)
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
# inputs, outputs/output/bar
|
|
|
|
|
inputs = []
|
|
|
|
|
outputs = []
|
2019-07-19 23:58:37 +02:00
|
|
|
for bit in range(self.num_wmasks):
|
2019-07-04 19:34:14 +02:00
|
|
|
inputs.append("wmask{}[{}]".format(port, bit))
|
2019-07-12 19:34:29 +02:00
|
|
|
outputs.append("bank_wmask{}[{}]".format(port, bit))
|
2019-07-04 19:34:14 +02:00
|
|
|
|
|
|
|
|
self.connect_inst(inputs + outputs + ["clk_buf{}".format(port), "vdd", "gnd"])
|
|
|
|
|
|
|
|
|
|
return insts
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-06-03 14:31:30 +02:00
|
|
|
def create_spare_wen_dff(self):
|
|
|
|
|
""" Add all spare write enable flops """
|
|
|
|
|
insts = []
|
|
|
|
|
for port in self.all_ports:
|
|
|
|
|
if port in self.write_ports:
|
|
|
|
|
insts.append(self.add_inst(name="spare_wen_dff{}".format(port),
|
|
|
|
|
mod=self.spare_wen_dff))
|
|
|
|
|
else:
|
|
|
|
|
insts.append(None)
|
|
|
|
|
continue
|
2019-07-04 19:34:14 +02:00
|
|
|
|
2020-06-03 14:31:30 +02:00
|
|
|
# inputs, outputs/output/bar
|
|
|
|
|
inputs = []
|
|
|
|
|
outputs = []
|
|
|
|
|
for bit in range(self.num_spare_cols):
|
|
|
|
|
inputs.append("spare_wen{}[{}]".format(port, bit))
|
|
|
|
|
outputs.append("bank_spare_wen{}[{}]".format(port, bit))
|
|
|
|
|
|
|
|
|
|
self.connect_inst(inputs + outputs + ["clk_buf{}".format(port), "vdd", "gnd"])
|
|
|
|
|
|
|
|
|
|
return insts
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-09-12 09:59:07 +02:00
|
|
|
def create_control_logic(self):
|
2018-11-14 01:05:22 +01:00
|
|
|
""" Add control logic instances """
|
|
|
|
|
|
2018-09-27 04:10:24 +02:00
|
|
|
insts = []
|
2018-11-08 21:19:40 +01:00
|
|
|
for port in self.all_ports:
|
|
|
|
|
if port in self.readwrite_ports:
|
2018-09-27 04:10:24 +02:00
|
|
|
mod = self.control_logic_rw
|
2018-11-08 21:19:40 +01:00
|
|
|
elif port in self.write_ports:
|
2018-09-27 04:10:24 +02:00
|
|
|
mod = self.control_logic_w
|
|
|
|
|
else:
|
|
|
|
|
mod = self.control_logic_r
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-11-14 01:05:22 +01:00
|
|
|
insts.append(self.add_inst(name="control{}".format(port), mod=mod))
|
2018-11-29 00:30:52 +01:00
|
|
|
|
|
|
|
|
# Inputs
|
2018-09-27 04:10:24 +02:00
|
|
|
temp = ["csb{}".format(port)]
|
2018-11-08 21:19:40 +01:00
|
|
|
if port in self.readwrite_ports:
|
2018-09-27 04:10:24 +02:00
|
|
|
temp.append("web{}".format(port))
|
|
|
|
|
temp.append("clk{}".format(port))
|
2019-08-08 02:14:33 +02:00
|
|
|
temp.append("rbl_bl{}".format(port))
|
2018-11-29 00:30:52 +01:00
|
|
|
|
2019-08-14 18:59:40 +02:00
|
|
|
# Outputs
|
2018-11-08 21:19:40 +01:00
|
|
|
if port in self.read_ports:
|
2018-09-27 04:10:24 +02:00
|
|
|
temp.append("s_en{}".format(port))
|
2018-11-08 21:19:40 +01:00
|
|
|
if port in self.write_ports:
|
2018-09-27 04:10:24 +02:00
|
|
|
temp.append("w_en{}".format(port))
|
2019-08-01 21:21:43 +02:00
|
|
|
temp.append("p_en_bar{}".format(port))
|
2018-11-27 03:00:59 +01:00
|
|
|
temp.extend(["wl_en{}".format(port), "clk_buf{}".format(port), "vdd", "gnd"])
|
2018-09-27 04:10:24 +02:00
|
|
|
self.connect_inst(temp)
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-09-27 04:10:24 +02:00
|
|
|
return insts
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-04-07 00:20:59 +02:00
|
|
|
def sp_write(self, sp_name, lvs_netlist=False):
|
2018-07-12 19:30:45 +02:00
|
|
|
# Write the entire spice of the object to the file
|
|
|
|
|
############################################################
|
|
|
|
|
# Spice circuit
|
|
|
|
|
############################################################
|
|
|
|
|
sp = open(sp_name, 'w')
|
|
|
|
|
|
|
|
|
|
sp.write("**************************************************\n")
|
|
|
|
|
sp.write("* OpenRAM generated memory.\n")
|
|
|
|
|
sp.write("* Words: {}\n".format(self.num_words))
|
|
|
|
|
sp.write("* Data bits: {}\n".format(self.word_size))
|
|
|
|
|
sp.write("* Banks: {}\n".format(self.num_banks))
|
|
|
|
|
sp.write("* Column mux: {}:1\n".format(self.words_per_row))
|
2020-04-03 22:39:54 +02:00
|
|
|
sp.write("**************************************************\n")
|
2018-07-12 19:30:45 +02:00
|
|
|
# This causes unit test mismatch
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-07-12 19:30:45 +02:00
|
|
|
# sp.write("* Created: {0}\n".format(datetime.datetime.now()))
|
|
|
|
|
# sp.write("* User: {0}\n".format(getpass.getuser()))
|
2020-04-03 22:39:54 +02:00
|
|
|
# sp.write(".global {0} {1}\n".format(spice["vdd_name"],
|
2018-07-12 19:30:45 +02:00
|
|
|
# spice["gnd_name"]))
|
|
|
|
|
usedMODS = list()
|
2020-04-07 00:20:59 +02:00
|
|
|
self.sp_write_file(sp, usedMODS, lvs_netlist=lvs_netlist)
|
2018-07-12 19:30:45 +02:00
|
|
|
del usedMODS
|
|
|
|
|
sp.close()
|
2020-04-07 00:20:59 +02:00
|
|
|
|
|
|
|
|
def lvs_write(self, sp_name):
|
|
|
|
|
self.sp_write(sp_name, lvs_netlist=True)
|
2020-09-29 19:26:31 +02:00
|
|
|
|
|
|
|
|
def graph_exclude_bits(self, targ_row, targ_col):
|
|
|
|
|
"""
|
|
|
|
|
Excludes bits in column from being added to graph except target
|
|
|
|
|
"""
|
|
|
|
|
self.bank.graph_exclude_bits(targ_row, targ_col)
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-09-29 19:26:31 +02:00
|
|
|
def clear_exclude_bits(self):
|
2020-11-03 15:29:17 +01:00
|
|
|
"""
|
2020-09-29 19:26:31 +02:00
|
|
|
Clears the bit exclusions
|
|
|
|
|
"""
|
|
|
|
|
self.bank.clear_exclude_bits()
|