Enable output filename and path to be in config file. Command line will over-ride config file.

This commit is contained in:
mguthaus 2017-06-12 14:37:15 -07:00
parent a840209c08
commit 6e90bf0d6d
7 changed files with 54 additions and 28 deletions

View File

@ -4,6 +4,9 @@ num_banks = 1
tech_name = "freepdk45" tech_name = "freepdk45"
output_path = "/tmp/mysram"
output_name = "sram_2_16_1_freepdk45"
decoder = "hierarchical_decoder" decoder = "hierarchical_decoder"
ms_flop = "ms_flop" ms_flop = "ms_flop"
ms_flop_array = "ms_flop_array" ms_flop_array = "ms_flop_array"

View File

@ -4,6 +4,9 @@ num_banks = 1
tech_name = "scn3me_subm" tech_name = "scn3me_subm"
output_path = "/tmp/mysram"
output_name = "sram_2_16_1_scn3me_subm"
decoder = "hierarchical_decoder" decoder = "hierarchical_decoder"
ms_flop = "ms_flop" ms_flop = "ms_flop"
ms_flop_array = "ms_flop_array" ms_flop_array = "ms_flop_array"

View File

@ -14,12 +14,17 @@ import importlib
# Current version of OpenRAM. # Current version of OpenRAM.
VERSION = "1.0" VERSION = "1.0"
USAGE = "Usage: openram.py [options] <config file>\nUse -h for help.\n"
USAGE = "usage: openram.py [options] <config file>\n"
# Anonymous object that will be the options # Anonymous object that will be the options
OPTS = options.options() OPTS = options.options()
# check that we are not using version 3 and at least 2.7
major_python_version = sys.version_info.major
minor_python_version = sys.version_info.minor
if not (major_python_version == 2 and minor_python_version >= 7):
debug.error("Python 2.7 is required.",-1)
def is_exe(fpath): def is_exe(fpath):
return os.path.exists(fpath) and os.access(fpath, os.X_OK) return os.path.exists(fpath) and os.access(fpath, os.X_OK)
@ -34,11 +39,11 @@ def parse_args():
option_list = { option_list = {
optparse.make_option("-b", "--backannotated", action="store_true", dest="run_pex", optparse.make_option("-b", "--backannotated", action="store_true", dest="run_pex",
help="back annotated simulation for characterizer"), help="Back annotate simulation"),
optparse.make_option("-o", "--output", dest="out_name", optparse.make_option("-o", "--output", dest="output_name",
help="Base output file name.", metavar="FILE"), help="Base output file name(s) prefix", metavar="FILE"),
optparse.make_option("-p", "--outpath", dest="out_path", optparse.make_option("-p", "--outpath", dest="output_path",
help="output file location."), help="Output file(s) location"),
optparse.make_option("-n", "--nocheck", action="store_false", optparse.make_option("-n", "--nocheck", action="store_false",
help="Disable inline LVS/DRC checks", dest="check_lvsdrc"), help="Disable inline LVS/DRC checks", dest="check_lvsdrc"),
optparse.make_option("-q", "--quiet", action="store_false", dest="print_banner", optparse.make_option("-q", "--quiet", action="store_false", dest="print_banner",
@ -102,9 +107,9 @@ def init_openram(config_file):
debug.info(1,"Initializing OpenRAM...") debug.info(1,"Initializing OpenRAM...")
setup_paths() setup_paths()
read_config(config_file)
read_config(config_file)
import_tech() import_tech()
set_spice() set_spice()
@ -125,6 +130,18 @@ def read_config(config_file):
except: except:
debug.error("Unable to read configuration file: {0}".format(OPTS.config_file+".py. Did you specify the technology?"),2) debug.error("Unable to read configuration file: {0}".format(OPTS.config_file+".py. Did you specify the technology?"),2)
# This path must be setup after the config file.
try:
# If path not set on command line, try config file.
if OPTS.output_path=="":
OPTS.output_path=OPTS.config.output_path
except:
# Default to current directory.
OPTS.output_path="."
if not OPTS.output_path.endswith('/'):
OPTS.output_path += "/"
debug.info(1, "Output saved in " + OPTS.output_path)
def set_calibre(): def set_calibre():
debug.info(2,"Finding calibre...") debug.info(2,"Finding calibre...")
@ -205,16 +222,11 @@ def setup_paths():
# Don't delete the output dir, it may have other files! # Don't delete the output dir, it may have other files!
# make the directory if it doesn't exist # make the directory if it doesn't exist
try: try:
os.makedirs(OPTS.out_path, 0750) os.makedirs(OPTS.output_path, 0750)
except OSError as e: except OSError as e:
if e.errno == 17: # errno.EEXIST if e.errno == 17: # errno.EEXIST
os.chmod(OPTS.out_path, 0750) os.chmod(OPTS.output_path, 0750)
if OPTS.out_path=="":
OPTS.out_path="."
if not OPTS.out_path.endswith('/'):
OPTS.out_path += "/"
debug.info(1, "Output saved in " + OPTS.out_path)
def set_spice(): def set_spice():

View File

@ -53,13 +53,13 @@ word_size = OPTS.config.word_size
num_words = OPTS.config.num_words num_words = OPTS.config.num_words
num_banks = OPTS.config.num_banks num_banks = OPTS.config.num_banks
if (OPTS.out_name == ""): if (OPTS.output_name == ""):
OPTS.out_name = "sram_{0}_{1}_{2}_{3}".format(word_size, OPTS.output_name = "sram_{0}_{1}_{2}_{3}".format(word_size,
num_words, num_words,
num_banks, num_banks,
OPTS.tech_name) OPTS.tech_name)
debug.info(1, "Output file is " + OPTS.out_name + ".(sp|gds|v|lib|lef)") debug.info(1, "Output file is " + OPTS.output_name + ".(sp|gds|v|lib|lef)")
print "Technology: %s" % (OPTS.tech_name) print "Technology: %s" % (OPTS.tech_name)
print "Word size: {0}\nWords: {1}\nBanks: {2}".format(word_size,num_words,num_banks) print "Word size: {0}\nWords: {1}\nBanks: {2}".format(word_size,num_words,num_banks)
@ -74,7 +74,7 @@ print "Start: ", datetime.datetime.now()
s = sram.sram(word_size=word_size, s = sram.sram(word_size=word_size,
num_words=num_words, num_words=num_words,
num_banks=num_banks, num_banks=num_banks,
name=OPTS.out_name) name=OPTS.output_name)
# Measure design area # Measure design area
# Not working? # Not working?
@ -83,36 +83,36 @@ s = sram.sram(word_size=word_size,
# Output the files for the resulting SRAM # Output the files for the resulting SRAM
spname = OPTS.out_path + s.name + ".sp" 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) s.sp_write(spname)
gdsname = OPTS.out_path + s.name + ".gds" 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) s.gds_write(gdsname)
# Run Characterizer on the design # Run Characterizer on the design
sram_file = spname sram_file = spname
if OPTS.use_pex: if OPTS.use_pex:
sram_file = OPTS.out_path + "temp_pex.sp" sram_file = OPTS.output_path + "temp_pex.sp"
calibre.run_pex(s.name, gdsname, spname, output=sram_file) calibre.run_pex(s.name, gdsname, spname, output=sram_file)
# geenrate verilog # geenrate verilog
import verilog import verilog
vname = OPTS.out_path + s.name + ".v" 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) verilog.verilog(vname,s)
# generate LEF # generate LEF
import lef import lef
lefname = OPTS.out_path + s.name + ".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) lef.lef(gdsname,lefname,s)
# generate lib # generate lib
import lib import lib
libname = OPTS.out_path + s.name + ".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) lib.lib(libname,s,sram_file)

View File

@ -33,7 +33,7 @@ class options(optparse.Values):
# Trim noncritical memory cells for simulation speed-up # Trim noncritical memory cells for simulation speed-up
trim_noncritical = False trim_noncritical = False
# Define the output file paths # Define the output file paths
out_path = "" output_path = ""
# Define the output file base name # Define the output file base name
out_name = "" output_name = ""
analytical_delay = False analytical_delay = False

View File

@ -4,6 +4,10 @@ num_banks = 1
tech_name = "freepdk45" tech_name = "freepdk45"
# Optional, will be over-ridden on command line.
output_path = "/tmp/mysram"
output_name = "sram_2_16_1_freepdk45"
decoder = "hierarchical_decoder" decoder = "hierarchical_decoder"
ms_flop = "ms_flop" ms_flop = "ms_flop"
ms_flop_array = "ms_flop_array" ms_flop_array = "ms_flop_array"

View File

@ -4,6 +4,10 @@ num_banks = 1
tech_name = "scn3me_subm" tech_name = "scn3me_subm"
# Optional, will be over-ridden on command line.
output_path = "/tmp/mysram"
output_name = "sram_2_16_1_scn3me_subm"
decoder = "hierarchical_decoder" decoder = "hierarchical_decoder"
ms_flop = "ms_flop" ms_flop = "ms_flop"
ms_flop_array = "ms_flop_array" ms_flop_array = "ms_flop_array"