1 -------------------------------------------------------------------------------     2 -- File       : SynchronizerOneShotCnt.vhd     3 -- Company    : SLAC National Accelerator Laboratory     4 -- Created    : 2014-04-11     5 -- Last update: 2014-04-14     6 -------------------------------------------------------------------------------     7 -- Description: Wrapper for SynchronizerOneShot with counter output     8 -------------------------------------------------------------------------------     9 -- This file is part of 'SLAC Firmware Standard Library'.    10 -- It is subject to the license terms in the LICENSE.txt file found in the     11 -- top-level directory of this distribution and at:     12 --    https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.     13 -- No part of 'SLAC Firmware Standard Library', including this file,     14 -- may be copied, modified, propagated, or distributed except according to     15 -- the terms contained in the LICENSE.txt file.    16 -------------------------------------------------------------------------------    19 use ieee.std_logic_1164.
all;
    20 use ieee.std_logic_arith.
all;
    21 use ieee.std_logic_unsigned.
all;
    26  --! @ingroup base_sync    29       TPD_G           :      := 1 ns;
 -- Simulation FF output delay    31       RST_ASYNC_G     :   := false;
-- true if reset is asynchronous, false if reset is synchronous    32       COMMON_CLK_G    :   := false;
-- True if wrClk and rdClk are the same clock    33       RELEASE_DELAY_G : positive := 3;
    -- Delay between deassertion of async and sync resets    36       USE_DSP48_G     :    := "no";
 -- "no" for no DSP48 implementation, "yes" to use DSP48 slices    37       SYNTH_CNT_G     : sl       := '1';
  -- Set to 1 for synthesising counter RTL, '0' to not synthesis the counter    38       CNT_RST_EDGE_G  :   := true;
 -- true if counter reset should be edge detected, else level detected    41       -- Write Ports (wrClk domain)        43       -- Read Ports (rdClk domain)        48       -- Clocks and Reset Ports    55 end SynchronizerOneShotCnt;
    59    constant MAX_CNT_C : slv(CNT_WIDTH_G-1 downto 0) := (others => '1');
    61    type RegType is record    65    constant REG_INIT_C : RegType := (    68    signal r   : RegType := REG_INIT_C;
    76    attribute use_dsp48      : ;
   149       cntOut <= (others => '0');
   155       comb : 
process (cntRstSync, 
dataIn, r, rollOverEnSync, 
wrRst) 
is   156          variable v : RegType;
   158          -- Latch the current value   161          -- Keep a record of the last syncData   166             -- Check for a rising edge   167             if (dataIn = '1') and (r.dataInDly = '0') then   168                -- Check for counter roll over   169                if (rollOverEnSync = '1') or (r.cntOut /= MAX_CNT_C) then   170                   -- Increment the counter   176             -- Check for a falling edge   177             if (dataIn = '0') and (r.dataInDly = '1') then   178                -- Check for counter roll over   179                if (rollOverEnSync = '1') or (r.cntOut /= MAX_CNT_C) then   180                   -- Increment the counter   186          -- Check for a counter reset   188             v.cntOut := (others => '0');
   193             v.cntOut      := (others => '0');
   194             v.dataInDly   := dataIn;
  -- prevent accidental edge detection   197          -- Register the variable for next clock cycle   207          if rising_edge(wrClk) then   208             r <= rin after TPD_G;
   212             r           <= REG_INIT_C after TPD_G;
   213             r.dataInDly <= dataIn     after TPD_G;
  -- prevent accidental edge detection   224             -- Asynchronous Reset   226             --Write Ports (wr_clk domain)   229             --Read Ports (rd_clk domain)   235 end architecture rtl;
 
in rstsl  :=not    RST_POLARITY_G
 
in dinslv(   DATA_WIDTH_G- 1 downto  0)  
 
BYPASS_SYNC_Gboolean  :=   false
 
RELEASE_DELAY_Gpositive  := 3
 
RST_ASYNC_Gboolean  :=   false
 
out doutslv(   DATA_WIDTH_G- 1 downto  0)  
 
CNT_RST_EDGE_Gboolean  :=   true
 
out cntOutslv(   CNT_WIDTH_G- 1 downto  0)  
 
RST_ASYNC_Gboolean  :=   false
 
in rstsl  :=not    RST_POLARITY_G
 
COMMON_CLK_Gboolean  :=   false
 
BYPASS_SYNC_Gboolean  :=   false
 
RELEASE_DELAY_Gpositive  := 3
 
CNT_WIDTH_Gpositive  := 16
 
SYNC_STAGES_Ginteger   range  3 to ( 2** 24):= 3
 
in wrRstsl  :=not    RST_POLARITY_G
 
in cntRstsl  :=not    RST_POLARITY_G
 
COMMON_CLK_Gboolean  :=   false
 
RST_ASYNC_Gboolean  :=   false
 
USE_DSP48_Gstring  :=   "no"
 
in rdRstsl  :=not    RST_POLARITY_G
 
DATA_WIDTH_Ginteger   range  1 to ( 2** 24):= 16