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
|
|
|
#
|
2017-08-24 00:02:15 +02:00
|
|
|
import debug
|
|
|
|
|
import design
|
|
|
|
|
from tech import drc
|
|
|
|
|
from contact import contact
|
|
|
|
|
from vector import vector
|
|
|
|
|
from globals import OPTS
|
2019-01-17 01:15:38 +01:00
|
|
|
from sram_factory import factory
|
2017-08-24 00:02:15 +02:00
|
|
|
|
|
|
|
|
class delay_chain(design.design):
|
|
|
|
|
"""
|
2018-02-14 00:54:50 +01:00
|
|
|
Generate a delay chain with the given number of stages and fanout.
|
2018-07-19 19:51:20 +02:00
|
|
|
Input is a list contains the electrical effort (fanout) of each stage.
|
|
|
|
|
Usually, this will be constant, but it could have varied fanout.
|
2017-08-24 00:02:15 +02:00
|
|
|
"""
|
|
|
|
|
|
2019-01-17 01:15:38 +01:00
|
|
|
def __init__(self, name, fanout_list):
|
2017-08-24 00:02:15 +02:00
|
|
|
"""init function"""
|
|
|
|
|
design.design.__init__(self, name)
|
2019-01-26 00:00:00 +01:00
|
|
|
debug.info(1, "creating delay chain {0}".format(str(fanout_list)))
|
|
|
|
|
self.add_comment("fanouts: {0}".format(str(fanout_list)))
|
|
|
|
|
|
2018-07-19 19:51:20 +02:00
|
|
|
# Two fanouts are needed so that we can route the vdd/gnd connections
|
2018-02-16 20:51:01 +01:00
|
|
|
for f in fanout_list:
|
2018-07-19 19:51:20 +02:00
|
|
|
debug.check(f>=2,"Must have >=2 fanouts for each stage.")
|
2018-02-16 20:51:01 +01:00
|
|
|
|
2017-08-24 00:02:15 +02:00
|
|
|
# number of inverters including any fanout loads.
|
|
|
|
|
self.fanout_list = fanout_list
|
|
|
|
|
|
2018-08-28 01:42:48 +02:00
|
|
|
self.create_netlist()
|
|
|
|
|
if not OPTS.netlist_only:
|
|
|
|
|
self.create_layout()
|
|
|
|
|
|
2017-08-24 00:02:15 +02:00
|
|
|
|
2018-08-28 01:42:48 +02:00
|
|
|
def create_netlist(self):
|
|
|
|
|
self.add_modules()
|
2018-08-28 19:24:09 +02:00
|
|
|
self.add_pins()
|
2018-08-28 01:42:48 +02:00
|
|
|
self.create_inverters()
|
|
|
|
|
|
|
|
|
|
def create_layout(self):
|
|
|
|
|
# Each stage is a a row
|
|
|
|
|
self.height = len(self.fanout_list)*self.inv.height
|
|
|
|
|
# The width is determined by the largest fanout plus the driver
|
|
|
|
|
self.width = (max(self.fanout_list)+1) * self.inv.width
|
|
|
|
|
|
|
|
|
|
self.place_inverters()
|
2018-03-12 21:14:53 +01:00
|
|
|
self.route_inverters()
|
2017-08-24 00:02:15 +02:00
|
|
|
self.add_layout_pins()
|
2019-05-28 01:32:38 +02:00
|
|
|
self.add_boundary()
|
2017-08-24 00:02:15 +02:00
|
|
|
self.DRC_LVS()
|
2019-05-28 01:32:38 +02:00
|
|
|
|
2017-08-24 00:02:15 +02:00
|
|
|
def add_pins(self):
|
|
|
|
|
""" Add the pins of the delay chain"""
|
2019-08-06 23:14:09 +02:00
|
|
|
self.add_pin("in", "INPUT")
|
|
|
|
|
self.add_pin("out", "OUTPUT")
|
|
|
|
|
self.add_pin("vdd", "POWER")
|
|
|
|
|
self.add_pin("gnd", "GROUND")
|
2017-08-24 00:02:15 +02:00
|
|
|
|
2018-08-28 01:42:48 +02:00
|
|
|
def add_modules(self):
|
2019-01-17 01:15:38 +01:00
|
|
|
self.inv = factory.create(module_type="pinv", route_output=False)
|
2017-08-24 00:02:15 +02:00
|
|
|
self.add_mod(self.inv)
|
|
|
|
|
|
2018-08-28 01:42:48 +02:00
|
|
|
def create_inverters(self):
|
|
|
|
|
""" Create the inverters and connect them based on the stage list """
|
2018-03-12 21:14:53 +01:00
|
|
|
self.driver_inst_list = []
|
|
|
|
|
self.rightest_load_inst = {}
|
|
|
|
|
self.load_inst_map = {}
|
|
|
|
|
for stage_num,fanout_size in zip(range(len(self.fanout_list)),self.fanout_list):
|
|
|
|
|
# Add the inverter
|
|
|
|
|
cur_driver=self.add_inst(name="dinv{}".format(stage_num),
|
2018-08-28 01:42:48 +02:00
|
|
|
mod=self.inv)
|
2017-08-24 00:02:15 +02:00
|
|
|
# keep track of the inverter instances so we can use them to get the pins
|
2018-03-12 21:14:53 +01:00
|
|
|
self.driver_inst_list.append(cur_driver)
|
2017-08-24 00:02:15 +02:00
|
|
|
|
2018-03-12 21:14:53 +01:00
|
|
|
# Hook up the driver
|
|
|
|
|
if stage_num+1==len(self.fanout_list):
|
|
|
|
|
stageout_name = "out"
|
2017-08-24 00:02:15 +02:00
|
|
|
else:
|
2018-03-12 21:14:53 +01:00
|
|
|
stageout_name = "dout_{}".format(stage_num+1)
|
|
|
|
|
if stage_num == 0:
|
|
|
|
|
stagein_name = "in"
|
2017-08-24 00:02:15 +02:00
|
|
|
else:
|
2018-03-12 21:14:53 +01:00
|
|
|
stagein_name = "dout_{}".format(stage_num)
|
|
|
|
|
self.connect_inst([stagein_name, stageout_name, "vdd", "gnd"])
|
|
|
|
|
|
|
|
|
|
# Now add the dummy loads to the right
|
|
|
|
|
self.load_inst_map[cur_driver]=[]
|
|
|
|
|
for i in range(fanout_size):
|
|
|
|
|
cur_load=self.add_inst(name="dload_{0}_{1}".format(stage_num,i),
|
2018-08-28 01:42:48 +02:00
|
|
|
mod=self.inv)
|
2018-03-12 21:14:53 +01:00
|
|
|
# Fanout stage is always driven by driver and output is disconnected
|
|
|
|
|
disconnect_name = "n_{0}_{1}".format(stage_num,i)
|
|
|
|
|
self.connect_inst([stageout_name, disconnect_name, "vdd", "gnd"])
|
|
|
|
|
|
|
|
|
|
# Keep track of all the loads to connect their inputs as a load
|
|
|
|
|
self.load_inst_map[cur_driver].append(cur_load)
|
|
|
|
|
else:
|
|
|
|
|
# Keep track of the last one so we can add the the wire later
|
|
|
|
|
self.rightest_load_inst[cur_driver]=cur_load
|
2018-08-28 01:42:48 +02:00
|
|
|
|
|
|
|
|
def place_inverters(self):
|
|
|
|
|
""" Place the inverters and connect them based on the stage list """
|
|
|
|
|
for stage_num,fanout_size in zip(range(len(self.fanout_list)),self.fanout_list):
|
|
|
|
|
if stage_num % 2:
|
|
|
|
|
inv_mirror = "MX"
|
|
|
|
|
inv_offset = vector(0, (stage_num+1)* self.inv.height)
|
|
|
|
|
else:
|
|
|
|
|
inv_mirror = "R0"
|
|
|
|
|
inv_offset = vector(0, stage_num * self.inv.height)
|
|
|
|
|
|
|
|
|
|
# Add the inverter
|
2018-08-28 02:25:39 +02:00
|
|
|
cur_driver=self.driver_inst_list[stage_num]
|
|
|
|
|
cur_driver.place(offset=inv_offset,
|
|
|
|
|
mirror=inv_mirror)
|
|
|
|
|
|
2018-08-28 01:42:48 +02:00
|
|
|
# Now add the dummy loads to the right
|
2018-08-28 02:25:39 +02:00
|
|
|
load_list = self.load_inst_map[cur_driver]
|
2018-08-28 01:42:48 +02:00
|
|
|
for i in range(fanout_size):
|
|
|
|
|
inv_offset += vector(self.inv.width,0)
|
2018-08-28 02:25:39 +02:00
|
|
|
load_list[i].place(offset=inv_offset,
|
|
|
|
|
mirror=inv_mirror)
|
2018-08-28 01:42:48 +02:00
|
|
|
|
2018-03-12 21:14:53 +01:00
|
|
|
|
2017-12-12 23:53:19 +01:00
|
|
|
def add_route(self, pin1, pin2):
|
|
|
|
|
""" This guarantees that we route from the top to bottom row correctly. """
|
|
|
|
|
pin1_pos = pin1.center()
|
|
|
|
|
pin2_pos = pin2.center()
|
|
|
|
|
if pin1_pos.y == pin2_pos.y:
|
2019-12-17 20:03:36 +01:00
|
|
|
self.add_path("m2", [pin1_pos, pin2_pos])
|
2017-12-12 23:53:19 +01:00
|
|
|
else:
|
|
|
|
|
mid_point = vector(pin2_pos.x, 0.5*(pin1_pos.y+pin2_pos.y))
|
|
|
|
|
# Written this way to guarantee it goes right first if we are switching rows
|
2019-12-17 20:03:36 +01:00
|
|
|
self.add_path("m2", [pin1_pos, vector(pin1_pos.x,mid_point.y), mid_point, vector(mid_point.x,pin2_pos.y), pin2_pos])
|
2017-12-12 23:53:19 +01:00
|
|
|
|
2018-03-12 21:14:53 +01:00
|
|
|
def route_inverters(self):
|
2017-08-24 00:02:15 +02:00
|
|
|
""" Add metal routing for each of the fanout stages """
|
2018-03-12 21:14:53 +01:00
|
|
|
|
|
|
|
|
for i in range(len(self.driver_inst_list)):
|
|
|
|
|
inv = self.driver_inst_list[i]
|
|
|
|
|
for load in self.load_inst_map[inv]:
|
|
|
|
|
# Drop a via on each A pin
|
|
|
|
|
a_pin = load.get_pin("A")
|
2019-12-17 20:03:36 +01:00
|
|
|
self.add_via_center(layers=self.m1_stack,
|
2018-03-14 18:53:20 +01:00
|
|
|
offset=a_pin.center())
|
2019-12-17 20:03:36 +01:00
|
|
|
self.add_via_center(layers=self.m2_stack,
|
2018-03-14 18:53:20 +01:00
|
|
|
offset=a_pin.center())
|
2018-03-12 21:14:53 +01:00
|
|
|
|
|
|
|
|
# Route an M3 horizontal wire to the furthest
|
|
|
|
|
z_pin = inv.get_pin("Z")
|
|
|
|
|
a_pin = inv.get_pin("A")
|
|
|
|
|
a_max = self.rightest_load_inst[inv].get_pin("A")
|
2019-12-17 20:03:36 +01:00
|
|
|
self.add_via_center(layers=self.m1_stack,
|
2018-03-14 18:53:20 +01:00
|
|
|
offset=a_pin.center())
|
2019-12-17 20:03:36 +01:00
|
|
|
self.add_via_center(layers=self.m1_stack,
|
2018-03-14 18:53:20 +01:00
|
|
|
offset=z_pin.center())
|
2019-12-17 20:03:36 +01:00
|
|
|
self.add_via_center(layers=self.m2_stack,
|
2018-03-14 18:53:20 +01:00
|
|
|
offset=z_pin.center())
|
2019-12-17 20:03:36 +01:00
|
|
|
self.add_path("m3",[z_pin.center(), a_max.center()])
|
2018-03-12 21:14:53 +01:00
|
|
|
|
2017-08-24 00:02:15 +02:00
|
|
|
|
2018-03-12 21:14:53 +01:00
|
|
|
# Route Z to the A of the next stage
|
|
|
|
|
if i+1 < len(self.driver_inst_list):
|
|
|
|
|
z_pin = inv.get_pin("Z")
|
|
|
|
|
next_inv = self.driver_inst_list[i+1]
|
|
|
|
|
next_a_pin = next_inv.get_pin("A")
|
|
|
|
|
y_mid = (z_pin.cy() + next_a_pin.cy())/2
|
|
|
|
|
mid1_point = vector(z_pin.cx(), y_mid)
|
|
|
|
|
mid2_point = vector(next_a_pin.cx(), y_mid)
|
2019-12-17 20:03:36 +01:00
|
|
|
self.add_path("m2",[z_pin.center(), mid1_point, mid2_point, next_a_pin.center()])
|
2017-12-12 23:53:19 +01:00
|
|
|
|
2018-03-12 21:14:53 +01:00
|
|
|
|
2017-08-24 00:02:15 +02:00
|
|
|
def add_layout_pins(self):
|
|
|
|
|
""" Add vdd and gnd rails and the input/output. Connect the gnd rails internally on
|
|
|
|
|
the top end with no input/output to obstruct. """
|
2018-03-12 21:14:53 +01:00
|
|
|
|
2018-07-19 19:23:08 +02:00
|
|
|
# Add power and ground to all the cells except:
|
|
|
|
|
# the fanout driver, the right-most load
|
|
|
|
|
# The routing to connect the loads is over the first and last cells
|
2018-07-19 19:37:47 +02:00
|
|
|
# We have an even number of drivers and must only do every other
|
|
|
|
|
# supply rail
|
|
|
|
|
for i in range(0,len(self.driver_inst_list),2):
|
|
|
|
|
inv = self.driver_inst_list[i]
|
|
|
|
|
for load in self.load_inst_map[inv]:
|
|
|
|
|
if load==self.rightest_load_inst[inv]:
|
|
|
|
|
continue
|
|
|
|
|
for pin_name in ["vdd", "gnd"]:
|
2018-07-19 19:23:08 +02:00
|
|
|
pin = load.get_pin(pin_name)
|
2018-08-30 02:21:53 +02:00
|
|
|
self.add_power_pin(pin_name, pin.rc())
|
2018-07-19 19:37:47 +02:00
|
|
|
else:
|
|
|
|
|
# We have an even number of rows, so need to get the last gnd rail
|
|
|
|
|
inv = self.driver_inst_list[-1]
|
|
|
|
|
for load in self.load_inst_map[inv]:
|
|
|
|
|
if load==self.rightest_load_inst[inv]:
|
|
|
|
|
continue
|
|
|
|
|
pin_name = "gnd"
|
|
|
|
|
pin = load.get_pin(pin_name)
|
2018-08-30 02:21:53 +02:00
|
|
|
self.add_power_pin(pin_name, pin.rc())
|
2018-07-19 19:37:47 +02:00
|
|
|
|
2018-03-12 21:14:53 +01:00
|
|
|
|
2017-08-24 00:02:15 +02:00
|
|
|
# input is A pin of first inverter
|
2018-03-12 21:14:53 +01:00
|
|
|
a_pin = self.driver_inst_list[0].get_pin("A")
|
2019-12-17 20:03:36 +01:00
|
|
|
self.add_via_center(layers=self.m1_stack,
|
2018-03-14 18:53:20 +01:00
|
|
|
offset=a_pin.center())
|
2017-08-24 00:02:15 +02:00
|
|
|
self.add_layout_pin(text="in",
|
2019-12-17 20:03:36 +01:00
|
|
|
layer="m2",
|
2018-03-12 21:14:53 +01:00
|
|
|
offset=a_pin.ll().scale(1,0),
|
|
|
|
|
height=a_pin.cy())
|
|
|
|
|
|
2017-08-24 00:02:15 +02:00
|
|
|
|
2018-03-12 21:14:53 +01:00
|
|
|
# output is A pin of last load inverter
|
|
|
|
|
last_driver_inst = self.driver_inst_list[-1]
|
|
|
|
|
a_pin = self.rightest_load_inst[last_driver_inst].get_pin("A")
|
2019-12-17 20:03:36 +01:00
|
|
|
self.add_via_center(layers=self.m1_stack,
|
2018-03-14 18:53:20 +01:00
|
|
|
offset=a_pin.center())
|
2018-03-12 21:14:53 +01:00
|
|
|
mid_point = vector(a_pin.cx()+3*self.m2_width,a_pin.cy())
|
2019-12-17 20:03:36 +01:00
|
|
|
self.add_path("m2",[a_pin.center(), mid_point, mid_point.scale(1,0)])
|
2018-03-21 21:20:48 +01:00
|
|
|
self.add_layout_pin_segment_center(text="out",
|
2019-12-17 20:03:36 +01:00
|
|
|
layer="m2",
|
2018-03-14 18:53:20 +01:00
|
|
|
start=mid_point,
|
|
|
|
|
end=mid_point.scale(1,0))
|
2017-08-24 00:02:15 +02:00
|
|
|
|
2018-11-09 05:47:34 +01:00
|
|
|
def get_cin(self):
|
|
|
|
|
"""Get the enable input ralative capacitance"""
|
|
|
|
|
#Only 1 input to the delay chain which is connected to an inverter.
|
|
|
|
|
dc_cin = self.inv.get_cin()
|
|
|
|
|
return dc_cin
|
|
|
|
|
|
2018-11-15 08:34:53 +01:00
|
|
|
def determine_delayed_en_stage_efforts(self, ext_delayed_en_cout, inp_is_rise=True):
|
2018-11-09 05:47:34 +01:00
|
|
|
"""Get the stage efforts from the en to s_en. Does not compute the delay for the bitline load."""
|
|
|
|
|
stage_effort_list = []
|
|
|
|
|
#Add a stage to the list for every stage in delay chain. Stages only differ in fanout except the last which has an external cout.
|
2018-11-15 08:34:53 +01:00
|
|
|
last_stage_is_rise = inp_is_rise
|
2018-11-09 05:47:34 +01:00
|
|
|
for stage_fanout in self.fanout_list:
|
|
|
|
|
stage_cout = self.inv.get_cin()*(stage_fanout+1)
|
|
|
|
|
if len(stage_effort_list) == len(self.fanout_list)-1: #last stage
|
|
|
|
|
stage_cout+=ext_delayed_en_cout
|
2019-01-23 21:03:52 +01:00
|
|
|
stage = self.inv.get_stage_effort(stage_cout, last_stage_is_rise)
|
2018-11-09 05:47:34 +01:00
|
|
|
stage_effort_list.append(stage)
|
2018-11-15 08:34:53 +01:00
|
|
|
last_stage_is_rise = stage.is_rise
|
2017-08-24 00:02:15 +02:00
|
|
|
|
2019-01-17 01:15:38 +01:00
|
|
|
return stage_effort_list
|