ITEC582 Chapter14
ITEC582 Chapter14
2
◦ 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
4
CPU with the system bus
5
6
Internal structure of the CPU
7
8
A user-visible register is one that may be
referenced by means of the machine
language that the processor executes.
10
Typically, the processor updates the PC after
each instruction fetch so that the PC always
points to the next instruction to be executed.
A branch or skip instruction will also modify
the contents of the PC.
The fetched instruction is loaded into an IR,
where the opcode and operand specifiers are
analyzed.
Data are exchanged with memory using the
MAR and MBR.
11
12
Common fields or flags include the following:
◦ Sign (sign bit of the last arithmetic operation)
◦ Zero (set when the result is 0)
◦ Carry (set if an operation resulted in a carry)
◦ Equal (set if a logical compare result is equality)
◦ Overflow (used to indicate arithmetic overflow)
◦ Interrupt Enable/Disable (used to enable or disable
interrupts)
◦ Supervisor (used to indicate supervisor or user mode)
13
14
The Motorola MC68000 (16-bit microprocessor)
partitions its 32-bit registers into eight data
registers and nine address registers.
Data registers are used primarily for data
manipulation and are also used in addressing as
index registers.
The width of the registers allows 8-, 16-, and
32-bit data operations, determined by opcode.
The MC68000 also includes a 32-bit program
counter and a 16-bit status register.
15
16
The Intel 80386-Pentium 4 (32-bit
microprocessors) uses 32-bit registers.
However, to provide upward compatibility for
programs written on the earlier machine, the
80386 retains the original register organization
embedded in the new organization.
Given this design constraint, the architects of
the 32-bit processors had limited flexibility in
designing the register organization.
17
18
19
20
Instruction Cycle State Diagram
21
Fetch Cycle
22
During the fetch cycle, an instruction is read
from memory. The PC contains the address of
the next instruction to be fetched. This address
is moved to the MAR and placed on the address
bus.
The control unit requests a memory read, and
the result is placed on the data bus and copied
into the MBR and then moved to the IR.
Meanwhile, the PC is incremented by 1,
preparatory for the next fetch.
23
Indirect Cycle
24
Once the fetch cycle is over, the control unit
examines the contents of the IR to determine if
it contains an operand specifier using indirect
addressing.
If so, an indirect cycle is performed.
The rightmost N bits of the MBR, which contain
the address reference, are transferred to the
MAR.
Then the control unit requests a memory read,
to get the desired address of the operand into
the MBR.
25
26
Interrupt Cycle
27
28
As computer systems evolve, greater
performance can be achieved by taking
advantage of improvements in technology,
such as faster circuitry.
In addition, organizational enhancements to
the processor can improve performance such
as the use of multiple registers rather than a
single accumulator, and the use of a cache
memory.
Another organizational approach, which is
quite common, is instruction pipelining.
29
30
Two-Stage Instruction Pipeline
31
32
This is called instruction prefetch or fetch
overlap.
33
34
◦ Calculate operands (CO)
Calculate the effective address of each source operand
◦ Fetch operands (FO)
Fetch each operand from memory
Operands in registers need not be fetched
◦ Execute instruction (EI)
Perform the indicated operation and store the result, if
any, in the specified destination operand location
◦ Write operand (WO)
Store the result in memory
35
36
The diagram assumes that each instruction
goes through all six stages of the pipeline
where each step has equal duration.
In particular, it is assumed that there are no
memory conflicts.
◦ For example, the FI, FO, and WO stages involve a
memory access. However, the desired value may be
in cache, or the FO or WO stage may be null.
◦ Thus, much of the time, memory conflicts will not
slow down the pipeline.
37
38
Example: The effect of a conditional branch on instruction
pipeline operation.
39
40
This is not determined until t=7.
At this point, the pipeline must be cleared of
instructions that are not useful.
During t=8, instruction 15 enters the
pipeline.
No instructions complete during time units 9
through 12; this is the performance penalty
incurred because we could not anticipate the
branch.
41
Figure indicates
the logic needed
for pipelining to
account for
branches and
interrupts.
42
Alternative Pipeline
Depiction
Figure shows
same sequence
of events in last
examples, with
time progressing
vertically down
the figure, and
each row
showing the state
of the pipeline at
a given point in
time.
Instruction
pipelining is a
powerful
technique for
enhancing
performance but
requires careful
design to
achieve optimum
results with
reasonable
complexity.
44
Occur when the pipeline, or some portion of
the pipeline, must stall because conditions do
not permit continued execution.
45
46
A data hazard occurs when there is a conflict in
the access of an operand location.
Assume that two instructions in a program are
to be executed in sequence and both access a
particular memory or register operand.
◦ If the two instructions are executed in strict sequence,
no problem occurs.
◦ However, if the instructions are executed in a pipeline,
then it is possible for the operand value to be updated
in such a way as to produce a different result than
would occur with strict sequential execution.
◦ In other words, the program produces an incorrect
result because of the use of pipelining.
47
48