Forum: FPGA, VHDL & Co. VHDL 8 BITS comarators


von FrAnKeStEiN M. (frankestein_m)


Lesenswert?

Hay everyone ,
 i am trying to simulate a 8 bits comparator using 2 * 4 bits comarators 
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)
1
    Library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.std_logic_unsigned.all;
4
entity Comp_4Bits is
5
port(
6
  A : in std_logic_vector (3 downto 0);
7
  B : in std_logic_vector (3 downto 0);
8
  SUP : out std_logic;
9
  iNF : out std_logic;
10
  EGA : out std_logic);
11
end Comp_4Bits ;
12
Architecture RTL of Comp_4Bits is
13
begin
14
 process(A,B)
15
 begin
16
  if (A>B) then Sup <='1' ; Inf <='0' ; Ega <='0' ;  
17
  Elsif (A<B) then Inf <='1' ; Sup <='0' ; ega <='0' ;
18
  elsif (A=B) then Ega <='1' ; sup <='0' ; inf <='0' ; 
19
  end if ;
20
 end process ;
21
end RTL;

and here is the code of 8 bits comparator
1
   
2
    library ieee;
3
     use ieee.std_logic_1164.all;
4
    use ieee.std_logic_unsigned.all;
5
    use ieee.numeric_std ;
6
7
entity compa_8bits is port(
8
    A:in std_logic_vector(7 downto 0);
9
    B:in std_logic_vector(7 downto 0);
10
    ega:out std_logic ;
11
  sup:out std_logic;
12
    inf:out std_logic
13
    );
14
end compa_8bits;
15
16
architecture RTL of compa_8bits is
17
18
signal sup1 , sup2 , inf1 , inf2 , ega1 , ega2  , sig1 , sig2:std_logic;
19
   
20
 component Comp_4Bits is port(
21
      A:IN std_logic_vector(3 downto 0);
22
      B:IN std_logic_vector(3 downto 0);
23
      ega:out std_logic;
24
    sup:out std_logic;
25
      inf:out std_logic);
26
      end component ;
27
      
28
      
29
      begin 
30
       u1:Comp_4Bits  port map
31
       (
32
        A =>A(7 downto 4),
33
        B=>B(7 downto 4),
34
        ega=>ega1 ,
35
      sup=>sup1,
36
        inf=>inf1
37
        );
38
    
39
        u2:Comp_4Bits port map
40
        (
41
        A=>A(3 downto 0),
42
        B=>B(3 downto 0),
43
        ega=>ega2,
44
    sup=>sup2,
45
        inf=>inf2);
46
        
47
        
48
        inf <= inf1 or (ega1 and inf2);
49
        sup <= sup1 or (ega1 and sup2);
50
        ega <= ega1 and ega2;
51
    
52
END RTL;

and finally the test bench
1
        library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.std_logic_unsigned.all;
4
use ieee.numeric_std ;
5
6
entity compa_8bits_tb is 
7
end compa_8bits_tb;
8
9
architecture BHV of compa_8bits_tb is
10
component compa_8bits is
11
port(
12
      A:IN std_logic_vector(7 downto 0);
13
      B:IN std_logic_vector(7 downto 0);
14
      sup:out std_logic;
15
      ega:out std_logic;
16
      inf:out std_logic  
17
      );
18
      end component;
19
      
20
      signal A, B : std_logic_vector( 7 downto 0) ;
21
      signal ega, inf, sup: std_logic;
22
23
begin 
24
25
Dut1:  compa_8bits port map(
26
   A  => A ,
27
   B  => B , 
28
   ega=>ega ,
29
   sup =>sup,
30
   inf=>inf
31
   );
32
33
  
34
   process
35
   begin 
36
   A<="11110000";
37
   B<="01101111";
38
   wait for 20 ns;
39
   A<="01110000";
40
   B<="01110000";
41
   wait for 30 ns;
42
   A<="10011111";
43
   B<="01101010";
44
   end process;
45
   end BHV;

: Bearbeitet durch Moderator
von Lothar M. (Firma: Titel) (lkmiller) (Moderator) Benutzerseite


Lesenswert?

FrAnKeStEiN M. schrieb:
> i am trying to simulate
With what toolchain?

> it's compile --> no errors
Fine.

>  but i have 3 red lignes in the wave
And what does this mean?
What value is this "red line"?
Is it "X" or "U" or something else?

This isn't a good idea:
1
    use ieee.std_logic_unsigned.all;
2
    use ieee.numeric_std ;
Because some of the definitions are declared in both of the libraries. 
Curious effects may happen...


Pls use the VHDL tags around your code:
1
  [vhdl]
2
     your VHDL code
3
  [/vhdl]

: Bearbeitet durch Moderator
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.