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 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 danv
-------------------------------------------------------------------------------
2
--
3 4 danv
-- Copyright 2020
4 3 danv
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
5
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
6 4 danv
-- 
7
-- Licensed under the Apache License, Version 2.0 (the "License");
8
-- you may not use this file except in compliance with the License.
9
-- You may obtain a copy of the License at
10
-- 
11
--     http://www.apache.org/licenses/LICENSE-2.0
12
-- 
13
-- Unless required by applicable law or agreed to in writing, software
14
-- distributed under the License is distributed on an "AS IS" BASIS,
15
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
-- See the License for the specific language governing permissions and
17
-- limitations under the License.
18 3 danv
--
19
-------------------------------------------------------------------------------
20
 
21
-- Purpose: Clock an asynchronous din into the clk clock domain
22
-- Description:
23
--   The delay line combats the potential meta-stability of clocked in data.
24
 
25
LIBRARY IEEE, common_pkg_lib;
26
USE IEEE.std_logic_1164.ALL;
27
USE common_pkg_lib.common_pkg.ALL;
28
 
29
ENTITY common_async IS
30
  GENERIC (
31
    g_rising_edge : BOOLEAN := TRUE;
32
    g_rst_level   : STD_LOGIC := '0';
33
    g_delay_len   : POSITIVE := c_meta_delay_len   -- use common_pipeline if g_delay_len=0 for wires only is also needed
34
  );
35
  PORT (
36
    rst  : IN  STD_LOGIC := '0';
37
    clk  : IN  STD_LOGIC;
38
    din  : IN  STD_LOGIC;
39
    dout : OUT STD_LOGIC
40
  );
41
END;
42
 
43
 
44
ARCHITECTURE rtl OF common_async IS
45
 
46
  SIGNAL din_meta : STD_LOGIC_VECTOR(0 TO g_delay_len-1) := (OTHERS=>g_rst_level);
47
 
48
  -- Synthesis constraint to ensure that register is kept in this instance region
49
  attribute preserve : boolean;
50
  attribute preserve of din_meta : signal is true;
51
 
52
BEGIN
53
 
54
  p_clk : PROCESS (rst, clk)
55
  BEGIN
56
    IF g_rising_edge=TRUE THEN
57
      -- Default use rising edge
58
      IF rst='1' THEN
59
        din_meta <= (OTHERS=>g_rst_level);
60
      ELSIF rising_edge(clk) THEN
61
        din_meta <= din & din_meta(0 TO din_meta'HIGH-1);
62
      END IF;
63
    ELSE
64
      -- also support using falling edge
65
      IF rst='1' THEN
66
        din_meta <= (OTHERS=>g_rst_level);
67
      ELSIF falling_edge(clk) THEN
68
        din_meta <= din & din_meta(0 TO din_meta'HIGH-1);
69
      END IF;
70
    END IF;
71
  END PROCESS;
72
 
73
  dout <= din_meta(din_meta'HIGH);
74
 
75
END rtl;

powered by: WebSVN 2.1.0

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