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-02-15 00:16:28 +01:00
|
|
|
import globals
|
|
|
|
|
import design
|
|
|
|
|
from math import log
|
|
|
|
|
import design
|
2018-11-08 09:10:51 +01:00
|
|
|
from tech import GDS,layer,spice,parameter
|
2018-02-15 00:16:28 +01:00
|
|
|
import utils
|
|
|
|
|
|
|
|
|
|
class dff(design.design):
|
|
|
|
|
"""
|
|
|
|
|
Memory address flip-flop
|
|
|
|
|
"""
|
|
|
|
|
|
2018-02-17 00:25:27 +01:00
|
|
|
pin_names = ["D", "Q", "clk", "vdd", "gnd"]
|
2019-05-07 09:52:27 +02:00
|
|
|
type_list = ["INPUT", "OUTPUT", "INPUT", "POWER", "GROUND"]
|
2018-02-15 00:16:28 +01:00
|
|
|
(width,height) = utils.get_libcell_size("dff", GDS["unit"], layer["boundary"])
|
2018-11-07 20:31:44 +01:00
|
|
|
pin_map = utils.get_libcell_pins(pin_names, "dff", GDS["unit"])
|
2018-02-15 00:16:28 +01:00
|
|
|
|
|
|
|
|
def __init__(self, name="dff"):
|
|
|
|
|
design.design.__init__(self, name)
|
|
|
|
|
|
|
|
|
|
self.width = dff.width
|
|
|
|
|
self.height = dff.height
|
|
|
|
|
self.pin_map = dff.pin_map
|
2019-05-07 09:52:27 +02:00
|
|
|
self.add_pin_types(self.type_list)
|
2018-02-15 00:16:28 +01:00
|
|
|
|
2019-03-05 04:27:53 +01:00
|
|
|
def analytical_power(self, corner, load):
|
2018-09-13 20:02:28 +02:00
|
|
|
"""Returns dynamic and leakage power. Results in nW"""
|
|
|
|
|
c_eff = self.calculate_effective_capacitance(load)
|
2019-03-05 04:27:53 +01:00
|
|
|
freq = spice["default_event_rate"]
|
|
|
|
|
power_dyn = self.calc_dynamic_power(corner, c_eff, freq)
|
2018-09-13 20:02:28 +02:00
|
|
|
power_leak = spice["msflop_leakage"]
|
|
|
|
|
|
|
|
|
|
total_power = self.return_power(power_dyn, power_leak)
|
|
|
|
|
return total_power
|
|
|
|
|
|
|
|
|
|
def calculate_effective_capacitance(self, load):
|
|
|
|
|
"""Computes effective capacitance. Results in fF"""
|
2018-11-08 09:10:51 +01:00
|
|
|
from tech import parameter
|
2018-09-13 20:02:28 +02:00
|
|
|
c_load = load
|
|
|
|
|
c_para = spice["flop_para_cap"]#ff
|
|
|
|
|
transition_prob = spice["flop_transition_prob"]
|
|
|
|
|
return transition_prob*(c_load + c_para)
|
|
|
|
|
|
2018-11-08 09:10:51 +01:00
|
|
|
def get_clk_cin(self):
|
|
|
|
|
"""Return the total capacitance (in relative units) that the clock is loaded by in the dff"""
|
|
|
|
|
#This is a handmade cell so the value must be entered in the tech.py file or estimated.
|
|
|
|
|
#Calculated in the tech file by summing the widths of all the gates and dividing by the minimum width.
|
|
|
|
|
return parameter["dff_clk_cin"]
|
2018-02-15 00:16:28 +01:00
|
|
|
|
2019-04-24 23:23:22 +02:00
|
|
|
def build_graph(self, graph, inst_name, port_nets):
|
2019-05-07 09:52:27 +02:00
|
|
|
"""Adds edges based on inputs/outputs. Overrides base class function."""
|
|
|
|
|
self.add_graph_edges(graph, port_nets)
|
2019-04-24 23:23:22 +02:00
|
|
|
|