Docsity

Notes on The Multi-Cycle CPU - Advanced Computer Architecture | CPSC 6155, Study notes of Computer Architecture and Organization

Toggle sidebar
bg1
The Multi–Cycle CPU
We have just seen that a CPU designed to complete the execution of
each instruction in a single clock cycle has two properties:
1. It is easy to design and easy to understand, and
2. It is unacceptably slow.
We say that the single–cycle CPU has CPI = 1; one clock cycle per instruction.
We now investigate a design in which CPI >1, in fact CPI 4. At first this might
appear to be slower, but remember the measure that we are trying to optimize.
The measure to minimize is the product CPI (Clock cycle time)Clock cycle time).
As an example, suppose that the single cycle CPU has a clock time of 1 nanosecond,
and that the multi–cycle CPU has a clock time of 200 picoseconds with CPI = 4.
For the single cycle CPU, we have CPI (Clock cycle time) = 1Clock cycle time) = 11 = 1 nanosecond
For the multi–cycle CPU, we have CPI (Clock cycle time) = 1Clock cycle time) = 40.2 = 0.8 nanosecond
In this section, we investigate speeding up the CPU clock at the cost of raising the
average CPI. We see that we get a faster CPU, but not fast enough.
In the next chapter, we keep the clock speed and lower the CPI; this is pipelining.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16

Partial preview of the text

Download Notes on The Multi-Cycle CPU - Advanced Computer Architecture | CPSC 6155 and more Study notes Computer Architecture and Organization in PDF only on Docsity!

The Multi–Cycle CPU

We have just seen that a CPU designed to complete the execution of each instruction in a single clock cycle has two properties:

  1. It is easy to design and easy to understand, and
  2. It is unacceptably slow. We say that the single–cycle CPU has CPI = 1; one clock cycle per instruction. We now investigate a design in which CPI >1, in fact CPI  4. At first this might appear to be slower, but remember the measure that we are trying to optimize. The measure to minimize is the product CPI(Clock cycle time)Clock cycle time). As an example, suppose that the single cycle CPU has a clock time of 1 nanosecond, and that the multi–cycle CPU has a clock time of 200 picoseconds with CPI = 4. For the single cycle CPU, we have CPI  (Clock cycle time) = 1Clock cycle time) = 1 1 = 1 nanosecond For the multi–cycle CPU, we have CPI  (Clock cycle time) = 1Clock cycle time) = 40.2 = 0.8 nanosecond In this section, we investigate speeding up the CPU clock at the cost of raising the average CPI. We see that we get a faster CPU, but not fast enough. In the next chapter, we keep the clock speed and lower the CPI; this is pipelining.

Selecting the Clock Speed

It should be obvious that we want the clock to be as fast as possible. What specifies the limits of possibility? We must recall that all commercial designs must have a margin of safety in setting the clock rate. This lead to the common practice of overclocking , in which a hacker would increase the CPU clock rate until errors occurred and then back it off a bit. It is obvious that the maximum clock rate is dependent on some aspect of the datapath. In the single–cycle CPU, the clock rate was set by the amount of time it took to complete the slowest machine language instruction. We discovered that this was LW. In other words, if it took one nanosecond to execute a Load Word instruction, then the maximum clock rate would be 1 GHz (Clock cycle time) = 11 nanosecond clock time). Recall that our discussion of the single–cycle CPU lead us to visualize the execution of each instruction as taking place in four or five distinct steps. Our multi–cycle implementation leads us to assign one clock cycle per step in execution of each instruction. Thus, some instructions have a CPI = 4 and some have a CPI = 5. Now the maximum clock rate is determined by the slowest phase of instruction execution and not by the slowest instruction.

Side Effects of the Multi–Cycle Implementation

One important side effect of this implementation is that a faster clock means a “hotter CPU”, one that radiates more heat. We must have a good cooling mechanism. Moreover, the cooling mechanism must be acceptable to the general public. Refrigerator type cooling systems are not likely to gain commercial acceptance for a home computer. Another important side effect is a direct consequence of the nature of sequential circuits. “At the end of a clock cycle, all data that is used in a subsequent clock cycle must be stored in a state element.” In a single–cycle CPU, these state elements will be almost always be registers that can be used by the programmer; these are in the ISA (Clock cycle time) = 1Instruction Set Architecture). In a multi–cycle CPU, the design requires some special registers to preserve data for a later step in the same instruction. These registers are not part of the ISA. These new registers fall into two classes:

  1. Those that must preserve data from one clock pulse to the next clock pulse, and
  2. Those that must preserve data across all clock pulses associated with one instruction. These must have an explicit write control signal to prevent their being updated on every clock pulse.

