The Four Step Process

Read time: 5 minutes (1286 words)

The processor works through one instruction using a four-step process:

  • Fetch - get part of the next instruction
  • Decode - analyze that instruction part and get any other data needed for this instruction. Finally update the PC so it points to the next instruction.
  • Execute - if needed, activate the ALU to perform some action
  • If needed, update memory with the result of this step

We need to assess how each step really works, by examining how the machine will perform these individual steps.

We need to work through each of these steps in detail to see how each instruction will be processed. In doing this, we define exactly how the controller will sequence all of the internal components in our simulator!

Fetch

Fetch is pretty easy. The Controller maintains a single register that always points to the next instruction to be processed in the memory area holding the program code. We will define holding registers that we can attach to wires so this information can be transmitted to the program memory unit:

* t0:CADDR <- PC            // transfer PC to controller address register
* t1:MADDR <- CADDR         // transfer address to code memory unit
* t2:MDATA <- IMEM[MADDR]   // retrieve desired instruction part (16-bits)
* t3:MDATA <- CIR1          // transfer instruction to Controller IR1 register

This sequence takes four steps to complete. We will call these steps “microcycles” and the controller will sequence the machine to accomplish this transfer.

Component Enable Ports

To make this happen, we will add an “enable” line on each component. The controller will set this line before activating the component.