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
|
|
|
#
|
2017-12-12 23:53:19 +01:00
|
|
|
import pgate
|
|
|
|
|
import debug
|
|
|
|
|
from tech import drc, parameter, spice
|
2020-04-14 05:48:34 +02:00
|
|
|
from globals import OPTS
|
2017-12-12 23:53:19 +01:00
|
|
|
from vector import vector
|
2018-11-08 09:10:51 +01:00
|
|
|
import logical_effort
|
2019-01-17 01:30:31 +01:00
|
|
|
from sram_factory import factory
|
2017-12-12 23:53:19 +01:00
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
|
2017-12-12 23:53:19 +01:00
|
|
|
class pnand2(pgate.pgate):
|
|
|
|
|
"""
|
|
|
|
|
This module generates gds of a parametrically sized 2-input nand.
|
|
|
|
|
This model use ptx to generate a 2-input nand within a cetrain height.
|
|
|
|
|
"""
|
2020-05-12 01:22:08 +02:00
|
|
|
def __init__(self, name, size=1, height=None, add_wells=True):
|
2017-12-12 23:53:19 +01:00
|
|
|
""" Creates a cell for a simple 2 input nand """
|
2019-04-26 20:57:29 +02:00
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
debug.info(2,
|
|
|
|
|
"creating pnand2 structure {0} with size of {1}".format(name,
|
|
|
|
|
size))
|
2019-01-24 02:27:15 +01:00
|
|
|
self.add_comment("size: {}".format(size))
|
2017-12-12 23:53:19 +01:00
|
|
|
|
2018-11-08 09:10:51 +01:00
|
|
|
self.size = size
|
2019-10-06 19:30:16 +02:00
|
|
|
self.nmos_size = 2 * size
|
|
|
|
|
self.pmos_size = parameter["beta"] * size
|
|
|
|
|
self.nmos_width = self.nmos_size * drc("minwidth_tx")
|
|
|
|
|
self.pmos_width = self.pmos_size * drc("minwidth_tx")
|
2017-12-12 23:53:19 +01:00
|
|
|
|
|
|
|
|
# FIXME: Allow these to be sized
|
2019-10-06 19:30:16 +02:00
|
|
|
debug.check(size == 1, "Size 1 pnand2 is only supported now.")
|
2017-12-12 23:53:19 +01:00
|
|
|
self.tx_mults = 1
|
|
|
|
|
|
2020-04-14 05:48:34 +02:00
|
|
|
if OPTS.tech_name == "s8":
|
|
|
|
|
(self.nmos_width, self.tx_mults) = self.bin_width("nmos", self.nmos_width)
|
|
|
|
|
(self.pmos_width, self.tx_mults) = self.bin_width("pmos", self.pmos_width)
|
|
|
|
|
|
2019-04-26 20:57:29 +02:00
|
|
|
# Creates the netlist and layout
|
2020-05-12 01:22:08 +02:00
|
|
|
pgate.pgate.__init__(self, name, height, add_wells)
|
2019-08-08 10:57:04 +02:00
|
|
|
|
2018-08-27 23:18:32 +02:00
|
|
|
def create_netlist(self):
|
|
|
|
|
self.add_pins()
|
2018-08-28 01:42:48 +02:00
|
|
|
self.add_ptx()
|
|
|
|
|
self.create_ptx()
|
2018-08-27 23:18:32 +02:00
|
|
|
|
2017-12-12 23:53:19 +01:00
|
|
|
def create_layout(self):
|
|
|
|
|
""" Calls all functions related to the generation of the layout """
|
|
|
|
|
|
|
|
|
|
self.setup_layout_constants()
|
2018-08-28 01:42:48 +02:00
|
|
|
self.place_ptx()
|
2020-05-12 01:22:08 +02:00
|
|
|
if self.add_wells:
|
|
|
|
|
self.add_well_contacts()
|
|
|
|
|
self.route_output()
|
2020-02-25 18:09:07 +01:00
|
|
|
self.determine_width()
|
|
|
|
|
self.route_supply_rails()
|
|
|
|
|
self.connect_rails()
|
2020-02-06 17:20:09 +01:00
|
|
|
self.extend_wells()
|
2017-12-12 23:53:19 +01:00
|
|
|
self.route_inputs()
|
2020-04-22 00:21:57 +02:00
|
|
|
self.add_boundary()
|
|
|
|
|
|
2018-08-28 01:42:48 +02:00
|
|
|
def add_pins(self):
|
|
|
|
|
""" Adds pins for spice netlist """
|
2019-05-07 09:52:27 +02:00
|
|
|
pin_list = ["A", "B", "Z", "vdd", "gnd"]
|
2019-08-06 23:14:09 +02:00
|
|
|
dir_list = ["INPUT", "INPUT", "OUTPUT", "POWER", "GROUND"]
|
2019-05-07 09:52:27 +02:00
|
|
|
self.add_pin_list(pin_list, dir_list)
|
2018-08-28 01:42:48 +02:00
|
|
|
|
|
|
|
|
def add_ptx(self):
|
2017-12-12 23:53:19 +01:00
|
|
|
""" Create the PMOS and NMOS transistors. """
|
2020-04-23 23:43:54 +02:00
|
|
|
self.nmos_left = factory.create(module_type="ptx",
|
|
|
|
|
width=self.nmos_width,
|
|
|
|
|
mults=self.tx_mults,
|
|
|
|
|
tx_type="nmos",
|
2020-05-07 21:35:21 +02:00
|
|
|
add_source_contact=self.route_layer,
|
2020-04-23 23:43:54 +02:00
|
|
|
add_drain_contact="active")
|
|
|
|
|
self.add_mod(self.nmos_left)
|
|
|
|
|
|
|
|
|
|
self.nmos_right = factory.create(module_type="ptx",
|
|
|
|
|
width=self.nmos_width,
|
|
|
|
|
mults=self.tx_mults,
|
|
|
|
|
tx_type="nmos",
|
|
|
|
|
add_source_contact="active",
|
|
|
|
|
add_drain_contact=self.route_layer)
|
|
|
|
|
self.add_mod(self.nmos_right)
|
|
|
|
|
|
|
|
|
|
self.pmos_left = factory.create(module_type="ptx",
|
|
|
|
|
width=self.pmos_width,
|
|
|
|
|
mults=self.tx_mults,
|
|
|
|
|
tx_type="pmos",
|
2020-05-07 21:35:21 +02:00
|
|
|
add_source_contact=self.route_layer,
|
2020-04-23 23:43:54 +02:00
|
|
|
add_drain_contact=self.route_layer)
|
|
|
|
|
self.add_mod(self.pmos_left)
|
|
|
|
|
|
|
|
|
|
self.pmos_right = factory.create(module_type="ptx",
|
|
|
|
|
width=self.pmos_width,
|
|
|
|
|
mults=self.tx_mults,
|
|
|
|
|
tx_type="pmos",
|
|
|
|
|
add_source_contact=self.route_layer,
|
2020-05-07 21:35:21 +02:00
|
|
|
add_drain_contact=self.route_layer)
|
2020-04-23 23:43:54 +02:00
|
|
|
self.add_mod(self.pmos_right)
|
2020-03-23 19:46:21 +01:00
|
|
|
|
2017-12-12 23:53:19 +01:00
|
|
|
def setup_layout_constants(self):
|
|
|
|
|
""" Pre-compute some handy layout parameters. """
|
|
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
# Compute the other pmos2 location,
|
|
|
|
|
# but determining offset to overlap the
|
2017-12-12 23:53:19 +01:00
|
|
|
# source and drain pins
|
2020-04-23 23:43:54 +02:00
|
|
|
self.overlap_offset = self.pmos_left.get_pin("D").center() - self.pmos_left.get_pin("S").center()
|
2017-12-12 23:53:19 +01:00
|
|
|
|
2018-08-28 01:42:48 +02:00
|
|
|
def create_ptx(self):
|
2019-10-06 19:30:16 +02:00
|
|
|
"""
|
2018-08-28 01:42:48 +02:00
|
|
|
Add PMOS and NMOS to the netlist.
|
2017-12-12 23:53:19 +01:00
|
|
|
"""
|
|
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
self.pmos1_inst = self.add_inst(name="pnand2_pmos1",
|
2020-04-23 23:43:54 +02:00
|
|
|
mod=self.pmos_left)
|
2017-12-12 23:53:19 +01:00
|
|
|
self.connect_inst(["vdd", "A", "Z", "vdd"])
|
|
|
|
|
|
|
|
|
|
self.pmos2_inst = self.add_inst(name="pnand2_pmos2",
|
2020-04-23 23:43:54 +02:00
|
|
|
mod=self.pmos_right)
|
2017-12-12 23:53:19 +01:00
|
|
|
self.connect_inst(["Z", "B", "vdd", "vdd"])
|
|
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
self.nmos1_inst = self.add_inst(name="pnand2_nmos1",
|
2020-04-23 23:43:54 +02:00
|
|
|
mod=self.nmos_left)
|
2018-01-30 00:31:14 +01:00
|
|
|
self.connect_inst(["Z", "B", "net1", "gnd"])
|
2017-12-12 23:53:19 +01:00
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
self.nmos2_inst = self.add_inst(name="pnand2_nmos2",
|
2020-04-23 23:43:54 +02:00
|
|
|
mod=self.nmos_right)
|
2018-01-30 00:31:14 +01:00
|
|
|
self.connect_inst(["net1", "A", "gnd", "gnd"])
|
2017-12-12 23:53:19 +01:00
|
|
|
|
2018-08-28 01:42:48 +02:00
|
|
|
def place_ptx(self):
|
2019-10-06 19:30:16 +02:00
|
|
|
"""
|
2018-08-28 01:42:48 +02:00
|
|
|
Place PMOS and NMOS to the layout at the upper-most and lowest position
|
|
|
|
|
to provide maximum routing in channel
|
|
|
|
|
"""
|
|
|
|
|
|
2020-04-23 23:43:54 +02:00
|
|
|
pmos1_pos = vector(self.pmos_left.active_offset.x,
|
|
|
|
|
self.height - self.pmos_left.active_height \
|
2019-10-06 19:30:16 +02:00
|
|
|
- self.top_bottom_space)
|
2018-08-28 02:25:39 +02:00
|
|
|
self.pmos1_inst.place(pmos1_pos)
|
2018-08-28 01:42:48 +02:00
|
|
|
|
|
|
|
|
self.pmos2_pos = pmos1_pos + self.overlap_offset
|
2018-08-28 02:25:39 +02:00
|
|
|
self.pmos2_inst.place(self.pmos2_pos)
|
2018-08-28 01:42:48 +02:00
|
|
|
|
2020-04-23 23:43:54 +02:00
|
|
|
nmos1_pos = vector(self.pmos_left.active_offset.x,
|
2019-10-06 19:30:16 +02:00
|
|
|
self.top_bottom_space)
|
2018-08-28 02:25:39 +02:00
|
|
|
self.nmos1_inst.place(nmos1_pos)
|
2018-08-28 01:42:48 +02:00
|
|
|
|
|
|
|
|
self.nmos2_pos = nmos1_pos + self.overlap_offset
|
2018-08-28 02:25:39 +02:00
|
|
|
self.nmos2_inst.place(self.nmos2_pos)
|
2018-08-28 01:42:48 +02:00
|
|
|
|
2017-12-12 23:53:19 +01:00
|
|
|
def add_well_contacts(self):
|
2020-04-14 19:52:25 +02:00
|
|
|
"""
|
2019-10-06 19:30:16 +02:00
|
|
|
Add n/p well taps to the layout and connect to supplies
|
|
|
|
|
AFTER the wells are created
|
|
|
|
|
"""
|
2017-12-12 23:53:19 +01:00
|
|
|
|
2020-04-23 23:43:54 +02:00
|
|
|
self.add_nwell_contact(self.pmos_right, self.pmos2_pos)
|
|
|
|
|
self.add_pwell_contact(self.nmos_left, self.nmos2_pos)
|
2017-12-12 23:53:19 +01:00
|
|
|
|
|
|
|
|
def connect_rails(self):
|
|
|
|
|
""" Connect the nmos and pmos to its respective power rails """
|
|
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
self.connect_pin_to_rail(self.nmos1_inst, "S", "gnd")
|
2017-12-12 23:53:19 +01:00
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
self.connect_pin_to_rail(self.pmos1_inst, "S", "vdd")
|
2017-12-12 23:53:19 +01:00
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
self.connect_pin_to_rail(self.pmos2_inst, "D", "vdd")
|
2017-12-12 23:53:19 +01:00
|
|
|
|
|
|
|
|
def route_inputs(self):
|
|
|
|
|
""" Route the A and B inputs """
|
2020-05-07 21:35:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# Top of NMOS drain
|
2020-06-10 01:34:15 +02:00
|
|
|
bottom_pin = self.nmos2_inst.get_pin("D")
|
|
|
|
|
self.inputA_yoffset = max(bottom_pin.uy() + self.m1_pitch,
|
|
|
|
|
self.nmos2_inst.uy() + self.poly_to_active)
|
2020-05-07 21:35:21 +02:00
|
|
|
|
|
|
|
|
self.inputB_yoffset = self.inputA_yoffset + self.m3_pitch
|
|
|
|
|
|
2020-04-23 23:43:54 +02:00
|
|
|
# This will help with the wells and the input/output placement
|
2019-10-06 19:30:16 +02:00
|
|
|
self.route_input_gate(self.pmos2_inst,
|
|
|
|
|
self.nmos2_inst,
|
2020-05-07 21:35:21 +02:00
|
|
|
self.inputB_yoffset,
|
2019-10-06 19:30:16 +02:00
|
|
|
"B",
|
2020-05-07 21:35:21 +02:00
|
|
|
position="center")
|
2017-12-12 23:53:19 +01:00
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
self.route_input_gate(self.pmos1_inst,
|
|
|
|
|
self.nmos1_inst,
|
|
|
|
|
self.inputA_yoffset,
|
2020-05-07 21:35:21 +02:00
|
|
|
"A",
|
|
|
|
|
position="center")
|
2017-12-12 23:53:19 +01:00
|
|
|
|
|
|
|
|
def route_output(self):
|
|
|
|
|
""" Route the Z output """
|
2020-05-07 21:35:21 +02:00
|
|
|
|
|
|
|
|
# One routing track layer below the PMOS contacts
|
|
|
|
|
route_layer_offset = 0.5 * self.route_layer_width + self.route_layer_space
|
|
|
|
|
output_yoffset = self.pmos1_inst.get_pin("D").by() - route_layer_offset
|
|
|
|
|
|
2020-04-14 19:52:25 +02:00
|
|
|
|
2019-10-06 19:30:16 +02:00
|
|
|
# PMOS1 drain
|
2017-12-12 23:53:19 +01:00
|
|
|
pmos_pin = self.pmos1_inst.get_pin("D")
|
2020-05-07 21:35:21 +02:00
|
|
|
top_pin_offset = pmos_pin.bc()
|
2017-12-12 23:53:19 +01:00
|
|
|
# NMOS2 drain
|
2018-11-26 22:59:53 +01:00
|
|
|
nmos_pin = self.nmos2_inst.get_pin("D")
|
2020-05-07 21:35:21 +02:00
|
|
|
bottom_pin_offset = nmos_pin.uc()
|
2018-11-26 22:59:53 +01:00
|
|
|
|
2017-12-12 23:53:19 +01:00
|
|
|
# Output pin
|
2020-05-07 21:35:21 +02:00
|
|
|
out_offset = vector(nmos_pin.cx() + self.route_layer_pitch,
|
|
|
|
|
output_yoffset)
|
2018-11-26 22:59:53 +01:00
|
|
|
|
2020-04-14 19:52:25 +02:00
|
|
|
# This routes on M2
|
|
|
|
|
# # Midpoints of the L routes go horizontal first then vertical
|
|
|
|
|
# mid1_offset = vector(out_offset.x, top_pin_offset.y)
|
|
|
|
|
# mid2_offset = vector(out_offset.x, bottom_pin_offset.y)
|
|
|
|
|
|
|
|
|
|
# # Non-preferred active contacts
|
|
|
|
|
# self.add_via_center(layers=self.m1_stack,
|
|
|
|
|
# directions=("V", "H"),
|
|
|
|
|
# offset=pmos_pin.center())
|
|
|
|
|
# # Non-preferred active contacts
|
|
|
|
|
# self.add_via_center(layers=self.m1_stack,
|
|
|
|
|
# directions=("V", "H"),
|
|
|
|
|
# offset=nmos_pin.center())
|
|
|
|
|
# self.add_via_center(layers=self.m1_stack,
|
|
|
|
|
# offset=out_offset)
|
|
|
|
|
|
|
|
|
|
# # PMOS1 to mid-drain to NMOS2 drain
|
|
|
|
|
# self.add_path("m2",
|
|
|
|
|
# [top_pin_offset, mid1_offset, out_offset,
|
|
|
|
|
# mid2_offset, bottom_pin_offset])
|
|
|
|
|
|
2020-04-23 23:43:54 +02:00
|
|
|
# This routes on route_layer
|
2020-04-14 19:52:25 +02:00
|
|
|
# Midpoints of the L routes goes vertical first then horizontal
|
2020-05-07 21:35:21 +02:00
|
|
|
top_mid_offset = vector(top_pin_offset.x, out_offset.y)
|
|
|
|
|
# Top transistors
|
|
|
|
|
self.add_path(self.route_layer,
|
|
|
|
|
[top_pin_offset, top_mid_offset, out_offset])
|
2020-04-23 23:43:54 +02:00
|
|
|
|
2020-05-07 21:35:21 +02:00
|
|
|
bottom_mid_offset = bottom_pin_offset + vector(0, self.route_layer_pitch)
|
|
|
|
|
# Bottom transistors
|
2020-04-23 23:43:54 +02:00
|
|
|
self.add_path(self.route_layer,
|
2020-05-07 21:35:21 +02:00
|
|
|
[out_offset, bottom_mid_offset, bottom_pin_offset])
|
2019-04-01 23:23:47 +02:00
|
|
|
|
2017-12-12 23:53:19 +01:00
|
|
|
# This extends the output to the edge of the cell
|
2018-03-21 21:20:48 +01:00
|
|
|
self.add_layout_pin_rect_center(text="Z",
|
2020-04-23 23:43:54 +02:00
|
|
|
layer=self.route_layer,
|
|
|
|
|
offset=out_offset)
|
2017-12-12 23:53:19 +01:00
|
|
|
|
2019-03-05 04:27:53 +01:00
|
|
|
def analytical_power(self, corner, load):
|
2018-03-02 08:34:15 +01:00
|
|
|
"""Returns dynamic and leakage power. Results in nW"""
|
2018-02-27 01:32:28 +01:00
|
|
|
c_eff = self.calculate_effective_capacitance(load)
|
2019-09-05 01:08:18 +02:00
|
|
|
freq = spice["default_event_frequency"]
|
2019-03-05 04:27:53 +01:00
|
|
|
power_dyn = self.calc_dynamic_power(corner, c_eff, freq)
|
2018-02-27 01:32:28 +01:00
|
|
|
power_leak = spice["nand2_leakage"]
|
|
|
|
|
|
|
|
|
|
total_power = self.return_power(power_dyn, power_leak)
|
|
|
|
|
return total_power
|
|
|
|
|
|
|
|
|
|
def calculate_effective_capacitance(self, load):
|
2018-03-02 08:34:15 +01:00
|
|
|
"""Computes effective capacitance. Results in fF"""
|
2018-02-27 01:32:28 +01:00
|
|
|
c_load = load
|
2019-10-06 19:30:16 +02:00
|
|
|
# In fF
|
|
|
|
|
c_para = spice["min_tx_drain_c"] * (self.nmos_size / parameter["min_tx_size"])
|
2019-09-05 01:08:18 +02:00
|
|
|
transition_prob = 0.1875
|
2019-10-06 19:30:16 +02:00
|
|
|
return transition_prob * (c_load + c_para)
|
2018-11-08 09:10:51 +01:00
|
|
|
|
2019-08-07 10:50:48 +02:00
|
|
|
def input_load(self):
|
|
|
|
|
"""Return the relative input capacitance of a single input"""
|
2019-10-06 19:30:16 +02:00
|
|
|
return self.nmos_size + self.pmos_size
|
2019-08-07 10:50:48 +02:00
|
|
|
|
2019-01-23 21:03:52 +01:00
|
|
|
def get_stage_effort(self, cout, inp_is_rise=True):
|
2018-11-15 08:34:53 +01:00
|
|
|
"""
|
2019-10-06 19:30:16 +02:00
|
|
|
Returns an object representing the parameters for delay in tau units.
|
|
|
|
|
Optional is_rise refers to the input direction rise/fall.
|
|
|
|
|
Input inverted by this stage.
|
|
|
|
|
"""
|
|
|
|
|
parasitic_delay = 2
|
|
|
|
|
return logical_effort.logical_effort(self.name,
|
|
|
|
|
self.size,
|
|
|
|
|
self.input_load(),
|
|
|
|
|
cout,
|
|
|
|
|
parasitic_delay,
|
|
|
|
|
not inp_is_rise)
|
|
|
|
|
|
|
|
|
|
def build_graph(self, graph, inst_name, port_nets):
|
|
|
|
|
"""
|
|
|
|
|
Adds edges based on inputs/outputs.
|
|
|
|
|
Overrides base class function.
|
|
|
|
|
"""
|
|
|
|
|
self.add_graph_edges(graph, port_nets)
|