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

Subversion Repositories gpib_controller

[/] [gpib_controller/] [trunk/] [vhdl/] [src/] [gpib_helper/] [EdgeDetector.vhd] - Blame information for rev 13

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 Andrewski
--------------------------------------------------------------------------------
2 13 Andrewski
--This file is part of fpga_gpib_controller.
3
--
4
-- Fpga_gpib_controller is free software: you can redistribute it and/or modify
5
-- it under the terms of the GNU General Public License as published by
6
-- the Free Software Foundation, either version 3 of the License, or
7
-- (at your option) any later version.
8
--
9
-- Fpga_gpib_controller is distributed in the hope that it will be useful,
10
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
11
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
-- GNU General Public License for more details.
13
 
14
-- You should have received a copy of the GNU General Public License
15
-- along with Fpga_gpib_controller.  If not, see <http://www.gnu.org/licenses/>.
16
--------------------------------------------------------------------------------
17 3 Andrewski
-- Entity: EdgeDetector
18
-- Date:2011-11-25  
19 13 Andrewski
-- Author: Andrzej Paluch
20 3 Andrewski
--
21
-- Description ${cursor}
22
--------------------------------------------------------------------------------
23
library ieee;
24
use ieee.std_logic_1164.all;
25
use ieee.std_logic_unsigned.all;
26
 
27
use work.helperComponents.all;
28
 
29
entity EdgeDetector is
30
        generic (
31
                RISING : std_logic := '1';
32
                FALLING : std_logic := '0';
33
                PULSE_WIDTH : integer := 10
34
        );
35
 
36
        port (
37
                reset : in std_logic;
38
                clk : in std_logic;
39
                in_data : in std_logic;
40
                pulse : out std_logic
41
        );
42
end EdgeDetector;
43
 
44
architecture arch of EdgeDetector is
45
 
46
        signal t_i, t_o : std_logic;
47
        signal lastData : std_logic;
48
 
49
begin
50
 
51
        process(reset, clk, t_o, in_data) begin
52
                if reset = '1' then
53
                        t_i <= t_o;
54
                        lastData <= in_data;
55
                elsif rising_edge(clk) then
56
                        if lastData /= in_data then
57
                                if RISING='1' and lastData='0' and in_data='1' then
58
                                        t_i <= not t_o;
59
                                end if;
60
 
61
                                if FALLING='1' and lastData='1' and in_data='0' then
62
                                        t_i <= not t_o;
63
                                end if;
64
                        end if;
65
                        lastData <= in_data;
66
                end if;
67
        end process;
68
 
69
        spg: SinglePulseGenerator generic map (WIDTH => PULSE_WIDTH) port map (
70
                reset => reset, clk => clk, t_in => t_i, t_out => t_o, pulse => pulse
71
        );
72
 
73
end arch;
74
 

powered by: WebSVN 2.1.0

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