Ddco Module 2
Ddco Module 2
A half adder is a fundamental digital circuit that performs the addition of two single-bit binary numbers. It is a basic
building block for more complex arithmetic circuits like full adders.
Truth Table
The truth table for a half adder shows the relationship between the inputs AA and BB and the outputs SS (Sum)
and CC (Carry):
A B S (Sum) C (Carry)
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
Gate Diagram
The half adder can be constructed using an XOR gate and an AND gate:
Boolean Expressions
The outputs of a half adder can be defined by the following Boolean expressions:
Sum (S): S=A⊕BS=A⊕B (where ⊕⊕ denotes the XOR operation)
Full Adder
A full adder is a combinational logic circuit that adds three binary digits: two
significant bits, AA and BB, along with a carry-in bit Cin. It produces a sum
output SS and a carry-out output Cout
Block Diagram
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
Gate Diagram
A full adder can be constructed using the following gates:
2 XOR gates
2 AND gates
1 OR gate
The first XOR gate takes inputs A and B to produce an intermediate sum.
The second XOR gate takes the intermediate sum and C_in to produce the final sum S.
The first AND gate takes inputs A and B to produce one carry output.
The second AND gate takes the intermediate sum and C_in to produce another carry output.
The OR gate combines the outputs of the two AND gates to produce the final carry output C_out.
Boolean Expressions
The outputs of a full adder can be expressed with the following Boolean equations:
Sum (S):
S=A⊕B⊕CinS=A⊕B⊕Cin
Carry (C_out):
Cout=AB+ACin+BCinCout=AB+ACin+BCin
These expressions indicate how the outputs are derived from the inputs using logical operations.
Working of a 4-Bit Full Adder
A 4-bit full adder is a digital circuit that adds two 4-bit binary numbers along with a carry
input from a previous addition. It consists of four individual full adders connected in series,
where the carry output from each adder becomes the carry input for the next adder. This
configuration allows for the addition of multi-bit binary numbers
Feature RISC CISC
Instruction Typically executes one Can take multiple cycles for complex
Execution instruction per cycle instructions
Addressing
Modes Fewer addressing modes More addressing modes
Instruction
Format Fixed-length instructions Variable-length instructions
Control Unit
Design Hardwired control unit Microprogrammed control unit
Detailed Explanations
BLOCK DIAGRAM
Feature Assembly Language High-Level Language
Control Over Provides greater control over Less control over hardware; abstracts
Hardware hardware components many details
endmodule
// Half Adder Module
module half_adder (
input wire A, // First input bit
input wire B, // Second input bit
output wire Sum, // Sum output
output wire Carry // Carry output
);
endmodule
A 4-bit adder is a digital circuit that performs the addition of two 4-bit binary numbers,
producing a 4-bit sum and a carry output. It is constructed using a combination of half
adders and full adders. Below is an explanation of its working principle along with a block
diagram.
Working Principle of a 4-Bit Adder
Components
1. Half Adder:
Used for the least significant bit (LSB) addition. It takes two inputs and produces a sum and
a carry output.
The logic for the half adder is:
Sum=A0⊕B0Sum=A0⊕B0
Carry=A0⋅B0Carry=A0⋅B0
2. Full Adders:
Used for the remaining three bits (A1, A2, A3 and B1, B2, B3). Each full adder takes three
inputs: two bits to be added and an incoming carry bit from the previous stage.
The logic for the full adder is:
Sum=Ai⊕Bi⊕CinSum=Ai⊕Bi⊕Cin
Cout=(Ai⋅Bi)+(Cin⋅(Ai⊕Bi))Cout=(Ai⋅Bi)+(Cin⋅(Ai⊕Bi))
Structure
The 4-bit adder consists of:
1 Half Adder for the LSB.
3 Full Adders for the remaining bits.
Carry Propagation
The carry output from each adder is connected as the carry input to the next higher-order
adder. This cascading effect allows for the addition of multi-bit numbers.
Block diagram:
A 4-bit adder and subtractor is a digital circuit that can perform both addition and
subtraction on two 4-bit binary numbers. This circuit utilizes a combination of full adders
and logic gates to achieve its functionality, along with an overflow detection mechanism.
Working of a 4-Bit Adder and Subtractor
Components
1. Full Adders:
The circuit consists of four full adders, each responsible for adding corresponding bits from
the two numbers along with any carry from the previous bit.
2. Control Signal (K):
A control signal determines whether the operation is addition or subtraction. When K = 0,
the circuit performs addition; when K = 1, it performs subtraction.
3. Two's Complement for Subtraction:
To perform subtraction using an adder, the second number is converted to its two's
complement (which involves inverting the bits and adding one). This allows the adder to
handle subtraction as an addition operation.
Operation
Addition:
The two 4-bit numbers AA and BB are fed into the full adders directly when K = 0.
Subtraction:
For subtraction, the bits of BB are inverted using XOR gates (with the control signal K) and
then added to AA. The carry-in for the least significant bit (LSB) is set to 1 to account for the
additional one in the two's complement.
Overflow Detection
Overflow occurs if the result of the addition or subtraction exceeds the range that can be
represented with 4 bits. For a 4-bit adder/subtractor:
Overflow in Addition: If both inputs are positive and the result is negative.
Overflow in Subtraction: If both inputs are negative and the result is positive.
This can be detected by examining the carry into and out of the most significant bit (MSB).
Block Diagram of a 4-Bit Adder/Subtractor
The implementation of this 3 line to 8 line decoder can be done using two 2 lines to 4 line
decoders. We have discussed above that 2 to 4 line decoder includes two inputs and four
outputs. So, in 3 lines to 8 line decoder, it includes three inputs like A2, A1 & A0 and 8
outputs from Y7 – Y0.
The following formula is used to implementation of higher-order decoders with the help of
low order decoders
The number of lower-order decoders required is m2/m1
Where,
The number of o/ps for the lower-order decoder is ‘m1’
The number of o/ps for higher-order decoder is ‘m2’
For instance, when m1 = 4 & m2 = 8, then substitute these values in the above equation.
We can get the required no. of decoders are 2. So, for implementing a single 3 to 8 decoder,
we need two 2 lines to 4 line decoders. Here, the block diagram is shown below by using
two 2 to 4 decoders.
D7 D6
-------- ---------
0 0
0 0
0 0
0 0
0 0
X X
Boolean Expressions
From the truth table, we can derive the Boolean expressions for the outputs Q2Q2, Q1Q1,
and Q0Q0:
Q2:
Q2=D4+D5+D6+D7Q2=D4+D5+D6+D7
Q1:
Q1=D2+D3+D6+D7Q1=D2+D3+D6+D7
Q0:
Q0=D1+D3+D5+D7Q0=D1+D3+D5+D7
Logic Diagram