Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b6a4906
integrate with turnt
Nikil-Shyamsunder Feb 15, 2026
6d5fbe1
make roundtrip a separate job
Nikil-Shyamsunder Feb 15, 2026
6b03d04
Use `uv run` instead of `python3` when invoking round-tripping script"
ngernest Feb 16, 2026
bff8547
add docstrings
Nikil-Shyamsunder Feb 16, 2026
841b5e6
add trace outputs for both failing and passing cases, remove ci skip
Nikil-Shyamsunder Feb 17, 2026
766cb0d
updated roundtrip case
Nikil-Shyamsunder Feb 17, 2026
3144053
make the .rt file formatting prettier
Nikil-Shyamsunder Feb 17, 2026
358df9c
modify python script to have prettier .rt outputs
Nikil-Shyamsunder Feb 17, 2026
f996b8f
debug: add --diff flag due to divergence in .rt results between ci ma…
Nikil-Shyamsunder Feb 17, 2026
68a5a2e
normalize panic outputs
Nikil-Shyamsunder Feb 17, 2026
1ec0679
[skip ci] Add TODO for Ernest
ngernest Feb 18, 2026
0a778f7
Merge remote-tracking branch 'origin/main' into roundtrip-test-turnt
ngernest Feb 18, 2026
d947ec2
Add extra CLI flag to round-trip testing script to keep intermediate …
ngernest Feb 19, 2026
bd12199
Merge remote-tracking branch 'origin/main' into roundtrip-test-turnt
ngernest Feb 19, 2026
5c7b979
Add allowed-to-fail CLI flag to round-tripping script
ngernest Feb 23, 2026
ef6e46e
Rename CLI flag to --allow-round-trip-failure, mark all tests with re…
ngernest Feb 23, 2026
48fab65
Bunch of fixes to allow individual tests to be skipped from round-tri…
ngernest Feb 23, 2026
2a4a1a4
Formatting
ngernest Feb 23, 2026
aa039ed
Only print name of fst file if user explicitly specifies it
ngernest Feb 23, 2026
374eced
Update another .rt file
ngernest Feb 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ jobs:
- name: Run Turnt tests for monitor
run: turnt --env monitor $(find . -type f -name '*.prot')

roundtrip:
name: Roundtrip
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-test-environment
- name: Run Turnt roundtrip tests
run: turnt --env roundtrip $(find . -type f -name '*.tx') --diff

msrv:
name: Check Minimum Rust Version for protocols library
runs-on: ubuntu-24.04
Expand Down
22 changes: 22 additions & 0 deletions examples/picorv32/unsigned_mul.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
trace_block: 0
trace_result: PASS
matched_monitor_trace_index: 0
interpreter_trace:
trace {
pcpi_mul_reset();
pcpi_mul(1, 1, 1);
pcpi_mul(1, 100, 100);
pcpi_mul(100, 1, 100);
pcpi_mul(33554483, 200, 2415929304);
}

parsed_monitor_trace_candidates:
candidate_monitor_trace: 0
trace {
pcpi_mul_reset();
pcpi_mul(1, 1, 1);
pcpi_mul(1, 100, 100);
pcpi_mul(100, 1, 100);
pcpi_mul(33554483, 200, 2415929304);
}

16 changes: 16 additions & 0 deletions examples/serv/serv_regfile.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
trace_block: 0
trace_result: PASS
matched_monitor_trace_index: 0
interpreter_trace:
trace {
read_write(0, 0, 0, 0, 1, 5, 3735928559);
read_write(5, 3735928559, 0, 0, 0, 0, 0);
}

parsed_monitor_trace_candidates:
candidate_monitor_trace: 0
trace {
read_write(0, 0, 0, 0, 1, 5, 3735928559);
read_write(5, 3735928559, 0, 0, 0, 0, 0);
}

16 changes: 16 additions & 0 deletions examples/tinyaes128/aes128.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
trace_block: 0
trace_result: PASS
matched_monitor_trace_index: 0
interpreter_trace:
trace {
aes128(5233100606242806050955395731361295, 88962710306127702866241727433142015, 140591190147677442632770771134392354138);
aes128(0, 0, 136792598789324718765670228683992083246);
}

