0% found this document useful (0 votes)
19 views12 pages

DLB Project Report

Uploaded by

tayuebkabir896
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views12 pages

DLB Project Report

Uploaded by

tayuebkabir896
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

DEPERMENT OF COMPUTER SCIENCE AND

ENGINEERING

PROJECT REPORT

Semester: Summer 25
Course Code: CSE 345 / ICE217
Course Title: Electrical Circuits
Section: 07
Project Title: 4-bit Magnitude Comparator
Group No: 05

Group Members:
1. 2022-3-60-082 Umme Habiba Tonni

2. 2023-3-60-083. Akib Hossain Daiyan

3. 2024-3-50-040. Tayueb Bin Kabir

4. 2023-1-60-094. Saima sultana


1. Problem Statement

In digital electronics, comparing numbers is an important task because many systems


need to know which value is bigger, smaller, or equal. For example, in processors,
sorting data, memory checking, and in control units, comparisons are always required.
In this project, we are making a 4-bit magnitude comparator. It is a combinational logic
circuit which will compare two 4-bit binary numbers:
• A = A₃ A₂ A₁ A₀
• B = B₃ B₂ B₁ B₀
The circuit gives three outputs:
• A > B: 1 (High) when A is greater than B.
• A = B: 1 (High) when both numbers are the same.
• A < B: 1 (High) when A is smaller than B.
Only one of these outputs can be 1 at a time, because a number cannot be greater,
equal, and smaller at the same moment.
This comparator is a simple but very useful building block in digital design. It helps us
understand how binary numbers can be compared with logic gates. It also shows how
small circuits like this are later combined to build bigger and more advanced parts of a
computer system.

2. Project Objectives

1. To design a 4-bit comparator circuit that can compare two binary numbers.

2. To find the logic expressions for A>B, A=B, and A<B conditions.

3 To simplify the logic so that the circuit needs fewer gates.

4 To build the circuit using only basic gates (AND, OR, NOT) and NOR gates.

5. To prepare the truth table for all input combinations and check the outputs.

6. To analyze and verify the correctness of the circuit through step-by-step explanation
and simulation results.

1. Problem Statement
In digital electronics, comparing numbers is an important task because
many systems need to know which value is bigger, smaller, or equal. For
example, in processors, sorting data, memory checking, and in control
units, comparisons are always required. In this project, we are making a 4-
bit magnitude comparator. It is a combinational logic
circuit which will compare two 4-bit binary numbers:
• A = A₃ A₂ A₁ A₀
• B = B₃ B₂ B₁ B₀
The circuit gives three outputs:
• A > B: 1 (High) when A is greater than B.

• A = B: 1 (High) when both numbers are the same.


• A < B: 1 (High) when A is smaller than B.
Only one of these outputs can be 1 at a time, because a number cannot be greater,
equal,
and smaller at the same moment.
This comparator is a simple but very useful building block in digital design. It helps us
understand how binary numbers can be compared with logic gates. It also shows how
small circuits like this are later combined to build bigger and more advanced parts of a
computer system.

Project Objectives :

1. To design a 4-bit comparator circuit that can compare two binary numbers.

2. To find the logic expressions for A>B, A=B, and A<B conditions.
3. To simplify the logic so that the circuit needs fewer gates.
4. To build the circuit using only basic gates (AND, OR, NOT) and NOR gates.
5. To prepare the truth table for all input combinations and check the outputs.
6. To analyze and verify the correctness of the circuit through step-by-step explanation
and simulation results.

Design Details

Inputs:
● 4-bit binary number A: A₃ (MSB), A₂, A₁, A₀ (LSB)
● 4-bit binary number B: B₃ (MSB), B₂, B₁, B₀ (LSB)
Outputs:
● A > B: 1 (High) when A is greater than B
● A = B: 1 (High) when A is equal to B
● A < B: 1 (High) when A is less than B
Only one output is high at any time.
Components Used
For building and testing the 4-bit magnitude comparator, we used the following
components:

1. Logic Gate ICs:

• NOT Gate (Inverter): 7404 (Hex Inverter IC)


• 2-input AND Gate: 7408 (Quad 2-input AND IC)
• 2-input NOR Gate: 7402 (Quad 2-input NOR IC)
• 3-input AND Gate: 7411 (Triple 3-input AND IC)
• 4-input AND Gate: 7421 (Dual 4-input AND IC)
• 4-input OR Gate: 4072 IC (Dual 4-input OR Gate)

Supporting Hardware:

• Breadboard – For constructing the circuit.


