Skip to content

Comments

[Interp] Produce non-empty waveforms for combinational DUTs#196

Open
ngernest wants to merge 11 commits intomainfrom
monitor_adder_bugs
Open

[Interp] Produce non-empty waveforms for combinational DUTs#196
ngernest wants to merge 11 commits intomainfrom
monitor_adder_bugs

Conversation

@ngernest
Copy link
Contributor

@ngernest ngernest commented Feb 23, 2026

Note: merge #195 before reviewing this PR (I merged #195 into this PR since I found the Cargo aliases defined there helpful for running the interpreter executable, so he changed .toml files come from #195). The only changed file that is relevant to this PR is interpreter.rs.

When debugging why the monitor was failing the adder_d0 (combinational adder) round-trip test (#187), I noticed that the waveform produced by the interpreter was empty (Surfer had trouble opening the .fst file that was produced by the interpreter). I think the issue was that previously, the simulator's sim_step() method was only called when the next_threads queue is non-empty:

// scheduler.rs           
           ...
           // setup the threads for the next cycle
            if !self.next_threads.is_empty() {
                // advance simulation for next step
                info!("Stepping...");
                self.evaluator.sim_step();
                 ...
             }

However, for combinational DUTs like adder_d0, the next_threads queue is empty since all protocols defined with the same .prot file finish within the same cycle. As a result, the simulator never gets stepped, resulting in an empty waveform.

The fix is to add an extra flag to the Scheduler struct that tracks whether a step() statement was encountered, and to call sim_step() on the simulator whenever a step() is encountered (regardless of whether the next_threads queue is empty or not).

This allows the interpreter to produce a non-empty waveform for adder_d0!

Screenshot 2026-02-22 at 8 40 14 PM

All other interpreter tests still pass after this change.

@ngernest ngernest changed the title (WIP) [Monitor] Fix round-trip bugs associated with adders (WIP) [Interp + Monitor] Fix round-trip bug for combinational adder Feb 23, 2026
@ngernest ngernest changed the title (WIP) [Interp + Monitor] Fix round-trip bug for combinational adder (WIP) [Interp] Produce non-empty waveforms for combinational adders Feb 23, 2026
@ngernest ngernest changed the title (WIP) [Interp] Produce non-empty waveforms for combinational adders [Interp] Produce non-empty waveforms for combinational adders Feb 23, 2026
@ngernest ngernest marked this pull request as ready for review February 23, 2026 02:02
@ngernest ngernest changed the title [Interp] Produce non-empty waveforms for combinational adders [Interp] Produce non-empty waveforms for combinational DUTs Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant