Forum: FPGA, VHDL & Co. Komisches Simulationsergebnis


von D. I. (Gast)


Angehängte Dateien:

Lesenswert?

Hi,
ich habe mir einen debouncer geschrieben:
1
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
use IEEE.NUMERIC_STD.ALL;
4
5
entity debouncer is
6
   generic ( reg_width   : natural := 4;   -- how many samples should be stored
7
             wait_x_clks : natural := 10); -- how many clocks pass between 2 samples
8
   port ( clk      : in   std_logic;
9
          sig_in   : in   std_logic;
10
          sig_out  : out  std_logic);
11
end debouncer;
12
13
architecture rtl of debouncer is
14
   component mod_x_cnt
15
      generic ( x : natural := wait_x_clks);
16
      port ( clk  : in  std_logic;
17
             rst  : in  std_logic;
18
             stop : in  std_logic;
19
             tick : out std_logic);
20
   end component;
21
   
22
   signal inputsr    : std_logic_vector(reg_width-1 downto 0) := (others => '0');
23
   signal sample_rdy : std_logic;
24
begin
25
   sample_tick : mod_x_cnt
26
   generic map ( x => wait_x_clks) 
27
   port map ( clk  => clk,
28
              rst  => '0',
29
              stop => '0',
30
              tick => sample_rdy);
31
32
   process 
33
   begin
34
      wait until rising_edge(clk);
35
      if (sample_rdy = '1') then
36
         if (inputsr = (inputsr'range => '0')) then 
37
            sig_out <= '0'; 
38
         end if;
39
         
40
         if (inputsr = (inputsr'range => '1')) then 
41
            sig_out <= '1';
42
         end if;         
43
         inputsr <= inputsr(reg_width-2 downto 0) & sig_in;
44
      end if;
45
   end process;
46
end rtl;
1
library IEEE;
2
use IEEE.STD_LOGIC_1164.ALL;
3
use IEEE.NUMERIC_STD.ALL;
4
5
entity mod_x_cnt is
6
   generic ( x : natural := 10);
7
   port ( clk  : in  std_logic;
8
          rst  : in  std_logic;
9
          stop : in  std_logic;
10
          tick : out std_logic);
11
end mod_x_cnt;
12
13
architecture rtl of mod_x_cnt is
14
   signal cnt : integer range 0 to x-1 := 0; 
15
begin
16
   process
17
   begin
18
      wait until rising_edge(clk);
19
      tick <= '0';
20
      if (rst = '1') then
21
         cnt <= 0;
22
      else
23
         if (stop = '1') then
24
            cnt <= cnt;
25
         else
26
            if (cnt = (x-1)) then
27
               cnt <= 0;
28
               tick <= '1';
29
            else
30
               cnt <= cnt + 1;
31
            end if;
32
         end if;
33
      end if;
34
   end process;
35
end rtl;

Mit folgender Testbench:
1
LIBRARY ieee;
2
USE ieee.std_logic_1164.ALL;
3
USE ieee.numeric_std.ALL;
4
 
5
ENTITY tb_debouncer IS
6
END tb_debouncer;
7
 
8
ARCHITECTURE behavior OF tb_debouncer IS 
9
 
10
    -- Component Declaration for the Unit Under Test (UUT)
11
 
12
    COMPONENT debouncer
13
    generic ( reg_width   : natural := 4;
14
              wait_x_clks : natural := 10);
15
    PORT(
16
         clk : IN  std_logic;
17
         sig_in : IN  std_logic;
18
         sig_out : OUT  std_logic
19
        );
20
    END COMPONENT;
21
    
22
23
   --Inputs
24
   signal clk : std_logic := '0';
25
   signal sig_in : std_logic := '0';
26
27
   --Outputs
28
   signal sig_out : std_logic;
29
30
   -- Clock period definitions
31
   constant clk_period : time := 20ns;
32
 
33
BEGIN
34
 
35
  -- Instantiate the Unit Under Test (UUT)
36
   uut: debouncer
37
   generic map( reg_width   => 4,
38
                wait_x_clks => 10)
39
   PORT MAP (
40
          clk => clk,
41
          sig_in => sig_in,
42
          sig_out => sig_out
43
        );
44
45
   -- Clock process definitions
46
   clk_process :process
47
   begin
48
    clk <= '0';
49
    wait for clk_period/2;
50
    clk <= '1';
51
    wait for clk_period/2;
52
   end process;
53
 
54
55
   -- Stimulus process
56
   stim_proc: process
57
   begin    
58
59
      sig_in <= '1';  wait for clk_period*50;
60
      
61
      sig_in <= '0'; wait for clk_period*5;
62
      sig_in <= '1'; wait for clk_period*5;
63
      sig_in <= '0'; wait for clk_period*5;
64
      sig_in <= '1'; wait for clk_period*5;
65
      sig_in <= '0'; wait for clk_period*50;
66
            
67
      -- insert stimulus here 
68
69
      wait;
70
   end process;
71
72
END;

Und bekomme den Signalverlauf im angehängten Screenshot den ich mir aber 
nicht erklären kann

von D. I. (Gast)


Lesenswert?

Hat sich schon erledigt, ich habe schlichtweg im Simulator die falsche 
Unit ausgewählt -.-

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.