1 ------------------------------------------------------------------------------- 2 -- File : JesdAlignChGen.vhd 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2015-04-15 5 -- Last update: 2016-02-22 6 ------------------------------------------------------------------------------- 7 -- Description: Alignment character generator 8 -- Scrambles incoming data if enabled 9 -- Inverts incoming data if enabled 11 -- Replaces data with F and A characters. 12 -- A(K28.3) - x"7C" - Inserted at the end of a multi-frame. 13 -- F(K28.7) - x"FC" - Inserted at the end of a frame. 15 -- Note: Character replacement mechanism is different weather scrambler is enabled or disabled. 16 -- Disabled: The characters are inserted if two corresponding octets in consecutive samples have the same value. 17 -- Enabled: The characters are inserted it the corresponding octet has the same value as the inserted character. 21 ------------------------------------------------------------------------------- 22 -- This file is part of 'SLAC Firmware Standard Library'. 23 -- It is subject to the license terms in the LICENSE.txt file found in the 24 -- top-level directory of this distribution and at: 25 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. 26 -- No part of 'SLAC Firmware Standard Library', including this file, 27 -- may be copied, modified, propagated, or distributed except according to 28 -- the terms contained in the LICENSE.txt file. 29 ------------------------------------------------------------------------------- 32 use ieee.std_logic_1164.
all;
33 use ieee.std_logic_unsigned.
all;
34 use ieee.std_logic_arith.
all;
37 use work.jesd204bpkg.
all;
40 --! @ingroup protocols_jesd204b 52 -- Enable scrambling/descrambling 58 -- Valid data from Tx FSM 71 end entity JesdAlignChGen;
75 -- How many samples is in a GT word 76 constant SAMPLES_IN_WORD_C : positive := (GT_WORD_SIZE_C/F_G);
79 type RegType is record 89 constant REG_INIT_C : RegType := ( 90 sampleDataReg => (others => '0'), 91 sampleDataInv => (others => '0'), 92 sampleDataD1 => (others => '0'), 93 sampleDataD2 => (others => '0'), 94 sampleKD1 => (others => '0'), 95 lfsr => (others => '0'), 99 signal r : RegType := REG_INIT_C;
100 signal rin : RegType;
108 variable v : RegType;
112 variable v_twoWordBuff : slv((2*GT_WORD_SIZE_C*8)-1 downto 0);
113 variable v_twoCharBuff : slv((2*GT_WORD_SIZE_C) -1 downto 0);
120 -- Invert Data if enabled 121 if (inv_i = '1') then 122 -- Invert sample data 123 v.sampleDataInv := invData(r.sampleDataReg, F_G, GT_WORD_SIZE_C);
125 v.sampleDataInv := r.sampleDataReg;
128 -- Scramble Data if enabled 130 for i in (GT_WORD_SIZE_C*8)-1 downto 0 loop 131 v.sampleDataD1(i) := r.sampleDataInv(i);
132 for j in JESD_PRBS_TAPS_C'range loop 133 v.sampleDataD1(i) := v.sampleDataD1(i) xor v.lfsr(JESD_PRBS_TAPS_C(j)-1);
135 v.lfsr := v.lfsr((GT_WORD_SIZE_C*8)-2 downto 0) & v.sampleDataD1(i);
138 -- Use the data from the input if scrambling disabled 139 v.sampleDataD1 := r.sampleDataInv;
143 -- Buffer data for two clock cycles 144 v.sampleDataD2 := r.sampleDataD1;
146 -- Delay LMFC for 1 c-c 149 -- Combinatorial logic 150 v_twoWordBuff := r.sampleDataD2 & r.sampleDataD1;
151 v_twoCharBuff := r.sampleKD1 & (sampleK_o'range => '0');
155 -- Replace with A character at the end of the multi-frame 156 if r.lmfcD1 = '1' then 158 if (v_twoWordBuff(7 downto 0) = A_CHAR_C) then 159 v_twoCharBuff(0) := '1';
162 if (v_twoWordBuff((F_G*8)+7 downto (F_G*8)) = v_twoWordBuff(7 downto 0)) then 163 v_twoWordBuff(7 downto 0) := A_CHAR_C;
164 v_twoCharBuff(0) := '1';
169 -- Replace with F character 170 for I in (SAMPLES_IN_WORD_C-1) downto 0 loop 172 if (v_twoWordBuff((I*F_G*8)+7 downto (I*F_G*8)) = F_CHAR_C and 173 v_twoCharBuff((I*F_G+F_G)) = '0') 175 v_twoCharBuff(I*F_G) := '1';
178 if (v_twoWordBuff((I*F_G*8)+(F_G*8)+7 downto (I*F_G*8)+(F_G*8)) = v_twoWordBuff((I*F_G*8)+7 downto (I*F_G*8)) and 179 v_twoCharBuff((I*F_G+F_G)) = '0') 181 v_twoWordBuff((I*F_G*8)+7 downto (I*F_G*8)) := F_CHAR_C;
182 v_twoCharBuff(I*F_G) := '1';
192 -- Buffer char for one clock cycle 193 v.sampleKD1 := v_twoCharBuff((GT_WORD_SIZE_C)-1 downto 0);
198 sampleData_o <= byteSwapSlv(v_twoWordBuff((GT_WORD_SIZE_C*8)-1 downto 0), GT_WORD_SIZE_C);
199 sampleK_o <= bitReverse(v_twoCharBuff((GT_WORD_SIZE_C)-1 downto 0));
203 seq :
process (
clk)
is 205 if (rising_edge(clk)) then 206 r <= rin after TPD_G;
209 --------------------------------------- 212 end architecture rtl;
in sampleData_islv( GT_WORD_SIZE_C* 8- 1 downto 0)
out sampleData_oslv( GT_WORD_SIZE_C* 8- 1 downto 0)
out sampleK_oslv( GT_WORD_SIZE_C- 1 downto 0)