Lec03 - Processor Structure and Function
Lec03 - Processor Structure and Function
Lec03 - Processor
Structure and Function
+ 2
Contents
Processor organization
Register organization
Instruction cycle
Instruction pipelining
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
Register Organization
Within the processor there is a set of registers
that function as a level of memory above main
memory and cache in the hierarchy
Categories:
• General purpose
• Can be assigned to a variety of functions by
Referenced by means of the programmer
the machine language • Data
that the processor
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
10
Table 14.1
Condition Codes
+ 11
Example
Microprocessor
Register
Organizations
+ 14
Intel 8086
16-bit
Every register is special purpose
4 data, 4 pointer and index, and 4 segment registers
Intel 80386
32-bit - extension of the 8086
Includes the
following
Instruction
stages:
Cycle
If interrupts are
enabled and an
Read the next
Interpret the opcode interrupt has
instruction from
and perform the occurred, save the
memory into the
indicated operation current process state
processor
and service the
interrupt
16
Instruction Cycle
+ 17
Indirect stage
1
2 3 4
5
6
5 5
+ 20
1
2
3
1 3
+ 22
2 2
1 3
+ 24
Pipelining Strategy
To apply this
concept to
instruction
Similar to the use of execution we must
an assembly line in recognize that an
a manufacturing instruction has a
plant number of stages
Pipeline Operation
The Effect of a Conditional Branch 29
Six Stage
Instruction Pipeline
+
Alternative Pipeline
Depiction
+ 32
Calculating Performance
Sk =
T1, n
=
(9 )(6 )(1)
=
54
= 3 .86
Tk , n [6 + (9 − 1)]1 14
+
Speedup Factors
with Instruction
Pipelining
Also referred to as a
pipeline bubble
+
Resource Hazards
A resource hazard is
sometimes referred to as
a structural hazard
38
Data
Control Hazard
Also known as a branch hazard
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
42
Loop Buffer
Small, very-high speed memory maintained by the
instruction fetch stage of the pipeline and containing the n
most recently fetched instructions, in sequence
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
Branch Prediction
Taken/not taken
switch
48
Branch Prediction State Diagram
+ 49
Fetch
Objective is to fill the prefetch buffers with new data as soon as the old
data have been consumed by the instruction decoder
Operates independently of the other stages to keep the prefetch buffers
full
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
+
80486
Instruction
Pipeline
Examples
+ 53
Interrupt Processing
Interrupts and Exceptions
Interrupts
Generated by a signal from hardware and it may occur at random
times during the execution of a program
Maskable
Nonmaskable
Exceptions
Generated from software and is provoked by the execution of an
instruction
Processor detected
Programmed
Processor Structure
and Function
Lec03
Instruction pipelining
Processor organization
Pipelining strategy
Register organization Pipeline performance
User-visible registers Pipeline hazards
Control and status registers Dealing with branches
Intel 80486 pipelining
Instruction cycle
The indirect cycle
Data flow