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
|
|
|
#
|
2016-11-08 18:57:35 +01:00
|
|
|
from math import log
|
|
|
|
|
import design
|
|
|
|
|
from tech import drc
|
|
|
|
|
import debug
|
2019-01-17 01:15:38 +01:00
|
|
|
from sram_factory import factory
|
2016-11-08 18:57:35 +01:00
|
|
|
from vector import vector
|
|
|
|
|
from globals import OPTS
|
|
|
|
|
|
|
|
|
|
class write_driver_array(design.design):
|
|
|
|
|
"""
|
|
|
|
|
Array of tristate drivers to write to the bitlines through the column mux.
|
|
|
|
|
Dynamically generated write driver array of all bitlines.
|
|
|
|
|
"""
|
|
|
|
|
|
2019-07-19 23:58:37 +02:00
|
|
|
def __init__(self, name, columns, word_size,write_size=None):
|
2019-01-17 01:15:38 +01:00
|
|
|
design.design.__init__(self, 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))
|
|
|
|
|
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
|
2019-07-19 22:17:55 +02:00
|
|
|
self.write_size = write_size
|
2018-05-12 01:32:00 +02:00
|
|
|
self.words_per_row = int(columns / word_size)
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2019-08-21 23:29:57 +02:00
|
|
|
if self.write_size:
|
2019-07-22 21:44:35 +02:00
|
|
|
self.num_wmasks = int(self.word_size/self.write_size)
|
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
|
|
def create_layout(self):
|
2018-09-01 08:28:06 +02:00
|
|
|
|
|
|
|
|
if self.bitcell.width > self.driver.width:
|
|
|
|
|
self.width = self.columns * self.bitcell.width
|
|
|
|
|
else:
|
|
|
|
|
self.width = self.columns * self.driver.width
|
2018-08-28 19:24:09 +02:00
|
|
|
self.height = self.driver.height
|
2017-08-24 00:02:15 +02:00
|
|
|
|
2018-08-28 19:24:09 +02:00
|
|
|
self.place_write_array()
|
|
|
|
|
self.add_layout_pins()
|
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):
|
2017-08-25 01:22:14 +02:00
|
|
|
for i in range(self.word_size):
|
2020-02-17 14:23:26 +01:00
|
|
|
self.add_pin(self.data_name + "_{0}".format(i), "INPUT")
|
|
|
|
|
for i in range(self.word_size):
|
|
|
|
|
self.add_pin(self.get_bl_name() + "_{0}".format(i), "OUTPUT")
|
|
|
|
|
self.add_pin(self.get_br_name() + "_{0}".format(i), "OUTPUT")
|
2019-08-23 00:02:52 +02:00
|
|
|
if self.write_size:
|
2019-07-22 21:44:35 +02:00
|
|
|
for i in range(self.num_wmasks):
|
2020-02-17 14:23:26 +01:00
|
|
|
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-08-28 19:24:09 +02:00
|
|
|
self.add_mod(self.driver)
|
2018-09-04 20:55:22 +02:00
|
|
|
|
|
|
|
|
# This is just used for measurements,
|
|
|
|
|
# so don't add the module
|
2019-01-17 01:15:38 +01:00
|
|
|
self.bitcell = factory.create(module_type="bitcell")
|
2016-11-08 18:57:35 +01:00
|
|
|
|
|
|
|
|
def create_write_array(self):
|
2017-08-25 01:22:14 +02:00
|
|
|
self.driver_insts = {}
|
2019-07-22 21:44:35 +02:00
|
|
|
w = 0
|
|
|
|
|
windex=0
|
2017-08-24 00:02:15 +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)
|
2018-05-12 01:32:00 +02:00
|
|
|
index = int(i/self.words_per_row)
|
|
|
|
|
self.driver_insts[index]=self.add_inst(name=name,
|
2018-08-27 20:13:34 +02:00
|
|
|
mod=self.driver)
|
2017-09-11 23:30:52 +02:00
|
|
|
|
2019-08-21 23:29:57 +02:00
|
|
|
if self.write_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
|
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
|
|
|
|
|
|
|
|
|
2018-08-27 20:13:34 +02:00
|
|
|
def place_write_array(self):
|
2020-01-27 17:20:48 +01:00
|
|
|
from tech import cell_properties
|
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
|
2018-08-27 20:13:34 +02:00
|
|
|
for i in range(0,self.columns,self.words_per_row):
|
2019-08-08 17:46:58 +02:00
|
|
|
index = int(i/self.words_per_row)
|
2020-01-27 17:20:48 +01:00
|
|
|
xoffset = i * self.driver_spacing
|
|
|
|
|
|
|
|
|
|
if cell_properties.bitcell.mirror.y and i % 2:
|
|
|
|
|
mirror = "MY"
|
|
|
|
|
xoffset = xoffset + self.driver.width
|
|
|
|
|
else:
|
|
|
|
|
mirror = ""
|
|
|
|
|
|
|
|
|
|
base = vector(xoffset, 0)
|
|
|
|
|
self.driver_insts[index].place(offset=base, mirror=mirror)
|
2018-08-27 20:13:34 +02:00
|
|
|
|
|
|
|
|
|
2017-08-24 00:02:15 +02:00
|
|
|
def add_layout_pins(self):
|
2017-08-25 01:22:14 +02:00
|
|
|
for i in range(self.word_size):
|
2020-02-17 14:23:26 +01:00
|
|
|
inst = self.driver_insts[i]
|
|
|
|
|
din_pin = inst.get_pin(inst.mod.din_name)
|
|
|
|
|
self.add_layout_pin(text=self.data_name + "_{0}".format(i),
|
2019-12-17 20:03:36 +01:00
|
|
|
layer="m2",
|
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),
|
2019-12-17 20:03:36 +01:00
|
|
|
layer="m2",
|
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),
|
2019-12-17 20:03:36 +01:00
|
|
|
layer="m2",
|
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
|
|
|
|
|
|
|
|
for n in ["vdd", "gnd"]:
|
2018-04-17 01:15:35 +02:00
|
|
|
pin_list = self.driver_insts[i].get_pins(n)
|
|
|
|
|
for pin in pin_list:
|
2019-12-23 16:37:16 +01:00
|
|
|
self.add_power_pin(name = n,
|
|
|
|
|
loc = pin.center(),
|
|
|
|
|
vertical=True,
|
|
|
|
|
start_layer = "m2")
|
2019-08-23 00:02:52 +02:00
|
|
|
if self.write_size:
|
2019-08-07 18:12:21 +02:00
|
|
|
for bit in range(self.num_wmasks):
|
2020-02-17 14:23:26 +01:00
|
|
|
inst = self.driver_insts[bit*self.write_size]
|
|
|
|
|
en_pin = inst.get_pin(inst.mod.en_name)
|
2019-08-09 00:49:23 +02:00
|
|
|
# Determine width of wmask modified en_pin with/without col mux
|
2019-08-21 17:50:12 +02:00
|
|
|
wmask_en_len = self.words_per_row*(self.write_size * self.driver_spacing)
|
2019-08-09 00:49:23 +02:00
|
|
|
if (self.words_per_row == 1):
|
|
|
|
|
en_gap = self.driver_spacing - en_pin.width()
|
|
|
|
|
else:
|
|
|
|
|
en_gap = self.driver_spacing
|
|
|
|
|
|
2020-02-17 14:23:26 +01:00
|
|
|
self.add_layout_pin(text=self.en_name + "_{0}".format(bit),
|
2019-08-08 17:46:58 +02:00
|
|
|
layer=en_pin.layer,
|
|
|
|
|
offset=en_pin.ll(),
|
2019-08-09 00:49:23 +02:00
|
|
|
width=wmask_en_len-en_gap,
|
2019-08-08 17:46:58 +02:00
|
|
|
height=en_pin.height())
|
2019-08-08 21:57:32 +02:00
|
|
|
else:
|
2020-02-17 14:23:26 +01:00
|
|
|
inst = self.driver_insts[0]
|
|
|
|
|
self.add_layout_pin(text=self.en_name,
|
2019-12-17 20:03:36 +01:00
|
|
|
layer="m1",
|
2020-02-17 14:23:26 +01:00
|
|
|
offset=inst.get_pin(inst.mod.en_name).ll().scale(0,1),
|
2019-08-21 17:50:12 +02:00
|
|
|
width=self.width)
|
2018-04-11 18:29:54 +02:00
|
|
|
|
|
|
|
|
|
2017-08-24 00:02:15 +02:00
|
|
|
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2019-01-23 21:03:52 +01:00
|
|
|
def get_w_en_cin(self):
|
|
|
|
|
"""Get the relative capacitance of all the enable connections in the bank"""
|
|
|
|
|
#The enable is connected to a nand2 for every row.
|
|
|
|
|
return self.driver.get_w_en_cin() * len(self.driver_insts)
|