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

Subversion Repositories pdp8

[/] [pdp8/] [trunk/] [nexys2/] [nexys2_debounce.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 trurl
------------------------------------------------------------------
2
--!
3
--! PDP-8 Processor
4
--!
5
--! \brief
6
--!      NEXYS2 Wrapper: Debounce Device
7
--!
8
--! \file
9
--!      nexys2_debounce.vhd
10
--!
11
--! \author
12
--!      Rob Doyle - doyle (at) cox (dot) net
13
--!
14
--------------------------------------------------------------------
15
--
16
--  Copyright (C) 2009, 2010, 2011 Rob Doyle
17
--
18
-- This source file may be used and distributed without
19
-- restriction provided that this copyright statement is not
20
-- removed from the file and that any derivative work contains
21
-- the original copyright notice and the associated disclaimer.
22
--
23
-- This source file is free software; you can redistribute it
24
-- and/or modify it under the terms of the GNU Lesser General
25
-- Public License as published by the Free Software Foundation;
26
-- version 2.1 of the License.
27
--
28
-- This source is distributed in the hope that it will be
29
-- useful, but WITHOUT ANY WARRANTY; without even the implied
30
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
31
-- PURPOSE. See the GNU Lesser General Public License for more
32
-- details.
33
--
34
-- You should have received a copy of the GNU Lesser General
35
-- Public License along with this source; if not, download it
36
-- from http://www.gnu.org/licenses/lgpl.txt
37
--
38
--------------------------------------------------------------------
39
--
40
-- Comments are formatted for doxygen
41
--
42
 
43
library ieee;                                   --! IEEE Library
44
use ieee.std_logic_1164.all;                    --! IEEE 1164
45
 
46
--
47
--! NEXYS2 Debounce Timer Entity
48
--
49
 
50
entity eNEXYS2_DEBOUNCE is port (
51
    clk   : in  std_logic;                      --! Clock
52
    rst   : in  std_logic;                      --! Reset
53
    clken : in  std_logic;                      --! Clock Enable
54
    di    : in  std_logic;                      --! Input
55
    do    : out std_logic                       --! Output
56
);
57
end eNEXYS2_DEBOUNCE;
58
 
59
--
60
--! NEXYS2 Debounce Timer RTL
61
--
62
 
63
architecture rtl of eNEXYS2_DEBOUNCE is
64
 
65
    signal   last  : std_logic;                 --! Last input
66
    signal   count : integer range 0 to 833;    --! Debounce Counter
67
    constant ms10  : integer := 833;            --! 10 milliseconds (clken=12us)
68
 
69
begin
70
    --
71
    --! This process implements a Debounce Timer.
72
    --
73
 
74
    DEBOUNCE_TIMER : process(clk, rst, di)
75
    begin
76
        if rst = '1' then
77
            do    <= di;
78
            last  <= di;
79
            count <= 0;
80
        elsif rising_edge(clk) then
81
            if clken = '1' then
82
                if di = last then
83
                    if count = 0 then
84
                        do <= di;
85
                    else
86
                        count <= count - 1;
87
                    end if;
88
                else
89
                    last  <= di;
90
                    count <= ms10;
91
                end if;
92
            end if;
93
        end if;
94
    end process DEBOUNCE_TIMER;
95
 
96
end rtl;

powered by: WebSVN 2.1.0

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