Skip to content

Why is it this value? Explain any value in an example's timeline - #21

Merged
dtt-github merged 1 commit into
mainfrom
feature/why-value
Nov 6, 2026
Merged

dtt-github merged 1 commit into
mainfrom
feature/why-value

Conversation

@dtt-github

Copy link
Copy Markdown
Owner

What

In an example's What actually happened timeline, any value can now be clicked. A Why? panel explains it:

led = 1 from cycle 4: line 20 of blinker.v wrote it: led <= ~led. It ran because !rst_n was false (rst_n = 1), and !en was false (en = 1), and cnt == N - 1 was true (cnt = 3). It used led = 0.

Every value mentioned can be clicked in turn, building a chain back to the cause: through block ports, to the example step that set an input ("set by step 1 of the example"). When the person then asks the AI to fix the design (or the assistant to fix the example), the chain goes with the request. Runs in the browser; no AI, no cost.

How

  • Simulator (wafer-sim): elaboration gives each assignment (and port connection, continuous assign, declaration initialiser) an Origin: file, line, scope, text as written, the signals it reads, and the enclosing if/case decisions with the way each went. Op::From(n) marks it; the simulator carries it with each write and records it per change in WaveSignal::by, alongside SimResult::origins. A starting value an assignment confirms without changing is credited to it.
  • WASM: by(i) and origins() (JSON).
  • Web: lib/why.ts follows a value at a time to its origin (port hops followed; nonblocking assignments read just before the clock edge); Replay exposes the simulation, check times and cycleAt; the timeline rows are clickable and the WhyPanel shows the chain.

Checked

  • New simulator test: changes in an up/down counter name the right line, reads and decisions (if/else chain, case arm), through ports to the testbench; starting values are credited.
  • Browser, local: the blinker example traced led → cnt → cnt → en (step 1); the UART receiver traced valid → state 3 → state 2 → rx through its case arms.
  • cargo fmt --check, clippy -D warnings, cargo test --workspace, web typecheck and build.

🤖 Generated with Claude Code

Clicking a value in "What actually happened" shows the line of the design
that wrote it, why that line ran (each if/case around it and which way it
went, with the values decided on) and the values it used, each clickable
in turn, through block ports back to the example step that set an input.
The explanation followed goes with requests to the AI.

The simulator records, for every value change, the assignment that made
it: WaveSignal::by and SimResult::origins (line, text, reads, decisions),
exposed to the browser through wafer-sim-wasm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dtt-github
dtt-github merged commit 007e6f4 into main Nov 6, 2026
2 checks passed
@dtt-github
dtt-github deleted the feature/why-value branch November 6, 2026 17:01
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