Repository navigation
Remove exercise leaks, draw waveforms in Module 5 - #22
Merged
Merged
Conversation
The test of the PipelineFlush exercise, in 5.6 and in PipelinedSpec, compared each output with an expression that was the answer. It now runs three short programs on the pipelined core and compares them with the golden model: stores on the wrong path of a jump, stores behind a halt, and a jump behind a halt. Together they catch every wrong value of any one flush output, checked by trying each one.
The hazard list of 5.7 and ForwardingSpec ran the very program the 5.9 ForwardsX0 exercise asks students to find. The forwarding unit test still checks that x0 is never forwarded.
Synthesis does not report how fast a core's clock can run; place and route does, as 5.10 explains, with nextpnr outside the image.
The two notebooks talked about waveforms but only printed tables. riscv.Waves draws per-cycle samples as an SVG timing diagram: a clock, one-bit lanes, and buses as bands with their values. 5.8 draws the UART frame of 'H' once the transmitter passes its test, and 5.9 draws the forwarding waveform with the cycle where the seeded bug forwards the older result highlighted.
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.
Module 5 gave away two exercise answers, made one wrong claim about timing, and talked about waveforms in 5.8 and 5.9 without showing any. This removes the leaks, corrects the claim, and adds a small SVG waveform drawer that the two notebooks use.
The 5.6 PipelineFlush test (notebook and PipelinedSpec) used to state the answer as expected values. It now runs three short programs on the pipelined core against the golden model: stores on the wrong path, stores behind a halt, and a jump behind a halt. I checked it by mutation: each of the 45 wrong truth tables for a single flush output fails at least one program, and the correct one passes. The program that 5.9 asks students to find for ForwardsX0 was listed verbatim in 5.7 and ForwardingSpec; it is gone, and the Forward unit test still checks x0. 5.7 credited synthesis with reporting clock speed; it is place and route.
riscv.Waves draws per-cycle samples (from a Vcd or a test log) as an SVG timing diagram: a clock lane, one-bit lanes, and buses as bands with their values. It formats numbers with Locale.ROOT and draws x/z as a grey band. 5.8 draws the UART frame of 'H' once the transmitter passes, with bit names taken from the logged busy and txd. 5.9 draws the forwarding waveform and highlights the cycle where the seeded bug forwards the older result. A notebook shows the drawing only when its outputs are trusted, which is always the case for cells the student runs.
Verified in the Docker image:
Codex, agy and Claude each reviewed the changes in two rounds, and their findings are addressed.
Summary by cubic
Module 5 no longer gives away two exercise answers, corrects a wrong claim about clock speed, and adds a small SVG waveform drawer (
riscv.Waves) that notebooks 5.8 and 5.9 use to show what they previously only described.PipelineFlushtruth-table test with three short programs run against the golden model, so the expected flush values are no longer stated as the answer.x0forwarding program from 5.7 andForwardingSpec; the forwarding unit test still verifiesx0is never forwarded. The 5.9 exercise previously gave away this answer verbatim.riscv.Waves, which draws per-cycle samples (from a VCD or a test log) as an SVG timing diagram with a clock lane, one-bit lanes, and buses as value bands; x/z draw as grey bands and numbers format withLocale.ROOT.'H'once the transmitter test passes; 5.9 draws the forwarding waveform and highlights the cycle where the seeded bug forwards the older result.PipelinedSpecgains a "jump behind a halt" program; thePipelineFlushunit test is replaced by program checks.tools/check-solutions.sh(72 tests pass), notebook runs with and without solutions,tests/test_notebooks.py, scalafmt, and pre-commit.Written for commit 428cfac. Summary will update on new commits.