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
|
|
|
#
|
2018-02-17 00:25:27 +01:00
|
|
|
import debug
|
|
|
|
|
import design
|
2020-06-09 22:48:16 +02:00
|
|
|
from tech import parameter, layer
|
2020-02-12 05:09:40 +01:00
|
|
|
from tech import cell_properties as props
|
2018-02-17 00:25:27 +01:00
|
|
|
from vector import vector
|
|
|
|
|
from globals import OPTS
|
2019-01-17 01:15:38 +01:00
|
|
|
from sram_factory import factory
|
2018-02-17 00:25:27 +01:00
|
|
|
|
2020-04-16 00:55:49 +02:00
|
|
|
|
2018-02-17 00:25:27 +01:00
|
|
|
class dff_buf(design.design):
|
|
|
|
|
"""
|
|
|
|
|
This is a simple buffered DFF. The output is buffered
|
|
|
|
|
with two inverters, of variable size, to provide q
|
|
|
|
|
and qbar. This is to enable driving large fanout loads.
|
|
|
|
|
"""
|
2018-11-16 20:48:41 +01:00
|
|
|
unique_id = 1
|
|
|
|
|
|
2018-03-06 01:22:35 +01:00
|
|
|
def __init__(self, inv1_size=2, inv2_size=4, name=""):
|
2018-02-17 00:25:27 +01:00
|
|
|
|
|
|
|
|
if name=="":
|
2018-11-16 20:48:41 +01:00
|
|
|
name = "dff_buf_{0}".format(dff_buf.unique_id)
|
|
|
|
|
dff_buf.unique_id += 1
|
2018-02-17 00:25:27 +01:00
|
|
|
design.design.__init__(self, name)
|
|
|
|
|
debug.info(1, "Creating {}".format(self.name))
|
2019-01-26 00:00:00 +01:00
|
|
|
self.add_comment("inv1: {0} inv2: {1}".format(inv1_size, inv2_size))
|
|
|
|
|
|
2018-07-27 17:17:50 +02:00
|
|
|
# This is specifically for SCMOS where the DFF vdd/gnd rails are more than min width.
|
|
|
|
|
# This causes a DRC in the pinv which assumes min width rails. This ensures the output
|
|
|
|
|
# contact does not violate spacing to the rail in the NMOS.
|
|
|
|
|
debug.check(inv1_size>=2, "Inverter must be greater than two for rail spacing DRC rules.")
|
2020-04-22 00:21:29 +02:00
|
|
|
debug.check(inv2_size>=2, "Inverter must be greater than two for rail spacing DRC rules.")
|
2018-07-27 17:17:50 +02:00
|
|
|
|
2018-08-28 19:24:09 +02:00
|
|
|
self.inv1_size=inv1_size
|
|
|
|
|
self.inv2_size=inv2_size
|
|
|
|
|
|
|
|
|
|
self.create_netlist()
|
|
|
|
|
if not OPTS.netlist_only:
|
|
|
|
|
self.create_layout()
|
|
|
|
|
|
|
|
|
|
def create_netlist(self):
|
|
|
|
|
self.add_modules()
|
|
|
|
|
self.add_pins()
|
2018-11-14 01:05:22 +01:00
|
|
|
self.create_instances()
|
2018-08-28 19:24:09 +02:00
|
|
|
|
|
|
|
|
def create_layout(self):
|
2020-02-10 20:28:30 +01:00
|
|
|
self.place_instances()
|
|
|
|
|
self.width = self.inv2_inst.rx()
|
2018-08-28 19:24:09 +02:00
|
|
|
self.height = self.dff.height
|
|
|
|
|
self.route_wires()
|
|
|
|
|
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()
|
2020-04-22 00:21:29 +02:00
|
|
|
|
2018-08-28 19:24:09 +02:00
|
|
|
def add_modules(self):
|
2019-01-17 01:15:38 +01:00
|
|
|
self.dff = factory.create(module_type="dff")
|
2018-02-17 00:25:27 +01:00
|
|
|
self.add_mod(self.dff)
|
|
|
|
|
|
2019-01-17 01:15:38 +01:00
|
|
|
self.inv1 = factory.create(module_type="pinv",
|
|
|
|
|
size=self.inv1_size,
|
|
|
|
|
height=self.dff.height)
|
2018-02-17 00:25:27 +01:00
|
|
|
self.add_mod(self.inv1)
|
|
|
|
|
|
2019-01-17 01:15:38 +01:00
|
|
|
self.inv2 = factory.create(module_type="pinv",
|
|
|
|
|
size=self.inv2_size,
|
|
|
|
|
height=self.dff.height)
|
2018-02-17 00:25:27 +01:00
|
|
|
self.add_mod(self.inv2)
|
|
|
|
|
|
|
|
|
|
def add_pins(self):
|
2019-08-06 23:14:09 +02:00
|
|
|
self.add_pin("D", "INPUT")
|
|
|
|
|
self.add_pin("Q", "OUTPUT")
|
|
|
|
|
self.add_pin("Qb", "OUTPUT")
|
|
|
|
|
self.add_pin("clk", "INPUT")
|
|
|
|
|
self.add_pin("vdd", "POWER")
|
|
|
|
|
self.add_pin("gnd", "GROUND")
|
2018-02-17 00:25:27 +01:00
|
|
|
|
2020-02-12 05:09:40 +01:00
|
|
|
if props.dff_buff.add_body_contacts:
|
2020-02-10 08:10:33 +01:00
|
|
|
self.add_pin("vpb", "INPUT")
|
|
|
|
|
self.add_pin("vpn", "INPUT")
|
|
|
|
|
|
2018-11-14 01:05:22 +01:00
|
|
|
def create_instances(self):
|
2018-02-17 00:25:27 +01:00
|
|
|
self.dff_inst=self.add_inst(name="dff_buf_dff",
|
2018-08-28 19:24:09 +02:00
|
|
|
mod=self.dff)
|
2020-04-05 12:58:26 +02:00
|
|
|
|
2020-03-03 13:40:08 +01:00
|
|
|
self.connect_inst(["D", "qint", "clk", "vdd", "gnd"])
|
2018-02-17 00:25:27 +01:00
|
|
|
|
|
|
|
|
self.inv1_inst=self.add_inst(name="dff_buf_inv1",
|
2018-08-28 19:24:09 +02:00
|
|
|
mod=self.inv1)
|
2020-04-22 00:21:29 +02:00
|
|
|
self.connect_inst(["qint", "Qb", "vdd", "gnd"])
|
2018-02-17 00:25:27 +01:00
|
|
|
|
|
|
|
|
self.inv2_inst=self.add_inst(name="dff_buf_inv2",
|
2018-08-28 19:24:09 +02:00
|
|
|
mod=self.inv2)
|
2020-04-22 00:21:29 +02:00
|
|
|
self.connect_inst(["Qb", "Q", "vdd", "gnd"])
|
2018-08-28 19:24:09 +02:00
|
|
|
|
2018-11-14 01:05:22 +01:00
|
|
|
def place_instances(self):
|
2018-08-28 19:24:09 +02:00
|
|
|
# Add the DFF
|
2020-04-22 00:21:29 +02:00
|
|
|
self.dff_inst.place(vector(0, 0))
|
2018-08-28 19:24:09 +02:00
|
|
|
|
|
|
|
|
# Add INV1 to the right
|
2020-04-22 00:21:29 +02:00
|
|
|
# The INV needs well spacing because the DFF is likely from a library
|
|
|
|
|
# with different well construction rules
|
2020-04-16 00:55:49 +02:00
|
|
|
well_spacing = 0
|
|
|
|
|
try:
|
|
|
|
|
well_spacing = max(well_spacing, self.nwell_space)
|
|
|
|
|
except AttributeError:
|
|
|
|
|
pass
|
|
|
|
|
try:
|
|
|
|
|
well_spacing = max(well_spacing, self.pwell_space)
|
|
|
|
|
except AttributeError:
|
|
|
|
|
pass
|
|
|
|
|
try:
|
|
|
|
|
well_spacing = max(well_spacing, self.pwell_to_nwell)
|
|
|
|
|
except AttributeError:
|
|
|
|
|
pass
|
|
|
|
|
self.inv1_inst.place(vector(self.dff_inst.rx() + well_spacing + self.well_extend_active, 0))
|
2020-06-09 22:48:16 +02:00
|
|
|
|
2018-08-28 19:24:09 +02:00
|
|
|
# Add INV2 to the right
|
2020-04-16 00:55:49 +02:00
|
|
|
self.inv2_inst.place(vector(self.inv1_inst.rx(), 0))
|
2018-02-17 00:25:27 +01:00
|
|
|
|
2018-08-28 19:24:09 +02:00
|
|
|
def route_wires(self):
|
2020-06-09 22:48:16 +02:00
|
|
|
if "li" in layer:
|
|
|
|
|
self.route_layer = "li"
|
|
|
|
|
else:
|
|
|
|
|
self.route_layer = "m1"
|
|
|
|
|
|
2018-02-17 00:25:27 +01:00
|
|
|
# Route dff q to inv1 a
|
|
|
|
|
q_pin = self.dff_inst.get_pin("Q")
|
|
|
|
|
a1_pin = self.inv1_inst.get_pin("A")
|
2020-06-09 22:48:16 +02:00
|
|
|
mid1 = vector(a1_pin.cx(), q_pin.cy())
|
|
|
|
|
self.add_path(q_pin.layer, [q_pin.center(), mid1, a1_pin.center()])
|
|
|
|
|
self.add_via_stack_center(from_layer=a1_pin.layer,
|
|
|
|
|
to_layer=q_pin.layer,
|
|
|
|
|
offset=a1_pin.center())
|
2018-02-17 00:25:27 +01:00
|
|
|
|
|
|
|
|
# Route inv1 z to inv2 a
|
|
|
|
|
z1_pin = self.inv1_inst.get_pin("Z")
|
|
|
|
|
a2_pin = self.inv2_inst.get_pin("A")
|
2020-06-09 22:48:16 +02:00
|
|
|
self.mid_qb_pos = vector(0.5 * (z1_pin.cx() + a2_pin.cx()), z1_pin.cy())
|
|
|
|
|
self.add_zjog(z1_pin.layer, z1_pin.center(), a2_pin.center())
|
2018-02-17 00:25:27 +01:00
|
|
|
|
|
|
|
|
def add_layout_pins(self):
|
|
|
|
|
|
|
|
|
|
# Continous vdd rail along with label.
|
|
|
|
|
vdd_pin=self.dff_inst.get_pin("vdd")
|
|
|
|
|
self.add_layout_pin(text="vdd",
|
2020-06-09 22:48:16 +02:00
|
|
|
layer=vdd_pin.layer,
|
2018-02-17 00:25:27 +01:00
|
|
|
offset=vdd_pin.ll(),
|
|
|
|
|
width=self.width,
|
|
|
|
|
height=vdd_pin.height())
|
|
|
|
|
|
|
|
|
|
# Continous gnd rail along with label.
|
|
|
|
|
gnd_pin=self.dff_inst.get_pin("gnd")
|
|
|
|
|
self.add_layout_pin(text="gnd",
|
2020-06-09 22:48:16 +02:00
|
|
|
layer=gnd_pin.layer,
|
2018-02-17 00:25:27 +01:00
|
|
|
offset=gnd_pin.ll(),
|
|
|
|
|
width=self.width,
|
|
|
|
|
height=vdd_pin.height())
|
|
|
|
|
|
|
|
|
|
clk_pin = self.dff_inst.get_pin("clk")
|
|
|
|
|
self.add_layout_pin(text="clk",
|
|
|
|
|
layer=clk_pin.layer,
|
|
|
|
|
offset=clk_pin.ll(),
|
|
|
|
|
width=clk_pin.width(),
|
|
|
|
|
height=clk_pin.height())
|
|
|
|
|
|
|
|
|
|
din_pin = self.dff_inst.get_pin("D")
|
|
|
|
|
self.add_layout_pin(text="D",
|
|
|
|
|
layer=din_pin.layer,
|
|
|
|
|
offset=din_pin.ll(),
|
|
|
|
|
width=din_pin.width(),
|
|
|
|
|
height=din_pin.height())
|
|
|
|
|
|
|
|
|
|
dout_pin = self.inv2_inst.get_pin("Z")
|
2020-05-07 21:35:21 +02:00
|
|
|
mid_pos = dout_pin.center() + vector(self.m1_nonpref_pitch, 0)
|
2020-04-22 00:21:29 +02:00
|
|
|
q_pos = mid_pos - vector(0, self.m2_pitch)
|
2018-03-21 21:20:48 +01:00
|
|
|
self.add_layout_pin_rect_center(text="Q",
|
2019-12-17 20:03:36 +01:00
|
|
|
layer="m2",
|
2018-11-28 19:43:11 +01:00
|
|
|
offset=q_pos)
|
2020-06-09 22:48:16 +02:00
|
|
|
self.add_path(self.route_layer, [dout_pin.center(), mid_pos, q_pos])
|
|
|
|
|
self.add_via_stack_center(from_layer=dout_pin.layer,
|
|
|
|
|
to_layer="m2",
|
|
|
|
|
offset=q_pos)
|
2018-03-06 01:22:35 +01:00
|
|
|
|
2020-04-22 00:21:29 +02:00
|
|
|
qb_pos = self.mid_qb_pos + vector(0, self.m2_pitch)
|
2018-03-21 21:20:48 +01:00
|
|
|
self.add_layout_pin_rect_center(text="Qb",
|
2019-12-17 20:03:36 +01:00
|
|
|
layer="m2",
|
2018-11-28 19:43:11 +01:00
|
|
|
offset=qb_pos)
|
2020-06-09 22:48:16 +02:00
|
|
|
self.add_path(self.route_layer, [self.mid_qb_pos, qb_pos])
|
|
|
|
|
a2_pin = self.inv2_inst.get_pin("A")
|
|
|
|
|
self.add_via_stack_center(from_layer=a2_pin.layer,
|
|
|
|
|
to_layer="m2",
|
|
|
|
|
offset=qb_pos)
|
2019-08-07 02:09:25 +02:00
|
|
|
|
2018-12-03 08:09:00 +01:00
|
|
|
def get_clk_cin(self):
|
|
|
|
|
"""Return the total capacitance (in relative units) that the clock is loaded by in the dff"""
|
2020-04-22 00:21:29 +02:00
|
|
|
# This is a handmade cell so the value must be entered in the tech.py file or estimated.
|
|
|
|
|
# Calculated in the tech file by summing the widths of all the gates and dividing by the minimum width.
|
|
|
|
|
# FIXME: Dff changed in a past commit. The parameter need to be updated.
|
2019-01-17 01:15:38 +01:00
|
|
|
return parameter["dff_clk_cin"]
|