1 ------------------------------------------------------------------------------- 2 -- File : SyncStatusVector.vhd 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2014-04-11 5 -- Last update: 2014-06-02 6 ------------------------------------------------------------------------------- 7 -- Description: General Purpose Status Vector and Status Counter module 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_unsigned.
all;
21 use ieee.std_logic_arith.
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 : slv := "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 40 WIDTH_G : positive := 16);
-- Status vector width 42 --------------------------------------------- 43 -- Input Status bit Signals (wrClk domain) 44 --------------------------------------------- 46 --------------------------------------------- 47 -- Output Status bit Signals (rdClk domain) 48 --------------------------------------------- 50 --------------------------------------------- 51 -- Status Bit Counters Signals (rdClk domain) 52 --------------------------------------------- 54 -- This input is the common resets all the counters 57 -- This input is counter roll over enable vector. 58 -- Each element of the vector corresponds to its respective counter. 59 -- For example: rollOverEnIn(0) is statusIn(0)'s counter roll over enable bit 60 -- rollOverEnIn(1) is statusIn(1)'s counter roll over enable bit 61 -- rollOverEnIn(2) is statusIn(2)'s counter roll over enable bit 65 -- This output is counter value vector array. 66 -- The remapping of cntOut to a SLV array (outside of this module) is has followed: 68 -- for i in WIDTH_G-1 to 0 loop 69 -- for j in CNT_WIDTH_G-1 to 0 loop 70 -- MySlvArray(i)(j) <= cntOut(i, j); 75 --------------------------------------------- 76 -- Interrupt Signals (rdClk domain) 77 --------------------------------------------- 79 -- This input is counter roll over enable vector. 80 -- Each element of the vector corresponds to its respective status bit. 81 -- For example: irqEnIn(0) is statusIn(0)'s enable interrupt bit 82 -- irqEnIn(1) is statusIn(1)'s enable interrupt bit 83 -- irqEnIn(2) is statusIn(2)'s enable interrupt bit 87 -- This output is interrupt output signal. 89 --------------------------------------------- 90 -- Clocks and Reset Ports 91 --------------------------------------------- 100 type RegType is record 105 constant REG_INIT_C : RegType := ( 109 signal r : RegType := REG_INIT_C;
110 signal rin : RegType;
112 signal statusStrobe : slv(WIDTH_G-1 downto 0);
142 -- Write Ports (wrClk domain) 144 -- Read Ports (rdClk domain) 149 -- Clocks and Reset Ports 157 variable v : RegType;
162 -- Refresh the mask check 165 v.hitVector(i) := statusStrobe(i);
169 -- Check the hitVector vector for a new interrupt 170 if uOr(r.hitVector) = '1' then 179 -- Register the variable for next clock cycle 189 if rising_edge(rdClk) then 190 r <= rin after TPD_G;
194 r <= REG_INIT_C after TPD_G;
CNT_RST_EDGE_Gboolean := true
in cntRstsl :=not RST_POLARITY_G
COMMON_CLK_Gboolean := false
BYPASS_SYNC_Gboolean := false
array(natural range <> ,natural range <> ) of sl SlVectorArray
in rollOverEnslv( WIDTH_G- 1 downto 0)
CNT_WIDTH_Gpositive := 16
USE_DSP48_Gstring := "no"
RST_ASYNC_Gboolean := false
COMMON_CLK_Gboolean := false
in dataInslv( WIDTH_G- 1 downto 0)
out cntOutSlVectorArray ( WIDTH_G- 1 downto 0, CNT_WIDTH_G- 1 downto 0)
USE_DSP48_Gstring := "no"
in dataInslv( WIDTH_G- 1 downto 0)
RELEASE_DELAY_Gpositive := 3
CNT_WIDTH_Gpositive := 32
in rollOverEnInslv( WIDTH_G- 1 downto 0) :=( others => '0')
in irqEnInslv( WIDTH_G- 1 downto 0) :=( others => '0')
in rdRstsl :=not RST_POLARITY_G
RST_ASYNC_Gboolean := false
out dataOutslv( WIDTH_G- 1 downto 0)
in wrRstsl :=not RST_POLARITY_G
CNT_RST_EDGE_Gboolean := true
out statusOutslv( WIDTH_G- 1 downto 0)
RELEASE_DELAY_Gpositive := 3
out dataOutslv( WIDTH_G- 1 downto 0)
out cntOutSlVectorArray ( WIDTH_G- 1 downto 0, CNT_WIDTH_G- 1 downto 0)
in statusInslv( WIDTH_G- 1 downto 0)