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-11-12 18:53:21 +01:00
|
|
|
import debug
|
|
|
|
|
from vector import vector
|
2018-11-27 01:19:18 +01:00
|
|
|
import pgate
|
2019-01-17 01:15:38 +01:00
|
|
|
from sram_factory import factory
|
2018-11-12 18:53:21 +01:00
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
|
2018-11-27 01:19:18 +01:00
|
|
|
class pbuf(pgate.pgate):
|
2018-11-12 18:53:21 +01:00
|
|
|
"""
|
2019-10-06 19:30:16 +02:00
|
|
|
This is a simple buffer used for driving loads.
|
2018-11-12 18:53:21 +01:00
|
|
|
"""
|
2019-01-17 01:15:38 +01:00
|
|
|
def __init__(self, name, size=4, height=None):
|
|
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
debug.info(1, "creating {0} with size of {1}".format(name, size))
|
2019-04-26 20:57:29 +02:00
|
|
|
self.add_comment("size: {}".format(size))
|
|
|
|
|
|
2018-11-27 00:29:42 +01:00
|
|
|
self.stage_effort = 4
|
|
|
|
|
self.size = size
|
|
|
|
|
self.height = height
|
2018-11-12 18:53:21 +01:00
|
|
|
|
2019-04-26 20:57:29 +02:00
|
|
|
# Creates the netlist and layout
|
2018-11-27 01:19:18 +01:00
|
|
|
pgate.pgate.__init__(self, name, height)
|
2018-11-12 18:53:21 +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-12 18:53:21 +01:00
|
|
|
|
|
|
|
|
def create_layout(self):
|
2018-11-27 00:29:42 +01:00
|
|
|
self.width = self.inv1.width + self.inv2.width
|
|
|
|
|
self.place_insts()
|
2018-11-12 18:53:21 +01:00
|
|
|
self.add_wires()
|
|
|
|
|
self.add_layout_pins()
|
2020-04-22 00:21:57 +02:00
|
|
|
self.add_boundary()
|
2018-11-12 18:53:21 +01:00
|
|
|
|
|
|
|
|
def add_pins(self):
|
2019-08-06 23:14:09 +02:00
|
|
|
self.add_pin("A", "INPUT")
|
|
|
|
|
self.add_pin("Z", "OUTPUT")
|
|
|
|
|
self.add_pin("vdd", "POWER")
|
|
|
|
|
self.add_pin("gnd", "GROUND")
|
2018-11-12 18:53:21 +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
|
2019-10-06 19:30:16 +02:00
|
|
|
input_size = max(1, int(self.size / self.stage_effort))
|
|
|
|
|
self.inv1 = factory.create(module_type="pinv",
|
|
|
|
|
size=input_size,
|
|
|
|
|
height=self.height)
|
2018-11-27 00:29:42 +01:00
|
|
|
self.add_mod(self.inv1)
|
|
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
self.inv2 = factory.create(module_type="pinv",
|
|
|
|
|
size=self.size,
|
|
|
|
|
height=self.height)
|
2018-11-27 00:29:42 +01:00
|
|
|
self.add_mod(self.inv2)
|
|
|
|
|
|
|
|
|
|
def create_insts(self):
|
2019-10-06 19:30:16 +02:00
|
|
|
self.inv1_inst = self.add_inst(name="buf_inv1",
|
|
|
|
|
mod=self.inv1)
|
|
|
|
|
self.connect_inst(["A", "zb_int", "vdd", "gnd"])
|
2018-11-12 18:53:21 +01:00
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
self.inv2_inst = self.add_inst(name="buf_inv2",
|
|
|
|
|
mod=self.inv2)
|
|
|
|
|
self.connect_inst(["zb_int", "Z", "vdd", "gnd"])
|
2018-11-27 00:29:42 +01:00
|
|
|
|
|
|
|
|
def place_insts(self):
|
2019-10-06 19:30:16 +02:00
|
|
|
# Add INV1 to the right
|
|
|
|
|
self.inv1_inst.place(vector(0, 0))
|
2018-11-27 00:29:42 +01:00
|
|
|
|
|
|
|
|
# Add INV2 to the right
|
2019-10-06 19:30:16 +02:00
|
|
|
self.inv2_inst.place(vector(self.inv1_inst.rx(), 0))
|
2018-11-12 18:53:21 +01:00
|
|
|
|
|
|
|
|
def add_wires(self):
|
|
|
|
|
# inv1 Z to inv2 A
|
|
|
|
|
z1_pin = self.inv1_inst.get_pin("Z")
|
|
|
|
|
a2_pin = self.inv2_inst.get_pin("A")
|
2019-10-06 19:30:16 +02:00
|
|
|
mid_point = vector(z1_pin.cx(), a2_pin.cy())
|
2019-12-17 20:03:36 +01:00
|
|
|
self.add_path("m1", [z1_pin.center(), mid_point, a2_pin.center()])
|
2018-11-12 18:53:21 +01:00
|
|
|
|
|
|
|
|
def add_layout_pins(self):
|
|
|
|
|
# Continous vdd rail along with label.
|
2019-10-06 19:30:16 +02:00
|
|
|
vdd_pin = self.inv1_inst.get_pin("vdd")
|
2018-11-12 18:53:21 +01:00
|
|
|
self.add_layout_pin(text="vdd",
|
2019-12-17 20:03:36 +01:00
|
|
|
layer="m1",
|
2019-10-06 19:30:16 +02:00
|
|
|
offset=vdd_pin.ll().scale(0, 1),
|
2018-11-12 18:53:21 +01:00
|
|
|
width=self.width,
|
|
|
|
|
height=vdd_pin.height())
|
|
|
|
|
|
|
|
|
|
# Continous gnd rail along with label.
|
2019-10-06 19:30:16 +02:00
|
|
|
gnd_pin = self.inv1_inst.get_pin("gnd")
|
2018-11-12 18:53:21 +01:00
|
|
|
self.add_layout_pin(text="gnd",
|
2019-12-17 20:03:36 +01:00
|
|
|
layer="m1",
|
2019-10-06 19:30:16 +02:00
|
|
|
offset=gnd_pin.ll().scale(0, 1),
|
2018-11-12 18:53:21 +01:00
|
|
|
width=self.width,
|
|
|
|
|
height=vdd_pin.height())
|
|
|
|
|
|
2018-11-12 22:24:27 +01:00
|
|
|
z_pin = self.inv2_inst.get_pin("Z")
|
2018-11-12 18:53:21 +01:00
|
|
|
self.add_layout_pin_rect_center(text="Z",
|
2018-11-28 21:42:29 +01:00
|
|
|
layer=z_pin.layer,
|
|
|
|
|
offset=z_pin.center(),
|
|
|
|
|
width=z_pin.width(),
|
|
|
|
|
height=z_pin.height())
|
2018-11-12 18:53:21 +01:00
|
|
|
|
|
|
|
|
a_pin = self.inv1_inst.get_pin("A")
|
|
|
|
|
self.add_layout_pin_rect_center(text="A",
|
2018-11-28 21:42:29 +01:00
|
|
|
layer=a_pin.layer,
|
|
|
|
|
offset=a_pin.center(),
|
|
|
|
|
width=a_pin.width(),
|
|
|
|
|
height=a_pin.height())
|
2018-11-12 18:53:21 +01:00
|
|
|
|
2019-01-23 21:03:52 +01:00
|
|
|
def get_stage_efforts(self, external_cout, inp_is_rise=False):
|
2018-12-03 08:09:00 +01:00
|
|
|
"""Get the stage efforts of the A -> Z path"""
|
|
|
|
|
stage_effort_list = []
|
|
|
|
|
stage1_cout = self.inv2.get_cin()
|
2019-01-23 21:03:52 +01:00
|
|
|
stage1 = self.inv1.get_stage_effort(stage1_cout, inp_is_rise)
|
2018-12-03 08:09:00 +01:00
|
|
|
stage_effort_list.append(stage1)
|
|
|
|
|
last_stage_is_rise = stage1.is_rise
|
|
|
|
|
|
2019-01-23 21:03:52 +01:00
|
|
|
stage2 = self.inv2.get_stage_effort(external_cout, last_stage_is_rise)
|
2018-12-03 08:09:00 +01:00
|
|
|
stage_effort_list.append(stage2)
|
|
|
|
|
|
|
|
|
|
return stage_effort_list
|
2018-12-06 02:10:11 +01:00
|
|
|
|
|
|
|
|
def get_cin(self):
|
|
|
|
|
"""Returns the relative capacitance of the input"""
|
|
|
|
|
input_cin = self.inv1.get_cin()
|
2019-01-17 01:15:38 +01:00
|
|
|
return input_cin
|