f4pga/flows: mv common_modules modules

Signed-off-by: Unai Martinez-Corral <umartinezcorral@antmicro.com>
This commit is contained in:
Unai Martinez-Corral 2022-09-22 21:30:18 +01:00
parent ebf85baba5
commit d6957b87c6
16 changed files with 50 additions and 73 deletions

View File

@ -33,7 +33,6 @@ from f4pga.flows.common import (
F4PGAException, F4PGAException,
ResolutionEnv, ResolutionEnv,
fatal, fatal,
scan_modules,
set_verbosity_level, set_verbosity_level,
sfprint, sfprint,
sub as common_sub, 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 = setup_resolution_env()
r_env.add_values({"part_name": part_name.lower()}) r_env.add_values({"part_name": part_name.lower()})
scan_modules(str(ROOT))
with (ROOT / "platforms.yml").open("r") as rfptr: with (ROOT / "platforms.yml").open("r") as rfptr:
platforms = yaml_load(rfptr, yaml_loader) platforms = yaml_load(rfptr, yaml_loader)
if platform not in platforms: if platform not in platforms:

View File

@ -64,34 +64,14 @@ def with_qualifier(name: str, q: str) -> str:
return decompose_depname(name)[0] + "!" 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): def resolve_modstr(modstr: str):
""" """
Resolves module location from modulestr. Resolves module location from modstr.
""" """
sl = modstr.split(":") modpath = Path(__file__).resolve().parent / f"modules/{modstr}.py"
if len(sl) > 2: if not modpath.exists():
raise Exception("Incorrect module sysntax. Expected one ':' or one '::'") raise Exception(f"Unknown module <{modstr}>!")
if len(sl) < 2: return str(modpath)
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)
def deep(fun, allow_none=False): def deep(fun, allow_none=False):

View File

@ -20,7 +20,7 @@
import pathlib import pathlib
from f4pga.flows.common import ResolutionEnv from f4pga.flows.common import ResolutionEnv
from f4pga.flows.module import ModuleContext from f4pga.flows.module import ModuleContext
from f4pga.flows.common_modules.nextpnr import NextPnrBaseModule from f4pga.flows.modules.nextpnr import NextPnrBaseModule
import re import re
from pathlib import Path from pathlib import Path

View File

