From d6957b87c62f2bd684277ac5a9cd24eff164e7b8 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral Date: Thu, 22 Sep 2022 21:30:18 +0100 Subject: [PATCH 1/2] f4pga/flows: mv common_modules modules Signed-off-by: Unai Martinez-Corral --- f4pga/flows/commands.py | 3 - f4pga/flows/common.py | 30 ++----- f4pga/flows/common_modules/__init__.py | 0 .../{common_modules => modules}/analysis.py | 0 .../flows/{common_modules => modules}/fasm.py | 0 .../generic_script_wrapper.py | 0 .../{common_modules => modules}/io_rename.py | 0 .../{common_modules => modules}/mkdirs.py | 0 .../{common_modules => modules}/nextpnr.py | 0 .../nextpnr_ice40.py | 2 +- .../flows/{common_modules => modules}/pack.py | 0 .../{common_modules => modules}/place.py | 0 .../place_constraints.py | 0 .../{common_modules => modules}/route.py | 0 .../{common_modules => modules}/yosys.py | 0 f4pga/flows/platforms.yml | 88 +++++++++---------- 16 files changed, 50 insertions(+), 73 deletions(-) delete mode 100644 f4pga/flows/common_modules/__init__.py rename f4pga/flows/{common_modules => modules}/analysis.py (100%) rename f4pga/flows/{common_modules => modules}/fasm.py (100%) rename f4pga/flows/{common_modules => modules}/generic_script_wrapper.py (100%) rename f4pga/flows/{common_modules => modules}/io_rename.py (100%) rename f4pga/flows/{common_modules => modules}/mkdirs.py (100%) rename f4pga/flows/{common_modules => modules}/nextpnr.py (100%) rename f4pga/flows/{common_modules => modules}/nextpnr_ice40.py (97%) rename f4pga/flows/{common_modules => modules}/pack.py (100%) rename f4pga/flows/{common_modules => modules}/place.py (100%) rename f4pga/flows/{common_modules => modules}/place_constraints.py (100%) rename f4pga/flows/{common_modules => modules}/route.py (100%) rename f4pga/flows/{common_modules => modules}/yosys.py (100%) diff --git a/f4pga/flows/commands.py b/f4pga/flows/commands.py index 697f0ce..82784ef 100644 --- a/f4pga/flows/commands.py +++ b/f4pga/flows/commands.py @@ -33,7 +33,6 @@ from f4pga.flows.common import ( F4PGAException, ResolutionEnv, fatal, - scan_modules, set_verbosity_level, sfprint, sub as common_sub, @@ -195,8 +194,6 @@ def make_flow_config(project_flow_cfg: ProjectFlowConfig, part_name: str) -> Flo r_env = setup_resolution_env() r_env.add_values({"part_name": part_name.lower()}) - scan_modules(str(ROOT)) - with (ROOT / "platforms.yml").open("r") as rfptr: platforms = yaml_load(rfptr, yaml_loader) if platform not in platforms: diff --git a/f4pga/flows/common.py b/f4pga/flows/common.py index f2efe8f..4085562 100644 --- a/f4pga/flows/common.py +++ b/f4pga/flows/common.py @@ -64,34 +64,14 @@ def with_qualifier(name: str, q: str) -> str: return decompose_depname(name)[0] + "!" -_sfbuild_module_collection_name_to_path = {} - - -def scan_modules(mypath: str): - global _sfbuild_module_collection_name_to_path - sfbuild_home = mypath - _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): """ - Resolves module location from modulestr. + Resolves module location from modstr. """ - sl = modstr.split(":") - if len(sl) > 2: - raise Exception("Incorrect module sysntax. Expected one ':' or one '::'") - if len(sl) < 2: - return modstr - collection_name = sl[0] - module_filename = sl[1] + ".py" - - col_path = _sfbuild_module_collection_name_to_path.get(collection_name) - if not col_path: - fatal(-1, f"Module collection {collection_name} does not exist") - return str(Path(col_path) / module_filename) + modpath = Path(__file__).resolve().parent / f"modules/{modstr}.py" + if not modpath.exists(): + raise Exception(f"Unknown module <{modstr}>!") + return str(modpath) def deep(fun, allow_none=False): diff --git a/f4pga/flows/common_modules/__init__.py b/f4pga/flows/common_modules/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/f4pga/flows/common_modules/analysis.py b/f4pga/flows/modules/analysis.py similarity index 100% rename from f4pga/flows/common_modules/analysis.py rename to f4pga/flows/modules/analysis.py diff --git a/f4pga/flows/common_modules/fasm.py b/f4pga/flows/modules/fasm.py similarity index 100% rename from f4pga/flows/common_modules/fasm.py rename to f4pga/flows/modules/fasm.py diff --git a/f4pga/flows/common_modules/generic_script_wrapper.py b/f4pga/flows/modules/generic_script_wrapper.py similarity index 100% rename from f4pga/flows/common_modules/generic_script_wrapper.py rename to f4pga/flows/modules/generic_script_wrapper.py diff --git a/f4pga/flows/common_modules/io_rename.py b/f4pga/flows/modules/io_rename.py similarity index 100% rename from f4pga/flows/common_modules/io_rename.py rename to f4pga/flows/modules/io_rename.py diff --git a/f4pga/flows/common_modules/mkdirs.py b/f4pga/flows/modules/mkdirs.py similarity index 100% rename from f4pga/flows/common_modules/mkdirs.py rename to f4pga/flows/modules/mkdirs.py diff --git a/f4pga/flows/common_modules/nextpnr.py b/f4pga/flows/modules/nextpnr.py similarity index 100% rename from f4pga/flows/common_modules/nextpnr.py rename to f4pga/flows/modules/nextpnr.py diff --git a/f4pga/flows/common_modules/nextpnr_ice40.py b/f4pga/flows/modules/nextpnr_ice40.py similarity index 97% rename from f4pga/flows/common_modules/nextpnr_ice40.py rename to f4pga/flows/modules/nextpnr_ice40.py index e0396c7..03d97f5 100644 --- a/f4pga/flows/common_modules/nextpnr_ice40.py +++ b/f4pga/flows/modules/nextpnr_ice40.py @@ -20,7 +20,7 @@ import pathlib from f4pga.flows.common import ResolutionEnv from f4pga.flows.module import ModuleContext -from f4pga.flows.common_modules.nextpnr import NextPnrBaseModule +from f4pga.flows.modules.nextpnr import NextPnrBaseModule import re from pathlib import Path diff --git a/f4pga/flows/common_modules/pack.py b/f4pga/flows/modules/pack.py similarity index 100% rename from f4pga/flows/common_modules/pack.py rename to f4pga/flows/modules/pack.py diff --git a/f4pga/flows/common_modules/place.py b/f4pga/flows/modules/place.py similarity index 100% rename from f4pga/flows/common_modules/place.py rename to f4pga/flows/modules/place.py diff --git a/f4pga/flows/common_modules/place_constraints.py b/f4pga/flows/modules/place_constraints.py similarity index 100% rename from f4pga/flows/common_modules/place_constraints.py rename to f4pga/flows/modules/place_constraints.py diff --git a/f4pga/flows/common_modules/route.py b/f4pga/flows/modules/route.py similarity index 100% rename from f4pga/flows/common_modules/route.py rename to f4pga/flows/modules/route.py diff --git a/f4pga/flows/common_modules/yosys.py b/f4pga/flows/modules/yosys.py similarity index 100% rename from f4pga/flows/common_modules/yosys.py rename to f4pga/flows/modules/yosys.py diff --git a/f4pga/flows/platforms.yml b/f4pga/flows/platforms.yml index 9929bdc..bc65b72 100644 --- a/f4pga/flows/platforms.yml +++ b/f4pga/flows/platforms.yml @@ -55,11 +55,11 @@ xc7a50t: &xc7 stages: mk_build_dir: - module: 'common:mkdirs' + module: 'mkdirs' params: build_dir: 'build/${device}' synth: - module: 'common:yosys' + module: 'yosys' params: takes: - xdc? @@ -85,9 +85,9 @@ xc7a50t: &xc7 UTILS_PATH: '${shareDir}/scripts' INPUT_XDC_FILES: '${:xdc}' pack: - module: 'common:pack' + module: 'pack' ioplace: - module: 'common:generic_script_wrapper' + module: 'generic_script_wrapper' params: stage_name: ioplace interpreter: '${python3}' @@ -103,7 +103,7 @@ xc7a50t: &xc7 pcf: '${:pcf?}' $PYTHONPATH: '${binDir}/python/' place_constraints: - module: 'common:generic_script_wrapper' + module: 'generic_script_wrapper' params: stage_name: place_constraints interpreter: '${python3}' @@ -122,13 +122,13 @@ xc7a50t: &xc7 vpr_grid_map: '${shareDir}/arch/${device}/vpr_grid_map.csv' $PYTHONPATH: '${binDir}/python/' place: - module: 'common:place' + module: 'place' route: - module: 'common:route' + module: 'route' fasm: - module: 'common:fasm' + module: 'fasm' bitstream: - module: 'common:generic_script_wrapper' + module: 'generic_script_wrapper' params: stage_name: bitstream script: xcfasm @@ -189,11 +189,11 @@ ice40: stages: mk_build_dir: - module: 'common:mkdirs' + module: 'mkdirs' params: build_dir: build/${device} synth: - module: 'common:yosys' + module: 'yosys' params: takes: produces: @@ -202,12 +202,12 @@ ice40: yosys_tcl_env: OUT_JSON: '${:json}' pnr: - module: 'common:nextpnr_ice40' + module: 'nextpnr_ice40' values: placer: heap router: router1 bitstream: - module: 'common:generic_script_wrapper' + module: 'generic_script_wrapper' params: stage_name: bitstream script: icepack @@ -257,11 +257,11 @@ ql-eos-s3: stages: mk_build_dir: - module: 'common:mkdirs' + module: 'mkdirs' params: build_dir: 'build/${device}' synth: - module: 'common:yosys' + module: 'yosys' params: takes: - pcf? @@ -284,7 +284,7 @@ ql-eos-s3: PYTHON3: '${python3}' UTILS_PATH: '${shareDir}/scripts' prepare_sdc: - module: 'common:generic_script_wrapper' + module: 'generic_script_wrapper' params: stage_name: prepare_sdc interpreter: '${python3}' @@ -302,7 +302,7 @@ ql-eos-s3: pin-map: '' $PYTHONPATH: '${shareDir}/scripts/' pack: - module: 'common:pack' + module: 'pack' values: device: ql-eos-s3 device_alt: ql-eos-s3_wlcsp @@ -338,7 +338,7 @@ ql-eos-s3: suppress_warnings: >- ${noisyWarnings},sum_pin_class:check_unbuffered_edges:load_rr_indexed_data_T_values:check_rr_node:trans_per_R:check_route:set_rr_graph_tool_comment ioplace: - module: 'common:generic_script_wrapper' + module: 'generic_script_wrapper' params: stage_name: ioplace interpreter: '${python3}' @@ -354,7 +354,7 @@ ql-eos-s3: map: '${shareDir}/arch/ql-eos-s3_wlcsp/pinmap_${package}.csv' $PYTHONPATH: '${shareDir}/scripts/' place_constraints: - module: 'common:generic_script_wrapper' + module: 'generic_script_wrapper' params: stage_name: place_constraints interpreter: '${python3}' @@ -369,9 +369,9 @@ ql-eos-s3: i: '${:io_place}' $PYTHONPATH: '${shareDir}/scripts/' place: - module: 'common:place' + module: 'place' iomux_jlink: - module: 'common:generic_script_wrapper' + module: 'generic_script_wrapper' params: stage_name: iomux_jlink interpreter: '${python3}' @@ -387,7 +387,7 @@ ql-eos-s3: output-format: jlink $PYTHONPATH: '${shareDir}/scripts/' iomux_openocd: - module: 'common:generic_script_wrapper' + module: 'generic_script_wrapper' params: stage_name: iomux_openocd interpreter: '${python3}' @@ -403,7 +403,7 @@ ql-eos-s3: output-format: openocd $PYTHONPATH: '${shareDir}/scripts/' iomux_binary: - module: 'common:generic_script_wrapper' + module: 'generic_script_wrapper' params: stage_name: iomux_binary interpreter: '${python3}' @@ -419,7 +419,7 @@ ql-eos-s3: output-format: binary $PYTHONPATH: '${shareDir}/scripts/' route: - module: 'common:route' + module: 'route' values: device: ql-eos-s3 device_alt: ql-eos-s3_wlcsp @@ -455,7 +455,7 @@ ql-eos-s3: suppress_warnings: >- ${noisyWarnings},sum_pin_class:check_unbuffered_edges:load_rr_indexed_data_T_values:check_rr_node:trans_per_R:check_route:set_rr_graph_tool_comment analysis: - module: 'common:analysis' + module: 'analysis' values: device: ql-eos-s3 device_alt: ql-eos-s3_wlcsp @@ -495,9 +495,9 @@ ql-eos-s3: suppress_warnings: >- ${noisyWarnings},sum_pin_class:check_unbuffered_edges:load_rr_indexed_data_T_values:check_rr_node:trans_per_R:check_route:set_rr_graph_tool_comment fasm: - module: 'common:fasm' + module: 'fasm' bitstream: - module: 'common:generic_script_wrapper' + module: 'generic_script_wrapper' params: stage_name: bitstream script: qlfasm @@ -516,7 +516,7 @@ ql-eos-s3: values: build_dir: . bitstream_bitheader: - module: 'common:generic_script_wrapper' + module: 'generic_script_wrapper' params: stage_name: bitstream_bitheader script: symbiflow_write_bitheader @@ -533,7 +533,7 @@ ql-eos-s3: '#2': '${:bitstream}.h' '#3': '${:iomux_binary}' bitstream_jlink: - module: 'common:generic_script_wrapper' + module: 'generic_script_wrapper' params: stage_name: bitstream_jlink script: symbiflow_write_jlink @@ -550,7 +550,7 @@ ql-eos-s3: '#2': '${:bitstream}.jlink' '#3': '${:iomux_jlink}' bitstream_openocd: - module: 'common:generic_script_wrapper' + module: 'generic_script_wrapper' params: stage_name: bitstream_openocd script: symbiflow_write_openocd @@ -567,7 +567,7 @@ ql-eos-s3: '#2': '${:bitstream}.openocd' '#3': '${:iomux_openocd}' bitstream_binary: - module: 'common:generic_script_wrapper' + module: 'generic_script_wrapper' params: stage_name: bitstream_binary script: symbiflow_write_binary @@ -584,7 +584,7 @@ ql-eos-s3: '#2': '${:bitstream}.bin' '#3': '${:iomux_binary}' fasm2bels: - module: 'common:generic_script_wrapper' + module: 'generic_script_wrapper' params: stage_name: fasm2bels script: symbiflow_fasm2bels @@ -646,11 +646,11 @@ ql-k4n8_fast: &ql-k4n8 stages: &ql-k4n8-stages mk_build_dir: - module: 'common:mkdirs' + module: 'mkdirs' params: build_dir: 'build/${device}' synth: - module: 'common:yosys' + module: 'yosys' params: produces: - synth_v @@ -666,9 +666,9 @@ ql-k4n8_fast: &ql-k4n8 OUT_EBLIF: '${:eblif}' PYTHON3: '${python3}' pack: - module: 'common:pack' + module: 'pack' ioplace: - module: 'common:generic_script_wrapper' + module: 'generic_script_wrapper' params: stage_name: ioplace interpreter: '${python3}' @@ -687,7 +687,7 @@ ql-k4n8_fast: &ql-k4n8 ${shareDir}/arch/qlf_k4n8-qlf_k4n8_umc22_fast_qlf_k4n8-qlf_k4n8_umc22_fast/pinmap_qlf_k4n8_umc22.csv $PYTHONPATH: '${binDir}/python/' repack: &ql-k4n8-stages-repack - module: 'common:generic_script_wrapper' + module: 'generic_script_wrapper' params: stage_name: repack interpreter: '${python3}' @@ -725,25 +725,25 @@ ql-k4n8_fast: &ql-k4n8 repacking_rules: >- ${shareDir}/arch/qlf_k4n8-qlf_k4n8_umc22_fast_qlf_k4n8-qlf_k4n8_umc22_fast/qlf_k4n8-qlf_k4n8_umc22_fast.repacking_rules.json place: - module: 'common:place' + module: 'place' route: - module: 'common:io_rename' + module: 'io_rename' params: - module: 'common:route' + module: 'route' rename_takes: eblif: eblif_repacked place: place_repacked net: net_repacked fasm: - module: 'common:io_rename' + module: 'io_rename' params: - module: 'common:fasm' + module: 'fasm' rename_takes: eblif: eblif_repacked place: place_repacked net: net_repacked bitstream: - module: 'common:generic_script_wrapper' + module: 'generic_script_wrapper' params: stage_name: bitstream script: qlf_fasm @@ -780,7 +780,7 @@ ql-k4n8_slow: stages: <<: *ql-k4n8-stages ioplace: - module: 'common:generic_script_wrapper' + module: 'generic_script_wrapper' params: stage_name: ioplace interpreter: '${python3}' From bae00eb72b0c7fd4b5d36ad72feefdc842989c61 Mon Sep 17 00:00:00 2001 From: Unai Martinez-Corral <38422348+umarcor@users.noreply.github.com> Date: Wed, 28 Sep 2022 22:05:44 +0100 Subject: [PATCH 2/2] f4pga/flows/common: update docstring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Krzysztof BoroĊ„ski <94375110+kboronski-ant@users.noreply.github.com> --- f4pga/flows/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/f4pga/flows/common.py b/f4pga/flows/common.py index 4085562..031b034 100644 --- a/f4pga/flows/common.py +++ b/f4pga/flows/common.py @@ -66,7 +66,7 @@ def with_qualifier(name: str, q: str) -> str: def resolve_modstr(modstr: str): """ - Resolves module location from modstr. + Resolves module location given its name. """ modpath = Path(__file__).resolve().parent / f"modules/{modstr}.py" if not modpath.exists():