Unit-2 Coa
Unit-2 Coa
Tanya Shrivastava
UNIT – 2
In case of SUM we take corresponding input values where we get SUM 1 in output, so we write the
equation according to Minterm like A1, A’0, B1, B’0
SUM = A’B + AB’ (here we can see this equation is of XOR gate, see the table given below)
So, SUM = A ⊕ B
Similar for carry we take corresponding input values where we get CARRY 1 in output, so we write the
equation according to Minterm like A1, A’0, B1, B’0
CARRY = AB
FULL ADDER
Full adder is also known as 3 input and 2 output circuits.
A full adder is a digital logic circuit that performs binary addition of three bit binary numbers.
It has three inputs, A, B and C, and two outputs, SUM (S) and CARRY (C).
The full adder can be implemented using basic gates such as OR, XOR and AND gates.
In case of SUM we take corresponding input values where we get SUM 1 in output, so we write the
equation according to Minterm like A1, A’0, B1, B’0
XOR XNOR
Let B ⊕ C = W and B ⊕ C= W’
SUM = A⊕ B ⊕ C
Similar for carry we take corresponding input values where we get CARRY 1 in output, so we write the
equation according to Minterm like A1, A’0, B1, B’0
XOR 1
CARRY = C(A⊕ B) + AB
HALF SUBTRACTOR
Half subtractor is also known as 2 input and 2 output circuits.
A half subtractor is a digital logic circuit that performs binary subtraction of two bit binary
numbers.
It has two inputs, A and B, and two outputs, DIFFERENCE and BORROW.
The half subtractor can be implemented using basic gates such as NOT, XOR and AND gates.
FULL SUBTRACTOR
Full subtractor is also known as 3 input and 2 output circuits.
A full subtractor is a digital logic circuit that performs binary subtraction of three bit binary
numbers.
It has three inputs, A, B and C, and two outputs DIFFERENCE and BORROW.
The full subtractor can be implemented using basic gates such as OR, NOT, XOR and AND
gates.
Also in parallel adder all the full adders are not working together, because each full adder is
depend on carry input. Until next full adder does not receive carry the work of circuit does not
move further. So it does not allow using all the full adder simultaneously.
Also parallel adder contains propagation delay, because next full adder has to wait for carry bit.
To overcome the disadvantage of parallel adder we use carry look ahead adder means in
parallel adder propagation delay is generated because all the adders are wait for carry. But in
carry look ahead adder we generate a carry in advance, so we don’t need to wait for the carry.
SUM = Si = Ai ⊕ Bi ⊕ Ci
CARRY = Ci+1 = (Ai ⊕ Bi) Ci + AiBi
Now generate carry in advance with the help of carry equation Ci+1 = PiCi + Gi :
C0 is always zero because initial carry always we assume 0. C0=0
For i=0
Ci+1 = PiCi + Gi
C1 = P0C0 +G0 (1 AND and 1 OR gate)
For i=1
Ci+1 = PiCi + Gi
C2 = P1C1 +G1 (Put the value of C1 in this equation)
C2 = P1 (P0C0 +G0) +G1
C2 = P1P0C0 +P1G0 +G1 (2 AND and 1 OR gate)
For i=2
Ci+1 = PiCi + Gi
C3 = P2C2 +G2 (Put the value of C2 in this equation)
C3 = P2 (P1P0C0 +P1G0 +G1) +G2
C3 = P2P1P0C0 +P2P1G0 +P2G1 +G2 (3 AND and 1 OR gate)
For i=3
Ci+1 = PiCi + Gi
C4 = P3C3 +G3 (Put the value of C2 in this equation)
C4 = P3 (P2P1P0C0 +P2P1G0 +P2G1 +G2) +G3
C4 = P3P2P1P0C0 +P3P2P1G0 + P3P2G1 + P3G2 +G3 (4 AND and 1 OR gate)
Hence, according to the circuit diagram up to C4 there is total 10 AND gates and 4 OR gates.
Answer.
Here n= 4, hence
Formula: AND gates = n(n + 1)/2
Formula: OR gates = n
So AND gates = 10
OR gates = 4
So,2x+2y=28
Q. 1-bit full-adder takes 20 ns to generate carry-out bit and 40 ns for the sum bit. The maximum rate
of addition per second, when four 1-bit full adders are cascaded is ×106/sec
Solution
Q. The carry and sum of a full-adder takes 20 ns and 30 ns respectively. Then calculate the maximum
number of additions performed in a second, if three full adders are cascaded ×106/sec (Round
of two decimal points).
Solution
Tcarry = 20 ns, Tsum = 30 ns (given)
Q. In a 4 bit carry look ahead adder the input bits are 1011 & 1001, the Generate, Propagate and
carry signal from the third stage respectively:
1. 0,0,0
2. 0,1,0
3. 1,1,0
4. 1,0,1
1 0 1 1 A3 A2 A1 A0 = 1011
+1 0 0 1 B3 B2 B1 B0 = 1001
C0 = G0 + P0Cin
=1
C1 = G1 + P1C0
= 1.0 + (1⊕0)1
=1
C2 = G2 + P2C1
= 0.0 + (0⊕0)1
=0
So, the generate, propagate and carry signal from the third stage are 0,0,0 respectively.
Hardware Implementation:
Following components are required for the Hardware Implementation of multiplication
algorithm :
Hence Multiplicand is the first no. and multiplier is the second no.
Multiplicand always store in B register in the form of binary.
Sign bit of multiplicand store in BSign register.
Multiplier always store in Q register in the form of binary.
Sign bit of multiplier store in QSign register.
And the A register contains partial addition
ASign register contains partial addition sign bit
Sequence Counter register (SC) is used to store number of bits in the multiplier.
BOOTHS ALGORITHM
The booth algorithm is a multiplication algorithm that allows us to multiply the two signed binary
integers in 2's complement, respectively. It is also used to speed up the performance of the multiplication
process. It is very efficient too.
Solution: let’s assume register size = 4 bit. Hence we get the answer in 4 cycles. Here both the values
7 & 3 are positive.
M = Multiplicand = 7 = 0111 AC = AC + M
Q = Multiplier = 3 = 0011
-M = 2’s Complement of M AC = AC – M, so we can also write
M = 0111 this equation in another way:
1’s = 1000 AC = AC + (-M)
2’s = +1
2’s = 1001 For negative value we always find 2’s complement
-M = 1001
AC Q Q-1 Operation
0000 0011 0 Initial
1001 0011 0 Q0.Q-1 = 10, AC=AC+(-M), AC= 1001
1100 1001 1 Arithmetic shift right
1110 0100 1 Q0.Q-1= 11, Arithmetic shift right
0101 0100 1 Q0.Q-1=01, AC=AC+M, AC=1110,
M=0111, AC = 10101 carry discarded
Solution: let’s assume register size = 4 bit. Hence we get the answer in 4 cycles. Here the value 7 is
negative & 3 is positive.
For any negative value we always find 1’S and 2’s complement first.
AC = AC + (-M)
-M = 2’s Complement of M
M = 1001
1’s = 0110
2’s = +1
2’s = 0111
-M = 0111
AC Q Q-1 Operation
0000 0011 0 Initial
11101011
1’s = 00010100
2’s = +1
2’s = 00010101 -21
AC Q Q-1 Operation
0000 1101 0 Initial
ARRAY MULTIPLIER
An array multiplier is a digital combinational circuit used for multiplying two binary numbers by
employing an array of full adders and half adders. This array is used for the nearly simultaneous
addition of the various product terms involved. To form the various product terms, an array of
AND gates is used before the Adder array.
Array multiplier is faster than signed magnitude multiplication and booth algorithm because in this
we do not perform any arithmetic shift operations or do not find any 1’s or 2’s complement, in this
we simply perform multiplication of the given numbers.
Array multiplier circuit is based on add and shift algorithm.
The addition can be performed with normal carry and adder.
Here mainly we use adder like half adder, full adder and 4 bit parallel adder and AND gates.
Example: 2 by 2 bit array multiplier
Q. An array multiplier is used to find the product of a 3 bit number with a 4 bit
number. How many 4 bits addresses are required to perform multiplication?
Solution:
Given no. are 3 bit and 4 bit, let A = a2 a1 a0 and B = b3 b2 b1 b0
Hence A total no. of Two 4 bit addresses are required for the multiplication operation.
The division algorithm is generally of two types, i.e., fast algorithm and slow algorithm. Fast
algorithm is restoring algorithm and slow algorithm is non restoring algorithm.
Restoring division operates on fixed point fractional numbers and depends on the assumption
0 < D < N,
Where,
N = Numerator (dividend)
D = Denominator (divisor)
Restoring division is usually performed on the fixed point fractional numbers. When we perform
division operations on two numbers, the division algorithm will give us two things, i.e., quotient and
remainder. This algorithm is based on the assumption that 0 < D < N. With the help of digit set {0, 1},
the quotient digit q will be formed in the restoring division algorithm
Non-restoring division uses the digit set {−1, 1} for the quotient digits instead of {0, 1}. The algorithm
is more complex, but has the advantage when implemented in hardware that there is only one decision
and addition/subtraction per quotient bit; there is no restoring step after the subtraction, which
potentially cuts down the numbers of operations by up to half and lets it be executed faster.
Step 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.
Step 2: In this step, register A and register Q will be treated as a single unit, and the value of both the
registers will be shifted left.
Step 3: After that, the value of register M will be subtracted from register A. The result of subtraction
will be stored in register A.
Step 4: Now, check the most significant bit of register A. If this bit of register A is 0, then the least
significant bit of register Q will be set with a value 1. If the most significant bit of A is 1, then the least
significant 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.
Step 5: After that, the value of N will be decremented. Here n is used as a counter.
Step 6: Now, if the value of N is 0, we will break the loop. Otherwise, we have to again go to step 2.
Step 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.
For example:
S
M A Q OPERATION
011 ×000 111 INITIAL
Step 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.
Step 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 means in case of 0, the 2's
complement of M is added into register A, and the result is stored into A.
Step 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 significant bit of Q.
Step 6: After that, the value of N will be decremented. Here N is used as a counter.
Step 7: If the value of N = 0, then we will go to the next step. Otherwise, we have to again go to step 2.
Step 9: This is the last step. In this step, register A contains the remainder, and register Q contains the
quotient.
For example:
In this example, we will perform a Non-Restoring Division algorithm with the help of an Unsigned
integer.
1. Q = Dividend = 7 = 111
2. M = Divisor = 3 = 011
3. -M = 101
M A Q OPERATION
011 000 111 INITIAL
SIGN BIT OF A=0
001 110 LEFT SHIFT AQ
110 110 A=A-M, A=A+(-M), A=001, -M=101
A=110
110 110 SIGN BIT OF A=1, Q(0)=0
SIGN BIT OF A=1
101 101 LEFT SHIFT AQ
000 101 A=A+M, A=101, M=011
A=1000 CARRY DISCARDED
000 101 SIGN BIT OF A=0, Q(0)=1
SIGN BIT OF A=0
001 010 LEFT SHIFT AQ
110 010 A=A-M, A=A+(-M), A=001, -M=101
A=110
110 010 SIGN BIT OF A=1, Q(0)=0
001 010 Hence 3 cycles are done, counter=N=0
So we will perform algorithm further
SIGN BIT OF A=1
A=A+M, A=110, M=011
A=1001, CARRY DISCARDED
REMAINDER QUOTIENT
ALU derives its name because it performs arithmetic and logical operations. A simple ALU design is
constructed with Combinational circuits. ALUs that perform multiplication and division are designed
around the circuits developed for these operations while implementing the desired algorithm. More
complex ALUs are designed for executing Floating point, Decimal operations and other complex
numerical operations.
Combinational ALU
A primitive ALU supporting three functions AND, OR and ADD is explained in figure 1 The
ALU has two inputs A and B.
These inputs are fed to AND gate, OR Gate and Full ADDER.
The Full Adder also has CARRY IN as an input. The combinational logic output of A and B is
statically available at the output of AND, OR and Full Adder.
The desired output is chosen by the Select function, which in turn is decoded from the
instruction under execution.
Multiplexer passes one of the inputs as output based on this select function.
Select Function essentially reflects the operation to be carried out on the operands A and B.
Thus A and B, A or B and A+B functions are supported by this ALU. When ALU is to be
extended for more bits the logic is duplicated for as many bits and necessary cascading is done.
The AND and OR logic are part of the logical unit while the adder is part of the arithmetic unit.
The simplest ALU has more functions that are essential to support the ISA of the CPU. Therefore the
ALU combines the functions of 2's complement, Adder, Subtractor, as part of the arithmetic unit. The
logical unit would generate logical functions of the form f(x,y) like AND, OR, NOT, XOR etc. Such a
combination supplements most of a CPU's fixed point data processing instructions.
So far what we have seen is a primitive ALU. ALU can be as complex as the variety of functions that
are carried out by the ALU. The powerful modern CPUs have powerful and versatile ALUs. Modern
CPUs have multiple ALU to improve efficiency.
A floating point number is a positive or negative whole number with a decimal point. For example,
5.5, 0.25, and -103.342 are all floating point numbers, while 91, and 0 are not these are fixed point
numbers. Floating point numbers get their name from the way the decimal point can "float" to any
position necessary.
A float represents numbers using a binary-equivalent of scientific notation. For example, the number
1.2 x 103 can be represented as a float. Floats work well when we're dealing with very large or very
small values but perfectly accurate measurements and arithmetic are not required.
Step 1: Convert the decimal number into binary format, divide it into two points by lower cumulative
multiplication we get,
1259 = (10011100011)
0.125 = 0.125*2= 0.250 = 0
=0.250*2 =0.500 = 0
=0.500*2=1.00 = 1
0.125 = (001)
1259.125 = (10011100011.001)
Step 2: Normalize the number
A single precision formula is (1.N ) 2e-127,
i.e 1.0011100011001 x 2¹⁰ (the number of moved bits) here N = 0011100011001 is mantissa, also
mantissa include sign bit so first bit of sign bit is 0.
Sign bit
Step 3 : Single precision format :
This is how we represent a binary number in single precision format and double precision format.
Q. Represent the following decimal number in IEEE Standard floating point format in a single
precision and Double precision representation method.
i. (32.75) 10
ii. (-506.257) 10
Solution:
i. (32.75) 10
Step 1: Convert the decimal number into binary format, divide it into two points by lower cumulative
multiplication we get,
32 = (100000)
0.75 = 0.75*2= 1.50 = 1
=0.50*2 =1.00 = 1
0.75 = (11)
32.75 = (100000.11)
Step 2: Normalize the number
A single precision formula is (1.N ) 2e-127,
i.e 1.0000011 x 25 (the number of moved bits) here N = 0000011 is mantissa, also mantissa include sign
bit so first bit of sign bit is 0.
Sign bit
Step 3 : Single precision format :
10000100 00000000000000000000000
10000000100 00000
This is how we represent a binary number in single precision format and double precision format.
ii (-114.625) 10
Step 1: Convert the decimal number into binary format, divide it into two points by lower cumulative
multiplication we get,
114 = (01110010)
0.625 = 0.625*2= 1.250 = 1
=0.250*2 =0.500 = 0
=0.500*2=1.00 = 1
0.625 = (101)
114.625 = (01110010.101)
Step 2: Normalize the number
A single precision formula is (1.N ) 2e-127,
e= 133 (10000101).
1 10000101 11001000000000000000000
1 10000000111 11001
This is how we represent a binary number in single precision format and double precision format.
Solution: 00110010001110100000000000000000
Sign bit = 0
Q. Perform arithmetic operations on the following decimal numbers in binary using signed-
magnitude representation.
1. (+42) +(-13)
2. (-42) -(-13)
Solution:
42: 101010
-13 = 110011
13: 001101
1’s: 110010
2’s: +1
2’s: 110011