Skip to content

Why wasn't it the expected value? Explain a failing check - #22

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

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

Conversation

@dtt-github

Copy link
Copy Markdown
Owner

What

A failing example's account in What actually happened now ends with a Why wasn't it N? link. It lists every line of the design that could have given the signal the expected value, and what happened to it the last time it could have run:

  • Blocked: "Line 20 of blinker.v: led <= ~led. Didn't run for cycle 3 (!rst_n was false, !en was false) because cnt == N - 1 was false (cnt = 2)."
  • Ran: it ran with the values shown and computed something else, or a later line changed the value.
  • Hadn't run yet: nothing had reached its decisions by then.

Lines that only write other constants are left out and counted. If no line can write the expected value, it says so. Values in the answer can be clicked to continue in the existing "Why?" chain, and the answer goes with a request to the AI to fix the design or example. It runs in the browser, with no AI and no cost.

How

  • wafer-sim: records every if/case decision with the branch taken (SimResult::decisions, capped at MAX_DECISIONS, with decisions_cut) and maps branches to decisions (cover_decision). Origin::writes names the signal an assignment writes, and Cond::point names its branch.
  • wafer-sim-wasm / worker: pass the decision log as typed arrays.
  • apps/web/src/lib/why.ts: whyNot() finds the candidate lines, walks their decisions at the last moment they were made, and reports the first one that went another way.

Checked

  • Simulator test: the up/down counter records the right branch per clock edge, in time order, plus writes.
  • In the browser, blinker with a check made one cycle early: the panel names cnt == N - 1 (cnt = 2), and clicking cnt = 2 continues the "Why?" chain. The test example was restored afterwards.
  • UART receiver: the case decision is reported ("state matched one of the listed values (state = 2)").
  • Local checks: fmt, clippy -D warnings, workspace tests, web typecheck and build.

Docs: user guide (design view), architecture, CHANGELOG.

Initiated by DigitalTwin Technology GmbH.

🤖 Generated with Claude Code

A failing example's account ends with "Why wasn't it N?": every line of
the design that could have written the expected value, and for each the
decision that kept it from running (with the values decided on), or that
it ran and computed something else. Its values continue into the "Why?"
chain, and the answer goes with requests to the AI.

The simulator records every if/case decision with the branch taken
(SimResult::decisions, capped at MAX_DECISIONS) and which signal each
assignment writes (Origin::writes); conditions name their branch point.

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