Unit IV Cpu Organization
Unit IV Cpu Organization
Organization
G.Rajendra
Assistant Professor,
MCA Department, LBRCE
Register set
ALU
Control units
CPU
The central processing unit (CPU) of a
computer is the main unit that dictates
the rest of the computer organization
Control
Unit
Arithmetic
Logic Unit
Registers
Control
Unit
Arithmetic
Logic Unit
Registers
Main
Memory
Bus
Printer
Register Transfer
Language
Register: A register consists of a group of flip flops with
a clock input. Registers are commonly used to store and
shift binary data.
Register Transfer Language:
The symbolic notation used to describe the micro
operation transfers among registers is called a register
transfer language.
The operations executed on data stored in registers are
called microoperations.
Register Transfer
Language
The internal hardware organization of a digital
computer is best defined by specifying
1. The set of registers it contains and their function
2. The sequence of micro operations performed on
the binary information stored in the registers.
3. The control that initiates the sequence of micro
operations.
Register Transfer:
Computer registers are designated by capital
letters
( sometimes followed by numerals) to
denote the function of the register.
Register Transfer
Language
Register Transfer
Language
(a) Register R
individual bits
15
R2
( C) Numbering of
bits
(b). Showing
0
PC(H)
PC(L)
Register Transfer
Language
Register Transfer
Language
Often we want the transfer to occur only under a
predetermined control condition,
IF(P=1) then (R2 R1) where p is a
control signal generated in the control section.
The control function is a Boolean variable that is
equal to 1 or 0.
The control function is included in the statement as
follows:
P: R2 R1, control function is terminated by colon.
Which means if p =1, then load the contents of
register R1 into register R2.
Register Transfer
Language
Load
R2
clock
R1
Register Transfer
Language
Description
examples
Letters
( and Numerals)
Denotes a Register
MAR, R2
Parenthesis
Denotes a part of a
register
R2(0-7), R2(L)
R2(8-15), R2(H)
Arrow
Denotes the
transfer of
information
R2 R1
Comma
Separates two
micro operations
R2R1, R1R2
Computer Registers
Computer Registers
0
AR
15
0
IR
15
Memory
4096 words
16 bits per word
0 15
TR
0
OUTR
DR
0 15
INTR
AC
Computer Registers
Computer Registers
Program Counter(PC) :
Computer Registers
Computer Registers
Number
Register
of bits
name
16
Data register
12
Address register
16
Accumulator
16
Instruction register
12
Program counter
16
Temporary register
8
Input register
8
Output register
Register
Function----------------------Holds memory operands
Holds address for memory
Processor register
Holds instruction code
Holds address of instruction
Holds temporary data
Holds input character
Holds output character
4 *1
M UX 3
4 *1
M UX 2
4 *1
M U X 1
4 *1
M UX 0
Register D
Register C
Register B
Register A
S0
0
1
0
1
Register selected
A
B
C
D
Memory Transfer
Computer Instructions
15 14
Opcode
0
Address
Register-Reference Instructions
15
0
12 11
Register operation
1
Input-Output Instructions
15
1 1
12 11
1
(OP-code = 111, I = 0)
0
(OP-code =111, I = 1)
0
I/O operation
Computer Instructions
Computer Instructions
Computer Instructions
Computer Instructions
Hex
I=0
0xxx
1xxx
2xxx
3xxx
4xxx
5xxx
6xxx
Code
I=1
8xxx
9xxx
Axxx
Bxxx
Cxxx
Dxxx
Exxx
Description
AND memory word to AC
Add memory word to AC
Load AC from memory
Store content of AC into memory
Branch unconditionally
Branch and save return address
Increment and skip if zero
CLA
CLE
CMA
CME
CIR
CIL
INC
SPA
SNA
SZA
SZE
HLT
7800
7400
7200
7100
7080
7040
7020
7010
7008
7004
7002
7001
Clear AC
Clear E
Complement AC
Complement E
Circulate right AC and E
Circulate left AC and E
Increment AC
Skip next instr. if AC is positive
Skip next instr. if AC is negative
Skip next instr. if AC is zero
Skip next instr. if E is zero
Halt computer
INP
OUT
SKI
SKO
ION
IOF
F800
F400
F200
F100
F080
F040
Input character to AC
Output character from AC
Skip on input flag
Skip on output flag
Interrupt on
Interrupt of
Instruction set
completeness
1.
2.
3.
4.
Arithmetic Micro
operations
A micro operation is an elementary operation
performed with the data stored in registers.
Classified into four categories
1. Register transfer micro operations transfer
binary information from one register to another.
2. Arithmetic micro operations perform arithmetic
operations on numeric data stored in registers.
3. Logic micro operations perform bit manipulation
operations on non-numeric data stored in
registers
4. Shift micro operations perform shift operations
on data stored in registers.
Arithmetic Micro
operations
Arithmetic Micro
operations
Arithmetic Micro
operations
Symbolic
Designation
Description
R3 R1 + R2
R3 R1 R2
R2 R2
R2 R2 + 1
R1 R1 1
Stack organization
Stack organization
Stack organization
Register Stack: A stack can be organized
as a collection of a finite number words or
registers.
Fig: Block diagram of a 64-word stack
Stack Organization
Note: FULL 1 ,when the stack is full, FULL 0 , when the stack is not
full
EMTY 1, when the stack is empty of items
EMTY 0, when the stack is not empty
Stack Organization
Stack Organization
Stack Organization
Stack Organization
Stack Organization
The top Item is read from the stack into DR. The
stack pointer is then decremented. If its value
reaches 0, the stack is empty, so EMTY is set to 1.
Stack Organization
Stack Organization
Stack Organization
prefix notation, places the operator before the
operands.
The postfix notation, referred to as Reverse
Polish Notation(RPN) places the operators after
the operands.
Example: A + B infix notation
+ AB
Postfix notation
AB + Postfix or Reverse Polish Notation
The Reverse Polish Notation is a form suitable for
stack manipulation.
Stack Organization
The expression A * B + C * D is written as AB *CD*
Evaluated as follows
1. Scan the expression from left to right.
2. When an operator is reached, perform the operation
with the two operands found on the left side of the
operator.
3. Replace the two operands and the operator by the
result obtained from the operation.
n Example:
infix 3*4+5*6=42
postfix 34*56*+
1256*+
1230+
42
Stack Organization
Reverse Polish notation evaluation with a stack.
Stack is the most efficient way for evaluating
arithmetic expressions.
(Example) using stacks to do this.
3 * 4 + 5 * 6 = 42
=> 3 4 * 5 6 * +
Instruction Codes
Instruction Codes
Instruction Codes
An instruction code must therefore specify not
only the operation but also the registers or the
memory words where the operands are to be
found, as well as registers or memory words
where the results is to be stored.
Stored program Organization
The simplest way to organize a computer is to
have one processor register and instruction
code format with two parts. The first part
specifies the operation to be performed and the
second part specifies an address.
Instruction Codes
Instruction Codes
Computer instruction
Instruction Codes
12 11
Opcode
Address
Instruction Format
1
5
Binary Operand
Instruction Codes
Fig: Stored Program Organization
Memory
4096 * 16
Instructions
(Program)
Operands
(data)
Processor Register
(accumulator or AC )
Instruction Codes
Instruction Codes
15
Op. Code
Address
instruction
data
Not an instruction
Instruction codes
Instruction Code
Op code
Address
Instruction Code
Fig: Demonstration of direct and indirect
address
Indirect addressing
Direct addressing
22
457
ADD
35
300
457
ADD
300
1350
Operand
1350
+
AC
Operand
+
AC
Instruction Cycle
1.
2.
3.
4.
Instruction Cycle
Instruction Cycle
T0: AR PC
T1: IR M[AR], PC PC+1
Instruction Cycle
Instruction Cycle
S2
T0
S1 Bus
S0
Memory
unit
7
Address
Read
AR
LD
PC
INR
IR
LD
Common bus
5
Clock
Instruction Cycle
1.
2.
3.
4.
Instruction Cycle
Determine the Type of Instruction
The timing signal that is active after the decoding is
T3. During time T3, the control unit determines the
type of instruction that was just read from memory.
Decoder output D7 is equal to 1 if the operation code
is equal to binary 111 we determine that if D7=1,
the instruction must be register or input-output
instruction type. If D7=0, the operation code must
be one of the other seven values 000 through 110,
specifying a memory-reference instruction.
Instruction Cycle..
Register Reference
Instruction
r:
rB11:
rB10:
rB9:
SC 0
AC 0
E0
AC AC
CME
CIR
CIL
INC
SPA
SNA
SZA
SZE
HLT
rB8:
rB7:
rB6:
rB5:
rB4:
rB3:
rB2:
rB1:
rB0:
E E
Complement E
AC shr AC, AC(15) E, E AC(0) Circulate right
AC shl AC, AC(0) E, E AC(15) Circulate left
AC AC + 1
Increment AC
if (AC(15) = 0) then (PC PC+1)
Skip if positive
if (AC(15) = 1) then (PC PC+1)
Skip if negative
if (AC = 0) then (PC PC+1)
Skip if AC zero
if (E = 0) then (PC PC+1)
Skip if E zero
S 0 (S is a start-stop flip-flop)
Halt computer
Clear SC
Clear AC
Clear E
Complement AC
Memory Reference
Instructions
Memory Reference
Instructions
Memory Reference
Instructions
Table: Memory Reference Instruction
Symbol
Operation
Decoder
Symbolic description
AND
D0
AC AC M[AR]
ADD
D1
AC AC + M[AR], E Cout
LDA
D2
AC M[AR]
STA
D3
M[AR] AC
BUN
D4
PC AR
BSA
D5
M[AR]PC, PCAR+1
ISZ
D6
M[AR]M[AR]+1,
If M[AR]+1 =0 then PC PC +1
Memory Reference
Instructions
AND to AC
This is an instruction that performs the AND logic
operation on pairs of bits in AC and the memory word
specified by the effective address. The result of the
operation is transferred to AC. The micro operations that
execute this instruction are:
D0T4 : DR M[AR]
D0T5: AC AC DR, SC 0.
The control function for this instruction uses the operation
decoder D0 since this output of the decoder is active
when the instruction has an AND operation whose binary
code value is 000.
Two timing signals are needed to execute the instruction.
Memory Reference
Instructions
Two timing signals are needed to execute the instruction.
The clock transition associated with timing signal T4
transfers the operand from memory into DR.
The clock transition associated with the next timing signal
T5 transfers to AC the result of the AND logic operation
between the contents of DR and AC.
The clock transition associated with timing signal T4
transfers the operand from memory into DR.
The clock transition associated with the next timing signal
T5 transfers to AC the result of the AND logic operation
between the contents of DR and AC.
Memory Reference
Instruction
ADD to AC
The instruction adds the content of the memory
word specified by the effective address to the
value of AC. The sum is transferred into AC and
the output carry Count is transferred to the E
(extended accumulator) flip-flop. The micro
operations needed to execute this instruction
are
D1T4: DR M[AR]
D1T5: AC AC + DR, E Cout, SC 0
Memory Reference
Instruction
Memory Reference
Instruction
LDA : Load to AC
This instruction transfers the memory word
specified by the effective address to AC.
The microoperations needed to execute this
instruction are
D2T4: DR M[AR]
D2T5: AC DR, SC 0
Memory Reference
Instruction
STA : Store AC
This instruction stores the content of AC into
the memory word specified by the effective
address.
Since the output of AC is applied to the bus and
the data input of memory is connected to the
bus,
we can execute this instruction with one micro
operation:
D3T4: M[AR] AC, SC 0
Memory Reference
Instruction
Memory Reference
Instruction
D5T5: PC AR, SC 0
AR = 135
136
Subroutine
1 BUN 135
Memory
135
PC = 136
21
Subroutine
1 BUN 135
Memory
Memory Reference
Instruction
ISZ : Increment and Skip if Zero
This instruction increments the word specified by
the effective address, and if the incremented
value is equal to 0, PC is incremented by 1.
This is done with the following sequence of
microoperations:
D T : DR M[AR]
6 4
D6T5: DR DR + 1
ADD
LDA
D0 T4
D1 T4
DR M[AR]
DR M[AR]
D0 T5
D1 T5
AC AC DR AC AC + DR
SC 0
E Cout
SC 0
BUN
BSA
STA
D2 T4
DR M[AR]
D3 T4
M[AR] AC
SC 0
D2 T5
AC DR
SC 0
ISZ
D4 T4
D5 T4
D6 T4
PC AR
M[AR] PC
DR M[AR]
SC 0
AR AR + 1
D5 T5
PC AR
SC 0
D6 T5
DR DR + 1
D6 T6
M[AR] DR
If (DR = 0)
then (PC PC + 1)
SC 0
Instruction Formats
Instruction Formats
Instruction Formats
Instruction Formats
General Register Organization: The
instruction format in this type of computer needs
three registers address fields.
ADD R1, R2, R3
R1 R2+ R3
We can reduce from three to two if the destination
register is the same as one of the source register.
ADD R1, R2
MOV R1, R2
R1 R1+R2
R1 R2 (OR R2 R1)
Instruction Formats
ADD R1, X
R1 R1 + M[X].
It has two address fields, one form register R1
and the other from the Memory address X.
Computers with Stack organization would
have PUSH and POP instructions which
require an address field.
Thus the instruction
PUSH X Will push the word at X to the top
of stack. Operation type instruction do not
need an address field in stack organized
computers.
Instruction Formats
Instruction Formats
Instruction Formats
The advantage of the three address formats is
that it results in short program when evaluating
arithmetic expression.
The disadvantage is that the binary-coded
instructions require too many bits to specify
three addresses.
Two Address Instruction:
Most common in commercial computers. Each
address field can specify either a processes
register on a memory word.
X = (A + B) * ( C + D)
Instruction Formats
MOV
R1, A
R1M [A]
ADD
R1, B
R1 R1 + M [B]
MOV
R2, C
R2 M [C]
ADD
R2, D
R2 R2 + M [D]
MUL
R1, R2
R1 R1 * R2
MOV
X, R1 M [X] R1
Instruction Formats
LOAD A
ADD B
STORE T
LOAD C
ADD D
MUL T
STORE X
AC M [A]
AC AC + M [B]
M [T] AC
AC M (C)
AC AC + M (D)
AC AC * M (T)
M [] AC
Instruction Formats
All operations are done between the AC register
and a memory operand. Its the address of a
temporary memory location required for storing
the intermediate result.
Zero Address Instruction
A stack organized computer does not use an
address field for the instruction ADD and MUL.
The PUSH & POP instruction, however, need an
address field to specify the operand that
communicates with the stack (TOS top of the
stack)
Instruction Formats
PUSH
TOS A
PUSH
TOS B
ADD
PUSH
TOS C
PUSH
TOS D
ADD
TOS (C + D)
MUL
POP
TOS (C + D) * (A + B)
M [X] TOS
TOS (A + B)
Addressing Modes
Addressing Modes
Addressing Modes
1.
2.
3.
Addressing Modes
Addressing Modes
Addressing Modes
Implied Mode:
In this mode the operands are specified
implicitly in the definition of the instruction.
For example: The instruction complement
accumulator is an implied mode instruction
because the operand in the accumulator register
is implied in the definition of the instruction.
In fact, all register reference instructions that
use an accumulator are implied mode
instructions
Addressing Modes
Zero-address instructions in a stack organization
computer are implied-mode instructions since the
operands are implied to be on top of the stack.
Examples
RAL : Rotate the contents of the accumulator left
RLC: Rotate the contents of the accumulator left
through carry
CMA : Take the complement of the contents of the
accumulator
Addressing Modes
Immediate Mode: In this mode the operand is
specified in the instruction itself. In other words, an
immediate mode instruction has an operand field
rather than address field.
Example:
MVI A, 06 : Move 06 to the accumulator
ADI 05 : Add 05 to the content of the accumulator
Register Mode: In this mode the operands are in
registers that reside within the CPU. In other words
the contents of a register is the operand.
Addressing Modes
Example:
MOV A ,B : Transfer the contents of the register B to register A.
ADD B : Add the contents of the register B to the contents of the
accumulator.
No memory access
Very fast execution
Very limited address space
Register Address R
Memory
Registers
Pointer to Operand
Operand
Addressing Modes
Direct Addressing: In this mode the effective
address is equal to the address part of the
instruction. The operand resides in memory and
its address is given directly by the address field
of the instruction.
Advantages:
Single memory reference to access data
No additional calculations to work out effective
address
Limited address space
Address A
Memory
Operand
Addressing Modes
Indirect Addressing
Diagram
Instruction
Opcode
Address A
Memory
Pointer to operand
Operand
Addressing Modes
Addressing Modes
Addressing Modes
Direct Relative Addressing Mode:
Address of operand = EA
= Content of PC +
Displacement
Indirect Addressing Mode: Address of operand
is calculated by adding the content of register
indicated by the base register and displacement
Address of Operand = EA
= Displacement + Base
address
Addressing Modes
Example:
Main Memory
If PC
ADD
R1
24
800
800
24
100
Addressing Modes
Indexed Addressing Mode:
In this mode the content of an index register is
added to the address part of the instruction to
obtain EA. The index register is a special CPU
register that contains an index value
Example:
index
ADD
R1
500
24
50
0
52
4
Main
Memory
1001