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"
output_path = "/tmp/mysram"
output_name = "sram_2_16_1_freepdk45"
decoder = "hierarchical_decoder"
ms_flop = "ms_flop"
ms_flop_array = "ms_flop_array"

View File

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

View File

@ -14,12 +14,17 @@ import importlib
# Current version of OpenRAM.
VERSION = "1.0"
USAGE = "usage: openram.py [options] <config file>\n"
USAGE = "Usage: openram.py [options] <config file>\nUse -h for help.\n"
# Anonymous object that will be the 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):
return os.path.exists(fpath) and os.access(fpath, os.X_OK)
@ -34,11 +39,11 @@ def parse_args():
option_list = {
optparse.make_option("-b", "--backannotated", action="store_true", dest="run_pex",
help="back annotated simulation for characterizer"),
optparse.make_option("-o", "--output", dest="out_name",
help="Base output file name.", metavar="FILE"),
optparse.make_option("-p", "--outpath", dest="out_path",
help="output file location."),
help="Back annotate simulation"),
optparse.make_option("-o", "--output", dest="output_name",
help="Base output file name(s) prefix", metavar="FILE"),
optparse.make_option("-p", "--outpath", dest="output_path",
help="Output file(s) location"),
optparse.make_option("-n", "--nocheck", action="store_false",
help="Disable inline LVS/DRC checks", dest="check_lvsdrc"),
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...")
setup_paths()
read_config(config_file)
read_config(config_file)
import_tech()
set_spice()
@ -125,6 +130,18 @@ def read_config(config_file):
except:
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():
debug.info(2,"Finding calibre...")
@ -205,16 +222,11 @@ def setup_paths():
# Don't delete the output dir, it may have other files!
# make the directory if it doesn't exist
try:
os.makedirs(OPTS.out_path, 0750)
os.makedirs(OPTS.output_path, 0750)
except OSError as e:
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():

View File

@ -53,13 +53,13 @@ word_size = OPTS.config.word_size
num_words = OPTS.config.num_words
num_banks = OPTS.config.num_banks
if (OPTS.out_name == ""):
OPTS.out_name = "sram_{0}_{1}_{2}_{3}".format(word_size,
if (OPTS.output_name == ""):
OPTS.output_name = "sram_{0}_{1}_{2}_{3}".format(word_size,
num_words,
num_banks,
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 "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,
num_words=num_words,
num_banks=num_banks,
name=OPTS.out_name)
name=OPTS.output_name)
# Measure design area
# Not working?
@ -83,36 +83,36 @@ s = sram.sram(word_size=word_size,
# 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)
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)
s.gds_write(gdsname)
# Run Characterizer on the design
sram_file = spname
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)
# geenrate verilog
import verilog
vname = OPTS.out_path + s.name + ".v"
vname = OPTS.output_path + s.name + ".v"
print "Verilog: Writing to {0}".format(vname)
verilog.verilog(vname,s)
# generate LEF
import lef
lefname = OPTS.out_path + s.name + ".lef"
lefname = OPTS.output_path + s.name + ".lef"
print "LEF: Writing to {0}".format(lefname)
lef.lef(gdsname,lefname,s)
# generate lib
import lib
libname = OPTS.out_path + s.name + ".lib"
libname = OPTS.output_path + s.name + ".lib"
print "LIB: Writing to {0}".format(libname)
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 = False
# Define the output file paths
out_path = ""
output_path = ""
# Define the output file base name
out_name = ""
output_name = ""
analytical_delay = False

View File

@ -4,6 +4,10 @@ num_banks = 1
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"
ms_flop = "ms_flop"
ms_flop_array = "ms_flop_array"

View File

@ -4,6 +4,10 @@ num_banks = 1
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"
ms_flop = "ms_flop"
ms_flop_array = "ms_flop_array"