OpenCores
URL https://opencores.org/ocsvn/debouncer_vhdl/debouncer_vhdl/trunk

Subversion Repositories debouncer_vhdl

[/] [debouncer_vhdl/] [trunk/] [bench/] [debounce_atlys_test.vhd] - Blame information for rev 3

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 jdoin
-- TestBench Template 
2
 
3
library ieee;
4
use ieee.std_logic_1164.all;
5
use ieee.numeric_std.all;
6
 
7
entity testbench is
8
end testbench;
9
 
10
architecture behavior of testbench is
11
 
12
    --=============================================================================================
13
    -- Constants
14
    --=============================================================================================
15
    -- clock period
16
    constant CLK_PERIOD : time := 10 ns;
17
 
18
    --=============================================================================================
19
    -- COMPONENT DECLARATIONS
20
    --=============================================================================================
21
    COMPONENT debounce_atlys_top
22
    PORT(
23
        gclk_i : IN std_logic;
24
        sw_i : IN std_logic_vector(7 downto 0);
25
        led_o : OUT std_logic_vector(7 downto 0);
26
        strb_o : OUT std_logic;
27
        dbg_o : OUT std_logic_vector(15 downto 0)
28
    );
29
    END COMPONENT;
30
 
31
    --=============================================================================================
32
    -- Signals for internal operation
33
    --=============================================================================================
34
    --- clock signals ---
35
    signal sysclk           : std_logic := '0';                                 -- 100MHz clock
36
    --- switch debouncer signals ---
37
    signal sw_data          : std_logic_vector (7 downto 0) := (others => '0'); -- switch data
38
    -- debug output signals
39
    signal leds             : std_logic_vector (7 downto 0);    -- board leds
40
    signal dbg              : std_logic_vector (15 downto 0);   -- LA debug vector
41
    signal strobe           : std_logic;
42
    signal sw_input         : std_logic_vector (7 downto 0);    -- raw switches
43
    signal sw_output        : std_logic_vector (7 downto 0);    -- debounced switches
44
begin
45
 
46
    --=============================================================================================
47
    -- COMPONENT INSTANTIATIONS FOR THE CORES UNDER TEST
48
    --=============================================================================================
49
    -- debounce_atlys_top:
50
    --      receives the 100 MHz clock from the board clock oscillator
51
    --      receives the 8 slide switches and 5 pushbuttons as test stimuli
52
    --      connects to 8 board LEDs
53
    --      connects to 16 debug pins
54
    Inst_debounce_atlys_top: debounce_atlys_top
55
    PORT MAP(
56
        gclk_i => sysclk,       -- connect board clock
57
        sw_i => sw_data,        -- connect board switches
58
        led_o => leds,          -- connect board leds
59
        strb_o => strobe,       -- connect strobe debug
60
        dbg_o => dbg            -- connect logic analyzer
61
    );
62
 
63
    -- debug signals mapped on dbg vector
64
    sw_input   <= dbg(7 downto 0);
65
    sw_output    <= dbg(15 downto 8);
66
 
67
    --=============================================================================================
68
    -- CLOCK GENERATION
69
    --=============================================================================================
70
    gclk_proc: process is
71
    begin
72
        loop
73
            sysclk <= not sysclk;
74
            wait for CLK_PERIOD / 2;
75
        end loop;
76
    end process gclk_proc;
77
 
78
    --=============================================================================================
79
    -- TEST BENCH STIMULI
80
    --=============================================================================================
81
    tb : process
82
    begin
83
        wait for 100 ns; -- wait until global set/reset completes
84
        sw_data <= X"00";
85
        wait for 1 us;
86
 
87
        -- change switches to 0x93, with bouncing
88
        sw_data <= X"81";
89
        wait for 50 ns;
90
        sw_data <= X"80";
91
        wait for 250 ns;
92
        sw_data <= X"91";
93
        wait for 40 ns;
94
        sw_data <= X"81";
95
        wait for 90 ns;
96
        sw_data <= X"93";
97
        wait for 40 us;
98
 
99
        -- change switches to 0x3E, with bouncing
100
        sw_data <= X"97";
101
        wait for 50 ns;
102
        sw_data <= X"16";
103
        wait for 150 ns;
104
        sw_data <= X"3E";
105
        wait for 300 ns;
106
        sw_data <= X"2C";
107
        wait for 50 ns;
108
        sw_data <= X"3D";
109
        wait for 400 ns;
110
        sw_data <= X"3E";
111
        wait for 50 us;
112
 
113
        -- end simulation
114
        assert false report "End Simulation" severity failure; -- stop simulation
115
    end process tb;
116
    --  End Test Bench 
117
END;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.