PCSrcRegWriteALUSrcALUOpMemToRegOutWriteHaltZCNimmrd rsmemPC0+2NEXT PC010 02214 03451 006E0 00818 03101C 01126B 0014D0 0C1600 00IR—CONTROL UNIT01r00r10r20r300101010110MUX010101-10MUX010101OUT–00000PC
Lit wire with moving dashes: a value is travelling on it nowLamps: the control signals (ALUOp lit when the ALU is used; its operation shows on the ALU), flags Z C N and the clock; a glowing lamp is 1White tokens: values moving between parts; the PC marker shows which instruction is nextBoxes with numbers: PC, memory, IR, registers and the output portA single-cycle CPU runs one instruction per clock cycle: fetch the instruction PC points to, decode it in the control unit, execute it in the ALU, write the result back, and update PC. Every value shown comes from TINY-8's reference simulator running the course's example program: it prints 5, then counts r2 down to zero with SUB, the Z flag and JNZ. In a single-cycle CPU the instruction is simply the memory's output: PC does not change until the edge at the end of the cycle, so those wires hold the instruction steady all cycle long. We label them IR (Harris and Harris, section 7.3).

The parts

  1. A program is just numbers in memory. TINY-8's example is 9 instructions of 2 bytes each, 18 bytes in all. The program counter, PC, holds the address of the next instruction. It starts at 0.

One cycle, phase by phase

Running the program

The loop

Cycle time

Inside the cycle

;; step 1/12 · program
;; about: Memory, Program counter
addr  bytes   instruction
   0  10 02   LDI r0, 2
   2  14 03   LDI r1, 3
   4  51 00   ADD r0, r1
   6  E0 00   OUT r0
   8  18 03   LDI r2, 3
  10  1C 01   LDI r3, 1
  12  6B 00   SUB r2, r3
  14  D0 0C   JNZ 12
  16  00 00   HALT

loop: is address 12 (the JNZ jumps there)

PC, the registers, the flags and the output port are all clocked state: they change only at the rising clock edge that ends the cycle. Everything between edges is combinational logic settling. Delays are the textbook example values for a 65 nm process in Harris and Harris, Digital Design and Computer Architecture (2nd ed.), Table 7.6: clock-to-Q 30 ps, memory read 250 ps, register file read 150 ps, multiplexer 25 ps, ALU 200 ps, register file setup 20 ps. As in their analysis, the control unit's delay is assumed to be off the critical path. The rule period ≥ clock-to-Q + logic + setup is the one from the Clocks and timing lesson.