CO Unit-II
CO Unit-II
ORGANIZATION
Central Processing Unit
1. Stack Organization
A useful feature that is included in the CPU of most computers is a stack or last in, first
out (LIFO) list. A stack is a storage device that stores information in such a manner that the
item stored last is the first item retrieved. The operation of a stack can be compared to a stack
of trays. The last tray placed on top of the stack is the first to be taken off.
The register that holds the address for the stack is called a stack pointer (SP) because its
value always points at the top item in stack.
The two operation of stack are the insertion and deletion of items.
1. The operation of insertion is called PUSH.
2. The operation of deletion is called POP
Register Stack:
Below figure shows the organization of a 64-word register stack. The stack
pointer register SP contains a binary number whose value is equal to the address of the word
that is currently on top of the stack. In a 64-word stack, the stack pointer contains 6
bits because
6
2 =64.
The one bit register Full is set to 1 when the stack is full, and the one-bit register EMTY
is set to 1 when the stack is empty of items.
NEC (Autonomous) 1
UNIT-III COMPUTER ARCHITECTURE AND
A portion of memory isORGANIZATION
used as a stack with a processor register as a stack
pointer
PUSH: SP SP + 1
M[SP] DR
POP: DR M[SP]
SP SP - 1
Most computers do not provide hardware to check stack overflow (full stack) or
underflow (empty stack).
Reverse Polish Notation (Postfix
Notation):
Arithmetic Expressions: A +
B
A + B Infix notation
+ A B Prefix or Polish notation
A B + Postfix or reverse Polish notation
Any arithmetic expression can be expressed in parenthesis-free Polish
notation, including reverse Polish notation.
2. Instruction
Formats
1.An operation code field that specifies the operation to be performed.
2.An address field that designates a memory address or a processor register.
3.A mode field that specifies the way the operands or the effective address is determined.
a. Three-Address Instructions:
In three-address machines, instructions carry all three addresses explicitly. The
RISC processors use three addresses. Table X1 gives some sample instructions
of a three-address machine.
ADD R2 A B
M [X] ← R1 ∗ R2
ADD R2, C, D ; R2 ← M [C] + M [D]
MUL 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.
The advantage of the three-address format is that it results in short programs
when evaluating arithmetic expressions.
NEC (Autonomous) 2
UNIT-III COMPUTER ARCHITECTURE AND
The disadvantage is that the binary-coded instructions require too many
ORGANIZATION bits to specify
three addresses.
b. Two-address instructions:
Two address instructions are the most common in commercial computers. Here again
each address field can specify either a processor register or a memory word. The program to
X = (A + B) ∗ (C + D) is as follows:
evaluate
MOV R1 A
The MOV instruction moves or transfers the operands to and from memory and
processor registers. The first symbol listed in an instruction is assumed to be both a source and
the destination where the result of the operation is transferred
c. One-address instructions:
One-address instructions use an implied accumulator (AC) register for all
LOAD A; AC ← M [A]
ADD B; AC ← AC + M [B]
STORE T; M [T] ← AC
LOAD C; AC ← M [C]
AC ← AC ∗ M [T]
ADD D; AC ← AC + M [D]
MUL T;
STORE X; M [X] ← AC
All operations are done between the AC register and a memory operand. T is
the address of a temporary memory location required for storing the intermediate result.
Advantage: Instruction size is very small
Dis advantage : Code will be more compared to two address and three address
instructions.
d. Zero-address instructions:
A stack-organized computer does not use an address field for the instructions ADD and
MUL. The PUSH and POP instructions, however, need an address field to specify the operand
MUL; TOS ← (C + D) ∗ (A + B)
POP X ; M [X] ← TOS
To evaluate arithmetic expressions in a stack computer, it is necessary to convert the
expression into reverse Polish notation. The name “zero-address” is given to this type
of computer because of the absence of an address field in the computational instructions.
3. Addressing
Modes
The operation field of an instruction specifies the operation to be performed. This
operation must be executed on some data stored in computer registers or memory words.
The way the address of operand specified in the INSTRUCTION
is called ADDRESSSING MODE.
Addressing modes are as:
1. Implied
Mode
Address of the operands are specified implicitly in the definition of the instruction
- No need to specify address in the instruction
- EA = AC, or EA = Stack[SP], EA: Effective Address.
PUSH
POP
2. Immediate
Mode
If the operand is part of instruction then it is called IMMEDIATE
addressing.
If address part of instruction contains Operand then it is called
IMMEDIATE addressing.
- No need to specify address in the instruction
- However, operand itself needs to be specified
- Sometimes, require more bits than the address
- Fast to acquire an operand
EA=Not defined.
3. Register
Mode
If address part of instruction contains REGITER NUMER then it
is called IREGISTER addressing.
Address specified in the instruction is the register address.
- Designated operand need to be in a register
- Shorter address than the memory address
- Saving address field in the instruction
- Faster to acquire an operand than the memory addressing
EA = IR(R); (IR(R): Register field of IR)
NEC (Autonomous) 4
UNIT-III COMPUTER ARCHITECTURE AND
ORGANIZATION
NEC (Autonomous) 5
UNIT-III COMPUTER ARCHITECTURE AND
ORGANIZATION
NEC (Autonomous) 6
UNIT-III COMPUTER ARCHITECTURE AND
ORGANIZATION
Numerical Example:
NEC (Autonomous) 7
UNIT-III COMPUTER ARCHITECTURE AND
ORGANIZATION
4. Data Transfer & Manipulation
Computer provides an extensive set of instructions to give the user the flexibility to
carryout various computational tasks. Most computer instruction can be classified into three
categories.
(1) Data transfer instruction
(2) Data manipulation instruction
(3) Program control instruction
Data transfer instruction cause transferred data from one location to another without changing
the binary instruction content. Data manipulation instructions are those that perform arithmetic
logic, and shift operations. Program control instructions provide decision-making capabilities
and change the path taken by the program when executed in the computer.
(1) Data Transfer Instruction
Data transfer instruction move data from one place in the computer to another without
changing the data content. The most common transfers are between memory and processes
registers, between processes register & input or output, and between processes register
themselves
(Typical data transfer instruction)
Name Mnemonic
Load LD
Store ST
Move MOV
Exchange XCH
Input IN
Output OUT
Push PUSH
Pop POP
(2) Data Manipulation Instruction
It performs operations on data and provides the computational capabilities for the computer.
The data manipulation instructions in a typical computer are usually divided into three basic
types.
(a) Arithmetic Instruction
(b) Logical bit manipulation Instruction
(c) Shift Instruction.
(a) Arithmetic Instruction
Name Mnemonic
Increment INC
Decrement DEC
Add Add
Subtract Sub
Multiply MUL
Divide DIV
Add with Carry ADDC
Subtract with Basses SUBB
Negate (2’s Complement) NEG
NEC (Autonomous) 8
UNIT-III COMPUTER ARCHITECTURE AND
(b) Logical & Bit ManipulationORGANIZATION
Instruction
Name Mnemonic
Clear CLR
Complement COM
AND AND
OR OR
Exclusive-Or XOR
Clear Carry CLRC
Set Carry SETC
Complement Carry COMC
Enable Interrupt ET
Disable Interrupt OI
(c) Shift Instruction
Instructions to shift the content of an operand are quite useful and one often provided in several
variations. Shifts are operation in which the bits of a word are moved to the left or right. The
bit-shifted in at the and of the word determines the type of shift used. Shift instruction may
specify either logical shift, arithmetic shifts, or rotate type shifts.
Name Mnemonic
Logical Shift right SHR
Logical Shift left SHL
Arithmetic shift right SHRA
Arithmetic shift left SHLA
Rotate right ROR
Rotate left ROL
Rotate mgmt through carry RORC
Rotate left through carry ROLC
(3) Program Control:
Instructions are always stored in successive memory locations. When processed in the
CPU, the instructions are fetched from consecutive memory locations and executed
Status Bit Conditions
It is sometimes convenient to supplement the ALU circuit in the CPU with a
status register where status b it conditions can be stored for further analysis. Status bits
are also called condition-code bits or flag bits. The four status bits are symbolized by C,
S, Z, and V. The bits are set or cleared as a result of an operation performed in the ALU.
NEC (Autonomous) 9
UNIT-III COMPUTER ARCHITECTURE AND
ORGANIZATION
4. Bit V (overflow) is set to 1 if the exclusive-OR of the last two carries is equal to 1,
and Cleared to 0 otherwise. This is the condition for an overflow when negative
numbers are In 2's complement.
For the 8-bit ALU, V = 1 if the output is greater than +127 or less than -128.
NEC (Autonomous) 10
UNIT-III COMPUTER ARCHITECTURE AND
ORGANIZATION
- Program status word the collection of all status bit conditions in the CPU is
sometimes called a program status word or PSW. The PSW is stored in a separate hardware
register and contains the status information that characterizes the state of the CPU.
Types of Interrupts
- There are three major types of interrupts that cause a break in the normal execution of
a Program. They can be classified as:
1. External interrupts
2. Internal interrupts
3. Software interrupts
- External interrupts come from input-output (I/O) devices, from a timing device, from a
circuit monitoring the power supply, or from any other external source.
- Internal interrupts arise from illegal or erroneous use of an instruction or data. Internal
interrupts are also called traps. Examples of interrupts caused by internal error conditions are
register overflow, attempt to divide by zero, an invalid operation code, stack overflow,
and protection violation.
- A software interrupt is initiated by executing an instruction. Software interrupt is
a special call instruction that behaves like an interrupt rather than a subroutine call. It can be
used by the programmer to initiate an interrupt procedure at any desired point in the program.
NEC (Autonomous) 11
UNIT-III COMPUTER ARCHITECTURE AND
ORGANIZATION
Control Memory
6. Introduction
The function of the control unit in a digital computer is to initiate sequences of
microoperations. When the control signals are generated by hardware using
conventional logic design techniques, the control unit is said to be hardwired.
Microprogramming is a second alternative for designing the control unit of a digital
computer.
o The principle of microprogramming is systematic method for controlling the
microoperation sequences in a digital computer.
A control unit whose binary control variables are stored in memory is called a
microprogrammed control unit.
A memory that is part of a control unit is referred to as a control memory.
o Each word in control memory contains within it a microinstruction.
o A sequence of microinstructions constitutes a microprogram.
o Can be either read-only memory(ROM) or writable control memory
(dynamic microprogramming)
A computer that employs a microprogrammed control unit will have two separate
memories:
o A main memory
o A control memory
The general configuration of a microprogrammed control unit is demonstrated as:
o The control memory is assumed to be a ROM, within which all control
information is permanently stored.
o The control address register specifies the address of the microinstruction.
o The control data register holds the microinstruction read from
memory.
Thus a microinstruction contains bits for initiating microoperations
in the data processor part and bits that determine the address sequence for the
control memory.
Microprogram
o Program stored in memory that generates all the control signals required
to execute the instruction set correctly
o Consists of microinstructions
Microinstruction
o Contains a control word and a sequencing word
Control Word - All the control information required for one clock cycle
Sequencing Word - Information needed to decide the next
microinstruction address
Vocabulary to write a microprogram
Control Memory (Control Storage: CS)
o Storage in the microprogrammed control unit to store the microprogram
Writeable Control Memory(Writeable Control Storage:WCS)
o CS whose contents can be modified
Allows the microprogram can be changed
Instruction set can be changed or modified
Dynamic Microprogramming
Computer system whose control unit is implemented with a microprogram in WCS
Microprogram can be changed by a systems programmer or a user.
NEC (Autonomous) 12
UNIT-III COMPUTER ARCHITECTURE AND
ORGANIZATION
Programming Microprogramming
Sequence of instructions is a program Sequence of micro instructions called
Program stored in memory(RAM) Micro program stored in the ROM
PC is used to store address of next CONTROL ADDRESS register is used to hold
instruction to be fetched address of next address sequence
Data is fetched into Data register Control Data Register holds Microinstruction read
from control memory.
Instruction contains mode bit, opcode Micro Instruction Micro operation bits, Next
and Address address Sequence
Opcode is used to generate control Micro Operation bits are to generate control
signals signals
RAM is divided into words Control Memory is divided into control words.
7. Microrogrammed Sequencer
The next address generator is sometimes called a
microprogram sequencer, as it determines the address sequence that is
read from control memory.
Typical functions of a microprogram sequencer are:
o Incrementing the control address register by one
o Loading into the control address register an address from control
memory
o Transferring an external address
o Loading an initial address to start the control operations
Advantages
The main advantage of the microprogrammed control is the fact that once the hardware
configuration is established; there should be no need for further hardware or wiring
change. Most computers based on the reduced instruction set computer
(RISC) architecture concept use hardwired control rather than a control memory with a
microprogram. (Why?)
A Microprogram Control Unit that determines the Microinstruction Address to be executed
in the next clock cycle
In-line Sequencing
Branch
Conditional Branch
Subroutine
Loop
Instruction OP-code mapping
NEC (Autonomous) 13
UNIT-III COMPUTER ARCHITECTURE AND
ORGANIZATION
Addressing Sequencing
Microinstructions are stored in control memory in groups, with each group specifying a
routine.
Each computer instruction has its own microprogram routine in control memory to
generate the microoperations that execute the instruction.
To appreciate the address sequencing in a microprogram control unit:
o An initial address is loaded into the control address register when
power is turned on in the computer.
NEC (Autonomous) 14
UNIT-III COMPUTER ARCHITECTURE AND
ORGANIZATION
NEC (Autonomous) 15
UNIT-III COMPUTER ARCHITECTURE AND
ORGANIZATION
Mapping of Instructions
A special type of branch exists when a microinstruction specifies a branch to the first
word in control memory where a microprogram routine for an instruction is located.
The status bits for this type of branch are the bits in the operation code part of
the instruction.
One simple mapping process that converts the 4-bit operation code to a 7-bit address for
control memory is shown in Fig. 3-3.
o Placing a 0 in the most significant bit of the address
o Transferring the four operation code bits
o Clearing the two least significant bits of the control address register
This provides for each computer instruction a microprogram routine with a capacity of
four microinstructions.
o If the routine needs more than four microinstructions, it can use addresses
1000000 through 1111111.
o If it uses fewer than four microinstructions, the unused memory locations would
be available for other routines.
One can extend this concept to a more general mapping rule by using a ROM
or programmable logic device (PLD) to specify the mapping function.
NEC (Autonomous) 16
UNIT-III COMPUTER ARCHITECTURE AND
Mapping from the OP-code of anORGANIZATION
instruction to the address of the Microinstruction which is the
starting microinstruction of its execution microprogram.
Subroutine
Subroutines are programs that are used by other routines to accomplish a
particular task.
Microinstructions can be saved by employing subroutines that use common sections of
microcode.
o e.g. effective address computation
The subroutine register can then become the source for transferring the address for the
return to the main routine.
The best way to structure a register file that stores addresses for subroutines is
to organize the registers in a last-in, first-out (LIFO) stack.
Computer Configuration
Once the configuration of a computer and its microprogrammed control unit is
established, the designer’s task is to generate the microcode for the control memory.
This microcode generation is called microprogramming.
The block diagram of the computer is shown in Below Fig.
Two memory units
o A main memory for storing instructions and data
o A control memory for storing the microprogram
Four registers are associated with the processor unit
o Program counter PC, address register AR, data register DR, accumulator register
AC
The control unit has a control address register CAR and a subroutine register SBR.
The control memory and its register are organized as a microprogrammed control unit.
The transfer of information among the registers in the processor is done through
multiplexers rather than a common bus.
NEC (Autonomous) 17
UNIT-III COMPUTER ARCHITECTURE AND
Microinstruction Format - ComputerORGANIZATION
instruction Format
The computer instruction format is depicted in Fig. (a).
It consists of three fields:
o A 1-bit field for indirect addressing symbolized by I
o A 4-bit operation code (opcode)
o An 11-bit address field
Fig. (b) lists four of the 16 possible memory-reference instructions.
NEC (Autonomous) 18
UNIT-III COMPUTER ARCHITECTURE AND
ORGANIZATION
NEC (Autonomous) 17
UNIT-III COMPUTER ARCHITECTURE AND
ORGANIZATION
Fig: Symbols and Binary code for Microinstruction fields
The CD field consists of two bits which are encoded to specify four status
bit conditions as listed in above Table.
The BR field consists of two bits. It is used, in conjunction with the address field
AD, to choose the address of the next microinstruction.
o The jump and call operations depend on the value of the CD field.
o The two operations are identical except that a call microinstruction stores
the return address in the subroutine register SBR.
o Note that the last two conditions in the BR field are independent of the values in
the CD and AD fields.
Symbolic Microinstructions
The symbols defined in Table 3-1 cab be used to specify microinstructions in symbolic
form.
Symbols are used in microinstructions as in assembly language
The simplest and most straightforward way to formulate an assembly language for a
microprogram is to define symbols for each field of the microinstruction and to
give users the capability for defining their own symbolic addresses.
A symbolic microprogram can be translated into its binary equivalent by a microprogram
assembler.
Sample Format
Five fields: label; micro-ops; CD; BR; AD
The label field: may be empty or it may specify a symbolic address terminated with a
colon
The microoperations field: of one, two, or three symbols separated by commas ,
the
NOP symbol is used when the microinstruction has no microoperations
The CD field: one of the letters {U, I, S, Z} can be chosen where
o U: Unconditional Branch
o I: Indirect address bit
o S: Sign of AC
o Z: Zero value in AC
The BR field: contains one of the four symbols {JMP, CALL, RET, MAP}
The AD field: specifies a value for the address field of the microinstruction with one of
{Symbolic address, NEXT, empty}
o When the BR field contains a RET or MAP symbol, the AD field is left empty
Fetch Subroutine
During FETCH, Read an instruction from memory and decode the instruction and update PC.
The first 64 words are to be occupied by the routines for the 16 instructions.
The last 64 words may be used for any other purpose.
o A convenient starting location for the fetch routine is address 64.
The three microinstructions that constitute the fetch routine have been listed in
three different representations.
o The register transfer representation:
NEC (Autonomous) 18
UNIT-III COMPUTER ARCHITECTURE AND
ORGANIZATION
Symbolic Microprogram
Control Storage: 128 20-bit words
The first 64 words: Routines for the 16 machine instructions 0, 4, 8, …, 60 gives four
words in control memory for each routine.
The last 64 words: Used for other purpose (e.g., fetch routine and other subroutines)
The execution of the third (MAP) microinstruction in the fetch routine results in
a branch to address 0xxxx00, were xxxx are the four bits of the operation code. e.g.
ADD is 0000
In each routine we must provide microinstructions for evaluating the effective address
and for executing the instruction.
The indirect address mode is associated with all memory-reference instructions.
A saving in the number of control memory words may be achieved if
the microinstructions for the indirect address are stored as a subroutine.
This subroutine, INDRCT, is located right after the fetch routine, as shown in Table.
Mapping: OP-code XXXX into 0XXXX00, the first address for the 16 routines are 0(0
0000 00), 4(0 0001 00), 8, 12, 16, 20, ..., 60
To see how the transfer and return from the indirect subroutine occurs:
o MAP microinstruction caused a branch to address 0
o The first microinstruction in the ADD routine calls subroutine INDRCT when
I=1
o The return address is stored in the subroutine register SBR.
o The INDRCT subroutine has two microinstructions:
INDRCT: READ U JMP NEXT
DRTAR U RET
o Therefore, the memory has to be accessed to get the effective address, which is
then transferred to AR.
o The execution of the ADD instruction is carried out by the microinstructions at
addresses 1 and 2
o The first microinstruction reads the operand from memory into DR.
o The second microinstruction performs an add microoperation with the content
of DR and AC and then jumps back to the beginning of the fetch routine.
NEC (Autonomous) 19
UNIT-III COMPUTER ARCHITECTURE AND
ORGANIZATION
NEC (Autonomous) 20
UNIT-III COMPUTER ARCHITECTURE AND
ORGANIZATION
NEC (Autonomous) 21
UNIT-III COMPUTER ARCHITECTURE AND
The basic components of aORGANIZATION
microprogrammed control unit are the control memory and
the circuits that select the next address.
The address selection part is called a microprogram sequencer.
A microprogram sequencer can be constructed with digital functions to suit a particular
application.
To guarantee a wide range of acceptability, an integrated circuit sequencer must
provide an internal organization that can be adapted to a wide range of application.
The purpose of a microprogram sequencer is to present an address to the control
memory so that a microinstruction may be read and executed.
The block diagram of the microprogram sequencer is shown in below Fig.
o The control memory is included to show the interaction between the sequencer
and the attached to it.
o There are two multiplexers in the circuit; first multiplexer selects an
address from one of the four sources and routes to CAR, second multiplexer
tests the value of the selected status bit and result is applied to an input logic
circuit.
o The output from CAR provides the address for control memory, contents of
CAR incremented and applied to one of the multiplexers input and to the SBR.
o Although the diagram shows a single subroutine register, a typical sequencer will
have a register stack about four to eight levels deep. In this way, a push, pop
operation and stack pointer operates for subroutine call and return instructions.
o The CD (Condition) field of the microinstruction selects one of the status bits in the
second multiplexer.
o The Test variable (either 1 or 0) i.e. T value together with the two bits from the BR
(Branch) field go to an input logic circuit.
o The input logic circuit determines the type of the operation.
NEC (Autonomous) 22
UNIT-III COMPUTER ARCHITECTURE AND
Typical sequencer operationsORGANIZATION
are: increment, branch or jump, call and return
from subroutine, load an external address, push or pop the stack, and other
address sequencing operations.
Based on the function listed in each entry was defined in previous Table, the truth table
for the input logic circuit is shown in below Table.
Therefore, the simplified Boolean functions for the input logic circuit can be given as:
S0 = I 0
S1 = I0I1 + I0’T
L = I0’I1T
The bit values for S1 and S0 are determined from the stated function and the path in the
multiplexer that establishes the required transfer.
Note that the incrementer circuit in the sequencer diagram is not a counter constructed
with flip-flops but rather a combinational circuit constructed with gates.
NEC (Autonomous) 23