Skip to content

Commit

Permalink
Merge pull request #335 from byuccl/separate_vivado_tools
Browse files Browse the repository at this point in the history
separate vivado tools
  • Loading branch information
jgoeders authored Nov 8, 2023
2 parents 169c8f7 + 89e55df commit 6ee3269
Show file tree
Hide file tree
Showing 26 changed files with 394 additions and 238 deletions.
8 changes: 4 additions & 4 deletions bfasst/ninja_flows/flow.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Base class for all ninja flows"""
import abc

from bfasst.ninja_tools.vivado.vivado import Vivado
from bfasst.ninja_tools.vivado.synth.vivado_synth import VivadoSynth
from bfasst.paths import BUILD_DIR, DESIGNS_PATH


Expand Down Expand Up @@ -29,7 +29,7 @@ def add_ninja_deps(self):
def get_top_level_flow_path(self) -> str:
"""Get the path to the top level flow file for this flow"""

def configure_vivado_tool(self, design, flow_args, ooc=False):
def configure_vivado_synth_tool(self, design, flow_args, ooc=False):
if isinstance(flow_args, dict) and "synth" in flow_args:
return Vivado(design, flow_args["synth"], ooc)
return Vivado(design, ooc=ooc)
return VivadoSynth(design, flow_args["synth"], ooc)
return VivadoSynth(design, ooc=ooc)
13 changes: 9 additions & 4 deletions bfasst/ninja_flows/vivado.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Flow to create Vivado synthesis and implementation ninja snippets."""
from bfasst.ninja_flows.flow import Flow
from bfasst.ninja_tools.vivado.impl.vivado_impl import VivadoImpl
from bfasst.paths import NINJA_FLOWS_PATH


Expand All @@ -9,16 +10,20 @@ class Vivado(Flow):
def __init__(self, design, flow_args=None, ooc=False):
super().__init__(design)
self.ooc = ooc
self.vivado_tool = self.configure_vivado_tool(design, flow_args, ooc)
self.vivado_synth_tool = self.configure_vivado_synth_tool(design, flow_args, ooc)
self.vivado_impl_tool = VivadoImpl(design, ooc)

def create_rule_snippets(self):
self.vivado_tool.create_rule_snippets()
self.vivado_synth_tool.create_rule_snippets()
self.vivado_impl_tool.create_rule_snippets()

def create_build_snippets(self):
self.vivado_tool.create_build_snippets()
self.vivado_synth_tool.create_build_snippets()
self.vivado_impl_tool.create_build_snippets()

def add_ninja_deps(self, deps):
self.vivado_tool.add_ninja_deps(deps)
self.vivado_synth_tool.add_ninja_deps(deps)
self.vivado_impl_tool.add_ninja_deps(deps)
deps.append(NINJA_FLOWS_PATH / "vivado.py")
if self.ooc:
deps.append(NINJA_FLOWS_PATH / "vivado_ooc.py")
Expand Down
15 changes: 10 additions & 5 deletions bfasst/ninja_flows/vivado_bit_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pathlib

from bfasst.ninja_flows.flow import Flow
from bfasst.ninja_tools.vivado.impl.vivado_impl import VivadoImpl
from bfasst.ninja_tools.rev_bit.xray import Xray as XrevTool
from bfasst.ninja_tools.transform.netlist_cleanup import NetlistCleanupTool
from bfasst.ninja_tools.transform.netlist_phys_to_logical import NetlistPhysToLogicalTool
Expand All @@ -13,20 +14,23 @@ class VivadoBitAnalysis(Flow):

def __init__(self, design, flow_args=None):
super().__init__(design)
self.vivado_tool = self.configure_vivado_tool(design, flow_args)
self.vivado_synth_tool = self.configure_vivado_synth_tool(design, flow_args)
self.vivado_impl_tool = VivadoImpl(design)
self.xrev_tool = XrevTool(design)
self.netlist_cleanup_tool = NetlistCleanupTool(design)
self.netlist_phys_to_logical = NetlistPhysToLogicalTool(design)

