2 Central Processing Unit PDF
2 Central Processing Unit PDF
PROCESSING
UNIT
Computer Architecture & Organization
OBJECTIVES
• Identify the components of the central
processing unit and how they work
together and interact with memory
• Describe how program instructions are
executed by the computer
• Differentiate between CISC and RISC
architectures.
Introduction to CPU
Store
CPU PROCESS DATA CYCLE
AddressingModes
Immediate
Direct
Indirect
Register
RegisterIndirect
Displacement
Stack
Components of CPU
Components of CPU
Control Unit
Controls the operation of the CPU and hence the
computer
Arithmetic and Logic Unit (ALU)
Performs the computer’s data processing function
Registers
Provide storage internal to the CPU
CPU Interconnection
Some mechanism that provides for communication
among the control unit, ALU, and registers
Components of CPU
Control unit
• Moves data and instructions between main memory
and registers
• coordinates the components of a computer system.
• It reads program instruction .
• Regulate the timing of all operations carried out in the
CPU.
• Control the sequence in which the instructions are to
be executed.
• It uses registers to temporarily store the data it needs.
Components of CPU
Arithmetic logic unit (ALU)
• Definition : digital circuit that performs integer arithmetic
and logical operations
• Performs computation and comparison operations
• Computation / Arithmetic operations:
• E.g : + , - , * , /
• Logical operations:
• Not, And, OR, >, <, >=, <=, =
• performs its operations on whole numbers only.
Components of CPU
Registers
Storage locations that hold inputs and
outputs for the ALU
• Is a Small, temporary storage locations within the CPU
• Can be accessed more quickly .
• CPU load data from a larger memory into registers
• used for
• arithmetic,
• manipulated, or
• tested,
• Can hold data, an address or an instruction
• Manipulated data is then often stored back in main memory.
Components of CPU
Registers
• Registers are temporary storage areas for program instructions
or data.
• They are not a part of memory; rather they are special additional
storage locations that offer the advantage of speed.
• Registers work under the direction of the control unit to accept,
hold, and transfer instructions or data and perform arithmetic or
logical comparisons at high speed.
• The control unit uses a data storage register the way a store
owner uses a cash register-as a temporary, convenient place to
store what is used in transactions.
Types of CPU Registers
7-29
Bus Structures
Computer Architecture describes the way these components are connected
and the manner in which they communicate
Input
Output Memory Processor
Single-bus structure.
Cache
• To reduce the average time to access memory .
• The cache is:
• a smaller ,
• faster memory
• stores copies of most frequently used data from
the main memory.
Types of Cache
• Internal cache
• Level 1 (L1)
• Built into microprocessor
• Up to 128KB
• External cache
• Level 2 (L2)
• Separate chips
• 256KB or 512 KB
• SRAM technology
• Cheaper and slower than L1
• Faster and more expensive than memory
Process Flow
An Example: Multi-Core Systems
L2 CACHE 1
L2 CACHE 0
SHARED L3 CACHE
DRAM INTERFACE
Multi-Core
DRAM BANKS
Chip CORE 0 CORE 1
DRAM
MEMORY
CONTROLLER
L2 CACHE 2
L2 CACHE 3
CORE 2 CORE 3
Past systems
9 2 0 3 B B 8 1
Move X, D0
Add Y, D0
Move D0, Z
Stop
This program is coded into machine instruction and suppose is loaded into memory
starting at location $0000 0000
• How does the CPU know which instruction to execute?
• There is a dedicated register in CPU called Program Counter (PC)
that points to the memory location where next instruction is
stored
Therefore, at start PC = $0000 0000
• Instruction is in Main Memory – it is to be transferred
(fetched) to CPU to be executed
• CPU has an Instruction Register (IR) that holds the instruction
• What kind of instruction is to be executed?
• CPU has its own Instruction Interpreter (Decoder)
• Followed by Instruction execution
• Next instruction follows. PC is incremented by length of
instruction just completed
Mechanism of Transferring Data from MM to CPU
CPU has an external bus that connects it to the Memory and I/O devices.
The data lines are connected to the processor via the Memory Data
Register (MDR)
The address lines are connected to the processor via the Memory Address
Register (MAR)
• Memory address from where the instruction/data is to be accessed is copied into
MAR
• Contents of MAR are loaded onto address bus
• Corresponding memory location accessed MAR
Address bus
Control bus
CPU MM
R/W
General Purpose Register (GPR)Architecture
Its functional units are:
Data Registers : D0, D1, D2,..., D7 for arithmetic operations – holds any kind of data
Address Registers : A0, A1, A2,..., A7 serve as pointers to memory addresses
Working Registers : several such registers – serve as scratch pads for CPU
Program Counter (PC) holding the address in memory of the next instruction to be
executed. After an instruction is fetched from memory, the PC is automatically
incremented to hold the address of, or point to, the next instruction to be executed.
Instruction Register (IR) holds the most recently read instruction from memory while it
is being decoded by the Instruction Interpreter.
Memory Address Register (MAR) holds the address of the next location to be accessed
in memory.
Memory Buffer Register (MBR or MDR) holds the data just read from memory, or the
data which is about to be written to memory. Buffer is referring to temporarily holding
data.
Status Register (SR) to record status information
GPR CPU
Data bus
0 Register MBR
1
File
2 IR
3 Address bus
MAR
Interprete
ALU r
PC
Memory
Control
16 bit Incremen
8 bit t
CPU Memory
Program Execution
Fetch Cycle:
• Processor fetches one instruction at a time from successive memory locations
until a branch/jump occurs.
• Instructions are located in the memory location pointed to by the PC
• Instruction is loaded into the IR
• Increment the contents of the PC by the size of an instruction
Decode Cycle:
• Instruction is decoded/interpreted, opcode will provide the type of operation to
be performed, the nature and mode of the operands
• Decoder and control logic unit is responsible to select the registers involved and
direct the data transfer.
Execute Cycle:
• Carry out the actions specified by the instruction in the IR
Execution for add D1,D2 in a GPR processor
MAR PC
MDR M[MAR]
Fetch
PC PC + 2
IR MDR
Decode
D2 D1 + D2
Execute
GPR CPU
Data bus
0 Register MBR
1
File
2 IR
3 Address bus
Type equation here. MAR
Interprete
ALU r
PC
Memory
Control
16 bit Incremen
8 bit t
CPU Memory
Execution for add X,D0 in a GPR processor
MAR PC
MDR M[MAR]
Fetch
PC PC + 2
IR MDR
Decode
Contents of Address X
transferred to MDR MDR M[MAR] Execute
Data bus
0 Register MBR
1
File
2 IR
3 Address bus
Type equation here. MAR
Interprete
ALU r
PC
Memory
Control
16 bit Incremen
8 bit t
CPU Memory
Instruction Execution Time
Clock Cycles (P) – regular time intervals
defined by the CPU clock
Clock Rate, R = 1/P cycles per second (Hz)
500 MHz => P = 2ns
1.25 GHz => P = 0.8ns MicroStepNumberofClockCycles
RegisterTransfer1
Add2
Fetch: Total 12 clock cycles
Multiply5
MAR PC 1
MemoryAccess10
MDR M[MAR] 10
IR MBR 1
Decode: 2 clock cycles
Execute: depends on instruction
Accumulator(Acc) Architecture
• Its functional units are same as GPR architecture, except there is only
ONE register – accumulator (Acc) – instead of the Register File
Ex: Z = X + Y
Move contents of location X to Acc
Add contents of location Y to Acc
Move from Acc to location Z
Stop
• All operations and data movements are on this single register
• Most of the instructions in the instruction set require only one Operand
• Destination and Source are implicitly Acc
• Leads to shorter instructions but program may be slower to execute since
there are more moves to memory for intermediate results (to free Acc)
• May lead to inefficiency
Accumulator Architecture CPU
Data bus
Acc MBR
IR
Address bus
MAR
Interprete
ALU r
PC
Memory
Control
16 bit Incremen
10 bit t
CPU Memory
Execution for Add Y in an Acc Architecture
MAR PC
MDR M[MAR]
Fetch
PC PC + 2
IR MDR
Decode
Contents of Address X
transferred to MDR MDR M[MAR] Execute