1 ------------------------------------------------------
2 -- SLINK Optical interface sender
6 -- Dominique Gigi Feb 2012
7 ------------------------------------------------------
8 -- INstatiate the differents components for sender optical SLINK
12 ------------------------------------------------------
18 USE ieee.std_logic_1164.
all;
19 use ieee.numeric_std.
all;
20 use ieee.std_logic_unsigned.
all;
22 -- USE lpm.lpm_components.all;
23 -- USE altera_mf.altera_mf_components.all;
24 -- USE altera.altera_primitives_components.all;
33 LINKData : in (63 downto 0);
34 src_ID : in (15 downto 0);
35 inject_err : in (17 downto 0);
37 Addr : in (15 downto 0);
38 status_data : out (63 downto 0);
45 SD_Data_o : out (31 downto 0);
46 SD_Kb_o : out (3 downto 0);
48 SD_Data_i : in (31 downto 0);
49 SD_Kb_i : in (3 downto 0);
50 Serdes_status : in (31 downto 0)
58 generic (generator : := true);
65 LinkData :
in (
63 downto 0);
66 LinkAlmostFull :
out ;
68 src_ID :
in (
15 downto 0);
69 inject_err :
in (
17 downto 0);
71 addr :
in (
15 downto 0);
72 status_data :
out (
63 downto 0);
75 clock :
in ;
-- clock from internal logic
76 block_free :
in ;
-- almost one block is free
77 data_fed :
out (
63 downto 0);
78 block_sz_fed :
out (
15 downto 0);
84 func :
in (
31 downto 0);
85 data_wr :
in (
31 downto 0);
86 data_rd :
out (
63 downto 0);
87 cnt_evt :
out ;
-- pulse for each event (on sys_clk)
88 cnt_pckt_rcv :
in (
31 downto 0);
89 cnt_pckt_snd :
in (
31 downto 0);
92 status_state_build_p :
in (
31 downto 0);
93 status_state_core :
in (
31 downto 0);
94 Serdes_status :
in (
31 downto 0)
103 -- interface from the FED block
104 data_fed :
in (
63 downto 0);
108 block_sz_fed :
in (
15 downto 0);
111 src_ID :
in (
15 downto 0);
112 req_reset_resync :
out ;
113 -- interface to the SERDES OUT (send part)
114 start_pckt :
out ;
-- trigger the packet send
115 init_pckt :
out ;
-- indicates that the packet is a Init packet
116 ack_pckt :
out ;
-- indicates that the packet is a acknoldge packet
117 data_pckt :
out ;
-- indicates that the packet is a data packet
118 data_evt :
out (
63 downto 0);
--data for data packet
119 status :
out (
63 downto 0);
--status data for acknowledge packet
120 card_ID :
out (
15 downto 0);
-- CARD_ID
121 Seq_nb :
out (
30 downto 0);
-- sequence number
122 len_pckt :
out (
15 downto 0);
-- length of the packet (for data packet only) other 0
123 cmd :
out (
63 downto 0);
-- command for data packet only
128 -- interface to the SERDES IN (receiver part)
129 cmd_rcv :
in (
31 downto 0);
-- command from MOL
130 data_rcv :
in (
31 downto 0);
-- data from MOL
131 ena_cmd :
in ;
-- validate command
132 sta_dt :
in (
63 downto 0);
-- value return in an ack packet
134 seqnb_rcv :
in (
30 downto 0);
-- seq numb from cmd (need an ack)
135 card_ID_rcv :
in (
15 downto 0);
138 func :
out (
31 downto 0);
139 data_wr :
out (
31 downto 0);
140 data_rd :
in (
63 downto 0);
141 status_state :
out (
31 downto 0)
151 start_pckt :
in ;
-- trigger the packet send
152 init_pckt :
in ;
-- indicates that the packet is a Init packet
153 ack_pckt :
in ;
-- indicates that the packet is a acknoldge packet
154 data_pckt :
in ;
-- indicates that the packet is a data packet
155 data_evt :
in (
63 downto 0);
--data for data packet
156 status :
in (
63 downto 0);
--status data for acknowledge packet
157 card_ID :
in (
15 downto 0);
-- CARD_ID
158 Seq_nb :
in (
30 downto 0);
-- sequence number
159 len_pckt :
in (
15 downto 0);
-- length of the packet (for data packet only) other 0
160 cmd :
in (
63 downto 0);
-- command for data packet only
161 error_gen :
in (
3 downto 0);
162 rd_dt :
out ;
-- request data for data packet only
165 datao :
out (
31 downto 0);
--- data and K send to SERDES
166 k_byte :
out (
3 downto 0);
168 cnt_pckt_snd :
out (
31 downto 0);
169 status_state :
out (
31 downto 0) );
181 datai :
in (
31 downto 0);
--- data and K send from SERDES
182 k_byte :
in (
3 downto 0);
186 cmd :
out (
31 downto 0);
-- command from MOL
187 data :
out (
31 downto 0);
-- data from MOL
188 ena_cmd :
out ;
-- validate command
190 status :
out (
63 downto 0);
-- value return from read command request
191 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) );
200 data_i :
in (
31 downto 0);
201 ctrl_i :
in (
3 downto 0);
203 data_o :
out (
31 downto 0);
204 ctrl_o :
out (
3 downto 0)
216 SIGNAL data_rcv : (31 downto 0);
218 SIGNAL sta_dt : (63 downto 0);
220 SIGNAL seqnb_rcv : (30 downto 0);
221 SIGNAL idle_state : ;
222 SIGNAL end_snd_pckt : ;
224 SIGNAL cmd_rcv : (31 downto 0);
225 SIGNAL cmd : (63 downto 0);
226 SIGNAL len_pckt : (15 downto 0);
227 SIGNAL Seq_nb : (30 downto 0);
228 SIGNAL card_ID_rcv : (15 downto 0);
229 SIGNAL card_ID_snd : (15 downto 0);
230 SIGNAL status : (63 downto 0);
231 SIGNAL data_evt : (63 downto 0);
235 SIGNAL start_pckt : ;
236 SIGNAL end_blk_fed : ;
240 SIGNAL block_sz_fed : (15 downto 0);
241 SIGNAL data_fed : (63 downto 0);
242 SIGNAL block_free : ;
243 -- interface slave to read and write
245 SIGNAL func : (31 downto 0);
246 SIGNAL data_wr : (31 downto 0);
247 SIGNAL data_rd : (63 downto 0);
249 SIGNAL cnt_pckt_rcv : (31 downto 0);
250 SIGNAL cnt_pckt_snd : (31 downto 0);
251 SIGNAL status_state_build_p : (31 downto 0);
252 SIGNAL status_state_core : (31 downto 0);
254 SIGNAL DATAo_unswapped : (31 downto 0);
255 SIGNAL CTRLo_unswapped : ( 3 downto 0);
256 SIGNAL DATAi_unswapped : (31 downto 0);
257 SIGNAL CTRLi_unswapped : ( 3 downto 0);
258 SIGNAL req_reset_resync : ;
259 SIGNAL retransmit : ;
262 SIGNAL reg_datai : (63 downto 0);
263 SIGNAL req_uctrli : ;
269 SIGNAL GRst_sysckl : ;
270 SIGNAL GRst_T_ckl : ;
271 SIGNAL GRst_R_ckl : ;
272 SIGNAL Rst_sysckl : ;
275 SIGNAL LINKDown_s : ;
276 --******************************************************************
277 --******************* BEGIN **************************************
278 --******************************************************************
281 --#################################################
283 --#################################################
284 -- reset coming form FED
289 Reset_sync => Rst_sysckl
296 Reset_sync => Rst_T_ckl
303 Reset_sync => Rst_R_ckl
305 -- reset coming form FED or from DAQ
306 G_reset <= '0' when reset = '0' or req_reset_resync = '0' else '1';
312 Reset_sync => GRst_sysckl
319 Reset_sync => GRst_T_ckl
326 Reset_sync => GRst_R_ckl
328 --#################################################
329 -- registers FED interface
330 --#################################################
331 process(LINKDown_s,SYS_CLK)
333 if LINKDown_s = '0' then
335 elsif rising_edge(SYS_CLK) then
336 reg_datai <= LINKData;
337 req_uctrli <= LINKCtrl;
342 LINKDown <= LINKDown_s;
346 reset_sysCLK => Rst_sysckl,
347 Greset_sysCLK => GRst_sysckl,
350 LinkCtrl => req_uctrli,
351 LinkData => reg_datai,
352 LinkAlmostFull => LINK_LFF,
353 LinkDown => LINKDown_s,
355 inject_err => inject_err,
358 status_data => status_data,
359 reset_CLK => Rst_T_ckl,
360 Greset_CLK => GRst_T_ckl,
362 block_free => block_free,
363 data_fed => data_fed,
364 block_sz_fed => block_sz_fed,
366 start_evt => start_evt,
367 stop_evt => stop_evt,
368 end_blk_fed => end_blk_fed,
373 --cnt_evt => cnt_evt,
374 cnt_pckt_rcv => cnt_pckt_rcv,
375 cnt_pckt_snd => cnt_pckt_snd,
376 retransmit_ena => retransmit,
377 status_state_build_p => status_state_build_p,
378 status_state_core => status_state_core,
379 Serdes_status => Serdes_status
);
383 reset_clk => Rst_T_ckl,
384 Greset_clk => GRst_T_ckl,
386 -- interface from the FED block
387 data_fed => data_fed,
389 start_evt => start_evt,
390 stop_evt => stop_evt,
391 block_sz_fed => block_sz_fed,
392 end_blk_fed => end_blk_fed,
393 block_free => block_free,
395 req_reset_resync => req_reset_resync,
396 -- interface to the SERDES OUT (send part)
397 start_pckt => start_pckt,
398 init_pckt => init_pckt,
399 ack_pckt => ack_pckt,
400 data_pckt => data_pckt,
401 data_evt => data_evt,
403 card_ID => card_ID_snd,
405 len_pckt => len_pckt,
408 end_snd_pckt => end_snd_pckt,
409 idle_state => idle_state,
410 serdes_init => serdes_init,
411 -- interface to the SERDES IN (receiver part)
413 data_rcv => data_rcv,
417 seqnb_rcv => seqnb_rcv,
418 card_ID_rcv => card_ID_rcv,
419 retransmit => retransmit,
424 status_state => status_state_core
);
428 reset_CLK => Rst_T_ckl,
429 Greset_CLK => GRst_T_ckl,
431 start_pckt => start_pckt,
432 init_pckt => init_pckt,
433 ack_pckt => ack_pckt,
434 data_pckt => data_pckt,
435 data_evt => data_evt,
437 card_ID => card_ID_snd,
439 len_pckt => len_pckt,
441 error_gen => inject_err
(4 downto 1),
443 end_pckt => end_snd_pckt,
445 datao => DATAo_unswapped,
446 k_byte => CTRLo_unswapped,
447 idle_state => idle_state,
448 status_state => status_state_build_p,
449 cnt_pckt_snd => cnt_pckt_snd
);
452 -- i_swapp:swapp_byte
454 -- data_i => DATAo_unswapped,
455 -- ctrl_i => CTRLo_unswapped,
456 -- data_o => SD_Data_o,
460 SD_Data_o <= DATAo_unswapped;
461 SD_Kb_o <= CTRLo_unswapped;
465 -- i_unswapp:swapp_byte
467 -- data_i => SD_Data_i,
468 -- ctrl_i => SD_Kb_i,
469 -- data_o => DATAi_unswapped,
470 -- ctrl_o => CTRLi_unswapped
473 DATAi_unswapped <= SD_Data_i;
474 CTRLi_unswapped <= SD_Kb_i;
478 reset_clk => Rst_R_ckl,
479 reset_clkT => Rst_T_ckl,
480 Greset_clk => GRst_R_ckl,
481 Greset_clkT => GRst_T_ckl,
484 datai => DATAi_unswapped,
485 k_byte => CTRLi_unswapped,
486 error_gen => inject_err
(5),
493 card_ID => card_ID_rcv,
494 cnt_pckt_rcv => cnt_pckt_rcv
);