def create_rule_snippets(self):
self.vivado_tool.create_rule_snippets()
self.vivado_synth_tool.create_rule_snippets()
self.vivado_impl_tool.create_rule_snippets()
self.xrev_tool.create_rule_snippets()
self.netlist_cleanup_tool.create_rule_snippets()
self.netlist_phys_to_logical.create_rule_snippets()

def create_build_snippets(self):
self.vivado_tool.create_build_snippets()
self.xrev_tool.create_build_snippets(str(self.vivado_tool.outputs["bitstream"]))
self.vivado_synth_tool.create_build_snippets()
self.vivado_impl_tool.create_build_snippets()
self.xrev_tool.create_build_snippets(str(self.vivado_impl_tool.outputs["bitstream"]))
self.netlist_cleanup_tool.create_build_snippets(
netlist_in_path=self.xrev_tool.outputs["xray_netlist"],
)
Expand All @@ -35,7 +39,8 @@ def create_build_snippets(self):
)

def add_ninja_deps(self, deps):
self.vivado_tool.add_ninja_deps(deps)
self.vivado_synth_tool.add_ninja_deps(deps)
self.vivado_impl_tool.add_ninja_deps(deps)
self.xrev_tool.add_ninja_deps(deps)
self.netlist_cleanup_tool.add_ninja_deps(deps)
self.netlist_phys_to_logical.add_ninja_deps(deps)
Expand Down
17 changes: 11 additions & 6 deletions bfasst/ninja_flows/vivado_conformal.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Run vivado, phys_netlist, reverse with xray, then compare with conformal."""

from bfasst.ninja_flows.flow import Flow
from bfasst.ninja_tools.vivado.impl.vivado_impl import VivadoImpl
from bfasst.ninja_tools.compare.conformal.conformal import Conformal
from bfasst.ninja_tools.rev_bit.xray import Xray
from bfasst.paths import NINJA_FLOWS_PATH
Expand All @@ -12,26 +13,30 @@ class VivadoConformal(Flow):

def __init__(self, design, flow_args=None):
super().__init__(design)
self.vivado_tool = self.configure_vivado_tool(design, flow_args)
self.vivado_synth_tool = self.configure_vivado_synth_tool(design, flow_args)
self.vivado_impl_tool = VivadoImpl(design)
self.xrev_tool = Xray(design)
self.conformal_tool = Conformal(design)

def create_rule_snippets(self):
self.vivado_tool.create_rule_snippets()
self.vivado_synth_tool.create_rule_snippets()
self.vivado_impl_tool.create_rule_snippets()
self.xrev_tool.create_rule_snippets()
self.conformal_tool.create_rule_snippets()

def create_build_snippets(self):
self.vivado_tool.create_build_snippets()
self.xrev_tool.create_build_snippets(str(self.vivado_tool.outputs["bitstream"]))
self.vivado_synth_tool.create_build_snippets()
self.vivado_impl_tool.create_build_snippets()
self.xrev_tool.create_build_snippets(str(self.vivado_impl_tool.outputs["bitstream"]))
self.conformal_tool.create_build_snippets(
impl_netlist=str(self.vivado_tool.outputs["impl_verilog"]),
impl_netlist=str(self.vivado_impl_tool.outputs["impl_verilog"]),
rev_netlist=str(self.xrev_tool.outputs["xray_netlist"]),
vendor=Vendor.XILINX,
)

def add_ninja_deps(self, deps):
self.vivado_tool.add_ninja_deps(deps)
self.vivado_synth_tool.add_ninja_deps(deps)
self.vivado_impl_tool.add_ninja_deps(deps)
self.xrev_tool.add_ninja_deps(deps)
self.conformal_tool.add_ninja_deps(deps)
deps.append(NINJA_FLOWS_PATH / "vivado_conformal.py")
Expand Down
19 changes: 13 additions & 6 deletions bfasst/ninja_flows/vivado_phys_netlist.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Creates a Vivado netlist that has only physical primitives."""

from bfasst.ninja_flows.flow import Flow
from bfasst.ninja_tools.vivado.impl.vivado_impl import VivadoImpl
from bfasst.ninja_tools.transform.phys_netlist import PhysNetlist
from bfasst.paths import NINJA_FLOWS_PATH

