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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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):
|
2019-08-06 23:14:09 +02:00
|
|
|
self.add_pin("data_{0}".format(i), "INPUT")
|
2017-08-25 01:22:14 +02:00
|
|
|
for i in range(self.word_size):
|
2019-08-06 23:14:09 +02:00
|
|
|
self.add_pin("bl_{0}".format(i), "OUTPUT")
|
|
|
|
|
self.add_pin("br_{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):
|
2019-08-08 17:46:58 +02:00
|
|
|
self.add_pin("en_{0}".format(i), "INPUT")
|
2019-07-19 22:17:55 +02:00
|
|
|
else:
|
2019-08-06 23:14:09 +02:00
|
|
|
self.add_pin("en", "INPUT")
|
|
|
|
|
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:
|
2019-07-19 22:17:55 +02:00
|
|
|
self.connect_inst(["data_{0}".format(index),
|
|
|
|
|
"bl_{0}".format(index),
|
|
|
|
|
"br_{0}".format(index),
|
2019-07-22 21:44:35 +02:00
|
|
|
"en_{0}".format(windex), "vdd", "gnd"])
|
|
|
|
|
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:
|
|
|
|
|
self.connect_inst(["data_{0}".format(index),
|
|
|
|
|
"bl_{0}".format(index),
|
|
|
|
|
"br_{0}".format(index),
|
|
|
|
|
"en", "vdd", "gnd"])
|
2016-11-08 18:57:35 +01: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
|
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)
|
2019-08-09 00:49:23 +02:00
|
|
|
base = vector(i * self.driver_spacing, 0)
|
2018-08-28 02:25:39 +02:00
|
|
|
self.driver_insts[index].place(base)
|
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):
|
|
|
|
|
din_pin = self.driver_insts[i].get_pin("din")
|
2018-10-11 18:53:08 +02:00
|
|
|
self.add_layout_pin(text="data_{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())
|
2018-02-01 02:37:16 +01:00
|
|
|
bl_pin = self.driver_insts[i].get_pin("bl")
|
2018-10-11 18:53:08 +02:00
|
|
|
self.add_layout_pin(text="bl_{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())
|
|
|
|
|
|
2018-02-01 02:37:16 +01:00
|
|
|
br_pin = self.driver_insts[i].get_pin("br")
|
2018-10-11 18:53:08 +02:00
|
|
|
self.add_layout_pin(text="br_{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:
|
|
|
|
|
pin_pos = pin.center()
|
|
|
|
|
# Add the M2->M3 stack
|
2019-12-13 23:13:41 +01:00
|
|
|
self.add_via_center(layers=self.m2_stack,
|
2018-04-17 01:15:35 +02:00
|
|
|
offset=pin_pos)
|
|
|
|
|
self.add_layout_pin_rect_center(text=n,
|
2019-12-17 20:03:36 +01:00
|
|
|
layer="m3",
|
2018-04-17 01:15:35 +02:00
|
|
|
offset=pin_pos)
|
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):
|
2019-08-08 17:46:58 +02:00
|
|
|
en_pin = self.driver_insts[bit*self.write_size].get_pin("en")
|
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
|
|
|
|
|
|
2019-08-08 17:46:58 +02:00
|
|
|
self.add_layout_pin(text="en_{0}".format(bit),
|
|
|
|
|
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:
|
2019-08-07 18:12:21 +02:00
|
|
|
self.add_layout_pin(text="en",
|
2019-12-17 20:03:36 +01:00
|
|
|
layer="m1",
|
2019-08-07 18:12:21 +02:00
|
|
|
offset=self.driver_insts[0].get_pin("en").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)
|