1 ------------------------------------------------------------------------------- 2 -- File : GlinkDecoder.vhd 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2012-03-12 5 -- Last update: 2014-10-24 6 ------------------------------------------------------------------------------- 7 -- Description: A collection of common constants and functions intended for 8 -- use encoding/decoding the GLink Protocol. 9 ------------------------------------------------------------------------------- 10 -- This file is part of 'SLAC Firmware Standard Library'. 11 -- It is subject to the license terms in the LICENSE.txt file found in the 12 -- top-level directory of this distribution and at: 13 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. 14 -- No part of 'SLAC Firmware Standard Library', including this file, 15 -- may be copied, modified, propagated, or distributed except according to 16 -- the terms contained in the LICENSE.txt file. 17 ------------------------------------------------------------------------------- 20 use ieee.std_logic_1164.
all;
27 --! @ingroup protocols_glink_core 42 data => (others => '0'), 48 data => (others => '0'), 59 -- Link Status Signals 72 data => (others => '0'), 73 -- Link Status Signals 81 -- Valid C Field values 89 -- Array of valid C Fields 100 -- Valid idle (fill) words 105 -- Array of valid idle words 113 -- GLink Word structure 114 -- Contains 16 bit W-Field (data) and 4 bit C-Field (control) 118 c : slv(3 downto 0);
-- C-Field 121 -- Array of GLink words (I really hate that VHDL makes you do this) 124 -- Functions for working with GLinkWordType 136 end package GLinkPkg;
141 variable retVar :
slv(19 downto 0) :=
(others => '
0'
);
143 retVar
(19) := vec.
idle;
145 retVar
(17) := vec.
flag;
147 retVar
(15 downto 0) := vec.
data(15 downto 0);
154 retVar.
idle := vec
(19);
156 retVar.
flag := vec
(17);
158 retVar.
data(15 downto 0) := vec
(15 downto 0);
163 variable retVar :
slv(23 downto 0) :=
(others => '
0'
);
168 retVar
(20) := vec.
flag;
169 retVar
(19) := vec.
error;
173 retVar
(15 downto 0) := vec.
data(15 downto 0);
183 retVar.
flag := vec
(20);
184 retVar.
error := vec
(19);
188 retVar.
data(15 downto 0) := vec
(15 downto 0);
198 retVar.
w :=
data(19 downto 4);
199 retVar.
c :=
data(3 downto 0);
207 variable retVar :
slv(19 downto 0);
209 retVar
(19 downto 4) := word.
w;
210 retVar
(3 downto 0) := word.
c;
214 ----------------------------------------------------------------------------- 215 -- Test if a word is valid. 216 -- Detectable error states listed on page 23 of HDMP-1032A/1034A Data Sheet 217 ----------------------------------------------------------------------------- 222 variable validVar : := true;
224 if (std_match
(word.
c,
"-00-") or 225 std_match
(word.
c,
"-11-") or 226 std_match
(word.
c,
"0101") or 227 std_match
(word.
c,
"1010")) then 229 elsif word.
c =
"1100" then --check for invalid Filled frames 230 if (std_match
(word.
w,
"-------0--------") or 231 std_match
(word.
w,
"-------11-------")) then 236 end function isValidWord;
239 -- we might want to add a 01/10 check in the isControlWord function, 240 -- instead on relying on the isValidWord function (LLR - 26FEB2014) function isControlWord (
244 variable retVar : := false;
250 end function isControlWord;
256 variable retVar : := false;
272 variable retVar : := false;
281 end function isDataWord;
287 variable retVar : := false;
295 end function isInvertedWord;
301 variable retVar :
slv(15 downto 0);
303 retVar
(6 downto 0) := bitReverse
(word.
w(0 to 6));
304 retVar
(13 downto 7) := bitReverse
(word.
w(9 to 15));
305 retVar
(15 downto 14) := word.
w(7 to 8);
-- actually don't care 314 return bitReverse
(word.
w);
330 end package body GLinkPkg;
array(natural range <> ) of GLinkTxType GLinkTxArray
slv( 0 to 15) := X"FF00" GLINK_IDLE_WORD_FF0_C
array(natural range <> ) of GLinkWordType GLinkWordArray
array(natural range <> ,natural range <> ) of GLinkRxType GLinkRxVectorArray
GLinkTxType toGLinkTxvec,
GLinkSlv16Array( 0 to 2) :=( GLINK_IDLE_WORD_FF0_C, GLINK_IDLE_WORD_FF1L_C, GLINK_IDLE_WORD_FF1H_C) GLINK_VALID_IDLE_WORDS_C
array(natural range <> ,natural range <> ) of GLinkTxType GLinkTxVectorArray
GLinkRxType toGLinkRxvec,
slv( 0 to 15) := X"FF80" GLINK_IDLE_WORD_FF1H_C
array(natural range <> ) of GLinkRxType GLinkRxArray
slv( 3 downto 0) := "1011" GLINK_DATA_WORD_FLAG_HIGH_C
array(natural range <> ) of slv( 0 to 15) GLinkSlv16Array
array(natural range <> ) of slv( 3 downto 0) GLinkSlv4Array
slv( 3 downto 0) := "1101" GLINK_DATA_WORD_FLAG_LOW_C
slv getControlPayloadword,
GLinkRxType :=(isIdle => '1',isData => '0',isControl => '0',flag => '0',data =>( others => '0'),error => '0',rxReady => '0',txReady => '0',linkUp => '0') GLINK_RX_INIT_C
GLinkTxType :=(idle => '1',control => '0',flag => '0',data =>( others => '0'),linkRst => '1') GLINK_TX_INIT_C
slv( 3 downto 0) := "0100" GLINK_DATA_WORD_INV_FLAG_HIGH_C
slv( 0 to 15) := X"FE00" GLINK_IDLE_WORD_FF1L_C
boolean isInvertedWordword,
slv( 3 downto 0) := "0011" GLINK_CONTROL_WORD_C
slv( 3 downto 0) := "1100" GLINK_CONTROL_WORD_INV_C
GLinkSlv4Array( 0 to 5) :=( GLINK_CONTROL_WORD_C, GLINK_CONTROL_WORD_INV_C, GLINK_DATA_WORD_FLAG_LOW_C, GLINK_DATA_WORD_INV_FLAG_LOW_C, GLINK_DATA_WORD_FLAG_HIGH_C, GLINK_DATA_WORD_INV_FLAG_HIGH_C) GLINK_VALID_C_FIELDS_C
GLinkWordType toGLinkWorddata,
boolean isControlWordword,
GLinkTxType :=(idle => '1',control => '0',flag => '0',data =>( others => '0'),linkRst => '0') GLINK_TX_UNUSED_C
slv( 3 downto 0) := "0010" GLINK_DATA_WORD_INV_FLAG_LOW_C