Expand All @@ -10,22 +11,28 @@ class VivadoPhysNetlist(Flow):

def __init__(self, design, flow_args=None):
super().__init__(design)
self.vivado_tool = self.configure_vivado_tool(design, flow_args)
self.vivado_synth_tool = self.configure_vivado_synth_tool(design, flow_args)
self.vivado_impl_tool = VivadoImpl(design)
self.phys_netlist_tool = PhysNetlist(design)

def create_rule_snippets(self):
self.vivado_tool.create_rule_snippets()
self.vivado_synth_tool.create_rule_snippets()
self.vivado_impl_tool.create_rule_snippets()
self.phys_netlist_tool.create_rule_snippets()

def create_build_snippets(self):
self.vivado_tool.create_build_snippets()
# pylint: disable=duplicate-code
self.vivado_synth_tool.create_build_snippets()
self.vivado_impl_tool.create_build_snippets()
self.phys_netlist_tool.create_build_snippets(
impl_dcp=self.vivado_tool.outputs["impl_checkpoint"],
impl_edf=self.vivado_tool.outputs["impl_edf"],
impl_dcp=self.vivado_impl_tool.outputs["impl_checkpoint"],
impl_edf=self.vivado_impl_tool.outputs["impl_edf"],
)
# pylint: enable=duplicate-code

def add_ninja_deps(self, deps):
self.vivado_tool.add_ninja_deps(deps)
self.vivado_synth_tool.add_ninja_deps(deps)
self.vivado_impl_tool.add_ninja_deps(deps)
self.phys_netlist_tool.add_ninja_deps(deps)
deps.append(NINJA_FLOWS_PATH / "vivado_phys_netlist.py")

