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

Subversion Repositories wb_uart

[/] [wb_uart/] [trunk/] [src/] [slib_input_filter.vhd] - Blame information for rev 16

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 15 federico.a
--
2
-- Input filter
3
--
4
-- Author:   Sebastian Witt
5
-- Data:     06.03.2008
6
-- Version:  1.0
7
--
8
-- This code is free software; you can redistribute it and/or
9
-- modify it under the terms of the GNU Lesser General Public
10
-- License as published by the Free Software Foundation; either
11
-- version 2.1 of the License, or (at your option) any later version.
12
--
13
-- This code is distributed in the hope that it will be useful,
14
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
15
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
-- Lesser General Public License for more details.
17
--
18
-- You should have received a copy of the GNU Lesser General Public
19
-- License along with this library; if not, write to the
20
-- Free Software  Foundation, Inc., 59 Temple Place, Suite 330,
21
-- Boston, MA  02111-1307  USA
22
--
23
 
24
LIBRARY IEEE;
25
USE IEEE.std_logic_1164.all;
26
USE IEEE.numeric_std.all;
27
 
28
entity slib_input_filter is
29
    generic (
30
        SIZE        : natural := 4      -- Filter counter size
31
    );
32
    port (
33
        CLK         : in std_logic;     -- Clock
34
        RST         : in std_logic;     -- Reset
35
        CE          : in std_logic;     -- Clock enable
36
        D           : in std_logic;     -- Signal input
37
        Q           : out std_logic     -- Signal output
38
    );
39
end slib_input_filter;
40
 
41
architecture rtl of slib_input_filter is
42
    signal iCount : integer range 0 to SIZE;
43
begin
44
    IF_D: process (RST, CLK)
45
    begin
46
        if (RST  = '1') then
47
            iCount <= 0;
48
            Q      <= '0';
49
        elsif (CLK'event and CLK='1') then
50
            -- Input counter
51
            if (CE = '1' ) then
52
                if (D = '1' and iCount /= SIZE) then
53
                    iCount <= iCount + 1;
54
                elsif (D = '0' and iCount /= 0) then
55
                    iCount <= iCount - 1;
56
                end if;
57
            end if;
58
 
59
            -- Output
60
            if (iCount = SIZE) then
61
                Q <= '1';
62
            elsif (iCount = 0) then
63
                Q <= '0';
64
            end if;
65
        end if;
66
    end process;
67
 
68
end rtl;
69
 

powered by: WebSVN 2.1.0

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