mirror of https://github.com/VLSIDA/OpenRAM.git
Move classes to individual file.
This commit is contained in:
parent
8ca656959b
commit
37fcf3bf37
|
|
@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
@ -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
|
||||
Loading…
Reference in New Issue