OpenRAM/compiler/pgates/pand2.py

129 lines
4.2 KiB
Python
Raw Normal View History

2018-11-26 22:45:22 +01:00
import debug
from tech import drc
from math import log
from vector import vector
from globals import OPTS
from pnand2 import pnand2
from pinv import pinv
import pgate
2018-11-26 22:45:22 +01:00
class pand2(pgate.pgate):
2018-11-26 22:45:22 +01:00
"""
This is a simple buffer used for driving loads.
"""
from importlib import reload
c = reload(__import__(OPTS.bitcell))
bitcell = getattr(c, OPTS.bitcell)
unique_id = 1
def __init__(self, size=1, height=None, name=""):
2018-11-26 22:45:22 +01:00
2018-11-27 00:29:42 +01:00
self.size = size
2018-11-26 22:45:22 +01:00
if name=="":
2018-11-27 00:29:42 +01:00
name = "pand2_{0}_{1}".format(size, pand2.unique_id)
2018-11-26 22:45:22 +01:00
pand2.unique_id += 1
pgate.pgate.__init__(self, name, height)
2018-11-26 22:45:22 +01:00
debug.info(1, "Creating {}".format(self.name))
2018-11-27 00:29:42 +01:00
self.create_netlist()
if not OPTS.netlist_only:
self.create_layout()
2018-11-26 22:45:22 +01:00
2018-11-27 00:29:42 +01:00
def create_netlist(self):
self.add_pins()
self.create_modules()
self.create_insts()
2018-11-26 22:45:22 +01:00
2018-11-27 00:29:42 +01:00
def create_modules(self):
# Shield the cap, but have at least a stage effort of 4
self.nand = pnand2(height=self.height)
self.add_mod(self.nand)
2018-11-26 22:45:22 +01:00
2018-11-27 00:29:42 +01:00
self.inv = pinv(size=self.size, height=self.height)
self.add_mod(self.inv)
2018-11-26 22:45:22 +01:00
def create_layout(self):
2018-11-27 00:29:42 +01:00
self.width = self.nand.width + self.inv.width
self.place_insts()
2018-11-26 22:45:22 +01:00
self.add_wires()
self.add_layout_pins()
def add_pins(self):
self.add_pin("A")
self.add_pin("B")
self.add_pin("Z")
self.add_pin("vdd")
self.add_pin("gnd")
2018-11-27 00:29:42 +01:00
def create_insts(self):
2018-11-26 22:45:22 +01:00
self.nand_inst=self.add_inst(name="pand2_nand",
2018-11-27 00:29:42 +01:00
mod=self.nand)
2018-11-26 22:45:22 +01:00
self.connect_inst(["A", "B", "zb_int", "vdd", "gnd"])
self.inv_inst=self.add_inst(name="pand2_inv",
2018-11-27 00:29:42 +01:00
mod=self.inv)
2018-11-26 22:45:22 +01:00
self.connect_inst(["zb_int", "Z", "vdd", "gnd"])
2018-11-27 00:29:42 +01:00
def place_insts(self):
# Add NAND to the right
self.nand_inst.place(offset=vector(0,0))
# Add INV to the right
self.inv_inst.place(offset=vector(self.nand_inst.rx(),0))
2018-11-26 22:45:22 +01:00
def add_wires(self):
# nand Z to inv A
z1_pin = self.nand_inst.get_pin("Z")
a2_pin = self.inv_inst.get_pin("A")
mid1_point = vector(0.5*(z1_pin.cx()+a2_pin.cx()), z1_pin.cy())
mid2_point = vector(mid1_point, a2_pin.cy())
self.add_path("metal1", [z1_pin.center(), mid1_point, mid2_point, a2_pin.center()])
def add_layout_pins(self):
# Continous vdd rail along with label.
vdd_pin=self.inv_inst.get_pin("vdd")
self.add_layout_pin(text="vdd",
layer="metal1",
offset=vdd_pin.ll().scale(0,1),
width=self.width,
height=vdd_pin.height())
# Continous gnd rail along with label.
gnd_pin=self.inv_inst.get_pin("gnd")
self.add_layout_pin(text="gnd",
layer="metal1",
offset=gnd_pin.ll().scale(0,1),
width=self.width,
height=vdd_pin.height())
pin = self.inv_inst.get_pin("Z")
2018-11-26 22:45:22 +01:00
self.add_layout_pin_rect_center(text="Z",
layer=pin.layer,
offset=pin.center(),
width=pin.width(),
height=pin.height())
2018-11-26 22:45:22 +01:00
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())
2018-11-26 22:45:22 +01:00
def analytical_delay(self, slew, load=0.0):
""" Calculate the analytical delay of DFF-> INV -> INV """
nand_delay = selfnand.analytical_delay(slew=slew, load=self.inv.input_load())
inv_delay = self.inv.analytical_delay(slew=nand_delay.slew, load=load)
return nand_delay + inv_delay