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

Subversion Repositories mod_sim_exp

[/] [mod_sim_exp/] [trunk/] [rtl/] [vhdl/] [core/] [pulse_cdc.vhd] - Blame information for rev 94

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 94 JonasDC
----------------------------------------------------------------------  
2
----  pulse_cdc                                                   ---- 
3
----                                                              ---- 
4
----  This file is part of the                                    ----
5
----    Modular Simultaneous Exponentiation Core project          ---- 
6
----    http://www.opencores.org/cores/mod_sim_exp/               ---- 
7
----                                                              ---- 
8
----  Description                                                 ---- 
9
----    transfers a pulse (1clk wide) from clock domain A to      ----
10
----    clock domain B by using a toggling signal. This design    ----
11
----    avoids metastable states                                  ----
12
----                                                              ---- 
13
----  Dependencies: none                                          ---- 
14
----                                                              ---- 
15
----  Authors:                                                    ----
16
----      - Geoffrey Ottoy, DraMCo research group                 ----
17
----      - Jonas De Craene, JonasDC@opencores.org                ---- 
18
----                                                              ---- 
19
---------------------------------------------------------------------- 
20
----                                                              ---- 
21
---- Copyright (C) 2011 DraMCo research group and OPENCORES.ORG   ---- 
22
----                                                              ---- 
23
---- This source file may be used and distributed without         ---- 
24
---- restriction provided that this copyright statement is not    ---- 
25
---- removed from the file and that any derivative work contains  ---- 
26
---- the original copyright notice and the associated disclaimer. ---- 
27
----                                                              ---- 
28
---- This source file is free software; you can redistribute it   ---- 
29
---- and/or modify it under the terms of the GNU Lesser General   ---- 
30
---- Public License as published by the Free Software Foundation; ---- 
31
---- either version 2.1 of the License, or (at your option) any   ---- 
32
---- later version.                                               ---- 
33
----                                                              ---- 
34
---- This source is distributed in the hope that it will be       ---- 
35
---- useful, but WITHOUT ANY WARRANTY; without even the implied   ---- 
36
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ---- 
37
---- PURPOSE.  See the GNU Lesser General Public License for more ---- 
38
---- details.                                                     ---- 
39
----                                                              ---- 
40
---- You should have received a copy of the GNU Lesser General    ---- 
41
---- Public License along with this source; if not, download it   ---- 
42
---- from http://www.opencores.org/lgpl.shtml                     ---- 
43
----                                                              ---- 
44
----------------------------------------------------------------------
45
 
46
library ieee;
47
use ieee.std_logic_1164.all;
48
use ieee.std_logic_unsigned.all;
49
 
50
entity pulse_cdc is
51
        port (
52
          reset  : in std_logic;
53
                clkA   : in std_logic;
54
                pulseA : in std_logic;
55
                clkB   : in std_logic;
56
    pulseB : out std_logic
57
        );
58
end pulse_cdc;
59
 
60
 
61
architecture arch of pulse_cdc is
62
  signal pulseA_d : std_logic;
63
  signal toggle : std_logic := '0';
64
  signal toggle_d, toggle_d2, toggle_d3 : std_logic;
65
begin
66
 
67
  -- Convert pulse from clock domain A to a toggling signal
68
  PulseAtoToggle : process (clkA, reset)
69
  begin
70
    if reset='1' then
71
      toggle <= '0';
72
    else
73
      if rising_edge(clkA) then
74
        pulseA_d <= pulseA;
75
        toggle <= toggle xor (pulseA and not pulseA_d);
76
      end if;
77
    end if;
78
  end process;
79
 
80
  -- Convert toggling signal to a pulse of 1clk wide to clock domain B
81
  ToggletoPulseB : process (clkB, reset)
82
  begin
83
    if reset='1' then
84
      toggle_d <= '0';
85
      toggle_d2 <= '0';
86
      toggle_d3 <= '0';
87
    else
88
      if rising_edge(clkB) then
89
        toggle_d <= toggle; -- this signal may have metastability isues
90
        toggle_d2 <= toggle_d; -- stable now
91
        toggle_d3 <= toggle_d2;
92
      end if;
93
    end if;
94
  end process;
95
 
96
  pulseB <= toggle_d2 xor toggle_d3;
97
end arch;

powered by: WebSVN 2.1.0

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