2020-05-14 20:20:37 +02:00
|
|
|
# See LICENSE for licensing information.
|
|
|
|
|
#
|
|
|
|
|
# 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.
|
|
|
|
|
#
|
|
|
|
|
import design
|
2020-06-02 01:46:00 +02:00
|
|
|
from tech import GDS, layer, spice, parameter, drc
|
2020-05-14 20:20:37 +02:00
|
|
|
import logical_effort
|
|
|
|
|
import utils
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class nand2_dec(design.design):
|
|
|
|
|
"""
|
|
|
|
|
2-input NAND decoder for address decoders.
|
|
|
|
|
"""
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-05-14 20:20:37 +02:00
|
|
|
pin_names = ["A", "B", "Z", "vdd", "gnd"]
|
|
|
|
|
type_list = ["INPUT", "INPUT", "OUTPUT", "POWER", "GROUND"]
|
2020-11-03 01:00:16 +01:00
|
|
|
cell_size_layer = "boundary"
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-05-14 20:20:37 +02:00
|
|
|
def __init__(self, name="nand2_dec", height=None):
|
2020-11-03 20:58:25 +01:00
|
|
|
super().__init__(name)
|
2020-05-14 20:20:37 +02:00
|
|
|
|
2020-11-03 20:58:25 +01:00
|
|
|
(width, height) = utils.get_libcell_size(self.cell_name,
|
2020-11-03 01:00:16 +01:00
|
|
|
GDS["unit"],
|
|
|
|
|
layer[self.cell_size_layer])
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-11-03 01:00:16 +01:00
|
|
|
pin_map = utils.get_libcell_pins(self.pin_names,
|
2020-11-03 20:58:25 +01:00
|
|
|
self.cell_name,
|
2020-11-03 01:00:16 +01:00
|
|
|
GDS["unit"])
|
|
|
|
|
|
|
|
|
|
self.width = width
|
|
|
|
|
self.height = height
|
|
|
|
|
self.pin_map = pin_map
|
2020-05-14 20:20:37 +02:00
|
|
|
self.add_pin_types(self.type_list)
|
2020-06-02 01:46:00 +02:00
|
|
|
|
|
|
|
|
# FIXME: For now...
|
|
|
|
|
size = 1
|
|
|
|
|
self.size = size
|
|
|
|
|
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")
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-05-14 20:20:37 +02:00
|
|
|
def analytical_power(self, corner, load):
|
|
|
|
|
"""Returns dynamic and leakage power. Results in nW"""
|
|
|
|
|
c_eff = self.calculate_effective_capacitance(load)
|
|
|
|
|
freq = spice["default_event_frequency"]
|
|
|
|
|
power_dyn = self.calc_dynamic_power(corner, c_eff, freq)
|
|
|
|
|
power_leak = spice["nand2_leakage"]
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-05-14 20:20:37 +02:00
|
|
|
total_power = self.return_power(power_dyn, power_leak)
|
|
|
|
|
return total_power
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-05-14 20:20:37 +02:00
|
|
|
def calculate_effective_capacitance(self, load):
|
|
|
|
|
"""Computes effective capacitance. Results in fF"""
|
|
|
|
|
c_load = load
|
|
|
|
|
# In fF
|
|
|
|
|
c_para = spice["min_tx_drain_c"] * (self.nmos_size / parameter["min_tx_size"])
|
|
|
|
|
transition_prob = 0.1875
|
|
|
|
|
return transition_prob * (c_load + c_para)
|
|
|
|
|
|
|
|
|
|
def input_load(self):
|
|
|
|
|
"""Return the relative input capacitance of a single input"""
|
|
|
|
|
return self.nmos_size + self.pmos_size
|
2020-11-03 15:29:17 +01:00
|
|
|
|
2020-05-14 20:20:37 +02:00
|
|
|
def get_stage_effort(self, cout, inp_is_rise=True):
|
|
|
|
|
"""
|
|
|
|
|
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)
|
2020-11-03 15:29:17 +01:00
|
|
|
|