CPU Structure and Functions
CPU Structure and Functions
CPU Structure and Functions
To do these things, it should be clear that the CPU needs to store some data temporarily. It must
remember the location of the last instruction so that it can know where to get the next instruction. It
needs to store instructions and data temporarily while an instruction is being executed. In other words,
the CPU needs a small internal memory.
Figure a. The CPU with the System Bus
Figure a. is a simplified view of a CPU, indicating its connection to the rest of the system
via the system bus. You will recall (Lecture 1) that the major components of the CPU are
an arithmetic and logic unit (ALU) and a control unit (CU). The ALU does the actual
computation or processing of data. The control unit controls the movement of data and
instructions into and out of the CPU and controls the operation of the ALU. In addition, the
figure shows a minimal internal memory, consisting of a set of storage locations, called
registers.
Figure b. CPU Internal Structure
Figure b. is a slightly more detailed view of the CPU. The
data transfer and logic control paths are indicated,
including an element labeled internal CPU-bus. This
element is needed to transfer data between the various
registers and the ALU because the ALU in fact operates
only on data in the internal CPU memory.
REGISTER ORGANIZATION (11.2)
The register in the processor performs two
roles:
Control and Status Registers: used by the control unit to control the
operation of the CPU and by privileged, OS programs to control the
execution of programs.
USER-VISIBLE REGISTERS
Categories:
General Purpose
Data
Address
Condition Codes
GENERAL PURPOSE
Data Register
- to hold data and cannot be employed in the calculation of an operand address.
ADDRESS REGISTERS
Address Register
- they may be devoted to a particular addressing mode
Segment Pointers: a segment register holds the address of the base of the segment
Index Registers: are used for indexed addressing and may be auto indexed.
Stack Pointer: If there is user-visible stack addressing, then typically there is a dedicated
register that points to the top of the stack.
CONDITION CODES
Condition codes
- are bits set by the processor hardware as the result of operations.
Condition codes are bits set by the processor hardware as the result of operation
CONTROL AND STATUS REGISTERS
include:
IR is examined.
If indirect addressing, indirect cycle is performed.
Right most N bits of MBR (the memory reference)
are transferred to MAR
Control unit requests a memory read
Result(address of operand) moved to MBR
3. EXECUTE CYCLE
Pipelining:
Pipelining is the process of accumulating instruction from the processor
through a pipeline. It allows storing and executing instructions in an orderly
process. It is also known as pipeline processing.
It is a technique where multiple instructions are overlapped during
execution. Pipeline is divided into stages and these stages are connected
with one another to form a pipe like structure. Instructions enter from one
end and exit from another end.
There are two types of pipeline:
1.) Arithmetic pipelines: are usually found in most of the
computers. They are used for floating point operations,
multiplication of fixed point numbers.
2.) Instruction Pipelines: In this a stream of instructions can be
executed by overlapping fetch, decode and execute phases of
an instruction cycle. This type of technique is used to increase
the throughput of the computer system.
ADVANTAGES AND DISADVANTAGES:
Advantages of Pipelining:
Fetch instruction
Execute instruction
During execution, there are times when main memory is not
being accessed.
During this time, the next instruction could be fetched and
buffered (called instruction prefetch
or fetch overlap).
WHAT IS INSTRUCTION PREFETCH?
Prefetching is a technique used in microprocessors to speed up the execution of a program. It
occurs when a processor requests an instruction from main memory before it is actually needed.
Once the instruction comes back from memory, it is placed in a cache and accessed later.
Performance is likely to be best when instructions are prefetched in program order.
If the Fetch and Execute stages were of equal duration, the instruction cycle time would be
halved.
However, doubling of execution time is unlikely because:
Execution time is generally longer than fetch time (it will also involve reading and
storing operands, in addition to operation execution)
A conditional branch makes the address of the next instruction to be fetched unknown
(although we can minimize this problem by fetching the next sequential instruction anyway)
To gain further speedup, the pipeline must have more stages. Consider the following
decomposition of instruction processing:
Pipeline Units
FI (Fetch Instruction) fetch next expected instruction into buffer
DI (decode Instruction) determine opcode & operand specifiers
CO (Calculate Operands) calculate effective address of each operand, i.e., mode
• Displacement
• Register Indirect
• Indirect
• etc
FO (Fetch Operands) fetch each operand from memory
The CO (Calculate Operands) stage may depend on the contents of a register that could be
altered by a previous instruction that is still in the pipeline
It may appear that more stages will result in even more speedup
There is some overhead in moving data from buffer to buffer, which increases with more stages
The amount of control logic for dependencies, etc. for moving from stage to stage
Increases exponentially as stages are added
Conditional branch instructions and interrupts can invalidate several instruction fetches
EFFECTS OF A CONDITIONAL BRANCH
INSTUCTION PIPELINE:
UNPREDICTABLE EVENTS
Not all instructions go through all six stages
Memory conflicts exist
All stages do not execute simultaneously with the same execution time
CO Stage may depend on the contents of a register that could have been altered by an
instruction that is still in the pipeline
Interrupts occur - disrupt the ideal conditions
Conditional branch instructions may invalidate multiple instruction fetches
Instruction 3 is a conditional branch to Instruction 15
Branch not taken is not determined until the end of time unit 7
Pipeline must be flushed
During time unit 8 instruction 15 enters the pipeline
No instructions complete during time units 9 through 12
THE SIX STAGE OF INSTRUCTION PIPELINE:
INTEL 80486 PIPELINING
Intel i486 (often called 486 or 80486) is a series of 32-bit Intel scalar CISC micro processors that
are part of the Intel x86 processor family. i486 is the successor to the processor Intel 80386,
processor micro 486 first time introduced in the 1989
From the assessment device software, the instruction set of the family i486 is very similar
to its predecessor, the Intel 80386, with some bit instructions extra.
USES A 5-STAGE PIPELINE
1. Fetch
From cache or external memory
Use one of the two prefetch buffers, each measuring 16 bytes
Fill the buffer with new data as soon as the old data is finished using
On average it can take 5 instructions for one operation
Be independent of other stages so that the buffer can remain full
2. Decode stage 1
Opcode information and memory tracking mode
At most take the first 3 bytes of an instruction
Delegate to Decode stage 2 to retrieve the remaining instructions
3. Decode stage 2
Develop o- mode into control signal
Calculations for complex addressing modes
4. Execute
Operations on the ALU
Access cache
Perform an update to the register
5. Write back
Updating many registers and flag
Results are sent to the cache and the bus write interface is buffered