SURF  1.0
Jesd204bTxGthUltra.vhd
Go to the documentation of this file.
1 -------------------------------------------------------------------------------
2 -- File : Jesd204bTxGthUltra.vhd
3 -- Company : SLAC National Accelerator Laboratory
4 -- Created : 2015-04-14
5 -- Last update: 2015-04-14
6 -------------------------------------------------------------------------------
7 -- Description: JESD204b module containing the GTH Ultrascale MGT transmitter modules
8 -- Wrapper module for JESD.
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  -- Internal SYSREF SYSREF_GEN_G= TRUE else
44  -- External SYSREF
45  SYSREF_GEN_G : boolean := false;
46 
47  -- Simulation disconnect the GTX
48  SIM_G : boolean := false;
49 
50 
51  -- GT Settings
52  ----------------------------------------------------------------------------------------------
53  -- AXI Lite and AXI stream generics
54  ----------------------------------------------------------------------------------------------
56 
57  -- JESD generics
58  ----------------------------------------------------------------------------------------------
59  F_G : positive := 2;
60  K_G : positive := 32;
61  L_G : positive := 2
62  );
63 
64  port (
65  -- GT Interface
66  ----------------------------------------------------------------------------------------------
67  -- GT Clocking
68  stableClk : in sl; -- GT needs a stable clock to "boot up"(buffered refClkDiv2)
69  refClk : in sl; -- GT Reference clock directly from GT GTH diff. input buffer
70 
71  -- Gt Serial IO
72  gtTxP : out slv(L_G-1 downto 0); -- GT Serial Transmit Positive
73  gtTxN : out slv(L_G-1 downto 0); -- GT Serial Transmit Negative
74  gtRxP : in slv(L_G-1 downto 0); -- GT Serial Receive Positive
75  gtRxN : in slv(L_G-1 downto 0); -- GT Serial Receive Negative
76 
77  -- User clocks and resets
78  ----------------------------------------------------------------------------------------------
79  devClk_i : in sl; -- Device clock also rxUsrClkIn for MGT
80  devClk2_i : in sl; -- Device clock divided by 2 also rxUsrClk2In for MGT
81  devRst_i : in sl; --
82 
83  -- AXI interface
84  ------------------------------------------------------------------------------------------------
85  axiClk : in sl;
86  axiRst : in sl;
87 
88  -- AXI-Lite RX Register Interface
93 
94  -- AXI Streaming Interface
97 
98  -- External sample data input
100 
101  -- JESD
102  ------------------------------------------------------------------------------------------------
103 
104  -- SYSREF for subcalss 1 fixed latency
105  sysRef_i : in sl;
106 
107  -- SYSREF out when it is generated internally SYSREF_GEN_G=True
108  sysRef_o : out sl;
109 
110  -- Synchronisation output combined from all receivers
111  nSync_i : in sl;
112 
113  -- Test signal
114  pulse_o : out slv(L_G-1 downto 0);
115 
116  -- Out to led
117  leds_o : out slv(1 downto 0);
118 
119  -- Out to led
120  qPllLock_o : out sl
121  );
122 end Jesd204bTxGthUltra;
123 
124 architecture rtl of Jesd204bTxGthUltra is
125 
126 ---------------------------------------
127 component gthultrascalejesdcoregen
128  port (
129  gtwiz_userclk_rx_active_in : in std_logic_vector(0 downto 0);
130  gtwiz_buffbypass_tx_reset_in : in std_logic_vector(0 downto 0);
131  gtwiz_buffbypass_tx_start_user_in : in std_logic_vector(0 downto 0);
132  gtwiz_buffbypass_tx_done_out : out std_logic_vector(0 downto 0);
133  gtwiz_buffbypass_tx_error_out : out std_logic_vector(0 downto 0);
134  gtwiz_reset_clk_freerun_in : in std_logic_vector(0 downto 0);
135  gtwiz_reset_all_in : in std_logic_vector(0 downto 0);
136  gtwiz_reset_tx_pll_and_datapath_in : in std_logic_vector(0 downto 0);
137  gtwiz_reset_tx_datapath_in : in std_logic_vector(0 downto 0);
138  gtwiz_reset_rx_pll_and_datapath_in : in std_logic_vector(0 downto 0);
139  gtwiz_reset_rx_datapath_in : in std_logic_vector(0 downto 0);
140  gtwiz_reset_rx_cdr_stable_out : out std_logic_vector(0 downto 0);
141  gtwiz_reset_tx_done_out : out std_logic_vector(0 downto 0);
142  gtwiz_reset_rx_done_out : out std_logic_vector(0 downto 0);
143  gtwiz_userdata_tx_in : in std_logic_vector(63 downto 0);
144  gtwiz_userdata_rx_out : out std_logic_vector(63 downto 0);
145  gtrefclk00_in : in std_logic_vector(0 downto 0);
146  qpll0lock_out : out std_logic_vector(0 downto 0);
147  qpll0outclk_out : out std_logic_vector(0 downto 0);
148  qpll0outrefclk_out : out std_logic_vector(0 downto 0);
149  gthrxn_in : in std_logic_vector(1 downto 0);
150  gthrxp_in : in std_logic_vector(1 downto 0);
151  rx8b10ben_in : in std_logic_vector(1 downto 0);
152  rxcommadeten_in : in std_logic_vector(1 downto 0);
153  rxmcommaalignen_in : in std_logic_vector(1 downto 0);
154  rxpcommaalignen_in : in std_logic_vector(1 downto 0);
155  rxpolarity_in : in std_logic_vector(1 downto 0);
156  rxusrclk_in : in std_logic_vector(1 downto 0);
157  rxusrclk2_in : in std_logic_vector(1 downto 0);
158  tx8b10ben_in : in std_logic_vector(1 downto 0);
159  txctrl0_in : in std_logic_vector(31 downto 0);
160  txctrl1_in : in std_logic_vector(31 downto 0);
161  txctrl2_in : in std_logic_vector(15 downto 0);
162  txpolarity_in : in std_logic_vector(1 downto 0);
163  txusrclk_in : in std_logic_vector(1 downto 0);
164  txusrclk2_in : in std_logic_vector(1 downto 0);
165  gthtxn_out : out std_logic_vector(1 downto 0);
166  gthtxp_out : out std_logic_vector(1 downto 0);
167  rxbyteisaligned_out : out std_logic_vector(1 downto 0);
168  rxbyterealign_out : out std_logic_vector(1 downto 0);
169  rxcommadet_out : out std_logic_vector(1 downto 0);
170  rxctrl0_out : out std_logic_vector(31 downto 0);
171  rxctrl1_out : out std_logic_vector(31 downto 0);
172  rxctrl2_out : out std_logic_vector(15 downto 0);
173  rxctrl3_out : out std_logic_vector(15 downto 0);
174  rxoutclk_out : out std_logic_vector(1 downto 0);
175  rxpmaresetdone_out : out std_logic_vector(1 downto 0);
176  txoutclk_out : out std_logic_vector(1 downto 0);
177  txpmaresetdone_out : out std_logic_vector(1 downto 0)
178  );
179 end component;
180 -------------------------------------
181 
182 -- Internal signals
183  signal r_jesdGtTxArr : jesdGtTxLaneTypeArray(L_G-1 downto 0);
184 
185  -- Rx Channel Bonding
186  -- signal rxChBondLevel : slv(2 downto 0);
187  signal rxChBondIn : Slv5Array(L_G-1 downto 0);
188  signal rxChBondOut : Slv5Array(L_G-1 downto 0);
189 
190  -- GT reset
191  signal s_gtRxUserReset : slv(L_G-1 downto 0);
192  signal s_gtxRst : sl;
193 
194  signal s_gtTxUserReset : slv(L_G-1 downto 0);
195  signal s_gtTxReset : slv(L_G-1 downto 0);
196  --
197  signal s_gtTxReady : slv(L_G-1 downto 0);
198 
199  -- Generated or external
200  signal s_sysRef : sl;
201 
202  -- GT signals
203  signal s_data : slv(63 downto 0);
204  signal s_dataK : slv(15 downto 0);
205  signal s_devClkVec : slv(1 downto 0);
206  signal s_devClk2Vec : slv(1 downto 0);
207 
208  signal s_txDone : sl;
209 
210 
211 begin
212  -- Check generics TODO add others
213  assert (1 <= L_G and L_G <= 8) report "L_G must be between 1 and 8" severity failure;
214 
215  --------------------------------------------------------------------------------------------------
216  -- JESD transmitter core
217  --------------------------------------------------------------------------------------------------
218  Jesd204bTx_INST: entity work.Jesd204bTx
219  generic map (
220  TPD_G => TPD_G,
222  F_G => F_G,
223  K_G => K_G,
224  L_G => L_G)
225  port map (
226  axiClk => axiClk,
227  axiRst => axiRst,
235  devClk_i => devClk_i,
236  devRst_i => devRst_i,
237  sysRef_i => s_sysRef,
238  nSync_i => nSync_i,
239  gtTxReady_i => s_gtTxReady,
240  gtTxReset_o => s_gtTxUserReset,
241  r_jesdGtTxArr => r_jesdGtTxArr,
242  pulse_o => pulse_o,
243  leds_o => leds_o
244  );
245 
246  --------------------------------------------------------------------------------------------------
247  -- Generate the internal or external SYSREF depending on SYSREF_GEN_G
248  --------------------------------------------------------------------------------------------------
249  -- IF DEF SYSREF_GEN_G
250  SELF_TEST_GEN: if SYSREF_GEN_G = true generate
251  -- Generate the sysref internally
252  -- Sysref period will be 8x K_G.
253  SysrefGen_INST: entity work.LmfcGen
254  generic map (
255  TPD_G => TPD_G,
256  K_G => 256,
257  F_G => 2)
258  port map (
259  clk => devClk_i,
260  rst => devRst_i,
261  nSync_i => '0',
262  sysref_i => '0',
263  lmfc_o => s_sysRef
264  );
265  sysRef_o <= s_sysRef;
266  end generate SELF_TEST_GEN;
267  -- Else
268  OPER_GEN: if SYSREF_GEN_G = false generate
269  s_sysRef <= sysRef_i;
270  sysRef_o <= '0';
271  end generate OPER_GEN;
272 
273  --------------------------------------------------------------------------------------------------
274  -- GTH signals. Only for L_G = 2
275  --------------------------------------------------------------------------------------------------
276  s_gtxRst <= devRst_i or uOr(s_gtTxUserReset);
277  s_data <= r_jesdGtTxArr(1).data & r_jesdGtTxArr(0).data;
278  s_dataK <= x"0" & r_jesdGtTxArr(1).dataK & X"0" & r_jesdGtTxArr(0).dataK;
279  s_devClkVec <= devClk_i & devClk_i;
280  s_devClk2Vec <= devClk2_i & devClk2_i;
281  s_gtTxReady <= s_txDone & s_txDone;
282  -- debug
283  --qPllLock_o <= s_txDone;
284 
285  --------------------------------------------------------------------------------------------------
286  -- Include Core from Coregen Vivado 15.1
287  -- Coregen settings:
288  -- - Lane rate 7.4 GHz
289  -- - Reference freq 184 MHz
290  -- - 8b10b encription enabled
291  -- - 32b/40b word datapath
292  -- - TR buffer disabled for deterministic latency - IMPORTANT
293  --------------------------------------------------------------------------------------------------
294  --GT_OPER_GEN: if SIM_G = false generate
295  GthUltrascaleJesdCoregen_INST: GthUltrascaleJesdCoregen
296  port map (
297  -- Clocks
298 -- gtwiz_userclk_tx_active_in(0) => '1',
299  gtwiz_userclk_rx_active_in(0) => '1',
300 
301  gtwiz_buffbypass_tx_reset_in(0) => s_gtxRst,
302  gtwiz_buffbypass_tx_start_user_in(0) => s_gtxRst,
303  gtwiz_buffbypass_tx_done_out(0) => qPllLock_o,
304  gtwiz_buffbypass_tx_error_out => open,
305 
306  gtwiz_reset_clk_freerun_in(0) => stableClk,
307 
308  gtwiz_reset_all_in(0) => s_gtxRst,
309  gtwiz_reset_tx_pll_and_datapath_in(0) => s_gtxRst,
310  gtwiz_reset_tx_datapath_in(0) => s_gtxRst,
311  gtwiz_reset_rx_pll_and_datapath_in(0) => s_gtxRst,
312  gtwiz_reset_rx_datapath_in(0) => s_gtxRst,
313  gtwiz_reset_rx_cdr_stable_out => open,
314  gtwiz_reset_tx_done_out(0) => s_txDone,
315  gtwiz_reset_rx_done_out => open,
316  gtwiz_userdata_tx_in => s_data,
317  gtwiz_userdata_rx_out => open,
318  gtrefclk00_in(0) => refClk,
319  qpll0outclk_out => open,
320  qpll0outrefclk_out => open,
321  gthrxn_in => gtRxN,
322  gthrxp_in => gtRxP,
323  qpll0lock_out => open,--qPllLock_o,
324  rx8b10ben_in => "11",
325  rxcommadeten_in => "11",
326  rxmcommaalignen_in => "11",
327  rxpcommaalignen_in => "11",
328  rxpolarity_in => "11", -- Changed to '1' after receiving weird data (sometimes ok sometimes wrong)
329  rxusrclk_in => s_devClkVec,
330  rxusrclk2_in => s_devClk2Vec,
331  tx8b10ben_in => "11",
332  txctrl0_in => X"0000_0000",
333  txctrl1_in => X"0000_0000",
334  txctrl2_in => s_dataK,
335  txpolarity_in => "00",
336  txusrclk_in => s_devClkVec,
337  txusrclk2_in => s_devClk2Vec,
338  gthtxn_out => gtTxN,
339  gthtxp_out => gtTxP,
340  txoutclk_out => open,
341  txpmaresetdone_out => open,
342 
343  -- RX settings
344  rxbyteisaligned_out => open,
345  rxbyterealign_out => open,
346  rxcommadet_out => open,
347  rxctrl0_out => open, -- x"000" & r_jesdGtRxArr(1).dataK & X"000" & r_jesdGtRxArr(0).dataK,
348  rxctrl1_out => open, -- x"000" & r_jesdGtRxArr(1).dispErr & X"000" & r_jesdGtRxArr(0).dispErr,
349  rxctrl2_out => open, -- open -- comma detected on corresponding byte
350  rxctrl3_out => open, -- x"0" & r_jesdGtRxArr(1).decErr & X"0" & r_jesdGtRxArr(0).decErr,
351  rxoutclk_out => open,
352  rxpmaresetdone_out => open
353  );
354  -----------------------------------------
355  -- end generate GT_OPER_GEN;
356  -----------------------------------------------------
357 end rtl;
slv( 127 downto 0) data
Definition: SsiPkg.vhd:67
array(natural range <> ) of slv(( GT_WORD_SIZE_C* 8)- 1 downto 0) sampleDataArray
Definition: Jesd204bPkg.vhd:91
array(natural range <> ) of AxiStreamSlaveType AxiStreamSlaveArray
TPD_Gtime := 1 ns
Definition: Jesd204bTx.vhd:46
in gtRxPslv( L_G- 1 downto 0)
K_Gpositive := 32
Definition: Jesd204bTx.vhd:54
in axilReadMasterAxiLiteReadMasterType
Definition: Jesd204bTx.vhd:64
AxiLiteWriteMasterType
Definition: AxiLitePkg.vhd:111
std_logic sl
Definition: StdRtlPkg.vhd:28
in nSync_isl
Definition: Jesd204bTx.vhd:82
_library_ ieeeieee
F_Gpositive := 2
Definition: Jesd204bTx.vhd:52
in txAxisMasterArr_iAxiStreamMasterArray( L_G- 1 downto 0)
slv( GT_WORD_SIZE_C- 1 downto 0) dataK
Definition: Jesd204bPkg.vhd:63
L_Gpositive range 1 to 32:= 2
Definition: Jesd204bTx.vhd:56
out r_jesdGtTxArrjesdGtTxLaneTypeArray( L_G- 1 downto 0)
Definition: Jesd204bTx.vhd:92
out axilReadSlaveTxAxiLiteReadSlaveType
in axilReadMasterTxAxiLiteReadMasterType
out gtTxReset_oslv( L_G- 1 downto 0)
Definition: Jesd204bTx.vhd:88
out pulse_oslv( L_G- 1 downto 0)
Definition: Jesd204bTx.vhd:104
array(natural range <> ) of jesdGtTxLaneType jesdGtTxLaneTypeArray
Definition: Jesd204bPkg.vhd:89
out axilReadSlaveAxiLiteReadSlaveType
Definition: Jesd204bTx.vhd:65
in devClk_isl
Definition: Jesd204bTx.vhd:75
in devRst_isl
Definition: Jesd204bTx.vhd:76
slv( 1 downto 0) := "10" AXI_RESP_SLVERR_C
Definition: AxiLitePkg.vhd:36
in axiRstsl
Definition: Jesd204bTx.vhd:61
out gtTxNslv( L_G- 1 downto 0)
in axiClksl
Definition: Jesd204bTx.vhd:60
out axilWriteSlaveTxAxiLiteWriteSlaveType
out leds_oslv( 1 downto 0)
SIM_Gboolean := false
AxiLiteReadMasterType
Definition: AxiLitePkg.vhd:59
in extSampleDataArray_isampleDataArray( L_G- 1 downto 0)
Definition: Jesd204bTx.vhd:85
in txAxisMasterArr_iAxiStreamMasterArray( L_G- 1 downto 0) :=( others => AXI_STREAM_MASTER_INIT_C)
Definition: Jesd204bTx.vhd:70
array(natural range <> ) of AxiStreamMasterType AxiStreamMasterArray
out gtTxPslv( L_G- 1 downto 0)
out pulse_oslv( L_G- 1 downto 0)
AxiLiteReadSlaveType
Definition: AxiLitePkg.vhd:85
array(natural range <> ) of slv( 4 downto 0) Slv5Array
Definition: StdRtlPkg.vhd:406
AXI_ERROR_RESP_Gslv( 1 downto 0) := AXI_RESP_SLVERR_C
Definition: Jesd204bTx.vhd:47
in axilWriteMasterAxiLiteWriteMasterType
Definition: Jesd204bTx.vhd:66
out leds_oslv( 1 downto 0)
Definition: Jesd204bTx.vhd:105
in gtTxReady_islv( L_G- 1 downto 0)
Definition: Jesd204bTx.vhd:89
out txAxisSlaveArr_oAxiStreamSlaveArray( L_G- 1 downto 0)
out axilWriteSlaveAxiLiteWriteSlaveType
Definition: Jesd204bTx.vhd:67
in axilWriteMasterTxAxiLiteWriteMasterType
_library_ unisimunisim
in extSampleDataArray_isampleDataArray( L_G- 1 downto 0)
AXI_ERROR_RESP_Gslv( 1 downto 0) := AXI_RESP_SLVERR_C
in sysRef_isl
Definition: Jesd204bTx.vhd:79
out txAxisSlaveArr_oAxiStreamSlaveArray( L_G- 1 downto 0)
Definition: Jesd204bTx.vhd:71
SYSREF_GEN_Gboolean := false
std_logic_vector slv
Definition: StdRtlPkg.vhd:29
in gtRxNslv( L_G- 1 downto 0)