f4pga/flows: style

Signed-off-by: Unai Martinez-Corral <umartinezcorral@antmicro.com>
This commit is contained in:
Unai Martinez-Corral 2022-08-18 05:48:11 +02:00
parent ebabd6a5a3
commit c6e0c3bcc6
2 changed files with 14 additions and 30 deletions

View File

@ -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

View File

@ -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):