Single-cycle datapath
Type a MIPS program and its initial state and watch how the single-cycle datapath from the course notes runs it, one cycle per instruction: the path each instruction takes, the value on every wire and the control signals the control unit sets, with the exam table and its X. With the extensions from the problems: addi, slti, bne and jal. It runs in your browser, on your phone too.
How to use it
- Type the program with its labels and, below it, the registers and memory it starts with (for example
$s0 = 0x10010000andM[0x10010008] = 120). Or pick an example: one instruction of each type, the train ticket office, counting passes or a subroutine withjal. - Press Step: each step is one clock cycle. The drawing paints that instruction’s path in coral, writes the value of each signal and numbers the wires; below it you have the value of each number.
- Tap a piece of the drawing (the ALU, a multiplexer, the register file…) to see what it does and its values in that cycle.
- Switch on addi, slti, bne or jal to extend the datapath as in the problems: their signals (BranchNE, Link) and their new pieces appear.
- In Clock cycle you set the delay of each block and see how long each instruction type takes and how long the cycle lasts.
What each cycle does
In each cycle, the PC fetches the instruction, the control unit looks at op and sets its signals, the register file reads rs and rt, the ALU operates (add, subtract or whatever funct says) and, on the clock edge, whatever is due is written: a register, memory or nothing. At the same time the next PC is worked out: PC + 4, the branch target or the address of j.
The values come from the same model as the datapath and control unit articles (monociclo.py), checked cycle by cycle on more than 100,000 cycles of random programs.
The rules it follows
- The basic datapath does
add,sub,and,or,nor,slt,lw,sw,beqandj; if you type another one, it tells you. - Conditional branches count from PC + 4, as in the course notes and the exam; the control table is the one in the notes, with X where it does not matter.
- An
lworswwith an address that is not a multiple of 4 stops the run (QtSpim would raise an exception).
For the exam
The exam asks for the signal table of an instruction (with its X), the value on some wire or what has to be added to the datapath for a new instruction. Do it on paper and check it here; the challenge below gives you random instructions.
