2019-04-26 21:21:50 +02:00
|
|
|
# See LICENSE for licensing information.
|
|
|
|
|
#
|
2021-01-22 20:23:28 +01:00
|
|
|
# Copyright (c) 2016-2021 Regents of the University of California and The Board
|
2019-06-14 17:43:41 +02:00
|
|
|
# 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-26 22:45:22 +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-26 22:45:22 +01:00
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
|
2018-11-27 01:19:18 +01:00
|
|
|
class pand2(pgate.pgate):
|
2018-11-26 22:45:22 +01:00
|
|
|
"""
|
2020-05-14 20:20:37 +02:00
|
|
|
This is an AND (or NAND) with configurable drive strength.
|
2018-11-26 22:45:22 +01:00
|
|
|
"""
|
2020-05-13 23:46:42 +02:00
|
|
|
def __init__(self, name, size=1, height=None, vertical=False, add_wells=True):
|
2020-05-12 01:22:08 +02:00
|
|
|
debug.info(1, "Creating pand2 {}".format(name))
|
2019-04-26 20:57:29 +02:00
|
|
|
self.add_comment("size: {}".format(size))
|
2020-05-12 01:22:08 +02:00
|
|
|
|
|
|
|
|
self.vertical = vertical
|
2018-11-27 00:29:42 +01:00
|
|
|
self.size = size
|
2020-05-12 01:22:08 +02:00
|
|
|
|
2020-08-06 20:33:26 +02:00
|
|
|
super().__init__(name, height, add_wells)
|
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):
|
2020-05-12 01:22:08 +02:00
|
|
|
self.nand = factory.create(module_type="pnand2",
|
2020-05-13 23:46:42 +02:00
|
|
|
height=self.height,
|
2022-02-23 18:30:31 +01:00
|
|
|
add_wells=self.add_wells)
|
2019-08-21 19:18:46 +02:00
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
self.inv = factory.create(module_type="pdriver",
|
2020-05-12 01:22:08 +02:00
|
|
|
size_list=[self.size],
|
2020-05-13 23:46:42 +02:00
|
|
|
height=self.height,
|
|
|
|
|
add_wells=self.add_wells)
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-11-26 22:45:22 +01:00
|
|
|
def create_layout(self):
|
2020-05-12 01:22:08 +02:00
|
|
|
if self.vertical:
|
|
|
|
|
self.height = 2 * self.nand.height
|
|
|
|
|
self.width = max(self.nand.width, self.inv.width)
|
|
|
|
|
else:
|
|
|
|
|
self.width = self.nand.width + self.inv.width
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-11-27 00:29:42 +01:00
|
|
|
self.place_insts()
|
2018-11-26 22:45:22 +01:00
|
|
|
self.add_wires()
|
|
|
|
|
self.add_layout_pins()
|
2020-05-07 21:35:21 +02:00
|
|
|
self.route_supply_rails()
|
2020-04-22 00:21:57 +02:00
|
|
|
self.add_boundary()
|
2019-04-26 20:57:29 +02:00
|
|
|
self.DRC_LVS()
|
2020-11-03 15:29:17 +01:00
|
|
|
|
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):
|
2019-10-06 19:30:16 +02:00
|
|
|
self.nand_inst = self.add_inst(name="pand2_nand",
|
|
|
|
|
mod=self.nand)
|
|
|
|
|
self.connect_inst(["A", "B", "zb_int", "vdd", "gnd"])
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2019-10-06 19:30:16 +02: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):
|
2019-10-06 19:30:16 +02:00
|
|
|
# Add NAND to the right
|
|
|
|
|
self.nand_inst.place(offset=vector(0, 0))
|
2018-11-27 00:29:42 +01:00
|
|
|
|
2020-05-12 01:22:08 +02:00
|
|
|
if self.vertical:
|
|
|
|
|
# Add INV above
|
|
|
|
|
self.inv_inst.place(offset=vector(self.inv.width,
|
|
|
|
|
2 * self.nand.height),
|
|
|
|
|
mirror="XY")
|
|
|
|
|
else:
|
|
|
|
|
# Add INV to the right
|
|
|
|
|
self.inv_inst.place(offset=vector(self.nand_inst.rx(), 0))
|
|
|
|
|
|
|
|
|
|
def route_supply_rails(self):
|
|
|
|
|
""" Add vdd/gnd rails to the top, (middle), and bottom. """
|
|
|
|
|
self.add_layout_pin_rect_center(text="gnd",
|
|
|
|
|
layer=self.route_layer,
|
|
|
|
|
offset=vector(0.5 * self.width, 0),
|
|
|
|
|
width=self.width)
|
|
|
|
|
|
|
|
|
|
# Second gnd of the inverter gate
|
|
|
|
|
if self.vertical:
|
|
|
|
|
self.add_layout_pin_rect_center(text="gnd",
|
|
|
|
|
layer=self.route_layer,
|
|
|
|
|
offset=vector(0.5 * self.width, self.height),
|
|
|
|
|
width=self.width)
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-05-12 01:22:08 +02:00
|
|
|
if self.vertical:
|
|
|
|
|
# Shared between two gates
|
|
|
|
|
y_offset = 0.5 * self.height
|
|
|
|
|
else:
|
|
|
|
|
y_offset = self.height
|
|
|
|
|
self.add_layout_pin_rect_center(text="vdd",
|
|
|
|
|
layer=self.route_layer,
|
|
|
|
|
offset=vector(0.5 * self.width, y_offset),
|
|
|
|
|
width=self.width)
|
2020-11-03 15:29:17 +01:00
|
|
|
|
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")
|
2020-05-12 01:22:08 +02:00
|
|
|
if self.vertical:
|
|
|
|
|
route_layer = "m2"
|
|
|
|
|
self.add_via_stack_center(offset=z1_pin.center(),
|
|
|
|
|
from_layer=z1_pin.layer,
|
|
|
|
|
to_layer=route_layer)
|
|
|
|
|
self.add_zjog(route_layer,
|
|
|
|
|
z1_pin.uc(),
|
|
|
|
|
a2_pin.bc(),
|
|
|
|
|
"V")
|
|
|
|
|
self.add_via_stack_center(offset=a2_pin.center(),
|
|
|
|
|
from_layer=a2_pin.layer,
|
|
|
|
|
to_layer=route_layer)
|
|
|
|
|
else:
|
|
|
|
|
route_layer = self.route_layer
|
|
|
|
|
mid1_point = vector(z1_pin.cx(), a2_pin.cy())
|
|
|
|
|
self.add_path(route_layer,
|
|
|
|
|
[z1_pin.center(), mid1_point, a2_pin.center()])
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2018-11-26 22:45:22 +01:00
|
|
|
def add_layout_pins(self):
|
2018-11-28 21:42:29 +01:00
|
|
|
pin = self.inv_inst.get_pin("Z")
|
2018-11-26 22:45:22 +01:00
|
|
|
self.add_layout_pin_rect_center(text="Z",
|
2018-11-28 21:42:29 +01:00
|
|
|
layer=pin.layer,
|
|
|
|
|
offset=pin.center(),
|
|
|
|
|
width=pin.width(),
|
|
|
|
|
height=pin.height())
|
2018-11-26 22:45:22 +01:00
|
|
|
|
2019-10-06 19:30:16 +02: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,
|
2018-11-28 21:42:29 +01:00
|
|
|
layer=pin.layer,
|
|
|
|
|
offset=pin.center(),
|
|
|
|
|
width=pin.width(),
|
|
|
|
|
height=pin.height())
|
2021-11-22 19:51:40 +01:00
|
|
|
|
2020-11-18 00:05:07 +01:00
|
|
|
def is_non_inverting(self):
|
|
|
|
|
"""Return input to output polarity for module"""
|
2021-11-22 19:51:40 +01:00
|
|
|
|
|
|
|
|
return True
|