Unit 5: Central Processing Unit
Unit 5: Central Processing Unit
Introduction
Stack Organization
Instruction Formats
Addressing Modes
Register Set
CU
ALU
1 / 44
General Register Organization
Input
R1
R2
R3
R4
R5
R6
R7
00000 Add A + B R2
R3
00011 Subtract A B R4
00100 Transfer A R5
00101 Increment A R6
R7
00110 Decrement A
01000 AND A and B LD SELA MUX MUX SELB
01010 OR A and B
3x8 A B
01100 XOR A and B Decoder
01110 Complement A OPR
ALU
10000 Shift right A SELD
Chapter 8
5 / 44
Homework
8-3 Specify the control word that must be applied to the
processor of Fig. 8-2 to implement the following micro
operations.
a. R1 R2 + R3
b. R4 R4
c. R5 R5 1
d. R6 shl R1
e. R7 input
3 3 3 5
Control Word : SELA SELB SELD OPR
6 / 44
8-3
Homework
8-4 Determine the micro operations that will be executed in
processor of Fig 8.2 in the following 14 bit control world
are applied .
a. 001 010 011 00101
b. 000 000 000 00000
c. 010 010 010 01100
d. 000 001 000 00010
e. 111 100 011 10000
8 / 44
8-4
8.1
A bus-organized CPU similar to Fig.8-2 has 16 registers with
32 bits in each, an ALU, and a destination decoder.
a. How many selection inputs are needed for MUX A and
MUX B?
b. How many inputs and outputs are there in the decoder?
c. How many inputs and outputs are there in the ALU for data,
including input and output carries?
d. Formulate a control word for the system assuming that the
ALU has 35 operations.
10 / 44
8.1
11 / 44
Stack Organization
LIFO Current
Last In First Out Top of Stack
TOS 63
6
5
SP 4 0 1 2 3
3 0 0 5 5
FULL EMPTY 2 0 0 0 8
1 0 0 2 5
Stack Bottom 0 0 0 1 5
Stack
12 / 44
Stack Organization
PUSH Current 1 6 9 0
SP SP + 1 Top of Stack
TOS 63
M[SP] DR
If (SP = 64) then (FULL 1)
EMPTY 0 6
5 1 6 9 0
SP 4 0 1 2 3
3 0 0 5 5
FULL EMPTY 2 0 0 0 8
1 0 0 2 5
Stack Bottom 0 0 0 1 5
Stack
13 / 44
Stack Organization
POP Current
DR M[SP] Top of Stack
TOS 63
SP SP - 1
If (SP = 0) then (EMPTY 1)
FULL 0 6
5 1 6 9 0
SP 4 0 1 2 3
3 0 0 5 5
FULL EMPTY 2 0 0 0 8
1 0 0 2 5
Stack Bottom 0 0 0 1 5
Stack
14 / 44
Stack Organization
Memory Stack
PC 0
PUSH
1
SP SP + 1 2
M[SP] DR
AR 100
POP
101
DR M[SP] 102
SP SP - 1
200
SP 201
202
15 / 44
Reverse Polish Notation
Infix Notation
A+B
Example
(A + B) [C (D + E) + F]
(A B +) (D E +) C F +
17 / 44
Reverse Polish Notation
Stack Operation
(3) (4) (5) (6) +
PUSH 3
PUSH 4
6
MULT
PUSH 5 30
4
5
PUSH 6
3
42
12
MULT
ADD
18 / 44
CPU Organization
Single Accumulator
ADD x
General Register
ADD R1, R2
ADD R1, R2, R3
Stack
PUSH x
ADD
19 / 44
Instruction Formats
Three-Address Instructions
ADD R1, A , B R1 M[A] + M[B]
Two-Address Instructions
ADD R1, A R1 R1 + M[A]
One-Address Instructions
ADD M AC AC + M[AR]
Zero-Address Instructions
ADD TOS TOS + (TOS 1)
RISC Instructions
Lots of registers. Memory is restricted to Load & Store
LOAD R1, A
LOAD R2, B
ADD R1, R1, R2 20 / 44
Instruction Formats
21 / 44
Instruction Formats
22 / 44
Instruction Formats
23 / 44
Instruction Formats
26 / 44
8-9
6
Homework
8-12 Write a program to evaluate the arithmetic statement.
RPN:
Immediate
The use of a constant in MOV R1, 5, i.e. R1 5
Register
Indicate which register holds the operand
33 / 44
Addressing Modes
Register Indirect
Indicate the register that holds the number of the
register that holds the operand
R1
MOV R1, (R2)
Direct Address
Use the given address to access a memory location
34 / 44
Addressing Modes
Indirect Address
Indicate the memory location that holds the address of
the memory location that holds the data
AR = 101
100
101 0 1 0 4
102
103
104 1 1 0 A
35 / 44
Addressing Modes
Relative Address
EA = PC + IR(Address) 0
1
PC = 2 2
100
AR = 100
101
102 1 1 0 A
103
104
36 / 44
Addressing Modes
Indexed
EA = Index Register + AR(Address)
IR = 2
100
AR = 100
101
102 1 1 0 A
103
104
37 / 44
Addressing Modes
Base Register
EA = Base Register + AR(Address)
AR = 2
100 0 0 0 5
R1 = 100
101 0 0 1 2
102 0 0 0 A
103 0 1 0 7
104 0 0 5 9
38 / 44
Addressing Modes
Implied
Immediate
Register
Register Indirect
Auto increment / Auto decrement
Direct Address
Indirect Address
Relative Address
Indexed
Base Register
39 / 44
Addressing Modes
399 450
IR= 100 700
400
401 725
AC
500 800
600 900
R15
Common to D and A
R10
R73
Proc D Local to D
R64
R63
Common to C and D
R58
R57
Proc C Local to C
R48
R47
Common to B and C
R42
R41
Proc B Local to B
R32
R32 R31
Common to A and B
R26
R25
Proc A Local to A
R16
R15
Common to A and D
R10
R9
Common to all
procedures
R0
Global
registers
OVERLAPPED REGISTER WINDOWS
There are three classes of registers:
Global Registers(10 registers)
Available to all functions
Window local registers(10 registers)
Variables local to the function
Window shared registers(2set of 6 registers)
Permit data to be shared without actually needing to copy it
This saves
Accesses - memory to access the stack.
The cost of copying the register contents at all
No of global registers = G
No of registers in each window = L
No. of registers common to two windows = C
No of window = W
CISC
Design of Instruction set for the processor
46 / 44
RISC
47 / 44
Types of Instructions
Arithmetic Name
Increment
Mnemonic
INC
Decrement DEC
Logical & Bit Manipulation Add ADD
Subtract SUB
Shift Multiply MUL
Divide DIV
Add with carry ADDC
Subtract with borrow SUBB
Name Mnemonic
Negate NEG
Clear CLR
Complement COM Name Mnemonic
AND AND Logical shift right SHR
OR OR Logical shift left SHL
Exclusive-OR XOR Arithmetic shift right SHRA
Clear carry CLRC Arithmetic shift left SHLA
Set carry SETC Rotate right ROR
Complement carry COMC Rotate left ROL
Enable interrupt EI Rotate right through carry RORC
Disable interrupt DI Rotate left through carry ROLC
49 / 44
Program Control Instructions
Name Mnemonic
Branch BR
Jump JMP
Skip SKP
Call CALL Carry bit, Sign bit,
Zero bit, Overflow bit
Return RET
Compare (Subtract) CMP
Test TST
50 / 44
Status Bits
8-bit 8-bit
C7 = 1
A B
C8 =1 ALU
F0 to F7
V Z S C
F7 = 1
Zero Check
51 / 44
Questions of GTU
1. List the characteristics of RISC architecture & CISC architecture. (4 times)
3. List the addressing modes. Explain any Three with example. (4-5 times)
4. What is overlapped register window? How window size and register file size
is computed? (4-5 times)
52 / 44
Questions of GTU Conti
6. Convert the following into reverse polish notation.
1) A+B*[C*D+E*(F+G)]
2) A*[B+C*(D+E)] / [F+G*(H+I)] (2 times)
54 / 44
8-7
(a) A*B+C*D+E*F
RPN: AB * CD * EF * + +
(b) A*B+A*(B*D+C*E)
RPN: AB * ABD * CE * + * +
(c) A+B*[C*D+E*(F+G)]
RPN: FG+E*CD*+B*A+