IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VHDL Discussion :

VHDL 8 bits comarators using modelsim


Sujet :

VHDL

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Inscrit en
    Juillet 2013
    Messages
    24
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2013
    Messages : 24
    Points : 25
    Points
    25
    Par défaut VHDL 8 bits comarators using modelsim
    Hay everyone ,
    i am trying to simulate a 8 bits comparator using 2 * 4 bits comparators here's my code .... it's compile --> no errors
    but i have 3 red lignes in the wave

    this is the 4bits comparator (with 3 outputs ega , inf and sup)




    Library ieee;
    use ieee.std_logic_1164.all;
    use ieee.std_logic_unsigned.all;
    entity Comp_4Bits is
    port(
    A : in std_logic_vector (3 downto 0);
    B : in std_logic_vector (3 downto 0);
    SUP : out std_logic;
    iNF : out std_logic;
    EGA : out std_logic);
    end Comp_4Bits ;
    Architecture RTL of Comp_4Bits is
    begin
    process(A,B)
    begin
    if (A>B) then Sup <='1' ; Inf <='0' ; Ega <='0' ;
    Elsif (A<B) then Inf <='1' ; Sup <='0' ; ega <='0' ;
    elsif (A=B) then Ega <='1' ; sup <='0' ; inf <='0' ;
    end if ;
    end process ;
    end RTL;


    and here is the code of 8 bits comparator



    library ieee;
    use ieee.std_logic_1164.all;
    use ieee.std_logic_unsigned.all;
    use ieee.numeric_std ;

    entity compa_8bits is port(
    A:in std_logic_vector(7 downto 0);
    B:in std_logic_vector(7 downto 0);
    ega:out std_logic ;
    sup:out std_logic;
    inf:out std_logic
    );
    end compa_8bits;

    architecture RTL of compa_8bits is

    signal sup1 , sup2 , inf1 , inf2 , ega1 , ega2 , sig1 , sig2:std_logic;

    component Comp_4Bits is port(
    A:IN std_logic_vector(3 downto 0);
    B:IN std_logic_vector(3 downto 0);
    ega:out std_logic;
    sup:out std_logic;
    inf:out std_logic);
    end component ;


    begin
    u1:Comp_4Bits port map
    (
    A =>A(7 downto 4),
    B=>B(7 downto 4),
    ega=>ega1 ,
    sup=>sup1,
    inf=>inf1
    );

    u2:Comp_4Bits port map
    (
    A=>A(3 downto 0),
    B=>B(3 downto 0),
    ega=>ega2,
    sup=>sup2,
    inf=>inf2);


    inf <= inf1 or (ega1 and inf2);
    sup <= sup1 or (ega1 and sup2);
    ega <= ega1 and ega2;

    END RTL;

    and finally the test bench

    library ieee;
    use ieee.std_logic_1164.all;
    use ieee.std_logic_unsigned.all;
    use ieee.numeric_std ;

    entity compa_8bits_tb is
    end compa_8bits_tb;

    architecture BHV of compa_8bits_tb is
    component compa_8bits is
    port(
    A:IN std_logic_vector(7 downto 0);
    B:IN std_logic_vector(7 downto 0);
    sup:out std_logic;
    ega:out std_logic;
    inf:out std_logic
    );
    end component;

    signal A, B : std_logic_vector( 7 downto 0) ;
    signal ega, inf, sup: std_logic;

    begin

    Dut1: compa_8bits port map(
    A => A ,
    B => B ,
    ega=>ega ,
    sup =>sup,
    inf=>inf
    );


    process
    begin
    A<="11110000";
    B<="01101111";
    wait for 20 ns;
    A<="01110000";
    B<="01110000";
    wait for 30 ns;
    A<="10011111";
    B<="01101010";
    end process;
    end BHV;



    merci bcp ;

  2. #2
    Membre expérimenté

    Homme Profil pro
    Collégien
    Inscrit en
    Juillet 2010
    Messages
    545
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Afghanistan

    Informations professionnelles :
    Activité : Collégien

    Informations forums :
    Inscription : Juillet 2010
    Messages : 545
    Points : 1 429
    Points
    1 429
    Par défaut
    Never put anything other than the clock and reset in the process sensitivity list

    You don't need two 4bits comparator to make a single 8 bits comparator.
    You just need a sigle 8 bits comparator...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
     
    entity Comp_NBits is
        generic( DATA_WIDTH : natural);
        port(
        A : in std_logic_vector (DATA_WIDTH-1 downto 0);
        B : in std_logic_vector (DATA_WIDTH-1 downto 0);
        SUP : out std_logic;
        iNF : out std_logic;
        EGA : out std_logic);
    end Comp_NBits ;
    Architecture RTL of Comp_NBits is
    begin
        Sup <= '1' when (A>B) else '0';
        Inf <= '1' when (A<B) else '0';
        Ega <= '1' when (A=B) else '0';
    end RTL;

Discussions similaires

  1. Réponses: 3
    Dernier message: 04/06/2015, 09h08
  2. Multiplication de deux nombres sur 8 bits en VHDL
    Par nissou23 dans le forum VHDL
    Réponses: 4
    Dernier message: 30/01/2013, 20h46
  3. Cherche l'algo crc 16 bits
    Par icepower dans le forum Algorithmes et structures de données
    Réponses: 2
    Dernier message: 21/08/2002, 13h27
  4. Debugger 16-32 bits
    Par Mat dans le forum Assembleur
    Réponses: 4
    Dernier message: 28/06/2002, 11h34
  5. Lire 1 bit d'un fichier en C
    Par Anonymous dans le forum C
    Réponses: 3
    Dernier message: 23/05/2002, 18h31

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo