Slot15 CH14 ProcessorStructureAndFunction 42 Slots
Slot15 CH14 ProcessorStructureAndFunction 42 Slots
Processor Structure
Chapter 14 and Function
William Stallings, Computer Organization and Architecture, 9 th Edition
+ 2
Objectives
CLO8: Explain processor structure and function
in details, the operations of Reduced Instruction
Set Computers
Contents
14.1 Processor Organization
14.2 Register Organization
14.3 Instruction Cycle
14.4 Instruction Pipelining
+ 4
10 Exercises
14.1 What general roles are performed by processor registers?
14.2 What categories of data are commonly supported by user-visible
registers?
14.3 What is the function of condition codes?
14.4 What is a program status word?
14.5 Why is a two-stage instruction pipeline unlikely to cut the instruction
cycle time in half, compared with the use of no pipeline?
14.6 List and briefly explain various ways in which an instruction pipeline
can deal with conditional branch instructions (Refer to “Control Hazard”).
14.7 How are history bits used for branch prediction? (refer to “Branch
Prediction State Diagram”)
+ 10 Exercises 5
What would be the value of the following flags: Carry, Zero, Overflow,
Sign, Even Parity , Half-Carry ?
14.8 -If the last operation performed on a computer with an 8-bit
word was an addition in which the two operands were 00000010 and
00000011.
14.9-Repeat for the addition of -1 (twos complement) and +1.
14.10- Repeat for the substraction A - B, where A contains 11110000
and B contains 0010100.
Cờ nhớ carry: Làm phép toán xong còn nhớ hay không?
Cờ zero: Kết quả của phép toán có là 0 hay không?
Cờ tràn (overflow): Kết quả của phép toán có bị tràn hay không (nơi chưa kết
quả không đủ rông để chứa kết quả)?
Cờ dấu (sign): Kết quả có là số âm không?
Cờ parity chẵn (even parity): Số bit 1 của kết quả có là số chẵn không?
Cờ nhớ nửa (half-carry): Giá trị của biến nhớ (carry) say khi thực thi được một
nửa số bit cần tính toán. Thí dụ: Đơn vị bộ nhớ là 1 byte thì một nửa có 4 bit.
+ 6
User-Visible Registers
Categories:
• General purpose
Referenced • Can be assigned to a variety of functions by the programmer
by means of • Data
the machine • May be used only to hold data and cannot be employed in the
language that calculation of an operand address
the processor • Address
executes • 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
Example
Microprocessor
Register
Organizations
14.3- 14
Loop due to
additional memory
accesses
16
Operation
I: Instruction
O: operand
F: Fetch
C: Calculate
E: Execute
W: Write
The Effect of a Conditional Branch on 23
I3 is a
conditional
branch to
I15
+ number of
instructions that are
Speedup executed without a
branch
Factors
with
Instruction
Pipelining
Also referred
to as a
pipeline
bubble
+ Resource
Hazards
A resource hazard occurs
when two or more
instructions that are already
in the pipeline need the same
resource
A resource hazard is
sometimes referred to as a
structural hazard
FO is accessing memory. So, this step is idle
Data Hazards 29
X86
Hazard
instruction
+
+ Types of Data Hazard 30
Control Hazard
Also known as a branch hazard
Occurswhen the pipeline makes the wrong decision on a
branch prediction
Brings
instructions into the pipeline that must
subsequently be discarded
Dealing with Branches:
Multiple streams
Prefetch branch target
Loop buffer
Branch prediction
Delayed branch
Multiple Streams 32
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
33
Benefits:
Similar in principle to
Instructions fetched in sequence will be
a cache dedicated to
available without the usual memory access
time instructions. Differences:
• The loop buffer only
If a branch occurs to a target just a few retains instructions in
locations ahead of the address of the branch sequence
instruction, the target will already be in the • Is much smaller in size
buffer and hence lower in cost
This strategy is particularly well suited to
dealing with loops
+ 35
Branch Prediction
Various
techniques can be used to predict whether a
branch will be taken:
How are predictions carried out? States of some last instructions (some
bits) must be stores in cache
Next slide
+Branch
Prediction Flow
Chart
If only one bit is stored,
a loop may cause 2
errors in prediction:
once on entering and
once on exiting.
Finite-state machine is a
way to express a
processing mechanism
in which each part of
input will determine a
step of the process.
Some bits are stored: 0: Not taken, 1: Taken. A history can be as 01110
+ Dealing
With
Branches
sequential address.
Match: a prediction is
made based on the state of
the instruction: Either the
next sequential address or
the branch target address is
fed to the select logic.
+ Delayed Branch 39
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
+ Summary
42