Skip to content

Commit

Permalink
rand_soc synthesis
Browse files Browse the repository at this point in the history
  • Loading branch information
jgoeders committed Nov 29, 2023
1 parent 0b2070a commit b9756c9
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 9 deletions.
4 changes: 4 additions & 0 deletions bfasst/ninja_flows/rand_soc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from bfasst.ninja_flows.flow import FlowNoDesign
from bfasst.ninja_tools.design_create.rand_soc import RandSoCTool
from bfasst.ninja_tools.synth.vivado_synth_tcl import VivadoSynthFromTcl


class RandSoc(FlowNoDesign):
Expand All @@ -13,6 +14,9 @@ def __init__(self, num_designs=1):

self.rand_soc_tool = RandSoCTool(self, num_designs=num_designs)

for design in self.rand_soc_tool.outputs["design_tcl"]:
VivadoSynthFromTcl(self, design)

@classmethod
def flow_build_dir_name(cls) -> str:
"""Get the name of the build directory for this flow"""
Expand Down
17 changes: 9 additions & 8 deletions bfasst/ninja_tools/design_create/rand_soc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ def __init__(self, flow, num_designs):
self._my_dir_path = pathlib.Path(__file__).parent.resolve()
self.num_designs = num_designs

def create_rule_snippets(self):
self._append_rule_snippets_default(__file__)

def create_build_snippets(self):
self.outputs["design_tcl"] = []
for i in range(self.num_designs):
design_dir_path = self.build_path / f"design_{i}"
# design_dir_path.mkdir(parents=True, exist_ok=True)
self.outputs["design_tcl"].append(design_dir_path / "design.tcl")

# TODO: Outputs
# self._init_outputs(self.injection_log, self.corrupt_netlist)
def create_rule_snippets(self):
self._append_rule_snippets_default(__file__)

rand_soc_pkg_files = list((GMT_TOOLS_PATH / "rand_soc" / "rand_soc").glob("**/*.py"))
def create_build_snippets(self):
rand_soc_pkg_files = list((GMT_TOOLS_PATH / "rand_soc" / "rand_soc").glob("**/*.py"))
rand_soc_pkg_files.append(GMT_TOOLS_PATH / "rand_soc" / "main.py")

for i, design in enumerate(self.outputs["design_tcl"]):
design_dir_path = design.parent
with open(self._my_dir_path / "rand_soc_build.ninja.mustache", "r") as f:
build = chevron.render(
f,
Expand Down
39 changes: 39 additions & 0 deletions bfasst/ninja_tools/synth/vivado_synth_tcl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Tool to create Vivado synthesis ninja snippets."""
import pathlib
from bfasst import config
from bfasst.ninja_tools.tool import Tool
from bfasst.paths import COMMON_TOOLS_PATH, NINJA_UTILS_PATH


class VivadoSynthFromTcl(Tool):
"""Tool to create vivado synthesis ninja snippets."""

def __init__(self, flow, design_tcl_path):
super().__init__(flow, design_tcl_path.parent)
self.design_tcl_path = design_tcl_path
self._my_dir_path = pathlib.Path(__file__).parent
self.build_path = self.design_build_path / "synth"

def create_rule_snippets(self):
self._append_rule_snippets_default(
__file__,
{"vivado_path": config.VIVADO_BIN_PATH, "utils_path": NINJA_UTILS_PATH},
COMMON_TOOLS_PATH / "vivado_rules.ninja.mustache",
)

def create_build_snippets(self):
"""Create build snippets in ninja file"""

self._append_build_snippets_default(
__file__,
{
"synth_output": self.build_path,
"design_tcl": self.design_tcl_path,
"cwd": self.build_path,
},
)

def add_ninja_deps(self, deps):
"""Add dependencies to the master ninja file that would cause it to rebuild if modified"""
self._add_ninja_deps_default(deps, __file__)
deps.append(self._my_dir_path / "vivado_synth.tcl.mustache")
5 changes: 4 additions & 1 deletion bfasst/ninja_tools/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,7 @@ def __init__(self, flow, design_path) -> None:
else:
self.design_build_path = BUILD_PATH / "<external>" / design_path

self.design_props = DesignParser(design_path / "design.yaml")
design_yaml = design_path / "design.yaml"
self.design_props = None
if design_yaml.is_file():
self.design_props = DesignParser(design_yaml)

0 comments on commit b9756c9

Please sign in to comment.