diff --git a/f4pga/flows/common.py b/f4pga/flows/common.py index 00e42d9..d0d3f8a 100644 --- a/f4pga/flows/common.py +++ b/f4pga/flows/common.py @@ -62,18 +62,11 @@ _sfbuild_module_collection_name_to_path = {} def scan_modules(mypath: str): global _sfbuild_module_collection_name_to_path - sfbuild_home = mypath - sfbuild_home_dirs = os_listdir(sfbuild_home) - sfbuild_module_dirs = \ - [dir for dir in sfbuild_home_dirs if re_match('.*_modules$', dir)] - _sfbuild_module_collection_name_to_path = dict([ - ( - re_match('(.*)_modules$', moddir).groups()[0], - str(Path(sfbuild_home) / moddir) - ) - for moddir in sfbuild_module_dirs - ]) + _sfbuild_module_collection_name_to_path = { + re_match('(.*)_modules$', moddir).groups()[0]: str(Path(sfbuild_home) / moddir) + for moddir in [dir for dir in os_listdir(sfbuild_home) if re_match('.*_modules$', dir)] + } def resolve_modstr(modstr: str): @@ -215,7 +208,7 @@ def options_dict_to_list(opt_dict: dict): opts = [] for key, val in opt_dict.items(): - opts.append('--' + key) + opts.append(f'--{key}') if not(type(val) is list and val == []): opts.append(str(val)) return opts diff --git a/f4pga/flows/common_modules/synth.py b/f4pga/flows/common_modules/synth.py index c4f35b3..e014ab4 100755 --- a/f4pga/flows/common_modules/synth.py +++ b/f4pga/flows/common_modules/synth.py @@ -29,27 +29,15 @@ def yosys_setup_tcl_env(tcl_env_def): """ Setup environmental variables for YOSYS TCL scripts. """ - env = {} - for key, value in tcl_env_def.items(): - if value is None: - continue - v = value - if type(value) is list: - v = ' '.join(value) - env[key] = v - return env + return { + key: (' '.join(val) if type(val) is list else val) + for key, val in tcl_env_def.items() + if val is not None + } def yosys_synth(tcl, tcl_env, verilog_files=[], read_verilog_args=None, log=None): - # Set up environment for TCL weirdness - optional = [] - if log: - optional += ['-l', log] - env = environ.copy() - env.update(tcl_env) - tcl = f'tcl {tcl}' - # Use append read_verilog commands to the scripts for more sophisticated # input if arguments are specified. Omit direct input throught `yosys` command. if read_verilog_args: @@ -58,8 +46,11 @@ def yosys_synth(tcl, tcl_env, verilog_files=[], read_verilog_args=None, log=None tcl = f'read_verilog {args_str} {verilog}; {tcl}' verilog_files = [] + # Set up environment for TCL weirdness + env = environ.copy() + env.update(tcl_env) # Execute YOSYS command - return common_sub(*(['yosys', '-p', tcl] + optional + verilog_files), env=env) + return common_sub(*(['yosys', '-p', tcl] + (['-l', log] if log else []) + verilog_files), env=env) def yosys_conv(tcl, tcl_env, synth_json):