OpenRAM/compiler/modules/sense_amp_array.py

194 lines
7.0 KiB
Python
Raw Normal View History

# 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.
#
2016-11-08 18:57:35 +01:00
import design
from vector import vector
2019-01-17 01:15:38 +01:00
from sram_factory import factory
2016-11-08 18:57:35 +01:00
import debug
from globals import OPTS
2020-03-31 19:15:46 +02:00
2016-11-08 18:57:35 +01:00
class sense_amp_array(design.design):
"""
Array of sense amplifiers to read the bitlines through the column mux.
Dynamically generated sense amp array for all bitlines.
"""
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))
self.add_comment("word_size {0}".format(word_size))
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
self.num_cols = word_size * words_per_row
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
self.column_offset = column_offset
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"
self.create_netlist()
if not OPTS.netlist_only:
self.create_layout()
def get_bl_name(self):
bl_name = "bl"
return bl_name
def get_br_name(self):
br_name = "br"
return br_name
@property
def data_name(self):
return "data"
@property
def en_name(self):
return "en"
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
self.place_sense_amp_array()
2020-11-03 15:29:17 +01:00
self.height = self.amp.height
self.width = self.local_insts[-1].rx()
self.add_layout_pins()
self.route_rails()
2020-11-03 15:29:17 +01: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):
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")
def add_modules(self):
2019-01-17 01:15:38 +01:00
self.amp = factory.create(module_type="sense_amp")
self.add_mod(self.amp)
2016-11-08 18:57:35 +01: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)
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):
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))
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"])
2018-08-27 20:13:34 +02:00
def place_sense_amp_array(self):
if self.bitcell.width > self.amp.width:
self.amp_spacing = self.bitcell.width
else:
self.amp_spacing = self.amp.width
2020-11-03 15:29:17 +01:00
if not self.offsets:
self.offsets = []
for i in range(self.num_cols + self.num_spare_cols):
self.offsets.append(i * self.bitcell.width)
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"
xoffset = xoffset + self.amp_spacing
2020-04-14 05:09:10 +02:00
else:
mirror = ""
2020-04-14 05:09:10 +02:00
amp_position = vector(xoffset, 0)
self.local_insts[i].place(offset=amp_position, mirror=mirror)
2020-11-03 15:29:17 +01:00
2020-04-14 05:09:10 +02:00
# place spare sense amps (will share the same enable as regular sense amps)
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:
mirror = "MY"
xoffset = xoffset + self.amp_width
else:
mirror = ""
amp_position = vector(xoffset, 0)
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]
2020-06-26 20:47:55 +02:00
for gnd_pin in inst.get_pins("gnd"):
self.add_power_pin(name="gnd",
loc=gnd_pin.center(),
start_layer=gnd_pin.layer,
directions=("V", "V"))
for vdd_pin in inst.get_pins("vdd"):
self.add_power_pin(name="vdd",
loc=vdd_pin.center(),
start_layer=vdd_pin.layer,
directions=("V", "V"))
2018-08-27 20:13:34 +02: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),
layer=bl_pin.layer,
2018-08-27 20:13:34 +02:00
offset=bl_pin.ll(),
width=bl_pin.width(),
height=bl_pin.height())
self.add_layout_pin(text=self.get_br_name() + "_{0}".format(i),
layer=br_pin.layer,
2018-08-27 20:13:34 +02:00
offset=br_pin.ll(),
width=br_pin.width(),
height=br_pin.height())
self.add_layout_pin(text=self.data_name + "_{0}".format(i),
layer=dout_pin.layer,
2018-08-27 20:13:34 +02:00
offset=dout_pin.ll(),
width=dout_pin.width(),
height=dout_pin.height())
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())