COA - Unit-III - Notes (1) Edited
COA - Unit-III - Notes (1) Edited
Suman Singh
Assistant Professor (IT)
UNIT – III:-No. of Hours: 11 Chapter/Book Reference: TB1 [Chapter-5, 9], RB3 [Chapter-11]
Data Transfer Operations: Register Transfer, Bus and Memory Transfer, Registers and micro-
operations. Basic Computer Organizations and Design: Instruction Codes, Computer Registers,
Instruction Cycle, General Register Organization, Stack Organization, Instruction Formats,
Addressing Modes,
Data Transfer Operations: Register Transfer, Bus and Memory Transfer, Registers and micro-
operations.
Micro operation: The operations executed on the data stored in registers are called micro
operations.
A symbolic language
A convenient tool for describing the internal organization of digital
computers
Can also be used to facilitate the design process of digital systems.
Register transfer implies the availability of hardware logic circuits that can perform a stated
micro operation and transfer the result of operation to the same register or another register.
Language implies the programming language or Symbolic language for register transfer.
Register
Page 1 of 38
Computer Organization Architecture Unit-III Ms. Suman Singh
Assistant Professor (IT)
– PC - program counter
– IR - instruction register
Registers and their contents can be viewed and represented in various ways
A register can be viewed as a single entity:
Registers may also be represented showing the bits of data they contain
Common ways of drawing the block diagram of a register
R2 R1
In this case the contents of register R2 are copied (loaded) into registerR1
A simultaneous transfer of all bits from the source R1 to the destination
register R2, during one clock pulse
Note that this is a non-destructive; i.e. the contents of R1 are not altered by copying
(loading) them to R2
Example: A register transfer such as
R3 R5
Implies that the digital system has
the data lines from the source register (R5) to the destination register (R3)
Parallel load in the destination register (R3)
Control lines to perform the action
Transfer to occur only under a predetermined control condition This is shown by an if-
else statement
If (P=1) then (R2 R1) Where P is a control signal.
In digital systems, if –else statement done via a control signal, called a control function
Control Function is a Boolean variable that is equal to 1 or 0.
Page 2 of 38
Computer Organization Architecture Unit-III Ms. Suman Singh
Assistant Professor (IT)
Here, if the control function P = 1, load the contents of R5 into R3, and at the same time (clock), load the
contents of register IR into register MAR
Page 3 of 38
Computer Organization Architecture Unit-III Ms. Suman Singh
Assistant Professor (IT)
• In a digital system with many registers, it is impractical to have data and control
lines to directly allow each register to be loaded with the contents of every possible
other registers
Bus: Bus is a path (of a group of wires) over which information is transferred, from any of
several sources to any of several destinations.
Common Bus: The more efficient scheme of transferring information between registers in a
multiple register organization configuration is called a Common bus system
Bus Structure Consists of a set of common lines, one for each bit of a register, through which
binary information is transferred one at a time. Control Signal determines which register is
selected by bus during register transfer.
Bus system is constructed with multiplexers; Multiplexers select the source register whose binary
information’s placed on the bus. The Bus consisted of four Multiplexers each having four input 0
to 4, and two selection inputs S1 and S0.there are four register 0 to 3.
Example: Output 1 of register A is connected to inputs 0 of MUX 1 because the input is labeled
as A1.
Page 4 of 38
Computer Organization Architecture Unit-III Ms. Suman Singh
Assistant Professor (IT)
Bus Selection: The two selection lines S1 and S0 are connected to the selection inputs of all four
multiplexers. The selection line selects the four bits of one register and transfers them into 4 line
common bus.
S1 S0 Register Selected
0 0 A
0 1 B
1 0 C
1 1 D
The transfer of information from a bus into one of many destination register can be accomplished
by connecting the bus lines to the inputs of all destination registers and activating the load
control for particular register selected.
The inverter is a triangle, followed by a circle/bubble. That circle sometimes appears by itself,
and meansnegation.
If we remove the circle… We'd have a buffer.
In buffer the output is exactly the same as the input.
Page 5 of 38
Computer Organization Architecture Unit-III Ms. Suman Singh
Assistant Professor (IT)
Three state gate: A three state gate is a digital circuit that exhibits three states. Two
states are signals equivalent to logic 0 and logic 1.third state is a high- impedance state.
High- impedance state Behaves like an open circuit, which means that the output is
disconnected and does not have logic significance.
Tri –State Buffer
A tri-state buffer is a useful device that allows us to control when current passes through the
device, and when it doesn't
Tri-state buffer has two inputs: a data input x and a control input c. The control input acts like a
valve. When the control input is active, the output is the input. That is, it behaves just like a
normal buffer. The "valve" is open.
When the control input is not active, the output is "Z". The "valve" is open, and no electrical
current flows through. Thus, even if x is 0 or 1, that value does not flow through
c x z
0 0 Z
0 1 Z
1 0 0
1 1 1
Page 6 of 38
Computer Organization Architecture Unit-III Ms. Suman Singh
Assistant Professor (IT)
Note: No more than one buffer may be in the active state at any given time
No more than one control input is active at any given time (when we use a decoder)
When the enable input of the decoder is 0, all of its four outputs are 0 and the bus line is
in a high-impedance state because all four buffers are disabled.
When the enable input is active one of the three state buffers will be active, depending on
the binary value in the select inputs of the decoder.
Page 7 of 38
Computer Organization Architecture Unit-III Ms. Suman Singh
Assistant Professor (IT)
Micro operations
Microoperation is an elementary operation performed with the data stored in registers. Computer
system micro operations are of four types these are:
Register transfer micro operations
Arithmetic micro operations
Logic micro operations
Shift micro operations
The basic arithmetic micro operations are:
Addition
Subtraction
Increment
Decrement
Shift.
The arithmetic microoperation defined by the statement:
R3 R1 +R2 Specifies the add operation
R3R1+R2’ +1 Specifies the subtract microoperation
R3 R1 + R2’+ 1 subtraction
R1 R1 + 1 Increment
R1 R1 – 1 Decrement
Page 8 of 38
Computer Organization Architecture Unit-III Ms. Suman Singh
Assistant Professor (IT)
Binary Adder:
To implement the add microoperation with hardware ,a digital circuit that forms the arithmetic
sum of two bits and the previous carry is called a full adder.
The binary adder is constructed with full adder circuits connected in cascade with output carry
from one full adder connected to the input carry of the next full-adder.
The augends bit of A and the addend bits of B are designated by subscript numbers from right to
left with subscript 0 denoting the low order bit. The carry are connected in a chain through the
full adders. The input carry to the binary adder is C0 and the output carry is C4. The S output of
the full adders generates the required sum bits.
Binary adder/subtractor:
The Subtraction (A-B) can be done by taking 2’s complements of B and adding it to A.
Page 9 of 38
Computer Organization Architecture Unit-III Ms. Suman Singh
Assistant Professor (IT)
The addition and subtraction operation can be combined into one common circuit by including an
exclusive OR gate with each full adder. In 4-bit adder/subtractor there is a mode input M controls
the operation. When M=0 the circuit is an adder and when M=1 the circuits become subtractor.
Each exclusive-OR gate receives input M and one of the inputs of B. When M=0, we have B
0=B. The full adder receives the value of B the input carry C0=0 and circuit performs A plus B.
When M=1 we have B 1 =B’ and C0=1.the B inputs are all complemented and a 1 is added
through the input carry, the circuits performs the A-B’+1.
Binary Incrementer:
In 4-bit binary incrementer one of the inputs to half adder is connected to logic-1 and the other
inputs is connected to least significant bit of the number to be incremented. The output carry
from one half adder is connected to one of the inputs of the next higher order half adder.
The circuit receives the four bits from A0 to A3 adds one to it and generates the incremented
output in S0 to S3.The output carry C4 will be 1 only after incrementing binary 111.
Arithmetic Circuit:
The basic components of an arithmetic circuit are parallel adder. In 4 bit arithmetic circuit it has
four full adder circuits that constitute the 4 bit adder and four multiplexers for choosing different
operations.
There are two 4 bit inputs A and B and a 4-bit output D.
The four inputs from A go directly to the X inputs of the binary adder.
Each of the four inputs from B are connected to data inputs of the multiplexers, The
multiplexers data inputs also receive the complement of B.
The other two data inputs are connected to logic 0 and logic 1
The four multiplexers are controlled by two selection inputs S1 and S0.
The input carry Cin goes to the carry input of FA in the least significant position.
The output of the binary adder is calculated from the following arithmetic sum:
D=A+Y+Cin
Page 10 of 38
Computer Organization Architecture Unit-III Ms. Suman Singh
Assistant Professor (IT)
Page 11 of 38
Computer Organization Architecture Unit-III Ms. Suman Singh
Assistant Professor (IT)
Binary Decrementer:
In 4-bit binary decrementer one of the inputs to full adder is connected to logic-1 and the other
inputs is connected to least significant bit of the number to be decremented.
Logic microoperations specify binary operations for strings of bits stored in registers.
Logic microoperations are bit-wise operations, i.e., they work on the individual bits of
data
useful for bit manipulations on binary data
There are, in principle, 16 different logic functions that can be defined over two binary
input variables
Page 12 of 38
Computer Organization Architecture Unit-III Ms. Suman Singh
Assistant Professor (IT)
The hardware implementation of logic microoperations requires that logic gates be inserted
for each bit or pair of bits in the registers to perform the required logic functions.
Logic circuit:
2. Each of four logic operations is generated through a gate that perform the logic .
3. The outputs of the gates are applied to the data inputs of the multiplexer.
4. The two selection input selects one of the data inputs of the multiplexers and directs
its value to output.
Page 13 of 38
Computer Organization Architecture Unit-III Ms. Suman Singh
Assistant Professor (IT)
1. SELECTIVE SET
• In a selective set operation, the bit pattern in B is used to set certain bits in A
1 1 0 0 A (t)
1010B
1 1 1 0 A (t+1) (A A + B) [t= clock time]
• If a bit in B is set to 1, that same position in A gets set to 1, otherwise that bit in A keeps
its previous value
2. SELECTIVE COMPLEMENT
1 1 0 0 A (t)
1 0 1 0 ()
0 1 1 0 A (t+1) (A A B)
• If a bit in B is set to 1, that same position in A gets complemented from its original
value,otherwise it is unchanged
3. SELECTIVE CLEAR
• In a selective clear operation, the bit pattern in B is used to clear certain bits in A
1 1 0 0 A (t)
1010B
0 1 0 0 A (t+1) (A A B’)
1 1 0 0 A (t)
1010B
1 0 0 0 A (t+1) (A A B)
• If a bit in B is set to 0, that same position in A gets set to 0, otherwise it is unchanged
Page 14 of 38
Computer Organization Architecture Unit-III Ms. Suman Singh
Assistant Professor (IT)
5. CLEAR OPERATION
• In a clear operation, if the bits in the same position in A and B are the same, they
arecleared in A, otherwise they are set in A
1 1 0 0 A (t)
1010B
0 1 1 0 A (t+1) (A A B)
6. INSERT OPERATION
• An insert operation is used to introduce a specific bit pattern into A register, leaving the
other bit positions unchanged
• This is done as
– A mask operation to clear the desired bit positions, followed by
– An OR operation to introduce the new bits into the desired positions
– Example
» Suppose you wanted to introduce 1010 into the low order four bits of A:
1101 1000 1011 0001 A (Original)
1101 1000 1011 1010 A (Desired)
» 1101 1000 1011 0001 A (Original)
Page 15 of 38
Computer Organization Architecture Unit-III Ms. Suman Singh
Assistant Professor (IT)
SHIFT MICROOPERATIONS
Are used for serial transfer of data. They can also be used with arithmetic, logic and
other data processing operations.
In shift microoperations the content of a register can be shifted to left or the right.
Logical shift
Circular shift
Arithmetic shift
Logical Shift
In a logical shift the serial input to the shift is a 0.
Page 16 of 38
Computer Organization Architecture Unit-III Ms. Suman Singh
Assistant Professor (IT)
Examples: R2 shr R2
R3 shl R3
Circular Shift
In a circular shift the serial input is the bit that is shifted out of the other end of the
register.
Page 17 of 38
Computer Organization Architecture Unit-III Ms. Suman Singh
Assistant Professor (IT)
ARITHMETIC SHIFT
The main distinction of an arithmetic shift is that it must keep the sign of the
number the same as it performs the multiplication or division
Page 18 of 38
Computer Organization Architecture Unit-III Ms. Suman Singh
Assistant Professor (IT)
Examples:
R2 ashr R2
R3 ashl R3
Information can be transferred to the register in parallel and then shifted to left and right.
A clock pulse is needed for loading the data into register and another pulse is needed to
initiate the shift.
The content of a register that has to be shifted is first placed onto a common bus whose
output is connected to the combinational shifter and shifted number is then loaded back
into the register.
This requires only one clock pulse for loading the shifted value into the register.
Page 19 of 38
Computer Organization Architecture Unit-III Ms. Suman Singh
Assistant Professor (IT)
4 –bit combinational circuit shifter
A combinational circuit shifter can be constructed with multiplexers .The 4 –bit shifter has four
data inputs, A0 through A3 and four data outputs,H0 through H3.There are two serial inputs one
for shift left(IL) and other is for shift right(IR).When the selection inputs S=0 the input data are
shifted right .When S=1 the input data are shifted left.
Select output
Input
S H0 H1 H2 H3
0 IR A0 A1 A2
1 A1 A2 A3 IL
Page 20 of 38
COA BCA-III M1 Prepared By: Ms. Suman Singh
Assistant Professor (IT)
IITM
INTRODUCTION
• Every different processor type has its own design (different registers, buses,
microoperations, machine instructions, etc)
• It contains
– Many registers
– Multiple arithmetic units, for both integer and floating point calculations
– Etc.
• However, to understand how processors work, we will start with a simplified processor
model
Page 21 of 38
COA BCA-III M1 Prepared By: Ms. Suman Singh
Assistant Professor (IT)
IITM
INSTRUCTIONS
• Program
• Instruction
– A group of bits that tell the computer to perform a specific operation (a sequence
of micro-operation)
• The instructions of a program, along with any needed data are stored in memory
• Control circuitry in control unit then translates the instruction into the sequence of
microoperations necessary to implement it
INSTRUCTION FORMAT
– An opcode (Operation Code) that specifies the operation for that instruction
– An address that specifies the registers and/or locations in memory to use for that
operation
• In the Basic Computer, since the memory contains 4096 (= 212) words, we needs 12 bit
to specify which memory address this instruction will use
• In the Basic Computer, bit 15 of the instruction specifies the addressing mode (0:
direct addressing, 1: indirect addressing)
• Since the memory words, and hence the instructions, are 16 bits long, that leaves 3 bits
for the instruction’s opcode
Page 22 of 38
COA BCA-III M1 Prepared By: Ms. Suman Singh
Assistant Professor (IT)
IITM
• The address field of an instruction can represent either
– Direct address: the address in memory of the data to use (the address of the
operand), or
– Indirect address: the address in memory of the address in memory of the data to
use
• Immediate instruction
– The address, that can be directly used without modification to access an operand
for a computation-type instruction, or as the target address for a branch-type
instruction
Computer instructions are stored in memory locations and are executed sequentially one at a
time. The control read an instruction from a specific address in memory and executes it.
Page 23 of 38
COA BCA-III M1 Prepared By: Ms. Suman Singh
Assistant Professor (IT)
IITM
Computer Registers:
Page 24 of 38
COA BCA-III M1 Prepared By: Ms. Suman Singh
Assistant Professor (IT)
IITM
List of basic computer registers
Computer Instructions
The basic computer has three instruction formats .each format is of 16 bits. The operation
part contain the three bits, 12 bit for address of operand n 1 bit for addressing mode or
address bit. These are:
3. Input –output instruction: An input –output instruction does not need a reference to
memory and recognized by the operation code 111 with a 1 in the 15th bit of the
instruction.
Page 25 of 38
COA BCA-III M1 Prepared By: Ms. Suman Singh
Assistant Professor (IT)
IITM
The type of instruction is recognized by the computer control from the four bits in
Position 12 through 15 of the instruction.
The total number of instructions chosen for the basic computer is equal to 25.
A computer should have a set of instructions so that the user can construct machine language
programs to evaluate any function that is known to be computable.
• Instruction Types
Functional Instructions
Transfer Instructions
- Data transfers between the main memory and the processor registers
Page 26 of 38
COA BCA-III M1 Prepared By: Ms. Suman Singh
Assistant Professor (IT)
IITM
Eg: - LDA, STA
Control Instructions
Input/Output Instructions
INSTRUCTION CYCLE
3. Read the effective address from memory if the instruction has an indirect address
• After an instruction is executed, the cycle starts again at step 1, for the next instruction
• Note: Every different processor has its own (different) instruction cycle
Initially the program counter PC is loaded with the address of the first instruction in the program.
After each clock pulse SC is incremented by one so that the timing signals go through T0, T1, T2
and so on the microoperations for the fetch and decode phase can be specified by the following
register transfer statements.
Page 27 of 38
COA BCA-III M1 Prepared By: Ms. Suman Singh
Assistant Professor (IT)
IITM
The timing signal that is active after the decoding is T3 .During T3 the control unit determine
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, if D7=1 the
instruction must be a register reference or input-output type, If D7=0 the operation code must
one of the other seven values 000 through 110 specifying a memory reference instruction.
The three instruction types are subdivided into four separate paths The selected operation is
activated with the clock transition associated with timing signal T3.This can be symbolized as
follows:
The computer that performs the bulk of data processing operations is called the central
processing unit and referred as CPU.
The CPU is made up of three major parts. These are:
1. Register set: stores intermediate data used during the execution of the instructions.
2. ALU: performs the required micro operations for executing the instructions.
3. Control unit: supervises the transfer of information among the registers and instructs the
ALU to which operation to perform
The control must provide binary selection variables the following selector inputs:
1. MUX A selector (SEL A): To place the content of R2 into bus A.
2. MUX B selector (SEL B): To place the content of R3 into bus B.
3. ALU operation selector (OPR): To provide the arithmetic addition A+B.
4. Decoder destination selector (SEL D): To transfer the content of the output bus into R1.
Page 29 of 38
COA BCA-III M1 Prepared By: Ms. Suman Singh
Assistant Professor (IT)
IITM
Control Variable: Control word is a 14-binary selection inputs in the unit and their combined
value specifies a control word.
Three fields contain three bits each and one field has five bits.
Three bits of SELA select a source register for the A input of the ALU
* The three bits of SELB select a register for the b input of the ALU.
* The three bit of SELD selects a destination register using the decoder.
* The five bits of OPR selects one of the operations in the ALU.
Page 30 of 38
COA BCA-III M1 Prepared By: Ms. Suman Singh
Assistant Professor (IT)
IITM
Stack Organization
A stack is a storage device that stores information, the item stored last is the first
retrieved (LIFO).
The stack in digital computers is essentially a memory unit with an address register.
The register that holds the address for the stack is called a stack pointer (SP).
The two operation of stack are the insertion and deletion of items.
The operation of insertion is called push and the deletion operation is pop
Push and pop operations are simulated by incrementing or decrementing the stack pointer
register.
Register Stack
Page 31 of 38
COA BCA-III M1 Prepared By: Ms. Suman Singh
Assistant Professor (IT)
IITM
• The one bit register FULL is set to 1 when stack is full
• The one bit register EMPTY is set to 1when the stack is empty of items.
• DR is the data register holds the binary data to be written or read of the stack
Push operations: initially SP is cleared to 0, EMPTY is set to 1 and FULL is cleared to 0
POP Operation:
A new item is deleted from the stack if the stack is not empty if EMPTY =0.the pop operation
consists of the following microoperations
Memory Stack
Page 32 of 38
COA BCA-III M1 Prepared By: Ms. Suman Singh
Assistant Professor (IT)
IITM
Three register are connected to a common address bus.PC is used for fetch phase, AR is used
during execution and SP is used to push or pop items into or from the stack.
• The initial value of SP is 4001 and the stack grows with decreasing addresses.
• First item stored in stack at 4000.
Pop operation in memory stack : A new item is deleted with a pop operation as follows
Page 33 of 38
COA BCA-III M1 Prepared By: Ms. Suman Singh
Assistant Professor (IT)
IITM
Note: most computers do not provide hardware to check for stack overflow or underflow.
Stack Limit:
The stack limit can be checked by using two processor registers one holds the upper limit
(3000)and other to holds the lower limit (4001).
After push operation SP is compared with the upper limit register and after a pop
operation SP is compared with lower limit register.
Instruction Formats
A Computer will usually have 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.
The Bit of the instruction is divided into groups called fields. The most common fields in
instruction format are:
Operation code field that specifies the operation to be performed.
Address field that designates a memory address or a processor register.
Mode field that specifies the way the operand or the effective address is determined.
Operations specified by computer instructions are executed on some data stored in
memory or processor register.
Operands residing in memory are specified by their memory address
Operands residing in processor registers are specified with a register address.
Computers may have instructions of several different lengths containing varying number
of address.
The number of address fields in the instruction format of a computer depends on the
internal organization of its register.
Most of the computers are one of the following types of CPU organizations:
1. Single Accumulator Organization
2. General Register Organization
3. Stack organization
Page 34 of 38
COA BCA-III M1 Prepared By: Ms. Suman Singh
Assistant Professor (IT)
IITM
Two Address Instructions
Two Address Instructions are the most common in commercial computers. The program to
evaluate X= (A+B)*(C+D) as follows
The PUSH and POP instructions needed an address field to specify the operand that
communicates with the stack
no address field
stack organized
computer use
Page 35 of 38
zero address instruction
instruction specify data itself
COA BCA-III M1 Prepared By: Ms. Suman Singh
Assistant Professor (IT)
IITM
Addressing Modes
The addressing mode specifies a rule for interpreting or modifying the address field of the
instruction before the operand is actually referenced. Addressing mode techniques is use for the
purpose of:
1. To give programming versatility
2. To reduce the number of bits in the addressing field of the instruction.
Mode Field: The mode field is used to locate the operands needed for the operation. There may
or may not be an address field in the instruction. The instruction may have more than one address
field.
In a basic computer there are following types of addressing mode these are:
1. Implied Mode:
In this mode the operands are specified implicitly in the definition of the
instruction.For example (complement accumulator) is an implied mode instruction
because the operand in the accumulator register is implied in the definition of
instruction. All register reference instructions that use an accumulator are implied
mode instructions. Zero address instructions in a stack organized computer are
implied mode instructions since the operands are implied to be on the top of the stack.
2. Immediate Mode:
3. Register Mode :
The address field of an instruction may specify either a memory word or processor
register. When the address field specifies a processor register, the instruction is said
to be in the register mode. In the mode the operands are in registers that reside within
the CPU
Page 36 of 38
COA BCA-III M1 Prepared By: Ms. Suman Singh
Assistant Professor (IT)
IITM
5. Auto increment or Decrement Mode:
This is similar to the register indirect mode except that the register is incremented or
decremented (after or before) its value is used to access memory. When the address
stored in the register refers to a table of data in memory, it is necessary to increment
or decrement the register after every access to the table, can be achieved by using the
increment or decrement instruction.
In this mode the effective address is equal to the address part of instruction. The
operand resides in memory and its address is given directly by the address field of the
instruction.
In this mode the address field of the instruction gives the address where the effective
address is stored in memory.
In this mode the content of the program counter is added to the address part of the
instruction in order to obtain the effective address. When this number is added to the
content of the program counter, the result produces an effective address whose
position in memory is relative to the address of the next instruct on. Relative
addressing is often used with branch type instructions.
The index register is a special CPU register that contains an index value. The address
field of the instruction defines the beginning address of data array in memory. The
index register can be incremented to consecutive operands. In this mode the content
of an index register is added to the address part of the instruction to obtain the
effective address.
A base register is assumed to hold a base address and the address field of the
instruction gives a displacement relative to this base address. In this mode the content
of a base register is added to the address part of the instruction to obtain the effective
address.
Page 37 of 38
COA BCA-III M1 Prepared By: Ms. Suman Singh
Assistant Professor (IT)
IITM
To show the difference between the various modes we will take the given figure as an example.
The two word instruction at address 200 and 201. The PC has the value 200 for fetching this
instruction. The content of processor register R1 is 400. Index register XR has content 100. AC
receives the operand after the instruction is executed.
Page 38 of 38