Professional Documents
Culture Documents
Estructura y Función de La CPU V5
Estructura y Función de La CPU V5
William Stallings
Computer Organization
and Architecture
9th Edition
Chapter 14
Processor Structure and Function
LEARNING OBJECTIVES
After studying this chapter, you should be
able to:
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
ALU
Control
Unit
System
Bus
Status Flags
Registers
Shifter
Arithmetic
and
Boolean
Logic
Control
Unit
Control
Paths
Categories:
Referenced by means of • General purpose
the machine language • Can be assigned to a variety of functions by
the programmer
that the processor • Data
executes • May be used only to hold data and cannot
be employed in the calculation of an
operand address
• Address
• May be somewhat general purpose or may
be devoted to a particular addressing mode
• Examples: segment pointers, index
registers, stack pointer
• Condition codes
• Also referred to as flags
• Bits set by the processor hardware as the
result of operations
Table 14.1
Condition Codes
Advantages Disadvantages
1. Because condition codes are set by normal 1. Condition codes add complexity, both to
arithmetic and data movement instructions, the hardware and software. Condition code
they should reduce the number of bits are often modified in different ways
COMPARE and TEST instructions needed. by different instructions, making life more
2. Conditional instructions, such as BRANCH difficult for both the microprogrammer
are simplified relative to composite and compiler writer.
instructions, such as TEST AND 2. Condition codes are irregular; they are
BRANCH. typically not part of the main data path, so
3. Condition codes facilitate multiway they require extra hardware connections.
branches. For example, a TEST instruction 3. Often condition code machines must add
can be followed by two branches, one on special non-condition-code instructions for
less than or equal to zero and one on special situations anyway, such as bit
greater than zero. checking, loop control, and atomic
semaphore operations.
4. Condition codes can be saved on the stack 4. In a pipelined implementation, condition
during subroutine calls along with other codes require special synchronization to
register information. avoid conflicts.
+
Control and Status Registers
Four registers are essential to instruction execution:
If interrupts are
Read the next enabled and an
Interpret the opcode
instruction from interrupt has occurred,
and perform the
memory into the save the current
indicated operation
processor process state and
service the interrupt
Instruction Cycle
Fetch
I nterrupt I ndirect
Execute
Multiple Multiple
operands results
No
Instruction complete, Return for string interrupt
fetcth next instruction or vector data
PC M AR
M emory
Control
Unit
IR M BR
M AR
M emory
Control
Unit
M BR
PC M AR
M emory
Control
Unit
M BR
Laundry Example
Ann, Brian, Cathy, Dave each have one
A B C D
load of clothes to wash, dry, and fold
Washer takes 30 minutes
6 PM 7 8 9 10 11 Midnight
Time
30 40 40 40 40 20
T
A
a
s
k B
O C
r
d D
e
r • Pipelined laundry takes 3.5 hours for 4 loads
Pipelining Lessons
Discard
(b) Expanded view
1 2 3 4 5 6 7 8 9 10 11 12 13 14
I nstruction 1 FI DI CO FO EI WO
I nstruction 2 FI DI CO FO EI WO
I nstruction 3 FI DI CO FO EI WO
I nstruction 4 FI DI CO FO EI WO
I nstruction 5 FI DI CO FO EI WO
I nstruction 6 FI DI CO FO EI WO
I nstruction 7 FI DI CO FO EI WO
I nstruction 8 FI DI CO FO EI WO
I nstruction 9 FI DI CO FO EI WO
1 2 3 4 5 6 7 8 9 10 11 12 13 14
I nstruction 1 FI DI CO FO EI WO
I nstruction 2 FI DI CO FO EI WO
I nstruction 3 FI DI CO FO EI WO
I nstruction 4 FI DI CO FO
I nstruction 5 FI DI CO
I nstruction 6 FI DI
I nstruction 7 FI
I nstruction 15 FI DI CO FO EI WO
I nstruction 16 FI DI CO FO EI WO
Decode
DI I nstruction
Calculate
CO Operands
Yes Uncon-
ditional
Branch?
Six Stage No
Instruction Pipeline FO
Fetch
Operands
Execute
EI I nstruction
Update Write
PC
WO Operands
Empty
Pipe Yes Branch No
or
I nter
-rupt?
1 I1 1 I1
2 I2 I1 2 I2 I1
3 I3 I2 I1 3 I3 I2 I1
4 I4 I3 I2 I1 4 I4 I3 I2 I1
5 I5 I4 I3 I2 I1 5 I5 I4 I3 I2 I1
6 I6 I5 I4 I3 I2 I1 6 I6 I5 I4 I3 I2 I1
Time
7 I7 I6 I5 I4 I3 I2 7 I7 I6 I5 I4 I3 I2
Alternative Pipeline 8 I8 I7 I6 I5 I4 I3 8 I 15 I3
Depiction 9 I9 I8 I7 I6 I5 I4 9 I 16 I 15
10 I9 I8 I7 I6 I5 10 I 16 I 15
11 I9 I8 I7 I6 11 I 16 I 15
12 I9 I8 I7 12 I 16 I 15
13 I9 I8 13 I 16 I 15
14 I9 14 I 16
D D D EI D WO D
Instruction i D DI D CO FO (Write
FI (Calculate (Fetch
(Execute
El Tiempo de Ciclo es el tiempo necesario para que un conjunto de
instrucciones avance una etapa a través del cauce
max[i]+ d m + d 1≤ i ≤ k
Donde:
i : retardo de tiempo de circuitería de la i-ésima etapa del cauce
m : máximo retardo de etapa
k: número de etapas del cauce de instrucciones
d: retardo de tiempo de un registro (equivalente a un pulso de reloj ), m d
Pipeline Performance
Para ejecutar n instrucciones sin saltos en un cauce de k etapas
se requiere un tiempo total Tkn
Tkn [k+(n-1)]
Speedup Factors
with Instruction Aquí, en el limite (n ) la velocidad se
Pipelining incrementa en un factor k.
Also referred to as a
pipeline bubble
+
Clock cycle
1 2 3 4 5 6 7 8 9
I1 FI DI FO EI WO
I nstrutcion
I2 FI DI FO EI WO
Resource I3 FI DI FO EI WO
Hazards I4 FI DI FO EI WO
I3 FI DI FO EI WO
I4 FI DI FO EI WO
Hazard
Figure 14.16 Example of Data Hazard
+
Data Hazards
A data hazard occurs when there is a conflict in the
access of an operand location
+
Types of Data Hazard
Read after write (RAW), or true dependency
An instruction modifies a register or memory location
Succeeding instruction reads data in memory or register location
Hazard occurs if the read takes place before write operation is
complete
Drawbacks:
• With multiple pipelines there are contention delays
for access to the registers and to memory
• Additional branch instructions may enter the pipeline
before the original branch decision is resolved
Prefetch Branch Target
Benefits:
Instructions fetched in sequence will be available without the usual
memory access time
If a branch occurs to a target just a few locations ahead of the address of
the branch instruction, the target will already be in the buffer
This strategy is particularly well suited to dealing with loops
Very good for small loops or jumps (secuencias IF-THEN e IF-THEN-ELSE)
Used by CRAY-1, Motorola 68010
Yes
Not Taken
Taken
Not Taken
Predict Predict Not Taken
Not Taken Not Taken
Taken
+
address
Select
M emory
E Branch M iss
Handling
Next sequential
address
I PFAR Branch
Select
Lookup
Branches
M emory
Update
state
Decode stage 1
All opcode and addressing-mode information is decoded in the D1 stage
3 bytes of instruction are passed to the D1 stage from the prefetch buffers
D1 decoder can then direct the D2 stage to capture the rest of the instruction
Decode stage 2
Expands each opcode into control signals for the ALU
Also controls the computation of the more complex addressing modes
Execute
Stage includes ALU operations, cache access, and register update
Write back
Updates registers and status flags modified during the preceding execute
stage
+ Fetch D1
Fetch
D2
D1
Fetch
EX
D2
D1
WB
EX
D2
WB
EX WB
M OV Reg1, M em1
M OV Reg1, Reg2
M OV M em2, Reg1
80486
Instruction Fetch D1 D2 EX WB M OV Reg1, M em1
Pipeline
Fetch D1 D2 EX M OV Reg2, (Reg1)
Fetch D1 D2 EX WB CM P Reg1, I mm
Fetch D1 D2 EX Jcc Target
Fetch D1 D2 EX Target
31 21 16 15 0
I V V A V R N IO O D I T S Z A P C
I I
D P F C M F T PL F F F F F F F F F
M M X Registers
Exceptions
Generated from software and is provoked by the execution of an
instruction
Processor detected
Programmed