Line 19... |
Line 19... |
-- COMPONENT DECLARATIONS
|
-- COMPONENT DECLARATIONS
|
--=============================================================================================
|
--=============================================================================================
|
COMPONENT debounce_atlys_top
|
COMPONENT debounce_atlys_top
|
PORT(
|
PORT(
|
gclk_i : IN std_logic;
|
gclk_i : IN std_logic;
|
sw_i : IN std_logic_vector(7 downto 0);
|
sw_i : IN std_logic_vector(6 downto 0);
|
led_o : OUT std_logic_vector(7 downto 0);
|
led_o : OUT std_logic_vector(6 downto 0);
|
strb_o : OUT std_logic;
|
|
dbg_o : OUT std_logic_vector(15 downto 0)
|
dbg_o : OUT std_logic_vector(15 downto 0)
|
);
|
);
|
END COMPONENT;
|
END COMPONENT;
|
|
|
--=============================================================================================
|
--=============================================================================================
|
-- Signals for internal operation
|
-- Signals for internal operation
|
--=============================================================================================
|
--=============================================================================================
|
--- clock signals ---
|
--- clock signals ---
|
signal sysclk : std_logic := '0'; -- 100MHz clock
|
signal sysclk : std_logic := '0'; -- 100MHz clock
|
--- switch debouncer signals ---
|
--- switch debouncer signals ---
|
signal sw_data : std_logic_vector (7 downto 0) := (others => '0'); -- switch data
|
signal sw_data : std_logic_vector (6 downto 0) := (others => '0'); -- switch data
|
-- debug output signals
|
-- debug output signals
|
signal leds : std_logic_vector (7 downto 0); -- board leds
|
signal leds : std_logic_vector (6 downto 0); -- board leds
|
signal dbg : std_logic_vector (15 downto 0); -- LA debug vector
|
signal dbg : std_logic_vector (15 downto 0); -- LA debug vector
|
signal strobe : std_logic;
|
signal strobe : std_logic;
|
signal sw_input : std_logic_vector (7 downto 0); -- raw switches
|
signal sw_input : std_logic_vector (6 downto 0); -- raw switches
|
signal sw_output : std_logic_vector (7 downto 0); -- debounced switches
|
signal sw_output : std_logic_vector (6 downto 0); -- debounced switches
|
begin
|
begin
|
|
|
--=============================================================================================
|
--=============================================================================================
|
-- COMPONENT INSTANTIATIONS FOR THE CORES UNDER TEST
|
-- COMPONENT INSTANTIATIONS FOR THE CORES UNDER TEST
|
--=============================================================================================
|
--=============================================================================================
|
-- debounce_atlys_top:
|
-- debounce_atlys_top:
|
-- receives the 100 MHz clock from the board clock oscillator
|
-- receives the 100 MHz clock from the board clock oscillator
|
-- receives the 8 slide switches and 5 pushbuttons as test stimuli
|
-- receives 7 slide switches as test stimuli
|
-- connects to 8 board LEDs
|
-- connects to 7 board LEDs
|
-- connects to 16 debug pins
|
-- connects to 16 debug pins
|
Inst_debounce_atlys_top: debounce_atlys_top
|
Inst_debounce_atlys_top: debounce_atlys_top
|
PORT MAP(
|
PORT MAP(
|
gclk_i => sysclk, -- connect board clock
|
gclk_i => sysclk, -- connect board clock
|
sw_i => sw_data, -- connect board switches
|
sw_i => sw_data, -- connect board switches
|
led_o => leds, -- connect board leds
|
led_o => leds, -- connect board leds
|
strb_o => strobe, -- connect strobe debug
|
|
dbg_o => dbg -- connect logic analyzer
|
dbg_o => dbg -- connect logic analyzer
|
);
|
);
|
|
|
-- debug signals mapped on dbg vector
|
-- debug signals mapped on dbg vector
|
sw_input <= dbg(7 downto 0);
|
sw_input <= dbg(6 downto 0);
|
sw_output <= dbg(15 downto 8);
|
sw_output <= dbg(13 downto 7);
|
|
strobe <= dbg(14);
|
|
|
--=============================================================================================
|
--=============================================================================================
|
-- CLOCK GENERATION
|
-- CLOCK GENERATION
|
--=============================================================================================
|
--=============================================================================================
|
gclk_proc: process is
|
gclk_proc: process is
|
Line 79... |
Line 78... |
-- TEST BENCH STIMULI
|
-- TEST BENCH STIMULI
|
--=============================================================================================
|
--=============================================================================================
|
tb : process
|
tb : process
|
begin
|
begin
|
wait for 100 ns; -- wait until global set/reset completes
|
wait for 100 ns; -- wait until global set/reset completes
|
sw_data <= X"00";
|
sw_data <= B"000_0000";
|
wait for 1 us;
|
wait for 1 us;
|
|
|
-- change switches to 0x93, with bouncing
|
-- change switches to 0x71, with bouncing
|
sw_data <= X"81";
|
sw_data <= B"100_0001";
|
wait for 50 ns;
|
wait until strobe = '1';
|
sw_data <= X"80";
|
wait until strobe = '0';
|
wait for 250 ns;
|
sw_data <= B"100_0000";
|
sw_data <= X"91";
|
wait until strobe = '1';
|
wait for 40 ns;
|
wait until strobe = '0';
|
sw_data <= X"81";
|
sw_data <= B"101_0001";
|
wait for 90 ns;
|
wait until strobe = '1';
|
sw_data <= X"93";
|
wait until strobe = '0';
|
wait for 40 us;
|
sw_data <= B"100_0001";
|
|
wait until strobe = '1';
|
|
wait until strobe = '0';
|
|
sw_data <= B"111_0001";
|
|
wait until strobe = '1';
|
|
wait until strobe = '0';
|
|
|
-- change switches to 0x3E, with bouncing
|
-- change switches to 0x3E, with bouncing
|
sw_data <= X"97";
|
sw_data <= B"111_1001";
|
wait for 50 ns;
|
wait until strobe = '1';
|
sw_data <= X"16";
|
wait until strobe = '0';
|
wait for 150 ns;
|
sw_data <= B"011_0001";
|
sw_data <= X"3E";
|
wait until strobe = '1';
|
wait for 300 ns;
|
wait until strobe = '0';
|
sw_data <= X"2C";
|
sw_data <= B"111_1101";
|
wait for 50 ns;
|
wait until strobe = '1';
|
sw_data <= X"3D";
|
wait until strobe = '0';
|
wait for 400 ns;
|
sw_data <= B"011_1011";
|
sw_data <= X"3E";
|
wait until strobe = '1';
|
wait for 50 us;
|
wait until strobe = '0';
|
|
sw_data <= B"111_1100";
|
|
wait until strobe = '1';
|
|
wait until strobe = '0';
|
|
sw_data <= B"011_1110";
|
|
wait until strobe = '1';
|
|
wait until strobe = '0';
|
|
|
-- end simulation
|
-- end simulation
|
assert false report "End Simulation" severity failure; -- stop simulation
|
assert false report "End Simulation" severity failure; -- stop simulation
|
end process tb;
|
end process tb;
|
-- End Test Bench
|
-- End Test Bench
|