diff --git a/bfasst/ninja_flows/flow_utils.py b/bfasst/ninja_flows/flow_utils.py index 18580b655..d9644da15 100644 --- a/bfasst/ninja_flows/flow_utils.py +++ b/bfasst/ninja_flows/flow_utils.py @@ -4,8 +4,6 @@ from bfasst.paths import NINJA_BUILD_PATH -from bfasst.ninja_tools.vivado.synth.vivado_synth import VivadoSynth - def get_flows(): """Get all flows in the flows directory""" @@ -32,9 +30,3 @@ def create_build_file(): """Overwrite the build.ninja file when running generation and build steps separately""" with open(NINJA_BUILD_PATH, "w") as f: f.write("# This file is autogenerated by bfasst\n\n") - - -def configure_vivado_synth_tool(design, flow_args, ooc=False): - if isinstance(flow_args, dict) and "synth" in flow_args: - return VivadoSynth(design, flow_args["synth"], ooc) - return VivadoSynth(design, ooc=ooc) diff --git a/bfasst/ninja_flows/ninja_flow_manager.py b/bfasst/ninja_flows/ninja_flow_manager.py index 2d60bc4da..42387f506 100644 --- a/bfasst/ninja_flows/ninja_flow_manager.py +++ b/bfasst/ninja_flows/ninja_flow_manager.py @@ -31,6 +31,8 @@ def __init__(self): def create_flows(self, flow_name, designs, flow_args=None): """Create the ninja flows for the given designs.""" + if flow_args is None: + flow_args = {} self.flow_name = flow_name self.flows = [] self.designs = [] @@ -101,7 +103,7 @@ def get_design_basenames(designs): if parsed_args.flow_args: FLOW_ARGS_DICT = json.loads(parsed_args.flow_args.replace("'", '"')) else: - FLOW_ARGS_DICT = {} + FLOW_ARGS_DICT = None flow_manager = NinjaFlowManager() flow_manager.create_flows( diff --git a/bfasst/ninja_flows/vivado.py b/bfasst/ninja_flows/vivado.py index 205fc18a2..54787028b 100644 --- a/bfasst/ninja_flows/vivado.py +++ b/bfasst/ninja_flows/vivado.py @@ -3,6 +3,7 @@ from bfasst.ninja_tools.vivado.impl.vivado_impl import VivadoImpl from bfasst.paths import NINJA_FLOWS_PATH from bfasst.ninja_tools.vivado.synth.vivado_synth import VivadoSynth +from bfasst.utils.general import ensure class Vivado(Flow): @@ -11,7 +12,7 @@ class Vivado(Flow): def __init__(self, design, flow_args=None, ooc=False): super().__init__(design) self.ooc = ooc - self.vivado_synth_tool = VivadoSynth(design, flow_args.get("synth"), ooc=ooc) + self.vivado_synth_tool = VivadoSynth(design, ensure(flow_args, {}).get("synth"), ooc) self.vivado_impl_tool = VivadoImpl(design, ooc) def create_rule_snippets(self): diff --git a/bfasst/ninja_flows/vivado_bit_analysis.py b/bfasst/ninja_flows/vivado_bit_analysis.py index d03b2b79d..b7ef02ee0 100644 --- a/bfasst/ninja_flows/vivado_bit_analysis.py +++ b/bfasst/ninja_flows/vivado_bit_analysis.py @@ -8,6 +8,7 @@ from bfasst.ninja_tools.transform.netlist_cleanup import NetlistCleanupTool from bfasst.ninja_tools.transform.netlist_phys_to_logical import NetlistPhysToLogicalTool from bfasst.ninja_tools.vivado.synth.vivado_synth import VivadoSynth +from bfasst.utils.general import ensure class VivadoBitAnalysis(Flow): @@ -15,7 +16,7 @@ class VivadoBitAnalysis(Flow): def __init__(self, design, flow_args=None): super().__init__(design) - self.vivado_synth_tool = VivadoSynth(design, flow_args.get("synth")) + self.vivado_synth_tool = VivadoSynth(design, ensure(flow_args, {}).get("synth")) self.vivado_impl_tool = VivadoImpl(design) self.xrev_tool = XrevTool(design) self.netlist_cleanup_tool = NetlistCleanupTool(design) diff --git a/bfasst/ninja_flows/vivado_conformal.py b/bfasst/ninja_flows/vivado_conformal.py index fbbceae1f..f0e677454 100644 --- a/bfasst/ninja_flows/vivado_conformal.py +++ b/bfasst/ninja_flows/vivado_conformal.py @@ -7,6 +7,7 @@ from bfasst.paths import NINJA_FLOWS_PATH from bfasst.types import Vendor from bfasst.ninja_tools.vivado.synth.vivado_synth import VivadoSynth +from bfasst.utils.general import ensure class VivadoConformal(Flow): @@ -14,7 +15,7 @@ class VivadoConformal(Flow): def __init__(self, design, flow_args=None): super().__init__(design) - self.vivado_synth_tool = VivadoSynth(design, flow_args.get("synth")) + self.vivado_synth_tool = VivadoSynth(design, ensure(flow_args, {}).get("synth")) self.vivado_impl_tool = VivadoImpl(design) self.xrev_tool = Xray(design) self.conformal_tool = Conformal(design) diff --git a/bfasst/ninja_flows/vivado_phys_netlist.py b/bfasst/ninja_flows/vivado_phys_netlist.py index 8967e0487..b18aafaea 100644 --- a/bfasst/ninja_flows/vivado_phys_netlist.py +++ b/bfasst/ninja_flows/vivado_phys_netlist.py @@ -5,6 +5,7 @@ from bfasst.ninja_tools.transform.phys_netlist import PhysNetlist from bfasst.paths import NINJA_FLOWS_PATH from bfasst.ninja_tools.vivado.synth.vivado_synth import VivadoSynth +from bfasst.utils.general import ensure class VivadoPhysNetlist(Flow): @@ -12,7 +13,7 @@ class VivadoPhysNetlist(Flow): def __init__(self, design, flow_args=None): super().__init__(design) - self.vivado_synth_tool = VivadoSynth(design, flow_args.get("synth")) + self.vivado_synth_tool = VivadoSynth(design, ensure(flow_args, {}).get("synth")) self.vivado_impl_tool = VivadoImpl(design) self.phys_netlist_tool = PhysNetlist(design) diff --git a/bfasst/ninja_flows/vivado_phys_netlist_cmp.py b/bfasst/ninja_flows/vivado_phys_netlist_cmp.py index 9e56fe24d..b53bae9ba 100644 --- a/bfasst/ninja_flows/vivado_phys_netlist_cmp.py +++ b/bfasst/ninja_flows/vivado_phys_netlist_cmp.py @@ -7,6 +7,7 @@ from bfasst.ninja_tools.transform.phys_netlist import PhysNetlist from bfasst.paths import NINJA_FLOWS_PATH from bfasst.ninja_tools.vivado.synth.vivado_synth import VivadoSynth +from bfasst.utils.general import ensure class VivadoPhysNetlistCmp(Flow): @@ -14,7 +15,7 @@ class VivadoPhysNetlistCmp(Flow): def __init__(self, design, flow_args=None): super().__init__(design) - self.vivado_synth_tool = VivadoSynth(design, flow_args.get("synth")) + self.vivado_synth_tool = VivadoSynth(design, ensure(flow_args, {}).get("synth")) self.vivado_impl_tool = VivadoImpl(design) self.phys_netlist_tool = PhysNetlist(design) self.xray_tool = Xray(design) diff --git a/bfasst/ninja_flows/vivado_phys_netlist_xrev.py b/bfasst/ninja_flows/vivado_phys_netlist_xrev.py index e5a4e3ce7..fc3403268 100644 --- a/bfasst/ninja_flows/vivado_phys_netlist_xrev.py +++ b/bfasst/ninja_flows/vivado_phys_netlist_xrev.py @@ -7,6 +7,7 @@ from bfasst.ninja_tools.transform.phys_netlist import PhysNetlist from bfasst.paths import NINJA_FLOWS_PATH from bfasst.ninja_tools.vivado.synth.vivado_synth import VivadoSynth +from bfasst.utils.general import ensure class VivadoPhysNetlistXrev(Flow): @@ -14,7 +15,7 @@ class VivadoPhysNetlistXrev(Flow): def __init__(self, design, flow_args=None): super().__init__(design) - self.vivado_synth_tool = VivadoSynth(design, flow_args.get("synth")) + self.vivado_synth_tool = VivadoSynth(design, ensure(flow_args, {}).get("synth")) self.vivado_impl_tool = VivadoImpl(design) self.phys_netlist_tool = PhysNetlist(design) self.xrev_tool = Xray(design) diff --git a/bfasst/ninja_flows/vivado_structural_error_injection.py b/bfasst/ninja_flows/vivado_structural_error_injection.py index 52665f5a3..23f21ec89 100644 --- a/bfasst/ninja_flows/vivado_structural_error_injection.py +++ b/bfasst/ninja_flows/vivado_structural_error_injection.py @@ -10,6 +10,7 @@ from bfasst.ninja_tools.transform.phys_netlist import PhysNetlist from bfasst.paths import NINJA_FLOWS_PATH from bfasst.ninja_tools.vivado.synth.vivado_synth import VivadoSynth +from bfasst.utils.general import ensure from bfasst.ninja_utils.error_injector import ErrorType @@ -20,7 +21,7 @@ class VivadoStructuralErrorInjection(Flow): def __init__(self, design, flow_args=None): super().__init__(design) random.seed(0) - self.vivado_synth_tool = VivadoSynth(design, flow_args.get("synth")) + self.vivado_synth_tool = VivadoSynth(design, ensure(flow_args, {}).get("synth")) self.vivado_impl_tool = VivadoImpl(design) self.phys_netlist_tool = PhysNetlist(design) self.xrev_tool = Xray(design) diff --git a/bfasst/ninja_flows/vivado_yosys_impl.py b/bfasst/ninja_flows/vivado_yosys_impl.py index 7e4f87d23..0c15405d0 100644 --- a/bfasst/ninja_flows/vivado_yosys_impl.py +++ b/bfasst/ninja_flows/vivado_yosys_impl.py @@ -5,6 +5,7 @@ from bfasst.ninja_tools.rev_bit.xray import Xray from bfasst.paths import NINJA_FLOWS_PATH from bfasst.ninja_tools.vivado.synth.vivado_synth import VivadoSynth +from bfasst.utils.general import ensure class VivadoYosysImpl(Flow): @@ -12,7 +13,7 @@ class VivadoYosysImpl(Flow): def __init__(self, design, flow_args=None): super().__init__(design) - self.vivado_synth_tool = VivadoSynth(design, flow_args.get("synth")) + self.vivado_synth_tool = VivadoSynth(design, ensure(flow_args, {}).get("synth")) self.vivado_impl_tool = VivadoImpl(design) self.xrev_tool = Xray(design) self.yosys_tool = Yosys(design) diff --git a/bfasst/utils/general.py b/bfasst/utils/general.py index dd9ed1020..cbf4c4974 100644 --- a/bfasst/utils/general.py +++ b/bfasst/utils/general.py @@ -235,3 +235,10 @@ def ensure_tuple(x): if isinstance(x, list): return tuple(x) return (x,) + + +def ensure(x, y): + """Compensates for how python deals with default reference objects""" + if x is None: + return y + return x