Expand Down
21 changes: 14 additions & 7 deletions bfasst/ninja_flows/vivado_phys_netlist_cmp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Structural Comparison of physical netlist and reversed netlist"""

from bfasst.ninja_flows.flow import Flow
from bfasst.ninja_tools.vivado.impl.vivado_impl import VivadoImpl
from bfasst.ninja_tools.compare.structural.structural import Structural
from bfasst.ninja_tools.rev_bit.xray import Xray
from bfasst.ninja_tools.transform.phys_netlist import PhysNetlist
Expand All @@ -12,32 +13,38 @@ class VivadoPhysNetlistCmp(Flow):

def __init__(self, design, flow_args=None):
super().__init__(design)
self.vivado_tool = self.configure_vivado_tool(design, flow_args)
self.vivado_synth_tool = self.configure_vivado_synth_tool(design, flow_args)
self.vivado_impl_tool = VivadoImpl(design)
self.phys_netlist_tool = PhysNetlist(design)
self.xray_tool = Xray(design)
self.compare_tool = Structural(design)

def create_rule_snippets(self):
self.vivado_tool.create_rule_snippets()
self.vivado_synth_tool.create_rule_snippets()
self.vivado_impl_tool.create_rule_snippets()
self.phys_netlist_tool.create_rule_snippets()
self.xray_tool.create_rule_snippets()
self.compare_tool.create_rule_snippets()

def create_build_snippets(self):
self.vivado_tool.create_build_snippets()
# pylint: disable=duplicate-code
self.vivado_synth_tool.create_build_snippets()
self.vivado_impl_tool.create_build_snippets()
self.phys_netlist_tool.create_build_snippets(
impl_dcp=self.vivado_tool.outputs["impl_checkpoint"],
impl_edf=self.vivado_tool.outputs["impl_edf"],
impl_dcp=self.vivado_impl_tool.outputs["impl_checkpoint"],
impl_edf=self.vivado_impl_tool.outputs["impl_edf"],
)
self.xray_tool.create_build_snippets(str(self.vivado_tool.outputs["bitstream"]))
self.xray_tool.create_build_snippets(str(self.vivado_impl_tool.outputs["bitstream"]))
self.compare_tool.create_build_snippets(
netlist_a=self.xray_tool.outputs["xray_netlist"],
netlist_b=self.phys_netlist_tool.outputs["viv_impl_physical_v"],
log_name="struct_cmp.log",
)
# pylint: enable=duplicate-code

def add_ninja_deps(self, deps):
self.vivado_tool.add_ninja_deps(deps)
self.vivado_synth_tool.add_ninja_deps(deps)
self.vivado_impl_tool.add_ninja_deps(deps)
self.phys_netlist_tool.add_ninja_deps(deps)
self.xray_tool.add_ninja_deps(deps)
self.compare_tool.add_ninja_deps(deps)
Expand Down
19 changes: 12 additions & 7 deletions bfasst/ninja_flows/vivado_phys_netlist_xrev.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


from bfasst.ninja_flows.flow import Flow
from bfasst.ninja_tools.vivado.impl.vivado_impl import VivadoImpl
from bfasst.ninja_tools.rev_bit.xray import Xray
from bfasst.ninja_tools.transform.phys_netlist import PhysNetlist
from bfasst.paths import NINJA_FLOWS_PATH
Expand All @@ -12,27 +13,31 @@ class VivadoPhysNetlistXrev(Flow):

def __init__(self, design, flow_args=None):
super().__init__(design)
self.vivado_tool = self.configure_vivado_tool(design, flow_args)
self.vivado_synth_tool = self.configure_vivado_synth_tool(design, flow_args)
self.vivado_impl_tool = VivadoImpl(design)
self.phys_netlist_tool = PhysNetlist(design)
self.xrev_tool = Xray(design)

def create_rule_snippets(self):
"""Create the rule snippets for the flow and append them to build.ninja."""
self.vivado_tool.create_rule_snippets()
self.vivado_synth_tool.create_rule_snippets()
self.vivado_impl_tool.create_rule_snippets()
self.phys_netlist_tool.create_rule_snippets()
self.xrev_tool.create_rule_snippets()

def create_build_snippets(self):
"""Create the build snippets for the flow and append them to build.ninja."""
self.vivado_tool.create_build_snippets()
self.vivado_synth_tool.create_build_snippets()
self.vivado_impl_tool.create_build_snippets()
self.phys_netlist_tool.create_build_snippets(
impl_dcp=self.vivado_tool.outputs["impl_checkpoint"],
impl_edf=self.vivado_tool.outputs["impl_edf"],
impl_dcp=self.vivado_impl_tool.outputs["impl_checkpoint"],
impl_edf=self.vivado_impl_tool.outputs["impl_edf"],
)
self.xrev_tool.create_build_snippets(self.vivado_tool.outputs["bitstream"])
self.xrev_tool.create_build_snippets(self.vivado_impl_tool.outputs["bitstream"])

def add_ninja_deps(self, deps):
self.vivado_tool.add_ninja_deps(deps)
self.vivado_synth_tool.add_ninja_deps(deps)
self.vivado_impl_tool.add_ninja_deps(deps)
self.phys_netlist_tool.add_ninja_deps(deps)
self.xrev_tool.add_ninja_deps(deps)
deps.append(NINJA_FLOWS_PATH / "vivado_phys_netlist_xrev.py")
Expand Down
19 changes: 12 additions & 7 deletions bfasst/ninja_flows/vivado_structural_error_injection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import random

from bfasst.ninja_flows.flow import Flow
from bfasst.ninja_tools.vivado.impl.vivado_impl import VivadoImpl
from bfasst.ninja_tools.compare.structural.structural import Structural
from bfasst.ninja_tools.rev_bit.xray import Xray
from bfasst.ninja_tools.transform.error_injector import ErrorInjector
Expand All @@ -18,7 +19,8 @@ class VivadoStructuralErrorInjection(Flow):
def __init__(self, design, flow_args=None):
super().__init__(design)
random.seed(0)
self.vivado_tool = self.configure_vivado_tool(design, flow_args)
self.vivado_synth_tool = self.configure_vivado_synth_tool(design, flow_args)
self.vivado_impl_tool = VivadoImpl(design)
self.phys_netlist_tool = PhysNetlist(design)
self.xrev_tool = Xray(design)
self.error_injector_tool = ErrorInjector(design)
Expand All @@ -28,19 +30,21 @@ def __init__(self, design, flow_args=None):

def create_rule_snippets(self):
"""Create the rule snippets for the flow and append them to build.ninja."""
self.vivado_tool.create_rule_snippets()
self.vivado_synth_tool.create_rule_snippets()
self.vivado_impl_tool.create_rule_snippets()
self.phys_netlist_tool.create_rule_snippets()
self.xrev_tool.create_rule_snippets()
self.error_injector_tool.create_rule_snippets()
self.compare_tool.create_rule_snippets()

def create_build_snippets(self):
self.vivado_tool.create_build_snippets()
self.vivado_synth_tool.create_build_snippets()
self.vivado_impl_tool.create_build_snippets()
self.phys_netlist_tool.create_build_snippets(
impl_dcp=self.vivado_tool.outputs["impl_checkpoint"],
impl_edf=self.vivado_tool.outputs["impl_edf"],
impl_dcp=self.vivado_impl_tool.outputs["impl_checkpoint"],
impl_edf=self.vivado_impl_tool.outputs["impl_edf"],
)
self.xrev_tool.create_build_snippets(self.vivado_tool.outputs["bitstream"])
self.xrev_tool.create_build_snippets(self.vivado_impl_tool.outputs["bitstream"])

random_seed_multiplier = 1
error_type = [ErrorType.BIT_FLIP, ErrorType.WIRE_SWAP]
Expand All @@ -62,7 +66,8 @@ def create_build_snippets(self):
)

def add_ninja_deps(self, deps):
self.vivado_tool.add_ninja_deps(deps)
self.vivado_synth_tool.add_ninja_deps(deps)
self.vivado_impl_tool.add_ninja_deps(deps)
self.phys_netlist_tool.add_ninja_deps(deps)
self.xrev_tool.add_ninja_deps(deps)
self.error_injector_tool.add_ninja_deps(deps)
Expand Down
17 changes: 11 additions & 6 deletions bfasst/ninja_flows/vivado_yosys_impl.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Flow to compare reversed netlist to original using yosys."""
from bfasst.ninja_flows.flow import Flow
from bfasst.ninja_tools.vivado.impl.vivado_impl import VivadoImpl
from bfasst.ninja_tools.compare.yosys.yosys import Yosys
from bfasst.ninja_tools.rev_bit.xray import Xray
from bfasst.paths import NINJA_FLOWS_PATH
Expand All @@ -10,25 +11,29 @@ class VivadoYosysImpl(Flow):

