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

Subversion Repositories common_components

[/] [common_components/] [trunk/] [common_async.vhd] - Diff between revs 3 and 4

Only display areas with differences | Details | Blame | View Log

Rev 3 Rev 4
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
--
--
-- Copyright (C) 2009
-- Copyright 2020
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
--
--
-- This program is free software: you can redistribute it and/or modify
-- Licensed under the Apache License, Version 2.0 (the "License");
-- it under the terms of the GNU General Public License as published by
-- you may not use this file except in compliance with the License.
-- the Free Software Foundation, either version 3 of the License, or
-- You may obtain a copy of the License at
-- (at your option) any later version.
 
--
--
-- This program is distributed in the hope that it will be useful,
--     http://www.apache.org/licenses/LICENSE-2.0
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
 
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
-- GNU General Public License for more details.
 
--
--
-- You should have received a copy of the GNU General Public License
-- Unless required by applicable law or agreed to in writing, software
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
-- distributed under the License is distributed on an "AS IS" BASIS,
 
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
-- See the License for the specific language governing permissions and
 
-- limitations under the License.
--
--
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
 
 
-- Purpose: Clock an asynchronous din into the clk clock domain
-- Purpose: Clock an asynchronous din into the clk clock domain
-- Description:
-- Description:
--   The delay line combats the potential meta-stability of clocked in data.
--   The delay line combats the potential meta-stability of clocked in data.
 
 
LIBRARY IEEE, common_pkg_lib;
LIBRARY IEEE, common_pkg_lib;
USE IEEE.std_logic_1164.ALL;
USE IEEE.std_logic_1164.ALL;
USE common_pkg_lib.common_pkg.ALL;
USE common_pkg_lib.common_pkg.ALL;
 
 
ENTITY common_async IS
ENTITY common_async IS
  GENERIC (
  GENERIC (
    g_rising_edge : BOOLEAN := TRUE;
    g_rising_edge : BOOLEAN := TRUE;
    g_rst_level   : STD_LOGIC := '0';
    g_rst_level   : STD_LOGIC := '0';
    g_delay_len   : POSITIVE := c_meta_delay_len   -- use common_pipeline if g_delay_len=0 for wires only is also needed
    g_delay_len   : POSITIVE := c_meta_delay_len   -- use common_pipeline if g_delay_len=0 for wires only is also needed
  );
  );
  PORT (
  PORT (
    rst  : IN  STD_LOGIC := '0';
    rst  : IN  STD_LOGIC := '0';
    clk  : IN  STD_LOGIC;
    clk  : IN  STD_LOGIC;
    din  : IN  STD_LOGIC;
    din  : IN  STD_LOGIC;
    dout : OUT STD_LOGIC
    dout : OUT STD_LOGIC
  );
  );
END;
END;
 
 
 
 
ARCHITECTURE rtl OF common_async IS
ARCHITECTURE rtl OF common_async IS
 
 
  SIGNAL din_meta : STD_LOGIC_VECTOR(0 TO g_delay_len-1) := (OTHERS=>g_rst_level);
  SIGNAL din_meta : STD_LOGIC_VECTOR(0 TO g_delay_len-1) := (OTHERS=>g_rst_level);
 
 
  -- Synthesis constraint to ensure that register is kept in this instance region
  -- Synthesis constraint to ensure that register is kept in this instance region
  attribute preserve : boolean;
  attribute preserve : boolean;
  attribute preserve of din_meta : signal is true;
  attribute preserve of din_meta : signal is true;
 
 
BEGIN
BEGIN
 
 
  p_clk : PROCESS (rst, clk)
  p_clk : PROCESS (rst, clk)
  BEGIN
  BEGIN
    IF g_rising_edge=TRUE THEN
    IF g_rising_edge=TRUE THEN
      -- Default use rising edge
      -- Default use rising edge
      IF rst='1' THEN
      IF rst='1' THEN
        din_meta <= (OTHERS=>g_rst_level);
        din_meta <= (OTHERS=>g_rst_level);
      ELSIF rising_edge(clk) THEN
      ELSIF rising_edge(clk) THEN
        din_meta <= din & din_meta(0 TO din_meta'HIGH-1);
        din_meta <= din & din_meta(0 TO din_meta'HIGH-1);
      END IF;
      END IF;
    ELSE
    ELSE
      -- also support using falling edge
      -- also support using falling edge
      IF rst='1' THEN
      IF rst='1' THEN
        din_meta <= (OTHERS=>g_rst_level);
        din_meta <= (OTHERS=>g_rst_level);
      ELSIF falling_edge(clk) THEN
      ELSIF falling_edge(clk) THEN
        din_meta <= din & din_meta(0 TO din_meta'HIGH-1);
        din_meta <= din & din_meta(0 TO din_meta'HIGH-1);
      END IF;
      END IF;
    END IF;
    END IF;
  END PROCESS;
  END PROCESS;
 
 
  dout <= din_meta(din_meta'HIGH);
  dout <= din_meta(din_meta'HIGH);
 
 
END rtl;
END rtl;
 
 

powered by: WebSVN 2.1.0

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