SURF  1.0
GtpTxPhaseAligner.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : GtpTxPhaseAligner.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2012-11-12
5 -- Last update: 2012-12-06
6 -------------------------------------------------------------------------------
7 -- Description: GTH7 TX phase 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 -------------------------------------------------------------------------------
17 
18 library ieee;
19 use ieee.std_logic_1164.all;
20 use ieee.numeric_std.all;
21 
22 --! @see entity
23  --! @ingroup xilinx_Virtex5_gtp
25 
26  generic (
27  TPD_G : time := 1 ns);
28 
29  port (
30  gtpTxUsrClk2 : in std_logic;
31  gtpReset : in std_logic;
32  gtpPllLockDetect : in std_logic;
33  gtpTxEnPmaPhaseAlign : out std_logic;
34  gtpTxPmaSetPhase : out std_logic;
35  gtpTxAligned : out std_logic);
36 
37 end entity GtpTxPhaseAligner;
38 
39 architecture rtl of GtpTxPhaseAligner is
40 
41  type StateType is (PHASE_ALIGN_S, SET_PHASE_S, ALIGNED_S);
42 
43  type RegType is record
44  state : StateType;
45  counter : unsigned(13 downto 0);
46  gtpTxEnPmaPhaseAlign : std_logic;
47  gtpTxPmaSetPhase : std_logic;
48  end record RegType;
49 
50  signal r, rin : RegType;
51 
52 begin
53 
54  seq : process (gtpTxUsrClk2, gtpReset, gtpPllLockDetect) is
55  begin
56  if (gtpReset = '1' or gtpPllLockDetect = '0') then
57  r.state <= PHASE_ALIGN_S after TPD_G;
58  r.counter <= (others => '0') after TPD_G;
59  r.gtpTxEnPmaPhaseAlign <= '0' after TPD_G;
60  r.gtpTxPmaSetPhase <= '0' after TPD_G;
61  elsif (rising_edge(gtpTxUsrClk2)) then
62  r <= rin after TPD_G;
63  end if;
64  end process seq;
65 
66  comb : process (r) is
67  variable v : RegType;
68  begin
69  v := r;
70 
71  v.gtpTxPmaSetPhase := '0';
72  v.gtpTxEnPmaPhaseAlign := '0';
73  gtpTxAligned <= '0';
74 
75  case r.state is
76  when PHASE_ALIGN_S =>
77  v.gtpTxPmaSetPhase := '0';
78  v.gtpTxEnPmaPhaseAlign := '1';
79  v.counter := r.counter + 1;
80  if (r.counter(9) = '1') then -- Count reached 512
81  v.counter := (others => '0');
82  v.state := SET_PHASE_S;
83  end if;
84 
85  when SET_PHASE_S =>
86  v.gtpTxEnPmaPhaseAlign := '1';
87  v.gtpTxPmaSetPhase := '1';
88  v.counter := r.counter + 1;
89  if (r.counter(13) = '1') then -- Count reached 16384
90  v.state := ALIGNED_S;
91  end if;
92 
93  when ALIGNED_S =>
94  v.gtpTxEnPmaPhaseAlign := '1';
95  v.gtpTxPmaSetPhase := '0';
96  gtpTxAligned <= '1';
97  end case;
98 
99  rin <= v;
100 
103 
104 
105  end process comb;
106 
107 end architecture rtl;
in gtpTxUsrClk2std_logic
out gtpTxEnPmaPhaseAlignstd_logic
out gtpTxPmaSetPhasestd_logic
in gtpPllLockDetectstd_logic
out gtpTxAlignedstd_logic