Skip to content

Commit

Permalink
Remove duplicate ops from lib.rs. (#2272)
Browse files Browse the repository at this point in the history
This PR removes ops from `lib.rs` which are duplicated in Rhai scripts.
  • Loading branch information
jku20 authored Nov 4, 2024
1 parent 8294be8 commit 3687b07
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 929 deletions.
4 changes: 0 additions & 4 deletions fud2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ readme = "README.md"
categories = ["build-tool"]
description = "Compiler driver for the Calyx infrastructure"

[features]
migrate_to_scripts = []
default = ["migrate_to_scripts"]

[dependencies]
fud-core = { path = "fud-core", version = "0.0.2", features = ["egg_planner"] }
anyhow.workspace = true
Expand Down
40 changes: 38 additions & 2 deletions fud2/scripts/cocotb-axi.rhai
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,36 @@ fn cocotb_setup(e) {
let data_path = e.external_path(data_name);
e.var_("sim_data", data_path);

let waves = e.config_constrained_or("waves", ["true", "false"], "false");
if waves == "true" {
//adds lines based on what is needed for icarus fst output.
e.rule("iverilog-fst-sed",
`sed '/\/\/ COMPONENT END: wrapper/c\` + "ifdef COCOTB_SIM\n initial begin\n" + ` \$$dumpfile ("$fst_file_name");` + "\n " + `\$$dumpvars (0, wrapper);` + "\n 1;\n end\n`endif\n" + `\/\/ COMPONENT END: wrapper' $in > $out`);
}

e.var_("cocotb-args", if waves == "true" {"WAVES=1"} else {""});
e.rule("make-cocotb", "make DATA_PATH=$sim_data VERILOG_SOURCE=$in COCOTB_LOG_LEVEL=CRITICAL $cocotb-args > $out");

// Cocotb is wants files relative to the location of the makefile.
// This is annoying to calculate on the fly, so we just copy necessary files to the build directory
e.rule("copy", "cp $in $out");
e.rule("make-cocotb", "make DATA_PATH=$sim_data VERILOG_SOURCE=$in COCOTB_LOG_LEVEL=CRITICAL > $out");
// This cleans up the extra `make` cruft, leaving what is in between `{` and `}.`
e.rule("cleanup-cocotb", "sed -n '/Output:/,/make\\[1\\]/{/Output:/d;/make\\[1\\]/d;p}' $in > $out");
e.rule(
"cleanup-cocotb", `sed -n '/Output:/,/make\[1\]/{/Output:/d;/make\[1\]/d;p}' $in > $out`
);
}

fn basename(s) {
let out = "";
let dot_idx = s.len() - 1;
while s[dot_idx] != "." && dot_idx >= 0 {
dot_idx -= 1;
}
if dot_idx != 0 {
s.truncate(dot_idx)
} else {
s
}
}

op(
Expand All @@ -43,6 +67,18 @@ op(
["$cocotb-makefile-dir/run_axi_test.py"],
[],
);
let waves = e.config_constrained_or(
"waves",
["true", "false"],
"false",
);
let vcd_file_name = `${basename(input)}.fst`;
let make_in = input;
if waves == "true" {
make_in = "dumpvars.v";
e.build_cmd([make_in], "iverilog-fst-sed", input, []);
e.arg("fst_file_name", vcd_file_name);
}
e.build_cmd(
["tmp.dat"],
"make-cocotb",
Expand Down
Loading

0 comments on commit 3687b07

Please sign in to comment.