SURF  1.0
Gth7TxManualPhaseAligner.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : Gth7TxManualPhaseAligner.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2015-04-01
5 -- Last update: 2015-04-01
6 -------------------------------------------------------------------------------
7 -- Description: GTH7 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_gth7
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 Gth7TxManualPhaseAligner;
44 
45 architecture rtl of Gth7TxManualPhaseAligner 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  attribute KEEP_HIERARCHY : string;
81  attribute KEEP_HIERARCHY of
82  TX_DLY_S_RESET_DONE_SYNC,
83  TX_PH_INIT_DONE_SYNC,
84  TX_PH_ALIGN_DONE_SYNC : label is "TRUE";
85 
86 begin
87 
88  TX_DLY_S_RESET_DONE_SYNC : entity work.Synchronizer
89  generic map (
90  TPD_G => TPD_G)
91  port map (
92  clk => stableClk,
94  dataOut => gtTxDlySResetDoneSync);
95 
96  TX_PH_INIT_DONE_SYNC : entity work.Synchronizer
97  generic map (
98  TPD_G => TPD_G)
99  port map (
100  clk => stableClk,
102  dataOut => gtTxPhInitDoneSync);
103 
104  TX_PH_ALIGN_DONE_SYNC : entity work.SynchronizerEdge
105  generic map (
106  TPD_G => TPD_G)
107  port map (
108  clk => stableClk,
110  dataOut => gtTxPhAlignDoneSync,
111  risingEdge => gtTxPhAlignDoneEdge,
112  fallingEdge => open);
113 
114  comb : process (r, gtTxDlySResetDoneSync, gtTxPhInitDoneSync, gtTxPhAlignDoneSync, gtTxPhAlignDoneEdge,
116  variable v : RegType;
117  begin
118  v := r;
119 
120  case (r.state) is
121  when INIT_S =>
122  if (runPhAlignment = '1') then
123  v.gtTxDlySReset := '1';
124  v.state := WAIT_DLY_SRESET_DONE_S;
125  end if;
126 
127  when WAIT_DLY_SRESET_DONE_S =>
128  -- When resetDone arrives, lower reset and raise phInit
129  if (gtTxDlySResetDoneSync = '1') then
130  v.gtTxDlySReset := '0';
131  v.gtTxPhInit := '1';
132  v.state := WAIT_PH_INIT_DONE_S;
133  end if;
134 
135  when WAIT_PH_INIT_DONE_S =>
136  if (gtTxPhInitDoneSync = '1') then
137  v.gtTxPhInit := '0';
138  v.gtTxPhAlign := '1';
139  v.state := WAIT_PH_ALIGN_DONE_S;
140  end if;
141 
142  when WAIT_PH_ALIGN_DONE_S =>
143  if (gtTxPhAlignDoneEdge = '1') then
144  v.gtTxPhAlign := '0';
145  v.gtTxDlyEn := '1';
146 -- v.state := WAIT_PH_ALIGN_DONE_2_S;
147  v.state := DONE_S;
148  end if;
149 
150  when WAIT_PH_ALIGN_DONE_2_S =>
151  if (gtTxPhAlignDoneEdge = '1') then
152  v.gtTxDlyEn := '0';
153  v.state := DONE_S;
154  end if;
155 
156  when DONE_S =>
157  v.phaseAlignmentDone := '1';
158 
159  when others => null;
160  end case;
161 
162  if (resetPhAlignment = '1') then
163  v := REG_RESET_C;
164  end if;
165 
166  rin <= v;
167 
170  gtTxPhInit <= r.gtTxPhInit;
172  gtTxDlyEn <= r.gtTxDlyEn;
173 
174  end process comb;
175 
176  seq : process (stableClk) is
177  begin
178  if rising_edge(stableClk) then
179  r <= rin after TPD_G;
180  end if;
181  end process seq;
182 end architecture rtl;
std_logic sl
Definition: StdRtlPkg.vhd:28
out dataOutsl
TPD_Gtime := 1 ns