mirror of https://github.com/VLSIDA/OpenRAM.git
PEP8 cleanup
This commit is contained in:
parent
2850b9efb5
commit
8603d3edd6
|
|
@ -15,6 +15,7 @@ from wire_spice_model import *
|
|||
from power_data import *
|
||||
import logical_effort
|
||||
|
||||
|
||||
class spice():
|
||||
"""
|
||||
This provides a set of useful generic types for hierarchy
|
||||
|
|
@ -42,7 +43,7 @@ class spice():
|
|||
# Keep track of any comments to add the the spice
|
||||
try:
|
||||
self.commments
|
||||
except:
|
||||
except NameError:
|
||||
self.comments = []
|
||||
|
||||
self.sp_read()
|
||||
|
|
@ -56,7 +57,7 @@ class spice():
|
|||
|
||||
try:
|
||||
self.commments
|
||||
except:
|
||||
except NameError:
|
||||
self.comments = []
|
||||
|
||||
self.comments.append(comment)
|
||||
|
|
@ -65,7 +66,9 @@ class spice():
|
|||
""" Adds a pin to the pins list. Default type is INOUT signal. """
|
||||
self.pins.append(name)
|
||||
self.pin_type[name]=pin_type
|
||||
debug.check(pin_type in self.valid_signal_types, "Invalid signaltype for {0}: {1}".format(name,pin_type))
|
||||
debug.check(pin_type in self.valid_signal_types,
|
||||
"Invalid signaltype for {0}: {1}".format(name,
|
||||
pin_type))
|
||||
|
||||
def add_pin_list(self, pin_list, pin_type="INOUT"):
|
||||
""" Adds a pin_list to the pins list """
|
||||
|
|
@ -73,19 +76,25 @@ class spice():
|
|||
# or a list that is the same length as the pin list.
|
||||
if type(pin_type)==str:
|
||||
for pin in pin_list:
|
||||
debug.check(pin_type in self.valid_signal_types, "Invalid signaltype for {0}: {1}".format(pin,pin_type))
|
||||
debug.check(pin_type in self.valid_signal_types,
|
||||
"Invalid signaltype for {0}: {1}".format(pin,
|
||||
pin_type))
|
||||
self.add_pin(pin, pin_type)
|
||||
|
||||
elif len(pin_type)==len(pin_list):
|
||||
for (pin, ptype) in zip(pin_list, pin_type):
|
||||
debug.check(ptype in self.valid_signal_types, "Invalid signaltype for {0}: {1}".format(pin,ptype))
|
||||
debug.check(ptype in self.valid_signal_types,
|
||||
"Invalid signaltype for {0}: {1}".format(pin,
|
||||
ptype))
|
||||
self.add_pin(pin, ptype)
|
||||
else:
|
||||
debug.error("Mismatch in type and pin list lengths.", -1)
|
||||
|
||||
def add_pin_types(self, type_list):
|
||||
"""Add pin types for all the cell's pins.
|
||||
Typically, should only be used for handmade cells."""
|
||||
"""
|
||||
Add pin types for all the cell's pins.
|
||||
Typically, should only be used for handmade cells.
|
||||
"""
|
||||
# This only works if self.pins == bitcell.pin_names
|
||||
if self.pin_names != self.pins:
|
||||
debug.error("{} spice subcircuit port names do not match pin_names\
|
||||
|
|
@ -97,7 +106,8 @@ class spice():
|
|||
def get_pin_type(self, name):
|
||||
""" Returns the type of the signal pin. """
|
||||
pin_type = self.pin_type[name]
|
||||
debug.check(pin_type in self.valid_signal_types, "Invalid signaltype for {0}: {1}".format(name,pin_type))
|
||||
debug.check(pin_type in self.valid_signal_types,
|
||||
"Invalid signaltype for {0}: {1}".format(name, pin_type))
|
||||
return pin_type
|
||||
|
||||
def get_pin_dir(self, name):
|
||||
|
|
@ -125,7 +135,6 @@ class spice():
|
|||
output_list.append(pin)
|
||||
return output_list
|
||||
|
||||
|
||||
def copy_pins(self, other_module, suffix=""):
|
||||
""" This will copy all of the pins from the other module and add an optional suffix."""
|
||||
for pin in other_module.pins:
|
||||
|
|
@ -144,7 +153,6 @@ class spice():
|
|||
"""Adds a subckt/submodule to the subckt hierarchy"""
|
||||
self.mods.append(mod)
|
||||
|
||||
|
||||
def connect_inst(self, args, check=True):
|
||||
"""Connects the pins of the last instance added
|
||||
It is preferred to use the function with the check to find if
|
||||
|
|
@ -182,8 +190,10 @@ class spice():
|
|||
return None
|
||||
|
||||
def sp_read(self):
|
||||
"""Reads the sp file (and parse the pins) from the library
|
||||
Otherwise, initialize it to null for dynamic generation"""
|
||||
"""
|
||||
Reads the sp file (and parse the pins) from the library
|
||||
Otherwise, initialize it to null for dynamic generation
|
||||
"""
|
||||
if self.sp_file and os.path.isfile(self.sp_file):
|
||||
debug.info(3, "opening {0}".format(self.sp_file))
|
||||
f = open(self.sp_file)
|
||||
|
|
@ -202,7 +212,8 @@ class spice():
|
|||
|
||||
def check_net_in_spice(self, net_name):
|
||||
"""Checks if a net name exists in the current. Intended to be check nets in hand-made cells."""
|
||||
#Remove spaces and lower case then add spaces. Nets are separated by spaces.
|
||||
# Remove spaces and lower case then add spaces.
|
||||
# Nets are separated by spaces.
|
||||
net_formatted = ' ' + net_name.lstrip().rstrip().lower() + ' '
|
||||
for line in self.spice:
|
||||
# Lowercase the line and remove any part of the line that is a comment.
|
||||
|
|
@ -244,7 +255,6 @@ class spice():
|
|||
if self.pins == []:
|
||||
return
|
||||
|
||||
|
||||
# write out the first spice line (the subcircuit)
|
||||
sp.write("\n.SUBCKT {0} {1}\n".format(self.name,
|
||||
" ".join(self.pins)))
|
||||
|
|
@ -264,8 +274,6 @@ class spice():
|
|||
debug.error("-----")
|
||||
debug.error("Connections: \n" + str(self.conns), 1)
|
||||
|
||||
|
||||
|
||||
for i in range(len(self.insts)):
|
||||
# we don't need to output connections of empty instances.
|
||||
# these are wires and paths
|
||||
|
|
@ -305,7 +313,8 @@ class spice():
|
|||
def analytical_delay(self, corner, slew, load=0.0):
|
||||
"""Inform users undefined delay module while building new modules"""
|
||||
|
||||
# FIXME: Slew is not used in the model right now. Can be added heuristically as linear factor
|
||||
# FIXME: Slew is not used in the model right now.
|
||||
# Can be added heuristically as linear factor
|
||||
relative_cap = logical_effort.convert_farad_to_relative_c(load)
|
||||
stage_effort = self.get_stage_effort(relative_cap)
|
||||
|
||||
|
|
@ -403,7 +412,9 @@ class spice():
|
|||
thermal_voltage_nom = 0.008625 * tech.spice["nom_temperature"]
|
||||
thermal_voltage = 0.008625 * temp
|
||||
vthresh = (tech.spice["nom_threshold"] + 2 * (thermal_voltage - thermal_voltage_nom))
|
||||
#Calculate effect on Vdd-Vth. The current vdd is not used here. A separate vdd factor is calculated.
|
||||
# Calculate effect on Vdd-Vth.
|
||||
# The current vdd is not used here.
|
||||
# A separate vdd factor is calculated.
|
||||
return (tech.spice["nom_supply_voltage"] - tech.spice["nom_threshold"]) / (tech.spice["nom_supply_voltage"] - vthresh)
|
||||
|
||||
def return_delay(self, delay, slew):
|
||||
|
|
@ -420,7 +431,8 @@ class spice():
|
|||
net_vswing = vdd * swing
|
||||
power_dyn = c * vdd * net_vswing * freq
|
||||
|
||||
#Apply process and temperature factors. Roughly, process and Vdd affect the delay which affects the power.
|
||||
# A pply process and temperature factors.
|
||||
# Roughly, process and Vdd affect the delay which affects the power.
|
||||
# No other estimations are currently used. Increased delay->slower freq.->less power
|
||||
proc_div = max(self.get_process_delay_factor(proc))
|
||||
temp_div = self.get_temp_delay_factor(temp)
|
||||
|
|
|
|||
Loading…
Reference in New Issue