1 -------------------------------------------------------------------------------     2 -- File       : Gtp7RxFixedLatPhaseAligner.vhd     3 -- Company    : SLAC National Accelerator Laboratory     4 -- Created    : 2012-11-06     5 -- Last update: 2016-12-16     6 -------------------------------------------------------------------------------     8 -- Used in conjunction for a Xilinx 7 Series GTX.     9 -- Given raw 8b10b encoded data presented 2 bytes at a time (20 bits),    10 -- attempts to align any observed comma to the lower byte.    11 -- Assumes GTX comma align is enabled and in PMA mode.    12 -- Comma is configurable through the COMMA_G generic.    13 -- If an odd number of rxSlides is required for alignment, resets the GTX RX    14 -- so that a new CDR lock can be obtained. The GTX in PMA Slide Mode shifts    15 -- the phase of the output clock only every other slide. This module's    16 -- purpose is to obtain an output clock that exactly matches the phase of the    18 -------------------------------------------------------------------------------    19 -- This file is part of 'SLAC Firmware Standard Library'.    20 -- It is subject to the license terms in the LICENSE.txt file found in the     21 -- top-level directory of this distribution and at:     22 --    https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.     23 -- No part of 'SLAC Firmware Standard Library', including this file,     24 -- may be copied, modified, propagated, or distributed except according to     25 -- the terms contained in the LICENSE.txt file.    26 -------------------------------------------------------------------------------    29 use ieee.std_logic_1164.
all;
    30 use ieee.numeric_std.
all;
    35  --! @ingroup xilinx_7Series_gtp7    54 end entity Gtp7RxFixedLatPhaseAligner;
    58    constant SLIDE_WAIT_C :  := 64;
  -- Dictated by UG476 GTX Tranceiver Guide    60    type StateType is (SEARCH_S, RESET_S, SLIDE_S, SLIDE_WAIT_S, ALIGNED_S);
    62    type RegType is record    66       slideWaitCounter     : (bitSize(SLIDE_WAIT_C)-1 downto 0);
    72    constant REG_RESET_C : RegType :=    74        last                 => (others => '0'),    75        slideCount           => (others => '0'),    76        slideWaitCounter     => (others => '0'),    81    signal r, rin : RegType := REG_RESET_C;
    83    signal rxRunPhAlignmentSync : sl;
    87    -- Must use async resets since rxUsrClk can drop out    96          syncRst  => rxRunPhAlignmentSync
);
    99    comb : 
process (r, 
rxData) 
is   100       variable v : RegType;
   112                -- Look for pos or neg comma   118                      v.state := ALIGNED_S;
   119                   elsif (i mod 2 = 0) then   120                      -- Even number of slides needed   121                      -- slideCount set to number of slides needed - 1   122                      v.slideCount := to_unsigned(i-1, bitSize(WORD_SIZE_G));
   125                      -- Reset the rx and hope for a new lock requiring an even number of slides   132             -- Async reset will eventually get everything back to SEARCH_S state   137             v.state   := SLIDE_WAIT_S;
   140             -- Wait SLIDE_WAIT_C clocks between each slide   141             v.slideWaitCounter := r.slideWaitCounter + 1;
   142             if (uAnd(slv(r.slideWaitCounter)) = '1') then   143                if (r.slideCount = 0) then   144                   v.state := SEARCH_S;
  -- Double check that the slides worked   146                   v.slideCount := r.slideCount - 1;
   153             -- Gtx7RxRst module will reset this module back to SEARCH_S if alignment is lost   165    seq : 
process (rxRunPhAlignmentSync, 
rxUsrClk) 
is   168          r <= rin after TPD_G;
   170       if (rxRunPhAlignmentSync = '0') then   171          r <= REG_RESET_C after TPD_G;
   175 end architecture rtl;
 
in rxDataslv(   WORD_SIZE_G- 1 downto  0)  
 
out rxPhaseAlignmentDonesl  
 
COMMA_1_Gslv  :=   "----------1010000011"
 
COMMA_EN_Gslv( 3 downto  0)  :=   "0011"
 
COMMA_3_Gslv  :=   "XXXXXXXXXXXXXXXXXXXX"
 
COMMA_0_Gslv  :=   "----------0101111100"
 
COMMA_2_Gslv  :=   "XXXXXXXXXXXXXXXXXXXX"