Skip to content

Commit

Permalink
Out of tree build
Browse files Browse the repository at this point in the history
  • Loading branch information
jgoeders committed Sep 26, 2024
1 parent 8f7bbef commit b47d571
Show file tree
Hide file tree
Showing 28 changed files with 46 additions and 41 deletions.
2 changes: 1 addition & 1 deletion bfasst/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
STRUCTURAL_TOOLS_PATH = COMPARE_TOOLS_PATH / "structural"
YOSYS_TOOLS_PATH = COMPARE_TOOLS_PATH / "yosys"

NINJA_BUILD_PATH = ROOT_PATH / "build.ninja"
NINJA_BUILD_PATH = pathlib.Path().cwd() / "build.ninja"

IC2_RESOURCES = RESOURCES_PATH / "iCEcube2"
LSE_PRJ_TEMPLATE = IC2_RESOURCES / "template_lse_prj.mustache"
Expand Down
2 changes: 1 addition & 1 deletion bfasst/tools/common/vivado_rules.ninja.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ rule vivado

{{#in_context}}
rule vivado_ioparse
command = python bfasst/utils/vivado_ioparse.py <$in >$out
command = python {{ bfasst_path }}/bfasst/utils/vivado_ioparse.py <$in >$out
description = vivado_ioparse <$in >$out

{{/in_context}}
4 changes: 3 additions & 1 deletion bfasst/tools/compare/structural/structural.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def __init__(
self.debug = debug
self.logging_level = logging_level
self._init_outputs()
self.rule_snippet_path = COMPARE_TOOLS_PATH / "structural" / "structural_rules.ninja"
self.rule_snippet_path = (
COMPARE_TOOLS_PATH / "structural" / "structural_rules.ninja.mustache"
)

def create_build_snippets(self):
self._append_build_snippets_default(
Expand Down
4 changes: 0 additions & 4 deletions bfasst/tools/compare/structural/structural_rules.ninja

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
rule compare
command = python {{ bfasst_path }}/bfasst/utils/structural.py --netlists $in --log_path $out $expect_fail $debug $logging_level
description = structurally compare $in

2 changes: 1 addition & 1 deletion bfasst/tools/compare/wafove/wafove.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(

self.build_path = self.design_build_path / "wafove"
self._init_outputs(self.std_out_log_name, self.std_err_log_name)
self.rule_snippet_path = COMPARE_TOOLS_PATH / "wafove" / "wafove_rules.ninja"
self.rule_snippet_path = COMPARE_TOOLS_PATH / "wafove" / "wafove_rules.ninja.mustache"

def create_build_snippets(self):
self._append_build_snippets_default(
Expand Down
4 changes: 0 additions & 4 deletions bfasst/tools/compare/wafove/wafove_rules.ninja

This file was deleted.

4 changes: 4 additions & 0 deletions bfasst/tools/compare/wafove/wafove_rules.ninja.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
rule wafove
command = python {{ bfasst_path }}/third_party/WaFoVe/wafove/compare_waveforms.py --top $top --base $base_path --fullScreen --newTests $in >$log_path 2>$std_err_log
description = run wafove on the netlists specified as inputs to the rule

2 changes: 1 addition & 1 deletion bfasst/tools/compare/yosys/yosys_rules.ninja.mustache
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rule yosys
command = cd third_party/yosys; ./yosys $in >$out 2>>$out
command = cd {{ bfasst_path }}/third_party/yosys; ./yosys $in >$out 2>>$out
description = running yosys compare with $in

2 changes: 1 addition & 1 deletion bfasst/tools/design_create/rand_soc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, flow, num_designs, config_path):
self.num_designs = num_designs
self.config_path = config_path
self._init_outputs()
self.rule_snippet_path = TOOLS_PATH / "design_create" / "rand_soc_rules.ninja"
self.rule_snippet_path = TOOLS_PATH / "design_create" / "rand_soc_rules.ninja.mustache"

def create_build_snippets(self):
rand_soc_pkg_files = list((GMT_TOOLS_PATH / "rand_soc" / "rand_soc").glob("**/*.py"))
Expand Down
4 changes: 0 additions & 4 deletions bfasst/tools/design_create/rand_soc_rules.ninja

This file was deleted.

4 changes: 4 additions & 0 deletions bfasst/tools/design_create/rand_soc_rules.ninja.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
rule rand_soc
command = python {{ bfasst_path }}/third_party/gmt_tools/rand_soc/main.py $design_dir_path $config_path --seed $seed --part $part
description = generate a random SoC in $design_dir_path

2 changes: 1 addition & 1 deletion bfasst/tools/rev_bit/icestorm.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, flow, design_path, constraints_file, bitstream):

# outputs must be initialized AFTER output paths are set
self._init_outputs()
self.rule_snippet_path = REV_BIT_TOOLS_PATH / "icestorm_rules.ninja"
self.rule_snippet_path = REV_BIT_TOOLS_PATH / "icestorm_rules.ninja.mustache"

def create_build_snippets(self):
self._append_build_snippets_default(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ rule icestorm_ascii_to_netlist
description = convert icestorm $asciifile to verilog equivalent circuit

rule icestorm_netlist_rpt
command = python bfasst/utils/icestorm_rpt.py --netlist $in --report $out
command = python {{ bfasst_path }}/bfasst/utils/icestorm_rpt.py --netlist $in --report $out
description = count luts, carries, ffs, etc for $in and write to $out

5 changes: 3 additions & 2 deletions bfasst/tools/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import chevron
from bfasst.flows.flow import FlowBase

from bfasst.paths import BUILD_PATH, DESIGNS_PATH, NINJA_BUILD_PATH
from bfasst.paths import BUILD_PATH, DESIGNS_PATH, NINJA_BUILD_PATH, ROOT_PATH
from bfasst.yaml_parser import DesignParser


Expand All @@ -25,12 +25,13 @@ def __init__(self, flow):
def create_rule_snippets(self):
"""Create the rule snippets for the flow and append them to build.ninja"""
rules_path = self.rule_snippet_path if hasattr(self, "rule_snippet_path") else None
rules_render_dict = self.rules_render_dict if hasattr(self, "rules_render_dict") else None
rules_render_dict = self.rules_render_dict if hasattr(self, "rules_render_dict") else {}
if rules_path in self.flow.rule_paths:
return

self.flow.rule_paths.append(rules_path)

rules_render_dict["bfasst_path"] = ROOT_PATH
with open(rules_path, "r") as f:
if rules_render_dict:
rules = chevron.render(f, rules_render_dict)
Expand Down
2 changes: 1 addition & 1 deletion bfasst/tools/transform/error_injector.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(
self.injection_log = None
self.corrupt_netlist = None
self._init_outputs(self.injection_log, self.corrupt_netlist)
self.rule_snippet_path = NINJA_TRANSFORM_TOOLS_PATH / "error_injector_rules.ninja"
self.rule_snippet_path = NINJA_TRANSFORM_TOOLS_PATH / "error_injector_rules.ninja.mustache"

def create_build_snippets(self):
with open(NINJA_TRANSFORM_TOOLS_PATH / "error_injector_build.ninja.mustache", "r") as f:
Expand Down
4 changes: 0 additions & 4 deletions bfasst/tools/transform/error_injector_rules.ninja

This file was deleted.

4 changes: 4 additions & 0 deletions bfasst/tools/transform/error_injector_rules.ninja.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
rule inject
command = python {{ bffast_path }}/bfasst/utils/error_injector.py --build_dir $build_dir --log_path $log_path --seed $seed --error_type $error_type --reversed_netlist $reversed_netlist $logging_level
description = inject a $error_type into xrev netlist for $build_dir

2 changes: 1 addition & 1 deletion bfasst/tools/transform/netlist_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, flow, design, rev_netlist, logging_level):

self.build_path = self.design_build_path / "netlist_cleanup"
self._init_outputs()
self.rule_snippet_path = NINJA_TRANSFORM_TOOLS_PATH / "netlist_cleanup_rules.ninja"
self.rule_snippet_path = NINJA_TRANSFORM_TOOLS_PATH / "netlist_cleanup_rules.ninja.mustache"

def _init_outputs(self):
self.outputs["netlist_cleaned_path"] = self.build_path / (
Expand Down
3 changes: 0 additions & 3 deletions bfasst/tools/transform/netlist_cleanup_rules.ninja

This file was deleted.

3 changes: 3 additions & 0 deletions bfasst/tools/transform/netlist_cleanup_rules.ninja.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rule netlist_cleanup
command = python {{ bfasst_path }}/bfasst/utils/netlist_cleanup.py $build_path $netlist_in $netlist_out $logging_level
description = netlist cleanup for $in
4 changes: 3 additions & 1 deletion bfasst/tools/transform/netlist_phys_to_logical.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def __init__(self, flow, design, cleaned_netlist):

self.build_path = self.design_build_path / "netlist_phys_to_logical"
self._init_outputs()
self.rule_snippet_path = NINJA_TRANSFORM_TOOLS_PATH / "netlist_phys_to_logical_rules.ninja"
self.rule_snippet_path = (
NINJA_TRANSFORM_TOOLS_PATH / "netlist_phys_to_logical_rules.ninja.mustache"
)

def _init_outputs(self):
self.outputs["netlist_phys_to_logical_path"] = self.build_path / (
Expand Down
3 changes: 0 additions & 3 deletions bfasst/tools/transform/netlist_phys_to_logical_rules.ninja

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rule netlist_phys_to_logical
command = python {{ bfasst_path }}/third_party/gmt_tools/netlist_phys_to_logical.py $build_path $netlist_in $netlist_out
description = netlist physical to logical for $in
2 changes: 1 addition & 1 deletion bfasst/tools/transform/phys_netlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, flow, design, impl_checkpoint, impl_edf, logging_level):
self.build_path = self.design_build_path / "vivado_phys_netlist"

self._init_outputs()
self.rule_snippet_path = NINJA_TRANSFORM_TOOLS_PATH / "phys_netlist_rules.ninja"
self.rule_snippet_path = NINJA_TRANSFORM_TOOLS_PATH / "phys_netlist_rules.ninja.mustache"

def create_build_snippets(self):
self.__write_json_file()
Expand Down
4 changes: 0 additions & 4 deletions bfasst/tools/transform/phys_netlist_rules.ninja

This file was deleted.

4 changes: 4 additions & 0 deletions bfasst/tools/transform/phys_netlist_rules.ninja.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
rule phys_netlist
command = python {{ bfasst_path }}/bfasst/utils/rw_phys_netlist.py --build_dir $build_dir --impl_dcp $impl_dcp --impl_edf $impl_edf $logging_level
description = generate physical netlist for $build_dir

2 changes: 1 addition & 1 deletion scripts/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __run_ninja(self):
cmd = ["ninja"]
if self.num_threads:
cmd += ["-j", str(self.num_threads)]
proc = subprocess.Popen(cmd, cwd=ROOT_PATH)
proc = subprocess.Popen(cmd)
proc.communicate()
return_code = proc.wait()

Expand Down

0 comments on commit b47d571

Please sign in to comment.