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

Subversion Repositories uart_fpga_slow_control_migrated

[/] [uart_fpga_slow_control/] [trunk/] [code/] [library/] [gh_edge_det_XCD.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 aborga
-----------------------------------------------------------------------------
2
--      Filename:       gh_edge_det_XCD.vhd
3
--
4
--      Description:
5
--              an edge detector, for crossing clock domains - 
6
--                 finds the rising edge and falling edge for a pulse crossing clock domains
7
--
8
--      Copyright (c) 2006, 2008 by George Huber 
9
--              an OpenCores.org Project
10
--              free to use, but see documentation for conditions  
11
--
12
--      Revision        History:
13
--      Revision        Date            Author          Comment
14
--      --------        ----------      --------        -----------
15
--      1.0             09/16/06        S A Dodd        Initial revision
16
--      2.0             04/12/08        hlefevre        mod to double register between clocks
17
--                                                         output time remains the same
18
--
19
-----------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.all;
22
 
23
entity gh_edge_det_XCD is
24
        port(
25
                iclk : in STD_LOGIC;  -- clock for input data signal
26
                oclk : in STD_LOGIC;  -- clock for output data pulse
27
                rst  : in STD_LOGIC;
28
                D    : in STD_LOGIC;
29
                re   : out STD_LOGIC; -- rising edge 
30
                fe   : out STD_LOGIC  -- falling edge 
31
                );
32
end entity;
33
 
34
 
35
architecture a of gh_edge_det_XCD is
36
 
37
        signal iQ  : std_logic;
38
        signal jkR, jkF : std_logic;
39
        signal irQ0, rQ0, rQ1 : std_logic;
40
        signal ifQ0, fQ0, fQ1 : std_logic;
41
 
42
begin
43
 
44
process(iclk,rst)
45
begin
46
        if (rst = '1') then
47
                iQ <= '0';
48
                jkR <= '0';
49
                jkF <= '0';
50
        elsif (rising_edge(iclk)) then
51
                iQ <= D;
52
                if ((D = '1') and (iQ = '0')) then
53
                        jkR <= '1';
54
                elsif (rQ1 = '1') then
55
                        jkR <= '0';
56
                else
57
                        jkR <= jkR;
58
                end if;
59
                if ((D = '0') and (iQ = '1')) then
60
                        jkF <= '1';
61
                elsif (fQ1 = '1') then
62
                        jkF <= '0';
63
                else
64
                        jkF <= jkF;
65
                end if;
66
        end if;
67
end process;
68
 
69
        re <= (not rQ1) and rQ0;
70
        fe <= (not fQ1) and fQ0;
71
 
72
process(oclk,rst)
73
begin
74
        if (rst = '1') then
75
                irQ0 <= '0';
76
                rQ0 <= '0';
77
                rQ1 <= '0';
78
                ---------------
79
                ifQ0 <= '0';
80
                fQ0 <= '0';
81
                fQ1 <= '0';
82
        elsif (rising_edge(oclk)) then
83
                irQ0 <= jkR;
84
                rQ0 <= irQ0;
85
                rQ1 <= rQ0;
86
                ---------------
87
                ifQ0 <= jkF;
88
                fQ0 <= ifQ0;
89
                fQ1 <= fQ0;
90
        end if;
91
end process;
92
 
93
 
94
end a;

powered by: WebSVN 2.1.0

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