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 |
4 |
jdoin |
-- This is a verification project for the Digilent Atlys board, to test the GRP_DEBOUNCE core.
|
12 |
3 |
jdoin |
-- It uses the board's 100MHz clock input, and clocks all sequential logic at this clock.
|
13 |
|
|
--
|
14 |
4 |
jdoin |
-- See the "debounce_atlys.ucf" file for pin assignments.
|
15 |
3 |
jdoin |
-- The test circuit uses the VHDCI connector on the Atlys to implement a 16-pin debug port to be used
|
16 |
|
|
-- with a Tektronix MSO2014. The 16 debug pins are brought to 2 8x2 headers that form a umbilical
|
17 |
|
|
-- digital pod port.
|
18 |
|
|
--
|
19 |
|
|
------------------------------ REVISION HISTORY -----------------------------------------------------------------------
|
20 |
|
|
--
|
21 |
|
|
-- 2011/07/02 v0.01.0010 [JD] implemented a wire-through from switches to LEDs, just to test the toolchain. It worked!
|
22 |
|
|
-- 2011/07/03 v0.01.0020 [JD] added clock input, and a simple LED blinker for each LED.
|
23 |
|
|
-- 2011/07/03 v0.01.0030 [JD] added clear input, and instantiated a SPI_MASTER from my OpenCores project.
|
24 |
|
|
-- 2011/07/04 v0.01.0040 [JD] changed all clocks to clock enables, and use the 100MHz board gclk_i to clock all registers.
|
25 |
|
|
-- this change made the design go up to 288MHz, after synthesis.
|
26 |
|
|
-- 2011/07/07 v0.03.0050 [JD] implemented a 16pin umbilical port for the MSO2014 in the Atlys VmodBB board, and moved all
|
27 |
|
|
-- external monitoring pins to the VHDCI ports.
|
28 |
|
|
-- 2011/07/10 v1.10.0075 [JD] verified spi_master_slave at 50MHz, 25MHz, 16.666MHz, 12.5MHz, 10MHz, 8.333MHz, 7.1428MHz,
|
29 |
|
|
-- 6.25MHz, 1MHz and 500kHz
|
30 |
|
|
-- 2011/07/29 v1.12.0105 [JD] spi_master.vhd and spi_slave_vhd changed to fix CPHA='1' bug.
|
31 |
|
|
-- 2011/08/02 v1.13.0110 [JD] testbed for continuous transfer in FPGA hardware.
|
32 |
4 |
jdoin |
-- 2011/08/10 v1.01.0025 [JD] changed to test the grp_debouncer.vhd module alone.
|
33 |
3 |
jdoin |
--
|
34 |
|
|
--
|
35 |
|
|
----------------------------------------------------------------------------------
|
36 |
|
|
library ieee;
|
37 |
|
|
use ieee.std_logic_1164.all;
|
38 |
|
|
use ieee.std_logic_arith.all;
|
39 |
|
|
|
40 |
|
|
entity debounce_atlys_top is
|
41 |
|
|
Port (
|
42 |
|
|
gclk_i : in std_logic := 'X'; -- board clock input 100MHz
|
43 |
|
|
--- input slide switches ---
|
44 |
|
|
sw_i : in std_logic_vector (7 downto 0); -- 8 input slide switches
|
45 |
|
|
--- output LEDs ----
|
46 |
|
|
led_o : out std_logic_vector (7 downto 0); -- output leds
|
47 |
|
|
--- debug outputs ---
|
48 |
|
|
strb_o : out std_logic; -- core strobe output
|
49 |
|
|
dbg_o : out std_logic_vector (15 downto 0) -- 16 generic debug pins
|
50 |
|
|
);
|
51 |
|
|
end debounce_atlys_top;
|
52 |
|
|
|
53 |
|
|
architecture rtl of debounce_atlys_top is
|
54 |
|
|
|
55 |
|
|
--=============================================================================================
|
56 |
|
|
-- Constants
|
57 |
|
|
--=============================================================================================
|
58 |
|
|
-- debounce generics
|
59 |
|
|
constant N : integer := 8; -- 8 bits (8 switch inputs)
|
60 |
|
|
constant CNT_VAL : integer := 1000; -- debounce period = 1000 * 10 ns (10 us)
|
61 |
|
|
|
62 |
|
|
--=============================================================================================
|
63 |
|
|
-- Signals for internal operation
|
64 |
|
|
--=============================================================================================
|
65 |
|
|
--- switch debouncer signals ---
|
66 |
|
|
signal sw_data : std_logic_vector (7 downto 0) := (others => '0'); -- debounced switch data
|
67 |
|
|
signal sw_reg : std_logic_vector (7 downto 0) := (others => '0'); -- registered switch data
|
68 |
|
|
signal sw_new : std_logic := '0';
|
69 |
|
|
-- debug output signals
|
70 |
|
|
signal leds_reg : std_logic_vector (7 downto 0) := (others => '0');
|
71 |
|
|
signal dbg : std_logic_vector (15 downto 0) := (others => '0');
|
72 |
|
|
begin
|
73 |
|
|
|
74 |
|
|
--=============================================================================================
|
75 |
|
|
-- COMPONENT INSTANTIATIONS FOR THE CORES UNDER TEST
|
76 |
|
|
--=============================================================================================
|
77 |
|
|
-- debounce for the input switches, with new data strobe output
|
78 |
|
|
Inst_sw_debouncer: entity work.grp_debouncer(rtl)
|
79 |
|
|
generic map (N => N, CNT_VAL => CNT_VAL)
|
80 |
|
|
port map(
|
81 |
|
|
clk_i => gclk_i, -- system clock
|
82 |
|
|
data_i => sw_i, -- noisy input data
|
83 |
|
|
data_o => sw_data, -- registered stable output data
|
84 |
|
|
strb_o => sw_new -- transition detection
|
85 |
|
|
);
|
86 |
|
|
|
87 |
|
|
--=============================================================================================
|
88 |
|
|
-- REGISTER TRANSFER PROCESSES
|
89 |
|
|
--=============================================================================================
|
90 |
|
|
-- data registers: synchronous to the system clock
|
91 |
|
|
dat_reg_proc : process (gclk_i) is
|
92 |
|
|
begin
|
93 |
|
|
-- transfer switch data when new switch is detected
|
94 |
|
|
if gclk_i'event and gclk_i = '1' then
|
95 |
|
|
if sw_new = '1' then -- clock enable
|
96 |
|
|
sw_reg <= sw_data; -- only provide local reset for the state registers
|
97 |
|
|
end if;
|
98 |
|
|
end if;
|
99 |
|
|
end process dat_reg_proc;
|
100 |
|
|
|
101 |
|
|
--=============================================================================================
|
102 |
|
|
-- COMBINATORIAL LOGIC PROCESSES
|
103 |
|
|
--=============================================================================================
|
104 |
|
|
-- LED register update
|
105 |
|
|
leds_reg_proc: leds_reg <= sw_reg; -- leds register is a copy of the updated switch register
|
106 |
|
|
|
107 |
|
|
-- update debug register
|
108 |
|
|
dbg_lo_proc: dbg(7 downto 0) <= sw_i; -- lower debug port has debounced switch data
|
109 |
|
|
dbg_hi_proc: dbg(15 downto 8) <= sw_data; -- upper debug port has direct switch connections
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
--=============================================================================================
|
113 |
|
|
-- OUTPUT LOGIC PROCESSES
|
114 |
|
|
--=============================================================================================
|
115 |
|
|
-- connect leds_reg signal to LED outputs
|
116 |
|
|
led_o_proc: led_o <= leds_reg; -- drive the output leds
|
117 |
|
|
|
118 |
|
|
--=============================================================================================
|
119 |
|
|
-- DEBUG LOGIC PROCESSES
|
120 |
|
|
--=============================================================================================
|
121 |
|
|
-- connect the debug vector outputs
|
122 |
|
|
strb_o_proc: strb_o <= sw_new; -- connect strobe debug out
|
123 |
|
|
dbg_o_proc: dbg_o <= dbg; -- drive the logic analyzer port
|
124 |
|
|
|
125 |
|
|
end rtl;
|
126 |
|
|
|