def __init__(self, design, flow_args=None):
super().__init__(design)
self.vivado_tool = self.configure_vivado_tool(design, flow_args)
self.vivado_synth_tool = self.configure_vivado_synth_tool(design, flow_args)
self.vivado_impl_tool = VivadoImpl(design)
self.xrev_tool = Xray(design)
self.yosys_tool = Yosys(design)

def create_rule_snippets(self):
self.vivado_tool.create_rule_snippets()
self.vivado_synth_tool.create_rule_snippets()
self.vivado_impl_tool.create_rule_snippets()
self.xrev_tool.create_rule_snippets()
self.yosys_tool.create_rule_snippets()

def create_build_snippets(self):
self.vivado_tool.create_build_snippets()
self.xrev_tool.create_build_snippets(str(self.vivado_tool.outputs["bitstream"]))
self.vivado_synth_tool.create_build_snippets()
self.vivado_impl_tool.create_build_snippets()
self.xrev_tool.create_build_snippets(str(self.vivado_impl_tool.outputs["bitstream"]))
self.yosys_tool.create_build_snippets(
gold_netlist=self.vivado_tool.outputs["impl_verilog"],
gold_netlist=self.vivado_impl_tool.outputs["impl_verilog"],
rev_netlist=self.xrev_tool.outputs["xray_netlist"],
)

def add_ninja_deps(self, deps):
self.vivado_tool.add_ninja_deps(deps)
self.vivado_synth_tool.add_ninja_deps(deps)
self.vivado_impl_tool.add_ninja_deps(deps)
self.xrev_tool.add_ninja_deps(deps)
self.yosys_tool.add_ninja_deps(deps)
deps.append(NINJA_FLOWS_PATH / "vivado_yosys_impl.py")
Expand Down
Loading

0 comments on commit 6ee3269

Please sign in to comment.