parsed_monitor_trace_candidates:
candidate_monitor_trace: 0
trace {
aes128(5233100606242806050955395731361295, 88962710306127702866241727433142015, 140591190147677442632770771134392354138);
aes128(0, 0, 136792598789324718765670228683992083246);
}

5 changes: 5 additions & 0 deletions examples/turnt.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
[envs.interp]
command = "cargo run --package protocols-interp -- --color never --transactions {filename} {args}"

[envs.roundtrip]
command = "uv run ../scripts/roundtrip_case.py {filename} {args}"
binary = true
output.rt = "-"
5 changes: 5 additions & 0 deletions interp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ struct Cli {
/// of cycles specified with this option.
#[arg(long)]
max_steps: Option<u32>,

/// Mark this test as allowed to fail (ignored by interpreter, used only
/// round-trip test harness)
#[arg(long)]
allow_round_trip_failure: bool,
}

/// Examples (enables all tracing logs):
Expand Down
4 changes: 4 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ interp:
monitor:
turnt --env monitor $(find . -type f -name '*.prot')

# Run roundtrip checks (interp -> fst -> monitor) for all transactions
roundtrip:
turnt --env roundtrip $(find . -type f -name '*.tx')

# Run Turnt tests for the monitor based on the Brave New World artifacts
bnw_monitor:
turnt --env monitor $(find monitor/tests/fpga-debugging -type f -name '*.prot')
Expand Down
3 changes: 3 additions & 0 deletions protocols/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ impl<'a> Scheduler<'a> {
}
}

// Emit one trailing empty cycle so all generated .fst files having timing information
self.evaluator.sim_step();

// Emit diagnostics for all errors after execution is complete
self.emit_all_diagnostics();
self.results.clone()
Expand Down
13 changes: 13 additions & 0 deletions protocols/tests/adders/adder_d0/add_combinational.rt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO for Ernest: investigate this (b ought to be defined)

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
trace_block: 0
trace_result: FAIL
failure_kind: monitor_error
interpreter_trace:
trace {
add_combinational(100, 200, 300);
}

monitor_error:
Transaction `add_combinational_illegal_observation_in_conditional`, cycle 0: Unable to find value for b (symbol5) in args_mapping, which is { (symbol4) a: 100
(symbol6) s: 300 }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

1 change: 1 addition & 0 deletions protocols/tests/adders/adder_d0/illegal_assignment.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: non-zero // RETURN
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: non-zero // RETURN
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: non-zero // RETURN
1 change: 1 addition & 0 deletions protocols/tests/adders/adder_d1/add_incorrect.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: non-zero // RETURN
1 change: 1 addition & 0 deletions protocols/tests/adders/adder_d1/add_incorrect_implicit.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: non-zero // RETURN
1 change: 1 addition & 0 deletions protocols/tests/adders/adder_d1/add_multitrace.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: non-zero // RETURN
1 change: 1 addition & 0 deletions protocols/tests/adders/adder_d1/both_threads_fail.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: non-zero // RETURN
15 changes: 15 additions & 0 deletions protocols/tests/adders/adder_d1/both_threads_pass.rt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO for Ernest: check why the monitor is failing here

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
trace_block: 0
trace_result: FAIL
failure_kind: monitor_error
interpreter_trace:
trace {
add(1, 2, 3);
add(4, 5, 9);
}

monitor_error:
All schedulers failed: No transactions match the waveform for DUT `Adder`
Failure at cycle 1: No transactions match the waveform in `.roundtrip_tmp/adders-adder_d1-both_threads_pass_0.fst`.
Possible transactions: [add, add_fork_early, add_doesnt_end_in_step, add_incorrect, add_incorrect_implicit, wait_and_add]
Error: Monitor failed

