Repository navigation
feat(tutorial): add the four-digit adder stage - #103
Merged
Merged
Conversation
…pin widths - A stage lays out what it starts with through layOut, which returns how to clear it from there. Decorations are only placed for the player, not inside a part handed over. StageCircuit can now set a node's config and split a pin. - A stage can place its pins further apart (pinDistance). - Check compares each stage pin's bit width with what the stage expects before simulating, and says "A should have 4 digits, but it has 1", instead of the simulation's internal error. - describeFailure moves out of the page into src/tutorial/failure.ts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eral bits A truth table's cells now hold values of any width, written in binary when they have several bits. goalTableOf replaces truthTableOfCheck: it lists every combination when each input is one bit, and otherwise the stage's examples. The bit helpers bitsOf and numberOf are shared by the value editor and tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stage 6, "Adding four digits", adds two four-bit numbers with four of stage 5's part. It starts with Decompose and Aggregate split into single digits and wired to A, B and S, and a 7seg and a 4x7 Display showing S. Its goal shows three examples, and its steps say which pin is which digit and how the carries chain. Decompose and Aggregate get summaries, and a stage now offers only the parts it hands over directly, not those built into them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on, and address the review - The width check skips a pin in a width conflict and an output nothing fixes, as the simulation tells what is wrong with those. - The English message counts "1 digit" for the expected width too. - Stage 6 calls C the fifth, sixteens digit, which is 1 when A + B is 16 or more, and names the letters the 7seg draws for 10 to 15 (A, b, C, d, E, F). - StageCircuit.split refuses a pin that is split already. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…of the check itself - The editor can fit its view to the nodes when it first gets its size, zooming out only as far as needed and leaving room for the title bar and the play button (fitsNodesInView). The tutorial turns it on, so a stage's nodes are in view on any window; the free mode keeps its view. - Stage 6 places the 7seg right of Aggregate's output, so the wire to it no longer crosses its name, and the Display at the top right, away from the play button. - An exception from the check outside the simulation is caught and logged, and the stage says that something went wrong instead of showing nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e the check - The editor fits its view only once, and only when both sides of the renderer have a size, and a renderer smaller than the padding still gets a finite scale. - checkCombinational itself turns an exception into checkFailed, which is now tested. The message no longer suggests resetting the stage, which would throw the circuit away. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Stages 1 to 3 say the lamp turns ON, as the Out node shows, not that it lights. - Stage 6 says which side of Decompose and Aggregate holds the digits, names the Decompose nodes and adders the wires run between, and where the output C is. - Stage 6 tells where the sum is shown, what the 7seg does, and which letter is which number in hexadecimal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only one-bit values were coloured, so a stage's example table showed C's 1 in green but the 1s of S in black. Each bit now carries its own colour, and digits keep their width. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploying create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee with
|
| Latest commit: |
11ee90e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://234f3935.create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee.pages.dev |
| Branch Preview URL: | https://feat-four-bit-adder-stage.create-cpu-c8345196-9409-4cce-afc4-389f413ad8ee.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stage 6 adds two four-digit binary numbers with four of stage 5's part and shows the sum as a numeral, the first payoff on the way to the stopwatch. It is the first stage with pins of several bits and with nodes placed besides its pins, so this PR also adds what such a stage needs.
layOutplaces what it starts with besides its pins and returns how to clear it from there. Decorations such as the display are only placed for the player, not inside a part handed over.StageCircuitcan set a node's config and split a pin, and a stage can set how far apart its pins sit.goalTableOfreplacestruthTableOfCheck. It lists every combination when each input is one bit, and otherwise the stage's examples. Table cells hold values of any width, in binary, with every 1 coloured.describeFailuremoves tosrc/tutorial/failure.ts.bitsOf/numberOfare shared by the value editor and the tests.Not in this PR
Testing
npx vitest run(208 tests),npx tsc -p .andnpx biome check srcpass. New tests cover:🤖 Generated with Claude Code