1 |
3 |
jdoin |
----------------------------------------------------------------------------------
|
2 |
|
|
-- Author: Jonny Doin, jdoin@opencores.org, jonnydoin@gmail.com
|
3 |
|
|
--
|
4 |
|
|
-- Create Date: 01:21:32 06/30/2011
|
5 |
|
|
-- Design Name:
|
6 |
|
|
-- Module Name: debounce_atlys_top
|
7 |
4 |
jdoin |
-- Project Name: debounce_vhdl
|
8 |
3 |
jdoin |
-- Target Devices: Spartan-6 LX45
|
9 |
|
|
-- Tool versions: ISE 13.1
|
10 |
|
|
-- Description:
|
11 |
8 |
jdoin |
--
|
12 |
4 |
jdoin |
-- This is a verification project for the Digilent Atlys board, to test the GRP_DEBOUNCE core.
|
13 |
3 |
jdoin |
-- It uses the board's 100MHz clock input, and clocks all sequential logic at this clock.
|
14 |
|
|
--
|
15 |
4 |
jdoin |
-- See the "debounce_atlys.ucf" file for pin assignments.
|
16 |
3 |
jdoin |
-- The test circuit uses the VHDCI connector on the Atlys to implement a 16-pin debug port to be used
|
17 |
|
|
-- with a Tektronix MSO2014. The 16 debug pins are brought to 2 8x2 headers that form a umbilical
|
18 |
|
|
-- digital pod port.
|
19 |
8 |
jdoin |
-- If you want details of the testing circuit, send me an e-mail: jdoin@opencores.org
|
20 |
3 |
jdoin |
--
|
21 |
|
|
------------------------------ REVISION HISTORY -----------------------------------------------------------------------
|
22 |
|
|
--
|
23 |
4 |
jdoin |
-- 2011/08/10 v1.01.0025 [JD] changed to test the grp_debouncer.vhd module alone.
|
24 |
7 |
jdoin |
-- 2011/08/11 v1.01.0026 [JD] reduced switch inputs to 7, to save digital pins to the strobe signal.
|
25 |
3 |
jdoin |
--
|
26 |
|
|
--
|
27 |
|
|
----------------------------------------------------------------------------------
|
28 |
|
|
library ieee;
|
29 |
|
|
use ieee.std_logic_1164.all;
|
30 |
|
|
use ieee.std_logic_arith.all;
|
31 |
|
|
|
32 |
|
|
entity debounce_atlys_top is
|
33 |
|
|
Port (
|
34 |
8 |
jdoin |
gclk_i : in std_logic := 'X'; -- board clock input 100MHz
|
35 |
3 |
jdoin |
--- input slide switches ---
|
36 |
8 |
jdoin |
sw_i : in std_logic_vector (6 downto 0); -- 7 input slide switches
|
37 |
3 |
jdoin |
--- output LEDs ----
|
38 |
8 |
jdoin |
led_o : out std_logic_vector (6 downto 0); -- 7 output leds
|
39 |
3 |
jdoin |
--- debug outputs ---
|
40 |
8 |
jdoin |
dbg_o : out std_logic_vector (15 downto 0) -- 16 generic debug pins
|
41 |
3 |
jdoin |
);
|
42 |
|
|
end debounce_atlys_top;
|
43 |
|
|
|
44 |
|
|
architecture rtl of debounce_atlys_top is
|
45 |
|
|
|
46 |
|
|
--=============================================================================================
|
47 |
|
|
-- Constants
|
48 |
|
|
--=============================================================================================
|
49 |
|
|
-- debounce generics
|
50 |
7 |
jdoin |
constant N : integer := 7; -- 7 bits (7 switch inputs)
|
51 |
6 |
jdoin |
constant CNT_VAL : integer := 5000; -- debounce period = 1000 * 10 ns (50 us)
|
52 |
3 |
jdoin |
|
53 |
|
|
--=============================================================================================
|
54 |
|
|
-- Signals for internal operation
|
55 |
|
|
--=============================================================================================
|
56 |
|
|
--- switch debouncer signals ---
|
57 |
7 |
jdoin |
signal sw_data : std_logic_vector (6 downto 0) := (others => '0'); -- debounced switch data
|
58 |
|
|
signal sw_reg : std_logic_vector (6 downto 0) := (others => '0'); -- registered switch data
|
59 |
3 |
jdoin |
signal sw_new : std_logic := '0';
|
60 |
|
|
-- debug output signals
|
61 |
7 |
jdoin |
signal leds_reg : std_logic_vector (6 downto 0) := (others => '0');
|
62 |
3 |
jdoin |
signal dbg : std_logic_vector (15 downto 0) := (others => '0');
|
63 |
|
|
begin
|
64 |
|
|
|
65 |
|
|
--=============================================================================================
|
66 |
|
|
-- COMPONENT INSTANTIATIONS FOR THE CORES UNDER TEST
|
67 |
|
|
--=============================================================================================
|
68 |
|
|
-- debounce for the input switches, with new data strobe output
|
69 |
|
|
Inst_sw_debouncer: entity work.grp_debouncer(rtl)
|
70 |
|
|
generic map (N => N, CNT_VAL => CNT_VAL)
|
71 |
|
|
port map(
|
72 |
8 |
jdoin |
clk_i => gclk_i, -- system clock
|
73 |
|
|
data_i => sw_i, -- noisy input data
|
74 |
|
|
data_o => sw_data, -- registered stable output data
|
75 |
|
|
strb_o => sw_new -- transition detection
|
76 |
3 |
jdoin |
);
|
77 |
|
|
|
78 |
|
|
--=============================================================================================
|
79 |
|
|
-- REGISTER TRANSFER PROCESSES
|
80 |
|
|
--=============================================================================================
|
81 |
|
|
-- data registers: synchronous to the system clock
|
82 |
|
|
dat_reg_proc : process (gclk_i) is
|
83 |
|
|
begin
|
84 |
|
|
-- transfer switch data when new switch is detected
|
85 |
|
|
if gclk_i'event and gclk_i = '1' then
|
86 |
8 |
jdoin |
if sw_new = '1' then -- clock enable
|
87 |
|
|
sw_reg <= sw_data; -- only provide local reset for the state registers
|
88 |
3 |
jdoin |
end if;
|
89 |
|
|
end if;
|
90 |
|
|
end process dat_reg_proc;
|
91 |
|
|
|
92 |
|
|
--=============================================================================================
|
93 |
|
|
-- COMBINATORIAL LOGIC PROCESSES
|
94 |
|
|
--=============================================================================================
|
95 |
|
|
-- LED register update
|
96 |
8 |
jdoin |
leds_reg_proc: leds_reg <= sw_reg; -- leds register is a copy of the updated switch register
|
97 |
3 |
jdoin |
|
98 |
|
|
-- update debug register
|
99 |
7 |
jdoin |
dbg_in_proc: dbg(6 downto 0) <= sw_i; -- lower debug port has direct switch connections
|
100 |
|
|
dbg_out_proc: dbg(13 downto 7) <= sw_data; -- upper debug port has debounced switch data
|
101 |
|
|
dbg_strb_proc: dbg(14) <= sw_new; -- monitor new data strobe
|
102 |
3 |
jdoin |
|
103 |
|
|
|
104 |
|
|
--=============================================================================================
|
105 |
|
|
-- OUTPUT LOGIC PROCESSES
|
106 |
|
|
--=============================================================================================
|
107 |
|
|
-- connect leds_reg signal to LED outputs
|
108 |
|
|
led_o_proc: led_o <= leds_reg; -- drive the output leds
|
109 |
|
|
|
110 |
|
|
--=============================================================================================
|
111 |
|
|
-- DEBUG LOGIC PROCESSES
|
112 |
|
|
--=============================================================================================
|
113 |
|
|
-- connect the debug vector outputs
|
114 |
|
|
dbg_o_proc: dbg_o <= dbg; -- drive the logic analyzer port
|
115 |
|
|
|
116 |
|
|
end rtl;
|
117 |
|
|
|