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 |
10 |
jdoin |
sw_i : IN std_logic_vector(6 downto 0);
|
25 |
|
|
led_o : OUT std_logic_vector(6 downto 0);
|
26 |
3 |
jdoin |
dbg_o : OUT std_logic_vector(15 downto 0)
|
27 |
|
|
);
|
28 |
|
|
END COMPONENT;
|
29 |
|
|
|
30 |
|
|
--=============================================================================================
|
31 |
|
|
-- Signals for internal operation
|
32 |
|
|
--=============================================================================================
|
33 |
|
|
--- clock signals ---
|
34 |
|
|
signal sysclk : std_logic := '0'; -- 100MHz clock
|
35 |
|
|
--- switch debouncer signals ---
|
36 |
10 |
jdoin |
signal sw_data : std_logic_vector (6 downto 0) := (others => '0'); -- switch data
|
37 |
3 |
jdoin |
-- debug output signals
|
38 |
10 |
jdoin |
signal leds : std_logic_vector (6 downto 0); -- board leds
|
39 |
3 |
jdoin |
signal dbg : std_logic_vector (15 downto 0); -- LA debug vector
|
40 |
|
|
signal strobe : std_logic;
|
41 |
10 |
jdoin |
signal sw_input : std_logic_vector (6 downto 0); -- raw switches
|
42 |
|
|
signal sw_output : std_logic_vector (6 downto 0); -- debounced switches
|
43 |
3 |
jdoin |
begin
|
44 |
|
|
|
45 |
|
|
--=============================================================================================
|
46 |
|
|
-- COMPONENT INSTANTIATIONS FOR THE CORES UNDER TEST
|
47 |
|
|
--=============================================================================================
|
48 |
|
|
-- debounce_atlys_top:
|
49 |
|
|
-- receives the 100 MHz clock from the board clock oscillator
|
50 |
10 |
jdoin |
-- receives 7 slide switches as test stimuli
|
51 |
|
|
-- connects to 7 board LEDs
|
52 |
3 |
jdoin |
-- connects to 16 debug pins
|
53 |
|
|
Inst_debounce_atlys_top: debounce_atlys_top
|
54 |
|
|
PORT MAP(
|
55 |
|
|
gclk_i => sysclk, -- connect board clock
|
56 |
|
|
sw_i => sw_data, -- connect board switches
|
57 |
|
|
led_o => leds, -- connect board leds
|
58 |
|
|
dbg_o => dbg -- connect logic analyzer
|
59 |
|
|
);
|
60 |
|
|
|
61 |
|
|
-- debug signals mapped on dbg vector
|
62 |
10 |
jdoin |
sw_input <= dbg(6 downto 0);
|
63 |
|
|
sw_output <= dbg(13 downto 7);
|
64 |
|
|
strobe <= dbg(14);
|
65 |
3 |
jdoin |
|
66 |
|
|
--=============================================================================================
|
67 |
|
|
-- CLOCK GENERATION
|
68 |
|
|
--=============================================================================================
|
69 |
|
|
gclk_proc: process is
|
70 |
|
|
begin
|
71 |
|
|
loop
|
72 |
|
|
sysclk <= not sysclk;
|
73 |
|
|
wait for CLK_PERIOD / 2;
|
74 |
|
|
end loop;
|
75 |
|
|
end process gclk_proc;
|
76 |
|
|
|
77 |
|
|
--=============================================================================================
|
78 |
|
|
-- TEST BENCH STIMULI
|
79 |
|
|
--=============================================================================================
|
80 |
|
|
tb : process
|
81 |
|
|
begin
|
82 |
|
|
wait for 100 ns; -- wait until global set/reset completes
|
83 |
10 |
jdoin |
sw_data <= B"000_0000";
|
84 |
3 |
jdoin |
wait for 1 us;
|
85 |
|
|
|
86 |
10 |
jdoin |
-- change switches to 0x71, with bouncing
|
87 |
|
|
sw_data <= B"100_0001";
|
88 |
|
|
wait until strobe = '1';
|
89 |
|
|
wait until strobe = '0';
|
90 |
|
|
sw_data <= B"100_0000";
|
91 |
|
|
wait until strobe = '1';
|
92 |
|
|
wait until strobe = '0';
|
93 |
|
|
sw_data <= B"101_0001";
|
94 |
|
|
wait until strobe = '1';
|
95 |
|
|
wait until strobe = '0';
|
96 |
|
|
sw_data <= B"100_0001";
|
97 |
|
|
wait until strobe = '1';
|
98 |
|
|
wait until strobe = '0';
|
99 |
|
|
sw_data <= B"111_0001";
|
100 |
|
|
wait until strobe = '1';
|
101 |
|
|
wait until strobe = '0';
|
102 |
3 |
jdoin |
|
103 |
|
|
-- change switches to 0x3E, with bouncing
|
104 |
10 |
jdoin |
sw_data <= B"111_1001";
|
105 |
|
|
wait until strobe = '1';
|
106 |
|
|
wait until strobe = '0';
|
107 |
|
|
sw_data <= B"011_0001";
|
108 |
|
|
wait until strobe = '1';
|
109 |
|
|
wait until strobe = '0';
|
110 |
|
|
sw_data <= B"111_1101";
|
111 |
|
|
wait until strobe = '1';
|
112 |
|
|
wait until strobe = '0';
|
113 |
|
|
sw_data <= B"011_1011";
|
114 |
|
|
wait until strobe = '1';
|
115 |
|
|
wait until strobe = '0';
|
116 |
|
|
sw_data <= B"111_1100";
|
117 |
|
|
wait until strobe = '1';
|
118 |
|
|
wait until strobe = '0';
|
119 |
|
|
sw_data <= B"011_1110";
|
120 |
|
|
wait until strobe = '1';
|
121 |
|
|
wait until strobe = '0';
|
122 |
3 |
jdoin |
|
123 |
|
|
-- end simulation
|
124 |
|
|
assert false report "End Simulation" severity failure; -- stop simulation
|
125 |
|
|
end process tb;
|
126 |
|
|
-- End Test Bench
|
127 |
|
|
END;
|