The New Registers

Here is a copy of the high–level view from the book. Note the five additional registers. The IR (Clock cycle time)Instruction Register) holds the instruction that is being executed. The contents of this register cannot change during the instruction execution; it is explicitly controlled. The MDR (Clock cycle time)Memory Data Register) holds the latest data read from memory. Often the contents are just a copy of those in the IR, but not always. The MDR holds data just read from memory until the next clock cycle during which the data are written to a register. The A, B, and ALUOut registers hold results from one clock pulse to the next one.

Comparison with the Boz–5: The MDR

Once again, this slide is for only those students who took CPSC 5155 from me when I was using the Boz series of computers as a design model. The MDR in the MIPS is somewhat similar to the MBR (Clock cycle time) = 1Memory Buffer Register) used by the BOZ designs. The main difference is that the BOZ–5 uses the MBR for all data and instructions to and from the memory; in particular the data to be copied into the IR. In order to clarify the difference in terminology between the MIPS and the BOZ series, I shall redraw part of Figure 5.26 (Clock cycle time) = 1or 5.27 or 5.28) using some plausible inferences. In other words, the MAR and MBR are considered part of the memory subsystem.

More Multiplexers

Another side effect of the multi–cycle implementation is the elimination of redundant functional units. In the single–cycle design, if a functional unit were used for multiple purposes, it had to be replicated as each unit could do only one thing in the one clock cycle that comprised the instruction execution. In the multi–cycle implementation, it is still the case that a functional unit can do only one thing during a clock cycle, but the execution of the instruction takes many cycles. The multi–cycle implementation allows each functional unit to be used for multiple purposes during the instruction execution, as long as it does only one thing per cycle. One result is that the design must either add multiplexers or upgrade the existing multiplexers for functional units that are shared for multiple purposes. In particular, replacing the single ALU and two dedicated adder units in the single–cycle CPU by a single ALU in the multi–cycle CPU demands additional multiplexers: a new one for the A input to the ALU and an expanded one for the B input. The A input to the ALU is now fed by a 2–to–1 multiplexer. The B input to the ALU is now fed by a 4–to–1 multiplexer.

Control of the PC (Clock cycle time)Program Counter)

There are three possible sources of input to the Program Counter. In addition, the Program Counter will always be updated once during the execution of an instruction and might be updated twice, with the second update value replacing the first. Possible values to be placed into the Program Counter are the following:

  1. The value (Clock cycle time) = 1PC) + 4, which is the address of the instruction following the one being executed. This update will occur in the first clock cycle.
  2. The value of the ALUOut register, which contains the address of the branch target. If this option is taken, the update will occur in the third clock cycle.
  3. The target address for a jump instruction, also on the third clock cycle. Update of the Program Counter is driven by two discrete signals: PCWrite and PCWriteCond. The function of each signal is suggested by its name. PCWrite Update the PC unconditionally PCWriteCond Update the PC if the branch condition is true. One might write the following Boolean equation, with Zero as the Boolean output signal from the ALU indicating that the two inputs to the ALU were equal. UpdatePC = PCWrite OR (Clock cycle time) = 1PCWriteCond AND Zero)

The Complete Datapath for the Multi–Cycle Implementation

This is just a copy of Figure 5.28 of the textbook. We now describe the control signals.

The 2–Bit Control Signals

There are three 2–bit control signals used in this design. One set controls the Arithmetic Logic Unit and two sets control 4–to–1 multiplexers. Name Binary Value Effect ALUOp 00 The ALU adds 01 The ALU subtracts 10 The ALU performs the function indicated by IR[5:0] ALUSrcB 00 The B input to the ALU comes from the B register 01 The B input to the ALU is the constant value 4 10 The B input to the ALU is the sign–extended 16–bit value from IR[15:0]; used for memory access 11 The B input to the ALU is the sign–extended 16–bit value of IR[15:0] left shifted by 2 bits; branch target PCSource 00 The PC will be updated by the value (Clock cycle time) = 1PC) + 4 01 The PC will be updated by the contents of ALUOut; this is a computed branch address. 10 The PC will be updated by IR[25:0] left shifted by 2 bits and concatenated with PC[31:28]. PC[31:28]¢IR[25:0]¢00 ** ** The book says PC + 4, because the PC is already pointing to the next instruction.

