Overview
This one‑pager is a complete walkthrough for building, exporting, simulating, and verifying the Lab 1 circuits in Digital → Verilog → GTKWave. It covers the logic (half/full adders), bus wiring with splitters/mergers, the role of *_top.v test benches, stimulus text files, iVerilog commands, wave inspection, edge‑case tests (signed/unsigned overflow), and a ready‑to‑use video script. Dark ASCII vibes included.
Lab1/ folder. Digital subcircuits must be discoverable from the current project directory; saving early avoids the “custom component not visible” gotcha.File Types & What They Do
*.dig— Your Digital schematics (source of truth for the logic).*.v— Verilog exports of your schematics (your DUT: Design‑Under‑Test).*_top.v— Test benches that instantiate your DUT, feed inputs, and check outputs.*_stim.txt— Stimulus/expected values consumed by the test benches.*_waves.vcd— Waveform dumps for GTKWave visualization.
Directory Layout (recommended)
Include the *_top.v and *_stim.txt files in your zip so the grader can re‑run your sims 1:1.
Toolchain & Commands
iVerilog Build + Run
iverilog -o half_adder.exe half_adder.v half_adder_top.v ./half_adder.exe # Windows: vvp half_adder.exe iverilog -o incrementer.exe incrementer.v incrementer_top.v ./incrementer.exe iverilog -o full_adder.exe full_adder.v full_adder_top.v ./full_adder.exe iverilog -o four_bit_adder.exe four_bit_adder.v four_bit_adder_top.v ./four_bit_adder.exe
GTKWave
gtkwave half_adder_waves.vcd # or: open GTKWave app → File → Open New Tab → select *_waves.vcd
Pro tip: expand the top‑level module, add only DUT I/Os (e.g., a, b, cin, sum, cout, y, cry, overfl) to keep waves clean.
Task 1‑1 • 1‑Bit Half Adder
Logic
sum = A ⊕ B, cry = A · B
| A | B | cry | sum |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 0 |
Export & Sim
- Save schematic as
half_adder.dig. - Export Verilog →
half_adder.v. - Run iVerilog with
half_adder_top.vand openhalf_adder_waves.vcd.
cry vs carry).Task 1‑2 • 4‑Bit Incrementer
Design
Build from four half adders. Use splitters/mergers for 4‑bit a → y, controlled by inc. When inc=0, pass‑through; when inc=1, add 1 (propagate carries).
Sim Check
- For
a=0x5, inc=0⇒y=0x5,cry=0. - For
a=0xF, inc=1⇒y=0x0,cry=1.
Task 1‑3 • 1‑Bit Full Adder
Logic
sum = A ⊕ B ⊕ Cin
cout = majority(A,B,Cin) = A·B + A·Cin + B·Cin
Digital hint: set XOR and OR to 3 inputs in properties.
Stim Bits (full_adder_stim.txt)
[7:6 unused][5 cout][4 sum][3 unused][2 cin][1 a][0 b]Task 1‑4 • 4‑Bit Full Adder
Design
Cascade four 1‑bit full adders, split/merge 4‑bit buses for a and b. Outputs: y[3:0], cout (unsigned carry out), overfl (signed overflow).
cout vs overfl.Classic Edge Cases
- Unsigned overflow: F + 1 →
cout=1 - Signed overflow (+ + → −): 7 + 4 → overflows (positive + positive yields negative)
- Signed overflow (− − → +): (8) + (8) → overflows (negative + negative yields positive)
Testing & Stimulus Files
four_bit_adder_stim.txt bit map
Each row like E_0_F_F_? is five hex digits separated by underscores for readability.
Example Test Rows & Motives
| Stimulus | What it checks |
|---|---|
0_0_0_0_0 | Stuck‑at‑1 sanity (no wires tied high) |
0_3_0_1_2 | Simple add: 1 + 2 → y=3 |
0_4_1_1_2 | Carry‑in handling |
0_F_0_F_0 | Max + 0 |
1_0_0_F_1 | Smallest unsigned overflow |
3_2_0_9_9 | Signed overflow (−7 + −7) |
2_8_0_7_1 | Smallest signed overflow (+7 + +1) |
2_9_1_4_4 | Signed overflow with Cin (4 + 4 + 1) |
Stim Harness Pattern
iverilog -o four_bit_adder.exe four_bit_adder.v four_bit_adder_top.v ./four_bit_adder.exe # If a mismatch appears, the printed index lines up with your test row number (0..15).
Common Pitfalls
- Wrong signal names: Use
cry(not carry) where required. - Custom component not visible: Save a new schematic into
Lab1/first soComponents → Customrefreshes. - Splitter order: Put MSB on top (
[3..0]) consistently for readability. - Overfl vs cout: Know which flag means signed vs unsigned overflow.
Quick Sanity Matrix
| Case | Inputs | Expect |
|---|---|---|
| Increment wrap | a=F, inc=1 | y=0, cry=1 |
| Unsigned carry | a=F, b=1, cin=0 | cout=1 |
| Signed overflow (+ +) | a=7, b=4, cin=0 | overfl=1 |
| Signed overflow (− −) | a=8, b=8, cin=0 | overfl=1 |
Submission Zip Checklist
- All
*.digschematics - All exported
*.vDUT files - All provided
*_top.vtest benches - All provided/edited
*_stim.txtfiles *_waves.vcdoptional but helpful- Screenshot images (schematics + waves)
my_answers.pdf(completed template)
Fast Video Script (teleprompter‑ready)
- Intro (10–15s): “Hi, I’m Lalo Morales — Lab 1: Half Adder, Full Adder, 4‑bit Incrementer/Adder. I’ll show schematics and GTKWave results.”
- Half Adder (~20s): Show XOR/AND, truth table match in waves.
- Incrementer (~20s): Four half adders + splitters.
inc=0pass‑through,inc=1+1, wrap at F→0 withcry=1. - Full Adder (~20s): 3‑input XOR/OR, sum & carry logic demo.
- 4‑bit Adder (~30–40s): Cascaded full adders, signed vs unsigned flags, edge‑case tests all pass.
- Close (10–15s): “All circuits verified. Thanks!”
FAQ — Why include *_top.v?
They’re the test benches. They instantiate your DUT, feed vectors from *_stim.txt, and auto‑check expected outputs. Without them, the grader can’t re‑run your sims.
GTKWave looks noisy — what do I add?
Add only high‑level I/Os: a, b, cin, y, cout, overfl, inc, cry. Ignore internal s# wires unless debugging.