Unit-Ii Computer Organization
Unit-Ii Computer Organization
UNIT-II
Arithmetic
The digital computers manipulate data to produce results necessary for the solution
of arithmetic computational problems. These instructions perform arithmetic calculations
and processing data in a computer. The four basic arithmetic operations are
1. addition
2. subtraction
3. multiplication
4. division
o An arithmetic processor is the part of a processor unit that executes arithmetic
operations.
o An arithmetic instruction may specify binary or decimal data.
o Each case the data may be in (ixed-point or (loating-point form.
o Fixed- point numbers may represent integers or fractions.
o Negative numbers may be in signed- magnitude or signed-complement representation.
VSREDDY
2
when the signs of A and B are identical (different), add the two magnitudes and
attach the sign of A to the result. When the signs of A and B are different (identical),
compare the magnitudes and subtract the smaller number from the larger. Choose the sign
of the result to be the same as A if A > B or the complement of the sign of A if A < B. If the
two magnitudes are equal, subtract B from A and make the sign of the result positive. The
two algorithms are similar except for the sign comparison
Addition Algorithm
The addition algorithm speci(ies that:
o If the signs of A and B are the same, add both the magnitudes and put the sign of A
to the result, as shown in the table.
o Compare both the magnitudes and subtract the small number from the greater
number when the signs of A and B disagree.
o In cases where A > B, the output signs must be equal to P, or the complement of A's
sign in cases where A < B.
o Subtract B from A and change the sign of the output to positive when the two
magnitudes are equal.
Subtraction Algorithm
The subtraction algorithm states that:
o When the signs of A and B differ, the subtraction method says to add both the
magnitudes and put the sign of A to the result.
o Compare both the magnitudes and subtract the smaller number from the greater
number when the signs of A and B are the same.
o In cases where A > B, the output signs must be equal to P, or the complement of A's
sign in cases where A < B.
o Subtract B from A and change the sign of the output to positive when the two
magnitudes are equal.
Hardware Algorithm
The (lowchart for the hardware algorithm is presented in Figure.
o The two signs As, and Bs are compared by an exclusive-OR gate. If the
output of the gate is 0, the signs are identical; if it is 1, the signs are
different for an add operation, identical signs dictate that the magnitudes
be added.
VSREDDY
3
o For a subtract operation, different signs dictate that the magnitudes be added. The
magnitudes are added
o with a micro-operation EA<- A + B where EA is a register that combines E and A. The
carry in E after the addition constitutes an over(low if it is equal to 1 and it is
transferred into the add-over(low (lip-(lop AVF.
o The two magnitudes are subtracted if the signs are different for an add operation or
identical for a subtract operation.
o The magnitudes are subtracted by adding A to the 2's complement of B. No over(low
can occur if the numbers are subtracted.
o A 1 in E indicates that A ≥ B and the number in A is the correct result. If this number
is zero, the sign As must be made positive to avoid a –0. A 0 in E indicates that A < B.
For this case it is necessary to take the 2's complement of the value in A.
o This operation can be done with one micro-operation A<-A’ + 1. In other paths of the
(lowchart, the sign of the result is the same as the sign of A, so no change in As is
required.
o However, when A < B, the sign of the result is the complement of the original sign of
A. It is then necessary to complement As to obtain the correct sign.
o The (inal result is found in register A and its sign in As. The value in AVF provides an
over(low indication. The (inal value of E is immaterial.
VSREDDY
4
Hardware Implementation
It consists of registers A and B and sign (lip-(lops As and Bs. Subtraction is done by adding
A to the 2's complement of B. The output carry is transferred to (lip-(lop E, where it can be
checked to determine the relative magnitudes of the two numbers. The add-over(low (lip-
(lop AVF holds the over(low bit when A and B are added. The A register provides other
micro-operations that may be needed when we specify the sequence of steps in the
algorithm. 3 The addition of A plus B is done through the parallel adder. The S(sum) output
of the adder is applied to the input of the A register. The complementer provides an output
of B or the complement of B depending on the state of the mode control M. The
complementer consists of exclusive-OR gates and the parallel adder consists of full-adder
circuits. The M signal is also applied to the input carry of the adder. When M = 0, the output
of B is transferred to the adder, the input carry is 0, and the output of the adder is equal to
the sum A+B. When M = 1, the 2’s complement of B is applied to the adder the input carry
is 1, and output S = A + B’ — 1. This is equal to A plus the 2's complement of B, which is
equivalent to the subtraction A — B.
De inition of Adder
• Component of a computer processor that adds two numbers sent from the
processing in
• structions.
• An adder is a circuit that sums the amplitudes of two input signals. A half-adder is
a group of connected logic gates that create a logic circuit, incapable of handling
addition for two numbers. A full-adder is a circuit that adds two binary numbers.
1. Half Adder : Half Adder is a combinational logic circuit which is designed by
connecting one EX-OR gate and one AND gate. The half adder circuit has two inputs: A and
B, which add two input digits and generates a carry and a sum.
VSREDDY
5
The output obtained from the EX-OR gate is the sum of the two numbers while that
obtained by AND gate is the carry. There will be no forwarding of carry addition because
there is no logic gate to process that. Thus, this is called the Half Adder circuit.
Logical Expression:
Sum = A XOR B
Carry = A AND B
Truth Table :
2. Full Adder: Full Adder is the circuit that consists of two EX-OR gates, two AND gates,
and one OR gate. Full Adder is the adder that adds three inputs and produces two outputs
which consist of two EX-OR gates, two AND gates, and one OR gate. The (irst two inputs
are A and B and the third input is an input carry as C-IN. The output carry is designated as
C-OUT and the normal output is designated as S which is SUM.
The equation obtained by the EX-OR gate is the sum of the binary digits. While the output
obtained by AND gate is the carry obtained by addition.
VSREDDY
6
Logical Expression:
SUM = (A XOR B) XOR Cin = (A ⊕ B) ⊕ Cin
CARRY-OUT = A AND B OR Cin(A XOR B) = A.B + Cin(A ⊕ B)
VSREDDY
7
The Figure shows the full adder circuit used to add the operand bits in the ith column;
namely Ai & Bi and the carry bit coming from the previous column (Ci ).
o Gi is known as the carry Generate signal since a carry (Ci+1) is generated whenever Gi =1,
regardless of the input carry (Ci).
o Pi is known as the carry propagate signal since whenever Pi =1, the input carry is propagated to
the output carry, i.e., Ci+1. = Ci (note that whenever Pi =1, Gi =0).
o Computing the values of Pi and Gi only depend on the input operand bits (Ai & Bi) as clear from
the Figure and equations.
o Computed values of all the Pi’s are valid one XOR-gate delay after the operands A and B
are made valid.
o Computed values of all the Gi’s are valid one AND-gate delay after the operands A and
B are made valid.
o The Boolean expression of the carry outputs of various stages can be written as follows:
Ci+1 = Gi + Pi Ci
Where i = 0 then
C1 = G0 + P0C0
Where i = 1 then
C2 = G1 + P1C1 = G1 + P1 (G0 + P0C0)
= G1 + P1G0 + P1P0C0
Where i = 2 then
C3 = G2 + P2C2
= G2 + P2G1 + P2P1G0 + P2P1P0C0
Where i = 3 then
C4 = G3 + P3C3
= G3 + P3G2 + P3P2G1 + P3P2P1G0 + P3P2P1P0C0
VSREDDY
8
o First level: Generates all the P & G signals. Four sets of P & G logic (each consists of
an XOR gate and an AND gate). Output signals of this level (P’s & G’s).
P Signals G Signals
P0 = A0 ⊕ B0 G0 = A0 B0
P1 = A1 ⊕ B1 G1 = A1 B1
P2 = A2 ⊕ B2 G2 = A2 B2
P3 = A3 ⊕ B3 G3 = A3 B3
o Second level: The Carry Look-Ahead (CLA) logic block which consists of four 2-level
implementation logic circuits. It generates the carry signals (C1, C2, C3, and C4) as
de(ined by the above expressions.
C1 = G0 + P0C0
C2 = G1 + P1G0 + P1P0C0
C3 = G2 + P2G1 + P2P1G0 + P2P1P0C0
C4 = G3 + P3G2 + P3P2G1 + P3P2P1G0 + P3P2P1P0C0
o Third level: Four XOR gates which generate the sum signals (Si) (Si = Pi ⊕ Ci).
Output signals of this level (S0, S1, S2, and S3).
S0 = A0 ⊕ B0 +C0
S1 = A1 ⊕ B1 +C1
S2 = A2 ⊕ B2 +C2
S3 = A3 ⊕ B3 +C3
VSREDDY
9
Carry Select Adder can be Constructed by implementing 2 stage Ripple Carry Adder and
multiplexer circuit. Carry Select Adder select the sum and carry output from stage 1 ripple
carry adder when carry input ‘0’ and select Sum and carry output from stage 2 ripple carry
adder, when carry input ‘1’.
The process consists of looking at successive bits of the multiplier, least signi(icant
bit (irst. If the multiplier bit is a 1, the multiplicand is copied down; otherwise, zeros are
copied down. The numbers copied down in successive lines are shifted one position to the
left from the previous number. Finally, the numbers are added and their sum forms the
product.
VSREDDY
10
Hardware Algorithm
A (lowchart of the hardware multiply algorithm. Initially, the multiplicand is in B and
the multiplier in Q. Their corresponding signs are in Bs, and Qs, respectively. The signs are
compared, and both A and Q are set to correspond to the sign of the product since a double-
length product will be stored in registers A and Q. Registers A and E are cleared and the
sequence counter SC is set to a number equal to the number of bits of the multiplier.
VSREDDY
11
Booth’s algorithm
Booth's algorithm is a multiplication algorithm used for signed integer
multiplication, particularly in binary arithmetic. It's an ef(icient algorithm that reduces the
number of additions required for the multiplication process. The algorithm uses a
technique involving shifting and addition to perform binary multiplication.
Here are the steps of Booth's algorithm for multiplying two binary numbers (BR and Q):
1. Initialize:
• BR is the multiplicand (usually in 2's complement form).
• Q is the multiplier (in binary).
• Q(-1) is initialized to 0 for sign extension.
2. Repeat for n bits (where n is the number of bits in the multiplier):
• Check the least signi(icant bit (LSB) of Q and Q(-1).
• If the last two bits of Q are "01," perform A = A + BR (BR is the multiplicand).
If "10," perform A = A - BR.
3. Arithmetic Right Shift:
• Shift AQ right by one bit, preserving the sign bit.
4. Repeat steps 2 and 3 for n iterations.
5. Result:
The (inal product is in AQ, with A containing the most signi(icant bits and Q containing the
least signi(icant bits.
VSREDDY
12
VSREDDY
13
Integer division
Integer division in computer organization refers to the process of dividing one integer
by another to obtain a quotient and possibly a remainder. This operation is fundamental
in computer arithmetic and is typically implemented in hardware to ensure ef(icient and
accurate computation.
Here, register Q is used to contain the quotient, and register A is used to contain the
remainder. Here, the divisor will be loaded into the register M, and n-bit divided will be
loaded into the register Q. 0 is the starting value of a register. The values of these types of
registers are restored at the time of iteration. That's why it is known as restoring.
1. The corresponding value will be initialized to the registers, i.e., register A will
contain value 0, register M will contain Divisor, register Q will contain Dividend, and
N is used to specify the number of bits in dividend.
2. register A and register Q will be treated as a single unit, and the value of both the
registers will be shifted left.
3. After that, the value of register M will be subtracted from register A. The result of
subtraction will be stored in register A.
4. Check the most signi(icant bit of register A.
a. If this bit of register A is 0, then the least signi(icant bit of register Q will be
set with a value 1.
b. If the most signi(icant bit of A is 1, then the least signi(icant bit of register Q
will be set to with value 0, and restore the value of A that means it will restore
the value of register A before subtraction with M.
5. After that, the value of N will be decremented. Here n is used as a counter.
6. if the value of N is 0, we will break the loop. Otherwise, we have to again go to step
2.
7. This is the last step. In this step, the quotient is contained in the register Q, and the
remainder is contained in register A.
VSREDDY
14
VSREDDY
15
Non-Restoring Division:
This technique is similar to restoring division but uses a non-restoring approach, meaning
the divisor is subtracted and restored based on whether the result is positive or negative.
This approach can reduce the number of operations needed.
Now we will learn steps of the non-restoring division algorithm, which are described as
follows:
1. In this step, the corresponding value will be initialized to the registers, i.e., register
A will contain value 0, register M will contain Divisor, register Q will contain
Dividend, and N is used to specify the number of bits in dividend.
2. In this step, we will check the sign bit of A.
3. If this bit of register A is 1, then shift the value of AQ through left, and perform A =
A + M. If this bit is 0, then shift the value of AQ into left and perform A = A - M. That
VSREDDY
16
means in case of 0, the 2's complement of M is added into register A, and the result
is stored into A.
4. Now, we will check the sign bit of A again.
5. If this bit of register A is 1, then Q[0] will become 0. If this bit is 0, then Q[0] will
become 1. Here Q[0] indicates the least signi(icant bit of Q.
6. After that, the value of N will be decremented. Here N is used as a counter.
7. If the value of N = 0, then we will go to the next step. Otherwise, we have to again go
to step 2.
8. We will perform A = A + M if the sign bit of register A is 1.
9. This is the last step. In this step, register A contains the remainder, and register Q
contains the quotient.
VSREDDY
17
1. Floating-Point Representation:
Floating-point numbers are a way to represent real numbers in a binary format. They are
characterized by three essential components:
o Sign bit (S): This bit determines the sign of the number, with 0 representing positive
and 1 representing negative.
o Exponent (E): This part represents the power of 2 to which the signi(icant
(mantissa or fraction) is raised. It can be positive or negative.
o Signi icant (Mantissa or Fraction): This component contains the signi(icant digits
of the number, which are multiplied by 2 raised to the exponent.
VSREDDY
18
2. Floating-Point Operations:
Common operations performed on (loating-point numbers in computer organization
include:
Floating-Point Addition:
0.5372400 X 103
0.1580000 x 10-1
It is necessary that the two exponents be equal before the mantissas can be added.
We can either shift the (irst number three positions to the left, or shift the second number
three positions to the right. When the mantissas are stored in registers, shifting to the left
causes a loss of most signi(icant digits. Shifting to the right causes a loss of least signi(icant
digits.
VSREDDY
19
0.5372400 X 102
0.0001580 X 102
0.5373980 X 102
Floating-Point Subtraction:
Floating-point subtraction is very similar to addition but with one key difference:
0.56780 X 105
0.56430 X 105
0.00350 X 105
VSREDDY
20
7. Memory Interface: The CPU interfaces with the computer's memory system,
enabling it to read and write data to and from RAM.
8. Clock: The CPU operates based on a clock signal, which controls the timing of its
operations and synchronizes them with other parts of the computer.
Fundamental Concepts
1. The processor fetches one instruction at a time and performs the operation
speci(ied.
2. Instructions are fetched from successive memory locations until a branch or a jump
instruction is encountered.
3. The processor keeps track of the address of the memory location containing the next
instruction to be fetched using Program Counter (PC).
4. Instruction Register (IR).
VSREDDY
21
a. The (inal result of the instruction is written back to the speci(ied destination
register or memory location.
b. The control unit updates registers or memory locations as necessary.
7. Update Program Counter (PC):
a. The program counter is updated to point to the address of the next
instruction to be executed. This is typically done at the end of the instruction
cycle.
b. The update may involve incrementing the program counter to point to the
next sequential instruction, or it could be based on conditional branching
decisions, where the program counter is set to a different address.
Multiple-Bus Organization
In single bus organization, only one data item can be transferred over the bus in a
clock cycle. To reduce the number of steps needed, most commercial processors provide
multiple internal paths that enable several transfers to take place in parallel.
Multiple bus organization in computer architecture is a design that allows multiple
devices to work simultaneously. This reduces the time spent waiting and improves the
computer's speed. The main advantage of multiple bus organization is the reduction in the
number of cycles required for execution.
In a multiple bus structure, one bus is used to fetch instructions and the other is
used to fetch data. The same bus is shared by three units: memory, processor, and I/O units.
In a multiple bus system, each processor-memory pair is linked by various
redundant paths. This means that the failure of one or more paths can be tolerated, but it
will degrade system performance. The main reason for having multiple buses in a computer
design is to improve performance.
Other advantages include:
a. Better connectivity
b. An increase in the size of the registers There are three types of bus lines: data
bus, address bus, and control bus. Communication over each bus line is
performed in cooperation with another.
Three bus organization of data path
In single bus organization, only one data item can be transferred over the bus in a clock
cycle. To reduce the number of steps needed, most commercial processors provide multiple
internal paths that enable several transfers to take place in parallel.
VSREDDY
22
A three-bus structure used to connect the registers and the ALU of a processor. All
general-purpose registers are combined into a single block called the register (ile. The
register (ile in Figure is said to have three ports. There are two outputs, allowing the
contents of two different registers to be accessed simultaneously and have their contents
VSREDDY
23
placed on buses A and B. The third port allows the data on bus C to be loaded into a third
register during the same clock cycle.
Buses A and B are used to transfer the source operands to the A and B inputs of the ALU,
where an arithmetic or logic operation may be performed. The result is transferred to the
destination over bus C. If needed, the ALU may simply pass one of its two input operands
unmodi(ied to bus C. We will call the ALU control signals for such an operation R=A or R=B.
A second feature in Figure is the introduction of the Incrementor unit, which is used to
increment the PC by 4. Using the Incrementor eliminates the need to add 4 to the PC using
the main ALD, as was done in single bus organization. The source for the constant 4 at the
ALU input multiplexer is still useful.
It can be used to increment other addresses, such as the memory addresses in Load
Multiple and Store Multiple instructions.
Consider the three-operand instruction Add R4,R5,R6: The control sequence for executing
this instruction is given in Figure.
In step 1, the contents of the PC are passed through the ALU, using the R=B control signal,
and loaded into the MAR to start a memory read operation. At the same time the PC is
incremented by 4. Note that the value loaded into MAR is the original contents of the PC.
The incremented value is loaded into the PC at the end of the clock cycle and will not affect
the contents of MAR.
In step 2, the processor waits for MFC and loads the data received into MDR, then transfers
them to IR in step 3. Finally, the execution phase of the instruction requires only one control
step to complete, step 4. By providing more paths for data transfer a signi(icant reduction
in the number of clock cycles needed to execute an instruction is achieved.
a. Hardwired Control
b. Microprogrammed Control
Hardwired Control
The Hardwired Control organization involves the control logic to be implemented with
gates, (lip-(lops, decoders, and other digital circuits.
VSREDDY
24
The following image shows the block diagram of a Hardwired Control organization.
Micro-programmed Control
The Microprogrammed Control organization is implemented by using the programming
approach.
In Microprogrammed Control, the micro-operations are performed by executing a program
consisting of micro-instructions.
The following image shows the block diagram of a Microprogrammed Control organization.
VSREDDY
25
a. The Control memory address register speci(ies the address of the micro-instruction.
b. The Control memory is assumed to be a ROM, within which all control information
is permanently stored.
c. The control register holds the microinstruction fetched from the memory.
d. The micro-instruction contains a control word that speci(ies one or more micro-
operations for the data processor.
e. While the micro-operations are being executed, the next address is computed in the
next address generator circuit and then transferred into the control address register
to read the next microinstruction.
f. The next address generator is often referred to as a micro-program sequencer, as it
determines the address sequence that is read from control memory.
Short Questions
1. Explain half adder
2. Explain full adders.
3. Explain Ripple carry address (RCA) with neat diagram.
4. Explain Carry Select Adder (CSA) with neat diagram.
5. Explain (loating point representation
6. Explain advantages of multi bus organization.
7. De(ine hardwired control unit.
8. De(ine multi programmed control.
Long Questions
1. Write addition algorithm with signed magnitude
2. Write subtraction algorithm with signed magnitude
3. Explain fast adders.
4. Explain Carry Look-Ahead Adder (CLA) with neat diagram.
5. Explain booths multiplication algorithm.
6. Explain integer division restoring method.
7. Explain (loating point operations.
8. Explain activities of processing unit.
9. De(ine instruction execution steps.
10. De(ine multi bus organisation
VSREDDY
26
II-Assignment Questions
Short Questions
1. Explain full adders.
2. Explain Ripple carry address (RCA) with neat diagram.
3. Explain (loating point representation
4. Explain advantages of multi bus organization.
5. De(ine multi programmed control.
Long Questions
1. Write addition algorithm with signed magnitude
2. Explain Carry Look-Ahead Adder (CLA) with neat diagram.
3. Explain booths multiplication algorithm.
4. Explain integer division restoring method.
5. De(ine instruction execution steps.
VSREDDY