Convert print to functional type call like Python 3. Perform error checking that requires Python >2.7 <3.0 for better error checking.

This commit is contained in:
Matt Guthaus 2017-06-12 15:02:48 -07:00
parent 6e90bf0d6d
commit 8a821e13ac
4 changed files with 30 additions and 32 deletions

View File

@ -13,20 +13,20 @@ def check(check,str):
(frame, filename, line_number, function_name, lines,
index) = inspect.getouterframes(inspect.currentframe())[1]
if not check:
print "ERROR: file ", os.path.basename(filename), ": line ", line_number, ": ", str
print("ERROR: file {0}: line {1}: {2}".format(os.path.basename(filename),line_number,str))
sys.exit(-1)
def error(str,return_value=None):
(frame, filename, line_number, function_name, lines,
index) = inspect.getouterframes(inspect.currentframe())[1]
print "ERROR: file ", os.path.basename(filename), ": line ", line_number, ": ", str
print("ERROR: file {0}: line {1}: {2}".format(os.path.basename(filename),line_number,str))
if return_value:
sys.exit(return_value)
def warning(str):
(frame, filename, line_number, function_name, lines,
index) = inspect.getouterframes(inspect.currentframe())[1]
print "WARNING: file ", os.path.basename(filename), ": line ", line_number, ": ", str
print("WARNING: file {0}: line {1}: {2}".format(os.path.basename(filename),line_number,str))
def info(lev, str):
@ -34,6 +34,6 @@ def info(lev, str):
if (OPTS.debug_level >= lev):
frm = inspect.stack()[1]
mod = inspect.getmodule(frm[0])
print "\n[", frm[0].f_code.co_name, "]: ", str
print("\n[{0}]: {1}".format(frm[0].f_code.co_name,str))
# This sometimes gets a NoneType mod...
# print "[" , mod.__name__ , "]: ", str

View File

@ -87,18 +87,18 @@ def print_banner():
if not OPTS.print_banner:
return
print "|==============================================================================|"
print("|==============================================================================|")
name = "OpenRAM Compiler v"+VERSION
print "|=========" + name.center(60) + "=========|"
print "|=========" + " ".center(60) + "=========|"
print "|=========" + "VLSI Design and Automation Lab".center(60) + "=========|"
print "|=========" + "University of California Santa Cruz CE Department".center(60) + "=========|"
print "|=========" + " ".center(60) + "=========|"
print "|=========" + "VLSI Computer Architecture Research Group".center(60) + "=========|"
print "|=========" + "Oklahoma State University ECE Department".center(60) + "=========|"
print "|=========" + " ".center(60) + "=========|"
print "|=========" + OPTS.openram_temp.center(60) + "=========|"
print "|==============================================================================|"
print("|=========" + name.center(60) + "=========|")
print("|=========" + " ".center(60) + "=========|")
print("|=========" + "VLSI Design and Automation Lab".center(60) + "=========|")
print("|=========" + "University of California Santa Cruz CE Department".center(60) + "=========|")
print("|=========" + " ".center(60) + "=========|")
print("|=========" + "VLSI Computer Architecture Research Group".center(60) + "=========|")
print("|=========" + "Oklahoma State University ECE Department".center(60) + "=========|")
print("|=========" + " ".center(60) + "=========|")
print("|=========" + OPTS.openram_temp.center(60) + "=========|")
print("|==============================================================================|")
def init_openram(config_file):
@ -214,18 +214,18 @@ def setup_paths():
# make the directory if it doesn't exist
try:
os.makedirs(OPTS.openram_temp, 0750)
os.makedirs(OPTS.openram_temp, 0o750)
except OSError as e:
if e.errno == 17: # errno.EEXIST
os.chmod(OPTS.openram_temp, 0750)
os.chmod(OPTS.openram_temp, 0o750)
# Don't delete the output dir, it may have other files!
# make the directory if it doesn't exist
try:
os.makedirs(OPTS.output_path, 0750)
os.makedirs(OPTS.output_path, 0o750)
except OSError as e:
if e.errno == 17: # errno.EEXIST
os.chmod(OPTS.output_path, 0750)
os.chmod(OPTS.output_path, 0o750)

View File

@ -109,7 +109,6 @@ class hierarchical_predecode2x4(hierarchical_predecode):
return self.rail_height
def delay(self, slope, load = 0.0 ):
#print "pre2x4 consist:"
# A -> B
a_t_b_delay = self.inv.delay(slope=slope,load = self.nand.input_load())
@ -120,7 +119,6 @@ class hierarchical_predecode2x4(hierarchical_predecode):
# Z -> out
a_t_out_delay = self.inv.delay(slope=b_t_z_delay.slope,load = load)
result = result + a_t_out_delay
#print "end of pre2x4"
return result
def input_load(self):

View File

@ -31,7 +31,7 @@ import debug
# required positional args for using openram main exe
if len(args) < 1:
print globals.USAGE
print(globals.USAGE)
sys.exit(2)
globals.print_banner()
@ -61,14 +61,14 @@ if (OPTS.output_name == ""):
debug.info(1, "Output file is " + OPTS.output_name + ".(sp|gds|v|lib|lef)")
print "Technology: %s" % (OPTS.tech_name)
print "Word size: {0}\nWords: {1}\nBanks: {2}".format(word_size,num_words,num_banks)
print("Technology: {0}".format(OPTS.tech_name))
print("Word size: {0}\nWords: {1}\nBanks: {2}".format(word_size,num_words,num_banks))
# only start importing modules after we have the config file
import calibre
import sram
print "Start: ", datetime.datetime.now()
print("Start: {0}".format(datetime.datetime.now()))
# import SRAM test generation
s = sram.sram(word_size=word_size,
@ -79,16 +79,16 @@ s = sram.sram(word_size=word_size,
# Measure design area
# Not working?
#cell_size = s.gds.measureSize(s.name)
#print "Area:", cell_size[0] * cell_size[1]
#print("Area:", cell_size[0] * cell_size[1])
# Output the files for the resulting SRAM
spname = OPTS.output_path + s.name + ".sp"
print "SP: Writing to {0}".format(spname)
print("SP: Writing to {0}".format(spname))
s.sp_write(spname)
gdsname = OPTS.output_path + s.name + ".gds"
print "GDS: Writing to {0}".format(gdsname)
print("GDS: Writing to {0}".format(gdsname))
s.gds_write(gdsname)
# Run Characterizer on the design
@ -101,21 +101,21 @@ if OPTS.use_pex:
# geenrate verilog
import verilog
vname = OPTS.output_path + s.name + ".v"
print "Verilog: Writing to {0}".format(vname)
print("Verilog: Writing to {0}".format(vname))
verilog.verilog(vname,s)
# generate LEF
import lef
lefname = OPTS.output_path + s.name + ".lef"
print "LEF: Writing to {0}".format(lefname)
print("LEF: Writing to {0}".format(lefname))
lef.lef(gdsname,lefname,s)
# generate lib
import lib
libname = OPTS.output_path + s.name + ".lib"
print "LIB: Writing to {0}".format(libname)
print("LIB: Writing to {0}".format(libname))
lib.lib(libname,s,sram_file)
globals.end_openram()
print "End: ", datetime.datetime.now()
print("End: {0}".format(datetime.datetime.now()))