OpenRAM/compiler/pgates/pand2.py

132 lines
4.7 KiB
Python
Raw Normal View History

# 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.
#
2018-11-26 22:45:22 +01:00
import debug
from vector import vector
import pgate
2019-01-17 01:15:38 +01:00
from sram_factory import factory
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.
2018-11-26 22:45:22 +01:00
"""
2019-01-17 01:15:38 +01:00
def __init__(self, name, size=1, height=None):
debug.info(1, "Creating pnand2 {}".format(name))
self.add_comment("size: {}".format(size))
2018-11-27 00:29:42 +01:00
self.size = size
# Creates the netlist and layout
pgate.pgate.__init__(self, name, height)
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 = factory.create(module_type="pnand2", height=self.height)
2018-11-27 00:29:42 +01:00
self.add_mod(self.nand)
self.inv = factory.create(module_type="pdriver",
neg_polarity=True,
fanout=3*self.size,
height=self.height)
2018-11-27 00:29:42 +01:00
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()
2020-04-22 00:21:57 +02:00
self.add_boundary()
self.DRC_LVS()
2018-11-26 22:45:22 +01:00
def add_pins(self):
2019-08-06 23:14:09 +02:00
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")
2018-11-26 22:45:22 +01:00
2018-11-27 00:29:42 +01:00
def create_insts(self):
self.nand_inst = self.add_inst(name="pand2_nand",
mod=self.nand)
self.connect_inst(["A", "B", "zb_int", "vdd", "gnd"])
2018-11-26 22:45:22 +01:00
self.inv_inst = self.add_inst(name="pand2_inv",
mod=self.inv)
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))
2018-11-27 00:29:42 +01:00
# 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())
2018-11-26 22:45:22 +01:00
mid2_point = vector(mid1_point, a2_pin.cy())
self.add_path("m1",
[z1_pin.center(), mid1_point, mid2_point, a2_pin.center()])
2018-11-26 22:45:22 +01:00
def add_layout_pins(self):
# Continous vdd rail along with label.
vdd_pin = self.inv_inst.get_pin("vdd")
2018-11-26 22:45:22 +01:00
self.add_layout_pin(text="vdd",
layer="m1",
offset=vdd_pin.ll().scale(0, 1),
2018-11-26 22:45:22 +01:00
width=self.width,
height=vdd_pin.height())
# Continous gnd rail along with label.
gnd_pin = self.inv_inst.get_pin("gnd")
2018-11-26 22:45:22 +01:00
self.add_layout_pin(text="gnd",
layer="m1",
offset=gnd_pin.ll().scale(0, 1),
2018-11-26 22:45:22 +01:00
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"]:
2018-11-26 22:45:22 +01:00
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 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.inv.get_cin()
stage1 = self.nand.get_stage_effort(stage1_cout, inp_is_rise)
stage_effort_list.append(stage1)
last_stage_is_rise = stage1.is_rise
stage2 = self.inv.get_stage_effort(external_cout, last_stage_is_rise)
stage_effort_list.append(stage2)
return stage_effort_list
def get_cin(self):
"""Return the relative input capacitance of a single input"""
return self.nand.get_cin()