2019-04-26 21:21:50 +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 and The Board
|
2019-06-14 17:43:41 +02:00
|
|
|
# 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
|
|
|
#
|
2022-07-13 19:57:56 +02:00
|
|
|
from base import design
|
|
|
|
|
from base import vector
|
2019-01-17 01:15:38 +01:00
|
|
|
from sram_factory import factory
|
2021-05-03 06:49:09 +02:00
|
|
|
from tech import cell_properties
|
2016-11-08 18:57:35 +01:00
|
|
|
import debug
|
|
|
|
|
from globals import OPTS
|
|
|
|
|
|
2020-03-31 19:15:46 +02:00
|
|
|
|
2022-07-13 19:57:56 +02:00
|
|
|
class sense_amp_array(design):
|
2016-11-08 18:57:35 +01:00
|
|
|
"""
|
|
|
|
|
Array of sense amplifiers to read the bitlines through the column mux.
|
|
|
|
|
Dynamically generated sense amp array for all bitlines.
|
|
|
|
|
"""
|
|
|
|
|
|
2020-09-12 00:36:22 +02:00
|
|
|
def __init__(self, name, word_size, words_per_row, offsets=None, num_spare_cols=None, column_offset=0):
|
2020-06-07 18:27:25 +02:00
|
|
|
|
2020-08-06 20:33:26 +02:00
|
|
|
super().__init__(name)
|
2016-11-08 18:57:35 +01:00
|
|
|
debug.info(1, "Creating {0}".format(self.name))
|
2020-03-31 05:00:32 +02:00
|
|
|
self.add_comment("word_size {0}".format(word_size))
|
2019-01-26 00:00:00 +01:00
|
|
|
self.add_comment("words_per_row: {0}".format(words_per_row))
|
2016-11-08 18:57:35 +01:00
|
|
|
|
|
|
|
|
self.word_size = word_size
|
2020-06-26 20:47:55 +02:00
|
|
|
self.words_per_row = words_per_row
|
2020-09-14 21:53:59 +02:00
|
|
|
self.num_cols = word_size * words_per_row
|
2020-09-12 00:36:22 +02:00
|
|
|
self.offsets = offsets
|
2020-04-14 05:09:10 +02:00
|
|
|
if not num_spare_cols:
|
|
|
|
|
self.num_spare_cols = 0
|
|
|
|
|
else:
|
|
|
|
|
self.num_spare_cols = num_spare_cols
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-06-05 20:29:31 +02:00
|
|
|
self.column_offset = column_offset
|
2017-08-24 00:02:15 +02:00
|
|
|
self.row_size = self.word_size * self.words_per_row
|
|
|
|
|
|
2020-06-30 01:23:25 +02:00
|
|
|
if OPTS.tech_name == "sky130":
|
|
|
|
|
self.en_layer = "m3"
|
|
|
|
|
else:
|
|
|
|
|
self.en_layer = "m1"
|
2018-08-28 19:24:09 +02:00
|
|
|
self.create_netlist()
|
|
|
|
|
if not OPTS.netlist_only:
|
|
|
|
|
self.create_layout()
|
|
|
|
|
|
2020-02-17 14:09:50 +01:00
|
|
|
def get_bl_name(self):
|
2020-02-17 14:27:35 +01:00
|
|
|
bl_name = "bl"
|
2020-02-17 14:09:50 +01:00
|
|
|
return bl_name
|
2020-02-12 14:04:05 +01:00
|
|
|
|
2020-02-17 14:09:50 +01:00
|
|
|
def get_br_name(self):
|
2020-02-17 14:27:35 +01:00
|
|
|
br_name = "br"
|
2020-02-17 14:09:50 +01:00
|
|
|
return br_name
|
2020-02-12 14:04:05 +01:00
|
|
|
|
2020-02-17 14:25:55 +01:00
|
|
|
@property
|
|
|
|
|
def data_name(self):
|
|
|
|
|
return "data"
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def en_name(self):
|
|
|
|
|
return "en"
|
|
|
|
|
|
2018-08-28 19:24:09 +02:00
|
|
|
def create_netlist(self):
|
|
|
|
|
self.add_modules()
|
|
|
|
|
self.add_pins()
|
|
|
|
|
self.create_sense_amp_array()
|
|
|
|
|
|
|
|
|
|
def create_layout(self):
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2018-08-28 19:24:09 +02:00
|
|
|
self.place_sense_amp_array()
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-09-14 21:05:45 +02:00
|
|
|
self.height = self.amp.height
|
|
|
|
|
self.width = self.local_insts[-1].rx()
|
|
|
|
|
|
2018-08-28 19:24:09 +02:00
|
|
|
self.add_layout_pins()
|
2022-03-06 18:56:00 +01:00
|
|
|
|
|
|
|
|
self.route_supplies()
|
2018-08-28 19:24:09 +02:00
|
|
|
self.route_rails()
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2019-05-28 01:32:38 +02:00
|
|
|
self.add_boundary()
|
2016-11-08 18:57:35 +01:00
|
|
|
self.DRC_LVS()
|
|
|
|
|
|
|
|
|
|
def add_pins(self):
|
2020-06-26 20:47:55 +02:00
|
|
|
for i in range(0, self.word_size + self.num_spare_cols):
|
2020-02-17 14:25:55 +01:00
|
|
|
self.add_pin(self.data_name + "_{0}".format(i), "OUTPUT")
|
|
|
|
|
self.add_pin(self.get_bl_name() + "_{0}".format(i), "INPUT")
|
|
|
|
|
self.add_pin(self.get_br_name() + "_{0}".format(i), "INPUT")
|
|
|
|
|
self.add_pin(self.en_name, "INPUT")
|
2019-08-06 23:14:09 +02:00
|
|
|
self.add_pin("vdd", "POWER")
|
|
|
|
|
self.add_pin("gnd", "GROUND")
|
2020-03-31 05:00:32 +02:00
|
|
|
|
2018-08-28 19:24:09 +02:00
|
|
|
def add_modules(self):
|
2019-01-17 01:15:38 +01:00
|
|
|
self.amp = factory.create(module_type="sense_amp")
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2018-09-04 20:55:22 +02:00
|
|
|
# This is just used for measurements,
|
|
|
|
|
# so don't add the module
|
2020-11-06 01:55:08 +01:00
|
|
|
self.bitcell = factory.create(module_type=OPTS.bitcell)
|
2020-03-31 05:00:32 +02:00
|
|
|
|
2018-08-27 20:13:34 +02:00
|
|
|
def create_sense_amp_array(self):
|
|
|
|
|
self.local_insts = []
|
2020-06-26 20:47:55 +02:00
|
|
|
for i in range(0, self.word_size + self.num_spare_cols):
|
2017-08-24 00:02:15 +02:00
|
|
|
name = "sa_d{0}".format(i)
|
2018-08-27 20:13:34 +02:00
|
|
|
self.local_insts.append(self.add_inst(name=name,
|
|
|
|
|
mod=self.amp))
|
2020-02-17 14:25:55 +01:00
|
|
|
self.connect_inst([self.get_bl_name() + "_{0}".format(i),
|
|
|
|
|
self.get_br_name() + "_{0}".format(i),
|
|
|
|
|
self.data_name + "_{0}".format(i),
|
|
|
|
|
self.en_name, "vdd", "gnd"])
|
2017-08-24 00:02:15 +02:00
|
|
|
|
2018-08-27 20:13:34 +02:00
|
|
|
def place_sense_amp_array(self):
|
2021-05-03 06:49:09 +02:00
|
|
|
cell = factory.create(module_type=OPTS.bitcell)
|
|
|
|
|
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
|
|
|
|
|
else:
|
|
|
|
|
precharge_width = cell.width
|
|
|
|
|
|
|
|
|
|
if precharge_width > self.amp.width:
|
|
|
|
|
self.amp_spacing = precharge_width
|
2020-09-14 21:05:45 +02:00
|
|
|
else:
|
|
|
|
|
self.amp_spacing = self.amp.width
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-09-14 21:05:45 +02:00
|
|
|
if not self.offsets:
|
|
|
|
|
self.offsets = []
|
|
|
|
|
for i in range(self.num_cols + self.num_spare_cols):
|
2021-05-07 20:29:43 +02:00
|
|
|
self.offsets.append(i * self.amp_spacing)
|
2020-09-14 21:05:45 +02:00
|
|
|
|
2020-09-14 21:53:59 +02:00
|
|
|
for i, xoffset in enumerate(self.offsets[0:self.num_cols:self.words_per_row]):
|
2020-11-14 00:55:55 +01:00
|
|
|
if self.bitcell.mirror.y and (i * self.words_per_row + self.column_offset) % 2:
|
2020-04-14 05:09:10 +02:00
|
|
|
mirror = "MY"
|
2020-09-14 21:05:45 +02:00
|
|
|
xoffset = xoffset + self.amp_spacing
|
2020-04-14 05:09:10 +02:00
|
|
|
else:
|
|
|
|
|
mirror = ""
|
2020-01-27 17:20:48 +01:00
|
|
|
|
2020-04-14 05:09:10 +02:00
|
|
|
amp_position = vector(xoffset, 0)
|
2020-09-14 21:05:45 +02:00
|
|
|
self.local_insts[i].place(offset=amp_position, mirror=mirror)
|
2020-04-14 05:09:10 +02:00
|
|
|
# place spare sense amps (will share the same enable as regular sense amps)
|
2020-09-14 21:53:59 +02:00
|
|
|
for i, xoffset in enumerate(self.offsets[self.num_cols:]):
|
2020-04-14 05:09:10 +02:00
|
|
|
index = self.word_size + i
|
2020-11-14 00:55:55 +01:00
|
|
|
if self.bitcell.mirror.y and (index + self.column_offset) % 2:
|
2020-01-27 17:20:48 +01:00
|
|
|
mirror = "MY"
|
2021-05-07 20:29:43 +02:00
|
|
|
xoffset = xoffset + self.amp_spacing
|
2020-01-27 17:20:48 +01:00
|
|
|
else:
|
|
|
|
|
mirror = ""
|
|
|
|
|
|
|
|
|
|
amp_position = vector(xoffset, 0)
|
2020-06-05 20:29:31 +02:00
|
|
|
self.local_insts[index].place(offset=amp_position, mirror=mirror)
|
2018-08-27 20:13:34 +02:00
|
|
|
|
|
|
|
|
def add_layout_pins(self):
|
|
|
|
|
for i in range(len(self.local_insts)):
|
|
|
|
|
inst = self.local_insts[i]
|
2019-12-23 16:37:16 +01:00
|
|
|
|
2020-02-17 14:25:55 +01:00
|
|
|
bl_pin = inst.get_pin(inst.mod.get_bl_names())
|
|
|
|
|
br_pin = inst.get_pin(inst.mod.get_br_names())
|
|
|
|
|
dout_pin = inst.get_pin(inst.mod.dout_name)
|
|
|
|
|
|
|
|
|
|
self.add_layout_pin(text=self.get_bl_name() + "_{0}".format(i),
|
2020-03-31 05:00:32 +02:00
|
|
|
layer=bl_pin.layer,
|
2018-08-27 20:13:34 +02:00
|
|
|
offset=bl_pin.ll(),
|
2017-08-24 00:02:15 +02:00
|
|
|
width=bl_pin.width(),
|
|
|
|
|
height=bl_pin.height())
|
2020-02-17 14:25:55 +01:00
|
|
|
self.add_layout_pin(text=self.get_br_name() + "_{0}".format(i),
|
2020-03-31 05:00:32 +02:00
|
|
|
layer=br_pin.layer,
|
2018-08-27 20:13:34 +02:00
|
|
|
offset=br_pin.ll(),
|
2017-08-24 00:02:15 +02:00
|
|
|
width=br_pin.width(),
|
|
|
|
|
height=br_pin.height())
|
2020-02-17 14:25:55 +01:00
|
|
|
|
|
|
|
|
self.add_layout_pin(text=self.data_name + "_{0}".format(i),
|
2020-03-31 05:00:32 +02:00
|
|
|
layer=dout_pin.layer,
|
2018-08-27 20:13:34 +02:00
|
|
|
offset=dout_pin.ll(),
|
2017-08-24 00:02:15 +02:00
|
|
|
width=dout_pin.width(),
|
|
|
|
|
height=dout_pin.height())
|
2020-03-31 05:00:32 +02:00
|
|
|
|
2022-03-06 18:56:00 +01:00
|
|
|
def route_supplies(self):
|
2022-05-11 20:01:14 +02:00
|
|
|
self.route_horizontal_pins("vdd")
|
|
|
|
|
self.route_horizontal_pins("gnd")
|
2022-03-06 18:56:00 +01:00
|
|
|
|
2018-08-27 20:13:34 +02:00
|
|
|
def route_rails(self):
|
2020-06-30 01:23:25 +02:00
|
|
|
# Add enable across the array
|
|
|
|
|
en_pin = self.amp.get_pin(self.amp.en_name)
|
|
|
|
|
start_offset = en_pin.lc().scale(0, 1)
|
|
|
|
|
end_offset = start_offset + vector(self.width, 0)
|
|
|
|
|
self.add_layout_pin_segment_center(text=self.en_name,
|
|
|
|
|
layer=self.en_layer,
|
|
|
|
|
start=start_offset,
|
|
|
|
|
end=end_offset)
|
|
|
|
|
for inst in self.local_insts:
|
|
|
|
|
self.add_via_stack_center(from_layer=en_pin.layer,
|
|
|
|
|
to_layer=self.en_layer,
|
|
|
|
|
offset=inst.get_pin(self.amp.en_name).center())
|