Unify stage declarations with options

Signed-off-by: Krzysztof Boronski <kboronski@antmicro.com>
This commit is contained in:
Krzysztof Boronski 2022-08-08 12:47:34 -05:00 committed by Unai Martinez-Corral
parent bd89d50693
commit 2f303cbc0f
8 changed files with 177 additions and 103 deletions

View File

@ -82,13 +82,9 @@ class FlowDefinition:
self.r_env.add_values(global_vals) self.r_env.add_values(global_vals)
stages_d = flow_def['stages'] stages_d = flow_def['stages']
modopts_d = flow_def.get('stage_options')
if modopts_d is None:
modopts_d = {}
for stage_name, modstr in stages_d.items(): for stage_name, stage_def in stages_d.items():
opts = modopts_d.get(stage_name) self.stages[stage_name] = Stage(stage_name, stage_def)
self.stages[stage_name] = Stage(stage_name, modstr, opts)
def stage_names(self): def stage_names(self):
return self.stages.keys() return self.stages.keys()

View File

@ -1,26 +1,4 @@
{ {
"stages": {
"mk_build_dir": "common:mkdirs",
"synth": "common:synth",
"prepare_sdc": "common:generic_script_wrapper",
"pack": "common:pack",
"ioplace": "common:generic_script_wrapper",
"place_constraints": "common:generic_script_wrapper",
"iomux_jlink": "common:generic_script_wrapper",
"iomux_openocd": "common:generic_script_wrapper",
"iomux_binary": "common:generic_script_wrapper",
"place": "common:place",
"route": "common:route",
"analysis": "common:analysis",
"fasm": "common:fasm",
"bitstream": "common:generic_script_wrapper",
"bitstream_bitheader": "common:generic_script_wrapper",
"bitstream_binary": "common:generic_script_wrapper",
"bitstream_jlink": "common:generic_script_wrapper",
"bitstream_openocd": "common:generic_script_wrapper",
"fasm2bels": "common:generic_script_wrapper"
},
"values": { "values": {
"device": "ql-eos-s3", "device": "ql-eos-s3",
"device_alt": "ql-eos-s3_wlcsp", "device_alt": "ql-eos-s3_wlcsp",
@ -54,13 +32,16 @@
} }
}, },
"stage_options": { "stages": {
"mk_build_dir": { "mk_build_dir": {
"module": "common:mkdirs",
"params": { "params": {
"build_dir": "build/${device}" "build_dir": "build/${device}"
} }
}, },
"synth": { "synth": {
"module": "common:synth",
"params": { "params": {
"takes": [ "pcf?" ], "takes": [ "pcf?" ],
"produces": [ "produces": [
@ -85,7 +66,9 @@
} }
} }
}, },
"prepare_sdc": { "prepare_sdc": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "prepare_sdc", "stage_name": "prepare_sdc",
"interpreter": "${python3}", "interpreter": "${python3}",
@ -107,7 +90,9 @@
} }
} }
}, },
"pack": { "pack": {
"module": "common:pack",
"values": { "values": {
"device": "ql-eos-s3", "device": "ql-eos-s3",
"device_alt": "ql-eos-s3_wlcsp", "device_alt": "ql-eos-s3_wlcsp",
@ -142,7 +127,9 @@
} }
} }
}, },
"ioplace": { "ioplace": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "ioplace", "stage_name": "ioplace",
"interpreter": "${python3}", "interpreter": "${python3}",
@ -162,7 +149,9 @@
} }
} }
}, },
"place_constraints": { "place_constraints": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "place_constraints", "stage_name": "place_constraints",
"interpreter": "${python3}", "interpreter": "${python3}",
@ -181,7 +170,13 @@
} }
} }
}, },
"place": {
"module": "common:place"
},
"iomux_jlink": { "iomux_jlink": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "iomux_jlink", "stage_name": "iomux_jlink",
"interpreter": "${python3}", "interpreter": "${python3}",
@ -201,7 +196,9 @@
} }
} }
}, },
"iomux_openocd": { "iomux_openocd": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "iomux_openocd", "stage_name": "iomux_openocd",
"interpreter": "${python3}", "interpreter": "${python3}",
@ -221,7 +218,9 @@
} }
} }
}, },
"iomux_binary": { "iomux_binary": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "iomux_binary", "stage_name": "iomux_binary",
"interpreter": "${python3}", "interpreter": "${python3}",
@ -241,7 +240,9 @@
} }
} }
}, },
"route": { "route": {
"module": "common:route",
"values": { "values": {
"device": "ql-eos-s3", "device": "ql-eos-s3",
"device_alt": "ql-eos-s3_wlcsp", "device_alt": "ql-eos-s3_wlcsp",
@ -276,7 +277,9 @@
} }
} }
}, },
"analysis": { "analysis": {
"module": "common:analysis",
"values": { "values": {
"device": "ql-eos-s3", "device": "ql-eos-s3",
"device_alt": "ql-eos-s3_wlcsp", "device_alt": "ql-eos-s3_wlcsp",
@ -315,7 +318,13 @@
} }
} }
}, },
"fasm": {
"module": "common:fasm"
},
"bitstream": { "bitstream": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "bitstream", "stage_name": "bitstream",
"script": "qlfasm", "script": "qlfasm",
@ -340,7 +349,9 @@
"build_dir": "." "build_dir": "."
} }
}, },
"bitstream_bitheader": { "bitstream_bitheader": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "bitstream_bitheader", "stage_name": "bitstream_bitheader",
"script": "symbiflow_write_bitheader", "script": "symbiflow_write_bitheader",
@ -362,7 +373,9 @@
} }
} }
}, },
"bitstream_jlink": { "bitstream_jlink": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "bitstream_jlink", "stage_name": "bitstream_jlink",
"script": "symbiflow_write_jlink", "script": "symbiflow_write_jlink",
@ -384,7 +397,9 @@
} }
} }
}, },
"bitstream_openocd": { "bitstream_openocd": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "bitstream_openocd", "stage_name": "bitstream_openocd",
"script": "symbiflow_write_openocd", "script": "symbiflow_write_openocd",
@ -406,7 +421,9 @@
} }
} }
}, },
"bitstream_binary": { "bitstream_binary": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "bitstream_binary", "stage_name": "bitstream_binary",
"script": "symbiflow_write_binary", "script": "symbiflow_write_binary",
@ -428,7 +445,9 @@
} }
} }
}, },
"fasm2bels": { "fasm2bels": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "fasm2bels", "stage_name": "fasm2bels",
"script": "symbiflow_fasm2bels", "script": "symbiflow_fasm2bels",

View File

@ -1,16 +1,4 @@
{ {
"stages": {
"mk_build_dir": "common:mkdirs",
"synth": "common:synth",
"pack": "common:pack",
"ioplace": "common:generic_script_wrapper",
"place": "common:place",
"repack": "common:generic_script_wrapper",
"route": "common:io_rename",
"fasm": "common:io_rename",
"bitstream": "common:generic_script_wrapper"
},
"values": { "values": {
"device": "qlf_k4n8_umc22", "device": "qlf_k4n8_umc22",
"rr_graph_lookahead_bin": "${shareDir}/arch/qlf_k4n8-qlf_k4n8_umc22_fast_qlf_k4n8-qlf_k4n8_umc22_fast/rr_graph_qlf_k4n8-qlf_k4n8_umc22_fast_qlf_k4n8-qlf_k4n8_umc22_fast.lookahead.bin", "rr_graph_lookahead_bin": "${shareDir}/arch/qlf_k4n8-qlf_k4n8_umc22_fast_qlf_k4n8-qlf_k4n8_umc22_fast/rr_graph_qlf_k4n8-qlf_k4n8_umc22_fast_qlf_k4n8-qlf_k4n8_umc22_fast.lookahead.bin",
@ -33,13 +21,16 @@
} }
}, },
"stage_options": { "stages": {
"mk_build_dir": { "mk_build_dir": {
"module": "common:mkdirs",
"params": { "params": {
"build_dir": "build/${device}" "build_dir": "build/${device}"
} }
}, },
"synth": { "synth": {
"module": "common:synth",
"params": { "params": {
"produces": [ "synth_v" ] "produces": [ "synth_v" ]
}, },
@ -56,7 +47,13 @@
} }
} }
}, },
"pack": {
"module": "common:pack"
},
"ioplace": { "ioplace": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "ioplace", "stage_name": "ioplace",
"interpreter": "${python3}", "interpreter": "${python3}",
@ -77,10 +74,9 @@
} }
} }
}, },
"repack": { "repack": {
"values": { "module": "common:generic_script_wrapper",
"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"
},
"params": { "params": {
"stage_name": "repack", "stage_name": "repack",
"interpreter": "${python3}", "interpreter": "${python3}",
@ -120,9 +116,18 @@
"pcf-constraints": "${pcf?}", "pcf-constraints": "${pcf?}",
"$PYTHONPATH": "${binDir}/python/" "$PYTHONPATH": "${binDir}/python/"
} }
},
"values": {
"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"
},
"route": { "route": {
"module": "common:io_rename",
"params": { "params": {
"module": "common:route", "module": "common:route",
"rename_takes": { "rename_takes": {
@ -132,7 +137,9 @@
} }
} }
}, },
"fasm": { "fasm": {
"module": "common:io_rename",
"params": { "params": {
"module": "common:fasm", "module": "common:fasm",
"rename_takes": { "rename_takes": {
@ -142,7 +149,9 @@
} }
} }
}, },
"bitstream": { "bitstream": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "bitstream", "stage_name": "bitstream",
"script": "qlf_fasm", "script": "qlf_fasm",

View File

@ -1,16 +1,4 @@
{ {
"stages": {
"mk_build_dir": "common:mkdirs",
"synth": "common:synth",
"pack": "common:pack",
"ioplace": "common:generic_script_wrapper",
"place": "common:place",
"repack": "common:generic_script_wrapper",
"route": "common:io_rename",
"fasm": "common:io_rename",
"bitstream": "common:generic_script_wrapper"
},
"values": { "values": {
"device": "qlf_k4n8_umc22", "device": "qlf_k4n8_umc22",
"rr_graph_lookahead_bin": "${shareDir}/arch/qlf_k4n8-qlf_k4n8_umc22_slow_qlf_k4n8-qlf_k4n8_umc22_slow/rr_graph_qlf_k4n8-qlf_k4n8_umc22_slow_qlf_k4n8-qlf_k4n8_umc22_slow.lookahead.bin", "rr_graph_lookahead_bin": "${shareDir}/arch/qlf_k4n8-qlf_k4n8_umc22_slow_qlf_k4n8-qlf_k4n8_umc22_slow/rr_graph_qlf_k4n8-qlf_k4n8_umc22_slow_qlf_k4n8-qlf_k4n8_umc22_slow.lookahead.bin",
@ -33,13 +21,16 @@
} }
}, },
"stage_options": { "stages": {
"mk_build_dir": { "mk_build_dir": {
"module": "common:mkdirs",
"params": { "params": {
"build_dir": "build/${device}" "build_dir": "build/${device}"
} }
}, },
"synth": { "synth": {
"common": "synth",
"params": { "params": {
"produces": [ "synth_v" ] "produces": [ "synth_v" ]
}, },
@ -56,7 +47,13 @@
} }
} }
}, },
"pack": {
"module": "common:pack"
},
"ioplace": { "ioplace": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "ioplace", "stage_name": "ioplace",
"interpreter": "${python3}", "interpreter": "${python3}",
@ -77,10 +74,9 @@
} }
} }
}, },
"repack": { "repack": {
"values": { "module": "common:generic_script_wrapper",
"repacking_rules": "${shareDir}/arch/qlf_k4n8-qlf_k4n8_umc22_slow_qlf_k4n8-qlf_k4n8_umc22_slow/qlf_k4n8-qlf_k4n8_umc22_slow.repacking_rules.json"
},
"params": { "params": {
"stage_name": "repack", "stage_name": "repack",
"interpreter": "${python3}", "interpreter": "${python3}",
@ -120,9 +116,18 @@
"pcf-constraints": "${pcf?}", "pcf-constraints": "${pcf?}",
"$PYTHONPATH": "${binDir}/python/" "$PYTHONPATH": "${binDir}/python/"
} }
},
"values": {
"repacking_rules": "${shareDir}/arch/qlf_k4n8-qlf_k4n8_umc22_slow_qlf_k4n8-qlf_k4n8_umc22_slow/qlf_k4n8-qlf_k4n8_umc22_slow.repacking_rules.json"
} }
}, },
"place": {
"module": "common:place"
},
"route": { "route": {
"module": "common:io_rename",
"params": { "params": {
"module": "common:route", "module": "common:route",
"rename_takes": { "rename_takes": {
@ -132,7 +137,9 @@
} }
} }
}, },
"fasm": { "fasm": {
"module": "common:io_rename",
"params": { "params": {
"module": "common:fasm", "module": "common:fasm",
"rename_takes": { "rename_takes": {
@ -142,7 +149,9 @@
} }
} }
}, },
"bitstream": { "bitstream": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "bitstream", "stage_name": "bitstream",
"script": "qlf_fasm", "script": "qlf_fasm",

View File

@ -37,24 +37,15 @@
}, },
"stages": { "stages": {
"mk_build_dir": "common:mkdirs",
"synth": "common:synth",
"pack": "common:pack",
"ioplace": "common:generic_script_wrapper",
"place_constraints": "common:generic_script_wrapper",
"place": "common:place",
"route": "common:route",
"fasm": "common:fasm",
"bitstream": "common:generic_script_wrapper"
},
"stage_options": {
"mk_build_dir": { "mk_build_dir": {
"module": "common:mkdirs",
"params": { "params": {
"build_dir": "build/${device}" "build_dir": "build/${device}"
} }
}, },
"synth": { "synth": {
"module": "common:synth",
"params": { "params": {
"takes": [ "xdc?" ], "takes": [ "xdc?" ],
"produces": [ "produces": [
@ -84,7 +75,13 @@
} }
} }
}, },
"pack": {
"module": "common:pack"
},
"ioplace": { "ioplace": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "ioplace", "stage_name": "ioplace",
"interpreter": "${python3}", "interpreter": "${python3}",
@ -104,7 +101,9 @@
} }
} }
}, },
"place_constraints": { "place_constraints": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "place_constraints", "stage_name": "place_constraints",
"interpreter": "${python3}", "interpreter": "${python3}",
@ -127,7 +126,21 @@
} }
} }
}, },
"place": {
"module": "common:place"
},
"route": {
"module": "common:route"
},
"fasm": {
"module": "common:fasm"
},
"bitstream": { "bitstream": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "bitstream", "stage_name": "bitstream",
"script": "xcfasm", "script": "xcfasm",

View File

@ -37,24 +37,15 @@
}, },
"stages": { "stages": {
"mk_build_dir": "common:mkdirs",
"synth": "common:synth",
"pack": "common:pack",
"ioplace": "common:generic_script_wrapper",
"place_constraints": "common:generic_script_wrapper",
"place": "common:place",
"route": "common:route",
"fasm": "common:fasm",
"bitstream": "common:generic_script_wrapper"
},
"stage_options": {
"mk_build_dir": { "mk_build_dir": {
"module": "common:mkdirs",
"params": { "params": {
"build_dir": "build/${device}" "build_dir": "build/${device}"
} }
}, },
"synth": { "synth": {
"module": "common:synth",
"params": { "params": {
"takes": [ "xdc?" ], "takes": [ "xdc?" ],
"produces": [ "produces": [
@ -84,7 +75,13 @@
} }
} }
}, },
"pack": {
"module": "common:pack"
},
"ioplace": { "ioplace": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "ioplace", "stage_name": "ioplace",
"interpreter": "${python3}", "interpreter": "${python3}",
@ -104,7 +101,9 @@
} }
} }
}, },
"place_constraints": { "place_constraints": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "place_constraints", "stage_name": "place_constraints",
"interpreter": "${python3}", "interpreter": "${python3}",
@ -127,7 +126,21 @@
} }
} }
}, },
"place": {
"module": "common:place"
},
"route": {
"module": "common:route"
},
"fasm": {
"module": "common:fasm"
},
"bitstream": { "bitstream": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "bitstream", "stage_name": "bitstream",
"script": "xcfasm", "script": "xcfasm",

View File

@ -1,16 +1,4 @@
{ {
"stages": {
"mk_build_dir": "common:mkdirs",
"synth": "common:synth",
"pack": "common:pack",
"ioplace": "common:generic_script_wrapper",
"place_constraints": "common:generic_script_wrapper",
"place": "common:place",
"route": "common:route",
"fasm": "common:fasm",
"bitstream": "common:generic_script_wrapper"
},
"values": { "values": {
"device": "xc7a50t_test", "device": "xc7a50t_test",
"bitstream_device": "artix7", "bitstream_device": "artix7",
@ -48,13 +36,16 @@
} }
}, },
"stage_options": { "stages": {
"mk_build_dir": { "mk_build_dir": {
"module": "common:mkdirs",
"params": { "params": {
"build_dir": "build/${device}" "build_dir": "build/${device}"
} }
}, },
"synth": { "synth": {
"module": "common:synth",
"params": { "params": {
"takes": [ "xdc?" ], "takes": [ "xdc?" ],
"produces": [ "produces": [
@ -84,7 +75,13 @@
} }
} }
}, },
"pack": {
"module": "common:pack"
},
"ioplace": { "ioplace": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "ioplace", "stage_name": "ioplace",
"interpreter": "${python3}", "interpreter": "${python3}",
@ -104,7 +101,9 @@
} }
} }
}, },
"place_constraints": { "place_constraints": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "place_constraints", "stage_name": "place_constraints",
"interpreter": "${python3}", "interpreter": "${python3}",
@ -127,7 +126,21 @@
} }
} }
}, },
"place": {
"module": "common:place"
},
"route": {
"module": "common:route"
},
"fasm": {
"module": "common:fasm"
},
"bitstream": { "bitstream": {
"module": "common:generic_script_wrapper",
"params": { "params": {
"stage_name": "bitstream", "stage_name": "bitstream",
"script": "xcfasm", "script": "xcfasm",

View File

@ -60,15 +60,17 @@ class Stage:
meta: 'dict[str, str]' # Stage's metadata extracted from module's meta: 'dict[str, str]' # Stage's metadata extracted from module's
# output. # output.
def __init__(self, name: str, modstr: str, mod_opts: 'dict[str, ] | None'): def __init__(self, name: str, stage_def: 'dict[str, ]'):
if mod_opts is None: if stage_def is None:
mod_opts = {} stage_def = {}
modstr = stage_def['module']
module_path = resolve_modstr(modstr) module_path = resolve_modstr(modstr)
ModuleClass = get_module(module_path) ModuleClass = get_module(module_path)
self.module = ModuleClass(mod_opts.get('params')) self.module = ModuleClass(stage_def.get('params'))
values = mod_opts.get('values') values = stage_def.get('values')
if values is not None: if values is not None:
self.value_overrides = values self.value_overrides = values
else: else: