Professional Documents
Culture Documents
Lect 2
Lect 2
Agenda
2 Processor Organization
3 Instruction Cycle
4 Instruction Pipelining
CPU
ALU
MBR I/O BR
Internal
bus
MAR Main
memory
PC IR CU
Instruction format
0 3 4 15
0 1 15
Size
Sign
instruction argument
Operation
Interrupt cycle
Interrupt
execution
STOP
ADDRESS BUS
ADDRESS BUS
Move 104
AC MBR Address Content
100 Move 104
ALU 101 Add 105
102 Store 106
103 Stop
104 3
PC PC + 1 105 5
READ
PC IR CU
106
101 CONTROL BUS
MAR 100
ADDRESS BUS
Move 104
AC MBR Address Content
100 Move 104
ALU 101 Add 105
IR MBR 102 Store 106
103 Stop
Move 104 104 3
105 5
READ
PC IR CU
106
101 CONTROL BUS
MAR 100
ADDRESS BUS
Move 104
AC MBR Address Content
100 Move 104
ALU 101 Add 105
102 Store 106
103 Stop
CU IR
104 3
Move 104
105 5
READ
PC IR CU
106
101 CONTROL BUS
MAR 100
ADDRESS BUS
Processor-memory
data transfer between CPU and memory
Processor – input/output
data transfer between CPU and input/output module
Data processing
Arithmetic or logical operations on the data
Change of the instruction execution order (for example, jump)
Control
Combination of the above
ADDRESS BUS
Add 105
AC MBR Address Content
100 Move 104
ALU 101 Add 105
102 Store 106
IR MBR
103 Stop
CU IR 104 3
Add 105
105 5
READ
PC IR CU
106
101 CONTROL BUS
MAR 101
ADDRESS BUS
Interrupts
Examples of interrupts
User program I/O program User program I/O Program
1 1
4 4
WRITE WRITE
I/O instruction
I/O instruction
2a
2 @ Interrupt
5 2b execution
program
WRITE WRITE
Stop 3a 5
3 @
3b
Stop
Interrupt cycle
Multiple interrupts
Interrupt nr 2
Interrupt nr 2
Processor Organization
Processor Requirements:
Fetch instruction
The processor reads an instruction from memory (register,
cache, main memory)
Interpret instruction
The instruction is decoded to determine what action is required
Fetch data
The execution of an instruction may require reading data from
memory or an I/O module
Process data
The execution of an instruction may require performing some
arithmetic or logical operation on data
Write data
The results of an execution may require writing data to
memory or an I/O module
Registers
1. User-visible Registers
General Purpose
Data
Address
Condition Codes
Instruction Cycle
Pipelining
Instruction Prefetch
Without prefetch:
Instruction 1 Instruction 2 Instruction 3 Instruction 4
With prefetch:
Instruction 1 fetch exec
Instruction 2 fetch exec
Instruction 3 fetch exec
F D E F D E F D E F D E
Instruction 1 F D E
Instruction 2 F D E
Instruction 3 F D E
Instruction 4 F D E
Pipelining Strategy
Alternative Pipeline
Depiction
Pipeline Hazards
Resource Hazards
A resource hazard occurs when two or more instructions that
are already in the pipeline need the same resource
The result is that the instructions must be executed in serial
rather than parallel for a portion of the pipeline
A resource hazard is sometimes referred to as a structural
hazard
Resource Hazard
Data Hazard
A data hazard
occurs when
there is a
conflict in the
access of an
operand
location
Control Hazard
Also known as a branch hazard
Occurs when the pipeline makes the wrong decision on a
branch prediction
Brings instructions into the pipeline that must subsequently
be discarded
Multiple Streams
Loop Buffer
Branch Prediction