SURF  1.0
Jesd204bRxGthUltra.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : Jesd204bRxGthUltra.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2015-04-14
5 -- Last update: 2015-04-14
6 -------------------------------------------------------------------------------
7 -- Description: JESD204b receiver module containing the GTH Ultrascale MGT
8 -- Wrapper module for JESD receiver.
9 -- GTH coregen generated core 2 GTH modules
10 -- Note: Intended only for two serial lanes L_G=2.
11 -- 7.4 GHz lane rate and 370MHz reference, Freerunning clk 185 MHz
12 -- If different amount of lanes or freq is required the Core has to be regenerated
13 -- by Xilinx Coregen.
14 -------------------------------------------------------------------------------
15 -- This file is part of 'SLAC Firmware Standard Library'.
16 -- It is subject to the license terms in the LICENSE.txt file found in the
17 -- top-level directory of this distribution and at:
18 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html.
19 -- No part of 'SLAC Firmware Standard Library', including this file,
20 -- may be copied, modified, propagated, or distributed except according to
21 -- the terms contained in the LICENSE.txt file.
22 -------------------------------------------------------------------------------
23 
24 library ieee;
25 library unisim;
26 use unisim.vcomponents.all;
27 
28 use ieee.std_logic_1164.all;
29 use ieee.std_logic_arith.all;
30 use ieee.std_logic_unsigned.all;
31 use ieee.numeric_std.all;
32 
33 use work.StdRtlPkg.all;
34 use work.AxiLitePkg.all;
35 use work.AxiStreamPkg.all;
36 use work.SsiPkg.all;
37 use work.Jesd204bPkg.all;
38 
40  generic (
41  TPD_G : time := 1 ns;
42 
43  -- Test tx module instead of GTX
44  TEST_G : boolean := false;
45 
46  -- Internal SYSREF SYSREF_GEN_G= TRUE else
47  -- External SYSREF
48  SYSREF_GEN_G : boolean := false;
49 
50  -- AXI Lite and AXI stream generics
51  ----------------------------------------------------------------------------------------------
53 
54  -- JESD generics
55  ----------------------------------------------------------------------------------------------
56  F_G : positive := 2;
57  K_G : positive := 32;
58  L_G : positive := 2
59  );
60 
61  port (
62  -- GT Interface
63  ----------------------------------------------------------------------------------------------
64  -- GT Clocking
65  stableClk : in sl; -- GT needs a stable clock to "boot up"(buffered refClkDiv2)
66  refClk : in sl; -- GT Reference clock directly from GT GTH diff. input buffer
67  -- Gt Serial IO
68  gtTxP : out slv(L_G-1 downto 0); -- GT Serial Transmit Positive
69  gtTxN : out slv(L_G-1 downto 0); -- GT Serial Transmit Negative
70  gtRxP : in slv(L_G-1 downto 0); -- GT Serial Receive Positive
71  gtRxN : in slv(L_G-1 downto 0); -- GT Serial Receive Negative
72 
73  -- User clocks and resets
74  ----------------------------------------------------------------------------------------------
75  devClk_i : in sl; -- Device clock also rxUsrClkIn for MGT
76  devClk2_i : in sl; -- Device clock divided by 2 also rxUsrClk2In for MGT
77  devRst_i : in sl; --
78 
79  -- AXI interface
80  ------------------------------------------------------------------------------------------------
81  axiClk : in sl;
82  axiRst : in sl;
83 
84  -- AXI-Lite Register Interface
89 
90  -- AXI Streaming Interface
92  rxCtrlArr : in AxiStreamCtrlArray(L_G-1 downto 0);
93 
94  -- JESD
95  ------------------------------------------------------------------------------------------------
96 
97  -- SYSREF for subclass 1 fixed latency
98  sysRef_i : in sl;
99 
100  -- SYSREF out when it is generated internally SYSREF_GEN_G=True
101  sysRef_o : out sl;
102 
103  -- Synchronization output combined from all receivers
104  nSync_o : out sl;
105 
106  -- Out to led
107  leds_o : out slv(1 downto 0);
108 
109  -- Rising edge pulses for test
110  pulse_o : out slv(L_G-1 downto 0);
111 
112  -- Out to led
113  qPllLock_o : out sl
114  );
115 end Jesd204bRxGthUltra;
116 
117 architecture rtl of Jesd204bRxGthUltra is
118 ---------------------------------------
119  component gthultrascalejesdcoregen
120  port (
121  gtwiz_userclk_tx_reset_in : in slv(0 downto 0);
122  gtwiz_userclk_tx_active_in : in slv(0 downto 0);
123  gtwiz_userclk_rx_active_in : in slv(0 downto 0);
124  gtwiz_reset_clk_freerun_in : in slv(0 downto 0);
125  gtwiz_reset_all_in : in slv(0 downto 0);
126  gtwiz_reset_tx_pll_and_datapath_in : in slv(0 downto 0);
127  gtwiz_reset_tx_datapath_in : in slv(0 downto 0);
128  gtwiz_reset_rx_pll_and_datapath_in : in slv(0 downto 0);
129  gtwiz_reset_rx_datapath_in : in slv(0 downto 0);
130  gtwiz_reset_rx_cdr_stable_out : out slv(0 downto 0);
131  gtwiz_reset_tx_done_out : out slv(0 downto 0);
132  gtwiz_reset_rx_done_out : out slv(0 downto 0);
133  gtwiz_userdata_tx_in : in slv((2*GT_WORD_SIZE_C*8)-1 downto 0);
134  gtwiz_userdata_rx_out : out slv((2*GT_WORD_SIZE_C*8)-1 downto 0);
135  drpclk_in : in slv(1 downto 0);
136  gthrxn_in : in slv(1 downto 0);
137  gthrxp_in : in slv(1 downto 0);
138  gtrefclk0_in : in slv(1 downto 0);
139  rx8b10ben_in : in slv(1 downto 0);
140  rxcommadeten_in : in slv(1 downto 0);
141  rxmcommaalignen_in : in slv(1 downto 0);
142  rxpcommaalignen_in : in slv(1 downto 0);
143  rxpolarity_in : in slv(1 downto 0);
144  rxusrclk_in : in slv(1 downto 0);
145  rxusrclk2_in : in slv(1 downto 0);
146  tx8b10ben_in : in slv(1 downto 0);
147  rxbufreset_in : in slv(1 downto 0);
148  txctrl0_in : in slv(31 downto 0);
149  txctrl1_in : in slv(31 downto 0);
150  txctrl2_in : in slv(15 downto 0);
151  txpolarity_in : in slv(1 downto 0);
152  txusrclk_in : in slv(1 downto 0);
153  txusrclk2_in : in slv(1 downto 0);
154  gthtxn_out : out slv(1 downto 0);
155  gthtxp_out : out slv(1 downto 0);
156  rxbyteisaligned_out : out slv(1 downto 0);
157  rxbyterealign_out : out slv(1 downto 0);
158  rxcommadet_out : out slv(1 downto 0);
159  rxctrl0_out : out slv(31 downto 0);
160  rxctrl1_out : out slv(31 downto 0);
161  rxctrl2_out : out slv(15 downto 0);
162  rxctrl3_out : out slv(15 downto 0);
163  rxoutclk_out : out slv(1 downto 0);
164  rxpmaresetdone_out : out slv(1 downto 0);
165  txoutclk_out : out slv(1 downto 0);
166  txpmaresetdone_out : out slv(1 downto 0)
167  );
168  end component;
169 -------------------------------------
170 
171 -- Internal signals
172  signal r_jesdGtRxArr : jesdGtRxLaneTypeArray(L_G-1 downto 0);
173 
174  -- Rx Channel Bonding
175  -- signal rxChBondLevel : slv(2 downto 0);
176  signal rxChBondIn : Slv5Array(L_G-1 downto 0);
177  signal rxChBondOut : Slv5Array(L_G-1 downto 0);
178 
179  -- GT reset
180  signal s_gtUserReset : slv(L_G-1 downto 0);
181  signal s_gtReset : sl;
182 
183  -- Generated or external
184  signal s_sysRef, s_sysRefDbg : sl;
185 
186  -- GT signals
187  signal s_rxctrl0 : slv(31 downto 0);
188  signal s_rxctrl1 : slv(31 downto 0);
189  signal s_rxctrl2 : slv(15 downto 0);
190  signal s_rxctrl3 : slv(15 downto 0);
191 
192  signal s_data : slv((2*GT_WORD_SIZE_C*8)-1 downto 0);
193 
194  signal s_devClkVec : slv(1 downto 0);
195  signal s_devClk2Vec : slv(1 downto 0);
196  signal s_stableClkVec : slv(1 downto 0);
197  signal s_gtRefClkVec : slv(1 downto 0);
198  signal s_rxDone : sl;
199 
200  signal s_nSync : sl;
201  signal s_validVec : slv(1 downto 0);
202  signal s_allignEnVec : slv(1 downto 0);
203 
204 begin
205  nSync_o <= s_nSync;
206  s_allignEnVec <= not s_validVec;
207 
208  --------------------------------------------------------------------------------------------------
209  -- JESD receiver core
210  --------------------------------------------------------------------------------------------------
211  Jesd204b_INST: entity work.Jesd204bRx
212  generic map (
213  TPD_G => TPD_G,
214  TEST_G => TEST_G,
216  F_G => F_G,
217  K_G => K_G,
218  L_G => L_G)
219  port map (
220  axiClk => axiClk,
221  axiRst => axiRst,
228  devClk_i => devClk_i,
229  devRst_i => devRst_i,
230  sysRef_i => s_sysRef,
231  sysRefDbg_o => s_sysRefDbg,
232  r_jesdGtRxArr => r_jesdGtRxArr,
233  gtRxReset_o => s_gtUserReset,
234  sampleDataArr_o => open, -- DAQ handled internally
235  dataValidVec_o => s_validVec, -- DAQ handled internally
236  nSync_o => s_nSync,
237  pulse_o => pulse_o,
238  leds_o => leds_o
239  );
240  --------------------------------------------------------------------------------------------------
241  -- Generate the internal or external SYSREF depending on SYSREF_GEN_G
242  --------------------------------------------------------------------------------------------------
243  -- IF DEF SYSREF_GEN_G
244  SELF_TEST_GEN: if SYSREF_GEN_G = true generate
245  -- Generate the sysref internally
246  -- Sysref period will be 8x K_G.
247  SysrefGen_INST: entity work.LmfcGen
248  generic map (
249  TPD_G => TPD_G,
250  K_G => 256,
251  F_G => 2)
252  port map (
253  clk => devClk_i,
254  rst => devRst_i,
255  nSync_i => '0',
256  sysref_i => '0',
257  lmfc_o => s_sysRef
258  );
259  sysRef_o <= s_sysRef;
260  end generate SELF_TEST_GEN;
261  -- Else
262  OPER_GEN: if SYSREF_GEN_G = false generate
263  s_sysRef <= sysRef_i;
264  sysRef_o <= s_sysRefDbg;
265  end generate OPER_GEN;
266 
267  --------------------------------------------------------------------------------------------------
268  -- GTH signals assignments. Only for L_G = 2
269  --------------------------------------------------------------------------------------------------
270  s_gtReset <= devRst_i or uOr(s_gtUserReset);
271 
272  r_jesdGtRxArr(0).data <= s_data((GT_WORD_SIZE_C*8)-1 downto 0);
273  r_jesdGtRxArr(1).data <= s_data((2*GT_WORD_SIZE_C*8)-1 downto (GT_WORD_SIZE_C*8));
274 
275  r_jesdGtRxArr(0).dataK <= s_rxctrl0(GT_WORD_SIZE_C-1 downto 0);
276  r_jesdGtRxArr(1).dataK <= s_rxctrl0(16+GT_WORD_SIZE_C-1 downto 16);
277 
278  r_jesdGtRxArr(0).dispErr <= s_rxctrl1(GT_WORD_SIZE_C-1 downto 0);
279  r_jesdGtRxArr(1).dispErr <= s_rxctrl1(16+GT_WORD_SIZE_C-1 downto 16);
280 
281  r_jesdGtRxArr(0).decErr <= s_rxctrl3(GT_WORD_SIZE_C-1 downto 0);
282  r_jesdGtRxArr(1).decErr <= s_rxctrl3(8+GT_WORD_SIZE_C-1 downto 8);
283 
284  r_jesdGtRxArr(0).rstDone <= s_rxDone;
285  r_jesdGtRxArr(1).rstDone <= s_rxDone;
286 
287  s_devClkVec <= devClk_i & devClk_i;
288  s_devClk2Vec <= devClk2_i & devClk2_i;
289  s_stableClkVec <= stableClk & stableClk;
290  s_gtRefClkVec <= refClk & refClk;
291 
292  qPllLock_o <= s_rxDone;
293 
294  --------------------------------------------------------------------------------------------------
295  -- Include Core from Coregen Vivado 15.1
296  -- Coregen settings:
297  -- - Lane rate 7.4 GHz
298  -- - Reference freq 184 MHz
299  -- - 8b10b enabled
300  -- - 32b/40b word datapath
301  -- - Comma detection has to be enabled to any byte boundary - IMPORTANT
302  --------------------------------------------------------------------------------------------------
303  GT_OPER_GEN: if TEST_G = false generate
304  GthUltrascaleJesdCoregen_INST: GthUltrascaleJesdCoregen
305  port map (
306  -- Clocks
307  gtwiz_userclk_tx_reset_in(0) => s_gtReset,
308  gtwiz_userclk_tx_active_in(0) => '1',
309  gtwiz_userclk_rx_active_in(0) => '1',
310  gtwiz_reset_clk_freerun_in(0) => stableClk,
311 
312  gtwiz_reset_all_in(0) => '0',
313  gtwiz_reset_tx_pll_and_datapath_in(0) => '0',
314  gtwiz_reset_tx_datapath_in(0) => s_gtReset,
315  gtwiz_reset_rx_pll_and_datapath_in(0) => '0',
316  gtwiz_reset_rx_datapath_in(0) => s_gtReset,
317  gtwiz_reset_rx_cdr_stable_out => open,
318  gtwiz_reset_tx_done_out => open,
319  gtwiz_reset_rx_done_out(0) => s_rxDone,
320  gtwiz_userdata_tx_in => (s_data'range =>'0'),
321  gtwiz_userdata_rx_out => s_data,
322  drpclk_in => s_stableClkVec,
323  gthrxn_in => gtRxN,
324  gthrxp_in => gtRxP,
325  gtrefclk0_in => s_gtRefClkVec,
326 
327  tx8b10ben_in => "00",
328  txctrl0_in => X"0000_0000",
329  txctrl1_in => X"0000_0000",
330  txctrl2_in => X"0000",
331  txpolarity_in => "00",
332  txusrclk_in => s_devClkVec,
333  txusrclk2_in => s_devClk2Vec,
334  gthtxn_out => gtTxN,
335  gthtxp_out => gtTxP,
336  txoutclk_out => open,
337  txpmaresetdone_out => open,
338 
339  -- RX settings
340  rx8b10ben_in => "11",
341  rxbufreset_in => "00",
342  rxcommadeten_in => "11",
343  rxmcommaalignen_in => s_allignEnVec,
344  rxpcommaalignen_in => s_allignEnVec,
345  rxpolarity_in => "11", -- TODO Check
346  rxusrclk_in => s_devClkVec,
347  rxusrclk2_in => s_devClk2Vec,
348 
349  rxbyteisaligned_out => open,
350  rxbyterealign_out => open,
351  rxcommadet_out => open,
352  rxctrl0_out => s_rxctrl0, -- x"000" & r_jesdGtRxArr(1).dataK & X"000" & r_jesdGtRxArr(0).dataK,
353  rxctrl1_out => s_rxctrl1, -- x"000" & r_jesdGtRxArr(1).dispErr & X"000" & r_jesdGtRxArr(0).dispErr,
354  rxctrl2_out => s_rxctrl2, -- open -- comma detected on corresponding byte
355  rxctrl3_out => s_rxctrl3, -- x"0" & r_jesdGtRxArr(1).decErr & X"0" & r_jesdGtRxArr(0).decErr,
356  rxoutclk_out => open,
357  rxpmaresetdone_out => open
358  );
359  -----------------------------------------
360  end generate GT_OPER_GEN;
361  -----------------------------------------------------
362 end rtl;
slv( 127 downto 0) data
Definition: SsiPkg.vhd:67
AXI_ERROR_RESP_Gslv( 1 downto 0) := AXI_RESP_SLVERR_C
out pulse_oslv( L_G- 1 downto 0)
out axilReadSlaveAxiLiteReadSlaveType
out rxAxisMasterArrAxiStreamMasterArray( L_G- 1 downto 0)
SYSREF_GEN_Gboolean := false
in gtRxNslv( L_G- 1 downto 0)
AxiLiteWriteMasterType
Definition: AxiLitePkg.vhd:111
TPD_Gtime := 1 ns
Definition: Jesd204bRx.vhd:48
std_logic sl
Definition: StdRtlPkg.vhd:28
L_Gpositive range 1 to 32:= 2
Definition: Jesd204bRx.vhd:65
out dataValidVec_oslv( L_G- 1 downto 0)
Definition: Jesd204bRx.vhd:85
out rxAxisMasterArr_oAxiStreamMasterArray( L_G- 1 downto 0)
Definition: Jesd204bRx.vhd:80
in rxCtrlArrAxiStreamCtrlArray( L_G- 1 downto 0)
TEST_Gboolean := false
Definition: Jesd204bRx.vhd:51
slv( GT_WORD_SIZE_C- 1 downto 0) dataK
Definition: Jesd204bPkg.vhd:63
out axilWriteSlaveAxiLiteWriteSlaveType
in axilReadMasterAxiLiteReadMasterType
out sysRefDbg_osl
Definition: Jesd204bRx.vhd:96
K_Gpositive := 32
Definition: Jesd204bRx.vhd:62
out sampleDataArr_osampleDataArray( L_G- 1 downto 0)
Definition: Jesd204bRx.vhd:84
in axilReadMasterAxiLiteReadMasterType
Definition: Jesd204bRx.vhd:74
out nSync_osl
Definition: Jesd204bRx.vhd:105
slv( 1 downto 0) := "10" AXI_RESP_SLVERR_C
Definition: AxiLitePkg.vhd:36
AXI_ERROR_RESP_Gslv( 1 downto 0) := AXI_RESP_SLVERR_C
Definition: Jesd204bRx.vhd:54
_library_ ieeeieee
Definition: I2cSlave.vhd:72
F_Gpositive := 2
Definition: Jesd204bRx.vhd:59
out axilReadSlaveAxiLiteReadSlaveType
Definition: Jesd204bRx.vhd:75
in devRst_isl
Definition: Jesd204bRx.vhd:90
AxiLiteReadMasterType
Definition: AxiLitePkg.vhd:59
in axiClksl
Definition: Jesd204bRx.vhd:70
slv( GT_WORD_SIZE_C- 1 downto 0) dispErr
Definition: Jesd204bPkg.vhd:64
out leds_oslv( 1 downto 0)
positive := 4 GT_WORD_SIZE_C
Definition: Jesd204bPkg.vhd:31
array(natural range <> ) of AxiStreamCtrlType AxiStreamCtrlArray
in sysRef_isl
Definition: Jesd204bRx.vhd:93
out pulse_oslv( L_G- 1 downto 0)
Definition: Jesd204bRx.vhd:108
array(natural range <> ) of AxiStreamMasterType AxiStreamMasterArray
out gtRxReset_oslv( L_G- 1 downto 0)
Definition: Jesd204bRx.vhd:100
in axilWriteMasterAxiLiteWriteMasterType
Definition: Jesd204bRx.vhd:76
in devClk_isl
Definition: Jesd204bRx.vhd:89
AxiLiteReadSlaveType
Definition: AxiLitePkg.vhd:85
array(natural range <> ) of slv( 4 downto 0) Slv5Array
Definition: StdRtlPkg.vhd:406
in r_jesdGtRxArrjesdGtRxLaneTypeArray( L_G- 1 downto 0)
Definition: Jesd204bRx.vhd:99
out gtTxPslv( L_G- 1 downto 0)
out gtTxNslv( L_G- 1 downto 0)
in axiRstsl
Definition: Jesd204bRx.vhd:71
slv( GT_WORD_SIZE_C- 1 downto 0) decErr
Definition: Jesd204bPkg.vhd:65
array(natural range <> ) of jesdGtRxLaneType jesdGtRxLaneTypeArray
Definition: Jesd204bPkg.vhd:88
out leds_oslv( 1 downto 0)
Definition: Jesd204bRx.vhd:110
in rxCtrlArr_iAxiStreamCtrlArray( L_G- 1 downto 0) :=( others => AXI_STREAM_CTRL_UNUSED_C)
Definition: Jesd204bRx.vhd:81
out axilWriteSlaveAxiLiteWriteSlaveType
Definition: Jesd204bRx.vhd:77
in axilWriteMasterAxiLiteWriteMasterType
in gtRxPslv( L_G- 1 downto 0)
std_logic_vector slv
Definition: StdRtlPkg.vhd:29
TEST_Gboolean := false