System Integration & Testing
After building the datapath and control unit separately, you must integrate them into a complete CPU. Only when the control signals correctly drive the datapath (and the datapath feeds needed signals back, such as Zero) will programs execute correctly.
Experiment: Single-cycle CPU integration and validation
Section titled “Experiment: Single-cycle CPU integration and validation”Objectives
Section titled “Objectives”- Integrate datapath + control unit into a runnable single-cycle CPU.
- Debug end-to-end using small programs (ALU ops, memory ops, branches).
Environment
Section titled “Environment”- Simulator: Logisim Evolution
Task 1: Connect control signals
Section titled “Task 1: Connect control signals”- Place the ControlUnit in the datapath circuit.
- Replace manual control pins with tunnels, connected to the ControlUnit outputs.
- Probe signals such as
Instr,Extend/Imm,SrcA,SrcB,ALUControl,ALUResult,PCTarget, etc.
Task 2: Program 1 (arithmetic chain)
Section titled “Task 2: Program 1 (arithmetic chain)”Assembly:
addi x1, x0, 5 # x1 = 5addi x2, x0, 7 # x2 = 7add x3, x1, x2 # x3 = 12sub x4, x3, x1 # x4 = 7Hex:
0x00000000: 0x005000930x00000004: 0x007001130x00000008: 0x002081b30x0000000c: 0x40118233Check:
RegWriteis 1 only for instructions that write registers.- Final:
x1=5, x2=7, x3=12, x4=7.
Task 3: Program 2 (memory)
Section titled “Task 3: Program 2 (memory)”Assembly:
addi x1, x0, 0x100 # x1 = 0x100addi x2, x0, 42 # x2 = 42sw x2, 0(x1) # mem[0x100] = 42lw x3, 0(x1) # x3 = mem[0x100]sub x4, x3, x2 # x4 = 0Hex:
0x00000000: 0x100000930x00000004: 0x02a001130x00000008: 0x0020a0230x0000000c: 0x0000a1830x00000010: 0x40218233Check:
- On
SW:MemWrite=1, write address is ALUx1+imm. - On
LW: write-back selects memory data. - Final:
mem[0x100]=42, x3=42, x4=0.
Task 4: Program 3 (branch and loop)
Section titled “Task 4: Program 3 (branch and loop)”Assembly:
addi x1, x0, 3 # x1 = 3 (counter)addi x2, x0, 0 # x2 = 0 (sum)
loop:add x2, x2, x1 # sum += counteraddi x1, x1, -1 # counter--beq x1, x0, done # if counter==0 breakbeq x0, x0, loop # unconditional branch (always taken)
done:addi x3, x2, 0 # x3 = sum (expected 6)Hex:
0x00000000: 0x003000930x00000004: 0x000001130x00000008: 0x001101330x0000000c: 0xfff080930x00000010: 0x000084630x00000014: 0xfe000ae30x00000018: 0x00010193Check:
- For
beq x1,x0,done, ALU comparison producesZerocorrectly. - When
x1becomes 0, PC should jump from 0x10 to 0x18. - Final:
x3=6.
Results
Section titled “Results”- CPU circuit screenshot.
- Program results (final register/memory values).
- One debugging record (what signals you probed and how you found/fixed the issue).
Question
Section titled “Question”- This lab uses
beq x0, x0, labelfor an unconditional branch. Which hardware facts/signals make this always taken?