• Jumper Wires – For interconnections.
• Switches (from lab) – To provide input combinations (A0–A3 and B0–B3).
• LEDs (from lab) – To display outputs:
• LED1 (Q0): A = B
• LED2 (Q1): A > B
• LED3 (Q2): A < B
• Power Supply (from lab, +5V DC) – To power the ICs.

2. Simulation Tool:
• Proteus – Used for circuit design, simulation, and verification.

Logical Working Rules

We compare two 4-bit numbers by checking one bit at a time, starting from the Most
Significant Bit (MSB) and going down to the Least Significant Bit (LSB). Checking the
bigger bits first helps us decide which number is bigger or smaller more accurately. We only
used AND, OR, NOT and NOR gates, no XOR or XNOR gates are used.
1. Equal (A=B) Condition:

To see if A and B are equal, we check each


bit in the same position:
● Bit 0: E₀ = (A₀ AND B₀) OR (NOT A₀ AND NOT B₀)
● Bit 1: E₁ = (A₁ AND B₁) OR (NOT A₁ AND NOT B₁)
● Bit 2: E₂ = (A₂ AND B₂) OR (NOT A₂ AND NOT B₂)
● Bit 3: E₃ = (A₃ AND B₃) OR (NOT A₃ AND NOT B₃)
These expressions confirm that each individual bit pair is either both 0 or both 1.
If all these bits match, then A equals B:

A = B: E₃ AND E₂ AND E₁ AND E₀


2. (A>B) Greater Than Condition:
To check if A is bigger than B, we start from the MSB. A lower bit can only decide if all
higher bits are equal. The logic is:
● G₃ = A₃ AND (NOT B₃)
● G₂ = A₂ AND (NOT B₂) AND E₃
● G₁ = A₁ AND (NOT B₁) AND E₃ AND E₂
● G₀ = A₀ AND (NOT B₀) AND E₃ AND E₂ AND E₁

These ensure that the higher-priority bits are equal before considering lower-order bits.
If any of these Gs’ is true, A is greater than B:
A > B = G₃ OR G₂ OR G₁ OR G₀
3. (A<B) Less Than Condition:
Checking if A is smaller than B works the same way, starting from the MSB. Only a
lower bit matters if all higher bits are equal:
● L₃ = (NOT A₃) AND B₃
● L₂ = (NOT A₂) AND B₂ AND E₃
● L₁ = (NOT A₁) AND B₁ AND E₃ AND E₂
● L₀ = (NOT A₀) AND B₀ AND E₃ AND E₂ AND E₁
So, A is smaller than B only if all higher bits are equal and one of the lower bits
is smaller.

Block Diagram Description


The design of the 4-bit magnitude comparator includes several logic levels.
• First, basic logic gates (AND, OR, NOT) & NOR gate are used to check whether
the individual bits of A and B are equal.
• Next, combinational logic is applied to determine when one input is larger or
smaller than the other by analyzing the higher-order bits first.
• Finally, these intermediate results are combined in a logic stage that produces three
distinct outputs: A > B, A = B, and A < B.
This structure ensures that only one condition is true at a time, making the comparator
accurate and reliable for binary number comparisons.
Block Diagram:

Truth table:
A3A2A1A0 A B3B2B1B0 B A>B A=B A<B
0000 0 0101 5 0 0 1
0001 1 0011 3 0 0 1
0010 2 0001 1 1 0 0
0011 3 0100 4 0 0 1
0100 4 0010 2 1 0 0
0101 5 0101 5 0 1 0
0110 6 0111 7 0 0 1
0111 7 0100 4 1 0 0
1000 8 1010 10 0 0 1
1001 9 1001 9 0 1 0
1010 10 0111 7 1 0 0
1011 11 1100 12 0 0 1
1100 12 1000 8 1 0 0
1101 13 1110 14 0 0 1
1110 14 1101 14 0 1 0
1111 15 1001 13 1 0 0
0010 2 0110 9 0 0 1
0101 5 0110 6 0 0 1
1011 11 1010 10 1 0 0
1100 12 1101 13 0 0 1
1111 15 1111 15 0 1 0
Circuit Diagram:

Diagram Description:

● Input: A3, A2, A1, A0 and B3, B2, B1, B0


● Output: A>B, A<B, A=B
● Use AND gates for bitwise equality and combining bits.
● Use OR gates to combine greater/less conditions.

7. Simulation Results
Hardware Picture:
7.2. Simulation Screenshots:
Conclusion:

The 4-bit magnitude comparator is a fundamental digital component used


to compare two 4-bit binary numbers. By analyzing each bit from the most
significant to the least significant, the comparator accurately determines
whether one number is greater than, less than, or equal to the other. Its
simple design, reliability, and ease of cascading for wider-bit comparisons
make it invaluable in digital electronics, especially in arithmetic and
decision-making circuits.

You might also like