Search This Blog

Saturday, July 20, 2013

Design of 4 Bit Comparator using IF-ELSE Statements (VHDL Code).





Design of 4 Bit Comparator using  IF-ELSE Statements (Behavior Modeling Style) -



Output Waveform :   4 Bit Comparator




VHDL Code -


-------------------------------------------------------------------------------
--
-- Title       : comparator_4bit
-- Design      : vhdl_upload 1
-- Author      : Naresh Singh Dobal
-- Company     : nsdobal@gmail.com
-- VHDL Tutorials & exercise by Naresh Singh Dobal
-------------------------------------------------------------------------------
--
-- File        : 4 bit comparator using if else.vhd

   

library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity comparator_4bit is
     port(
         a : in STD_LOGIC_VECTOR(3 downto 0);
         b : in STD_LOGIC_VECTOR(3 downto 0);
         equal : out STD_LOGIC;
         greater : out STD_LOGIC;
         lower : out STD_LOGIC
         );
end comparator_4bit;


architecture comparator_4bit_arc of comparator_4bit is
begin

    comparator : process (a,b) is
    begin
        if (a=b) then
            equal <= '1';
            greater <= '0';
            lower <= '0';
        elsif (a<b) then
            equal <= '0';
            greater <= '0';
            lower <= '1';
        else
            equal <= '0';
            greater <= '1';
            lower <= '0';
        end if;
    end process comparator;

end comparator_4bit_arc;

5 comments:

  1. how do you create a program for a 8 bit comparator using full adders?

    ReplyDelete
  2. i want the program of reversible quantum comparator sir

    ReplyDelete
  3. Why don't you search on google you'll find the same codes there :D

    ReplyDelete