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
|
2016-11-08 18:57:35 +01:00
|
|
|
import debug
|
2020-09-28 18:53:01 +02:00
|
|
|
import math
|
2020-06-08 16:31:46 +02:00
|
|
|
from tech import drc
|
2019-01-17 01:15:38 +01:00
|
|
|
from sram_factory import factory
|
2022-07-13 19:57:56 +02:00
|
|
|
from base import vector
|
2016-11-08 18:57:35 +01:00
|
|
|
from globals import OPTS
|
|
|
|
|
|
2020-03-31 19:15:46 +02:00
|
|
|
|
2022-07-13 19:57:56 +02:00
|
|
|
class write_driver_array(design):
|
2016-11-08 18:57:35 +01:00
|
|
|
"""
|
|
|
|
|
Array of tristate drivers to write to the bitlines through the column mux.
|
|
|
|
|
Dynamically generated write driver array of all bitlines.
|
|
|
|
|
"""
|
|
|
|
|
|
2020-09-12 00:36:22 +02:00
|
|
|
def __init__(self, name, columns, word_size, offsets=None, num_spare_cols=None, write_size=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))
|
2019-01-26 00:00:00 +01:00
|
|
|
self.add_comment("columns: {0}".format(columns))
|
2020-03-31 05:00:32 +02:00
|
|
|
self.add_comment("word_size {0}".format(word_size))
|
2016-11-08 18:57:35 +01:00
|
|
|
|
|
|
|
|
self.columns = columns
|
|
|
|
|
self.word_size = word_size
|
2022-08-05 01:37:21 +02:00
|
|
|
if write_size is None:
|
|
|
|
|
self.write_size = word_size
|
|
|
|
|
else:
|
|
|
|
|
self.write_size = write_size
|
2020-09-12 00:36:22 +02:00
|
|
|
self.offsets = offsets
|
2020-06-05 20:29:31 +02:00
|
|
|
self.column_offset = column_offset
|
2018-05-12 01:32:00 +02:00
|
|
|
self.words_per_row = int(columns / word_size)
|
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
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2022-07-29 01:45:58 +02:00
|
|
|
if self.write_size != self.word_size:
|
2020-09-28 18:53:01 +02:00
|
|
|
self.num_wmasks = int(math.ceil(self.word_size / self.write_size))
|
2022-08-11 01:35:39 +02:00
|
|
|
else:
|
|
|
|
|
self.num_wmasks = 0
|
2019-07-22 21:44:35 +02:00
|
|
|
|
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:25:00 +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:25:00 +01:00
|
|
|
br_name = "br"
|
2020-02-17 14:09:50 +01:00
|
|
|
return br_name
|
2018-08-28 19:24:09 +02:00
|
|
|
|
2020-02-17 14:23:26 +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_write_array()
|
2020-03-31 05:00:32 +02:00
|
|
|
|
2018-08-28 19:24:09 +02:00
|
|
|
def create_layout(self):
|
2020-03-31 05:00:32 +02:00
|
|
|
|
2018-08-28 19:24:09 +02:00
|
|
|
self.place_write_array()
|
2022-03-01 23:37:51 +01:00
|
|
|
self.width = self.local_insts[-1].rx()
|
2020-09-14 21:05:45 +02:00
|
|
|
self.height = self.driver.height
|
2018-08-28 19:24:09 +02:00
|
|
|
self.add_layout_pins()
|
2022-03-06 18:56:00 +01:00
|
|
|
self.route_supplies()
|
2019-05-28 01:32:38 +02:00
|
|
|
self.add_boundary()
|
2018-08-28 19:24:09 +02:00
|
|
|
self.DRC_LVS()
|
2016-11-08 18:57:35 +01:00
|
|
|
|
|
|
|
|
def add_pins(self):
|
2020-04-14 05:09:10 +02:00
|
|
|
for i in range(self.word_size + self.num_spare_cols):
|
2020-02-17 14:23:26 +01:00
|
|
|
self.add_pin(self.data_name + "_{0}".format(i), "INPUT")
|
2020-04-14 05:09:10 +02:00
|
|
|
for i in range(self.word_size + self.num_spare_cols):
|
2020-02-17 14:23:26 +01:00
|
|
|
self.add_pin(self.get_bl_name() + "_{0}".format(i), "OUTPUT")
|
|
|
|
|
self.add_pin(self.get_br_name() + "_{0}".format(i), "OUTPUT")
|
2022-07-29 01:45:58 +02:00
|
|
|
if self.write_size != self.word_size:
|
2020-05-16 12:09:03 +02:00
|
|
|
for i in range(self.num_wmasks + self.num_spare_cols):
|
2020-02-17 14:23:26 +01:00
|
|
|
self.add_pin(self.en_name + "_{0}".format(i), "INPUT")
|
2022-07-29 01:45:58 +02:00
|
|
|
elif self.num_spare_cols and self.write_size == self.word_size:
|
2020-04-14 05:09:10 +02:00
|
|
|
for i in range(self.num_spare_cols + 1):
|
|
|
|
|
self.add_pin(self.en_name + "_{0}".format(i), "INPUT")
|
2019-07-19 22:17:55 +02:00
|
|
|
else:
|
2020-02-17 14:23:26 +01:00
|
|
|
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")
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2018-08-28 19:24:09 +02:00
|
|
|
def add_modules(self):
|
2019-01-17 01:15:38 +01:00
|
|
|
self.driver = factory.create(module_type="write_driver")
|
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)
|
2016-11-08 18:57:35 +01:00
|
|
|
|
|
|
|
|
def create_write_array(self):
|
2022-03-01 23:37:51 +01:00
|
|
|
self.local_insts = []
|
2019-07-22 21:44:35 +02:00
|
|
|
w = 0
|
|
|
|
|
windex=0
|
2020-03-31 19:15:46 +02:00
|
|
|
for i in range(0, self.columns, self.words_per_row):
|
2018-11-27 21:02:53 +01:00
|
|
|
name = "write_driver{}".format(i)
|
2020-03-31 19:15:46 +02:00
|
|
|
index = int(i / self.words_per_row)
|
2022-03-01 23:37:51 +01:00
|
|
|
self.local_insts.append(self.add_inst(name=name,
|
2020-09-14 21:05:45 +02:00
|
|
|
mod=self.driver))
|
2017-09-11 23:30:52 +02:00
|
|
|
|
2022-07-29 01:45:58 +02:00
|
|
|
if self.write_size != self.word_size:
|
2020-02-17 14:23:26 +01:00
|
|
|
self.connect_inst([self.data_name + "_{0}".format(index),
|
|
|
|
|
self.get_bl_name() + "_{0}".format(index),
|
|
|
|
|
self.get_br_name() + "_{0}".format(index),
|
|
|
|
|
self.en_name + "_{0}".format(windex), "vdd", "gnd"])
|
2019-07-22 21:44:35 +02:00
|
|
|
w+=1
|
2019-08-07 18:12:21 +02:00
|
|
|
# when w equals write size, the next en pin can be connected since we are now at the next wmask bit
|
2019-07-22 21:44:35 +02:00
|
|
|
if w == self.write_size:
|
|
|
|
|
w = 0
|
|
|
|
|
windex+=1
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2022-07-29 01:45:58 +02:00
|
|
|
elif self.num_spare_cols and self.write_size == self.word_size:
|
2020-04-14 05:09:10 +02:00
|
|
|
self.connect_inst([self.data_name + "_{0}".format(index),
|
|
|
|
|
self.get_bl_name() + "_{0}".format(index),
|
|
|
|
|
self.get_br_name() + "_{0}".format(index),
|
|
|
|
|
self.en_name + "_{0}".format(0), "vdd", "gnd"])
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2019-07-19 22:17:55 +02:00
|
|
|
else:
|
2020-02-17 14:23:26 +01:00
|
|
|
self.connect_inst([self.data_name + "_{0}".format(index),
|
|
|
|
|
self.get_bl_name() + "_{0}".format(index),
|
|
|
|
|
self.get_br_name() + "_{0}".format(index),
|
|
|
|
|
self.en_name, "vdd", "gnd"])
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2020-04-14 05:09:10 +02:00
|
|
|
for i in range(self.num_spare_cols):
|
|
|
|
|
index = self.word_size + i
|
2022-07-29 01:45:58 +02:00
|
|
|
if self.write_size != self.word_size:
|
2020-05-16 12:09:03 +02:00
|
|
|
offset = self.num_wmasks
|
|
|
|
|
else:
|
|
|
|
|
offset = 1
|
2020-06-03 14:31:30 +02:00
|
|
|
name = "write_driver{}".format(self.columns + i)
|
2022-03-01 23:37:51 +01:00
|
|
|
self.local_insts.append(self.add_inst(name=name,
|
2020-09-14 21:05:45 +02:00
|
|
|
mod=self.driver))
|
2020-04-14 05:09:10 +02:00
|
|
|
|
|
|
|
|
self.connect_inst([self.data_name + "_{0}".format(index),
|
|
|
|
|
self.get_bl_name() + "_{0}".format(index),
|
|
|
|
|
self.get_br_name() + "_{0}".format(index),
|
2020-05-16 12:09:03 +02:00
|
|
|
self.en_name + "_{0}".format(i + offset), "vdd", "gnd"])
|
2020-04-14 05:09:10 +02:00
|
|
|
|
2018-08-27 20:13:34 +02:00
|
|
|
def place_write_array(self):
|
2018-09-01 08:28:06 +02:00
|
|
|
if self.bitcell.width > self.driver.width:
|
2019-08-09 00:49:23 +02:00
|
|
|
self.driver_spacing = self.bitcell.width
|
2018-09-01 08:28:06 +02:00
|
|
|
else:
|
2019-08-09 00:49:23 +02:00
|
|
|
self.driver_spacing = self.driver.width
|
2020-01-27 17:20:48 +01:00
|
|
|
|
2020-09-12 00:36:22 +02:00
|
|
|
if not self.offsets:
|
|
|
|
|
self.offsets = []
|
|
|
|
|
for i in range(self.columns + self.num_spare_cols):
|
|
|
|
|
self.offsets.append(i * self.driver_spacing)
|
|
|
|
|
|
|
|
|
|
for i, xoffset in enumerate(self.offsets[0:self.columns: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-01-27 17:20:48 +01:00
|
|
|
mirror = "MY"
|
|
|
|
|
xoffset = xoffset + self.driver.width
|
|
|
|
|
else:
|
|
|
|
|
mirror = ""
|
|
|
|
|
|
|
|
|
|
base = vector(xoffset, 0)
|
2022-03-01 23:37:51 +01:00
|
|
|
self.local_insts[i].place(offset=base, mirror=mirror)
|
2018-08-27 20:13:34 +02:00
|
|
|
|
2020-04-14 05:09:10 +02:00
|
|
|
# place spare write drivers (if spare columns are specified)
|
2020-09-12 00:36:22 +02:00
|
|
|
for i, xoffset in enumerate(self.offsets[self.columns:]):
|
2020-04-14 05:09:10 +02:00
|
|
|
index = self.word_size + i
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-11-14 00:55:55 +01:00
|
|
|
if self.bitcell.mirror.y and (index + self.column_offset) % 2:
|
2020-04-14 05:09:10 +02:00
|
|
|
mirror = "MY"
|
|
|
|
|
xoffset = xoffset + self.driver.width
|
|
|
|
|
else:
|
|
|
|
|
mirror = ""
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-04-14 05:09:10 +02:00
|
|
|
base = vector(xoffset, 0)
|
2022-03-01 23:37:51 +01:00
|
|
|
self.local_insts[index].place(offset=base, mirror=mirror)
|
2020-04-14 05:09:10 +02:00
|
|
|
|
2017-08-24 00:02:15 +02:00
|
|
|
def add_layout_pins(self):
|
2020-04-14 05:09:10 +02:00
|
|
|
for i in range(self.word_size + self.num_spare_cols):
|
2022-03-01 23:37:51 +01:00
|
|
|
inst = self.local_insts[i]
|
2020-02-17 14:23:26 +01:00
|
|
|
din_pin = inst.get_pin(inst.mod.din_name)
|
|
|
|
|
self.add_layout_pin(text=self.data_name + "_{0}".format(i),
|
2020-03-31 05:00:32 +02:00
|
|
|
layer=din_pin.layer,
|
2017-08-25 01:22:14 +02:00
|
|
|
offset=din_pin.ll(),
|
|
|
|
|
width=din_pin.width(),
|
2017-08-24 00:02:15 +02:00
|
|
|
height=din_pin.height())
|
2020-02-17 14:23:26 +01:00
|
|
|
bl_pin = inst.get_pin(inst.mod.get_bl_names())
|
|
|
|
|
self.add_layout_pin(text=self.get_bl_name() + "_{0}".format(i),
|
2020-03-31 05:00:32 +02:00
|
|
|
layer=bl_pin.layer,
|
2017-08-25 01:22:14 +02:00
|
|
|
offset=bl_pin.ll(),
|
|
|
|
|
width=bl_pin.width(),
|
2017-08-24 00:02:15 +02:00
|
|
|
height=bl_pin.height())
|
2020-02-17 14:23:26 +01:00
|
|
|
|
|
|
|
|
br_pin = inst.get_pin(inst.mod.get_br_names())
|
|
|
|
|
self.add_layout_pin(text=self.get_br_name() + "_{0}".format(i),
|
2020-03-31 05:00:32 +02:00
|
|
|
layer=br_pin.layer,
|
2017-08-25 01:22:14 +02:00
|
|
|
offset=br_pin.ll(),
|
|
|
|
|
width=br_pin.width(),
|
2017-08-24 00:02:15 +02:00
|
|
|
height=br_pin.height())
|
2018-04-11 18:29:54 +02:00
|
|
|
|
2022-07-29 01:45:58 +02:00
|
|
|
if self.write_size != self.word_size:
|
2019-08-07 18:12:21 +02:00
|
|
|
for bit in range(self.num_wmasks):
|
2022-03-01 23:37:51 +01:00
|
|
|
inst = self.local_insts[bit * self.write_size]
|
2020-09-30 21:39:40 +02:00
|
|
|
en_pin = inst.get_pin(inst.mod.en_name)
|
|
|
|
|
# Determine width of wmask modified en_pin with/without col mux
|
|
|
|
|
wmask_en_len = self.words_per_row * (self.write_size * self.driver_spacing)
|
|
|
|
|
if (self.words_per_row == 1):
|
|
|
|
|
en_gap = self.driver_spacing - en_pin.width()
|
|
|
|
|
else:
|
|
|
|
|
en_gap = self.driver_spacing
|
2019-08-09 00:49:23 +02:00
|
|
|
|
2020-02-17 14:23:26 +01:00
|
|
|
self.add_layout_pin(text=self.en_name + "_{0}".format(bit),
|
2020-09-30 21:39:40 +02:00
|
|
|
layer=en_pin.layer,
|
|
|
|
|
offset=en_pin.ll(),
|
|
|
|
|
width=wmask_en_len - en_gap,
|
|
|
|
|
height=en_pin.height())
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-05-16 12:09:03 +02:00
|
|
|
for i in range(self.num_spare_cols):
|
2022-03-01 23:37:51 +01:00
|
|
|
inst = self.local_insts[self.word_size + i]
|
2020-06-03 14:31:30 +02:00
|
|
|
en_pin = inst.get_pin(inst.mod.en_name)
|
2020-05-16 12:09:03 +02:00
|
|
|
self.add_layout_pin(text=self.en_name + "_{0}".format(i + self.num_wmasks),
|
|
|
|
|
layer="m1",
|
2020-09-30 21:39:40 +02:00
|
|
|
offset=en_pin.lr() + vector(-drc("minwidth_m1"),0))
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2022-07-29 01:45:58 +02:00
|
|
|
elif self.num_spare_cols and self.write_size == self.word_size:
|
2020-04-14 05:09:10 +02:00
|
|
|
# shorten enable rail to accomodate those for spare write drivers
|
2022-03-01 23:37:51 +01:00
|
|
|
left_inst = self.local_insts[0]
|
2020-09-14 23:42:28 +02:00
|
|
|
left_en_pin = left_inst.get_pin(inst.mod.en_name)
|
2022-03-01 23:37:51 +01:00
|
|
|
right_inst = self.local_insts[-self.num_spare_cols - 1]
|
2020-09-14 23:42:28 +02:00
|
|
|
right_en_pin = right_inst.get_pin(inst.mod.en_name)
|
2020-04-14 05:09:10 +02:00
|
|
|
self.add_layout_pin(text=self.en_name + "_{0}".format(0),
|
|
|
|
|
layer="m1",
|
2020-09-14 23:42:28 +02:00
|
|
|
offset=left_en_pin.ll(),
|
|
|
|
|
width=right_en_pin.rx() - left_en_pin.lx())
|
2020-04-14 05:09:10 +02:00
|
|
|
|
|
|
|
|
# individual enables for every spare write driver
|
|
|
|
|
for i in range(self.num_spare_cols):
|
2022-03-01 23:37:51 +01:00
|
|
|
inst = self.local_insts[self.word_size + i]
|
2020-06-03 14:31:30 +02:00
|
|
|
en_pin = inst.get_pin(inst.mod.en_name)
|
2020-04-14 05:09:10 +02:00
|
|
|
self.add_layout_pin(text=self.en_name + "_{0}".format(i + 1),
|
|
|
|
|
layer="m1",
|
2020-09-14 21:53:59 +02:00
|
|
|
offset=en_pin.lr() + vector(-drc("minwidth_m1"), 0))
|
2020-06-08 16:31:46 +02:00
|
|
|
|
2019-08-08 21:57:32 +02:00
|
|
|
else:
|
2022-03-01 23:37:51 +01:00
|
|
|
inst = self.local_insts[0]
|
2020-02-17 14:23:26 +01:00
|
|
|
self.add_layout_pin(text=self.en_name,
|
2019-12-17 20:03:36 +01:00
|
|
|
layer="m1",
|
2020-03-31 19:15:46 +02:00
|
|
|
offset=inst.get_pin(inst.mod.en_name).ll().scale(0, 1),
|
2019-08-21 17:50:12 +02:00
|
|
|
width=self.width)
|
2022-03-06 18:56:00 +01:00
|
|
|
|
|
|
|
|
def route_supplies(self):
|
2022-05-23 19:08:35 +02:00
|
|
|
self.route_horizontal_pins("vdd")
|
|
|
|
|
self.route_horizontal_pins("gnd")
|
2022-03-06 18:56:00 +01:00
|
|
|
|
|
|
|
|
|