1 change: 1 addition & 0 deletions protocols/tests/adders/adder_d1/busy_wait_fail.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: allowed to fail round trip
2 changes: 1 addition & 1 deletion protocols/tests/adders/adder_d1/busy_wait_fail.tx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ARGS: --verilog adders/adder_d1/add_d1.v --protocol adders/adder_d1/busy_wait.prot
// ARGS: --verilog adders/adder_d1/add_d1.v --protocol adders/adder_d1/busy_wait.prot --allow-round-trip-failure
// RETURN: 101
trace {
add_busy_wait(1, 2, 2, 999); // Wrong output value, this transaction fails
Expand Down
1 change: 1 addition & 0 deletions protocols/tests/adders/adder_d1/busy_wait_pass.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: allowed to fail round trip
2 changes: 1 addition & 1 deletion protocols/tests/adders/adder_d1/busy_wait_pass.tx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ARGS: --verilog adders/adder_d1/add_d1.v --protocol adders/adder_d1/busy_wait.prot
// ARGS: --verilog adders/adder_d1/add_d1.v --protocol adders/adder_d1/busy_wait.prot --allow-round-trip-failure
trace {
add_busy_wait(1, 2, 1, 3); // Runs busy-waiting loop for 1 iteration
add_busy_wait(4, 5, 3, 9); // Runs busy-waiting loop for 3 iterations
Expand Down
1 change: 1 addition & 0 deletions protocols/tests/adders/adder_d1/didnt_end_in_step.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: non-zero // RETURN
1 change: 1 addition & 0 deletions protocols/tests/adders/adder_d1/double_fork_error.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: non-zero // RETURN
1 change: 1 addition & 0 deletions protocols/tests/adders/adder_d1/first_fail_second_norun.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: non-zero // RETURN
1 change: 1 addition & 0 deletions protocols/tests/adders/adder_d1/first_thread_fails.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: non-zero // RETURN
1 change: 1 addition & 0 deletions protocols/tests/adders/adder_d1/fork_before_step_error.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: non-zero // RETURN
1 change: 1 addition & 0 deletions protocols/tests/adders/adder_d1/loop_with_assigns.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: allowed to fail round trip
2 changes: 1 addition & 1 deletion protocols/tests/adders/adder_d1/loop_with_assigns.tx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ARGS: --verilog adders/adder_d1/add_d1.v --protocol adders/adder_d1/loop_with_assigns.prot
// ARGS: --verilog adders/adder_d1/add_d1.v --protocol adders/adder_d1/loop_with_assigns.prot --allow-round-trip-failure
trace {
loop_add(1, 2, 3, 3); // assert 1+2=3 on each of 3 iterations
loop_add(10, 20, 1, 30); // assert 10+20=30 on 1 iteration
Expand Down
1 change: 1 addition & 0 deletions protocols/tests/adders/adder_d1/nested_busy_wait.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: allowed to fail round trip
2 changes: 1 addition & 1 deletion protocols/tests/adders/adder_d1/nested_busy_wait.tx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ARGS: --verilog adders/adder_d1/add_d1.v --protocol adders/adder_d1/nested_busy_wait.prot
// ARGS: --verilog adders/adder_d1/add_d1.v --protocol adders/adder_d1/nested_busy_wait.prot --allow-round-trip-failure
trace {
nested_busy_wait(1, 2, 2, 3, 3); // 6 inner steps + 2 outer steps = 8 cycles
nested_busy_wait(10, 20, 3, 2, 30); // 6 inner steps + 3 outer steps = 9 cycles
Expand Down
1 change: 1 addition & 0 deletions protocols/tests/adders/adder_d1/second_thread_fails.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: non-zero // RETURN
15 changes: 15 additions & 0 deletions protocols/tests/adders/adder_d1/wait_and_add_correct.rt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO for Ernest: check why monitor is failing here

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
trace_block: 0
trace_result: FAIL
failure_kind: monitor_error
interpreter_trace:
trace {
wait_and_add(1, 2, 3);
add(4, 5, 9);
}

monitor_error:
All schedulers failed: No transactions match the waveform for DUT `Adder`
Failure at cycle 1: No transactions match the waveform in `.roundtrip_tmp/adders-adder_d1-wait_and_add_correct_0.fst`.
Possible transactions: [add, add_fork_early, add_doesnt_end_in_step, add_incorrect, add_incorrect_implicit, wait_and_add]
Error: Monitor failed

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: non-zero // RETURN
16 changes: 16 additions & 0 deletions protocols/tests/adders/adder_d2/both_threads_pass.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
trace_block: 0
trace_result: PASS
matched_monitor_trace_index: 0
interpreter_trace:
trace {
add(1, 2, 3);
add(4, 5, 9);
}

parsed_monitor_trace_candidates:
candidate_monitor_trace: 0
trace {
add(1, 2, 3);
add(4, 5, 9);
}

1 change: 1 addition & 0 deletions protocols/tests/adders/adder_d2/no_dontcare_conflict.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: non-zero // RETURN
22 changes: 22 additions & 0 deletions protocols/tests/alus/alu_d1.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
trace_block: 0
trace_result: PASS
matched_monitor_trace_index: 0
interpreter_trace:
trace {
add(1, 2, 3);
add(123, 245, 368);
sub(200, 200, 0);
and(100, 100, 100);
or(0, 230, 230);
}

parsed_monitor_trace_candidates:
candidate_monitor_trace: 0
trace {
add(1, 2, 3);
add(123, 245, 368);
sub(200, 200, 0);
and(100, 100, 100);
or(0, 230, 230);
}

22 changes: 22 additions & 0 deletions protocols/tests/alus/alu_d2.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
trace_block: 0
trace_result: PASS
matched_monitor_trace_index: 0
interpreter_trace:
trace {
add(1, 2, 3);
add(123, 245, 368);
sub(200, 200, 0);
and(100, 100, 100);
or(0, 230, 230);
}

parsed_monitor_trace_candidates:
candidate_monitor_trace: 0
trace {
add(1, 2, 3);
add(123, 245, 368);
sub(200, 200, 0);
and(100, 100, 100);
or(0, 230, 230);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: non-zero // RETURN
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
trace_block: 0
trace_result: PASS
matched_monitor_trace_index: 0
interpreter_trace:
trace {
bit_truncation_fft(8386560, 2047);
}

parsed_monitor_trace_candidates:
candidate_monitor_trace: 0
trace {
bit_truncation_fft(8386560, 2047);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: non-zero // RETURN
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
trace_block: 0
trace_result: PASS
matched_monitor_trace_index: 0
interpreter_trace:
trace {
bit_truncation_sha(4398046511104, 68719476736);
}

parsed_monitor_trace_candidates:
candidate_monitor_trace: 0
trace {
bit_truncation_sha(4398046511104, 68719476736);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: non-zero // RETURN
14 changes: 14 additions & 0 deletions protocols/tests/brave_new_world/failure_to_update/ftu_sha_fix.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
trace_block: 0
trace_result: PASS
matched_monitor_trace_index: 0
interpreter_trace:
trace {
failure_to_update_sha();
}

parsed_monitor_trace_candidates:
candidate_monitor_trace: 0
trace {
failure_to_update_sha();
}

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: non-zero // RETURN
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
trace_block: 0
trace_result: PASS
matched_monitor_trace_index: 0
interpreter_trace:
trace {
signal_async(6, 7);
}

parsed_monitor_trace_candidates:
candidate_monitor_trace: 0
trace {
signal_async(6, 7);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP: non-zero // RETURN
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
trace_block: 0
trace_result: PASS
matched_monitor_trace_index: 0
interpreter_trace:
trace {
use_without_valid(5, 5);
}

parsed_monitor_trace_candidates:
candidate_monitor_trace: 0
trace {
use_without_valid(5, 5);
}

14 changes: 14 additions & 0 deletions protocols/tests/counters/counter.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
trace_block: 0
trace_result: PASS
matched_monitor_trace_index: 0
interpreter_trace:
trace {
count_up(10);
}

parsed_monitor_trace_candidates:
candidate_monitor_trace: 0
trace {
count_up(10);
}

Loading