2020-05-14 20:20:37 +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
|
2020-05-14 20:20:37 +02:00
|
|
|
# of Regents for the Oklahoma Agricultural and Mechanical College
|
|
|
|
|
# (acting for and on behalf of Oklahoma State University)
|
|
|
|
|
# All rights reserved.
|
|
|
|
|
#
|
|
|
|
|
import debug
|
|
|
|
|
from vector import vector
|
|
|
|
|
import design
|
|
|
|
|
from sram_factory import factory
|
|
|
|
|
from globals import OPTS
|
|
|
|
|
from tech import layer
|
2020-10-28 17:54:15 +01:00
|
|
|
from tech import layer_properties as layer_props
|
2020-05-14 20:20:37 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class wordline_driver(design.design):
|
|
|
|
|
"""
|
|
|
|
|
This is an AND (or NAND) with configurable drive strength to drive the wordlines.
|
|
|
|
|
It is matched to the bitcell height.
|
|
|
|
|
"""
|
2020-09-28 20:30:21 +02:00
|
|
|
def __init__(self, name, cols, height=None):
|
2020-05-14 20:20:37 +02:00
|
|
|
debug.info(1, "Creating wordline_driver {}".format(name))
|
2020-09-17 23:45:49 +02:00
|
|
|
self.add_comment("cols: {}".format(cols))
|
2020-08-12 20:15:32 +02:00
|
|
|
super().__init__(name)
|
2020-05-14 20:20:37 +02:00
|
|
|
|
|
|
|
|
if height is None:
|
2020-11-06 20:09:50 +01:00
|
|
|
b = factory.create(module_type=OPTS.bitcell)
|
2020-05-14 20:20:37 +02:00
|
|
|
self.height = b.height
|
|
|
|
|
else:
|
|
|
|
|
self.height = height
|
2020-09-17 23:45:49 +02:00
|
|
|
self.cols = cols
|
2020-05-14 20:20:37 +02:00
|
|
|
|
|
|
|
|
self.create_netlist()
|
|
|
|
|
if not OPTS.netlist_only:
|
|
|
|
|
self.create_layout()
|
|
|
|
|
|
|
|
|
|
def create_netlist(self):
|
|
|
|
|
self.add_pins()
|
|
|
|
|
self.create_modules()
|
|
|
|
|
self.create_insts()
|
|
|
|
|
|
|
|
|
|
def create_modules(self):
|
2020-06-02 01:46:00 +02:00
|
|
|
self.nand = factory.create(module_type="nand2_dec",
|
|
|
|
|
height=self.height)
|
2020-09-17 23:45:49 +02:00
|
|
|
|
2020-11-19 19:48:35 +01:00
|
|
|
local_array_size = OPTS.local_array_size
|
|
|
|
|
if local_array_size > 0:
|
2020-09-28 21:24:55 +02:00
|
|
|
driver_size = max(int(self.cols / local_array_size), 1)
|
2020-11-19 19:48:35 +01:00
|
|
|
else:
|
2020-09-17 23:45:49 +02:00
|
|
|
# Defautl to FO4
|
2020-09-28 21:24:55 +02:00
|
|
|
driver_size = max(int(self.cols / 4), 1)
|
2020-09-17 23:45:49 +02:00
|
|
|
|
|
|
|
|
# The polarity must be switched if we have a hierarchical wordline
|
|
|
|
|
# to compensate for the local array inverters
|
|
|
|
|
if local_array_size > 0:
|
|
|
|
|
self.driver = factory.create(module_type="buf_dec",
|
|
|
|
|
size=driver_size,
|
|
|
|
|
height=self.nand.height)
|
|
|
|
|
else:
|
|
|
|
|
self.driver = factory.create(module_type="inv_dec",
|
|
|
|
|
size=driver_size,
|
|
|
|
|
height=self.nand.height)
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-05-14 20:20:37 +02:00
|
|
|
self.add_mod(self.nand)
|
|
|
|
|
self.add_mod(self.driver)
|
|
|
|
|
|
|
|
|
|
def create_layout(self):
|
|
|
|
|
self.width = self.nand.width + self.driver.width
|
|
|
|
|
if "li" in layer:
|
|
|
|
|
self.route_layer = "li"
|
|
|
|
|
else:
|
|
|
|
|
self.route_layer = "m1"
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-05-14 20:20:37 +02:00
|
|
|
self.place_insts()
|
|
|
|
|
self.route_wires()
|
|
|
|
|
self.add_layout_pins()
|
|
|
|
|
self.route_supply_rails()
|
|
|
|
|
self.add_boundary()
|
|
|
|
|
self.DRC_LVS()
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-05-14 20:20:37 +02:00
|
|
|
def add_pins(self):
|
|
|
|
|
self.add_pin("A", "INPUT")
|
|
|
|
|
self.add_pin("B", "INPUT")
|
|
|
|
|
self.add_pin("Z", "OUTPUT")
|
|
|
|
|
self.add_pin("vdd", "POWER")
|
|
|
|
|
self.add_pin("gnd", "GROUND")
|
|
|
|
|
|
|
|
|
|
def create_insts(self):
|
|
|
|
|
self.nand_inst = self.add_inst(name="wld_nand",
|
|
|
|
|
mod=self.nand)
|
|
|
|
|
self.connect_inst(["A", "B", "zb_int", "vdd", "gnd"])
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-05-14 20:20:37 +02:00
|
|
|
self.driver_inst = self.add_inst(name="wl_driver",
|
|
|
|
|
mod=self.driver)
|
|
|
|
|
self.connect_inst(["zb_int", "Z", "vdd", "gnd"])
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-05-14 20:20:37 +02:00
|
|
|
def place_insts(self):
|
|
|
|
|
# Add NAND to the right
|
|
|
|
|
self.nand_inst.place(offset=vector(0, 0))
|
|
|
|
|
|
|
|
|
|
# Add INV to the right
|
|
|
|
|
self.driver_inst.place(offset=vector(self.nand_inst.rx(), 0))
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-05-14 20:20:37 +02:00
|
|
|
def route_supply_rails(self):
|
|
|
|
|
""" Add vdd/gnd rails to the top, (middle), and bottom. """
|
2020-10-28 17:54:15 +01:00
|
|
|
if layer_props.wordline_driver.vertical_supply:
|
2020-05-14 20:20:37 +02:00
|
|
|
for name in ["vdd", "gnd"]:
|
|
|
|
|
for inst in [self.nand_inst, self.driver_inst]:
|
|
|
|
|
self.copy_layout_pin(inst, name)
|
|
|
|
|
else:
|
|
|
|
|
self.add_layout_pin_rect_center(text="gnd",
|
|
|
|
|
layer=self.route_layer,
|
|
|
|
|
offset=vector(0.5 * self.width, 0),
|
|
|
|
|
width=self.width)
|
|
|
|
|
|
|
|
|
|
y_offset = self.height
|
|
|
|
|
self.add_layout_pin_rect_center(text="vdd",
|
|
|
|
|
layer=self.route_layer,
|
|
|
|
|
offset=vector(0.5 * self.width, y_offset),
|
|
|
|
|
width=self.width)
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-05-14 20:20:37 +02:00
|
|
|
def route_wires(self):
|
|
|
|
|
|
|
|
|
|
# nand Z to inv A
|
|
|
|
|
z1_pin = self.nand_inst.get_pin("Z")
|
|
|
|
|
a2_pin = self.driver_inst.get_pin("A")
|
2020-06-12 23:23:26 +02:00
|
|
|
if OPTS.tech_name == "sky130":
|
2020-05-14 20:20:37 +02:00
|
|
|
mid1_point = vector(a2_pin.cx(), z1_pin.cy())
|
|
|
|
|
else:
|
|
|
|
|
mid1_point = vector(z1_pin.cx(), a2_pin.cy())
|
|
|
|
|
self.add_path(self.route_layer,
|
|
|
|
|
[z1_pin.center(), mid1_point, a2_pin.center()])
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-05-14 20:20:37 +02:00
|
|
|
def add_layout_pins(self):
|
|
|
|
|
pin = self.driver_inst.get_pin("Z")
|
|
|
|
|
self.add_layout_pin_rect_center(text="Z",
|
|
|
|
|
layer=pin.layer,
|
|
|
|
|
offset=pin.center(),
|
|
|
|
|
width=pin.width(),
|
|
|
|
|
height=pin.height())
|
|
|
|
|
|
|
|
|
|
for pin_name in ["A", "B"]:
|
|
|
|
|
pin = self.nand_inst.get_pin(pin_name)
|
|
|
|
|
self.add_layout_pin_rect_center(text=pin_name,
|
|
|
|
|
layer=pin.layer,
|
|
|
|
|
offset=pin.center(),
|
|
|
|
|
width=pin.width(),
|
|
|
|
|
height=pin.height())
|
|
|
|
|
|
|
|
|
|
def get_stage_efforts(self, external_cout, inp_is_rise=False):
|
|
|
|
|
"""Get the stage efforts of the A or B -> Z path"""
|
|
|
|
|
stage_effort_list = []
|
|
|
|
|
stage1_cout = self.driver.get_cin()
|
|
|
|
|
stage1 = self.nand.get_stage_effort(stage1_cout, inp_is_rise)
|
|
|
|
|
stage_effort_list.append(stage1)
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-05-14 20:20:37 +02:00
|
|
|
stage2 = self.driver.get_stage_effort(external_cout, stage1.is_rise)
|
|
|
|
|
stage_effort_list.append(stage2)
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-05-14 20:20:37 +02:00
|
|
|
return stage_effort_list
|
|
|
|
|
|
|
|
|
|
def get_cin(self):
|
|
|
|
|
"""Return the relative input capacitance of a single input"""
|
|
|
|
|
return self.nand.get_cin()
|
2020-11-03 15:29:17 +01:00
|
|
|
|