Title of the exercise: Write a VHDL code for single bit digital comparator and simulate the code.
Introduction:
To develop Boolean expression for A>B, A=B, A<B, write a VHDL code and simulate the code in the software.

Material Required:
1. Xilinx Software Loaded PC = 1 Set
2. Printer = 1
3. FPGA kit Interface cable = 1
4. 9V DC Adopter = 1

Description:
1. Theory
2. Algorithm
3. Description
4. VHDL Code Writing
5. Compile and Run program.

ALGORITHM:
1. Define Library functions.
2. Declare Entity and Architecture.
3. Describe functionality.
4. End source code.
5. Compile and Run program.

Description
1-bit comparator has two inputs and three outputs.

THEORY:
The 1-bit comparator has two inputs and three outputs.

The 1-bit comparator circuit:

Truth table

1-bit comparator Output

VHDL Code for 1-bit comparator

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity comparator_1bit is
    Port ( A,B : in std_logic;
           G,S,E: out std_logic);
end comparator_1bit;
architecture comp_arch of comparator_1bit is
  begin
   G <= A and (not B);
   S <= (not A) and B;
   E <= A xnor B;
end comp_arch;

Result:
Verified by simulation three outputs.

Questions with answers:
1. What is single bit digital comparator?
Ans: A Comparator is a combinational circuit that gives output in terms of A>B, A<B, and A=B.

2. Which type of Gates used in comparator?
XOR, NOT, AND gates used.

3. Write One Bit Comparater truth table?

Video Tutorial:

About the Author

Subramanian

Hello! My Dear Friends. I am Subramanian. I am writing posts on androiderode about Electronics testing and equipments.

View All Articles