Skip to content

Commit

Permalink
[Cider 2] fud2 fixes (#2140)
Browse files Browse the repository at this point in the history
* rename `interp-flat` to `cider`

* fix the current tests

* now you can run with flags

* janky fix to disable logging by default for cider

* janky fix to disable logging by default for cider

* Fix the snapshots
  • Loading branch information
EclecticGriffin authored Jun 12, 2024
1 parent 484d09f commit 2439f79
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 10 deletions.
42 changes: 37 additions & 5 deletions fud2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ fn setup_calyx(
"calyx-pass",
"$calyx-exe -l $calyx-base -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",
)?;

Ok(())
});
bld.op(
Expand Down Expand Up @@ -500,6 +508,9 @@ pub fn build_driver(bld: &mut DriverBuilder) {

// Interpreter.
let debug = bld.state("debug", &[]); // A pseudo-state.
// A pseudo-state for cider input
let cider_state = bld.state("cider", &[]);

let cider_setup = bld.setup("Cider interpreter", |e| {
e.config_var_or(
"cider-exe",
Expand Down Expand Up @@ -537,7 +548,7 @@ pub fn build_driver(bld: &mut DriverBuilder) {
)?;

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

Expand All @@ -552,6 +563,22 @@ pub fn build_driver(bld: &mut DriverBuilder) {

Ok(())
});
bld.op(
"calyx-to-cider",
&[sim_setup, calyx_setup],
calyx,
cider_state,
|e, input, _output| {
e.build_cmd(
&["cider-input.futil"],
"calyx-with-flags",
&[input],
&[],
)?;
Ok(())
},
);

bld.op(
"interp",
&[
Expand All @@ -575,13 +602,18 @@ pub fn build_driver(bld: &mut DriverBuilder) {
},
);
bld.op(
"interp-flat",
"cider",
&[sim_setup, calyx_setup, cider_setup],
calyx,
cider_state,
dat,
|e, input, output| {
|e, _input, output| {
let out_file = "interp_out.dump";
e.build_cmd(&[out_file], "cider2", &[input], &["data.dump"])?;
e.build_cmd(
&[out_file],
"run-cider",
&["cider-input.futil"],
&["data.dump"],
)?;
e.build_cmd(
&[output],
"interp-to-dump",
Expand Down
5 changes: 4 additions & 1 deletion fud2/tests/snapshots/tests__emit@calyx_debug.snap
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out

# Cider interpreter
cider-exe = $calyx-base/target/debug/cider
Expand All @@ -47,7 +50,7 @@ rule dat-to-interp
rule interp-to-dat
command = $python interp-dat.py --from-interp $in $sim_data > $out
build data.json: dat-to-interp $sim_data | interp-dat.py
rule cider2
rule run-cider
command = $cider-exe -l $calyx-base --data data.dump $in flat > $out
rule dump-to-interp
command = $cider-converter --to cider $in > $out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out

# Custom Testbench Setup
rule ref-to-external
Expand Down
3 changes: 3 additions & 0 deletions fud2/tests/snapshots/tests__emit@calyx_icarus_dat.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out

# RTL simulation
python = python3
Expand Down
3 changes: 3 additions & 0 deletions fud2/tests/snapshots/tests__emit@calyx_icarus_vcd.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out

# RTL simulation
python = python3
Expand Down
5 changes: 4 additions & 1 deletion fud2/tests/snapshots/tests__emit@calyx_interp_dat.snap
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out

# Cider interpreter
cider-exe = $calyx-base/target/debug/cider
Expand All @@ -47,7 +50,7 @@ rule dat-to-interp
rule interp-to-dat
command = $python interp-dat.py --from-interp $in $sim_data > $out
build data.json: dat-to-interp $sim_data | interp-dat.py
rule cider2
rule run-cider
command = $cider-exe -l $calyx-base --data data.dump $in flat > $out
rule dump-to-interp
command = $cider-converter --to cider $in > $out
Expand Down
3 changes: 3 additions & 0 deletions fud2/tests/snapshots/tests__emit@calyx_verilator_dat.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out

# RTL simulation
python = python3
Expand Down
3 changes: 3 additions & 0 deletions fud2/tests/snapshots/tests__emit@calyx_verilator_vcd.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out

# RTL simulation
python = python3
Expand Down
3 changes: 3 additions & 0 deletions fud2/tests/snapshots/tests__emit@calyx_verilog.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out

# build targets
build stdin.sv: calyx stdin
Expand Down
3 changes: 3 additions & 0 deletions fud2/tests/snapshots/tests__emit@calyx_xrt-trace_vcd.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out

# Xilinx tools
vivado-dir = /test/xilinx/vivado
Expand Down
3 changes: 3 additions & 0 deletions fud2/tests/snapshots/tests__emit@calyx_xrt_dat.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ rule calyx
command = $calyx-exe -l $calyx-base -b $backend $args $in > $out
rule calyx-pass
command = $calyx-exe -l $calyx-base -p $pass $args $in > $out
flags = -p none
rule calyx-with-flags
command = $calyx-exe -l $calyx-base $flags $args $in > $out

# Xilinx tools
vivado-dir = /test/xilinx/vivado
Expand Down
5 changes: 3 additions & 2 deletions interp/cider2-tests/runt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ expect_dir = "control"
name = "invoke"
paths = ["../tests/control/invoke/*.futil"]
cmd = """
fud2 {} --from calyx --to dat --through interp-flat -s sim.data={}.data | jq --sort-keys
fud2 {} --from calyx --to dat --through cider -s sim.data={}.data -s calyx.args="--log off" | jq --sort-keys
"""
timeout = 10
expect_dir = "invoke"
Expand Down Expand Up @@ -106,8 +106,9 @@ name = "correctness dynamic"
paths = ["../../tests/correctness/*.futil"]
cmd = """
fud2 --from calyx --to dat \
--through interp-flat \
--through cider \
-s sim.data={}.data \
-s calyx.args="--log off" \
{} | jq --sort-keys
"""

Expand Down
2 changes: 1 addition & 1 deletion interp/src/flatten/structures/environment/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@ impl<'a> Simulator<'a> {

has_changed |= changed.as_bool();
} else if self.env.ports[dest].is_def() {
todo!("Raise an error here since this assignment is undefining things: {}", self.env.ctx.printer().print_assignment(ledger.comp_id, assign_idx))
todo!("Raise an error here since this assignment is undefining things: {}. Port currently has value: {}", self.env.ctx.printer().print_assignment(ledger.comp_id, assign_idx), &self.env.ports[dest])
}
}
}
Expand Down

0 comments on commit 2439f79

Please sign in to comment.