1 ------------------------------------------------------
2 -- SLINK Optical interface sender
6 -- Dominique Gigi May 2015
7 ------------------------------------------------------
8 -- INstatiate the differents components for sender optical SLINK
9 -- 31 of the
"cmd" specifies
if it
is a write '1'
or a read '0'
10 -- Command DAQON/DAQOFF cmd = 0x10006 Func(
6) DT30 =
1 DAQ OFF =0 DAQON
11 -- DT31 = 1 TEST mode =0 No TEST mode
13 ------------------------------------------------------
15 USE ieee.std_logic_1164.
all;
16 use ieee.numeric_std.
all;
17 use ieee.std_logic_unsigned.
all;
27 LINKData : in (63 downto 0);
28 src_ID : in (15 downto 0);
29 inject_err : in (17 downto 0);
31 Addr : in (15 downto 0);
32 status_data : out (63 downto 0);
39 SD_Data_o : out (63 downto 0);
40 SD_Kb_o : out (7 downto 0);
42 SD_Data_i : in (63 downto 0);
43 SD_Kb_i : in (7 downto 0);
45 Serdes_status : in (31 downto 0)
53 generic (generator : := true);
60 LinkData :
in (
63 downto 0);
61 LinkAlmostFull :
out ;
63 src_ID :
in (
15 downto 0);
64 inject_err :
in (
17 downto 0);
66 addr :
in (
15 downto 0);
67 status_data :
out (
63 downto 0);
70 clock :
in ;
-- clock from internal logic
71 block_free :
in ;
-- almost one block is free
72 data_fed :
out (
63 downto 0);
73 block_sz_fed :
out (
15 downto 0);
79 func :
in (
31 downto 0);
80 data_wr :
in (
31 downto 0);
81 data_rd :
out (
63 downto 0);
82 cnt_evt :
out ;
-- pulse for each event (on sys_clk)
83 cnt_pckt_rcv :
in (
31 downto 0);
84 cnt_pckt_snd :
in (
31 downto 0);
87 status_state_build_p :
in (
31 downto 0);
88 status_state_core :
in (
31 downto 0);
89 Serdes_status :
in (
31 downto 0)
98 -- interface from the FED block
99 data_fed :
in (
63 downto 0);
103 block_sz_fed :
in (
15 downto 0);
106 src_ID :
in (
15 downto 0);
107 req_reset_resync :
out ;
108 -- interface to the SERDES OUT (send part)
109 start_pckt :
out ;
-- trigger the packet send
110 init_pckt :
out ;
-- indicates that the packet is a Init packet
111 ack_pckt :
out ;
-- indicates that the packet is a acknoldge packet
112 data_pckt :
out ;
-- indicates that the packet is a data packet
113 data_evt :
out (
63 downto 0);
--data for data packet
114 status :
out (
63 downto 0);
--read_bck for acknowledge packet
115 card_ID :
out (
15 downto 0);
-- CARD_ID
116 Seq_nb :
out (
30 downto 0);
-- sequence number
117 len_pckt :
out (
15 downto 0);
-- length of the packet (for data packet only) other 0
118 cmd :
out (
63 downto 0);
-- command for data packet only
123 -- interface to the SERDES IN (receiver part)
124 cmd_rcv :
in (
31 downto 0);
-- command from MOL
125 data_rcv :
in (
31 downto 0);
-- data from MOL
126 ena_cmd :
in ;
-- validate command
127 sta_dt :
in (
63 downto 0);
-- value return in an ack packet
129 seqnb_rcv :
in (
30 downto 0);
-- seq numb from cmd (need an ack)
130 card_ID_rcv :
in (
15 downto 0);
133 func :
out (
31 downto 0);
134 data_wr :
out (
31 downto 0);
135 data_rd :
in (
63 downto 0);
136 status_state :
out (
31 downto 0)
145 start_pckt :
in ;
-- trigger the packet send
146 init_pckt :
in ;
-- indicates that the packet is a Init packet
147 ack_pckt :
in ;
-- indicates that the packet is a acknoldge packet
148 data_pckt :
in ;
-- indicates that the packet is a data packet
149 data_evt :
in (
63 downto 0);
--data for data packet
150 read_bck :
in (
63 downto 0);
--data back for acknowledge packet
151 card_ID :
in (
15 downto 0);
-- CARD_ID
152 Seq_nb :
in (
30 downto 0);
-- sequence number
153 len_pckt :
in (
15 downto 0);
-- length of the packet (for data packet only) other 0
154 cmd :
in (
63 downto 0);
-- command for data packet only
155 error_gen :
in (
3 downto 0);
156 rd_dt :
out ;
-- request data for data packet only
158 datao :
out (
63 downto 0);
--- data and K send to SERDES
159 k_byte :
out (
7 downto 0);
161 cnt_pckt_snd :
out (
31 downto 0);
162 status_state :
out (
31 downto 0) );
170 data_i :
in (
63 downto 0);
171 ctrl_i :
in (
7 downto 0);
172 data_o :
out (
63 downto 0);
173 ctrl_o :
out (
7 downto 0)
185 datai :
in (
63 downto 0);
--- data and K send from SERDES
186 k_byte :
in (
7 downto 0);
188 cmd :
out (
31 downto 0);
-- command from MOL
189 data :
out (
31 downto 0);
-- data from MOL
190 ena_cmd :
out ;
-- validate command
191 status :
out (
63 downto 0);
-- value return from read command request
192 seqnb :
out (
30 downto 0);
-- seq numb from cmd (need an ack)
194 card_ID :
out (
15 downto 0);
195 cnt_pckt_rcv :
out (
31 downto 0) );
206 SIGNAL data_rcv :(31 downto 0);
208 SIGNAL sta_dt :(63 downto 0);
210 SIGNAL seqnb_rcv :(30 downto 0);
212 SIGNAL end_snd_pckt :;
214 SIGNAL cmd_rcv :(31 downto 0);
215 SIGNAL cmd :(63 downto 0);
216 SIGNAL len_pckt :(15 downto 0);
217 SIGNAL Seq_nb :(30 downto 0);
218 SIGNAL card_ID_rcv :(15 downto 0);
219 SIGNAL card_ID_snd :(15 downto 0);
220 SIGNAL read_bck :(63 downto 0);
221 SIGNAL data_evt :(63 downto 0);
226 SIGNAL end_blk_fed :;
230 SIGNAL block_sz_fed :(15 downto 0);
231 SIGNAL data_fed :(63 downto 0);
233 -- interface slave to read and write
235 SIGNAL func : (31 downto 0);
236 SIGNAL data_wr : (31 downto 0);
237 SIGNAL data_rd : (63 downto 0);
239 SIGNAL cnt_pckt_rcv : (31 downto 0);
240 SIGNAL cnt_pckt_snd : (31 downto 0);
241 SIGNAL status_state_build_p : (31 downto 0);
242 SIGNAL status_state_core : (31 downto 0);
244 SIGNAL DATAo_unswapped : (31 downto 0);
245 SIGNAL CTRLo_unswapped : ( 3 downto 0);
246 SIGNAL DATAi_unswapped : (31 downto 0);
247 SIGNAL CTRLi_unswapped : ( 3 downto 0);
248 SIGNAL req_reset_resync : ;
249 SIGNAL retransmit : ;
251 SIGNAL reg_datai : (63 downto 0);
252 SIGNAL req_uctrli : ;
258 SIGNAL GRst_sysckl : ;
259 SIGNAL GRst_T_ckl : ;
260 SIGNAL GRst_R_ckl : ;
261 SIGNAL Rst_sysckl : ;
264 SIGNAL LINKDown_s : ;
266 signal datai_aligned : (63 downto 0);
267 signal k_byte_aligned : (7 downto 0);
269 --******************************************************************
270 --******************* BEGIN **************************************
271 --******************************************************************
273 --#################################################
275 --#################################################
276 -- reset coming form FED
281 Reset_sync => Rst_sysckl
288 Reset_sync => Rst_T_ckl
295 Reset_sync => Rst_R_ckl
297 -- reset coming form FED or from DAQ
298 G_reset <= '0' when reset = '0' or req_reset_resync = '0' else '1';
304 Reset_sync => GRst_sysckl
311 Reset_sync => GRst_T_ckl
318 Reset_sync => GRst_R_ckl
320 --#################################################
321 -- registers FED interface
322 --#################################################
323 process(LINKDown_s,SYS_CLK)
325 if LINKDown_s = '0' then
327 elsif rising_edge(SYS_CLK) then
328 reg_datai <= LINKData;
329 req_uctrli <= LINKCtrl;
334 LINKDown <= LINKDown_s;
337 reset_sysCLK => Rst_sysckl,
338 Greset_sysCLK => GRst_sysckl,
341 LinkCtrl => req_uctrli,
342 LinkData => reg_datai,
343 LinkAlmostFull => LINK_LFF,
344 LinkDown => LINKDown_s,
346 inject_err => inject_err,
349 status_data => status_data,
350 reset_CLK => Rst_T_ckl,
351 Greset_CLK => GRst_T_ckl,
353 block_free => block_free,
354 data_fed => data_fed,
355 block_sz_fed => block_sz_fed,
357 start_evt => start_evt,
358 stop_evt => stop_evt,
359 end_blk_fed => end_blk_fed,
364 --cnt_evt => cnt_evt,
365 cnt_pckt_rcv => cnt_pckt_rcv,
366 cnt_pckt_snd => cnt_pckt_snd,
367 retransmit_ena => retransmit,
368 status_state_build_p => status_state_build_p,
369 status_state_core => status_state_core,
370 Serdes_status => Serdes_status
);
374 reset_clk => Rst_T_ckl,
375 Greset_clk => GRst_T_ckl,
377 -- interface from the FED block
378 data_fed => data_fed,
380 start_evt => start_evt,
381 stop_evt => stop_evt,
382 block_sz_fed => block_sz_fed,
383 end_blk_fed => end_blk_fed,
384 block_free => block_free,
386 req_reset_resync => req_reset_resync,
387 -- interface to the SERDES OUT (send part)
388 start_pckt => start_pckt,
389 init_pckt => init_pckt,
390 ack_pckt => ack_pckt,
391 data_pckt => data_pckt,
392 data_evt => data_evt,
394 card_ID => card_ID_snd,
396 len_pckt => len_pckt,
399 end_snd_pckt => end_snd_pckt,
400 idle_state => idle_state,
401 serdes_init => serdes_init,
402 -- interface to the SERDES IN (receiver part)
404 data_rcv => data_rcv,
408 seqnb_rcv => seqnb_rcv,
409 card_ID_rcv => card_ID_rcv,
410 retransmit => retransmit,
415 status_state => status_state_core
);
419 reset_CLK => Rst_T_ckl,
420 Greset_CLK => GRst_T_ckl,
422 start_pckt => start_pckt,
423 init_pckt => init_pckt,
424 ack_pckt => ack_pckt,
425 data_pckt => data_pckt,
426 data_evt => data_evt,
427 read_bck => read_bck,
428 card_ID => card_ID_snd,
430 len_pckt => len_pckt,
432 error_gen => inject_err
(4 downto 1),
434 end_pckt => end_snd_pckt,
438 idle_state => idle_state,
439 status_state => status_state_build_p,
440 cnt_pckt_snd => cnt_pckt_snd
);
449 data_o => datai_aligned,
450 ctrl_o => k_byte_aligned
455 reset_clk => Rst_R_ckl,
456 reset_clkT => Rst_T_ckl,
457 Greset_clk => GRst_R_ckl,
458 Greset_clkT => GRst_T_ckl,
461 datai => datai_aligned,
462 k_byte => k_byte_aligned,
463 error_gen => inject_err
(5),
470 card_ID => card_ID_rcv,
471 cnt_pckt_rcv => cnt_pckt_rcv
);