Instruction Steps in the Multi–Cycle Implementation

In this design, the execution of each instruction is broken into a number of steps, with one or more steps being executed per clock cycle. Some steps are inherently sequential; one thing must be done before another. Some steps can be done in parallel; these do not require the same datapath element. It is important to note that methods for accessing stand–alone registers differ from those to access registers in the register file. The reasons are due to the decoders used to select the write target and the multiplexors used to pass the contents of the register read. Again, the design could be based on the time to access general purpose registers, but this would slow down the access to the stand–alone registers. Each MIPS instruction executes in three to five of the following steps.

  1. Instruction fetch step.
  2. Instruction decode and register fetch step.
  3. Execution, address computation, or branch completion.
  4. Memory access or complete execution of R–type instructions.
  5. Memory read completion for the Load Word and other register loads.

The Multi–Cycle Implementation (Clock cycle time)Step 2)

2. Instruction decode, register fetch and compute target address IR[31:26] copied to the Control Unit and decoded A <= Register[IR[25:21]] B <= Register[IR[20:16]] ALUOut <= PC + (Clock cycle time) = 1 sign_extend(Clock cycle time) = 1IR[15:0] << 2) At the end of this step, the instruction will have been identified by the control unit. At this point, the CPU performs a number of operations that are likely to be useful, since they can be proven not to be harmful. The CPU can perform an unnecessary step without harm if that step does not take resources from a necessary step. The branch target address is computed and stored in the ALUOut register, in case the instruction is a branch and the branch is taken. Otherwise it will be overwritten. The values of the two “read registers” in the instruction are copied into the temporary registers A and B for possible input into the ALU on the next step. Using the instruction mix for the SPEC 2000 benchmark (Clock cycle time) = 1see the Example in section 5.5), we have the following probabilities: 87% probability that the A value will be used, and 52% probability that the B value will be used.

The Multi–Cycle Implementation (Clock cycle time)Step 3)

3. Execute R–type instructions, compute address, or complete the branch. At this point the control unit has decoded the instruction, so that the datapath operations are now determined by the type of instruction. We have four possible operations types here, each having its distinct requirements. Branch If Zero Then PC <= ALUOut, Else no action. The multiplexers feeding the A and B inputs to the ALU are set to pass the contents of the A and B registers respectively. The ALU is set to subtract and assert the discrete signal Zero if (Clock cycle time) = 1A – B) is zero. If (Clock cycle time) = 1A == B) the PC is updated to point to the branch target, otherwise the PC is not updated. This instruction ends and the next instruction is fetched. Jump PC <= PC[31:28] ¢ IR[25:0] ¢ 00 This is an unconditional jump; the value of the Program Counter is replaced by the jump address, this instruction ends, and the next instruction is fetched. Note that the textbook uses a different notation, {PC[31:28], IR[25:0], 2’b00}. Take the four bits PC[31:28], concatenate the 26 bits IR[25:0] and then add two zeroes.

The Multi–Cycle Implementation (Clock cycle time)Step 4)

Here the CPU has three options, two of which are related to memory reference. Complete R–type instruction Register[IR[15:11]] <= ALUOut Here the contents of the ALUOut register, containing the value computed in step 3, are written to the destination register. The instruction ends and the next instruction fetched. Memory Reference: Store Word Memory[ALUOut] <= B Here the contents of the ALUOut register are used as a memory address. The contents of the B register are copied directly to the memory input Write Data , and the discrete control signal MemWrite asserted to initiate update of the addressed memory word. The instruction ends and the next instruction is fetched. Memory Reference: Load Word MDR <= Memory[ALUOut] Here the contents of the ALUOut register are used as a memory address, the address of the word to be copied into the MDR. The discrete signal MemRead is asserted, causing the memory to be read and the MDR to be updated automatically.

The Multi–Cycle Implementation (Clock cycle time)Step 5)

Only the register load instructions require this fifth step.

5. Load register from memory Register[IR[20:16]] <= MDR The multiplexer feeding the Write Data input to the register file is set to copy the contents of the Memory Data Register into the target general–purpose register. The discrete control signal RegDst is not asserted, so the target register is selected by IR[20:16]. The instruction ends and the next instruction is fetched.