3
Chapter#3: Central Processing Unit
Unit
CENTRAL PROCESSING UNIT
CPU (Central Processing Unit)
CPU is short for Central Processing Unit.
It is also known as a processor or microprocessor.
It is the brain of computer system.
CPU controls all the operations of the computer.
It controls and execute/carry out all the operations of computer
CPU controls input, storage, processing and output operations.
It is also called microprocessor, central processor and processor
CPU is connected to all parts of computer
It executes all the instructions it receives from hardware and
software running on the computer.
All functions and processes which are done on a computer are
performed directly or indirectly by the processor.
It is connected to all parts of the computer and not only executes instructions but also controls
the storage of data, input/output activities and functions of different devices attached.
🞛 Basic Components of CPU
A CPU consists of following basic components:
◾ Arithmetic and Logic Unit (ALU) ◾ Control Unit (CU)
◾ Cache memory ◾ Registers ◾ Internal Buses
i. ALU (Arithmatic Logic Unit)
ALU means Arithmetic and Logic Unit.
ALU is the main processing unit of CPU.
It is the part of CPU where all the processing happens.
It performs two types of functions i.e. the Arithmetic operations and Logical operations.
Arithmetic operations include functions such as addition, subtraction, multiplication, and
division.
Logic operations are comparisons like greater than, smaller than, equal to etc.
A CPU can have more than one ALUs, to improve the efficiency and speeds up the computation.
ii. CU (Control Unit)
CU Means control unit
CPU controls all the operations of computer.
It does not perform any processing
it fetches the instruction, decodes it and execute the instruction.
It also controls the Read and write operation
It also controls the functions of other unit like input, output devices, memory etc
iii. Registers
Registers are high-speed temporary storage locations inside processor to hold data and
instructions.
A register provides fastest way for a CPU to access data.
Each register performs a specific task, for which it is designed.
Registers vary in both number and size, depending on the CPU architecture.
The size of register can be 16, 32, or 64 bits.
Registers are divided into two main types: Special purpose register and General- purpose register
iv. Cache Memory
Cache memory is an extremely fast memory that is built into a computer’s CPU or located next to it on a
separate chip.
The main purpose of introduction of cache memory is to save the time of CPU.
Cache stores data and instructions that are frequently used by the CPU.
When information is required by the processor first it will look up in the cache memory, if it is not present
in cache, then it will fetch it from RAM.
The cache memory is very expensive and hence is limited in capacity.
It is the type of SRAM.
Types of Cache Memory
a) Level 1(L1) Cache
L1 cache is built in the processor
It is the fastest memory and closest to the CPU
It is very small and small in size typically upto 8 MB.
b) Level 2 (L2) cache or Secondary Cache
It is present between RAM and L1 cache.
It has large capacity than L1.
It is normally from 64 KB to 16 MB.
c) Level 3 (L3) cache
Cache is the largest level of cache memory.
It is slower than L1 and L2 (in terms of speed). It located outside the processor on motherboard.
v. Internal Buses.
Bus is an electrical pathway or channel between CPU and computer’s other devices.
These computer devices are input, output devices, computer memory, graphic cards etc.
Data is transferred by these communication wires using electrical signals
The buses size in computers are from 8-bits to 128 bits.
Modern computer buses can use both parallel and serial –bit connections
Parallel buses are those which carry data in parallel on multiple wires
Serial buses are those that carry data in serial form (Conventional PCI, Extended ISA, PCI-104)
Parallel wires (PCI express, SATA) serial buses
Types of Registers.
a) General Purpose Register
These register are used for arithmetic operations and data movement from one register to oth-
er register.
Typically, these register are 8-64 bit registers.
Types of general purpose register
a) Accumulator (AX)
Used for performing Arithmetic and logic operations
Holds the result of this operation
Initial value zero and later on value is updated
A complete 32-bit register can be used in three ways
As complete 32-bit data register: EAX
16-bit register (AX)
Two 8-bit register (AH and AL)
b) Base Register (BX)
Base register can perform arithmetic and data movement from one register to another register
Holds memory address to which value is to be sent
It usually contains a data pointer which Points to another variable
A complete 32-bit register can be used in three ways
As complete 32-bit data register: EBX
16-bit register (BX)
Two 8-bit register (BH and BL)
c) Counter register
Acts as counter for repeating or looping instructions
Instructions are repeated automatically and will decrement the value of CX
Stops when CX = 0
A complete 32-bit register can be used in three ways
As complete 32-bit data register: ECX
16-bit register (CX)
Two 8-bit register (CH and CL)
d) Data Register
It has role in multiply and divide operations.
It works like a buffer and holds data that comes from memory for the processor.
A complete 32-bit register can be used in three ways
As complete 32-bit data register: EDX
16-bit register (DX)
Two 8-bit register (DH and DL)
b) Special Purpose Register
Special purpose registers ( SPR ) holds program state
It can include program counter, instruction register, memory address register and
memory buffer registers.
These are used by control unit to control the operation of CPU and by the
operating system programs to control the execution of programs.
Types of special purpose register
a) Instruction Register
It is also called current instruction register.
It stores the current instruction being executed by the CPU.
The instructions are also decoded here
b) Program counter
It is also called instruction pointer.
Program counter contains the address of next instruction that is being executed by the CPU
When the instruction is fetched the value of program counter is incremented.
It now refers to the next instruction.
c) Memory Address Register (MAR)
Memory address register is used to store address of memory.
When CPU wants to read from memory or write data in memory, it uses that address stored by
MAR.
d) Memory buffer register (MBR)
Memory buffer register is used to store data coming from memory or going to memory.
Transfer of data from memory to microprocessor and from microprocessor to memory occur
through this register
Q. No4: Define System Bus and its types?
System Bus
Bus is an electrical pathway or channel between CPU and computer’s other devices.
These computer devices are input, output devices, computer memory, graphic cards etc.
Data is transferred by these communication wires using electrical signals
There are three types of buses.
The majority of system buses are made up of 50 to 100 distinct lines.
The system bus consists of three types of buses.
a) Data Bus
b) Address Bus
c) Control Bus
Types of System Buses
a) Data Bus
Data bus is the most common type of system bus which transfers data and instructions from one compo-
nent of computer to another.
It is the bidirectional bus means it can communicate in two ways.
It is an electrical path that connect the CPU, Memory, Input/output devices and secondary storage devic-
es.
The bus contains parallel group of lines.
A typical data bus is 32-bits wide.
New Computers have 64-bits data buses and even more.
b) Address Bus
Address bus carries address information.
When CPU or I/O section require data from memory, the address of those locations in memory must be
transmitted to memory through address bus.
An 8-bit bus can represent 28 i.e. 256 unique addresses.
A 16-bit bus can address 65536 unique addresses.
It is unidirectional bus.
c) Control Bus
This bus carries control signals from the control unit to the other units.
The control signal is used for directing the activities of all units.
It is used to transmit a variety of signals like read, write, interrupt and acknowledge.
The size of control bus is from 8 to 16 bits.
Q. No: 6 Define instruction and their types?
Instruction is a group of bit that tells the computer to perform a specific operation. OR
The set of bits that a particular processor understands and executes is called instruction or CPU
instruction.
Instruction are stored in the main memory, waiting to be processed by the processor.
An instruction has two fields:
Instruction = opcode + operand
Operation code Operands
a) Operation code
It is also known as opcode.
It represents the operation that the processor will execute.
b) Operand code
Defines the parameters of the action.
It can be data or a memory address.
Q. No: 7 Explain type of instruction?
There are different types of instructions, such as:
a) 🞓 Data Transfer Instructions 🞓 Data Processing Instructions
b) 🞓 Program Control Instructions 🞓 Miscellaneous Instructions
Data transfer instruction
Most of operation of the CPU are data transferring
These instructions transfer data from one location in the computer to another location without changing
the data content
Most common transfers are b/w
Register and memory
Register and I/O
Register to register
Examples of some common data transfer instructions are MOV, LOAD and STORE
Data Transfer Symbol Purpose Example
Instruction
Transfers data from memory MOV A, B
MOVE MOV to register, register to memory (Move the contents of
or register to register register A to B)
LD A
Loads data from memory to
LOAD LD (Loads the data to regis-
register
ter A from memory)
STO X
Stores data from register to (Store accumulator val-
STORE STO
memory ue in memory
location X
c) Data Processing instruction
These instructions are related to the arithmetic and logic operations
The arithmetic or logic operation are performed on the values of two registers and result is also placed in
a register
Data processing instructions can be divided in to three basic types i.e. arithmetic, logical and shift instruc-
tion
i). Arithmetic instruction
The four basic operation are ADD , SUB , MUL and DIV
An arithmetic instruction may operate on fixed-point data , binary or decimal data
The other possible operations include a variety of single-operand instruction for example ABSOLUTE,
NEGATE, INCREMENT, DECREMENT
ii). Logical instruction
AND, OR, NOT, XOR operate on binary data stored in registers
iii). Shift instruction
Shift instructions allow the bits of a register to be shifted one-bit place
to the left or to the right.
d) Program control instruction
It is the instruction that alters the sequence of the program's execution.
It means it changes the value of the program counter, due to which the execu-
tion of the program changes.
Examples:
o JMP: This instruction sends the control to some other part of program.
o LOOP: This instruction is used to repeat the execution of a statement.
Q. No: 8 Explain instruction format?
Instruction format
The instruction format describes the layout or design of an instruction.
Operation code
It is also known as opcode.
It represents the operation that the processor will execute.
Operand code
Defines the parameters of the action.
It can be data or a memory address.
Operation code Operands
Types of instruction format
a) Zero Address instruction
This is an instruction format without any operand.
Example of zero address instruction format is HALT and STOP which does not
have any operand (address or data).
b) One Address instruction
This instruction format requires one op-code and one operand is called one address instruction.
Example of one address instruction format is LD A (Load Accumulator), JMP
(Jump) etc. These instructions require one address (operand) to do operation.
Example LD A and JMP AX
c) Two Address instruction
The instruction format that requires one op-code and two operands is called two address instruction.
. Example of such instructions are ADD, SUB, MUL, MOV etc.
MOV (Move), instruction is used to move data from the memory location to the register and
vice versa.
Example ADD A ,B (adds value in A and B.
Op-Code Operand Operand
. No: 9 Explain instruction Cycle?
Instruction Cycle
The instruction cycle (also known as the fetch–decode–execute cycle.
It is a list of steps that CPU follows to execute the instructions.
It is also called fetch-and-execute cycle or fetch-decode-execute cycle.
In other words, we can say that instruction cycle is the time required by the CPU to
Each instruction cycle consists of the following phases:
a) Fetch instruction from memory.
b) Decode the instruction.
c) Read the effective address from memory.
d) Execute the instruction.
a) Fetch instruction from memory
In first step the processor fetches the instruction from the memory.
The memory places the instruction on the data bus.
The processor than copies the instruction from data bus to instruction register.
Thus the instruction is transferred from memory to instruction register.
The PC (Program counter) points to the next instruction that will be read at the
next cycle.
b) Decode instruction
In this step instruction inside Instruction Register gets decoded.
Instruction decoder examine instruction to determine what type of operation to be performed and oper-
and to be used
c) Execute instruction
Here the operation on decoded instruction is performed.
The decoded instruction is passed to ALU which execute the instruction
d) Store result
Result generated by the operation is stored in the main memory or sent to an output device.
Q No: 10 Explain CISC and RISC architectures?
a. CISC
It is known as Complex Instruction Set Computer.
It was first developed by Intel.
It is a type of architecture that has large and complex instructions as instruction set
CISC is hardware based architecture.
This minimizes the number of instructions per program
Instruction takes more than one clock cycle for execution
Takes more time so it is slow.
Data Transfer is from memory to memory.
Used in AMD and Intel Laptops and Desktop computers
b. RISC
It is known as Reduced Instruction Set Computer.
It is a type of architecture that has small and limited number of instructions as instruction set
Emphasizes on software level
This increases the number of instruction per program
They can execute their instructions very fast because instructions are very small and simple.
Each instruction requires only one clock cycle
Takes less time so it is fast.
Used in apple i-pods, tablets and smartphones
Question: Differentiate between CISC and RISC processor architecture.
Ans: The main differences between RISC and CISC architecture are as fol-
lows:
RISC CISC
Puts burden on software Puts burden on hardware
Small and simple instruction Large and complex number of
built into processor instructions built into processor
Instructions can take several clock
Instructions takes Single clock cycle cycles
Less instructions are needed to
More instructions are needed to write write an application.
an application
Heavy use of RAM More efficient use of RAM
Provides difficult and complex pro- Provides easier programming in as-
gramming in assembly language. sembly language