SURF  1.0
SynchronizerOneShotCntVector.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : SynchronizerOneShotCntVector.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2014-04-11
5 -- Last update: 2014-05-27
6 -------------------------------------------------------------------------------
7 -- Description: Wrapper for multiple SynchronizerOneShotCnt modules
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 -------------------------------------------------------------------------------
17 
18 library ieee;
19 use ieee.std_logic_1164.all;
20 
21 use work.StdRtlPkg.all;
22 
23 --! @see entity
24  --! @ingroup base_sync
26  generic (
27  TPD_G : time := 1 ns; -- Simulation FF output delay
28  RST_POLARITY_G : sl := '1'; -- '1' for active HIGH reset, '0' for active LOW reset
29  RST_ASYNC_G : boolean := false; -- true if reset is asynchronous, false if reset is synchronous
30  COMMON_CLK_G : boolean := false; -- True if wrClk and rdClk are the same clock
31  RELEASE_DELAY_G : positive := 3; -- Delay between deassertion of async and sync resets
32  IN_POLARITY_G : slv := "1"; -- 0 for active LOW, 1 for active HIGH (dataIn port)
33  OUT_POLARITY_G : slv := "1"; -- 0 for active LOW, 1 for active HIGH (dataOut port)
34  USE_DSP48_G : string := "no"; -- "no" for no DSP48 implementation, "yes" to use DSP48 slices
35  SYNTH_CNT_G : slv := "1"; -- Set to 1 for synthesising counter RTL, '0' to not synthesis the counter
36  CNT_RST_EDGE_G : boolean := true; -- true if counter reset should be edge detected, else level detected
37  CNT_WIDTH_G : positive := 16;
38  WIDTH_G : positive := 16);
39  port (
40  -- Write Ports (wrClk domain)
41  dataIn : in slv(WIDTH_G-1 downto 0); -- Data to be 'synced'
42  -- Read Ports (rdClk domain)
43  rollOverEn : in slv(WIDTH_G-1 downto 0); -- '1' allows roll over of the counter
44  cntRst : in sl := not RST_POLARITY_G; -- Optional counter reset
45  dataOut : out slv(WIDTH_G-1 downto 0); -- Synced data
46  cntOut : out SlVectorArray(WIDTH_G-1 downto 0, CNT_WIDTH_G-1 downto 0); -- Synced counter
47  -- Clocks and Reset Ports
48  wrClk : in sl;
49  wrRst : in sl := not RST_POLARITY_G;
50  rdClk : in sl; -- clock to be SYNC'd to
51  rdRst : in sl := not RST_POLARITY_G);
52 end SynchronizerOneShotCntVector;
53 
54 architecture mapping of SynchronizerOneShotCntVector is
55 
56  function fillVectorArray (INPUT : slv) return slv is
57  begin
58  return ite(INPUT = "1", slvOne(WIDTH_G),
59  ite(INPUT = "0", slvZero(WIDTH_G),
60  INPUT));
61  end function fillVectorArray;
62 
63  constant IN_POLARITY_C : slv(WIDTH_G-1 downto 0) := fillVectorArray(IN_POLARITY_G);
64  constant OUT_POLARITY_C : slv(WIDTH_G-1 downto 0) := fillVectorArray(OUT_POLARITY_G);
65  constant SYNTH_CNT_C : slv(WIDTH_G-1 downto 0) := fillVectorArray(SYNTH_CNT_G);
66 
67  type MySlvArray is array (WIDTH_G-1 downto 0) of slv(CNT_WIDTH_G-1 downto 0);
68  signal cnt : MySlvArray;
69 
70 begin
71 
72  GEN_VEC :
73  for i in (WIDTH_G-1) downto 0 generate
74 
75  SyncOneShotCnt_Inst : entity work.SynchronizerOneShotCnt
76  generic map (
77  TPD_G => TPD_G,
88  port map (
89  -- Write Ports (wrClk domain)
90  dataIn => dataIn(i),
91  -- Read Ports (rdClk domain)
92  rollOverEn => rollOverEn(i),
93  cntRst => cntRst,
94  dataOut => dataOut(i),
95  cntOut => cnt(i),
96  -- Clocks and Reset Ports
97  wrClk => wrClk,
98  wrRst => wrRst,
99  rdClk => rdClk,
100  rdRst => rdRst);
101 
102  GEN_MAP :
103  for j in (CNT_WIDTH_G-1) downto 0 generate
104  cntOut(i, j) <= cnt(i)(j);
105  end generate GEN_MAP;
106 
107  end generate GEN_VEC;
108 
109 end architecture mapping;
( WIDTH_G- 1 downto 0) slv( CNT_WIDTH_G- 1 downto 0) MySlvArray
slv( WIDTH_G- 1 downto 0) := fillVectorArray(SYNTH_CNT_G ) SYNTH_CNT_C
std_logic sl
Definition: StdRtlPkg.vhd:28
array(natural range <> ,natural range <> ) of sl SlVectorArray
Definition: StdRtlPkg.vhd:669
in rollOverEnslv( WIDTH_G- 1 downto 0)
out cntOutslv( CNT_WIDTH_G- 1 downto 0)
in dataInslv( WIDTH_G- 1 downto 0)
slv( WIDTH_G- 1 downto 0) := fillVectorArray(IN_POLARITY_G ) IN_POLARITY_C
in wrRstsl :=not RST_POLARITY_G
in cntRstsl :=not RST_POLARITY_G
slv( WIDTH_G- 1 downto 0) := fillVectorArray(OUT_POLARITY_G ) OUT_POLARITY_C
in rdRstsl :=not RST_POLARITY_G
out dataOutslv( WIDTH_G- 1 downto 0)
out cntOutSlVectorArray ( WIDTH_G- 1 downto 0, CNT_WIDTH_G- 1 downto 0)
std_logic_vector slv
Definition: StdRtlPkg.vhd:29