Saturday 15 January 2011

VHDL Code for 4 Bit Comparator

4 bit comparator

 

 

 

 

 

 

 

The vhdl coding for a 4 bit comparator is as follows:-

Its a behavioural type of modelling.....




LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
USE ieee.std_logic_arith.all ;
ENTITY compare IS
PORT ( A, B : IN SIGNED(3 DOWNTO 0) ;
AeqB, AgtB, AltB : OUT STD_LOGIC ) ;
END compare ;
ARCHITECTURE Behavior OF compare IS
BEGIN
AeqB <= '1' WHEN A = B ELSE '0' ;
AgtB <= '1' WHEN A > B ELSE '0' ;
AltB <= '1' WHEN A < B ELSE '0' ;
END Behavior ;

 

22 comments:

  1. very usefull

    ReplyDelete
  2. thanx abhijit, you can subscibe us too for more such useful posts!!

    ReplyDelete
  3. this is very gud....but i want foe 8bit comparator......:-/

    ReplyDelete
  4. Thank you for giving imp information...

    ReplyDelete
  5. Just take (7 downto 0 ) instead of (3 downto 0). :-)

    ReplyDelete
  6. Is there a code on here for the 4-bit comparator, but with a structural coding instead of behavioural?

    ReplyDelete
  7. i want vhdl code which generate 16 bit output as a pulse in step order

    ReplyDelete
  8. I do agree with all the ideas you have offered to your post.
    They are really convincing and can certainly work.
    Still, the posts are too quick for starters.
    May you please prolong them a little from subsequent time?

    Thank you for the post.

    ReplyDelete
  9. is this using altera quartus 2 software?

    ReplyDelete
  10. Generate a PWM signal with 50% duty cycle produce the VHDL code of a 4 bit comparator. The module should have two 4 bit inputs which have to be compared, and one 1 bit output.(the result of the comparision ) set the coparator threshold value (the value to be compared with) at 1000 binary.
    Design the top module that connects the modules created at stage 1 and 2 such that the counter will be clocked at the frequency of 2 HZ and the comparator will compare the counter output with 1000 binary pre set value.

    Please help me this.

    ReplyDelete
  11. please send me structural modeling vhdl code

    ReplyDelete
  12. USE ieee.std_logic_arith.all ; which statement is using this library? Is it necessary to take this library just in this particular code? Thanks in advance!

    ReplyDelete
  13. its simple and easy but we have to make use of process statement in behavioral modelling ,if process is not used will this work?

    ReplyDelete