@ -55,11 +55,11 @@ xc7a50t: &xc7
stages: stages:
mk_build_dir: mk_build_dir:
module: 'common:mkdirs' module: 'mkdirs'
params: params:
build_dir: 'build/${device}' build_dir: 'build/${device}'
synth: synth:
module: 'common:yosys' module: 'yosys'
params: params:
takes: takes:
- xdc? - xdc?
@ -85,9 +85,9 @@ xc7a50t: &xc7
UTILS_PATH: '${shareDir}/scripts' UTILS_PATH: '${shareDir}/scripts'
INPUT_XDC_FILES: '${:xdc}' INPUT_XDC_FILES: '${:xdc}'
pack: pack:
module: 'common:pack' module: 'pack'
ioplace: ioplace:
module: 'common:generic_script_wrapper' module: 'generic_script_wrapper'
params: params:
stage_name: ioplace stage_name: ioplace
interpreter: '${python3}' interpreter: '${python3}'
@ -103,7 +103,7 @@ xc7a50t: &xc7
pcf: '${:pcf?}' pcf: '${:pcf?}'
$PYTHONPATH: '${binDir}/python/' $PYTHONPATH: '${binDir}/python/'
place_constraints: place_constraints:
module: 'common:generic_script_wrapper' module: 'generic_script_wrapper'
params: params:
stage_name: place_constraints stage_name: place_constraints
interpreter: '${python3}' interpreter: '${python3}'
@ -122,13 +122,13 @@ xc7a50t: &xc7
vpr_grid_map: '${shareDir}/arch/${device}/vpr_grid_map.csv' vpr_grid_map: '${shareDir}/arch/${device}/vpr_grid_map.csv'
$PYTHONPATH: '${binDir}/python/' $PYTHONPATH: '${binDir}/python/'
place: place:
module: 'common:place' module: 'place'
route: route:
module: 'common:route' module: 'route'
fasm: fasm:
module: 'common:fasm' module: 'fasm'
bitstream: bitstream:
module: 'common:generic_script_wrapper' module: 'generic_script_wrapper'
params: params:
stage_name: bitstream stage_name: bitstream
script: xcfasm script: xcfasm
@ -189,11 +189,11 @@ ice40:
stages: stages:
mk_build_dir: mk_build_dir:
module: 'common:mkdirs' module: 'mkdirs'
params: params:
build_dir: build/${device} build_dir: build/${device}
synth: synth:
module: 'common:yosys' module: 'yosys'
params: params:
takes: takes:
produces: produces:
@ -202,12 +202,12 @@ ice40:
yosys_tcl_env: yosys_tcl_env:
OUT_JSON: '${:json}' OUT_JSON: '${:json}'
pnr: pnr:
module: 'common:nextpnr_ice40' module: 'nextpnr_ice40'
values: values:
placer: heap placer: heap
router: router1 router: router1
bitstream: bitstream:
module: 'common:generic_script_wrapper' module: 'generic_script_wrapper'
params: params:
stage_name: bitstream stage_name: bitstream
script: icepack script: icepack
@ -257,11 +257,11 @@ ql-eos-s3:
stages: stages:
mk_build_dir: mk_build_dir:
module: 'common:mkdirs' module: 'mkdirs'
params: params:
build_dir: 'build/${device}' build_dir: 'build/${device}'
synth: synth:
module: 'common:yosys' module: 'yosys'
params: params:
takes: takes:
- pcf? - pcf?
@ -284,7 +284,7 @@ ql-eos-s3:
PYTHON3: '${python3}' PYTHON3: '${python3}'
UTILS_PATH: '${shareDir}/scripts' UTILS_PATH: '${shareDir}/scripts'
prepare_sdc: prepare_sdc:
module: 'common:generic_script_wrapper' module: 'generic_script_wrapper'
params: params:
stage_name: prepare_sdc stage_name: prepare_sdc
interpreter: '${python3}' interpreter: '${python3}'
@ -302,7 +302,7 @@ ql-eos-s3:
pin-map: '' pin-map: ''
$PYTHONPATH: '${shareDir}/scripts/' $PYTHONPATH: '${shareDir}/scripts/'
pack: pack:
module: 'common:pack' module: 'pack'
values: values:
device: ql-eos-s3 device: ql-eos-s3
device_alt: ql-eos-s3_wlcsp device_alt: ql-eos-s3_wlcsp
@ -338,7 +338,7 @@ ql-eos-s3:
suppress_warnings: >- 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 ${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: ioplace:
module: 'common:generic_script_wrapper' module: 'generic_script_wrapper'
params: params:
stage_name: ioplace stage_name: ioplace
interpreter: '${python3}' interpreter: '${python3}'
@ -354,7 +354,7 @@ ql-eos-s3:
map: '${shareDir}/arch/ql-eos-s3_wlcsp/pinmap_${package}.csv' map: '${shareDir}/arch/ql-eos-s3_wlcsp/pinmap_${package}.csv'
$PYTHONPATH: '${shareDir}/scripts/' $PYTHONPATH: '${shareDir}/scripts/'
place_constraints: place_constraints:
module: 'common:generic_script_wrapper' module: 'generic_script_wrapper'
params: params:
stage_name: place_constraints stage_name: place_constraints
interpreter: '${python3}' interpreter: '${python3}'
@ -369,9 +369,9 @@ ql-eos-s3:
i: '${:io_place}' i: '${:io_place}'
$PYTHONPATH: '${shareDir}/scripts/' $PYTHONPATH: '${shareDir}/scripts/'
place: place:
module: 'common:place' module: 'place'
iomux_jlink: iomux_jlink:
module: 'common:generic_script_wrapper' module: 'generic_script_wrapper'
params: params:
stage_name: iomux_jlink stage_name: iomux_jlink
interpreter: '${python3}' interpreter: '${python3}'
@ -387,7 +387,7 @@ ql-eos-s3:
output-format: jlink output-format: jlink
$PYTHONPATH: '${shareDir}/scripts/' $PYTHONPATH: '${shareDir}/scripts/'
iomux_openocd: iomux_openocd:
module: 'common:generic_script_wrapper' module: 'generic_script_wrapper'
params: params:
stage_name: iomux_openocd stage_name: iomux_openocd
interpreter: '${python3}' interpreter: '${python3}'
@ -403,7 +403,7 @@ ql-eos-s3:
output-format: openocd output-format: openocd
$PYTHONPATH: '${shareDir}/scripts/' $PYTHONPATH: '${shareDir}/scripts/'
iomux_binary: iomux_binary:
module: 'common:generic_script_wrapper' module: 'generic_script_wrapper'
params: params:
stage_name: iomux_binary stage_name: iomux_binary
interpreter: '${python3}' interpreter: '${python3}'
@ -419,7 +419,7 @@ ql-eos-s3:
output-format: binary output-format: binary
$PYTHONPATH: '${shareDir}/scripts/' $PYTHONPATH: '${shareDir}/scripts/'
route: route:
module: 'common:route' module: 'route'
values: values:
device: ql-eos-s3 device: ql-eos-s3
device_alt: ql-eos-s3_wlcsp device_alt: ql-eos-s3_wlcsp
@ -455,7 +455,7 @@ ql-eos-s3:
suppress_warnings: >- 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 ${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: analysis:
module: 'common:analysis' module: 'analysis'
values: values:
device: ql-eos-s3 device: ql-eos-s3
device_alt: ql-eos-s3_wlcsp device_alt: ql-eos-s3_wlcsp
@ -495,9 +495,9 @@ ql-eos-s3:
suppress_warnings: >- 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 ${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: fasm:
module: 'common:fasm' module: 'fasm'
bitstream: bitstream:
module: 'common:generic_script_wrapper' module: 'generic_script_wrapper'
params: params:
stage_name: bitstream stage_name: bitstream
script: qlfasm script: qlfasm
@ -516,7 +516,7 @@ ql-eos-s3:
values: values:
build_dir: . build_dir: .
bitstream_bitheader: bitstream_bitheader:
module: 'common:generic_script_wrapper' module: 'generic_script_wrapper'
params: params:
stage_name: bitstream_bitheader stage_name: bitstream_bitheader
script: symbiflow_write_bitheader script: symbiflow_write_bitheader
@ -533,7 +533,7 @@ ql-eos-s3:
'#2': '${:bitstream}.h' '#2': '${:bitstream}.h'
'#3': '${:iomux_binary}' '#3': '${:iomux_binary}'
bitstream_jlink: bitstream_jlink:
module: 'common:generic_script_wrapper' module: 'generic_script_wrapper'
params: params:
stage_name: bitstream_jlink stage_name: bitstream_jlink
script: symbiflow_write_jlink script: symbiflow_write_jlink
@ -550,7 +550,7 @@ ql-eos-s3:
'#2': '${:bitstream}.jlink' '#2': '${:bitstream}.jlink'
'#3': '${:iomux_jlink}' '#3': '${:iomux_jlink}'
bitstream_openocd: bitstream_openocd:
module: 'common:generic_script_wrapper' module: 'generic_script_wrapper'
params: params:
stage_name: bitstream_openocd stage_name: bitstream_openocd
script: symbiflow_write_openocd script: symbiflow_write_openocd
@ -567,7 +567,7 @@ ql-eos-s3:
'#2': '${:bitstream}.openocd' '#2': '${:bitstream}.openocd'
'#3': '${:iomux_openocd}' '#3': '${:iomux_openocd}'
bitstream_binary: bitstream_binary:
module: 'common:generic_script_wrapper' module: 'generic_script_wrapper'
params: params:
stage_name: bitstream_binary stage_name: bitstream_binary
script: symbiflow_write_binary script: symbiflow_write_binary
@ -584,7 +584,7 @@ ql-eos-s3:
'#2': '${:bitstream}.bin' '#2': '${:bitstream}.bin'
'#3': '${:iomux_binary}' '#3': '${:iomux_binary}'
fasm2bels: fasm2bels:
module: 'common:generic_script_wrapper' module: 'generic_script_wrapper'
params: params:
stage_name: fasm2bels stage_name: fasm2bels
script: symbiflow_fasm2bels script: symbiflow_fasm2bels
@ -646,11 +646,11 @@ ql-k4n8_fast: &ql-k4n8
stages: &ql-k4n8-stages stages: &ql-k4n8-stages
mk_build_dir: mk_build_dir:
module: 'common:mkdirs' module: 'mkdirs'
params: params:
build_dir: 'build/${device}' build_dir: 'build/${device}'
synth: synth:
module: 'common:yosys' module: 'yosys'
params: params:
produces: produces:
- synth_v - synth_v
@ -666,9 +666,9 @@ ql-k4n8_fast: &ql-k4n8
OUT_EBLIF: '${:eblif}' OUT_EBLIF: '${:eblif}'
PYTHON3: '${python3}' PYTHON3: '${python3}'
pack: pack:
module: 'common:pack' module: 'pack'
ioplace: ioplace:
module: 'common:generic_script_wrapper' module: 'generic_script_wrapper'
params: params:
stage_name: ioplace stage_name: ioplace
interpreter: '${python3}' 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 ${shareDir}/arch/qlf_k4n8-qlf_k4n8_umc22_fast_qlf_k4n8-qlf_k4n8_umc22_fast/pinmap_qlf_k4n8_umc22.csv
$PYTHONPATH: '${binDir}/python/' $PYTHONPATH: '${binDir}/python/'
repack: &ql-k4n8-stages-repack repack: &ql-k4n8-stages-repack
module: 'common:generic_script_wrapper' module: 'generic_script_wrapper'
params: params:
stage_name: repack stage_name: repack
interpreter: '${python3}' interpreter: '${python3}'
@ -725,25 +725,25 @@ ql-k4n8_fast: &ql-k4n8
repacking_rules: >- 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 ${shareDir}/arch/qlf_k4n8-qlf_k4n8_umc22_fast_qlf_k4n8-qlf_k4n8_umc22_fast/qlf_k4n8-qlf_k4n8_umc22_fast.repacking_rules.json
place: place:
module: 'common:place' module: 'place'
route: route:
module: 'common:io_rename' module: 'io_rename'
params: params:
module: 'common:route' module: 'route'
rename_takes: rename_takes:
eblif: eblif_repacked eblif: eblif_repacked
place: place_repacked place: place_repacked
net: net_repacked net: net_repacked
fasm: fasm:
module: 'common:io_rename' module: 'io_rename'
params: params:
module: 'common:fasm' module: 'fasm'
rename_takes: rename_takes:
eblif: eblif_repacked eblif: eblif_repacked
place: place_repacked place: place_repacked
net: net_repacked net: net_repacked
bitstream: bitstream:
module: 'common:generic_script_wrapper' module: 'generic_script_wrapper'
params: params:
stage_name: bitstream stage_name: bitstream
script: qlf_fasm script: qlf_fasm
@ -780,7 +780,7 @@ ql-k4n8_slow:
stages: stages:
<<: *ql-k4n8-stages <<: *ql-k4n8-stages
ioplace: ioplace:
module: 'common:generic_script_wrapper' module: 'generic_script_wrapper'
params: params:
stage_name: ioplace stage_name: ioplace
interpreter: '${python3}' interpreter: '${python3}'