From 37fcf3bf37e923fee94f6f075eb9cd9e131353a5 Mon Sep 17 00:00:00 2001 From: mrg Date: Tue, 16 Jul 2019 15:18:04 -0700 Subject: [PATCH] Move classes to individual file. --- compiler/base/delay_data.py | 43 +++++++++++++ compiler/base/hierarchy_spice.py | 102 +----------------------------- compiler/base/power_data.py | 38 +++++++++++ compiler/base/wire_spice_model.py | 42 ++++++++++++ 4 files changed, 126 insertions(+), 99 deletions(-) create mode 100644 compiler/base/delay_data.py create mode 100644 compiler/base/power_data.py create mode 100644 compiler/base/wire_spice_model.py diff --git a/compiler/base/delay_data.py b/compiler/base/delay_data.py new file mode 100644 index 00000000..e3d5a8bc --- /dev/null +++ b/compiler/base/delay_data.py @@ -0,0 +1,43 @@ +# 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. +# + +class delay_data(): + """ + This is the delay class to represent the delay information + Time is 50% of the signal to 50% of reference signal delay. + Slew is the 10% of the signal to 90% of signal + """ + def __init__(self, delay=0.0, slew=0.0): + """ init function support two init method""" + # will take single input as a coordinate + self.delay = delay + self.slew = slew + + def __str__(self): + """ override print function output """ + return "Delay Data: Delay "+str(self.delay)+", Slew "+str(self.slew)+"" + + def __add__(self, other): + """ + Override - function (left), for delay_data: a+b != b+a + """ + assert isinstance(other,delay_data) + return delay_data(other.delay + self.delay, + other.slew) + + def __radd__(self, other): + """ + Override - function (right), for delay_data: a+b != b+a + """ + assert isinstance(other,delay_data) + return delay_data(other.delay + self.delay, + self.slew) + + + + diff --git a/compiler/base/hierarchy_spice.py b/compiler/base/hierarchy_spice.py index e106cb2a..9730c7ef 100644 --- a/compiler/base/hierarchy_spice.py +++ b/compiler/base/hierarchy_spice.py @@ -10,6 +10,9 @@ import re import os import math import tech +from delay_data import * +from wire_spice_model import * +from power_data import * class spice(): @@ -383,102 +386,3 @@ class spice(): def return_power(self, dynamic=0.0, leakage=0.0): return power_data(dynamic, leakage) -class delay_data: - """ - This is the delay class to represent the delay information - Time is 50% of the signal to 50% of reference signal delay. - Slew is the 10% of the signal to 90% of signal - """ - def __init__(self, delay=0.0, slew=0.0): - """ init function support two init method""" - # will take single input as a coordinate - self.delay = delay - self.slew = slew - - def __str__(self): - """ override print function output """ - return "Delay Data: Delay "+str(self.delay)+", Slew "+str(self.slew)+"" - - def __add__(self, other): - """ - Override - function (left), for delay_data: a+b != b+a - """ - assert isinstance(other,delay_data) - return delay_data(other.delay + self.delay, - other.slew) - - def __radd__(self, other): - """ - Override - function (right), for delay_data: a+b != b+a - """ - assert isinstance(other,delay_data) - return delay_data(other.delay + self.delay, - self.slew) - -class power_data: - """ - This is the power class to represent the power information - Dynamic and leakage power are stored as a single object with this class. - """ - def __init__(self, dynamic=0.0, leakage=0.0): - """ init function support two init method""" - # will take single input as a coordinate - self.dynamic = dynamic - self.leakage = leakage - - def __str__(self): - """ override print function output """ - return "Power Data: Dynamic "+str(self.dynamic)+", Leakage "+str(self.leakage)+" in nW" - - def __add__(self, other): - """ - Override - function (left), for power_data: a+b != b+a - """ - assert isinstance(other,power_data) - return power_data(other.dynamic + self.dynamic, - other.leakage + self.leakage) - - def __radd__(self, other): - """ - Override - function (left), for power_data: a+b != b+a - """ - assert isinstance(other,power_data) - return power_data(other.dynamic + self.dynamic, - other.leakage + self.leakage) - - -class wire_spice_model: - """ - This is the spice class to represent a wire - """ - def __init__(self, lump_num, wire_length, wire_width): - self.lump_num = lump_num # the number of segment the wire delay has - self.wire_c = self.cal_wire_c(wire_length, wire_width) # c in each segment - self.wire_r = self.cal_wire_r(wire_length, wire_width) # r in each segment - - def cal_wire_c(self, wire_length, wire_width): - from tech import spice - total_c = spice["wire_unit_c"] * wire_length * wire_width - wire_c = total_c / self.lump_num - return wire_c - - def cal_wire_r(self, wire_length, wire_width): - from tech import spice - total_r = spice["wire_unit_r"] * wire_length / wire_width - wire_r = total_r / self.lump_num - return wire_r - - def return_input_cap(self): - return 0.5 * self.wire_c * self.lump_num - - def return_delay_over_wire(self, slew, swing = 0.5): - # delay will be sum of arithmetic sequence start from - # rc to self.lump_num*rc with step of rc - - swing_factor = abs(math.log(1-swing)) # time constant based on swing - sum_factor = (1+self.lump_num) * self.lump_num * 0.5 # sum of the arithmetic sequence - delay = sum_factor * swing_factor * self.wire_r * self.wire_c - slew = delay * 2 + slew - result= delay_data(delay, slew) - return result - diff --git a/compiler/base/power_data.py b/compiler/base/power_data.py new file mode 100644 index 00000000..77d50d34 --- /dev/null +++ b/compiler/base/power_data.py @@ -0,0 +1,38 @@ +# 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. +# + +class power_data(): + """ + This is the power class to represent the power information + Dynamic and leakage power are stored as a single object with this class. + """ + def __init__(self, dynamic=0.0, leakage=0.0): + """ init function support two init method""" + # will take single input as a coordinate + self.dynamic = dynamic + self.leakage = leakage + + def __str__(self): + """ override print function output """ + return "Power Data: Dynamic "+str(self.dynamic)+", Leakage "+str(self.leakage)+" in nW" + + def __add__(self, other): + """ + Override - function (left), for power_data: a+b != b+a + """ + assert isinstance(other,power_data) + return power_data(other.dynamic + self.dynamic, + other.leakage + self.leakage) + + def __radd__(self, other): + """ + Override - function (left), for power_data: a+b != b+a + """ + assert isinstance(other,power_data) + return power_data(other.dynamic + self.dynamic, + other.leakage + self.leakage) diff --git a/compiler/base/wire_spice_model.py b/compiler/base/wire_spice_model.py new file mode 100644 index 00000000..5624b575 --- /dev/null +++ b/compiler/base/wire_spice_model.py @@ -0,0 +1,42 @@ +# 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. +# + +class wire_spice_model(): + """ + This is the spice class to represent a wire + """ + def __init__(self, lump_num, wire_length, wire_width): + self.lump_num = lump_num # the number of segment the wire delay has + self.wire_c = self.cal_wire_c(wire_length, wire_width) # c in each segment + self.wire_r = self.cal_wire_r(wire_length, wire_width) # r in each segment + + def cal_wire_c(self, wire_length, wire_width): + from tech import spice + total_c = spice["wire_unit_c"] * wire_length * wire_width + wire_c = total_c / self.lump_num + return wire_c + + def cal_wire_r(self, wire_length, wire_width): + from tech import spice + total_r = spice["wire_unit_r"] * wire_length / wire_width + wire_r = total_r / self.lump_num + return wire_r + + def return_input_cap(self): + return 0.5 * self.wire_c * self.lump_num + + def return_delay_over_wire(self, slew, swing = 0.5): + # delay will be sum of arithmetic sequence start from + # rc to self.lump_num*rc with step of rc + + swing_factor = abs(math.log(1-swing)) # time constant based on swing + sum_factor = (1+self.lump_num) * self.lump_num * 0.5 # sum of the arithmetic sequence + delay = sum_factor * swing_factor * self.wire_r * self.wire_c + slew = delay * 2 + slew + result= delay_data(delay, slew) + return result