Processor Organization and RISC
Processor organization
The processor executes instructions via two operations:
- Move data from one place to another
- Perform data processing through ALU
The data are stored in registers inside CPU, and operations controlled by control signals generated by control units.
Data movement is controled by control signals, generated by the control unit:
A movement operation requires 2 control signals:
- Tell PC to put contnet onto CPU bus
- Tell MAR to get value from CPU bus
Other operations may require more control signals, such as:
- ALU operations
- Read/write external memory
Recall the different FDE stages of an instruction.
We can increase the throughput of the CPU by processing different stages of different instructions simultaneously, by having different hardware used for each stage, in one clock cycle.
Ideally, this increases the throughput be 1 instruction per clock cycle ().
Note: [modern processors] don't have memory operands, so no CO stage.
Pipeline hazards
Situations that prevent the next instruction rom entering the pipeline for execution:
When two instruction require the same hardware at the same clock cycle.
Solutions: Dedicated hardware; Separate cache
Example
FI
uses same resource as FO
(see below image)
Consider instructions in sequence, occurs when there is dependency of operands. Types of data hazards:
- Read after write (RAW) - writes to a register, and reads from it. (Hazard occurs if read before write)
- Write after read (WAR) - reads from a register, and writes to it. (Hazard occurs if write before read)
- Write after write (WAW) - writes to a register, and writes to it. (Hazard occurs if writes before )
Note: Only RAW occurs in pipeline, others occur in parallel systems (undiscussed).
Solutions: Re-arrange instructions if possible, depending on optimization; Data forwarding
Example
ADD EAX, EBX, EAX
and SUB ECX, EAX, ECX
(see below image)
When we don't know where to continue until branch instruction is executed. The FI
stage of next instruction cannot start until branch resolved.
Example
A technique to reduce control hazards, by guessing the outcome of a branch instruction. If the guess is correct, no penalty; if wrong, flush the pipeline and restart.
Reduced Instruction Set Computer (RISC)
Notes:
Ways to improving (reducing) execution time:
- Simplify instruction set and use hardwired logic
- Extensive pipelining
There is overall improvement in performance, as increase in instruction count (and code size) is usually very small.
Improvement when using registers
Consider the two set of instructions:
Without registers:
With registers:
- All instructions are register-register type except LOAD and STORE (which access memory)
- Fixed length and simple, fixed format instructions.
- Relatively few operations and addressing modes.
- Use of instruction pipelining, instruction level parallelism and extensive software and hardware techniques to eliminate pipeline disruption.
- Rely on optimizing compiler to enhance system performance.
- Note that these measures mentioned above can be applied to any processor design, and not limited to RISCs.
- Actually, RISC is a design philosophy where performance of CPU is enhanced.
- Nothing prevents a CPU designer from incorporating these measures into their CISC (Complex Instruction Set Computer).
- Nowadays, usually we will see some kind of hybrid design