SURF  1.0
Gtp7TxManualPhaseAligner.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : Gtp7TxManualPhaseAligner.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2013-06-29
5 -- Last update: 2013-12-05
6 -------------------------------------------------------------------------------
7 -- Description: GTP7 TX manual 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 work.StdRtlPkg.all;
21 
22 --! @see entity
23  --! @ingroup xilinx_7Series_gtp7
25  generic (
26  TPD_G : time := 1 ns);
27  port (
28  stableClk : in sl;
29 
30  -- TX RST IO
34 
35  -- GT IO - Inputs are asynchronous
38  gtTxPhInit : out sl;
40  gtTxPhAlign : out sl;
42  gtTxDlyEn : out sl);
43 end Gtp7TxManualPhaseAligner;
44 
45 architecture rtl of Gtp7TxManualPhaseAligner is
46 
47  type StateType is (
48  INIT_S,
49  WAIT_DLY_SRESET_DONE_S,
50  WAIT_PH_INIT_DONE_S,
51  WAIT_PH_ALIGN_DONE_S,
52  WAIT_PH_ALIGN_DONE_2_S,
53  DONE_S);
54 
55  type RegType is record
56  state : StateType;
57  -- Outputs
59  gtTxDlySReset : sl;
60  gtTxPhInit : sl;
61  gtTxPhAlign : sl;
62  gtTxDlyEn : sl;
63  end record RegType;
64 
65  constant REG_RESET_C : RegType := (
66  state => INIT_S,
67  phaseAlignmentDone => '0',
68  gtTxDlySReset => '0',
69  gtTxPhInit => '0',
70  gtTxPhAlign => '0',
71  gtTxDlyEn => '0');
72 
73  signal r, rin : RegType := REG_RESET_C;
74 
75  signal gtTxDlySResetDoneSync : sl;
76  signal gtTxPhInitDoneSync : sl;
77  signal gtTxPhAlignDoneSync : sl;
78  signal gtTxPhAlignDoneEdge : sl;
79 
80 begin
81 
82  TX_DLY_S_RESET_DONE_SYNC : entity work.Synchronizer
83  generic map (
84  TPD_G => TPD_G)
85  port map (
86  clk => stableClk,
88  dataOut => gtTxDlySResetDoneSync);
89 
90  TX_PH_INIT_DONE_SYNC : entity work.Synchronizer
91  generic map (
92  TPD_G => TPD_G)
93  port map (
94  clk => stableClk,
96  dataOut => gtTxPhInitDoneSync);
97 
98  TX_PH_ALIGN_DONE_SYNC : entity work.SynchronizerEdge
99  generic map (
100  TPD_G => TPD_G)
101  port map (
102  clk => stableClk,
104  dataOut => gtTxPhAlignDoneSync,
105  risingEdge => gtTxPhAlignDoneEdge,
106  fallingEdge => open);
107 
108  comb : process (r, gtTxDlySResetDoneSync, gtTxPhInitDoneSync, gtTxPhAlignDoneSync, gtTxPhAlignDoneEdge,
110  variable v : RegType;
111  begin
112  v := r;
113 
114  case (r.state) is
115  when INIT_S =>
116  if (runPhAlignment = '1') then
117  v.gtTxDlySReset := '1';
118  v.state := WAIT_DLY_SRESET_DONE_S;
119  end if;
120 
121  when WAIT_DLY_SRESET_DONE_S =>
122  -- When resetDone arrives, lower reset and raise phInit
123  if (gtTxDlySResetDoneSync = '1') then
124  v.gtTxDlySReset := '0';
125  v.gtTxPhInit := '1';
126  v.state := WAIT_PH_INIT_DONE_S;
127  end if;
128 
129  when WAIT_PH_INIT_DONE_S =>
130  if (gtTxPhInitDoneSync = '1') then
131  v.gtTxPhInit := '0';
132  v.gtTxPhAlign := '1';
133  v.state := WAIT_PH_ALIGN_DONE_S;
134  end if;
135 
136  when WAIT_PH_ALIGN_DONE_S =>
137  if (gtTxPhAlignDoneEdge = '1') then
138  v.gtTxPhAlign := '0';
139  v.gtTxDlyEn := '1';
140  v.state := WAIT_PH_ALIGN_DONE_2_S;
141  --v.state := DONE_S;
142  end if;
143 
144  when WAIT_PH_ALIGN_DONE_2_S =>
145  if (gtTxPhAlignDoneEdge = '1') then
146  v.gtTxDlyEn := '0';
147  v.state := DONE_S;
148  end if;
149 
150  when DONE_S =>
151  v.phaseAlignmentDone := '1';
152 
153  when others => null;
154  end case;
155 
156  if (resetPhAlignment = '1') then
157  v := REG_RESET_C;
158  end if;
159 
160  rin <= v;
161 
164  gtTxPhInit <= r.gtTxPhInit;
166  gtTxDlyEn <= r.gtTxDlyEn;
167 
168  end process comb;
169 
170  seq : process (stableClk) is
171  begin
172  if rising_edge(stableClk) then
173  r <= rin after TPD_G;
174  end if;
175  end process seq;
176 end architecture rtl;
std_logic sl
Definition: StdRtlPkg.vhd:28
out dataOutsl
TPD_Gtime := 1 ns