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

Subversion Repositories common_components

[/] [common_components/] [trunk/] [common_async.vhd] - Blame information for rev 3

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

Line No. Rev Author Line
1 3 danv
-------------------------------------------------------------------------------
2
--
3
-- Copyright (C) 2009
4
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
5
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
6
--
7
-- This program is free software: you can redistribute it and/or modify
8
-- it under the terms of the GNU General Public License as published by
9
-- the Free Software Foundation, either version 3 of the License, or
10
-- (at your option) any later version.
11
--
12
-- This program is distributed in the hope that it will be useful,
13
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
14
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
-- GNU General Public License for more details.
16
--
17
-- You should have received a copy of the GNU General Public License
18
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
--
20
-------------------------------------------------------------------------------
21
 
22
-- Purpose: Clock an asynchronous din into the clk clock domain
23
-- Description:
24
--   The delay line combats the potential meta-stability of clocked in data.
25
 
26
LIBRARY IEEE, common_pkg_lib;
27
USE IEEE.std_logic_1164.ALL;
28
USE common_pkg_lib.common_pkg.ALL;
29
 
30
ENTITY common_async IS
31
  GENERIC (
32
    g_rising_edge : BOOLEAN := TRUE;
33
    g_rst_level   : STD_LOGIC := '0';
34
    g_delay_len   : POSITIVE := c_meta_delay_len   -- use common_pipeline if g_delay_len=0 for wires only is also needed
35
  );
36
  PORT (
37
    rst  : IN  STD_LOGIC := '0';
38
    clk  : IN  STD_LOGIC;
39
    din  : IN  STD_LOGIC;
40
    dout : OUT STD_LOGIC
41
  );
42
END;
43
 
44
 
45
ARCHITECTURE rtl OF common_async IS
46
 
47
  SIGNAL din_meta : STD_LOGIC_VECTOR(0 TO g_delay_len-1) := (OTHERS=>g_rst_level);
48
 
49
  -- Synthesis constraint to ensure that register is kept in this instance region
50
  attribute preserve : boolean;
51
  attribute preserve of din_meta : signal is true;
52
 
53
BEGIN
54
 
55
  p_clk : PROCESS (rst, clk)
56
  BEGIN
57
    IF g_rising_edge=TRUE THEN
58
      -- Default use rising edge
59
      IF rst='1' THEN
60
        din_meta <= (OTHERS=>g_rst_level);
61
      ELSIF rising_edge(clk) THEN
62
        din_meta <= din & din_meta(0 TO din_meta'HIGH-1);
63
      END IF;
64
    ELSE
65
      -- also support using falling edge
66
      IF rst='1' THEN
67
        din_meta <= (OTHERS=>g_rst_level);
68
      ELSIF falling_edge(clk) THEN
69
        din_meta <= din & din_meta(0 TO din_meta'HIGH-1);
70
      END IF;
71
    END IF;
72
  END PROCESS;
73
 
74
  dout <= din_meta(din_meta'HIGH);
75
 
76
END rtl;

powered by: WebSVN 2.1.0

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