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