Skip to content

Commit

Permalink
Separate flag for specifying lib path in fud2 (#2325)
Browse files Browse the repository at this point in the history
Add a `calyx.lib_path` argument for the `fud2` stage.
  • Loading branch information
rachitnigam authored Nov 2, 2024
1 parent 720e287 commit d1f43c6
Show file tree
Hide file tree
Showing 25 changed files with 107 additions and 77 deletions.
14 changes: 10 additions & 4 deletions fud2/fud-core/src/script/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,16 @@ impl ScriptRunner {
static_files: impl Iterator<Item = (&'static str, &'static [u8])>,
) -> &mut Self {
for (name, data) in static_files {
let ast = self
.engine
.compile(String::from_utf8(data.to_vec()).unwrap())
.unwrap();
let file = String::from_utf8(data.to_vec()).unwrap();
let compile_res = self.engine.compile(file);

let ast = match compile_res {
Ok(ast) => ast,
Err(e) => {
let msg = format!("Failed to parse `{name}': {e}",);
panic!("{msg}");
}
};
let functions =
self.resolver.as_mut().unwrap().register_data(name, ast);
self.rhai_functions = self.rhai_functions.merge(&functions);
Expand Down
8 changes: 5 additions & 3 deletions fud2/scripts/calyx.rhai
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ export let calyx_setup = calyx_setup;
fn calyx_setup(e) {
e.config_var("calyx-base", "calyx.base");
e.config_var_or("calyx-exe", "calyx.exe", "$calyx-base/target/debug/calyx");
e.config_var_or("calyx-lib-path", "calyx.lib_path", "$calyx-base");
e.config_var_or("args", "calyx.args", "");
e.rule("calyx", "$calyx-exe -l $calyx-base -b $backend $args $in > $out");
e.rule("calyx-pass", "$calyx-exe -l $calyx-base -p $pass $args $in > $out");

e.rule("calyx", "$calyx-exe -l $calyx-lib-path -b $backend $args $in > $out");
e.rule("calyx-pass", "$calyx-exe -l $calyx-lib-path -p $pass $args $in > $out");

e.config_var_or("flags", "calyx.flags", "-p none");
e.rule(
"calyx-with-flags",
"$calyx-exe -l $calyx-base $flags $args $in > $out",
"$calyx-exe -l $calyx-lib-path $flags $args $in > $out",
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ rule get-rsrc

calyx-base = /test/calyx
calyx-exe = $calyx-base/target/debug/calyx
calyx-lib-path = $calyx-base
args =
rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
command = $calyx-exe -l $calyx-lib-path -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
command = $calyx-exe -l $calyx-lib-path -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out
command = $calyx-exe -l $calyx-lib-path $flags $args $in > $out

cider-exe = $calyx-base/target/debug/cider
cider-converter = $calyx-base/target/debug/cider-data-converter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ rule get-rsrc

calyx-base = /test/calyx
calyx-exe = $calyx-base/target/debug/calyx
calyx-lib-path = $calyx-base
args =
rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
command = $calyx-exe -l $calyx-lib-path -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
command = $calyx-exe -l $calyx-lib-path -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out
command = $calyx-exe -l $calyx-lib-path $flags $args $in > $out

yxi = $calyx-base/target/debug/yxi
rule yxi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ rule get-rsrc

calyx-base = /test/calyx
calyx-exe = $calyx-base/target/debug/calyx
calyx-lib-path = $calyx-base
args =
rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
command = $calyx-exe -l $calyx-lib-path -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
command = $calyx-exe -l $calyx-lib-path -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out
command = $calyx-exe -l $calyx-lib-path $flags $args $in > $out

python = python3
build json-dat.py: get-rsrc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ rule get-rsrc

calyx-base = /test/calyx
calyx-exe = $calyx-base/target/debug/calyx
calyx-lib-path = $calyx-base
args =
rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
command = $calyx-exe -l $calyx-lib-path -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
command = $calyx-exe -l $calyx-lib-path -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out
command = $calyx-exe -l $calyx-lib-path $flags $args $in > $out

python = python3
build json-dat.py: get-rsrc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ rule get-rsrc

calyx-base = /test/calyx
calyx-exe = $calyx-base/target/debug/calyx
calyx-lib-path = $calyx-base
args =
rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
command = $calyx-exe -l $calyx-lib-path -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
command = $calyx-exe -l $calyx-lib-path -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out
command = $calyx-exe -l $calyx-lib-path $flags $args $in > $out

python = python3
build json-dat.py: get-rsrc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ rule get-rsrc

calyx-base = /test/calyx
calyx-exe = $calyx-base/target/debug/calyx
calyx-lib-path = $calyx-base
args =
rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
command = $calyx-exe -l $calyx-lib-path -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
command = $calyx-exe -l $calyx-lib-path -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out
command = $calyx-exe -l $calyx-lib-path $flags $args $in > $out

python = python3
build json-dat.py: get-rsrc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ rule get-rsrc

calyx-base = /test/calyx
calyx-exe = $calyx-base/target/debug/calyx
calyx-lib-path = $calyx-base
args =
rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
command = $calyx-exe -l $calyx-lib-path -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
command = $calyx-exe -l $calyx-lib-path -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out
command = $calyx-exe -l $calyx-lib-path $flags $args $in > $out

vivado-dir = /test/xilinx/vivado
vitis-dir = /test/xilinx/vitis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ rule get-rsrc

calyx-base = /test/calyx
calyx-exe = $calyx-base/target/debug/calyx
calyx-lib-path = $calyx-base
args =
rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
command = $calyx-exe -l $calyx-lib-path -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
command = $calyx-exe -l $calyx-lib-path -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out
command = $calyx-exe -l $calyx-lib-path $flags $args $in > $out

vivado-dir = /test/xilinx/vivado
vitis-dir = /test/xilinx/vitis
Expand Down
7 changes: 4 additions & 3 deletions fud2/tests/snapshots/tests__test@calyx_to_cider-debug.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ rule get-rsrc

calyx-base = /test/calyx
calyx-exe = $calyx-base/target/debug/calyx
calyx-lib-path = $calyx-base
args =
rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
command = $calyx-exe -l $calyx-lib-path -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
command = $calyx-exe -l $calyx-lib-path -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out
command = $calyx-exe -l $calyx-lib-path $flags $args $in > $out

build tb.sv: get-rsrc

Expand Down
7 changes: 4 additions & 3 deletions fud2/tests/snapshots/tests__test@calyx_to_verilog.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ rule get-rsrc

calyx-base = /test/calyx
calyx-exe = $calyx-base/target/debug/calyx
calyx-lib-path = $calyx-base
args =
rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
command = $calyx-exe -l $calyx-lib-path -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
command = $calyx-exe -l $calyx-lib-path -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out
command = $calyx-exe -l $calyx-lib-path $flags $args $in > $out

build _to_stdout_verilog.sv: calyx _from_stdin_calyx.futil
backend = verilog
Expand Down
7 changes: 4 additions & 3 deletions fud2/tests/snapshots/tests__test@plan_axi-wrapped.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ rule get-rsrc

calyx-base = /test/calyx
calyx-exe = $calyx-base/target/debug/calyx
calyx-lib-path = $calyx-base
args =
rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
command = $calyx-exe -l $calyx-lib-path -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
command = $calyx-exe -l $calyx-lib-path -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out
command = $calyx-exe -l $calyx-lib-path $flags $args $in > $out

yxi = $calyx-base/target/debug/yxi
rule yxi
Expand Down
7 changes: 4 additions & 3 deletions fud2/tests/snapshots/tests__test@plan_calyx-noverify.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ rule get-rsrc

calyx-base = /test/calyx
calyx-exe = $calyx-base/target/debug/calyx
calyx-lib-path = $calyx-base
args =
rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
command = $calyx-exe -l $calyx-lib-path -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
command = $calyx-exe -l $calyx-lib-path -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out
command = $calyx-exe -l $calyx-lib-path $flags $args $in > $out

build /output.ext: calyx /input.ext
backend = verilog
Expand Down
7 changes: 4 additions & 3 deletions fud2/tests/snapshots/tests__test@plan_calyx-to-cider.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ rule get-rsrc

calyx-base = /test/calyx
calyx-exe = $calyx-base/target/debug/calyx
calyx-lib-path = $calyx-base
args =
rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
command = $calyx-exe -l $calyx-lib-path -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
command = $calyx-exe -l $calyx-lib-path -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out
command = $calyx-exe -l $calyx-lib-path $flags $args $in > $out

build /output.ext: calyx-with-flags /input.ext

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ rule get-rsrc

calyx-base = /test/calyx
calyx-exe = $calyx-base/target/debug/calyx
calyx-lib-path = $calyx-base
args =
rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
command = $calyx-exe -l $calyx-lib-path -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
command = $calyx-exe -l $calyx-lib-path -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out
command = $calyx-exe -l $calyx-lib-path $flags $args $in > $out

cocotb-makefile-dir = $calyx-base/yxi/axi-calyx/cocotb
sim_data = /test/data.json
Expand Down
7 changes: 4 additions & 3 deletions fud2/tests/snapshots/tests__test@plan_calyx-to-firrtl.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ rule get-rsrc

calyx-base = /test/calyx
calyx-exe = $calyx-base/target/debug/calyx
calyx-lib-path = $calyx-base
args =
rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
command = $calyx-exe -l $calyx-lib-path -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
command = $calyx-exe -l $calyx-lib-path -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out
command = $calyx-exe -l $calyx-lib-path $flags $args $in > $out

yxi = $calyx-base/target/debug/yxi
rule yxi
Expand Down
7 changes: 4 additions & 3 deletions fud2/tests/snapshots/tests__test@plan_calyx-to-verilog.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ rule get-rsrc

calyx-base = /test/calyx
calyx-exe = $calyx-base/target/debug/calyx
calyx-lib-path = $calyx-base
args =
rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
command = $calyx-exe -l $calyx-lib-path -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
command = $calyx-exe -l $calyx-lib-path -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out
command = $calyx-exe -l $calyx-lib-path $flags $args $in > $out

build /output.ext: calyx /input.ext
backend = verilog
Expand Down
7 changes: 4 additions & 3 deletions fud2/tests/snapshots/tests__test@plan_calyx-to-yxi.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ rule get-rsrc

calyx-base = /test/calyx
calyx-exe = $calyx-base/target/debug/calyx
calyx-lib-path = $calyx-base
args =
rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
command = $calyx-exe -l $calyx-lib-path -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
command = $calyx-exe -l $calyx-lib-path -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out
command = $calyx-exe -l $calyx-lib-path $flags $args $in > $out

yxi = $calyx-base/target/debug/yxi
rule yxi
Expand Down
7 changes: 4 additions & 3 deletions fud2/tests/snapshots/tests__test@plan_cider.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ rule get-rsrc

calyx-base = /test/calyx
calyx-exe = $calyx-base/target/debug/calyx
calyx-lib-path = $calyx-base
args =
rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
command = $calyx-exe -l $calyx-lib-path -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
command = $calyx-exe -l $calyx-lib-path -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out
command = $calyx-exe -l $calyx-lib-path $flags $args $in > $out

cider-exe = $calyx-base/target/debug/cider
cider-converter = $calyx-base/target/debug/cider-data-converter
Expand Down
Loading

0 comments on commit d1f43c6

Please sign in to comment.