Understanding Waveforms
Waveforms are the primary way to debug and verify digital circuits. They show how signal values change over time (clock cycles).
Reading Waveforms
Section titled βReading WaveformsβHardcamlβs waveform output uses ASCII art:
βSignalsββββββββββWavesββββββββββββββββββββββββββββββββββββββββββββββββclock ββββββ ββββ ββββ ββββ ββββ ββββ ββββ ββββ βββββ ββ ββββ ββββ ββββ ββββ ββββ ββββ ββββ ββββ ββclear ββ ββ ββββββββββββββββββββββββββββββββββββββββββββββββββββ ββenable ββββββββββββββββββββββββββββββββββββββββββββββββββββ ββ ββ ββ βββββββ¬βββββ¬βββββ¬βββββ¬βββββ¬βββββ¬βββββ¬βββββ¬βββββ¬βββββ¬βββout ββ 00 β 01 β 02 β 03 β 04 β 05 β 06 β 07 β 08 β 09 β ββ βββββββ΄βββββ΄βββββ΄βββββ΄βββββ΄βββββ΄βββββ΄βββββ΄βββββ΄βββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββSignal Types
Section titled βSignal Typesβ1-bit signals show high/low transitions:
ββββββ- Signal is high (1)(blank) - Signal is low (0)ββββ ββββ- Clock toggling
Multi-bit signals show hex values:
β 00 β 01 β 02 β- Values in each cycleβββββ΄βββββ΄ββββ- Value changes
Customizing Display
Section titled βCustomizing DisplayβControl waveform appearance with options:
Waveform.expect ~display_height:20 (* More vertical space *) ~display_width:80 (* Wider display *) ~wave_width:2 (* Wider waves per cycle *) wavesSelecting Signals
Section titled βSelecting SignalsβBy default, all signals are shown. Select specific signals:
Waveform.expect ~display_rules: [ Display_rule.port_name_is "out" ; Display_rule.port_name_is "enable" ] wavesTiming Diagram Tips
Section titled βTiming Diagram Tipsβ- Count cycles - Each vertical bar marks a clock edge
- Watch edges - Outputs change after the clock edge that triggered them
- Check setup - Inputs must be stable before the clock edge
VCD Export
Section titled βVCD ExportβFor complex debugging, download VCD files and open in GTKWave:
- Click Download VCD in the IDE
- Open in GTKWave or other waveform viewer
- Zoom, measure, and analyze signals
Next Steps
Section titled βNext Stepsβ- Nand2Tetris - Apply these skills building real circuits