CRAFT cycle · Mon 5/25 · merged D1+D2 session — Part 2 of 2
HDL for Digital System Design · UCF ECE · Barcelona Summer 2026
| Phase | Time | Activity |
|---|---|---|
| 🌍 Contextualize | 10 min | Binary data in the city — metro card, baggage tag, BCN airport |
| ⚠️ Reframe | 15 min | wire ≠ variable · reg ≠ register · operators as gates |
| 🛠 Assemble | 70 min | 2:1 mux → 4:1 mux → ripple-carry adder → 7-seg decoder |
| 🛡 Fortify | 45 min | Sim every block · width-mismatch hunt · structural variant |
| 🔗 Transfer | 10 min | Debrief · Tue catch-up · preview Day 3 + Sagrada Família |
▸ Phase 1 of 5 · ~10 min
Binary data is in everything around you in Barcelona
Learn how HDL represents binary data — single bits, bus-width vectors, slices, concatenations — and the operators that move them around.
Every system you've seen since landing in Barcelona uses these primitives. Today you learn the syntax.
▸ Phase 2 of 5 · ~15 min
Sharper lens on the pre-class videos (V1 + V2, watched before arrival)
wire ≠ Variable. reg ≠ Register."Variables are storage boxes I put values into. wire stores a value; reg is a register."
wire is a physical connection — no storage. reg means "the simulator needs to remember this between events" — it might be a register, or it might be combinational. SystemVerilog fixes this with logic.
assign y = sel ? a : b; // 2:1 mux — one wire from two
assign y = s[1] ? (s[0] ? d : c)
: (s[0] ? b : a); // 4:1 mux nested
assign d = a + b; // adder (synth produces real gates)
assign m = {nibble, 4'b0}; // concat — pad with zeros
assign r = {4{1'b1}}; // replication — 4'b1111
if/else, every case, every conditional in HDL eventually becomes muxes. Internalise that mental picture now — it pays off on Day 3.
▸ Phase 3 of 5 · ~70 min · You build
Four blocks. Each one ends with bits on the board.
? : operator. Buttons for select & data, LED for output.full_adder module, instantiate four times. First taste of hierarchy.module mux_2to1 (
input wire a, b,
input wire sel,
output wire y
);
assign y = sel ? a : b;
endmodule
Map to the Go Board:
sel ← Button 0 · a ← Button 1 · b ← Button 2y → LED 0Widen to 4-bit inputs ([3:0]) once the 1-bit version is solid.
module full_adder (
input wire a, b, cin,
output wire sum, cout
);
assign sum = a ^ b ^ cin;
assign cout = (a & b) | (cin & (a ^ b));
endmodule
module adder4 (
input wire [3:0] a, b,
input wire cin,
output wire [3:0] sum,
output wire cout
);
wire [3:0] c;
full_adder fa0 (.a(a[0]), .b(b[0]), .cin(cin), .sum(sum[0]), .cout(c[0]));
full_adder fa1 (.a(a[1]), .b(b[1]), .cin(c[0]), .sum(sum[1]), .cout(c[1]));
full_adder fa2 (.a(a[2]), .b(b[2]), .cin(c[1]), .sum(sum[2]), .cout(c[2]));
full_adder fa3 (.a(a[3]), .b(b[3]), .cin(c[2]), .sum(sum[3]), .cout(cout));
endmodule
Four instances of the same module. This is what HDL hierarchy looks like.
module hex_to_7seg (
input wire [3:0] hex,
output reg [6:0] seg // {a,b,c,d,e,f,g}
);
always @(*) begin
case (hex)
4'h0: seg = 7'b1111110;
4'h1: seg = 7'b0110000;
4'h2: seg = 7'b1101101;
// ... fill in 3 through F
default: seg = 7'b0000000;
endcase
end
endmodule
default clause — always — to avoid latch inference (we'll dive into that tomorrow).
▸ Phase 4 of 5 · ~45 min · Verify · test · harden
Make every block earn its place
# Provided testbenches — run each one
cd labs/week1_day02/ex2_mux_hierarchy/starter && make sim
cd labs/week1_day02/ex3_adder/starter && make sim
cd labs/week1_day02/ex4_seven_seg/starter && make sim
sel × inputs combinationDon't program the board until all three TBs print "0 failed." Yesterday's Day-1 workflow, applied four times today.
wire [3:0] sum;
wire [3:0] a, b;
assign sum = a + b + 1'b1; // ⚠ Yosys may warn — width inference
// The literal 1'b1 is 1-bit; adder
// result is 5-bit (with carry).
4'd1 for sized literals, declare sum as [4:0], or $signed when intent is signed.sel low → LED reflects b; flip sel → LED reflects a.s[1], s[0]) combinations route the correct input..pcf); read sum on LEDs.0000 → 1111 on the input switches — both displays must light correctly. Phone-camera a 0–F sweep.▸ Phase 5 of 5 · ~10 min
What carries forward
① Vectors are universal. Every bus on every chip — AXI, UART, AHB — is a Verilog vector.
② Muxes are the substrate of choice. Every conditional becomes one.
③ Hierarchy is how big designs stay sane. Today: a 4-bit adder from 4 full-adders. Week 4: a UART from 4 sub-blocks.
④ Read the synthesis log. Warnings = future bugs.
Tue 5/26 is a catch-up block: finish board bring-up and the combined Day 1+2 lab. No new material — instructor-supported time to get everyone level.
Wed 5/27 (Day 3) brings always @(*), if/else, case — and the #1 beginner synthesis bug: latch inference. You'll build a 4-bit ALU and use yosys show to see if/else vs case.
Gaudí's structural models were essentially combinational: load in → shape out, no memory of sequence. Notice the branching geometry — it's a physical if/else tree. We open Day 3 with your photos.
🔗 End of Day 1+2 · Disfruta Barcelona
You now have the vocabulary to describe any combinational circuit.
Day 3 puts it inside always blocks — and shows you what can go wrong.