Central Processing Unit: Chapter - 2
Central Processing Unit: Chapter - 2
Central Processing Unit: Chapter - 2
Chapter – 2
Central Processing Unit
The part of the computer that performs the bulk of data processing operations is called the
Central Processing Unit (CPU) and is the central component of a digital computer. Its purpose is
to interpret instruction cycles received from memory and perform arithmetic, logic and control
operations with data stored in internal register, memory words and I/O interface units. A CPU is
usually divided into two parts namely processor unit (Register Unit and Arithmetic Logic Unit)
and control unit.
Processor Unit:
The processor unit consists of arithmetic unit, logic unit, a number of registers and internal buses
that provides data path for transfer of information between register and arithmetic logic unit. The
block diagram of processor unit is shown in figure below where all registers are connected
through common buses. The registers communicate each other not only for direct data transfer
but also while performing various micro-operations.
Here two sets of multiplexers select register which perform input data for ALU. A decoder
selects destination register by enabling its load input. The function select in ALU determines the
particular operation that to be performed.
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 1
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Control unit:
The control unit is the heart of CPU. It consists of a program counter, instruction register, timing
and control logic. The control logic may be either hardwired or micro-programmed. If it is a
hardwired, register decodes and a set of gates are connected to provide the logic that determines
the action required to execute various instructions. A micro-programmed control unit uses a
control memory to store micro instructions and a sequence to determine the order by which the
instructions are read from control memory.
The control unit decides what the instructions mean and directs the necessary data to be moved
from memory to ALU. Control unit must communicate with both ALU and main memory and
coordinates all activities of processor unit, peripheral devices and storage devices. It can be
characterized on the basis of design and implementation by:
Defining basic elements of the processor
Describing the micro-operation that processor performs
Determining the function that the control unit must perform to cause the micro-operations
to be performed.
Control unit must have inputs that allow determining the state of system and outputs that allow
controlling the behavior of system.
Flag: flags are headed to determine the status of processor and outcome of previous ALU
operation.
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 2
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Clock: All micro-operations are performed within each clock pulse. This clock pulse is
also called as processor cycle time or clock cycle time.
Control signal from control bus: The control bus portion of system bus provides interrupt,
acknowledgement signals to control unit.
Control signal within processor: These signals causes data transfer between registers,
activate ALU functions.
Control signal to control bus: These are signals to memory and I/O module. All these
control signals are applied directly as binary inputs to individual logic gate.
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 3
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Register Organization
Registers are at top of the memory hierarchy. They serve two functions:
1. User-Visible Registers - enable the machine- or assembly-language programmer
to minimize main-memory references by optimizing use of registers
2. Control and Status Registers - used by the control unit to control the operation
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 4
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Design Issues
Completely general-purpose registers or specialized use?
- Specialized registers save bits in instructions because their use can be implicit
- General-purpose registers are more flexible
- Trend is toward use of specialized registers
Number of registers provided?
- More registers require more operand specifier bits in instructions
- 8 to 32 registers appears optimum (RISC systems use hundreds, but are a
completely different approach)
Register Length?
- Address registers must be long enough to hold the largest address
- Data registers should be able to hold values of most data types
- Some machines allow two contiguous registers for double-length values
Automatic or manual save of condition codes?
- Condition restore is usually automatic upon call return
- Saving condition code registers may be automatic upon call instruction, or may be
manual
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 6
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 7
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Data Flow
- Exact sequence depends on CPU design
- We can indicate sequence in general terms, assuming CPU employs:
a memory address register (MAR)
a memory buffer register (MBR)
a program counter (PC)
an instruction register (IR)
Fetch cycle data flow
- PC contains address of next instruction to be fetched
- This address is moved to MAR and placed on address bus
- Control unit requests a memory read
- Result is
placed on data bus
result copied to MBR
then moved to IR
- Meanwhile, PC is incremented
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 8
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 9
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Data are presented to ALU in register and the result of operation is stored in register. These
registers are temporarily storage location within the processor that are connected by signal path
to the ALU. The ALU may also set flags as the result of an operation. The flags values are also
stored in registers within the processor. The control unit provides signals that control the
operation of ALU and the movement of data into an out of ALU.
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 10
Computer Organization and Architecture Chapter 2 : Central Processing Unit
4X1
Ei
MUX
S0 S1
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 11
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 12
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Example: Design a 2-bit ALU that can perform addition, AND, OR, & XOR.
Cin
A0
B0 FA
A1
B1
Cout
4X1
Result0
MUX
S1 S0
4X1
Result1
MUX
A computer usually has a variety of Instruction Code Formats. It is the function of the control
unit within the CPU to interpret each instruction code and provide the necessary control
functions needed to process the instruction. An n bit instruction that k bits in the address field
and m bits in the operation code field come addressed 2k location directly and specify 2m
different operation.
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 13
Computer Organization and Architecture Chapter 2 : Central Processing Unit
The bits of the instruction are divided into groups called fields.
The most common fields in instruction formats are:
o An Operation code field that specifies the operation to be performed.
o An Address field that designates a memory address or a processor
register.
o A Mode field that specifies the way the operand or the effective address is
determined.
Types of Instruction
Computers may have instructions of several different lengths containing varying
number of addresses.
The number of address fields in the instruction format of a computer depends on
the internal organization of its registers.
Most computers fall into one of 3 types of CPU organizations:
General register organization:- The instruction format in this type of computer needs
three register address fields. For example: ADD R1,R2,R3
Computers may have instructions of several different lengths containing varying number of
addresses. Following are the types of instructions.
1. Three address Instruction
With this type of instruction, each instruction specifies two operand location and a result
location. A temporary location T is used to store some intermediate result so as not to
alter any of the operand location. The three address instruction format requires a very
complex design to hold the three address references.
Format: Op X, Y, Z; X Y Op Z
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 14
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Example: ADD X, Y, Z; X Y + Z
ADVANTAGE: It results in short programs when evaluating arithmetic
expressions.
DISADVANTAGE: The instructions requires too many bits to specify 3
addresses.
Example: To illustrate the influence of the number of address on computer programs, we will
evaluate the arithmetic statement X=(A+B)*(C+D) using Zero, one, two, or three address
instructions.
1. Three-Address Instructions:
ADD R1, A, B; R1 M[A] + M[B]
ADD R2, C, D; R2 M[C] + M[D]
MUL X, R1,R2; M[X] R1 * R2
It is assumed that the computer has two processor registers R1 and R2. The symbol M[A]
denotes the operand at memory address symbolized by A.
2. Two-Address Instructions:
MOV R1, A; R1 M[A]
ADD R1, B; R1 R1 + M[B]
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 15
Computer Organization and Architecture Chapter 2 : Central Processing Unit
3. One-Address Instruction:
LOAD A; Ac M[A]
ADD B; Ac Ac + M[B]
STORE T; M[T] Ac
LOAD C; Ac M[C]
ADD D; Ac Ac + M[D]
MUL T; Ac Ac * M[T]
STORE X; M[X] Ac
Here, T is the temporary memory location required for storing the intermediate result.
4. Zero-Address Instructions:
PUSH A; TOS A
PUSH B; TOS B
ADD; TOS (A + B)
PUSH C; TOS C
PUSH D; TOS D
ADD; TOS (C + D)
MUL; TOS (C + D) * (A + B)
POP X ; M[X] TOS
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 16
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 17
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Instruction
Opcode Register Register
Operand
Operand
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 18
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Operand
Operand
Register Memory
+ Operand
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 19
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Implicit
Top of Stack
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 20
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 21
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Arithmetic Instructions
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 22
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Shift Instructions
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 23
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Interrupt
The interrupt procedure is, in principle, quite similar to a subroutine call except for three
variations:
The interrupt is usually initiated by an external or internal signal rather than from
execution of an instruction.
The address of the interrupt service program is determined by the hardware rather
than from the address field of an instruction.
An interrupt procedure usually stores all the information necessary to define the
state of the CPU rather than storing only the program counter.
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 24
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 25
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 26
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 27
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Berkeley RISC I
The Berkeley RISC I is a 32-bit integrated circuit CPU.
o It supports 32-bit address and either 8-, 16-, or 32-bit data.
o It has a 32-bit instruction format and a total of 31 instructions.
o There are three basic addressing modes: Register addressing, immediate operand,
and relative to PC addressing for branch instructions.
o It has a register file of 138 registers; 10 global register and 8 windows of 32
registers in each
o The 32 registers in each window have an organization similar to overlapped
register window.
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 28
Computer Organization and Architecture Chapter 2 : Central Processing Unit
64-bit processors have 64-bit ALUs, 64-bit registers, and 64-bit buses.
A 64-bit register can address up to 264 bytes of logical address.
64-bit processors have been with us since 1992.
Eg: 64-bit AMD processor.
Internal Architecture
The internal logic design of microprocessor which determines how and when various
operations are performed.
The various function performed by the microprocessor can be classified as:
o Microprocessor initiated operations
o Internal operations
o Peripheral operations
Microprocessor initiated operations mainly deal with memory and I/O read and write
operations.
Internal operations determines how and what operations can be performed with the
data.The operations include:
1. storing
2. performing arithmetic and logical operations
3. test for conditions
4. store in the stack
External initiated operations are initiated by the external devices to perform special
operations like reset, interrupt, ready, etc.
The block diagram of 64-bit microprocessor is shown below.
The major parts of the block diagram are:
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 29
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Architecture Elements
Addressing Modes
General Purpose Registers
Non-modal and modal Instructions
New Instructions in Support of 64-bit
New immediate Instructions
Addressing modes
This addressing mode determines the working environment. i.e 24,32 or 64 bit mode
PSW bits 31 and 32 designate addressing mode (out of 64 bit).
o Addressing modes bits:00=24 bit-mode
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 30
Computer Organization and Architecture Chapter 2 : Central Processing Unit
01=32 bit-mode
11=64 bit-mode
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 31
Computer Organization and Architecture Chapter 2 : Central Processing Unit
Compiled By: Er. Hari Aryal [[email protected]] References: W. Stalling & M. Mano | 32