1 ------------------------------------------------------------------------------- 2 -- File : GtpPgpWordAligner.vhd 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2012-11-06 5 -- Last update: 2013-07-15 6 ------------------------------------------------------------------------------- 7 -- Description: Pgp2 Gtp Word aligner 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;
23 --! @ingroup xilinx_Virtex5_gtp 40 end entity GtpRxCommaAligner;
44 constant RAW_COMMA_C : (9 downto 0) := "0101111100";
46 type StateType is (SEARCH_S, RESET_S, SLIDE_S, SLIDE_WAIT_0_S, SLIDE_WAIT_1_S, WAIT_SETTLE_S, ALIGNED_S);
48 type RegType is record 51 slideCount : (2 downto 0);
52 waitCounter : (4 downto 0);
61 signal r, rin : RegType;
68 r.state <= SEARCH_S after TPD_G;
69 r.last <= (others => '0') after TPD_G;
70 r.slideCount <= (others => '0') after TPD_G;
71 r.waitCounter <= (others => '0') after TPD_G;
84 variable searchVar : (29 downto 0);
92 v.last := gtpRxData(19 downto 10);
-- Save high byte 98 -- Look for pos or neg comma 99 if (searchVar((i+9) downto i) = RAW_COMMA_C or searchVar(i+9 downto i) = not RAW_COMMA_C) then 100 if (i = 2 or i = 4 or i = 6 or i = 8 or i = 0) then 101 -- v.slideCount := to_unsigned(9-i, 3); 102 -- v.state := SLIDE_S; 104 elsif (i = 12 or i = 14 or i = 16 or i = 18) then 105 v.slideCount := to_unsigned(i-11, 3);
107 -- Not sure if this can be done here. 108 -- Might want some wait time before starting slides 111 v.state := ALIGNED_S;
113 -- else reset the rx and hope for a new lock requiring an even number of slides 122 -- Async reset will eventually get everything back to SEARCH_S state 126 v.state := SLIDE_WAIT_0_S;
128 when SLIDE_WAIT_0_S => 129 v.slideCount := r.slideCount - 1;
130 if (r.slideCount = 0) then 131 v.slideCount := (others => '0');
132 v.state := WAIT_SETTLE_S;
134 v.state := SLIDE_WAIT_1_S;
137 when SLIDE_WAIT_1_S => 140 when WAIT_SETTLE_S => 141 -- All the rxslide assertions take some time 142 v.waitCounter := r.waitCounter + 1;
143 if (r.waitCounter = "11111") then 144 v.state := SEARCH_S;
-- Double check that the slides worked 149 -- Reuse wait counter to count 8b10b errors 150 -- After several errors, reset 152 v.waitCounter := r.waitCounter + 1;
154 if (r.waitCounter = "11111") then 169 end architecture rtl;
in gtpRxDatastd_logic_vector( 19 downto 0)
out gtpRxUsrClk2Selstd_logic
in dispErrstd_logic_vector( 1 downto 0)
out gtpRxCdrResetstd_logic
in gtpRxUsrClk2Rststd_logic
in codeErrstd_logic_vector( 1 downto 0)