OpenRAM/compiler/modules/port_data.py

859 lines
37 KiB
Python
Raw Normal View History

2019-07-03 00:35:53 +02:00
# See LICENSE for licensing information.
#
2021-01-22 20:23:28 +01:00
# Copyright (c) 2016-2021 Regents of the University of California
2019-07-03 00:35:53 +02:00
# All rights reserved.
#
2020-03-05 19:21:18 +01:00
from tech import drc
2019-07-03 00:35:53 +02:00
import debug
import design
import math
2019-07-03 00:35:53 +02:00
from sram_factory import factory
from collections import namedtuple
2019-07-03 00:35:53 +02:00
from vector import vector
from globals import OPTS
from tech import cell_properties
2020-10-27 23:11:04 +01:00
from tech import layer_properties as layer_props
2019-07-03 00:35:53 +02:00
2020-03-05 19:21:18 +01:00
2019-07-03 00:35:53 +02:00
class port_data(design.design):
"""
2019-07-05 17:18:58 +02:00
Create the data port (column mux, sense amps, write driver, etc.) for the given port number.
2019-07-11 23:47:27 +02:00
Port 0 always has the RBL on the left while port 1 is on the right.
2019-07-03 00:35:53 +02:00
"""
2021-05-03 06:49:09 +02:00
def __init__(self, sram_config, port, num_spare_cols=None, bit_offsets=None, name="", rows=None, cols=None, dimension_override=False):
2019-07-03 00:35:53 +02:00
sram_config.set_local_config(self)
2021-04-15 00:09:25 +02:00
if dimension_override:
self.num_rows = rows
self.num_cols = cols
2021-05-03 06:49:09 +02:00
self.word_size = sram_config.word_size
2021-04-15 00:09:25 +02:00
2019-07-03 00:35:53 +02:00
self.port = port
if self.write_size is not None:
self.num_wmasks = int(math.ceil(self.word_size / self.write_size))
else:
self.num_wmasks = 0
2021-05-04 06:59:05 +02:00
2021-05-04 09:41:20 +02:00
if num_spare_cols:
2021-05-04 06:59:05 +02:00
self.num_spare_cols = num_spare_cols
2021-05-04 09:41:20 +02:00
elif self.num_spare_cols is None:
self.num_spare_cols = 0
if not bit_offsets:
2020-11-06 01:55:08 +01:00
bitcell = factory.create(module_type=OPTS.bitcell)
2021-05-03 06:49:09 +02:00
if(cell_properties.use_strap == True and OPTS.num_ports == 1):
strap = factory.create(module_type=cell_properties.strap_module, version=cell_properties.strap_version)
precharge_width = bitcell.width + strap.width
2021-05-03 23:39:51 +02:00
else:
precharge_width = bitcell.width
self.bit_offsets = []
for i in range(self.num_cols + self.num_spare_cols):
self.bit_offsets.append(i * precharge_width)
else:
self.bit_offsets = bit_offsets
2019-07-03 00:35:53 +02:00
if name == "":
2019-07-05 17:18:58 +02:00
name = "port_data_{0}".format(self.port)
2020-08-06 20:33:26 +02:00
super().__init__(name)
2020-03-05 19:21:18 +01:00
debug.info(2,
"create data port of size {0} with {1} words per row".format(self.word_size,
self.words_per_row))
2019-07-03 00:35:53 +02:00
self.create_netlist()
if not OPTS.netlist_only:
2020-03-05 19:21:18 +01:00
debug.check(len(self.all_ports)<=2,
"Bank layout cannot handle more than two ports.")
2019-07-03 00:35:53 +02:00
self.create_layout()
self.add_boundary()
def get_bl_names(self):
# bl lines are connect from the precharger
return self.precharge.get_bl_names()
def get_br_names(self):
# br lines are connect from the precharger
return self.precharge.get_br_names()
def get_bl_name(self, port=0):
2020-08-25 20:50:44 +02:00
return "bl_{}".format(port)
def get_br_name(self, port=0):
2020-08-25 20:50:44 +02:00
return "br_{}".format(port)
2019-07-03 00:35:53 +02:00
def create_netlist(self):
2019-07-05 17:18:58 +02:00
self.precompute_constants()
2019-07-03 00:35:53 +02:00
self.add_pins()
self.add_modules()
self.create_instances()
def create_instances(self):
if self.precharge_array:
self.create_precharge_array()
else:
self.precharge_array_inst = None
if self.sense_amp_array:
self.create_sense_amp_array()
else:
self.sense_amp_array_inst = None
if self.write_driver_array:
self.create_write_driver_array()
if self.write_size is not None:
self.create_write_mask_and_array()
else:
self.write_mask_and_array_inst = None
2019-07-03 00:35:53 +02:00
else:
self.write_driver_array_inst = None
self.write_mask_and_array_inst = None
2019-07-03 00:35:53 +02:00
if self.column_mux_array:
self.create_column_mux_array()
else:
self.column_mux_array_inst = None
2019-07-03 00:35:53 +02:00
def create_layout(self):
self.compute_instance_offsets()
self.place_instances()
self.route_layout()
self.DRC_LVS()
def add_pins(self):
2020-04-14 05:09:10 +02:00
""" Adding pins for port data module"""
2020-03-05 19:21:18 +01:00
self.add_pin("rbl_bl", "INOUT")
self.add_pin("rbl_br", "INOUT")
2020-05-09 09:56:19 +02:00
for bit in range(self.num_cols):
2020-08-25 20:50:44 +02:00
self.add_pin("bl_{0}".format(bit), "INOUT")
self.add_pin("br_{0}".format(bit), "INOUT")
2020-05-09 09:56:19 +02:00
for bit in range(self.num_spare_cols):
2020-08-25 20:50:44 +02:00
self.add_pin("sparebl_{0}".format(bit), "INOUT")
self.add_pin("sparebr_{0}".format(bit), "INOUT")
2019-07-03 00:35:53 +02:00
if self.port in self.read_ports:
2020-04-14 05:09:10 +02:00
for bit in range(self.word_size + self.num_spare_cols):
2020-03-05 19:21:18 +01:00
self.add_pin("dout_{}".format(bit), "OUTPUT")
2019-07-03 00:35:53 +02:00
if self.port in self.write_ports:
2020-04-14 05:09:10 +02:00
for bit in range(self.word_size + self.num_spare_cols):
2020-03-05 19:21:18 +01:00
self.add_pin("din_{}".format(bit), "INPUT")
2019-07-03 22:17:12 +02:00
# Will be empty if no col addr lines
sel_names = ["sel_{}".format(x) for x in range(self.num_col_addr_lines)]
for pin_name in sel_names:
2020-03-05 19:21:18 +01:00
self.add_pin(pin_name, "INPUT")
2019-07-03 00:35:53 +02:00
if self.port in self.read_ports:
2019-07-03 22:17:12 +02:00
self.add_pin("s_en", "INPUT")
2019-08-01 21:21:43 +02:00
self.add_pin("p_en_bar", "INPUT")
2019-07-03 00:35:53 +02:00
if self.port in self.write_ports:
2019-07-03 22:17:12 +02:00
self.add_pin("w_en", "INPUT")
for bit in range(self.num_wmasks):
2020-03-05 19:21:18 +01:00
self.add_pin("bank_wmask_{}".format(bit), "INPUT")
2020-04-14 05:09:10 +02:00
for bit in range(self.num_spare_cols):
self.add_pin("bank_spare_wen{}".format(bit), "INPUT")
2020-03-05 19:21:18 +01:00
self.add_pin("vdd", "POWER")
self.add_pin("gnd", "GROUND")
2019-07-03 00:35:53 +02:00
def route_layout(self):
2019-08-08 17:46:58 +02:00
""" Create routing among the modules """
2019-07-03 22:17:12 +02:00
self.route_data_lines()
self.route_layout_pins()
2019-07-03 00:35:53 +02:00
self.route_supplies()
2019-07-03 22:17:12 +02:00
def route_layout_pins(self):
""" Add the pins """
self.route_bitline_pins()
self.route_control_pins()
2019-07-03 22:17:12 +02:00
def route_data_lines(self):
2019-07-03 00:35:53 +02:00
""" Route the bitlines depending on the port type rw, w, or r. """
2019-07-03 00:35:53 +02:00
if self.port in self.readwrite_ports:
2019-08-08 17:46:58 +02:00
# (write_mask_and ->) write_driver -> sense_amp -> (column_mux ->) precharge -> bitcell_array
self.route_write_mask_and_array_in(self.port)
self.route_write_mask_and_array_to_write_driver(self.port)
self.route_write_driver_in(self.port)
2019-07-03 00:35:53 +02:00
self.route_sense_amp_out(self.port)
self.route_write_driver_to_sense_amp(self.port)
self.route_sense_amp_to_column_mux_or_precharge_array(self.port)
self.route_column_mux_to_precharge_array(self.port)
elif self.port in self.read_ports:
# sense_amp -> (column_mux) -> precharge -> bitcell_array
self.route_sense_amp_out(self.port)
self.route_sense_amp_to_column_mux_or_precharge_array(self.port)
self.route_column_mux_to_precharge_array(self.port)
else:
2019-08-08 17:46:58 +02:00
# (write_mask_and ->) write_driver -> (column_mux ->) precharge -> bitcell_array
self.route_write_mask_and_array_in(self.port)
self.route_write_mask_and_array_to_write_driver(self.port)
self.route_write_driver_in(self.port)
2019-07-25 19:31:39 +02:00
self.route_write_driver_to_column_mux_or_precharge_array(self.port)
self.route_column_mux_to_precharge_array(self.port)
2019-07-03 00:35:53 +02:00
def route_supplies(self):
""" Propagate all vdd/gnd pins up to this level for all modules """
2019-07-03 00:35:53 +02:00
for inst in self.insts:
2020-03-05 19:21:18 +01:00
self.copy_power_pins(inst, "vdd")
self.copy_power_pins(inst, "gnd")
2019-07-03 00:35:53 +02:00
def add_modules(self):
# Extra column +1 is for RBL
# Precharge will be shifted left if needed
# Column offset is set to port so extra column can be on left or right
# and mirroring happens correctly
2020-11-03 15:29:17 +01:00
# Used for names/dimensions only
cell = factory.create(module_type=OPTS.bitcell)
2021-05-03 06:49:09 +02:00
if(cell_properties.use_strap == True and OPTS.num_ports == 1):
strap = factory.create(module_type=cell_properties.strap_module, version=cell_properties.strap_version)
precharge_width = cell.width + strap.width
2021-05-03 06:49:09 +02:00
else:
precharge_width = cell.width
if self.port == 0:
# Append an offset on the left
precharge_bit_offsets = [self.bit_offsets[0] - precharge_width] + self.bit_offsets
else:
# Append an offset on the right
precharge_bit_offsets = self.bit_offsets + [self.bit_offsets[-1] + precharge_width]
self.precharge_array = factory.create(module_type="precharge_array",
2020-04-14 05:09:10 +02:00
columns=self.num_cols + self.num_spare_cols + 1,
offsets=precharge_bit_offsets,
bitcell_bl=self.bl_names[self.port],
bitcell_br=self.br_names[self.port],
column_offset=self.port - 1)
self.add_mod(self.precharge_array)
if self.port in self.read_ports:
# RBLs don't get a sense amp
self.sense_amp_array = factory.create(module_type="sense_amp_array",
word_size=self.word_size,
offsets=self.bit_offsets,
2020-04-14 05:09:10 +02:00
words_per_row=self.words_per_row,
num_spare_cols=self.num_spare_cols)
self.add_mod(self.sense_amp_array)
else:
self.sense_amp_array = None
2019-07-03 00:35:53 +02:00
if self.col_addr_size > 0:
# RBLs dont get a col mux
2019-07-03 00:35:53 +02:00
self.column_mux_array = factory.create(module_type="column_mux_array",
columns=self.num_cols,
2019-07-03 00:35:53 +02:00
word_size=self.word_size,
offsets=self.bit_offsets,
2019-07-03 00:35:53 +02:00
bitcell_bl=self.bl_names[self.port],
bitcell_br=self.br_names[self.port])
self.add_mod(self.column_mux_array)
else:
self.column_mux_array = None
2019-07-05 17:18:58 +02:00
if self.port in self.write_ports:
# RBLs dont get a write driver
2019-07-03 00:35:53 +02:00
self.write_driver_array = factory.create(module_type="write_driver_array",
columns=self.num_cols,
2019-07-19 22:17:55 +02:00
word_size=self.word_size,
offsets=self.bit_offsets,
2020-04-14 05:09:10 +02:00
write_size=self.write_size,
num_spare_cols=self.num_spare_cols)
2019-07-03 00:35:53 +02:00
self.add_mod(self.write_driver_array)
if self.write_size is not None:
# RBLs don't get a write mask
self.write_mask_and_array = factory.create(module_type="write_mask_and_array",
columns=self.num_cols,
offsets=self.bit_offsets,
word_size=self.word_size,
write_size=self.write_size)
self.add_mod(self.write_mask_and_array)
else:
self.write_mask_and_array = None
2019-07-03 00:35:53 +02:00
else:
self.write_driver_array = None
self.write_mask_and_array = None
2019-07-03 00:35:53 +02:00
2019-07-05 17:18:58 +02:00
def precompute_constants(self):
""" Get some preliminary data ready """
2019-07-03 00:35:53 +02:00
2019-07-03 22:17:12 +02:00
# The central bus is the column address (one hot) and row address (binary)
if self.col_addr_size>0:
self.num_col_addr_lines = 2**self.col_addr_size
else:
self.num_col_addr_lines = 0
2019-07-03 00:35:53 +02:00
# A space for wells or jogging m2 between modules
2020-03-05 19:21:18 +01:00
self.m2_gap = max(2 * drc("pwell_to_nwell") + drc("nwell_enclose_active"),
3 * self.m2_pitch)
2019-07-03 00:35:53 +02:00
2020-03-05 19:21:18 +01:00
# create arrays of bitline and bitline_bar names for read,
# write, or all ports
2020-11-06 01:55:08 +01:00
self.bitcell = factory.create(module_type=OPTS.bitcell)
self.bl_names = self.bitcell.get_all_bl_names()
self.br_names = self.bitcell.get_all_br_names()
self.wl_names = self.bitcell.get_all_wl_names()
# used for bl/br names
self.precharge = factory.create(module_type=OPTS.precharge,
2020-03-05 19:21:18 +01:00
bitcell_bl=self.bl_names[0],
bitcell_br=self.br_names[0])
2019-07-03 00:35:53 +02:00
def create_precharge_array(self):
""" Creating Precharge """
if not self.precharge_array:
self.precharge_array_inst = None
return
2019-07-03 00:35:53 +02:00
self.precharge_array_inst = self.add_inst(name="precharge_array{}".format(self.port),
mod=self.precharge_array)
temp = []
2019-07-27 15:11:45 +02:00
# Use left BLs for RBL
if self.port==0:
2019-07-11 23:47:27 +02:00
temp.append("rbl_bl")
temp.append("rbl_br")
2019-07-03 22:17:12 +02:00
for bit in range(self.num_cols):
2020-08-25 20:50:44 +02:00
temp.append("bl_{0}".format(bit))
temp.append("br_{0}".format(bit))
2020-11-03 15:29:17 +01:00
2020-04-14 05:09:10 +02:00
for bit in range(self.num_spare_cols):
2020-08-25 20:50:44 +02:00
temp.append("sparebl_{0}".format(bit))
temp.append("sparebr_{0}".format(bit))
2019-07-27 15:11:45 +02:00
# Use right BLs for RBL
if self.port==1:
2019-07-11 23:47:27 +02:00
temp.append("rbl_bl")
temp.append("rbl_br")
2019-07-03 22:17:12 +02:00
temp.extend(["p_en_bar", "vdd"])
2019-07-03 00:35:53 +02:00
self.connect_inst(temp)
def place_precharge_array(self, offset):
""" Placing Precharge """
2019-07-03 00:35:53 +02:00
self.precharge_array_inst.place(offset=offset, mirror="MX")
def create_column_mux_array(self):
""" Creating Column Mux when words_per_row > 1 . """
2019-07-03 00:35:53 +02:00
self.column_mux_array_inst = self.add_inst(name="column_mux_array{}".format(self.port),
mod=self.column_mux_array)
temp = []
for col in range(self.num_cols):
2020-08-25 20:50:44 +02:00
temp.append("bl_{0}".format(col))
temp.append("br_{0}".format(col))
2019-07-03 00:35:53 +02:00
for word in range(self.words_per_row):
2019-07-03 22:17:12 +02:00
temp.append("sel_{}".format(word))
2019-07-03 00:35:53 +02:00
for bit in range(self.word_size):
2020-08-25 20:50:44 +02:00
temp.append("bl_out_{0}".format(bit))
temp.append("br_out_{0}".format(bit))
2019-07-03 00:35:53 +02:00
temp.append("gnd")
self.connect_inst(temp)
def place_column_mux_array(self, offset):
""" Placing Column Mux when words_per_row > 1 . """
if self.col_addr_size == 0:
return
2019-07-03 00:35:53 +02:00
self.column_mux_array_inst.place(offset=offset, mirror="MX")
def create_sense_amp_array(self):
""" Creating Sense amp """
self.sense_amp_array_inst = self.add_inst(name="sense_amp_array{}".format(self.port),
mod=self.sense_amp_array)
temp = []
for bit in range(self.word_size):
2019-07-03 22:17:12 +02:00
temp.append("dout_{}".format(bit))
2019-07-03 00:35:53 +02:00
if self.words_per_row == 1:
2020-08-25 20:50:44 +02:00
temp.append("bl_{0}".format(bit))
temp.append("br_{0}".format(bit))
2019-07-03 00:35:53 +02:00
else:
2020-08-25 20:50:44 +02:00
temp.append("bl_out_{0}".format(bit))
temp.append("br_out_{0}".format(bit))
2020-11-03 15:29:17 +01:00
2020-04-14 05:09:10 +02:00
for bit in range(self.num_spare_cols):
temp.append("dout_{}".format(self.word_size + bit))
2020-08-25 20:50:44 +02:00
temp.append("sparebl_{0}".format(bit))
2020-11-03 15:29:17 +01:00
temp.append("sparebr_{0}".format(bit))
2020-04-14 05:09:10 +02:00
temp.append("s_en")
temp.extend(["vdd", "gnd"])
2019-07-03 00:35:53 +02:00
self.connect_inst(temp)
def place_sense_amp_array(self, offset):
""" Placing Sense amp """
self.sense_amp_array_inst.place(offset=offset, mirror="MX")
def create_write_driver_array(self):
""" Creating Write Driver """
self.write_driver_array_inst = self.add_inst(name="write_driver_array{}".format(self.port),
2019-07-03 00:35:53 +02:00
mod=self.write_driver_array)
temp = []
2020-04-14 05:09:10 +02:00
for bit in range(self.word_size + self.num_spare_cols):
2019-07-03 22:17:12 +02:00
temp.append("din_{}".format(bit))
for bit in range(self.word_size):
2019-07-27 07:03:50 +02:00
if (self.words_per_row == 1):
2020-08-25 20:50:44 +02:00
temp.append("bl_{0}".format(bit))
temp.append("br_{0}".format(bit))
2019-07-03 00:35:53 +02:00
else:
2020-08-25 20:50:44 +02:00
temp.append("bl_out_{0}".format(bit))
temp.append("br_out_{0}".format(bit))
2020-04-14 05:09:10 +02:00
2020-07-01 23:44:18 +02:00
for bit in range(self.num_spare_cols):
2020-08-25 20:50:44 +02:00
temp.append("sparebl_{0}".format(bit))
temp.append("sparebr_{0}".format(bit))
2019-07-19 22:17:55 +02:00
if self.write_size is not None:
for i in range(self.num_wmasks):
temp.append("wdriver_sel_{}".format(i))
2020-05-16 12:09:03 +02:00
for i in range(self.num_spare_cols):
temp.append("bank_spare_wen{}".format(i))
2020-04-14 05:09:10 +02:00
2020-05-16 12:09:03 +02:00
elif self.num_spare_cols and not self.write_size:
2020-04-14 05:09:10 +02:00
temp.append("w_en")
for i in range(self.num_spare_cols):
temp.append("bank_spare_wen{}".format(i))
2019-07-19 22:17:55 +02:00
else:
temp.append("w_en")
temp.extend(["vdd", "gnd"])
2019-07-27 03:01:43 +02:00
2019-07-03 00:35:53 +02:00
self.connect_inst(temp)
def place_write_driver_array(self, offset):
""" Placing Write Driver """
self.write_driver_array_inst.place(offset=offset, mirror="MX")
def create_write_mask_and_array(self):
""" Creating Write Mask AND Array """
self.write_mask_and_array_inst = self.add_inst(name="write_mask_and_array{}".format(self.port),
mod=self.write_mask_and_array)
temp = []
for bit in range(self.num_wmasks):
2019-07-19 22:17:55 +02:00
temp.append("bank_wmask_{}".format(bit))
temp.extend(["w_en"])
for bit in range(self.num_wmasks):
2019-07-19 22:17:55 +02:00
temp.append("wdriver_sel_{}".format(bit))
temp.extend(["vdd", "gnd"])
self.connect_inst(temp)
def place_write_mask_and_array(self, offset):
""" Placing Write Mask AND array """
self.write_mask_and_array_inst.place(offset=offset, mirror="MX")
2019-07-03 00:35:53 +02:00
def compute_instance_offsets(self):
"""
Compute the empty instance offsets for port0 and port1 (if needed)
"""
vertical_port_order = []
vertical_port_order.append(self.precharge_array_inst)
vertical_port_order.append(self.column_mux_array_inst)
vertical_port_order.append(self.sense_amp_array_inst)
vertical_port_order.append(self.write_driver_array_inst)
vertical_port_order.append(self.write_mask_and_array_inst)
2019-07-03 00:35:53 +02:00
vertical_port_offsets = 5 * [None]
self.width = 0
2019-07-03 00:35:53 +02:00
self.height = 0
for i, p in enumerate(vertical_port_order):
if p == None:
2019-07-03 00:35:53 +02:00
continue
self.height += (p.height + self.m2_gap)
self.width = max(self.width, p.width)
vertical_port_offsets[i] = vector(0, self.height)
2019-07-03 00:35:53 +02:00
# Reversed order
self.write_mask_and_offset = vertical_port_offsets[4]
2019-07-03 00:35:53 +02:00
self.write_driver_offset = vertical_port_offsets[3]
self.sense_amp_offset = vertical_port_offsets[2]
self.column_mux_offset = vertical_port_offsets[1]
self.precharge_offset = vertical_port_offsets[0]
def place_instances(self):
""" Place the instances. """
# These are fixed in the order: write mask ANDs, write driver, sense amp, column mux, precharge,
2019-07-03 00:35:53 +02:00
# even if the item is not used in a given port (it will be None then)
if self.write_mask_and_offset:
self.place_write_mask_and_array(self.write_mask_and_offset)
2019-07-03 00:35:53 +02:00
if self.write_driver_offset:
self.place_write_driver_array(self.write_driver_offset)
if self.sense_amp_offset:
self.place_sense_amp_array(self.sense_amp_offset)
if self.precharge_offset:
self.place_precharge_array(self.precharge_offset)
if self.column_mux_offset:
self.place_column_mux_array(self.column_mux_offset)
def route_sense_amp_out(self, port):
""" Add pins for the sense amp output """
2020-04-14 05:09:10 +02:00
for bit in range(self.word_size + self.num_spare_cols):
2019-07-03 00:35:53 +02:00
data_pin = self.sense_amp_array_inst.get_pin("data_{}".format(bit))
2019-07-03 22:17:12 +02:00
self.add_layout_pin_rect_center(text="dout_{0}".format(bit),
2020-03-05 19:21:18 +01:00
layer=data_pin.layer,
2019-07-03 00:35:53 +02:00
offset=data_pin.center(),
height=data_pin.height(),
width=data_pin.width())
2019-07-03 00:35:53 +02:00
def route_write_driver_in(self, port):
""" Connecting write driver """
2020-04-14 05:09:10 +02:00
for row in range(self.word_size + self.num_spare_cols):
2019-07-03 00:35:53 +02:00
data_name = "data_{}".format(row)
2019-07-03 22:17:12 +02:00
din_name = "din_{}".format(row)
2019-07-03 00:35:53 +02:00
self.copy_layout_pin(self.write_driver_array_inst, data_name, din_name)
def route_write_mask_and_array_in(self, port):
""" Add pins for the write mask and array input """
2019-08-07 18:33:19 +02:00
for bit in range(self.num_wmasks):
wmask_in_name = "wmask_in_{}".format(bit)
bank_wmask_name = "bank_wmask_{}".format(bit)
self.copy_layout_pin(self.write_mask_and_array_inst, wmask_in_name, bank_wmask_name)
def route_write_mask_and_array_to_write_driver(self, port):
"""
Routing of wdriver_sel_{} between write mask AND array and
write driver array. Adds layout pin for write
mask AND array output and via for write driver enable
"""
wmask_inst = self.write_mask_and_array_inst
wdriver_inst = self.write_driver_array_inst
2019-08-08 17:46:58 +02:00
for bit in range(self.num_wmasks):
# Bring write mask AND array output pin to port data level
self.copy_layout_pin(wmask_inst, "wmask_out_{0}".format(bit), "wdriver_sel_{0}".format(bit))
wmask_out_pin = wmask_inst.get_pin("wmask_out_{0}".format(bit))
wdriver_en_pin = wdriver_inst.get_pin("en_{0}".format(bit))
wmask_pos = wmask_out_pin.center()
wdriver_pos = wdriver_en_pin.rc() - vector(self.m2_pitch, 0)
mid_pos = vector(wdriver_pos.x, wmask_pos.y)
# Add driver on mask output
2020-07-01 23:44:18 +02:00
self.add_via_stack_center(from_layer=wmask_out_pin.layer,
to_layer="m1",
offset=wmask_pos)
# Add via for the write driver array's enable input
2020-07-01 23:44:18 +02:00
self.add_via_stack_center(from_layer=wdriver_en_pin.layer,
to_layer="m2",
offset=wdriver_pos)
# Route between write mask AND array and write driver array
self.add_wire(self.m1_stack, [wmask_pos, mid_pos, wdriver_pos])
2019-07-03 00:35:53 +02:00
def route_column_mux_to_precharge_array(self, port):
""" Routing of BL and BR between col mux and precharge array """
# Only do this if we have a column mux!
if self.col_addr_size==0:
return
start_bit = 1 if self.port == 0 else 0
self.connect_bitlines(inst1=self.column_mux_array_inst,
inst2=self.precharge_array_inst,
num_bits=self.num_cols,
inst2_start_bit=start_bit)
2019-07-11 23:47:27 +02:00
2019-07-03 00:35:53 +02:00
def route_sense_amp_to_column_mux_or_precharge_array(self, port):
""" Routing of BL and BR between sense_amp and column mux or precharge array """
inst2 = self.sense_amp_array_inst
2019-07-03 00:35:53 +02:00
if self.col_addr_size>0:
# Sense amp is connected to the col mux
inst1 = self.column_mux_array_inst
inst1_bls_templ = "{inst}_out_{bit}"
2019-07-25 19:31:39 +02:00
start_bit = 0
2019-07-03 00:35:53 +02:00
else:
# Sense amp is directly connected to the precharge array
inst1 = self.precharge_array_inst
inst1_bls_templ="{inst}_{bit}"
if self.port==0:
2019-07-11 23:47:27 +02:00
start_bit=1
else:
start_bit=0
2020-11-03 15:29:17 +01:00
# spare cols connected to precharge array since they are read independently
2020-06-07 18:27:25 +02:00
if self.num_spare_cols and self.col_addr_size>0:
if self.port==0:
off = 1
else:
off = 0
2021-05-03 06:49:09 +02:00
if OPTS.num_ports > 1:
self.channel_route_bitlines(inst1=self.column_mux_array_inst,
inst1_bls_template="{inst}_out_{bit}",
inst2=inst2,
num_bits=self.word_size,
inst1_start_bit=start_bit)
self.channel_route_bitlines(inst1=self.precharge_array_inst,
inst1_bls_template="{inst}_{bit}",
inst2=inst2,
num_bits=self.num_spare_cols,
inst1_start_bit=self.num_cols + off,
inst2_start_bit=self.word_size)
else:
self.connect_bitlines(inst1=self.column_mux_array_inst,
inst1_bls_template="{inst}_out_{bit}",
inst2=inst2,
num_bits=self.word_size,
inst1_start_bit=start_bit)
self.connect_bitlines(inst1=self.precharge_array_inst,
inst1_bls_template="{inst}_{bit}",
inst2=inst2,
num_bits=self.num_spare_cols,
inst1_start_bit=self.num_cols + off,
inst2_start_bit=self.word_size)
2020-11-03 15:29:17 +01:00
2020-10-27 23:11:04 +01:00
elif layer_props.port_data.channel_route_bitlines:
self.channel_route_bitlines(inst1=inst1,
inst1_bls_template=inst1_bls_templ,
inst2=inst2,
num_bits=self.word_size + self.num_spare_cols,
inst1_start_bit=start_bit)
# This could be a channel route, but in some techs the bitlines
# are too close together.
2020-10-27 23:11:04 +01:00
else:
2020-06-02 20:43:57 +02:00
self.connect_bitlines(inst1=inst1,
inst1_bls_template=inst1_bls_templ,
inst2=inst2,
num_bits=self.word_size,
inst1_start_bit=start_bit)
2020-11-03 15:29:17 +01:00
2019-07-25 19:31:39 +02:00
def route_write_driver_to_column_mux_or_precharge_array(self, port):
""" Routing of BL and BR between sense_amp and column mux or precharge array """
2019-07-03 00:35:53 +02:00
inst2 = self.write_driver_array_inst
2019-07-03 00:35:53 +02:00
if self.col_addr_size>0:
# Write driver is connected to the col mux
inst1 = self.column_mux_array_inst
inst1_bls_templ = "{inst}_out_{bit}"
2019-07-25 19:31:39 +02:00
start_bit = 0
2019-07-03 00:35:53 +02:00
else:
2019-07-25 19:31:39 +02:00
# Sense amp is directly connected to the precharge array
inst1 = self.precharge_array_inst
inst1_bls_templ="{inst}_{bit}"
if self.port==0:
2019-07-25 19:31:39 +02:00
start_bit=1
else:
start_bit=0
2020-04-14 05:09:10 +02:00
if self.port==0:
off = 1
2020-04-14 05:09:10 +02:00
else:
off = 0
2020-04-14 05:09:10 +02:00
2020-11-03 15:29:17 +01:00
# Channel route spare columns' bitlines
2020-06-07 18:27:25 +02:00
if self.num_spare_cols and self.col_addr_size>0:
if self.port==0:
off = 1
else:
off = 0
2020-11-03 15:29:17 +01:00
2020-04-14 05:09:10 +02:00
self.channel_route_bitlines(inst1=self.column_mux_array_inst,
inst1_bls_template="{inst}_out_{bit}",
inst2=inst2,
num_bits=self.word_size,
inst1_start_bit=start_bit)
2020-11-03 15:29:17 +01:00
2020-04-14 05:09:10 +02:00
self.channel_route_bitlines(inst1=self.precharge_array_inst,
inst1_bls_template="{inst}_{bit}",
inst2=inst2,
num_bits=self.num_spare_cols,
inst1_start_bit=self.num_cols + off,
inst2_start_bit=self.word_size)
# This could be a channel route, but in some techs the bitlines
# are too close together.
2020-10-27 23:11:04 +01:00
elif layer_props.port_data.channel_route_bitlines:
self.channel_route_bitlines(inst1=inst1, inst2=inst2,
num_bits=self.word_size + self.num_spare_cols,
inst1_bls_template=inst1_bls_templ,
inst1_start_bit=start_bit)
else:
2020-06-02 20:43:57 +02:00
self.connect_bitlines(inst1=inst1, inst2=inst2,
num_bits=self.word_size,
inst1_bls_template=inst1_bls_templ,
inst1_start_bit=start_bit)
2019-08-07 18:33:19 +02:00
2019-07-03 00:35:53 +02:00
def route_write_driver_to_sense_amp(self, port):
""" Routing of BL and BR between write driver and sense amp """
2019-07-03 00:35:53 +02:00
inst1 = self.write_driver_array_inst
inst2 = self.sense_amp_array_inst
# This could be a channel route, but in some techs the bitlines
# are too close together.
self.connect_bitlines(inst1=inst1,
inst2=inst2,
2020-06-07 18:27:25 +02:00
num_bits=self.word_size + self.num_spare_cols)
2019-07-03 00:35:53 +02:00
2019-07-03 22:17:12 +02:00
def route_bitline_pins(self):
""" Add the bitline pins for the given port """
2019-07-27 15:11:45 +02:00
# Connect one bitline to the RBL and offset the indices for the other BLs
if self.port==0:
self.copy_layout_pin(self.precharge_array_inst, "bl_0", "rbl_bl")
self.copy_layout_pin(self.precharge_array_inst, "br_0", "rbl_br")
2019-07-11 23:47:27 +02:00
bit_offset=1
elif self.port==1:
2020-04-14 05:09:10 +02:00
self.copy_layout_pin(self.precharge_array_inst, "bl_{}".format(self.num_cols + self.num_spare_cols), "rbl_bl")
self.copy_layout_pin(self.precharge_array_inst, "br_{}".format(self.num_cols + self.num_spare_cols), "rbl_br")
2019-07-11 23:47:27 +02:00
bit_offset=0
else:
bit_offset=0
2020-05-09 09:56:19 +02:00
for bit in range(self.num_cols):
2019-07-11 23:47:27 +02:00
if self.precharge_array_inst:
2020-03-05 19:21:18 +01:00
self.copy_layout_pin(self.precharge_array_inst,
"bl_{}".format(bit + bit_offset),
"bl_{}".format(bit))
self.copy_layout_pin(self.precharge_array_inst,
"br_{}".format(bit + bit_offset),
"br_{}".format(bit))
2019-07-03 22:17:12 +02:00
else:
debug.error("Didn't find precharge array.")
2020-11-03 15:29:17 +01:00
2020-05-16 12:09:03 +02:00
# Copy bitlines of spare columns
2020-05-09 09:56:19 +02:00
for bit in range(self.num_spare_cols):
if self.precharge_array_inst:
self.copy_layout_pin(self.precharge_array_inst,
"bl_{}".format(self.num_cols + bit + bit_offset),
"sparebl_{}".format(bit))
self.copy_layout_pin(self.precharge_array_inst,
"br_{}".format(self.num_cols + bit + bit_offset),
"sparebr_{}".format(bit))
else:
debug.error("Didn't find precharge array.")
2019-07-03 22:17:12 +02:00
def route_control_pins(self):
""" Add the control pins: s_en, p_en_bar, w_en """
if self.precharge_array_inst:
self.copy_layout_pin(self.precharge_array_inst, "en_bar", "p_en_bar")
if self.column_mux_array_inst:
sel_names = ["sel_{}".format(x) for x in range(self.num_col_addr_lines)]
for pin_name in sel_names:
self.copy_layout_pin(self.column_mux_array_inst, pin_name)
if self.sense_amp_array_inst:
2020-04-14 05:09:10 +02:00
self.copy_layout_pin(self.sense_amp_array_inst, "en", "s_en")
2019-07-03 22:17:12 +02:00
if self.write_driver_array_inst:
if self.write_mask_and_array_inst:
for bit in range(self.num_wmasks):
# Add write driver's en_{} pins
self.copy_layout_pin(self.write_driver_array_inst, "en_{}".format(bit), "wdriver_sel_{}".format(bit))
2020-05-16 12:09:03 +02:00
for bit in range(self.num_spare_cols):
# Add spare columns' en_{} pins
self.copy_layout_pin(self.write_driver_array_inst, "en_{}".format(bit + self.num_wmasks), "bank_spare_wen{}".format(bit))
2020-05-16 12:09:03 +02:00
elif self.num_spare_cols and not self.write_mask_and_array_inst:
2020-08-25 20:50:44 +02:00
self.copy_layout_pin(self.write_driver_array_inst, "en_0", "w_en")
2020-04-14 05:09:10 +02:00
for bit in range(self.num_spare_cols):
self.copy_layout_pin(self.write_driver_array_inst, "en_{}".format(bit + 1), "bank_spare_wen{}".format(bit))
else:
self.copy_layout_pin(self.write_driver_array_inst, "en", "w_en")
if self.write_mask_and_array_inst:
self.copy_layout_pin(self.write_mask_and_array_inst, "en", "w_en")
def _group_bitline_instances(self, inst1, inst2, num_bits,
inst1_bls_template,
inst1_start_bit,
inst2_bls_template,
inst2_start_bit):
2019-07-03 00:35:53 +02:00
"""
Groups all the parameters into a named tuple and seperates them into
top and bottom instances.
2019-07-03 00:35:53 +02:00
"""
inst_group = namedtuple('InstanceGroup', ('inst', 'bls_template',
'bl_name', 'br_name', 'start_bit'))
inst1_group = inst_group(inst1, inst1_bls_template,
inst1.mod.get_bl_name(),
inst1.mod.get_br_name(),
inst1_start_bit)
inst2_group = inst_group(inst2, inst2_bls_template,
inst2.mod.get_bl_name(),
inst2.mod.get_br_name(),
inst2_start_bit)
2019-07-03 00:35:53 +02:00
# determine top and bottom automatically.
# since they don't overlap, we can just check the bottom y coordinate.
if inst1.by() < inst2.by():
bot_inst_group = inst1_group
top_inst_group = inst2_group
2019-07-03 00:35:53 +02:00
else:
bot_inst_group = inst2_group
top_inst_group = inst1_group
return (bot_inst_group, top_inst_group)
def _get_bitline_pins(self, inst_group, bit):
"""
Extracts bl/br pins from an InstanceGroup based on the bit modifier.
"""
full_bl_name = inst_group.bls_template.format(
2020-03-05 19:21:18 +01:00
**{'inst': inst_group.bl_name,
'bit': inst_group.start_bit + bit}
)
full_br_name = inst_group.bls_template.format(
2020-03-05 19:21:18 +01:00
**{'inst': inst_group.br_name,
'bit': inst_group.start_bit + bit}
)
return (inst_group.inst.get_pin(full_bl_name),
inst_group.inst.get_pin(full_br_name))
2019-07-03 00:35:53 +02:00
def channel_route_bitlines(self, inst1, inst2, num_bits,
inst1_bls_template="{inst}_{bit}",
inst1_start_bit=0,
inst2_bls_template="{inst}_{bit}",
inst2_start_bit=0):
"""
Route the bl and br of two modules using the channel router.
"""
bot_inst_group, top_inst_group = self._group_bitline_instances(inst1, inst2, num_bits,
inst1_bls_template, inst1_start_bit,
inst2_bls_template, inst2_start_bit)
2019-07-03 00:35:53 +02:00
# Channel route each mux separately since we don't minimize the number
# of tracks in teh channel router yet. If we did, we could route all the bits at once!
offset = bot_inst_group.inst.ul() + vector(0, self.m1_nonpref_pitch)
2019-07-03 00:35:53 +02:00
for bit in range(num_bits):
bottom_names = self._get_bitline_pins(bot_inst_group, bit)
top_names = self._get_bitline_pins(top_inst_group, bit)
2019-07-03 00:35:53 +02:00
route_map = list(zip(bottom_names, top_names))
self.create_horizontal_channel_route(route_map, offset, self.m1_stack)
2019-07-03 00:35:53 +02:00
def connect_bitlines(self, inst1, inst2, num_bits,
inst1_bls_template="{inst}_{bit}",
inst1_start_bit=0,
inst2_bls_template="{inst}_{bit}",
inst2_start_bit=0):
2019-07-03 00:35:53 +02:00
"""
Connect the bl and br of two modules.
This assumes that they have sufficient space to create a jog
in the middle between the two modules (if needed).
"""
2020-04-30 00:48:15 +02:00
bot_inst_group, top_inst_group = self._group_bitline_instances(inst1, inst2, num_bits,
inst1_bls_template, inst1_start_bit,
inst2_bls_template, inst2_start_bit)
2019-07-03 00:35:53 +02:00
for col in range(num_bits):
bot_bl_pin, bot_br_pin = self._get_bitline_pins(bot_inst_group, col)
top_bl_pin, top_br_pin = self._get_bitline_pins(top_inst_group, col)
bot_bl, bot_br = bot_bl_pin.uc(), bot_br_pin.uc()
top_bl, top_br = top_bl_pin.bc(), top_br_pin.bc()
2019-07-03 00:35:53 +02:00
2020-06-02 19:08:53 +02:00
layer_pitch = getattr(self, "{}_pitch".format(top_bl_pin.layer))
2020-06-05 01:03:39 +02:00
self.add_zjog(bot_bl_pin.layer, bot_bl, top_bl, "V", fixed_offset=top_bl_pin.by() - layer_pitch)
self.add_zjog(bot_br_pin.layer, bot_br, top_br, "V", fixed_offset=top_bl_pin.by() - 2 * layer_pitch)
2020-04-30 00:48:15 +02:00
2019-07-03 23:46:20 +02:00
def graph_exclude_precharge(self):
"""Precharge adds a loop between bitlines, can be excluded to reduce complexity"""
if self.precharge_array_inst:
self.graph_inst_exclude.add(self.precharge_array_inst)