COA 2ndunit
COA 2ndunit
Module-II
It is very easy to represent positive and negative numbers in our day to day life. We
represent the positive numbers without adding any sign before them and the negative
number with - (minus) sign before them. But in the digital system, it is not possible to use
negative sign before them because the data is in binary form in digital computers. For
representing the sign in binary numbers, we require a special notation.
Our computer can understand only (0, 1) language. The binary numbers are represented
in both ways, i.e., signed and unsigned. The positive numbers are represented in both
ways- signed and unsigned, but the negative numbers can only be described in a signed
way. The difference between unsigned and signed numbers is that unsigned numbers do
not use any sign bit for positive and negative numbers identification, but the signed
number used.
Unsigned Numbers
As we already know, the unsigned numbers don't have any sign for representing negative
numbers. So the unsigned numbers are always positive. By default, the decimal number
representation is positive. We always assume a positive sign in front of each decimal
digit.
There is no sign bit in unsigned binary numbers so it can only represent its magnitude. In
zero and one, zero is an unsigned binary number. There is only one zero (0) in this
representation, which is always positive. Because of one unique binary equivalent form of
lOMoARcPSD|37751672
We will change this decimal number into binary, which has the only magnitude of the
given name.
102 102/2 51 0
51 51/2 25 1
25 25/2 12 1
12 12/2 6 0
6 6/2 3 0
3 3/2 1 11
1/2 0 1
So the binary number of (102)10 is (1100110)2, a 7-bit magnitude of the decimal number
102.
Signed Numbers
The signed numbers have a sign bit so that it can differentiate positive and negative
integer numbers. The signed binary number technique has both the sign bit and the
magnitude of the number. For representing the negative decimal number, the
corresponding symbol in front of the binary number will be added.
The signed numbers are represented in three ways. The signed bit makes two possible
representations of zero (positive (0) and negative (1)), which is an ambiguous
representation. The third representation is 2's complement representation in which no
double representation of zero is possible, which makes it unambiguous representation.
There are the following types of representation of signed binary numbers:
1. Sign-Magnitude form
In this form, a binary number has a bit for a sign symbol. If this bit is set to 1, the
number will be negative else the number will be positive if it is set to 0. Apart
from this sign-bit, the n-1 bits represent the magnitude of the number.
2. 1's Complement
By inverting each bit of a number, we can obtain the 1's complement of a number.
The negative numbers can be represented in the form of 1's complement. In this
form, the binary number also has an extra bit for sign representation as a sign-
magnitude form.
3. 2's Complement
By inverting each bit of a number and adding plus 1 to its least significant bit, we
can obtain the 2's complement of a number. The negative numbers can also be
represented in the form of 2's complement. In this form, the binary number also
has an extra bit for sign representation as a sign-magnitude form.
1's complement
In number representation techniques, the binary number system is the most used
representation technique in digital electronics. The complement is used for representing
the negative decimal number in binary form. Different types of complement are possible
of the binary number, but 1's and 2's complements are mostly used for binary numbers.
lOMoARcPSD|37751672
We can find the 1's complement of the binary number by simply inverting the given
number. For example, 1's complement of binary number 1011001 is 0100110. We can
find the 2's complement of the binary number by changing each bit(0 to 1 and 1 to 0)
and adding 1 to the least significant bit. For example, 2's complement of binary number
1011001 is (0100110)+1=0100111.
For finding 1's complement of the binary number, we can implement the logic circuit also
by using NOT gate. We use NOT gate for each bit of the binary number. So, if we want to
implement the logic circuit for 5-bit 1's complement, five NOT gates will be used.
Example 1: 11010.1101
For finding 1's complement of the given number, change all 0's to 1 and all 1's to 0. So
the 1's complement of the number 11010.1101 comes out 00101.0010.
Example 2: 100110.1001
For finding 1's complement of the given number, change all 0's to 1 and all 1's to 0. So,
the 1's complement of the number 100110.1001 comes out 011001.0110. 1's
Complement Table
Binary Number 1's Complement
0000 1111
0001 1110
0010 1101
0011 1100
0100 1011
0101 1010
0110 1001
0111 1000
1000 0111
1001 0110
1010 0101
1011 0100
1100 0011
lOMoARcPSD|37751672
1101 0010
1110 0001
1111 0000
1's complement plays an important role in representing the signed binary numbers. The
main use of 1's complement is to represent a signed binary number. Apart from this, it is
also used to perform various arithmetic operations such as addition and subtraction.
In signed binary number representation, we can represent both positive and negative
numbers. For representing the positive numbers, there is nothing to do. But for
representing negative numbers, we have to use 1's complement technique. For
representing the negative number, we first have to represent it with a positive sign, and
then we find the 1's complement of it.
Let's take an example of a positive and negative number and see how these numbers are
represented.
=]xcfuiiiExample 1: +6 and -6
The number +6 is represented as same as the binary number. For representing both
numbers, we will take the 5-bit register.
1. +6=0 0110
2. Find the 1's complement of the number 0 0110, i.e., 1 1001. Here, MSB denotes
that a number is a negative number.
Here, MSB refers to Most Significant Bit, and LSB denotes the Least Significant Bit.
The number +120 is represented as same as the binary number. For representing both
numbers, take the 8-bit register.
So the +120 is represented in the 8-bit register as 0 1111000.
1. +120=0 1111000
lOMoARcPSD|37751672
2. Now, find the 1's complement of the number 0 1111000, i.e., 1 0000111. Here,
the MSB denotes the number is the negative number.
2's complement
Just like 1's complement, 2's complement is also used to represent the signed binary
numbers. For finding 2's complement of the binary number, we will first find the 1's
complement of the binary number and then add 1 to the least significant bit of it.
For example, if we want to calculate the 2's complement of the number 1011001, then
firstly, we find the 1's complement of the number that is 0100110 and add 1 to the LSB.
So, by adding 1 to the LSB, the number will be (0100110)+1=0100111. We can also
create the logic circuit using OR, AND, and NOT gates. The logic circuit for finding 2's
complement of the 5-bit binary number is as follows:
Example 1: 110100
For finding 2's complement of the given number, change all 0's to 1 and all 1's to 0. So
the 1's complement of the number 110100 is 001011. Now add 1 to the LSB of this
number, i.e., (001011)+1=001100.
Example 2: 100110
For finding 1's complement of the given number, change all 0's to 1 and all 1's to 0. So,
the 1's complement of the number 100110 is 011001. Now add one the LSB of this
1. +6=0 0110
2. Now, find the 1's complement of the number 0 0110, i.e. 1 1001.
3. Now, add 1 to its LSB. When we add 1 to the LSB of 11001, the newly generated
number comes out 11010. Here, the sign bit is one which means the number is
the negative number.
The number +120 is represented as same as the binary number. For representing both
numbers, take the 8-bit register.
1. +120=0 1111000
2. Now, find the 1's complement of the number 0 1111000, i.e. 1 0000111. Here, the
MSB denotes the number is the negative number.
3. Now, add 1 to its LSB. When we add 1 to the LSB of 1 0000111, the newly
generated number comes out 1 0001000. Here, the sign bit is one, which means
the number is the negative number.
lOMoARcPSD|37751672
Subtraction Algorithm
The subtraction algorithm states that:
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.
Compare both the magnitudes and subtract the smaller number from the
greater number when the signs of A and B are the same.
In cases where A > B, the output signs must be equal to A, or the
complement of A's sign in cases where A < B.
Subtract B from A and change the sign of the output to positive when the
two magnitudes are equal.
FlowChart
lOMoARcPSD|37751672
Let's add two values, +3 and +2, using the signed magnitude
representation.
Solution
We represent the given operands as shown below:
+3 = 0 0112
+2 = 0 0102
From the flowchart, we follow that As xor Bs = 0. This implies that As = Bs
Example 2
Let's subtract two values, +3 and +2, using the signed magnitude representation.
Solution
Step 1: Initialization
Step 2: Iteration
The algorithm iterates through the bits of the multiplier. For each bit of the
multiplier, it performs the following actions:
3. Shift Right:
Perform an arithmetic shift right on the accumulator and the multiplier. This
is equivalent to shifting the bits one position to the right, with the most
significant bit (MSB) of Q becoming the new Q_-1, and the MSB of A
becoming the new MSB of Q.
Step 3: Normalization
1. Shift A/Q: Perform one last arithmetic shift right on the accumulator and
the multiplier to align their positions.
M (Multiplicand) = 1010
Q (Multiplier) = 1101
1. Initialization:
A (Accumulator) = 0000
Q (Multiplier) = 1101
Q_-1 (Previous Qubit) = 0
2. Iteration:
3. Normalization:
Final Result:
A (Result) = 1001
lOMoARcPSD|37751672
“One of the most important point to be considered in this carry adder is the
final output is known only after the carry outputs are generated by each full
adder stage and forwarded to its next stage. So there will be a delay to get
the result with using of this carry adder”.
First, we will start with 4-bit ripple-carry-adder and then 8 bit and 16-bit
ripple-carry adders.
8bit-ripple-carry-adder
16-bit Ripple Carry Adder
It consists of 16 full adders which are connected in cascaded form.
Each full adder carry output is connected as an input carry to the
next stage full adder.
lOMoARcPSD|37751672
The input sequences are denoted by (A1 ….. A16) and (B1 ……
B16) and its relevant output sequence is denoted by (S1 ……..
S16).
The addition process in a 16-bit ripple-carry-adder is the same
principle which is used in a 4-bit ripple-carry adder i.e., each bit
from two input sequences are going to add along with input carry.
This will use when the addition of two 16 bit binary digits
sequence.
16-bit-ripple-carry-adder
Ripple Carry Adder Applications
The ripple-carry-adder applications include the following.
Array Multiplier
Checking the bits of the multiplier one at a time and forming partial
products is a sequential operation that requires a sequence of add and shift
micro-operations. The multiplication of two binary numbers can be done
with one micro-operation by means of a combinational circuit that forms the
product bits all at once. This is a fast way of multiplying two numbers since
all it takes is the time for the signals to propagate through the gates that
form the multiplication array. However, an array multiplier requires a large
number of gates, and for this reason it was not economical until the
development of integrated circuits.
1. P(0)= a0b0
2. P(1)=a1b0 + b1a0
3. P(2) = a1b1 + c1 where c1 is the carry generated during the addition for
the P(1) term.
4. P(3) = c2 where c2 is the carry generated during the addition for the P(2)
termts are a1 and a0, and the product is
For the above multiplication, an array of four AND gates is required to form
the various product terms like a0b0 etc. and then an adder array is required
to calculate the sums involving the various product terms and carry
combinations mentioned in the above equations in order to get the final
Product bits.
The above two partial products are added with two half-adder(HA) circuits.
Usually there are more bits in the partial products and it will be necessary
to use full-adders to produce the sum.
Note that the least significant bit of the product does not have to go through
an adder since it is formed by the output of the first AND gate.
In ripple carry adders, for each adder block, the two bits that are to be added are
available instantly. However, each adder block waits for the carry to arrive from its
previous block. So, it is not possible to generate the sum and carry of any block until
the input carry is known. The i^{th} block waits for the i-1^{th} block to produce
its carry. So there will be a considerable time delay which is carry propagation delay
Consider the above 4-bit ripple carry adder. The sum S_{3} is produced by the
corresponding full adder as soon as the input signals are applied to it. But the carry
input C_{4} is not available on its final steady-state value until carry C_{3} is
available at its steady-state value. Similarly C_{3} depends on C_{2} and C_{2}
on C_{1} . Therefore, though the carry must propagate to all the stages in order
that output S_{3} and carry C_{4} settle their final steady-state value.
The propagation time is equal to the propagation delay of each adder block,
multiplied by the number of adder blocks in the circuit. For example, if each full adder
stage has a propagation delay of 20 nanoseconds, then S_{3} will reach its final
correct value after 60 (20 × 3) nanoseconds. The situation gets worse, if we extend
the number of stages for adding more number of bits.
Consider the full adder circuit shown above with corresponding truth table. We define
two variables as ‘carry generate’ G_{i} and ‘carry propagate’ P_{i} then,
The sum output and carry output can be expressed in terms of carry generate G_{i}
and carry propagate P_{i} as
where G_{i} produces the carry when both A_{i} , B_{i} are 1 regardless of the
input carry. P_{i} is associated with the propagation of carry from C_{i} to C_{i +
1} .
The carry output Boolean function of each stage in a 4 stage carry look-ahead adder
can be expressed as
lOMoARcPSD|37751672
C_{1} = G_{0} + P_{0} C_{in} \newline C_{2} = G_{1} + P_{1} C_{1} = G_{1} + P_{1}
G_{0} + P_{1} P_{0} C_{in} \newline C_{3} = G_{2} + P_{2} C_{2} = G_{2} + P_{2}
G_{1} + P_{2} P_{1} G_{0} + P_{2} P_{1} P_{0} C_{in} \newline C_{4} = G_{3} +
P_{3} C_{3} = G_{3} + P_{3} G_{2} + P_{3} P_{2} G_{1} + P_{3} P_{2} P_{1} G_{0} +
P_{3} P_{2} P_{1} P_{0} C_{in} \newline
From the above Boolean equations we can observe that C_{4} does not have to
wait for C_{3} and C_{2} to propagate but actually C_{4} is propagated at the
same time as C_{3} and C_{2} . Since the Boolean expression for each carry
output is the sum of products so these can be implemented with one level of AND
gates followed by an OR gate.
The implementation of three Boolean functions for each carry output (C_{2} ,
C_{3} and C_{4} ) for a carry look-ahead carry generator shown in below figure.
The part that adds the input bits and the carry for each bit position.
The log(n) complexity arises from the part that generates the carry, not the circuit
that adds the bits.
Now, for the generation of the n^{th} carry bit, we need to perform a AND between
(n+1) inputs. The complexity of the adder comes down to how we perform this AND
operation. If we have AND gates, each with a fan-in (number of inputs accepted) of
k, then we can find the AND of all the bits in log_{k}(n+1) time. This is represented
in asymptotic notation as \Theta(log n) .
Advantages –
lOMoARcPSD|37751672
Disadvantages –
The Carry Look-ahead adder circuit gets complicated as the number of variables
increase.
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.
Checking the bits of the multiplier one at a time and forming partial products is a
sequential operation that requires a sequence of add and shift micro-operations. The
multiplication of two binary numbers can be done with one micro-operation by means
of a combinational circuit that forms the product bits all at once. This is a fast way of
multiplying two numbers since all it takes is the time for the signals to propagate
through the gates that form the multiplication array. However, an array multiplier
requires a large number of gates, and for this reason it was not economical until the
development of integrated circuits.
Assuming A = a1a0 and B= b1b0, the various bits of the final product term P can be
written as:-
1. P(0)= a0b0
2. P(1)=a1b0 + b1a0
3. P(2) = a1b1 + c1 where c1 is the carry generated during the addition for the P(1)
term.
lOMoARcPSD|37751672
4. P(3) = c2 where c2 is the carry generated during the addition for the P(2) term.
For the above multiplication, an array of four AND gates is required to form the
various product terms like a0b0 etc. and then an adder array is required to calculate
the sums involving the various product terms and carry combinations mentioned in
the above equations in order to get the final Product bits.
The first partial product is formed by multiplying a0 by b1, b0. The multiplication of
two bits such as a0 and b0 produces a 1 if both bits are 1; otherwise, it produces 0.
This is identical to an AND operation and can be implemented with an AND gate.
The second partial product is formed by multiplying a1 by b1b0 and is shifted one
position to the left.
The above two partial products are added with two half-adder(HA) circuits. Usually
there are more bits in the partial products and it will be necessary to use full-adders
to produce the sum.
Note that the least significant bit of the product does not have to go through an adder
since it is formed by the output of the first AND gate.
A combinational circuit binary multiplier with more bits can be constructed in similar
fashion. A bit of the multiplier is ANDed with each bit of the multiplicand in as many
levels as there are bits in the multiplier. The binary output in each level of AND gates
is added in parallel with the partial product of the previous level to form a new partial
product. The last level produces the product. For j multiplier bits and k multiplicand
we need j*k AND gates and (j-1) k-bit adders to produce a product of j+k bits.
lOMoARcPSD|37751672