Skip to content

Commit

Permalink
tweak the rhai files
Browse files Browse the repository at this point in the history
  • Loading branch information
EclecticGriffin committed Jul 15, 2024
1 parent 520b29d commit c16c112
Showing 1 changed file with 30 additions and 70 deletions.
100 changes: 30 additions & 70 deletions fud2/scripts/cider.rhai
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,39 @@ import "rtl_sim" as sim;
import "testbench" as tb;
import "calyx" as c;

let dbg = state("debug", []);
let dbg = state("cider-debug", []);
let cider_state = state("cider", []);

fn cider_setup(e) {
e.config_var_or(
"cider-exe",
"cider.exe",
"$calyx-base/target/debug/cider",
);
e.config_var_or(
"cider-converter",
"cider-converter.exe",
"$calyx-base/target/debug/cider-data-converter",
);
e.rule(
"cider",
"$cider-exe -l $calyx-base --raw --data data.json $in > $out",
);
e.rule(
"cider-debug",
"$cider-exe -l $calyx-base --data data.json $in debug || true",
);
e.arg("pool", "console");
e.config_var_or(
"cider-exe",
"cider.exe",
"$calyx-base/target/debug/cider",
);
e.config_var_or(
"cider-converter",
"cider-converter.exe",
"$calyx-base/target/debug/cider-data-converter",
);
e.rule(
"run-cider-debug",
"$cider-exe -l $calyx-base --data data.dump $in debug || true",
);
e.arg("pool", "console");

// TODO Can we reduce the duplication around and `$python`?
e.rsrc("interp-dat.py");
e.config_var_or("python", "python", "python3");
e.rule("dat-to-interp", "$python interp-dat.py --to-interp $in");
e.rule(
"interp-to-dat",
"$python interp-dat.py --from-interp $in $sim_data > $out",
);
e.build_cmd(
["data.json"],
"dat-to-interp",
["$sim_data"],
["interp-dat.py"],
);
e.rule(
"run-cider",
"$cider-exe -l $calyx-base --data data.dump $in > $out",
);

e.rule(
"run-cider",
"$cider-exe -l $calyx-base --data data.dump $in > $out",
);

e.rule("dump-to-interp", "$cider-converter --to cider $in > $out");
e.rule("interp-to-dump", "$cider-converter --to json $in > $out");
e.build_cmd(
["data.dump"],
"dump-to-interp",
["$sim_data"],
["$cider-converter"],
);
e.rule("dump-to-interp", "$cider-converter --to cider $in > $out");
e.rule("interp-to-dump", "$cider-converter --to json $in > $out");
e.build_cmd(
["data.dump"],
"dump-to-interp",
["$sim_data"],
["$cider-converter"],
);
}

op(
Expand All @@ -71,27 +52,6 @@ op(
},
);

op(
"interp",
[
sim::sim_setup,
tb::standalone_setup,
c::calyx_setup,
cider_setup,
],
c::calyx_state,
sim::dat,
|e, input, output| {
let out_file = "interp_out.json";
e.build_cmd([out_file], "cider", [input], ["data.json"]);
e.build_cmd(
[output],
"interp-to-dat",
[out_file],
["$sim_data", "interp-dat.py"],
);
},
);

op(
"cider",
Expand Down Expand Up @@ -123,9 +83,9 @@ op(
c::calyx_setup,
cider_setup,
],
c::calyx_state,
cider_state,
dbg,
|e, input, output| {
e.build_cmd([output], "cider-debug", [input], ["data.json"]);
e.build_cmd([output], "run-cider-debug", [input], ["data.dump"]);
},
);

0 comments on commit c16c112

Please sign in to comment.