Skip to content

8. Single-Cycle CPU

We now have enough components to make a single-cycle machine, where each instruction takes one clock cycle to execute.

alt text

Here is out CPU:

alt text

Whow, that's a lot! The instruction memory takes a PC, and spits out a instruction, they are then decoded. The control decides what happens from those decoded instructions. The control also has a ALU control for selecting which operation the main ALU should do. Also notice that immediates are signed. The whole block of registers, ALU, and data memory is the execution phase. The top part with the shift, ALU, and MUX all handle the branches.

R-Type

The R-type starts with the PC, then moves on to the decoding phase. The two registerss (rs, rt) are read, and the control unit determines the signals. The ALU performs the operation according to the lower 6-bits of the instruction (func). The result is written back to the register file (rd).

lw Instruction

The instruction is read and PC is incremeted. One register (rs) is read, and the control unit determines the signals. The ALU adds the register value with the immediate (offset) extended to 32-bits. The ALU result is the address we want to read. The memory is read in that address. The memory data is stored in the regsiter (rt).

beq Instruction

The instruction is read and PC is incremeted. Two registers (rs, rt) are read, and the control unit determines the signals. The immediate is shifted and added to PC+4. The ALU subtracts the contents of both registers. Depending on the result, the value of PC is set.

Jump Instruction

Wait, theres acutally more to our CPU.

alt text

There we go. Now, the instruction is read and PC is incremented. The new PC value is obtained by shifting the target field of the instruction left by 2.

Clocking Issues

Remember clocking? Well... Memory is slow, really slow.

alt text

The second one is an example of memory's clock.

Any instruction executes during a single clock cycle and the length of the clock cycle must accommodate the longest instruction. So, faster instruction waste a lot of cycle time.

alt text

Next Page →