Unit 2 Part1
Unit 2 Part1
3
Binary addition
Binary subtraction
1
Binary subtraction using 2’s complement method
=
Full adder using half adder
Sum = A ⊕ B ⊕ C
Carry = AB + (A ⊕ B)C
= AB + (A’B + AB’)C
= AB + A’BC + AB’C
= B (A + A’C) + AB’C
= B [(A + A’)(A + C)] + AB’C
= AB + BC + AB’C
= BC + A(B + B’C)
= BC + A[(B + B’)(B + C)]
= BC + AB + AC
= AB + BC + AC
4-bit ripple carry adder
1 1 0 0 0
1 1 0 1
1 1 0 0
1 1 0 0 1
4-bit ripple carry adder/Parallel adder
C3 = Cout
Working of Ripple Carry Adder /Parallel adder
• Firstly the Full Adder A adds A0 and B0 along with the carry Cin to
generate the sum S0 (the first bit of the output sum) and the carry
C0 which is connected to the next adder in chain.
• Next, the Full Adder B uses this carry bit C0 to add with the input
bits A1 and B1 to generate the sum S1(the second bit of the
output sum) and the carry C1 which is again further connected to
the next adder in chain and so on.
• The process continues till the last Full Adder D uses the carry bit
C2 to add with its input A3 and B3 to generate the last bit of the
output S3 along with last carry bit C3.
A3 A2 A1 A0 0101
B3 B2 B1 B0 1010
Cin0
------------------------------
S3S2S1S01111
C30
Half Subtractor
It produces the difference between the two binary bits at the input and
produces two outputs difference and borrow ( to indicate if a 1 has been
borrowed)
= A XOR B
Full Subtractor
• A full subtractor is a combinational circuit that
performs subtraction of two bits, one is minuend
and other is subtrahend, taking into account borrow
of the previous adjacent lower minuend bit. This
circuit has three inputs and two outputs.
• The three inputs A, B and Bin, denote the
minuend, subtrahend, and previous borrow,
respectively. The two outputs, D and Bout
represent the difference and output borrow,
respectively.
D Bout
Bout =
D
=
=
Parallel Subtractor
Working of Parallel Subtractor
• The parallel binary subtractor is formed by combination of all full
adders with subtrahend complement input.
• This operation considers that the addition of minuend along with
the 2’s complement of the subtrahend is equal to their subtraction.
• Firstly the 1’s complement of B is obtained by the NOT gate and 1
can be added through the carry to find out the 2’s complement of
B. This is further added to A to carry out the arithmetic subtraction.
• The process continues till the last full adder uses the carry bit to
add with its input A and 2’s complement of B to generate the last
bit of the output S3 along last carry bit C4.
For Subtraction
For a>b, a=b
• If a carry is generated (C4=1) , then ignore the carry
and result will be the difference between a and b.
For a<b
• If no carry (C4=0), then the difference is 2’s
compliment of the result with negative sign
4-bit Parallel Adder/Subtractor
• In Digital Circuits, a Binary adder/subtractor is capable
of both the addition and subtraction of binary numbers
in one circuit itself.
• The operation is performed depending on the binary
value the control signal holds. It is one of the
components of the ALU (Arithmetic Logic Unit).
• Let’s consider two 4-bit binary numbers A and B as
inputs to the Digital Circuit for the operation with
digits
𝑌 = 𝐵 𝐴 𝐷0 + 𝐵 𝐴 𝐷 1+ 𝐵 𝐴 𝐷2 + 𝐵𝐴 𝐷 3
8:1 Multiplexer
8:1 Multiplexer
Implement the following function using 4:1 MUX
a b c f
0 0 0 1 1
0 0 1 1
0 1 0 1 C’
0 1 1 0
1 0 0 0 0
1 0 1 0
1 1 0 0 c
1 1 1 1
Implement the following function using 4:1 MUX, use b and c as select lines
a b c f
a b c f
0 0 0 0 a
0 0 0 0
1 0 0 1
0 0 1 1
0 0 1 1 1
0 1 0 0
1 0 1 1
0 1 1 0
0 1 0 0 0
1 0 0 1
1 1 0 0
1 0 1 1
0 1 1 0 a
1 1 0 0
1 1 1 1
1 1 1 1
Encoder
An Encoder is a combinational circuit that performs the reverse
operation of a Decoder.
It has a maximum of 2n input lines and ‘n’ output lines, hence it
encodes the information from 2n inputs into an n-bit code.
It will produce a binary code equivalent to the input, which is
active High.
Therefore, the encoder encodes 2n input lines with ‘n’ bits.
Example of Encoder
4x2 Encoder
8x3 Encoder (Octal to Binary encoder)
outputs
inputs
A2 = Y7 + Y6 + Y5 + Y4
A1 = Y7 + Y6 + Y3 + Y2
A0 = Y7 + Y5 + Y3 + Y1
Decoder
• The combinational circuit that change the binary
information into 2N output lines is known as Decoders.
• The binary information is passed in the form of N input
lines.
• The output lines define the 2N-bit code for the binary
information.
• In simple words, the Decoder performs the reverse
operation of the Encoder.
• At a time, only one input line is activated for simplicity.
The produced 2N-bit output code is equivalent to the binary
information.
2 to 4 decoder with active high outputs
3 to 8 decoder with active high outputs
Truth Table of 3:8 decoder
Encoder
An Encoder is a combinational circuit that performs the reverse
operation of a Decoder.
It has a maximum of 2n input lines and ‘n’ output lines, hence it
encodes the information from 2n inputs into an n-bit code.
It will produce a binary code equivalent to the input, which is
active High.
Therefore, the encoder encodes 2n input lines with ‘n’ bits.
4x2 Encoder
8x3 Encoder
outputs
inputs
A2 = Y7 + Y6 + Y5 + Y4
A1 = Y7 + Y6 + Y3 + Y2
A0 = Y7 + Y5 + Y3 + Y1
Additional Problem Statements
BCD to Excess-3 Conversion
25/06/2024 85
25/06/2024 86
25/06/2024 87
The final set of output equations are
W= A + BD + BC
X = B’C + B’D + BC’D’
Y = C’D’ + CD
Z = D’
25/06/2024 88
Excess-3 to BCD
Excess-3 code is also a Self complementing code
Binary to gray code conversion
Binary to gray code conversion
Gray to Binary code conversion
Gray code is also called unit distance code
Binary Multiplier