From af22e438f121853d878021a55ff3e810f522198e Mon Sep 17 00:00:00 2001 From: Hunter Nichols Date: Tue, 8 Sep 2020 18:40:39 -0700 Subject: [PATCH] Added option to output an extended configuration file that includes defaults. --- compiler/options.py | 2 ++ compiler/sram/sram.py | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/compiler/options.py b/compiler/options.py index d97ea300..8d8e3b42 100644 --- a/compiler/options.py +++ b/compiler/options.py @@ -93,6 +93,8 @@ class options(optparse.Values): trim_netlist = False # Run with extracted parasitics use_pex = False + # Output config with all options + output_extended_config = False ################### diff --git a/compiler/sram/sram.py b/compiler/sram/sram.py index 8cf926c6..6b5d117d 100644 --- a/compiler/sram/sram.py +++ b/compiler/sram/sram.py @@ -63,6 +63,18 @@ class sram(): def verilog_write(self, name): self.s.verilog_write(name) + def extended_config_write(self, name): + """Dump config file with all options. + Include defaults and anything changed by input config.""" + f = open(name, "w") + var_dict = dict((name, getattr(OPTS, name)) for name in dir(OPTS) if not name.startswith('__') and not callable(getattr(OPTS, name))) + for var_name, var_value in var_dict.items(): + if isinstance(var_value, str): + f.write(str(var_name) + " = " + "\"" + str(var_value) + "\"\n") + else: + f.write(str(var_name) + " = " + str(var_value)+ "\n") + f.close() + def save(self): """ Save all the output files while reporting time to do it as well. """ @@ -137,3 +149,11 @@ class sram(): debug.print_raw("Verilog: Writing to {0}".format(vname)) self.verilog_write(vname) print_time("Verilog", datetime.datetime.now(), start_time) + + # Write out options if specified + if OPTS.output_extended_config: + start_time = datetime.datetime.now() + oname = OPTS.output_path + OPTS.output_name + "_extended.py" + debug.print_raw("Extended Config: Writing to {0}".format(oname)) + self.extended_config_write(oname) + print_time("Extended Config", datetime.datetime.now(), start_time) \ No newline at end of file