1 ----------------------------------------------------------------------------------
5 -- Create Date: 14:
07:
47 10/07/2013
7 -- Module Name: TCPIP_if - Behavioral
16 -- Revision 0.
01 -
File Created
17 -- Additional Comments:
19 ----------------------------------------------------------------------------------
21 use IEEE.STD_LOGIC_1164.
ALL;
22 use IEEE.STD_LOGIC_ARITH.
ALL;
23 use IEEE.STD_LOGIC_UNSIGNED.
ALL;
24 use IEEE.std_logic_misc.
all;
25 use IEEE.numeric_std.
all;
28 -- Uncomment the following library declaration if using
29 -- arithmetic functions with or values
30 --use IEEE.NUMERIC_STD.ALL;
32 -- Uncomment the following library declaration if instantiating
33 -- any Xilinx primitives in this code.
35 use UNISIM.VComponents.
all;
37 use UNIMACRO.vcomponents.
all;
40 generic (simulation : := false;
en_KEEPALIVE : := '0');
48 enSFP : IN (3 downto 0);
49 SFP_down : OUT (2 downto 0);
52 evt_data_rdy : in (2 downto 0);
53 EventData_in : in array3X67;
54 EventData_we : in (2 downto 0);
55 EventData_re : out (2 downto 0);
--
56 evt_buf_full : out (2 downto 0);
57 buf_rqst : in (3 downto 0);
59 MonBufOverWrite : in ;
64 mon_evt_cnt : out (31 downto 0);
65 WrtMonBlkDone : in (2 downto 0);
66 WrtMonEvtDone : in (2 downto 0);
67 KiloByte_toggle : in (2 downto 0);
68 EoB_toggle : in (2 downto 0);
70 wport_rdy : in (2 downto 0);
71 wport_FIFO_full : in (2 downto 0);
72 -- signal to ddr_if, AMC_if to start moving data
73 EventBufAddr_we : out (2 downto 0);
74 EventBufAddr : out array3X14;
75 -- ddr wportB signals in sysclk domain
77 TCP_dout : out (31 downto 0);
-- TCP data are written in unit of 32-bit words
78 TCP_channel : out (1 downto 0);
-- Each entry has four 32bit words, each address saves two entries. Addresses are kept in ddr_wportB
80 TCP_wcount : in (2 downto 0);
82 TCP_raddr : out (28 downto 0);
-- 28-26 encoded request source 25-0 address in 64 word
83 TCP_length : out (10 downto 0);
-- in 64 word, actual length -
1
86 TCP_din_type : in (2 downto 0);
-- TCP data destination
87 TCP_din : in (31 downto 0);
-- TCP data are written in unit of 32-bit words
105 cs_out : out (511 downto 0);
110 ipb_addr : in (31 downto 0);
111 ipb_wdata : in (31 downto 0);
112 ipb_rdata : out (31 downto 0)
118 generic (simulation : := false; en_KEEPALIVE : := '
0');
128 -- IP_ID : IN (15 downto 0);
129 MY_PORT :
IN (
15 downto 0);
130 MY_IP :
IN (
31 downto 0);
131 MY_ETH :
IN (
47 downto 0);
132 CWND_max :
IN (
31 downto 0);
133 TSclock :
IN (
31 downto 0);
134 EVENTdata :
IN (
66 downto 0);
135 EventBufAddr :
IN (
13 downto 0);
136 EventBufAddr_we :
IN ;
139 DDR2TCPdata :
IN (
32 downto 0);
140 RETXdata_we :
IN (
1 downto 0);
141 RETXdata_chksum :
IN (
15 downto 0);
142 re_RETX_ddr_wq :
IN ;
143 RETX_ddr_data_we :
IN ;
145 KiloByte_toggle :
in ;
148 PhyEmacRxC :
IN (
3 downto 0);
149 PhyEmacRxD :
IN (
31 downto 0);
152 RETX_ddr_out :
OUT (
31 downto 0);
153 RETX_ddr_wrqst :
OUT ;
154 RETX_ddr_LEN_max :
IN (
4 downto 0);
155 RETX_ddr_LEN :
OUT (
4 downto 0);
156 RETX_ddr_rrqst :
OUT ;
158 RETXdataAddr :
OUT (
25 downto 0);
159 RETXdataLEN :
OUT (
10 downto 0);
160 UNA_MonBuf :
OUT (
10 downto 0);
161 UNA_TCPBuf :
OUT (
10 downto 0);
162 EmacPhyTxC :
OUT (
3 downto 0);
163 EmacPhyTxD :
OUT (
31 downto 0);
164 ipb_addr :
in (
31 downto 0);
165 ipb_rdata :
out (
31 downto 0);
166 cs_out :
OUT (
511 downto 0)
180 GTX_TXD :
OUT (
31 downto 0);
181 GTX_TXHEADER :
OUT (
1 downto 0);
183 GTX_RXD :
IN (
31 downto 0);
185 GTX_RXHEADER :
IN (
1 downto 0);
186 GTX_RXHEADERVLD :
IN ;
188 GTX_RXGEARBOXSLIP_OUT :
OUT ;
189 EmacPhyTxC :
IN (
3 downto 0);
190 EmacPhyTxD :
IN (
31 downto 0);
191 PhyEmacRxC :
OUT (
3 downto 0);
192 PhyEmacRxD :
OUT (
31 downto 0)
206 EXAMPLE_SIM_GTRESET_SPEEDUP : :=
"TRUE";
-- simulation setting for GT SecureIP model
207 EXAMPLE_SIMULATION : :=
0;
-- Set to 1 for simulation
208 STABLE_CLOCK_PERIOD : :=
20;
--Period of the stable clock driving this state-machine, unit is [ns]
209 EXAMPLE_USE_CHIPSCOPE : :=
0 -- Set to 1 to use Chipscope
to drive resets
216 DONT_RESET_ON_DATA_ERROR_IN :
in ;
217 GT0_TX_FSM_RESET_DONE_OUT :
out ;
218 GT0_RX_FSM_RESET_DONE_OUT :
out ;
219 GT0_DATA_VALID_IN :
in ;
220 GT1_TX_FSM_RESET_DONE_OUT :
out ;
221 GT1_RX_FSM_RESET_DONE_OUT :
out ;
222 GT1_DATA_VALID_IN :
in ;
223 GT2_TX_FSM_RESET_DONE_OUT :
out ;
224 GT2_RX_FSM_RESET_DONE_OUT :
out ;
225 GT2_DATA_VALID_IN :
in ;
227 --_________________________________________________________________________
229 --____________________________CHANNEL PORTS________________________________
230 ---------------------------- Channel - DRP Ports --------------------------
231 GT0_DRPADDR_IN :
in (
8 downto 0);
233 GT0_DRPDI_IN :
in (
15 downto 0);
234 GT0_DRPDO_OUT :
out (
15 downto 0);
236 GT0_DRPRDY_OUT :
out ;
238 ------------------------------- Loopback Ports -----------------------------
239 GT0_LOOPBACK_IN :
in (
2 downto 0);
240 ------------------------------ Power-Down Ports ----------------------------
241 GT0_RXPD_IN :
in (
1 downto 0);
242 GT0_TXPD_IN :
in (
1 downto 0);
243 --------------------- RX Initialization and Reset Ports --------------------
244 GT0_RXUSERRDY_IN :
in ;
245 -------------------------- RX Margin Analysis Ports ------------------------
246 GT0_EYESCANDATAERROR_OUT :
out ;
247 ------------------------- Receive Ports - CDR Ports ------------------------
248 GT0_RXCDRLOCK_OUT :
out ;
249 ------------------ Receive Ports - FPGA RX Interface Ports -----------------
250 GT0_RXUSRCLK_IN :
in ;
251 GT0_RXUSRCLK2_IN :
in ;
252 ------------------ Receive Ports - FPGA RX interface Ports -----------------
253 GT0_RXDATA_OUT :
out (
31 downto 0);
254 ------------------- Receive Ports - Pattern Checker Ports ------------------
255 GT0_RXPRBSERR_OUT :
out ;
256 GT0_RXPRBSSEL_IN :
in (
2 downto 0);
257 ------------------- Receive Ports - Pattern Checker ports ------------------
258 GT0_RXPRBSCNTRESET_IN :
in ;
259 --------------------------- Receive Ports - RX AFE -------------------------
261 ------------------------ Receive Ports - RX AFE Ports ----------------------
263 ------------------- Receive Ports - RX Buffer Bypass Ports -----------------
264 GT0_RXBUFRESET_IN :
in ;
265 GT0_RXBUFSTATUS_OUT :
out (
2 downto 0);
266 --------------- Receive Ports - RX Fabric Output Control Ports -------------
267 GT0_RXOUTCLK_OUT :
out ;
268 ---------------------- Receive Ports - RX Gearbox Ports --------------------
269 GT0_RXDATAVALID_OUT :
out ;
270 GT0_RXHEADER_OUT :
out (
1 downto 0);
271 GT0_RXHEADERVALID_OUT :
out ;
272 --------------------- Receive Ports - RX Gearbox Ports --------------------
273 GT0_RXGEARBOXSLIP_IN :
in ;
274 ------------- Receive Ports - RX Initialization and Reset Ports ------------
275 GT0_GTRXRESET_IN :
in ;
276 GT0_RXPMARESET_IN :
in ;
277 ------------------ Receive Ports - RX Margin Analysis ports ----------------
278 GT0_RXLPMEN_IN :
in ;
279 -------------- Receive Ports -RX Initialization and Reset Ports ------------
280 GT0_RXRESETDONE_OUT :
out ;
281 --------------------- TX Initialization and Reset Ports --------------------
282 GT0_GTTXRESET_IN :
in ;
283 GT0_TXUSERRDY_IN :
in ;
284 ------------------ Transmit Ports - FPGA TX Interface Ports ----------------
285 GT0_TXUSRCLK_IN :
in ;
286 GT0_TXUSRCLK2_IN :
in ;
287 --------------- Transmit Ports - TX Configurable Driver Ports --------------
288 GT0_TXDIFFCTRL_IN :
in (
3 downto 0);
289 GT0_TXINHIBIT_IN :
in ;
290 GT0_TXMAINCURSOR_IN :
in (
6 downto 0);
291 ------------------ Transmit Ports - TX Data Path interface -----------------
292 GT0_TXDATA_IN :
in (
31 downto 0);
293 ---------------- Transmit Ports - TX Driver and OOB signaling --------------
294 GT0_GTXTXN_OUT :
out ;
295 GT0_GTXTXP_OUT :
out ;
296 ----------- Transmit Ports - TX Fabric Clock Output Control Ports ----------
297 GT0_TXOUTCLK_OUT :
out ;
298 GT0_TXOUTCLKFABRIC_OUT :
out ;
299 GT0_TXOUTCLKPCS_OUT :
out ;
300 --------------------- Transmit Ports - TX Gearbox Ports --------------------
301 GT0_TXHEADER_IN :
in (
1 downto 0);
302 GT0_TXSEQUENCE_IN :
in (
6 downto 0);
303 ------------- Transmit Ports - TX Initialization and Reset Ports -----------
304 GT0_TXRESETDONE_OUT :
out ;
305 ------------------ Transmit Ports - pattern Generator Ports ----------------
306 GT0_TXPRBSSEL_IN :
in (
2 downto 0);
309 --____________________________CHANNEL PORTS________________________________
310 ---------------------------- Channel - DRP Ports --------------------------
311 GT1_DRPADDR_IN :
in (
8 downto 0);
313 GT1_DRPDI_IN :
in (
15 downto 0);
314 GT1_DRPDO_OUT :
out (
15 downto 0);
316 GT1_DRPRDY_OUT :
out ;
318 ------------------------------- Loopback Ports -----------------------------
319 GT1_LOOPBACK_IN :
in (
2 downto 0);
320 ------------------------------ Power-Down Ports ----------------------------
321 GT1_RXPD_IN :
in (
1 downto 0);
322 GT1_TXPD_IN :
in (
1 downto 0);
323 --------------------- RX Initialization and Reset Ports --------------------
324 GT1_RXUSERRDY_IN :
in ;
325 -------------------------- RX Margin Analysis Ports ------------------------
326 GT1_EYESCANDATAERROR_OUT :
out ;
327 ------------------------- Receive Ports - CDR Ports ------------------------
328 GT1_RXCDRLOCK_OUT :
out ;
329 ------------------ Receive Ports - FPGA RX Interface Ports -----------------
330 GT1_RXUSRCLK_IN :
in ;
331 GT1_RXUSRCLK2_IN :
in ;
332 ------------------ Receive Ports - FPGA RX interface Ports -----------------
333 GT1_RXDATA_OUT :
out (
31 downto 0);
334 ------------------- Receive Ports - Pattern Checker Ports ------------------
335 GT1_RXPRBSERR_OUT :
out ;
336 GT1_RXPRBSSEL_IN :
in (
2 downto 0);
337 ------------------- Receive Ports - Pattern Checker ports ------------------
338 GT1_RXPRBSCNTRESET_IN :
in ;
339 --------------------------- Receive Ports - RX AFE -------------------------
341 ------------------------ Receive Ports - RX AFE Ports ----------------------
343 ------------------- Receive Ports - RX Buffer Bypass Ports -----------------
344 GT1_RXBUFRESET_IN :
in ;
345 GT1_RXBUFSTATUS_OUT :
out (
2 downto 0);
346 --------------- Receive Ports - RX Fabric Output Control Ports -------------
347 GT1_RXOUTCLK_OUT :
out ;
348 ---------------------- Receive Ports - RX Gearbox Ports --------------------
349 GT1_RXDATAVALID_OUT :
out ;
350 GT1_RXHEADER_OUT :
out (
1 downto 0);
351 GT1_RXHEADERVALID_OUT :
out ;
352 --------------------- Receive Ports - RX Gearbox Ports --------------------
353 GT1_RXGEARBOXSLIP_IN :
in ;
354 ------------- Receive Ports - RX Initialization and Reset Ports ------------
355 GT1_GTRXRESET_IN :
in ;
356 GT1_RXPMARESET_IN :
in ;
357 ------------------ Receive Ports - RX Margin Analysis ports ----------------
358 GT1_RXLPMEN_IN :
in ;
359 -------------- Receive Ports -RX Initialization and Reset Ports ------------
360 GT1_RXRESETDONE_OUT :
out ;
361 --------------------- TX Initialization and Reset Ports --------------------
362 GT1_GTTXRESET_IN :
in ;
363 GT1_TXUSERRDY_IN :
in ;
364 ------------------ Transmit Ports - FPGA TX Interface Ports ----------------
365 GT1_TXUSRCLK_IN :
in ;
366 GT1_TXUSRCLK2_IN :
in ;
367 --------------- Transmit Ports - TX Configurable Driver Ports --------------
368 GT1_TXDIFFCTRL_IN :
in (
3 downto 0);
369 GT1_TXINHIBIT_IN :
in ;
370 GT1_TXMAINCURSOR_IN :
in (
6 downto 0);
371 ------------------ Transmit Ports - TX Data Path interface -----------------
372 GT1_TXDATA_IN :
in (
31 downto 0);
373 ---------------- Transmit Ports - TX Driver and OOB signaling --------------
374 GT1_GTXTXN_OUT :
out ;
375 GT1_GTXTXP_OUT :
out ;
376 ----------- Transmit Ports - TX Fabric Clock Output Control Ports ----------
377 GT1_TXOUTCLK_OUT :
out ;
378 GT1_TXOUTCLKFABRIC_OUT :
out ;
379 GT1_TXOUTCLKPCS_OUT :
out ;
380 --------------------- Transmit Ports - TX Gearbox Ports --------------------
381 GT1_TXHEADER_IN :
in (
1 downto 0);
382 GT1_TXSEQUENCE_IN :
in (
6 downto 0);
383 ------------- Transmit Ports - TX Initialization and Reset Ports -----------
384 GT1_TXRESETDONE_OUT :
out ;
385 ------------------ Transmit Ports - pattern Generator Ports ----------------
386 GT1_TXPRBSSEL_IN :
in (
2 downto 0);
389 --____________________________CHANNEL PORTS________________________________
390 ---------------------------- Channel - DRP Ports --------------------------
391 GT2_DRPADDR_IN :
in (
8 downto 0);
393 GT2_DRPDI_IN :
in (
15 downto 0);
394 GT2_DRPDO_OUT :
out (
15 downto 0);
396 GT2_DRPRDY_OUT :
out ;
398 ------------------------------- Loopback Ports -----------------------------
399 GT2_LOOPBACK_IN :
in (
2 downto 0);
400 ------------------------------ Power-Down Ports ----------------------------
401 GT2_RXPD_IN :
in (
1 downto 0);
402 GT2_TXPD_IN :
in (
1 downto 0);
403 --------------------- RX Initialization and Reset Ports --------------------
404 GT2_RXUSERRDY_IN :
in ;
405 -------------------------- RX Margin Analysis Ports ------------------------
406 GT2_EYESCANDATAERROR_OUT :
out ;
407 ------------------------- Receive Ports - CDR Ports ------------------------
408 GT2_RXCDRLOCK_OUT :
out ;
409 ------------------ Receive Ports - FPGA RX Interface Ports -----------------
410 GT2_RXUSRCLK_IN :
in ;
411 GT2_RXUSRCLK2_IN :
in ;
412 ------------------ Receive Ports - FPGA RX interface Ports -----------------
413 GT2_RXDATA_OUT :
out (
31 downto 0);
414 ------------------- Receive Ports - Pattern Checker Ports ------------------
415 GT2_RXPRBSERR_OUT :
out ;
416 GT2_RXPRBSSEL_IN :
in (
2 downto 0);
417 ------------------- Receive Ports - Pattern Checker ports ------------------
418 GT2_RXPRBSCNTRESET_IN :
in ;
419 --------------------------- Receive Ports - RX AFE -------------------------
421 ------------------------ Receive Ports - RX AFE Ports ----------------------
423 ------------------- Receive Ports - RX Buffer Bypass Ports -----------------
424 GT2_RXBUFRESET_IN :
in ;
425 GT2_RXBUFSTATUS_OUT :
out (
2 downto 0);
426 --------------- Receive Ports - RX Fabric Output Control Ports -------------
427 GT2_RXOUTCLK_OUT :
out ;
428 ---------------------- Receive Ports - RX Gearbox Ports --------------------
429 GT2_RXDATAVALID_OUT :
out ;
430 GT2_RXHEADER_OUT :
out (
1 downto 0);
431 GT2_RXHEADERVALID_OUT :
out ;
432 --------------------- Receive Ports - RX Gearbox Ports --------------------
433 GT2_RXGEARBOXSLIP_IN :
in ;
434 ------------- Receive Ports - RX Initialization and Reset Ports ------------
435 GT2_GTRXRESET_IN :
in ;
436 GT2_RXPMARESET_IN :
in ;
437 ------------------ Receive Ports - RX Margin Analysis ports ----------------
438 GT2_RXLPMEN_IN :
in ;
439 -------------- Receive Ports -RX Initialization and Reset Ports ------------
440 GT2_RXRESETDONE_OUT :
out ;
441 --------------------- TX Initialization and Reset Ports --------------------
442 GT2_GTTXRESET_IN :
in ;
443 GT2_TXUSERRDY_IN :
in ;
444 ------------------ Transmit Ports - FPGA TX Interface Ports ----------------
445 GT2_TXUSRCLK_IN :
in ;
446 GT2_TXUSRCLK2_IN :
in ;
447 --------------- Transmit Ports - TX Configurable Driver Ports --------------
448 GT2_TXDIFFCTRL_IN :
in (
3 downto 0);
449 GT2_TXINHIBIT_IN :
in ;
450 GT2_TXMAINCURSOR_IN :
in (
6 downto 0);
451 ------------------ Transmit Ports - TX Data Path interface -----------------
452 GT2_TXDATA_IN :
in (
31 downto 0);
453 ---------------- Transmit Ports - TX Driver and OOB signaling --------------
454 GT2_GTXTXN_OUT :
out ;
455 GT2_GTXTXP_OUT :
out ;
456 ----------- Transmit Ports - TX Fabric Clock Output Control Ports ----------
457 GT2_TXOUTCLK_OUT :
out ;
458 GT2_TXOUTCLKFABRIC_OUT :
out ;
459 GT2_TXOUTCLKPCS_OUT :
out ;
460 --------------------- Transmit Ports - TX Gearbox Ports --------------------
461 GT2_TXHEADER_IN :
in (
1 downto 0);
462 GT2_TXSEQUENCE_IN :
in (
6 downto 0);
463 ------------- Transmit Ports - TX Initialization and Reset Ports -----------
464 GT2_TXRESETDONE_OUT :
out ;
465 ------------------ Transmit Ports - pattern Generator Ports ----------------
466 GT2_TXPRBSSEL_IN :
in (
2 downto 0);
469 --____________________________COMMON PORTS________________________________
470 ---------------------- Common Block - Ref Clock Ports ---------------------
471 GT0_GTREFCLK0_COMMON_IN :
in ;
472 ------------------------- Common Block - QPLL Ports ------------------------
473 GT0_QPLLLOCK_OUT :
out ;
474 GT0_QPLLLOCKDETCLK_IN :
in ;
475 GT0_QPLLRESET_IN :
in
485 d :
IN (
31 downto 0);
486 s :
OUT (
15 downto 0)
493 en_stop :
IN (
4 downto 0);
494 cmsCRC_err :
IN (
2 downto 0);
495 EventData_in :
IN array3X67;
496 EventData_we :
IN (
2 downto 0);
497 inc_err :
OUT array3X5;
505 di :
IN (
5 downto 0);
507 wa :
IN (
4 downto 0);
508 ra :
IN (
4 downto 0);
510 do :
OUT (
5 downto 0)
516 di :
IN (
5 downto 0);
518 wa :
IN (
4 downto 0);
519 ra :
IN (
4 downto 0);
520 do :
OUT (
5 downto 0)
529 crc_d :
IN (
63 downto 0);
531 crc :
OUT (
15 downto 0);
533 dout :
OUT (
63 downto 0);
537 signal resetSyncRegs : (2 downto 0) := (others => '0');
538 signal ClientClk2XresetSyncRegs : (2 downto 0) := (others => '0');
539 signal refclk : := '0';
540 signal REFCLK2XPLLRST : := '0';
541 signal refclk2x_in : := '0';
542 signal ClientClk2x_dcm : := '0';
543 signal ClientClk2x : := '0';
544 signal ClientClk_dcm : := '0';
545 signal ClientClk : := '0';
546 signal ClientClk_lock : := '0';
547 signal ClientClkToggle : := '0';
548 signal ClientClkToggle_q : := '0';
549 signal FIFO_rst : := '0';
550 --signal reset_dl : := '0';
551 signal FIFO_en : := '0';
552 signal TX_high : := '0';
553 signal us_cntr : (9 downto 0) := (others => '0');
554 signal ms_cntr : (10 downto 0) := (others => '0');
555 signal strobe_us : := '0';
556 signal strobe_ms : := '0';
557 signal TSclock : (31 downto 0) := (others => '0');
558 signal evt_FIFO_full : (2 downto 0) := (others => '0');
559 signal evt_FIFO_empty : (2 downto 0) := (others => '0');
560 signal evt_FIFO_we : (2 downto 0) := (others => '0');
561 signal evt_FIFO_re : (2 downto 0) := (others => '0');
562 signal evt_FIFO_rep : (2 downto 0) := (others => '0');
563 signal evt_FIFO_data_avl : (2 downto 0) := (others => '0');
564 signal evt_FIFO_di : array3X67 := (others => (others => '0'));
565 signal evt_FIFO_do : array3X67 := (others => (others => '0'));
566 signal evt_FIFO_RDCOUNT : array3X9 := (others => (others => '0'));
567 signal evt_FIFO_WRCOUNT : array3X9 := (others => (others => '0'));
568 signal EVENTdata_avl : (2 downto 0) := (others => '0');
569 signal EVENTdata_addr : array3X13 := (others => (others => '0'));
570 signal re_RETX_ddr_wq : (2 downto 0) := (others => '0');
571 signal RETX_ddr_data_we : (2 downto 0) := (others => '0');
572 signal RETX_ddr_wrqst : (2 downto 0) := (others => '0');
573 signal RETX_ddr_rrqst : (2 downto 0) := (others => '0');
574 signal RETX_ddr_out : array3X32 := (others => (others => '0'));
575 signal RETX_ddr_LEN_max : array3X5 := (others => (others => '0'));
576 signal RETX_ddr_LEN : array3X5 := (others => (others => '0'));
577 signal RETXdata_we : array3X2 := (others => (others => '0'));
578 signal DDR2TCPdata : (32 downto 0) := (others => '0');
579 signal rst_RETXdata_chksum : := '0';
580 signal RETXdata_chksum_out : (15 downto 0) := (others => '0');
581 signal RETXdata_checksum : array3x16 := (others => (others => '0'));
582 signal RETXdataLEN : array3X11 := (others => (others => '0'));
583 signal RETXdataAddr : array3X26 := (others => (others => '0'));
584 signal RETXdata_space : (2 downto 0) := (others => '0');
585 signal RETXdataRqst : (2 downto 0) := (others => '0');
586 signal RETXdataACK : (2 downto 0) := (others => '0');
587 signal ReleaseLen : array3X11 := (others => (others => '0'));
588 signal Release_space : (2 downto 0) := (others => '0');
589 signal ReleaseBuffer : (2 downto 0) := (others => '0');
590 signal Release_rqst: (2 downto 0) := (others => '0');
591 signal rrqstMask : (5 downto 0) := (others => '0');
592 signal TCP_rrqst_i : (2 downto 0) := (others => '0');
594 signal rst_odd : := '0';
595 --signal DDR2TCPdata_vld : := '0';
596 signal TCP_rFIFO_do_vld : := '0';
597 signal ld_RETXdata_chksum : (2 downto 0) := (others => '0');
598 signal ld_RETXdata_chksum_r : (2 downto 0) := (others => '0');
599 signal ld_RETXdata_chksum_r2 : (2 downto 0) := (others => '0');
600 signal TCP_rFIFO_wa0SyncRegs : (3 downto 0) := (others => '0');
601 signal TCP_rFIFO_wa1SyncRegs : (3 downto 0) := (others => '0');
602 signal TCP_rFIFO_wa2SyncRegs : (3 downto 0) := (others => '0');
603 signal TCP_rFIFO_di : (35 downto 0) := (others => '0');
604 signal TCP_rFIFO_do : (35 downto 0) := (others => '0');
605 signal TCP_rFIFO_wa : (4 downto 0) := (others => '0');
606 signal TCP_rFIFO_ra : (4 downto 0) := (others => '0');
607 signal RETX_ddr_rp_rst : := '0';
608 signal RETX_ddr_rp_we : := '0';
609 signal RETX_ddr_rp_di : (17 downto 0) := (others => '0');
610 signal RETX_ddr_rp_do : (17 downto 0) := (others => '0');
611 signal RETX_ddr_rp_a : (4 downto 0) := (others => '0');
612 signal TCP_length_i : (20 downto 0) := (others => '0');
613 signal TCP_raddr_i : (28 downto 0) := (others => '0');
614 signal TCP_rlength : (10 downto 0) := (others => '0');
615 --signal rdDDRqueue_we : := '0';
616 --signal rdDDRqueue_re : := '0';
617 --signal rdDDRqueue_a : (2 downto 0) := (
others => '0');
618 --signal rdDDRqueue_di : (2 downto 0) := (
others => '0');
619 --signal rdDDRqueue_do : (2 downto 0) := (
others => '0');
620 --signal rdDDRqueue_dout : (2 downto 0) := (
others => '0');
621 --signal rdDDRqueue_dout_vld : := '0';
622 signal TCP_wFIFO_re : := '0';
623 signal TCP_w_busy : := '0';
624 signal TCP_wFIFO_we : := '0';
625 signal TCP_w_sel : (1 downto 0) := (others => '0');
626 signal TCP_w_wc : (3 downto 0) := (others => '0');
627 signal TCP_wFIFO_DI : (33 downto 0) := (others => '0');
628 signal TCP_wFIFO_DO : (33 downto 0) := (others => '0');
629 signal TCP_wFIFO_RDCOUNT : (8 downto 0) := (others => '0');
630 signal TCP_wFIFO_WRCOUNT : (8 downto 0) := (others => '0');
631 signal inh_TX : (2 downto 0) := (others => '0');
632 signal inh_TX_q : (2 downto 0) := (others => '0');
633 signal reset_TXSyncRegs : (2 downto 0) := (others => '0');
634 signal SFP_TXOUTCLK : (2 downto 0) := (others => '0');
635 signal txusrclk : := '0';
636 signal qplllock : := '0';
637 signal qpllreset : := '0';
638 signal GTX_TX_READ : := '0';
639 signal LINK_down : (2 downto 0) := (others => '0');
640 signal EnTCPIP : (2 downto 0) := (others => '0');
641 signal SFP_rxoutclk : (2 downto 0) := (others => '0');
642 signal SFP_rxusrclk : (2 downto 0) := (others => '0');
643 signal SFP_txresetdone : (2 downto 0) := (others => '0');
644 signal SFP_gttxreset : (2 downto 0) := (others => '0');
645 signal SFP_txuserrdy : (2 downto 0) := (others => '0');
646 signal SFP_rxresetdone : (2 downto 0) := (others => '0');
647 signal SFP_gtrxreset : (2 downto 0) := (others => '0');
648 signal SFP_rxuserrdy : (2 downto 0) := (others => '0');
649 signal SFP_drprdy : (2 downto 0) := (others => '0');
650 signal SFP_drpen : (2 downto 0) := (others => '0');
651 signal SFP_drpwe : (2 downto 0) := (others => '0');
652 signal SFP_rxdfeagchold : (2 downto 0) := (others => '0');
653 signal SFP_adapt_done : (2 downto 0) := (others => '0');
654 signal SFP_rxmonitor : array3X7 := (others => (others => '0'));
655 signal SFP_drpdo : array3X16 := (others => (others => '0'));
656 signal SFP_rxmonitorsel : array3X2 := (others => (others => '0'));
657 signal SFP_drpaddr : array3X9 := (others => (others => '0'));
658 signal SFP_drpdi : array3X16 := (others => (others => '0'));
659 signal SFP_RX_FSM_RESET_DONE : (2 downto 0) := (others => '0');
660 signal SFP_TX_FSM_RESET_DONE : (2 downto 0) := (others => '0');
661 signal SFP_RXDVLD : (2 downto 0) := (others => '0');
662 signal SFP_RXHEADERVLD : (2 downto 0) := (others => '0');
663 signal SFP_RXGEARBOXSLIP : (2 downto 0) := (others => '0');
664 signal SFP_RXGOOD : (2 downto 0) := (others => '0');
665 signal SFP_TXD : array3X32 := (others => (others => '0'));
666 signal SFP_TXD_inv : array3X32 := (others => (others => '0'));
667 signal SFP_TXHEADER : array3X2 := (others => (others => '0'));
668 signal SFP_RXD : array3X32 := (others => (others => '0'));
669 signal SFP_RXD_inv : array3X32 := (others => (others => '0'));
670 signal SFP_RXHEADER : array3X2 := (others => (others => '0'));
671 signal SFP_EmacPhyTxD : array3X32 := (others => (others => '0'));
672 signal SFP_EmacPhyTxC : array3X4 := (others => (others => '0'));
673 signal SFP_PhyEmacRxD : array3X32 := (others => (others => '0'));
674 signal SFP_PhyEmacRxC : array3X4 := (others => (others => '0'));
675 signal EmacPhyTxD : array3X32 := (others => (others => '0'));
676 signal EmacPhyTxC : array3X4 := (others => (others => '0'));
677 signal PhyEmacRxD : array3X32 := (others => (others => '0'));
678 signal PhyEmacRxC : array3X4 := (others => (others => '0'));
679 signal TCPIP2SFP_sel : array3X2 := (others => (others => '0'));
680 signal SFP2TCPIP : array3X2 := (others => (others => '0'));
681 signal IPADDR : array3X32 := (others => (others => '0'));
682 signal SFP_IPADDR : array3X32 := (x"c0a80120",x"c0a80121",x"c0a80122");
683 signal CWND_max : (31 downto 0) := x"0fffffff";
684 signal MACADDR : array3X48 := (others => (others => '0'));
685 signal GTX_TX_PAUSE : := '0';
686 signal TXSEQ_cntr : (6 downto 0) := (others => '0');
687 signal SFP_TXSEQUENCE : array3X7 := (others => (others => '0'));
688 signal SFP_LOOPBACK_IN : array3X3 := (others => (others => '0'));
689 signal SFP_RXPRBSERR_OUT : (2 downto 0) := (others => '0');
690 signal SFP_RXPRBSSEL_IN : array3X3 := (others => (others => '0'));
691 signal SFP_TXPRBSSEL_IN : array3X3 := (others => (others => '0'));
692 signal SFP_EYESCANDATAERROR_OUT : (2 downto 0) := (others => '0');
693 signal got_eofToggle : (2 downto 0) := (others => '0');
694 signal EventBufAddr_we_i : (2 downto 0) := (others => '0');
695 signal EventData_re_i : (2 downto 0) := (others => '0');
696 signal EventBufAddr_i : array3X14 := (others => (others => '0'));
697 signal ReadBusy : (2 downto 0) := (others => '0');
698 signal UNA_MonBufMatch : (3 downto 0) := (others => '0');
699 signal UNA_TCPBufMatch : (2 downto 0) := (others => '0');
700 signal UNA_MonBufSyncRegs : (3 downto 0) := (others => '0');
701 signal UNA_TCPBufSyncRegs : (3 downto 0) := (others => '0');
702 signal inc_ddr_paSyncRegs : (3 downto 0) := (others => '0');
703 signal sysDIV2 : := '0';
704 signal evt_FIFO_sel : := '0';
705 signal ReleaseMonBuf : := '0';
706 signal ReleaseTCPBuf : := '0';
707 signal WrtMonBufAllDone_i : := '0';
708 --signal TCPBufCnt : (12 downto 0) := (
others => '0');
709 --signal MonBufCnt : (12 downto 0) := (
others => '0');
710 signal NXT_TCPBuf : array3X12 := (others => (others => '0'));
711 signal UNA_MonBuf : array5X11 := (others => (others => '0'));
712 signal UNA_TCPBuf : array4X11 := (others => (others => '0'));
713 signal AddrOffset : array3X10 := (others => (others => '0'));
714 signal SFPresetSyncRegs : array3X3 := (others => (others => '0'));
715 signal TCPresetSyncRegs : (2 downto 0) := (others => '0');
716 signal got_eofToggle0SyncRegs : (3 downto 0) := (others => '0');
717 signal reset_TCPIP : (2 downto 0) := (others => '0');
718 signal got_eofToggle1SyncRegs : (3 downto 0) := (others => '0');
719 signal got_eofToggle2SyncRegs : (3 downto 0) := (others => '0');
720 signal TCPIP_rdata : array3X32 := (others => (others => '0'));
721 signal AddrBuf_full : (2 downto 0) := (others => '0');
722 signal mon_evt_cnt_i : (10 downto 0) := (others => '0');
723 signal MonBufUsed : (9 downto 0) := (others => '0');
724 signal MonBuf_full : := '0';
725 signal chk_MonBuf_avl : := '0';
726 signal FirstBlkAddrDo : array2x3x12 := (others => (others => (others => '0')));
727 signal FirstBlkAddr_ra : array2x3x5 := (others => (others => (others => '0')));
728 signal FirstBlkAddr_re : array2X3 := (others => (others => '0'));
729 signal WrtMonEvtDone_l : (2 downto 0) := (others => '0');
730 signal MonEvtQueued : (2 downto 0) := (others => '0');
731 signal FirstBlkAddrDoValid : array2X3 := (others => (others => '0'));
732 signal FirstBlkAddr_wa : (4 downto 0) := (others => '0');
733 signal FirstBlkAddrDi : (11 downto 0) := (others => '0');
734 signal FirstBlkAddr_we : := '0';
735 signal MonBuf_wa : (10 downto 0) := (others => '0');
736 signal MonBuf_ra : (10 downto 0) := (others => '0');
737 signal NXT_MonBuf : array3X11 := (others => (others => '0'));
738 signal Written_MonBuf : array4X11 := (others => (others => '0'));
739 signal Written_MonBufMatch : (2 downto 0) := (others => '0');
740 signal SFP_pd : array3X2 := (others => (others => '0'));
741 signal EventData_reCntr : array3X32 := (others => (others => '0'));
742 signal EventData_weCntr : array3X32 := (others => (others => '0'));
743 signal EventBufAddr_weCntr : array3X32 := (others => (others => '0'));
744 signal cmsCRC_initp : (2 downto 0) := (others => '0');
745 signal cmsCRC_init : (2 downto 0) := (others => '0');
746 signal cmsCRC_ce : (2 downto 0) := (others => '0');
747 signal cmsCRC_err : (2 downto 0) := (others => '0');
748 signal cmsCRC_errCntr : array3X32 := (others => (others => '0'));
749 signal SFP_we : (2 downto 0) := (others => '0');
750 signal EoB : (2 downto 0) := (others => '0');
751 signal EoE : (2 downto 0) := (others => '0');
752 signal SFP_evt_cntr : array3X32 := (others => (others => '0'));
753 signal SFP_blk_cntr : array3X32 := (others => (others => '0'));
754 signal SFP_word_cntr : array3X32 := (others => (others => '0'));
755 --signal EvtLength_err : (2 downto 0) := (
others => '0');
756 signal TotalEvtLengthCntr24q : (2 downto 0) := (others => '0');
757 signal EvtLengthCntr : array3X24 := (others => (others => '0'));
758 signal EvtLength_errCntr : array3X32 := (others => (others => '0'));
759 signal AMClength_errCntr : array3X32 := (others => (others => '0'));
760 signal AMCvalid_errCntr : array3X32 := (others => (others => '0'));
761 signal AMCcrc_errCntr : array3X32 := (others => (others => '0'));
762 signal TotalEvtLengthCntr : array3X56 := (others => (others => '0'));
763 signal SFP_down_i : (2 downto 0) := (others => '0');
764 signal StopOverWrite : := '0';
765 signal StopOnCMScrc_err : := '0';
766 signal en_stop : (4 downto 0) := (others => '1');
767 signal stop : := '0';
768 signal inc_err : array3x5 := (others => (others => '0'));
774 ina :
IN (
135 downto 0);
775 inb :
IN (
135 downto 0)
782 Din :
IN (
303 downto 0)
785 COMPONENT chipscope1b
786 generic (USER2 : := false);
789 Din :
IN (
303 downto 0)
793 type array3x512 is array(0 to 2) of (511 downto 0);
794 signal TCPIP_cs : array3x512;
795 signal cs_din : (303 downto 0) := (others => '0');
796 signal waitcntr : (11 downto 0) := (others => '0');
798 SFP_down(2) <= SFP_down_i(2) and not enSFP(3) and enSFP(2);
799 SFP_down(1) <= SFP_down_i(1) and not enSFP(3) and enSFP(1);
800 SFP_down(0) <= SFP_down_i(0) and not enSFP(3) and enSFP(0);
801 TCPclk <= ClientClk2X;
802 --MonBuf_avl <= MonBuf_avl_i;
804 EventBufAddr_we <= EventBufAddr_we_i;
805 EventData_re <= EventData_re_i;
806 mon_evt_cnt(31 downto 11) <= (others => '0');
807 mon_evt_cnt(10 downto 0) <= mon_evt_cnt_i;
808 EventBufAddr <= EventBufAddr_i;
809 TCP_rrqst <= TCP_rrqst_i(2);
810 TCP_raddr <= TCP_raddr_i;
811 --TCP_length <= TCP_rlength(9 downto 0);
812 TCP_length <= TCP_rlength;
813 process(sysclk,reset,ClientClk_lock)
815 if(reset = '1' or ClientClk_lock = '0')then
816 resetSyncRegs <= (others => '1');
817 elsif(sysclk'event and sysclk = '1')then
818 resetSyncRegs <= resetSyncRegs(1 downto 0) & '0';
821 process(ClientClk2X,SFP_TX_FSM_RESET_DONE,SFP_RX_FSM_RESET_DONE)
824 if(SFP_TX_FSM_RESET_DONE(i) = '0' or SFP_RX_FSM_RESET_DONE(i) = '0')then
825 SFPresetSyncRegs(i) <= (others => '1');
826 elsif(ClientClk2X'event and ClientClk2X = '1')then
827 SFPresetSyncRegs(i) <= SFPresetSyncRegs(i)(1 downto 0) & '0';
831 process(ClientClk2X,reset,ClientClk_lock)
833 if(reset = '1' or ClientClk_lock = '0')then
834 ClientClk2XresetSyncRegs <= (others => '1');
835 elsif(ClientClk2X'event and ClientClk2X = '1')then
836 ClientClk2XresetSyncRegs <= ClientClk2XresetSyncRegs(1 downto 0) & '0';
839 process(ClientClk,TCPreset,ClientClk_lock)
841 if(TCPreset = '1' or ClientClk_lock = '0')then
842 TCPresetSyncRegs <= (others => '1');
843 elsif(ClientClk'event and ClientClk = '1')then
844 TCPresetSyncRegs <= TCPresetSyncRegs(1 downto 0) & '0';
849 if(ClientClk'event and ClientClk = '1')then
850 ClientClkToggle <= not ClientClkToggle;
855 if(ClientClk2X'event and ClientClk2X = '1')then
856 ClientClkToggle_q <= ClientClkToggle;
857 TX_high <= ClientClkToggle_q xnor ClientClkToggle;
858 if(us_cntr(9) = '1')then
859 us_cntr <= "00" & x"c9";
860 TSclock <= TSclock + 1;
862 us_cntr <= us_cntr + 1;
864 if(us_cntr(9) = '1')then
865 if(ms_cntr(10) = '1')then
866 ms_cntr <= x"03" & "000";
868 ms_cntr <= ms_cntr + 1;
871 strobe_ms <= us_cntr(9) and ms_cntr(10);
874 strobe_us <= us_cntr(9);
877 if(txusrclk'event and txusrclk = '1')then
878 if(TXSEQ_cntr = "1000001")then
879 TXSEQ_cntr <= (others => '0');
881 TXSEQ_cntr <= TXSEQ_cntr + 1;
883 if(TXSEQ_cntr(0) = '1')then
884 GTX_TX_PAUSE <= and_reduce(TXSEQ_cntr(5 downto 1));
886 if(inh_TX(0) = '1')then
887 SFP_TXSEQUENCE(0) <= (others => '0');
888 elsif(TXSEQ_cntr(0) = '1')then
889 SFP_TXSEQUENCE(0) <= '0' & TXSEQ_cntr(6 downto 1);
891 if(inh_TX(1) = '1')then
892 SFP_TXSEQUENCE(1) <= (others => '0');
893 elsif(TXSEQ_cntr(0) = '1')then
894 SFP_TXSEQUENCE(1) <= '0' & TXSEQ_cntr(6 downto 1);
896 if(inh_TX(2) = '1')then
897 SFP_TXSEQUENCE(2) <= (others => '0');
898 elsif(TXSEQ_cntr(0) = '1')then
899 SFP_TXSEQUENCE(2) <= '0' & TXSEQ_cntr(6 downto 1);
903 process(TXUSRCLK,TCPreset)
905 if(TCPreset = '1')then
906 reset_TXSyncRegs <= (others => '1');
907 elsif(TXUSRCLK'event and TXUSRCLK = '1')then
908 reset_TXSyncRegs <= reset_TXSyncRegs(1 downto 0) & '0';
911 process(TXUSRCLK,SFP_TX_FSM_RESET_DONE(
0))
913 if(SFP_TX_FSM_RESET_DONE(0) = '0')then
916 elsif(TXUSRCLK'event and TXUSRCLK = '1')then
917 if(TXSEQ_cntr(0) = '1' and TXSEQ_cntr(6) = '1')then
920 inh_TX_q(0) <= inh_TX(0);
923 process(TXUSRCLK,SFP_TX_FSM_RESET_DONE(
1))
925 if(SFP_TX_FSM_RESET_DONE(1) = '0')then
928 elsif(TXUSRCLK'event and TXUSRCLK = '1')then
929 if(TXSEQ_cntr(0) = '1' and TXSEQ_cntr(6) = '1')then
932 inh_TX_q(1) <= inh_TX(1);
935 process(TXUSRCLK,SFP_TX_FSM_RESET_DONE(
2))
937 if(SFP_TX_FSM_RESET_DONE(2) = '0')then
940 elsif(TXUSRCLK'event and TXUSRCLK = '1')then
941 if(TXSEQ_cntr(0) = '1' and TXSEQ_cntr(6) = '1')then
944 inh_TX_q(2) <= inh_TX(2);
949 if(sysclk'event and sysclk = '1')then
950 TCPBuf_avl <= not or_reduce(enTCPIP);
951 evt_buf_full <= evt_FIFO_full or wport_FIFO_full;
954 g_FirstBlkAddr: for j in 0 to 1 generate
955 g1_FirstBlkAddr: for i in 0 to 5 generate
956 i_FirstBlkAddr : RAM32M
958 DOA => FirstBlkAddrDo
(j
)(0)(i*2+1
downto i*2
),
-- Read port A 2-bit output
959 DOB => FirstBlkAddrDo
(j
)(1)(i*2+1
downto i*2
),
-- Read port B 2-bit output
960 DOC => FirstBlkAddrDo
(j
)(2)(i*2+1
downto i*2
),
-- Read port C 2-bit output
961 DOD =>
open,
-- Read/Write port D 2-bit output
962 ADDRA => FirstBlkAddr_ra
(j
)(0),
-- Read port A 5-bit address input
963 ADDRB => FirstBlkAddr_ra
(j
)(1),
-- Read port B 5-bit address input
964 ADDRC => FirstBlkAddr_ra
(j
)(2),
-- Read port C 5-bit address input
965 ADDRD => FirstBlkAddr_wa,
-- Read/Write port D 5-bit address input
966 DIA => FirstBlkAddrDi
(i*2+1
downto i*2
),
-- RAM 2-bit data write input addressed by ADDRD,
967 -- read addressed by ADDRA
968 DIB => FirstBlkAddrDi
(i*2+1
downto i*2
),
-- RAM 2-bit data write input addressed by ADDRD,
969 -- read addressed by ADDRB
970 DIC => FirstBlkAddrDi
(i*2+1
downto i*2
),
-- RAM 2-bit data write input addressed by ADDRD,
971 -- read addressed by ADDRC
972 DID => "
00",
-- RAM 2-bit data write input addressed by ADDRD,
973 -- read addressed by ADDRD
974 WCLK => sysclk,
-- Write clock input
975 WE => FirstBlkAddr_we
-- Write enable input
979 FirstBlkAddrDi <= '0' & MonBuf_wa;
982 if(sysclk'event and sysclk = '1')then
983 sysDIV2 <= not sysDIV2;
984 if(resetSyncRegs(2) = '1')then
985 chk_MonBuf_avl <= '1';
986 elsif(buf_rqst(0) = '1')then
987 chk_MonBuf_avl <= buf_rqst(3);
989 if(resetSyncRegs(2) = '1')then
991 elsif(WaitMonBuf = '1' or MonBufOverWrite = '1' or enTCPIP /= "000")then
992 if((MonBuf_wa(10) /= MonBuf_ra(10) and MonBuf_wa(9 downto 0) = MonBuf_ra(9 downto 0)))then
997 elsif(chk_MonBuf_avl = '1')then
998 if(MonBufUsed(9 downto 8) = "11")then
1004 if(enTCPIP /= "000")then
1005 mon_evt_cnt_i <= (others => '0');
1006 elsif(MonBufOverWrite = '1')then
1007 mon_evt_cnt_i <= '0' & Written_MonBuf(3)(9 downto 0);
1009 mon_evt_cnt_i <= Written_MonBuf(3) - MonBuf_ra;
1011 if(enTCPIP /= "000")then
1012 MonBuf_empty <= '1';
1013 elsif(MonBufOverWrite = '0')then
1014 MonBuf_empty <= not or_reduce(mon_evt_cnt_i);
1015 elsif(Written_MonBuf(3) /= MonBuf_ra or MonBuf_full = '1')then
1016 MonBuf_empty <= '0';
1018 MonBuf_empty <= '1';
1020 if(EnSFP(2 downto 1) = "00")then
1021 SFP_we(0) <= EventData_we(0);
1022 EoB(0) <= EventData_in(0)(64);
1023 EoE(0) <= EventData_in(0)(65);
1025 SFP_we(0) <= EventData_we(1) and EnSFP(0);
1026 EoB(0) <= EventData_in(1)(64);
1027 EoE(0) <= EventData_in(1)(65);
1029 if(EnSFP(2 downto 0) = "110")then
1030 SFP_we(1) <= EventData_we(1);
1031 EoB(1) <= EventData_in(1)(64);
1032 EoE(1) <= EventData_in(1)(65);
1034 SFP_we(1) <= EventData_we(0) and EnSFP(1);
1035 EoB(1) <= EventData_in(0)(64);
1036 EoE(1) <= EventData_in(0)(65);
1038 if(EnSFP(2 downto 0) = "111")then
1039 SFP_we(2) <= EventData_we(2);
1040 EoB(2) <= EventData_in(2)(64);
1041 EoE(2) <= EventData_in(2)(65);
1043 SFP_we(2) <= EventData_we(0) and EnSFP(2);
1044 EoB(2) <= EventData_in(0)(64);
1045 EoE(2) <= EventData_in(0)(65);
1047 if(resetSyncRegs(2) = '1')then
1048 ReadBusy <= (others => '0');
1049 EventData_re_i <= (others => '0');
1050 EventBufAddr_we_i <= (others => '0');
1051 UNA_MonBufSyncRegs <= (others => '0');
1052 UNA_TCPBufSyncRegs <= (others => '0');
1053 ReleaseMonBuf <= '0';
1054 ReleaseTCPBuf <= '0';
1055 MonBuf_wa <= (others => '0');
1056 MonBuf_ra <= (others => '0');
1057 Written_MonBufMatch <= (others => '1');
1058 Written_MonBuf <= (others => (others => '0'));
1059 NXT_MonBuf <= (others => (others => '0'));
1060 NXT_TCPBuf <= (others => (others => '0'));
1061 FirstBlkAddr_we <= '0';
1062 FirstBlkAddr_re <= (others => (others => '0'));
1063 FirstBlkAddrDoValid <= (others => (others => '0'));
1064 WrtMonEvtDone_l <= (others => '0');
1065 MonEvtQueued <= (others => '0');
1066 FirstBlkAddr_wa <= (others => '0');
1067 FirstBlkAddr_ra <= (others => (others => (others => '0')));
1069 EventData_reCntr <= (others => (others => '0'));
1070 EventData_weCntr <= (others => (others => '0'));
1071 EventBufAddr_weCntr <= (others => (others => '0'));
1072 EvtLengthCntr <= (others => x"000001");
1073 TotalEvtLengthCntr <= (others => (others => '0'));
1074 TotalEvtLengthCntr24q <= "000";
1075 SFP_blk_cntr <= (others => (others => '0'));
1076 SFP_evt_cntr <= (others => (others => '0'));
1077 SFP_word_cntr <= (others => (others => '0'));
1079 for i in 0 to 2 loop
1080 if(EVENTdata_in(i)(64) = '1' and EVENTdata_we(i) = '1')then
1082 elsif(evt_data_rdy(i) = '1' and wport_rdy(i) = '1' and AddrBuf_full(i) = '0')then
1085 EventData_re_i(i) <= evt_data_rdy(i) and wport_rdy(i) and not ReadBusy(i) and not AddrBuf_full(i);
1086 if(EventData_re_i(i) = '1')then
1087 EventData_reCntr(i) <= EventData_reCntr(i) + 1;
1089 if(EventData_we(i) = '1')then
1090 EventData_weCntr(i) <= EventData_weCntr(i) + 1;
1092 if(EventData_in(i)(66) = '0')then
1093 EventBufAddr_we_i(i) <= evt_data_rdy(i) and wport_rdy(i) and not ReadBusy(i) and not AddrBuf_full(i);
1095 EventBufAddr_we_i(i) <= '0';
1097 if(EventBufAddr_we_i(i) = '1')then
1098 EventBufAddr_weCntr(i) <= EventBufAddr_weCntr(i) + 1;
1100 if(EventData_we(i) = '1')then
1101 if(EventData_in(i)(65) = '1')then
1102 EvtLengthCntr(i) <= x"000001";
1103 TotalEvtLengthCntr(i)(24 downto 0) <= TotalEvtLengthCntr(i)(24 downto 0) + ('0' & EventData_in(i)(55 downto 32));
1105 EvtLengthCntr(i) <= EvtLengthCntr(i) + 1;
1108 TotalEvtLengthCntr24q(i) <= TotalEvtLengthCntr(i)(24);
1109 if(TotalEvtLengthCntr24q(i) = '1' and TotalEvtLengthCntr(i)(24) = '0')then
1110 TotalEvtLengthCntr(i)(55 downto 25) <= TotalEvtLengthCntr(i)(55 downto 25) + 1;
1113 if(MonBufOverWrite = '1' and Written_MonBuf(3)(10) = '1')then
1116 for j in 0 to 1 loop
1117 for i in 0 to 2 loop
1118 if(FirstBlkAddr_re(j)(i) = '1')then
1119 FirstBlkAddr_ra(j)(i) <= FirstBlkAddr_ra(j)(i) + 1;
1121 if(FirstBlkAddr_ra(j)(i) = FirstBlkAddr_wa)then
1122 FirstBlkAddrDoValid(j)(i) <= '0';
1124 FirstBlkAddrDoValid(j)(i) <= '1';
1128 if(FirstBlkAddr_we = '1')then
1129 FirstBlkAddr_wa <= FirstBlkAddr_wa + 1;
1131 for i in 0 to 2 loop
1132 if(WrtMonEvtDone(i) = '1' and enTCPIP = "000")then
1133 WrtMonEvtDone_l(i) <= '1';
1134 elsif(FirstBlkAddrDoValid(0)(i) = '1')then
1135 WrtMonEvtDone_l(i) <= '0';
1137 FirstBlkAddr_re(0)(i) <= FirstBlkAddrDoValid(0)(i) and WrtMonEvtDone_l(i);
1138 if(EventData_we(i) = '1' and EventData_in(i)(66 downto 65) = "01" and enTCPIP = "000")then
1139 MonEvtQueued(i) <= '1';
1140 elsif(FirstBlkAddrDoValid(1)(i) = '1')then
1141 MonEvtQueued(i) <= '0';
1143 FirstBlkAddr_re(1)(i) <= FirstBlkAddrDoValid(1)(i) and MonEvtQueued(i);
1145 FirstBlkAddr_we <= buf_rqst(3) and buf_rqst(0) and not or_reduce(enTCPIP);
1146 if(buf_rqst(0) = '1')then
1147 MonBuf_wa <= MonBuf_wa + 1;
1149 MonBufUsed <= MonBuf_wa(9 downto 0) - MonBuf_ra(9 downto 0);
1150 if(ReleaseMonBuf = '1' or (MonBufOverWrite = '1' and StopOverWrite = '0' and and_reduce(MonBufUsed) = '1' and buf_rqst(0) = '1'))then
1151 MonBuf_ra <= MonBuf_ra + 1;
1153 if(Written_MonBuf(0) = Written_MonBuf(3) and WrtMonEvtDone_l(0) = '0')then
1154 Written_MonBufMatch(0) <= '1';
1156 Written_MonBufMatch(0) <= '0';
1158 if((EnSFP(2 downto 0) = "111" or EnSFP(2 downto 0) = "011" or EnSFP(2 downto 0) = "110" or EnSFP(2 downto 0) = "101") and Written_MonBuf(1) = Written_MonBuf(3) and WrtMonEvtDone_l(1) = '0')then
1159 Written_MonBufMatch(1) <= '1';
1161 Written_MonBufMatch(1) <= '0';
1163 if(EnSFP(2 downto 0) = "111" and Written_MonBuf(2) = Written_MonBuf(3) and WrtMonEvtDone_l(2) = '0')then
1164 Written_MonBufMatch(2) <= '1';
1166 Written_MonBufMatch(2) <= '0';
1168 if(Written_MonBufMatch = "000" and sysDIV2 = '0')then
1169 Written_MonBuf(3) <= Written_MonBuf(3) + 1;
1171 UNA_MonBufSyncRegs <= UNA_MonBufSyncRegs(2 downto 0) & UNA_MonBuf(4)(0);
1172 UNA_TCPBufSyncRegs <= UNA_TCPBufSyncRegs(2 downto 0) & UNA_TCPBuf(3)(0);
1173 ReleaseMonBuf <= UNA_MonBufSyncRegs(3) xor UNA_MonBufSyncRegs(2);
1174 ReleaseTCPBuf <= UNA_TCPBufSyncRegs(3) xor UNA_TCPBufSyncRegs(2);
1175 for i in 0 to 2 loop
1176 if(FirstBlkAddr_re(0)(i) = '1')then
1177 Written_MonBuf(i) <= FirstBlkAddrDo(0)(i)(10 downto 0);
1178 elsif(WrtMonBlkDone(i) = '1')then
1179 Written_MonBuf(i) <= Written_MonBuf(i) + 1;
1181 if(FirstBlkAddr_re(1)(i) = '1')then
1182 NXT_MonBuf(i) <= FirstBlkAddrDo(1)(i)(10 downto 0);
1183 elsif(EventBufAddr_we_i(i) = '1' and EventData_in(i)(66) = '0')then
1184 NXT_MonBuf(i) <= NXT_MonBuf(i) + 1;
1186 if(EventBufAddr_we_i(i) = '1' and EventData_in(i)(66) = '1')then
1187 NXT_TCPBuf(i) <= NXT_TCPBuf(i) + 1;
1189 if(SFP_we(i) = '1' and EoB(i) = '1')then
1190 SFP_blk_cntr(i) <= SFP_blk_cntr(i) + 1;
1192 if(SFP_we(i) = '1' and EoE(i) = '1')then
1193 SFP_evt_cntr(i) <= SFP_evt_cntr(i) + 1;
1195 if(SFP_we(i) = '1')then
1196 SFP_word_cntr(i) <= SFP_word_cntr(i) + 1;
1200 for i in 0 to 2 loop
1201 if(EventData_in(i)(66) = '0')then
1202 EventBufAddr_i(i) <= NXT_MonBuf(i)(9 downto 0) & AddrOffset(i)(9 downto 6);
1204 EventBufAddr_i(i) <= NXT_TCPBuf(i)(9 downto 0) & AddrOffset(i)(9 downto 6);
1209 process(ClientClk2X)
1211 if(ClientClk2X'event and ClientClk2X = '1')then
1212 if(ClientClk2XresetSyncRegs(2) = '1')then
1213 inc_ddr_paSyncRegs <= (others => '0');
1214 UNA_MonBufMatch <= (others => '1');
1215 UNA_TCPBufMatch <= (others => '1');
1216 UNA_MonBuf(4) <= (others => '0');
1217 UNA_MonBuf(3) <= (others => '0');
1218 UNA_TCPBuf(3) <= (others => '0');
1220 inc_ddr_paSyncRegs <= inc_ddr_paSyncRegs(2 downto 0) & inc_ddr_pa;
1221 if(inc_ddr_paSyncRegs(3 downto 2) = "10")then
1222 UNA_MonBuf(3) <= UNA_MonBuf(3) + 1;
1224 for i in 0 to 2 loop
1225 if(enTCPIP(i) = '1' and UNA_MonBuf(i) = UNA_MonBuf(4))then
1226 UNA_MonBufMatch(i) <= '1';
1228 UNA_MonBufMatch(i) <= '0';
1230 if(enTCPIP(i) = '1' and UNA_TCPBuf(i) = UNA_TCPBuf(3))then
1231 UNA_TCPBufMatch(i) <= '1';
1233 UNA_TCPBufMatch(i) <= '0';
1236 if(EnTCPIP = "000" and UNA_MonBuf(3) = UNA_MonBuf(4))then
1237 UNA_MonBufMatch(3) <= '1';
1239 UNA_MonBufMatch(3) <= '0';
1241 if(UNA_MonBufMatch = x"0" and us_cntr(0) = '1')then
1242 UNA_MonBuf(4) <= UNA_MonBuf(4) + 1;
1244 if(UNA_TCPBufMatch = "000" and enSFP(2 downto 0) /= "000" and us_cntr(0) = '1')then
1245 UNA_TCPBuf(3) <= UNA_TCPBuf(3) + 1;
1248 case EnSFP(2 downto 0) is
1249 when "011" | "101" | "110" => AddrOffset(0)(9 downto 6) <= x"8";
1250 when "111" => AddrOffset(0)(9 downto 6) <= x"5";
1251 when others => AddrOffset(0)(9 downto 6) <= x"0";
1253 AddrOffset(1)(9 downto 6) <= x"0";
1254 AddrOffset(2)(9 downto 6) <= x"a";
1255 if(EnSFP(3) = '0' and or_reduce(EnSFP(2 downto 0)) = '1')then
1260 if(EnSFP(3) = '0' and (EnSFP(2 downto 0) = "011" or EnSFP(2 downto 0) = "101" or EnSFP(2 downto 0) = "110" or EnSFP(2 downto 0) = "111"))then
1265 if(EnSFP = x"7")then
1272 process(sysclk,rstCntr)
1274 if(rstCntr = '1')then
1275 EvtLength_errCntr <= (others => (others => '0'));
1276 AMCLength_errCntr <= (others => (others => '0'));
1277 AMCvalid_errCntr <= (others => (others => '0'));
1278 AMCcrc_errCntr <= (others => (others => '0'));
1279 elsif(sysclk'event and sysclk = '1')then
1280 for i in 0 to 2 loop
1281 if(inc_err(i)(1) = '1')then
1282 EvtLength_errCntr(i) <= EvtLength_errCntr(i) + 1;
1284 if(inc_err(i)(2) = '1')then
1285 AMClength_errCntr(i) <= AMClength_errCntr(i) + 1;
1287 if(inc_err(i)(3) = '1')then
1288 AMCvalid_errCntr(i) <= AMCvalid_errCntr(i) + 1;
1290 if(inc_err(i)(4) = '1')then
1291 AMCcrc_errCntr(i) <= AMCcrc_errCntr(i) + 1;
1298 reset => resetSyncRegs
(2),
1300 cmsCRC_err => "
000",
1301 EventData_in => EventData_in ,
1302 EventData_we => EventData_we ,
1306 process(sysclk,rstCntr)
1308 if(rstCntr = '1')then
1309 StopOverWrite <= '0';
1310 elsif(StopOnCMScrc_err = '1')then
1311 StopOverWrite <= '1';
1312 elsif(sysclk'event and sysclk = '1')then
1314 StopOverWrite <= '1';
1319 reset => resetSyncRegs
(2),
1321 fifo_rst => fifo_rst,
1326 if(sysclk'event and sysclk = '1')then
1327 for i in 0 to 2 loop
1328 if(resetSyncRegs(2) = '1' or EventBufAddr_we_i(i) = '1')then
1329 evt_FIFO_di(i)(65) <= '1';
1330 elsif(evt_FIFO_we(i) = '1')then
1331 evt_FIFO_di(i)(65) <= '0';
1336 g_evt_FIFO: for i in 0 to 2 generate
1337 i_evt_fifo : FIFO_DUALCLOCK_MACRO
1339 DEVICE =>
"7SERIES",
-- Target Device: "VIRTEX5",
"VIRTEX6",
"7SERIES"
1340 ALMOST_FULL_OFFSET => X"0004",
-- Sets almost full threshold
1341 ALMOST_EMPTY_OFFSET => X"0080",
-- Sets the almost empty threshold
1342 DATA_WIDTH =>
67,
-- Valid values are 1-72 (37-72 only valid when FIFO_SIZE="36Kb")
1343 FIFO_SIZE =>
"36Kb",
-- Target BRAM, "18Kb" or "36Kb"
1344 FIRST_WORD_FALL_THROUGH => TRUE
) -- Sets the FIFO FWFT to TRUE or FALSE
1346 ALMOSTEMPTY =>
open,
-- 1-bit output almost empty
1347 ALMOSTFULL => evt_FIFO_full
(i
),
-- 1-bit output almost full
1348 DO => evt_FIFO_do
(i
),
-- Output data, width defined by DATA_WIDTH parameter
1349 EMPTY => evt_FIFO_empty
(i
),
-- 1-bit output empty
1350 FULL =>
open,
-- 1-bit output full
1351 RDCOUNT => evt_FIFO_RDCOUNT
(i
),
-- Output read count, width determined by FIFO depth
1352 RDERR =>
open,
-- 1-bit output read error
1353 WRCOUNT => evt_FIFO_WRCOUNT
(i
),
-- Output write count, width determined by FIFO depth
1354 WRERR =>
open,
-- 1-bit output write error
1355 DI => evt_FIFO_di
(i
),
-- Input data, width defined by DATA_WIDTH parameter
1356 RDCLK => ClientClk2X,
-- 1-bit input read clock
1357 RDEN => evt_FIFO_re
(i
),
-- 1-bit input read enable
1358 RST => fifo_rst,
-- 1-bit input reset
1359 WRCLK => sysclk,
-- 1-bit input write clock
1360 WREN => evt_FIFO_we
(i
) -- 1-bit input write enable
1363 evt_FIFO_di(0)(64 downto 0) <= EVENTdata_in(0)(64 downto 0);
1364 evt_FIFO_di(1)(64 downto 0) <= EVENTdata_in(1)(64 downto 0);
1365 evt_FIFO_di(2)(64 downto 0) <= EVENTdata_in(2)(64 downto 0);
1366 evt_FIFO_di(0)(66) <= EVENTdata_in(0)(65);
1367 evt_FIFO_di(1)(66) <= EVENTdata_in(1)(65);
1368 evt_FIFO_di(2)(66) <= EVENTdata_in(2)(65);
1369 evt_FIFO_we <= "000" when EnSFP(3) = '1' or fifo_en = '0' else EVENTdata_we;
1370 evt_FIFO_re <= "000" when fifo_en = '0' else evt_FIFO_rep;
1371 EVENTdata_avl <= not evt_FIFO_empty;
1372 g_cmsCRC : for i in 0 to 2 generate
1374 clk => ClientClk2X ,
1376 crc_init => cmsCRC_init
(i
),
1377 trailer => evt_FIFO_do
(i
)(66),
1378 crc_d => evt_FIFO_do
(i
)(63 downto 0),
1379 crc_ce => cmsCRC_ce
(i
),
1381 crc_err => cmsCRC_err
(i
),
1386 cmsCRC_ce <= evt_FIFO_rep and EVENTdata_avl;
1387 process(ClientClk2X)
1389 if(ClientClk2X'event and ClientClk2X = '1')then
1390 if(ClientClk2XresetSyncRegs(2) = '1')then
1391 cmsCRC_initp <= "000";
1392 cmsCRC_init <= "111";
1393 cmsCRC_errCntr <= (others => (others => '0'));
1394 StopOnCMScrc_err <= '0';
1396 for i in 0 to 2 loop
1397 cmsCRC_initp(i) <= evt_FIFO_do(i)(66) and cmsCRC_ce(i);
1398 if(cmsCRC_err(i) = '1' and cmsCRC_init(i) = '1')then
1399 cmsCRC_errCntr(i) <= cmsCRC_errCntr(i) + 1;
1402 cmsCRC_init <= cmsCRC_initp;
1403 if(en_stop(0) = '1' and or_reduce(cmsCRC_err and cmsCRC_init) = '1')then
1404 StopOnCMScrc_err <= '1';
1406 StopOnCMScrc_err <= '0';
1411 g_TCPIP: for i in 0 to 2 generate
1412 i_TCPIP:
TCPIP PORT MAP(
1413 reset => reset_TCPIP
(i
),
1416 clk2x => ClientClk2X,
1418 strobe_us => strobe_us,
1419 strobe_ms => strobe_ms,
1420 en_LINK => enTCPIP
(i
),
1421 LINK_down => LINK_down
(i
),
1423 MY_IP => IPADDR
(i
),
1424 MY_ETH => MACADDR
(i
),
1426 CWND_max => CWND_max,
1427 EVENTdata => evt_FIFO_do
(i
),
1428 EVENTdata_avl => EVENTdata_avl
(i
),
1429 EVENTdata_re => evt_FIFO_rep
(i
),
1430 DDR2TCPdata => DDR2TCPdata ,
1431 RETXdata_chksum => RETXdata_checksum
(i
),
1432 RETXdata_we => RETXdata_we
(i
),
1433 RETX_ddr_out => RETX_ddr_out
(i
),
1434 re_RETX_ddr_wq => re_RETX_ddr_wq
(i
),
1435 RETX_ddr_wrqst => RETX_ddr_wrqst
(i
),
1436 RETX_ddr_data_we => RETX_ddr_data_we
(i
),
1437 RETX_ddr_rrqst => RETX_ddr_rrqst
(i
),
1438 RETX_ddr_LEN_max => RETX_ddr_LEN_max
(i
),
1439 RETX_ddr_LEN => RETX_ddr_LEN
(i
),
1440 RETXdataACK => RETXdataACK
(i
),
1441 RETXdataRqst => RETXdataRqst
(i
),
1442 RETXdataAddr => RETXdataAddr
(i
),
1443 RETXdataLEN => RETXdataLEN
(i
),
1444 KiloByte_toggle => KiloByte_toggle
(i
),
1445 EoB_toggle => EoB_toggle
(i
),
1446 TCP_wcount => TCP_wcount
(i
),
1447 EventBufAddr => EventBufAddr_i
(i
),
1448 EventBufAddr_we => EventBufAddr_we_i
(i
),
1449 AddrBuf_full => AddrBuf_full
(i
),
1450 UNA_MonBuf => UNA_MonBuf
(i
),
1451 UNA_TCPBuf => UNA_TCPBuf
(i
),
1452 EmacPhyTxC => EmacPhyTxc
(i
),
1453 EmacPhyTxD => EmacPhyTxd
(i
),
1454 PhyEmacRxC => PhyEmacRxC
(i
),
1455 PhyEmacRxD => PhyEmacRxD
(i
),
1456 ipb_addr => ipb_addr,
1457 ipb_rdata => TCPIP_rdata
(i
),
1458 cs_out => TCPIP_cs
(i
)
1463 r => rst_RETXdata_chksum,
1464 ce => TCP_din_valid,
1466 s => RETXdata_chksum_out
1468 process(ClientClk2X)
1470 if(ClientClk2X'event and ClientClk2X = '1')then
1471 if(TCP_lastword = '1' and TCP_din_valid = '1' and TCP_din_type = "100")then
1472 ld_RETXdata_chksum(0) <= '1';
1474 ld_RETXdata_chksum(0) <= '0';
1476 if(TCP_lastword = '1' and TCP_din_valid = '1' and TCP_din_type = "101")then
1477 ld_RETXdata_chksum(1) <= '1';
1479 ld_RETXdata_chksum(1) <= '0';
1481 if(TCP_lastword = '1' and TCP_din_valid = '1' and TCP_din_type = "110")then
1482 ld_RETXdata_chksum(2) <= '1';
1484 ld_RETXdata_chksum(2) <= '0';
1486 ld_RETXdata_chksum_r <= ld_RETXdata_chksum;
1487 ld_RETXdata_chksum_r2 <= ld_RETXdata_chksum_r;
1488 if(ld_RETXdata_chksum_r2(0) = '1')then
1489 RETXdata_checksum(0) <= RETXdata_chksum_out;
1491 if(ld_RETXdata_chksum_r2(1) = '1')then
1492 RETXdata_checksum(1) <= RETXdata_chksum_out;
1494 if(ld_RETXdata_chksum_r2(2) = '1')then
1495 RETXdata_checksum(2) <= RETXdata_chksum_out;
1497 if(ClientClk2XresetSyncRegs(2) = '1')then
1498 rst_RETXdata_chksum <= '1';
1500 rst_RETXdata_chksum <= TCP_lastword and TCP_din_valid;
1502 DDR2TCPdata <= TCP_lastword & TCP_din;
1503 if(FIFO_en = '1' and TCP_din_valid = '1' and TCP_din_type = "000")then
1504 RETX_ddr_data_we(0) <= '1';
1506 RETX_ddr_data_we(0) <= '0';
1508 if(FIFO_en = '1' and TCP_din_valid = '1' and TCP_din_type = "001")then
1509 RETX_ddr_data_we(1) <= '1';
1511 RETX_ddr_data_we(1) <= '0';
1513 if(FIFO_en = '1' and TCP_din_valid = '1' and TCP_din_type = "010")then
1514 RETX_ddr_data_we(2) <= '1';
1516 RETX_ddr_data_we(2) <= '0';
1518 rst_odd <= TCP_lastword and TCP_din_valid;
1519 if(ClientClk2XresetSyncRegs(2) = '1' or rst_odd = '1')then
1521 elsif(TCP_din_valid = '1')then
1524 if(TCP_din_valid = '1' and TCP_din_type = "100")then
1525 RETXdata_we(0) <= odd & not odd;
1527 RETXdata_we(0) <= "00";
1529 if(TCP_din_valid = '1' and TCP_din_type = "101")then
1530 RETXdata_we(1) <= odd & not odd;
1532 RETXdata_we(1) <= "00";
1534 if(TCP_din_valid = '1' and TCP_din_type = "110")then
1535 RETXdata_we(2) <= odd & not odd;
1537 RETXdata_we(2) <= "00";
1539 if(RETX_ddr_rp_rst = '1')then
1540 RETX_ddr_rp_di <= (others => '0');
1541 RETX_ddr_rp_we <= '1';
1543 RETX_ddr_rp_di(16 downto 0) <= RETX_ddr_rp_do(16 downto 0) + TCP_length_i(20 downto 4);
1544 RETX_ddr_rp_we <= TCP_rack and not TCP_raddr_i(28);
1546 if(ClientClk2XresetSyncRegs(2) = '1')then
1547 ReTx_ddr_LEN_max <= (others => "10000");
1548 elsif(RETX_ddr_rp_we = '1')then
1549 if(and_reduce(RETX_ddr_rp_di(8 downto 4)) = '0')then -- ReTx_ddr_LEN_max insures the readout does not go into event data area
1550 ReTx_ddr_LEN_max(conv_integer(RETX_ddr_rp_a)) <= "10000";
1552 ReTx_ddr_LEN_max(conv_integer(RETX_ddr_rp_a)) <= "10000" - ('0' & RETX_ddr_rp_di(3 downto 0));
1555 if(ClientClk2XresetSyncRegs(2) = '1')then
1556 RETX_ddr_rp_rst <= '1';
1557 RETX_ddr_rp_a <= (others => '0');
1558 TCP_rrqst_i <= "000";
1559 rrqstMask <= (others => '1');
1561 if(RETX_ddr_rp_a(1) = '1')then
1562 RETX_ddr_rp_rst <= '0';
1564 if(RETX_ddr_rp_rst = '1')then
1565 RETX_ddr_rp_a(1 downto 0) <= RETX_ddr_rp_a(1 downto 0) + 1;
1566 elsif(TCP_rrqst_i(0) = '0')then
1567 if(or_reduce(rrqstMask(5 downto 3) and RETXdataRqst) = '1')then
1568 RETX_ddr_rp_a(1 downto 0) <= "11";
1569 elsif(rrqstMask(0) = '1' and RETX_ddr_rrqst(0) = '1')then
1570 RETX_ddr_rp_a(1 downto 0) <= "00";
1571 elsif(rrqstMask(1) = '1' and RETX_ddr_rrqst(1) = '1')then
1572 RETX_ddr_rp_a(1 downto 0) <= "01";
1574 RETX_ddr_rp_a(1 downto 0) <= "10";
1577 if(TCP_rack = '1')then
1578 TCP_rrqst_i <= "000";
1580 if(or_reduce(rrqstMask(2 downto 0) and RETX_ddr_rrqst) = '1' or or_reduce(rrqstMask(5 downto 3) and RETXdataRqst) = '1')then
1581 TCP_rrqst_i(0) <= '1';
1583 TCP_rrqst_i(2 downto 1) <= TCP_rrqst_i(1 downto 0);
1585 for i in 0 to 2 loop
1586 if(TCP_rrqst_i(0) = '1' and TCP_raddr_i(28) = '0' and i = conv_integer(TCP_raddr_i(27 downto 26)))then
1587 rrqstMask(i) <= '0';
1588 elsif(rst_RETXdata_chksum = '1' and TCP_din_type(2) = '0' and i = conv_integer(TCP_din_type(1 downto 0)))then
1589 rrqstMask(i) <= '1';
1591 if(TCP_rrqst_i(0) = '1' and TCP_raddr_i(28) = '1' and i = conv_integer(TCP_raddr_i(27 downto 26)))then
1592 rrqstMask(i+3) <= '0';
1593 elsif(rst_RETXdata_chksum = '1' and TCP_din_type(2) = '1' and i = conv_integer(TCP_din_type(1 downto 0)))then
1594 rrqstMask(i+3) <= '1';
1598 if(TCP_rrqst_i(0) = '0')then
1599 RETXdataAck <= (others => '0');
1600 elsif(TCP_raddr_i(28) = '1')then
1601 case TCP_raddr_i(27 downto 26) is
1602 when "00" => RETXdataAck <= "001";
1603 when "01" => RETXdataAck <= "010";
1604 when "10" => RETXdataAck <= "100";
1605 when others => RETXdataAck <= "000";
1608 if(TCP_rrqst_i(0) = '0')then
1609 if(or_reduce(rrqstMask(5 downto 3) and RETXdataRqst) = '1')then
1610 TCP_raddr_i(28) <= '1';
1611 if(rrqstMask(3) = '1' and RETXdataRqst(0) = '1')then
1612 TCP_raddr_i(27 downto 26) <= "00";
1613 elsif(rrqstMask(4) = '1' and RETXdataRqst(1) = '1')then
1614 TCP_raddr_i(27 downto 26) <= "01";
1616 TCP_raddr_i(27 downto 26) <= "10";
1619 TCP_raddr_i(28) <= '0';
1620 if(rrqstMask(0) = '1' and RETX_ddr_rrqst(0) = '1')then
1621 TCP_raddr_i(27 downto 26) <= "00";
1622 elsif(rrqstMask(1) = '1' and RETX_ddr_rrqst(1) = '1')then
1623 TCP_raddr_i(27 downto 26) <= "01";
1625 TCP_raddr_i(27 downto 26) <= "10";
1629 case TCP_raddr_i(28 downto 26) is
1630 when "100" => TCP_raddr_i(25 downto 0) <= RETXdataAddr(0);
1631 when "101" => TCP_raddr_i(25 downto 0) <= RETXdataAddr(1);
1632 when "110" => TCP_raddr_i(25 downto 0) <= RETXdataAddr(2);
1633 when others => TCP_raddr_i(25 downto 0) <= TCP_raddr_i(27 downto 26)(1 downto 0) & RETX_ddr_rp_do(16 downto 9) & x"f" & RETX_ddr_rp_do(8 downto 0) & "000";
1635 TCP_rlength <= TCP_length_i(11 downto 1) - 1;
1636 case TCP_raddr_i(28 downto 26) is
1637 when "000" => TCP_length_i(11 downto 0) <= "000" & RETX_ddr_LEN(0) & x"0";
1638 when "001" => TCP_length_i(11 downto 0) <= "000" & RETX_ddr_LEN(1) & x"0";
1639 when "010" => TCP_length_i(11 downto 0) <= "000" & RETX_ddr_LEN(2) & x"0";
1640 when "100" => TCP_length_i(11 downto 0) <= RETXdataLEN(0) & '0';
1641 when "101" => TCP_length_i(11 downto 0) <= RETXdataLEN(1) & '0';
1642 when "110" => TCP_length_i(11 downto 0) <= RETXdataLEN(2) & '0';
1643 when others => TCP_length_i(11 downto 0) <= x"000";
1647 g_RETX_ddr_rp : for i in 0 to 2 generate
1649 wclk => ClientClk2X ,
1650 di => RETX_ddr_rp_di
(i*6+5
downto i*6
),
1651 we => RETX_ddr_rp_we,
1652 wa => RETX_ddr_rp_a,
1653 ra => RETX_ddr_rp_a,
1654 do => RETX_ddr_rp_do
(i*6+5
downto i*6
)
1657 TCP_we <= TCP_wFIFO_we;
1658 i_TCP_wFIFO_we : SRL16E
1660 Q => TCP_wFIFO_we,
-- SRL data output
1661 A0 => '0',
-- Select[0] input
1662 A1 => '1',
-- Select[1] input
1663 A2 => '0',
-- Select[2] input
1664 A3 => '0',
-- Select[3] input
1665 CE => '1',
-- Clock enable input
1666 CLK => ClientClk2X,
-- Clock input
1667 D => TCP_w_busy
-- SRL data input
1669 TCP_channel <= TCP_wFIFO_DI(33 downto 32);
1670 TCP_dout <= TCP_wFIFO_DI(31 downto 0);
1671 process(ClientClk2X, TCP_w_sel, RETX_ddr_wrqst)
1672 variable s : (4 downto 0);
1674 s := TCP_w_sel & RETX_ddr_wrqst;
1675 if(ClientClk2X'event and ClientClk2X = '1')then
1676 if(FIFO_en = '0' or ClientClk2XresetSyncRegs(2) = '1')then
1678 elsif(TCP_w_busy = '0')then
1680 when "00001" | "01001" | "01011" | "10001" | "10011" | "10101" | "10111" =>
1682 when "00010" | "00011" | "00110" | "00111" | "01010" | "10010" | "10110" =>
1684 when "00100" | "00101" | "01100" | "01101" | "01110" | "01111" | "10100" =>
1686 when others => null;
1689 if(FIFO_en = '0' or ClientClk2XresetSyncRegs(2) = '1')then
1691 elsif(TCP_w_wc = x"f")then
1693 elsif(RETX_ddr_wrqst /= "000")then
1696 if(ClientClk2XresetSyncRegs(2) = '1')then
1698 elsif(TCP_w_busy = '1')then
1699 TCP_w_wc <= TCP_w_wc + 1;
1701 if(FIFO_en = '0' or ClientClk2XresetSyncRegs(2) = '1')then
1702 re_RETX_ddr_wq <= "000";
1705 when "00" => re_RETX_ddr_wq(0) <= TCP_w_busy;
1706 when "01" => re_RETX_ddr_wq(1) <= TCP_w_busy;
1707 when others => re_RETX_ddr_wq(2) <= TCP_w_busy;
1711 when "00" => TCP_wFIFO_DI <= "00" & RETX_ddr_out(0);
1712 when "01" => TCP_wFIFO_DI <= "01" & RETX_ddr_out(1);
1713 when others => TCP_wFIFO_DI <= "10" & RETX_ddr_out(2);
1717 process(ClientClk2X)
1719 if(ClientClk2X'event and ClientClk2X = '1')then
1720 case EnSFP(2 downto 0) is
1721 when "010" | "011" | "101" | "111" => TCPIP2SFP_sel(0) <= "01";
1722 when "100" | "110" => TCPIP2SFP_sel(0) <= "10";
1723 when others => TCPIP2SFP_sel(0) <= "00";
1725 case EnSFP(2 downto 0) is
1726 when "010" | "011" | "111" => TCPIP2SFP_sel(1) <= "00";
1727 when "101" => TCPIP2SFP_sel(1) <= "10";
1728 when others => TCPIP2SFP_sel(1) <= "01";
1730 case EnSFP(2 downto 0) is
1731 when "100" | "101" | "110" => TCPIP2SFP_sel(2) <= "00";
1732 when others => TCPIP2SFP_sel(2) <= "10";
1734 for i in 0 to 1 loop
1735 SFP_EmacPhyTxc(i) <= EmacPhyTxc(conv_integer(TCPIP2SFP_sel(i)));
1736 SFP_EmacPhyTxD(i) <= EmacPhyTxD(conv_integer(TCPIP2SFP_sel(i)));
1737 SFP_down_i(i) <= LINK_down(conv_integer(TCPIP2SFP_sel(i)));
1739 if(TCPIP2SFP_sel(2)(1) = '0')then
1740 SFP_EmacPhyTxc(2) <= EmacPhyTxc(0);
1741 SFP_EmacPhyTxD(2) <= EmacPhyTxD(0);
1742 SFP_down_i(2) <= LINK_down(0);
1744 SFP_EmacPhyTxc(2) <= EmacPhyTxc(2);
1745 SFP_EmacPhyTxD(2) <= EmacPhyTxD(2);
1746 SFP_down_i(2) <= LINK_down(2);
1748 case EnSFP(2 downto 0) is
1749 when "010" | "011" | "111" => SFP2TCPIP(0) <= "01";
1750 when "100" | "101" | "110" => SFP2TCPIP(0) <= "10";
1751 when others => SFP2TCPIP(0) <= "00";
1753 case EnSFP(2 downto 0) is
1754 when "010" | "011" | "101" | "111" => SFP2TCPIP(1) <= "00";
1755 when others => SFP2TCPIP(1) <= "01";
1757 case EnSFP(2 downto 0) is
1758 when "100" | "110" => SFP2TCPIP(2) <= "00";
1759 when "101" => SFP2TCPIP(2) <= "01";
1760 when others => SFP2TCPIP(2) <= "10";
1762 PhyEmacRxc(0) <= SFP_PhyEmacRxc(conv_integer(SFP2TCPIP(0)));
1763 PhyEmacRxD(0) <= SFP_PhyEmacRxD(conv_integer(SFP2TCPIP(0)));
1764 if(SFP2TCPIP(1)(0) = '0')then
1765 PhyEmacRxc(1) <= SFP_PhyEmacRxc(0);
1766 PhyEmacRxD(1) <= SFP_PhyEmacRxD(0);
1768 PhyEmacRxc(1) <= SFP_PhyEmacRxc(1);
1769 PhyEmacRxD(1) <= SFP_PhyEmacRxD(1);
1771 PhyEmacRxc(2) <= SFP_PhyEmacRxc(conv_integer(SFP2TCPIP(2)));
1772 PhyEmacRxD(2) <= SFP_PhyEmacRxD(conv_integer(SFP2TCPIP(2)));
1773 IPADDR(0) <= SFP_IPADDR(conv_integer(SFP2TCPIP(0)));
1774 IPADDR(1) <= SFP_IPADDR(conv_integer(SFP2TCPIP(1)));
1775 IPADDR(2) <= SFP_IPADDR(conv_integer(SFP2TCPIP(2)));
1776 MACADDR(0) <= x"00ac1234568" & "10" & SFP2TCPIP(0);
1777 MACADDR(1) <= x"00ac1234568" & "100" & SFP2TCPIP(1)(0);
1778 MACADDR(2) <= x"00ac1234568" & "10" & SFP2TCPIP(2);
1779 reset_TCPIP(0) <= SFPresetSyncRegs(conv_integer(SFP2TCPIP(0)))(2);
1780 if(SFP2TCPIP(1)(0) = '0')then
1781 reset_TCPIP(1) <= SFPresetSyncRegs(conv_integer(SFP2TCPIP(0)))(2);
1783 reset_TCPIP(1) <= SFPresetSyncRegs(conv_integer(SFP2TCPIP(1)))(2);
1785 reset_TCPIP(2) <= SFPresetSyncRegs(conv_integer(SFP2TCPIP(2)))(2);
1788 g_XGbEPCS : for i in 0 to 2 generate
1790 reset => TCPresetSyncRegs
(2),
1791 clk2x => ClientClk2X,
1793 TXUSRCLK => txusrclk,
1795 RXUSRCLK => SFP_RXUSRCLK
(i
),
1796 RXRESETDONE => SFP_RXRESETDONE
(i
),
1797 inh_TX => inh_TX
(i
),
1798 RESET_TXSync => reset_TXSyncRegs
(2),
1799 GTX_RXGEARBOXSLIP_OUT => SFP_RXGEARBOXSLIP
(i
),
1800 GTX_TXD => SFP_TXD
(i
),
1801 GTX_TXHEADER => SFP_TXHEADER
(i
),
1802 GTX_TX_PAUSE => GTX_TX_PAUSE ,
1803 GTX_RXD => SFP_RXD
(i
),
1804 GTX_RXDVLD => SFP_RXDVLD
(i
),
1805 GTX_RXHEADER => SFP_RXHEADER
(i
),
1806 GTX_RXHEADERVLD => SFP_RXHEADERVLD
(i
),
1807 GTX_RXGOOD => SFP_RXGOOD
(i
),
1808 EmacPhyTxC => SFP_EmacPhyTxc
(i
),
1809 EmacPhyTxD => SFP_EmacPhyTxd
(i
),
1810 PhyEmacRxC => SFP_PhyEmacRxC
(i
),
1811 PhyEmacRxD => SFP_PhyEmacRxD
(i
)
1814 SFP_pd(0) <= "00" when Dis_pd = '1' else "11" when enSFP(3) = '1' or enSFP(0) = '0' else "00";
1815 SFP_pd(1) <= "00" when Dis_pd = '1' else "11" when enSFP(3) = '1' or enSFP(1) = '0' else "00";
1816 SFP_pd(2) <= "00" when Dis_pd = '1' else "11" when enSFP(3) = '1' or enSFP(2) = '0' else "00";
1817 SFP_gttxreset <= "111" when TCPreset = '1' else "000";
1818 SFP_gtrxreset <= "111" when TCPreset = '1' else "000";
1822 SYSCLK_IN => DRPclk,
1823 SOFT_RESET_IN => '0',
1824 DONT_RESET_ON_DATA_ERROR_IN => '0',
1825 GT0_TX_FSM_RESET_DONE_OUT => SFP_TX_FSM_RESET_DONE
(0),
1826 GT0_RX_FSM_RESET_DONE_OUT => SFP_RX_FSM_RESET_DONE
(0),
1827 GT0_DATA_VALID_IN => SFP_RXGOOD
(0),
1828 GT1_TX_FSM_RESET_DONE_OUT => SFP_TX_FSM_RESET_DONE
(1),
1829 GT1_RX_FSM_RESET_DONE_OUT => SFP_RX_FSM_RESET_DONE
(1),
1830 GT1_DATA_VALID_IN => SFP_RXGOOD
(1),
1831 GT2_TX_FSM_RESET_DONE_OUT => SFP_TX_FSM_RESET_DONE
(2),
1832 GT2_RX_FSM_RESET_DONE_OUT => SFP_RX_FSM_RESET_DONE
(2),
1833 GT2_DATA_VALID_IN => SFP_RXGOOD
(2),
1839 --_____________________________________________________________________
1840 --_____________________________________________________________________
1843 ---------------------------- Channel - DRP Ports --------------------------
1844 GT0_DRPADDR_IN => SFP_drpaddr
(0),
1845 GT0_DRPCLK_IN => DRPclk,
1846 GT0_DRPDI_IN => SFP_drpdi
(0),
1847 GT0_DRPDO_OUT => SFP_drpdo
(0),
1848 GT0_DRPEN_IN => SFP_drpen
(0),
1849 GT0_DRPRDY_OUT => SFP_drprdy
(0),
1850 GT0_DRPWE_IN => SFP_drpwe
(0),
1851 ------------------------------- Loopback Ports -----------------------------
1852 GT0_LOOPBACK_IN => SFP_LOOPBACK_IN
(0),
1853 ------------------------------ Power-Down Ports ----------------------------
1854 GT0_RXPD_IN => SFP_pd
(0),
1855 GT0_TXPD_IN => SFP_pd
(0),
1856 --------------------- RX Initialization and Reset Ports --------------------
1857 GT0_RXUSERRDY_IN => SFP_rxuserrdy
(0),
1858 -------------------------- RX Margin Analysis Ports ------------------------
1859 GT0_EYESCANDATAERROR_OUT => SFP_EYESCANDATAERROR_OUT
(0),
1860 ------------------------- Receive Ports - CDR Ports ------------------------
1861 GT0_RXCDRLOCK_OUT =>
open,
1862 ------------------ Receive Ports - FPGA RX Interface Ports -----------------
1863 GT0_RXUSRCLK_IN => SFP_RXUSRCLK
(0),
1864 GT0_RXUSRCLK2_IN => SFP_RXUSRCLK
(0),
1865 ------------------ Receive Ports - FPGA RX interface Ports -----------------
1866 GT0_RXDATA_OUT => SFP_RXD_inv
(0),
1867 ------------------- Receive Ports - Pattern Checker Ports ------------------
1868 GT0_RXPRBSERR_OUT => SFP_RXPRBSERR_OUT
(0),
1869 GT0_RXPRBSSEL_IN => SFP_RXPRBSSEL_IN
(0),
1870 ------------------- Receive Ports - Pattern Checker ports ------------------
1871 GT0_RXPRBSCNTRESET_IN => '0',
1872 --------------------------- Receive Ports - RX AFE -------------------------
1873 GT0_GTXRXP_IN => SFP0_RXP,
1874 ------------------------ Receive Ports - RX AFE Ports ----------------------
1875 GT0_GTXRXN_IN => SFP0_RXN,
1876 ------------------- Receive Ports - RX Buffer Bypass Ports -----------------
1877 GT0_RXBUFRESET_IN => '0',
1878 GT0_RXBUFSTATUS_OUT =>
open,
1879 --------------- Receive Ports - RX Fabric Output Control Ports -------------
1880 GT0_RXOUTCLK_OUT => SFP_rxoutclk
(0),
1881 ---------------------- Receive Ports - RX Gearbox Ports --------------------
1882 GT0_RXDATAVALID_OUT => SFP_RXDVLD
(0),
1883 GT0_RXHEADER_OUT => SFP_RXHEADER
(0),
1884 GT0_RXHEADERVALID_OUT => SFP_RXHEADERVLD
(0),
1885 --------------------- Receive Ports - RX Gearbox Ports --------------------
1886 GT0_RXGEARBOXSLIP_IN => SFP_RXGEARBOXSLIP
(0),
1887 ------------- Receive Ports - RX Initialization and Reset Ports ------------
1888 GT0_GTRXRESET_IN => SFP_gtrxreset
(0),
1889 GT0_RXPMARESET_IN => '0',
1890 ------------------ Receive Ports - RX Margin Analysis ports ----------------
1891 GT0_RXLPMEN_IN => '0',
1892 -------------- Receive Ports -RX Initialization and Reset Ports ------------
1893 GT0_RXRESETDONE_OUT => SFP_rxresetdone
(0),
1894 --------------------- TX Initialization and Reset Ports --------------------
1895 GT0_GTTXRESET_IN => SFP_gttxreset
(0),
1896 GT0_TXUSERRDY_IN => SFP_txuserrdy
(0),
1897 ------------------ Transmit Ports - FPGA TX Interface Ports ----------------
1898 GT0_TXUSRCLK_IN => txusrclk,
1899 GT0_TXUSRCLK2_IN => txusrclk,
1900 --------------- Transmit Ports - TX Configurable Driver Ports --------------
1901 GT0_TXDIFFCTRL_IN => "
1110",
1902 GT0_TXINHIBIT_IN => '0',
1903 GT0_TXMAINCURSOR_IN =>
(others => '0'
),
1904 ------------------ Transmit Ports - TX Data Path interface -----------------
1905 GT0_TXDATA_IN => SFP_TXD_inv
(0),
1906 ---------------- Transmit Ports - TX Driver and OOB signaling --------------
1907 GT0_GTXTXN_OUT => SFP0_TXN,
1908 GT0_GTXTXP_OUT => SFP0_TXP,
1909 ----------- Transmit Ports - TX Fabric Clock Output Control Ports ----------
1910 GT0_TXOUTCLK_OUT => SFP_TXOUTCLK
(0),
1911 GT0_TXOUTCLKFABRIC_OUT =>
open,
1912 GT0_TXOUTCLKPCS_OUT =>
open,
1913 --------------------- Transmit Ports - TX Gearbox Ports --------------------
1914 GT0_TXHEADER_IN => SFP_TXHEADER
(0),
1915 GT0_TXSEQUENCE_IN => SFP_TXSEQUENCE
(0),
1916 ------------- Transmit Ports - TX Initialization and Reset Ports -----------
1917 GT0_TXRESETDONE_OUT => SFP_txresetdone
(0),
1918 ------------------ Transmit Ports - pattern Generator Ports ----------------
1919 GT0_TXPRBSSEL_IN => SFP_TXPRBSSEL_IN
(0),
1926 --_____________________________________________________________________
1927 --_____________________________________________________________________
1930 ---------------------------- Channel - DRP Ports --------------------------
1931 GT1_DRPADDR_IN => SFP_drpaddr
(1),
1932 GT1_DRPCLK_IN => DRPclk,
1933 GT1_DRPDI_IN => SFP_drpdi
(1),
1934 GT1_DRPDO_OUT => SFP_drpdo
(1),
1935 GT1_DRPEN_IN => SFP_drpen
(1),
1936 GT1_DRPRDY_OUT => SFP_drprdy
(1),
1937 GT1_DRPWE_IN => SFP_drpwe
(1),
1938 ------------------------------- Loopback Ports -----------------------------
1939 GT1_LOOPBACK_IN => SFP_LOOPBACK_IN
(1),
1940 ------------------------------ Power-Down Ports ----------------------------
1941 GT1_RXPD_IN => SFP_pd
(1),
1942 GT1_TXPD_IN => SFP_pd
(1),
1943 --------------------- RX Initialization and Reset Ports --------------------
1944 GT1_RXUSERRDY_IN => SFP_rxuserrdy
(1),
1945 -------------------------- RX Margin Analysis Ports ------------------------
1946 GT1_EYESCANDATAERROR_OUT => SFP_EYESCANDATAERROR_OUT
(1),
1947 ------------------------- Receive Ports - CDR Ports ------------------------
1948 GT1_RXCDRLOCK_OUT =>
open,
1949 ------------------ Receive Ports - FPGA RX Interface Ports -----------------
1950 GT1_RXUSRCLK_IN => SFP_RXUSRCLK
(1),
1951 GT1_RXUSRCLK2_IN => SFP_RXUSRCLK
(1),
1952 ------------------ Receive Ports - FPGA RX interface Ports -----------------
1953 GT1_RXDATA_OUT => SFP_RXD_inv
(1),
1954 ------------------- Receive Ports - Pattern Checker Ports ------------------
1955 GT1_RXPRBSERR_OUT => SFP_RXPRBSERR_OUT
(1),
1956 GT1_RXPRBSSEL_IN => SFP_RXPRBSSEL_IN
(1),
1957 ------------------- Receive Ports - Pattern Checker ports ------------------
1958 GT1_RXPRBSCNTRESET_IN => '0',
1959 --------------------------- Receive Ports - RX AFE -------------------------
1960 GT1_GTXRXP_IN => SFP1_RXP,
1961 ------------------------ Receive Ports - RX AFE Ports ----------------------
1962 GT1_GTXRXN_IN => SFP1_RXN,
1963 ------------------- Receive Ports - RX Buffer Bypass Ports -----------------
1964 GT1_RXBUFRESET_IN => '0',
1965 GT1_RXBUFSTATUS_OUT =>
open,
1966 --------------- Receive Ports - RX Fabric Output Control Ports -------------
1967 GT1_RXOUTCLK_OUT => SFP_rxoutclk
(1),
1968 ---------------------- Receive Ports - RX Gearbox Ports --------------------
1969 GT1_RXDATAVALID_OUT => SFP_RXDVLD
(1),
1970 GT1_RXHEADER_OUT => SFP_RXHEADER
(1),
1971 GT1_RXHEADERVALID_OUT => SFP_RXHEADERVLD
(1),
1972 --------------------- Receive Ports - RX Gearbox Ports --------------------
1973 GT1_RXGEARBOXSLIP_IN => SFP_RXGEARBOXSLIP
(1),
1974 ------------- Receive Ports - RX Initialization and Reset Ports ------------
1975 GT1_GTRXRESET_IN => SFP_gtrxreset
(1),
1976 GT1_RXPMARESET_IN => '0',
1977 ------------------ Receive Ports - RX Margin Analysis ports ----------------
1978 GT1_RXLPMEN_IN => '0',
1979 -------------- Receive Ports -RX Initialization and Reset Ports ------------
1980 GT1_RXRESETDONE_OUT => SFP_rxresetdone
(1),
1981 --------------------- TX Initialization and Reset Ports --------------------
1982 GT1_GTTXRESET_IN => SFP_gttxreset
(1),
1983 GT1_TXUSERRDY_IN => SFP_txuserrdy
(1),
1984 ------------------ Transmit Ports - FPGA TX Interface Ports ----------------
1985 GT1_TXUSRCLK_IN => txusrclk,
1986 GT1_TXUSRCLK2_IN => txusrclk,
1987 --------------- Transmit Ports - TX Configurable Driver Ports --------------
1988 GT1_TXDIFFCTRL_IN => "
1110",
1989 GT1_TXINHIBIT_IN => '0',
1990 GT1_TXMAINCURSOR_IN =>
(others => '0'
),
1991 ------------------ Transmit Ports - TX Data Path interface -----------------
1992 GT1_TXDATA_IN => SFP_TXD_inv
(1),
1993 ---------------- Transmit Ports - TX Driver and OOB signaling --------------
1994 GT1_GTXTXN_OUT => SFP1_TXN,
1995 GT1_GTXTXP_OUT => SFP1_TXP,
1996 ----------- Transmit Ports - TX Fabric Clock Output Control Ports ----------
1997 GT1_TXOUTCLK_OUT =>
open,
1998 GT1_TXOUTCLKFABRIC_OUT =>
open,
1999 GT1_TXOUTCLKPCS_OUT =>
open,
2000 --------------------- Transmit Ports - TX Gearbox Ports --------------------
2001 GT1_TXHEADER_IN => SFP_TXHEADER
(1),
2002 GT1_TXSEQUENCE_IN => SFP_TXSEQUENCE
(1),
2003 ------------- Transmit Ports - TX Initialization and Reset Ports -----------
2004 GT1_TXRESETDONE_OUT => SFP_txresetdone
(1),
2005 ------------------ Transmit Ports - pattern Generator Ports ----------------
2006 GT1_TXPRBSSEL_IN => SFP_TXPRBSSEL_IN
(1),
2009 --_____________________________________________________________________
2010 --_____________________________________________________________________
2013 ---------------------------- Channel - DRP Ports --------------------------
2014 GT2_DRPADDR_IN => SFP_drpaddr
(2),
2015 GT2_DRPCLK_IN => DRPclk,
2016 GT2_DRPDI_IN => SFP_drpdi
(2),
2017 GT2_DRPDO_OUT => SFP_drpdo
(2),
2018 GT2_DRPEN_IN => SFP_drpen
(2),
2019 GT2_DRPRDY_OUT => SFP_drprdy
(2),
2020 GT2_DRPWE_IN => SFP_drpwe
(2),
2021 ------------------------------- Loopback Ports -----------------------------
2022 GT2_LOOPBACK_IN => SFP_LOOPBACK_IN
(2),
2023 ------------------------------ Power-Down Ports ----------------------------
2024 GT2_RXPD_IN => SFP_pd
(2),
2025 GT2_TXPD_IN => SFP_pd
(2),
2026 --------------------- RX Initialization and Reset Ports --------------------
2027 GT2_RXUSERRDY_IN => SFP_rxuserrdy
(2),
2028 -------------------------- RX Margin Analysis Ports ------------------------
2029 GT2_EYESCANDATAERROR_OUT => SFP_EYESCANDATAERROR_OUT
(2),
2030 ------------------------- Receive Ports - CDR Ports ------------------------
2031 GT2_RXCDRLOCK_OUT =>
open,
2032 ------------------ Receive Ports - FPGA RX Interface Ports -----------------
2033 GT2_RXUSRCLK_IN => SFP_RXUSRCLK
(2),
2034 GT2_RXUSRCLK2_IN => SFP_RXUSRCLK
(2),
2035 ------------------ Receive Ports - FPGA RX interface Ports -----------------
2036 GT2_RXDATA_OUT => SFP_RXD_inv
(2),
2037 ------------------- Receive Ports - Pattern Checker Ports ------------------
2038 GT2_RXPRBSERR_OUT => SFP_RXPRBSERR_OUT
(2),
2039 GT2_RXPRBSSEL_IN => SFP_RXPRBSSEL_IN
(2),
2040 ------------------- Receive Ports - Pattern Checker ports ------------------
2041 GT2_RXPRBSCNTRESET_IN => '0',
2042 --------------------------- Receive Ports - RX AFE -------------------------
2043 GT2_GTXRXP_IN => SFP2_RXP,
2044 ------------------------ Receive Ports - RX AFE Ports ----------------------
2045 GT2_GTXRXN_IN => SFP2_RXN,
2046 ------------------- Receive Ports - RX Buffer Bypass Ports -----------------
2047 GT2_RXBUFRESET_IN => '0',
2048 GT2_RXBUFSTATUS_OUT =>
open,
2049 --------------- Receive Ports - RX Fabric Output Control Ports -------------
2050 GT2_RXOUTCLK_OUT => SFP_rxoutclk
(2),
2051 ---------------------- Receive Ports - RX Gearbox Ports --------------------
2052 GT2_RXDATAVALID_OUT => SFP_RXDVLD
(2),
2053 GT2_RXHEADER_OUT => SFP_RXHEADER
(2),
2054 GT2_RXHEADERVALID_OUT => SFP_RXHEADERVLD
(2),
2055 --------------------- Receive Ports - RX Gearbox Ports --------------------
2056 GT2_RXGEARBOXSLIP_IN => SFP_RXGEARBOXSLIP
(2),
2057 ------------- Receive Ports - RX Initialization and Reset Ports ------------
2058 GT2_GTRXRESET_IN => SFP_gtrxreset
(2),
2059 GT2_RXPMARESET_IN => '0',
2060 ------------------ Receive Ports - RX Margin Analysis ports ----------------
2061 GT2_RXLPMEN_IN => '0',
2062 -------------- Receive Ports -RX Initialization and Reset Ports ------------
2063 GT2_RXRESETDONE_OUT => SFP_rxresetdone
(2),
2064 --------------------- TX Initialization and Reset Ports --------------------
2065 GT2_GTTXRESET_IN => SFP_gttxreset
(2),
2066 GT2_TXUSERRDY_IN => SFP_txuserrdy
(2),
2067 ------------------ Transmit Ports - FPGA TX Interface Ports ----------------
2068 GT2_TXUSRCLK_IN => txusrclk,
2069 GT2_TXUSRCLK2_IN => txusrclk,
2070 --------------- Transmit Ports - TX Configurable Driver Ports --------------
2071 GT2_TXDIFFCTRL_IN => "
1110",
2072 GT2_TXINHIBIT_IN => '0',
2073 GT2_TXMAINCURSOR_IN =>
(others => '0'
),
2074 ------------------ Transmit Ports - TX Data Path interface -----------------
2075 GT2_TXDATA_IN => SFP_TXD_inv
(2),
2076 ---------------- Transmit Ports - TX Driver and OOB signaling --------------
2077 GT2_GTXTXN_OUT => SFP2_TXN,
2078 GT2_GTXTXP_OUT => SFP2_TXP,
2079 ----------- Transmit Ports - TX Fabric Clock Output Control Ports ----------
2080 GT2_TXOUTCLK_OUT =>
open,
2081 GT2_TXOUTCLKFABRIC_OUT =>
open,
2082 GT2_TXOUTCLKPCS_OUT =>
open,
2083 --------------------- Transmit Ports - TX Gearbox Ports --------------------
2084 GT2_TXHEADER_IN => SFP_TXHEADER
(2),
2085 GT2_TXSEQUENCE_IN => SFP_TXSEQUENCE
(2),
2086 ------------- Transmit Ports - TX Initialization and Reset Ports -----------
2087 GT2_TXRESETDONE_OUT => SFP_txresetdone
(2),
2088 ------------------ Transmit Ports - pattern Generator Ports ----------------
2089 GT2_TXPRBSSEL_IN => SFP_TXPRBSSEL_IN
(2),
2092 --____________________________COMMON PORTS________________________________
2093 ---------------------- Common Block - Ref Clock Ports ---------------------
2094 GT0_GTREFCLK0_COMMON_IN => REFCLK,
2095 ------------------------- Common Block - QPLL Ports ------------------------
2096 GT0_QPLLLOCK_OUT => qplllock,
2097 GT0_QPLLLOCKDETCLK_IN => DRPclk,
2098 GT0_QPLLRESET_IN => qpllreset
2101 process(SFP_TXD,SFP_RXD,SFP_RXD_inv)
2103 for j in 0 to 2 loop
2104 for i in 0 to 31 loop
2105 SFP_TXD_inv(j)(i) <= SFP_TXD(j)(31-i);
2106 SFP_RXD(j)(i) <= SFP_RXD_inv(j)(31-i);
2110 i_REFCLK : IBUFDS_GTE2
port map(O => REFCLK, ODIV2 =>
open, CEB => '0', I => SFP_REFCLK_P, IB => SFP_REFCLK_N
);
2111 i_txusrclk : BUFG
port map (I => SFP_TXOUTCLK
(0), O => txusrclk
);
2112 g_SFP_rxusrclk : for i in 0 to 2 generate
2113 i_SFP_rxusrclk : BUFG
port map (I => SFP_RXOUTCLK
(i
), O => SFP_rxusrclk
(i
));
2115 i_REFCLK2X_in: bufg
port map(i => REFCLK, o => REFCLK2X_in
);
2116 i_ClientClk2X : BUFG
port map (I => ClientClk2X_dcm, O => ClientClk2X
);
2117 i_ClientClk : BUFG
port map (I => ClientClk_dcm, O => ClientClk
);
2118 i_REFCLK2XPLLRST : SRL16
generic map(INIT => x"ffff"
)
2120 Q => REFCLK2XPLLRST,
-- SRL data output
2121 A0 => '1',
-- Select[0] input
2122 A1 => '1',
-- Select[1] input
2123 A2 => '1',
-- Select[2] input
2124 A3 => '1',
-- Select[3] input
2125 CLK => REFCLK2X_in,
-- Clock input
2126 D => '0'
-- SRL data input
2128 i_REFCLK2XPLL : PLLE2_BASE
2130 BANDWIDTH =>
"OPTIMIZED",
-- OPTIMIZED, HIGH, LOW
2131 CLKFBOUT_MULT =>
8,
-- Multiply value for all CLKOUT, (2-64)
2132 CLKFBOUT_PHASE =>
0.0,
-- Phase offset in degrees of CLKFB, (-360.000-360.000).
2133 CLKIN1_PERIOD =>
6.4,
-- Input clock period in ns to ps resolution (i.e. 33.
333 is 30 MHz).
2134 -- CLKOUT0_DIVIDE - CLKOUT5_DIVIDE: Divide amount for each CLKOUT (1-128)
2135 CLKOUT0_DIVIDE =>
4,
2136 DIVCLK_DIVIDE =>
1,
-- Master division value, (1-56)
2137 REF_JITTER1 =>
0.0,
-- Reference input jitter in UI, (0.000-0.
999).
2138 STARTUP_WAIT =>
"FALSE" -- Delay DONE until PLL Locks, ("TRUE"/"FALSE")
2141 -- Clock Outputs: 1-bit (each) output: User configurable clock outputs
2142 CLKOUT0 => ClientClk2X_dcm ,
2143 -- Feedback Clocks: 1-bit (each) output: Clock feedback ports
2144 CLKFBOUT => ClientClk_dcm,
-- 1-bit output: Feedback clock
2145 -- Status Port: 1-bit (each) output: PLL status ports
2146 LOCKED => ClientClk_lock,
-- 1-bit output: LOCK
2147 -- Clock Input: 1-bit (each) input: Clock input
2148 CLKIN1 => REFCLK2X_in,
-- 1-bit input: Input clock
2149 -- Control Ports: 1-bit (each) input: PLL control ports
2150 PWRDWN => '0',
-- 1-bit input: Power-down
2151 RST => REFCLK2XPLLRST,
-- 1-bit input: Reset
2152 -- Feedback Clocks: 1-bit (each) input: Clock feedback ports
2153 CLKFBIN => ClientClk
-- 1-bit input: Feedback clock
2157 if(ipb_clk'event and ipb_clk = '1')then
2158 if(ipb_addr(15 downto 0) = x"1c20" and ipb_write = '1' and ipb_strobe = '1')then
2159 en_stop <= ipb_wdata(4 downto 0);
2164 variable s : (1 downto 0);
2166 case ipb_addr(11 downto 10) is
2168 case enSFP(2 downto 0) is
2169 when "010" | "011" | "101" | "111" => s := "01";
2170 when "110" => s := "10";
2171 when others => s := "00";
2174 case enSFP(2 downto 0) is
2175 when "010" | "011" | "111" => s := "00";
2176 when "101" => s := "10";
2177 when others => s := "01";
2180 case enSFP(2 downto 0) is
2181 when "100" | "101" | "110" => s := "00";
2182 when others => s := "10";
2184 when others => s := "11";
2186 if(ipb_addr(15 downto 12) = x"1")then
2189 if(ipb_addr(9 downto 8) = "11")then
2190 case ipb_addr(3 downto 0) is
2191 when x"0" => ipb_rdata <= TotalEvtLengthCntr(0)(31 downto 0);
2192 when x"1" => ipb_rdata <= x"00" & TotalEvtLengthCntr(0)(55 downto 32);
2193 when x"2" => ipb_rdata <= EvtLength_errCntr(0);
2194 when x"3" => ipb_rdata <= AMClength_errCntr(0);
2195 when x"4" => ipb_rdata <= AMCvalid_errCntr(0);
2196 when x"5" => ipb_rdata <= AMCcrc_errCntr(0);
2197 when others => ipb_rdata <= (others => '0');
2200 ipb_rdata <= TCPIP_rdata(0);
2203 if(ipb_addr(9 downto 8) = "11")then
2204 case ipb_addr(3 downto 0) is
2205 when x"0" => ipb_rdata <= TotalEvtLengthCntr(1)(31 downto 0);
2206 when x"1" => ipb_rdata <= x"00" & TotalEvtLengthCntr(1)(55 downto 32);
2207 when x"2" => ipb_rdata <= EvtLength_errCntr(1);
2208 when x"3" => ipb_rdata <= AMClength_errCntr(1);
2209 when x"4" => ipb_rdata <= AMCvalid_errCntr(1);
2210 when x"5" => ipb_rdata <= AMCcrc_errCntr(1);
2211 when others => ipb_rdata <= (others => '0');
2214 ipb_rdata <= TCPIP_rdata(0);
2217 if(ipb_addr(9 downto 8) = "11")then
2218 case ipb_addr(3 downto 0) is
2219 when x"0" => ipb_rdata <= TotalEvtLengthCntr(2)(31 downto 0);
2220 when x"1" => ipb_rdata <= x"00" & TotalEvtLengthCntr(2)(55 downto 32);
2221 when x"2" => ipb_rdata <= EvtLength_errCntr(2);
2222 when x"3" => ipb_rdata <= AMClength_errCntr(2);
2223 when x"4" => ipb_rdata <= AMCvalid_errCntr(2);
2224 when x"5" => ipb_rdata <= AMCcrc_errCntr(2);
2225 when others => ipb_rdata <= (others => '0');
2228 ipb_rdata <= TCPIP_rdata(0);
2231 case ipb_addr(5 downto 4) is
2233 case ipb_addr(3 downto 0) is
2234 when x"0" => ipb_rdata <= "00000" & NXT_MonBuf(1) & "00000" & NXT_MonBuf(0);
2235 when x"1" => ipb_rdata <= x"0000" & "00000" & NXT_MonBuf(2);
2236 when x"2" => ipb_rdata <= "00000" & UNA_MonBuf(1) & "00000" & UNA_MonBuf(0);
2237 when x"3" => ipb_rdata <= "00000" & UNA_MonBuf(3) & "00000" & UNA_MonBuf(2);
2238 when x"4" => ipb_rdata <= x"0000" & "00000" & UNA_MonBuf(4);
2239 when x"5" => ipb_rdata <= x"0" & NXT_TCPBuf(1) & x"0" & NXT_TCPBuf(0);
2240 when x"6" => ipb_rdata <= x"00000" & NXT_TCPBuf(2);
2241 when x"7" => ipb_rdata <= "00000" & UNA_TCPBuf(1) & "00000" & UNA_TCPBuf(0);
2242 when x"8" => ipb_rdata <= "00000" & UNA_TCPBuf(3) & "00000" & UNA_TCPBuf(2);
2243 when x"9" => ipb_rdata <= "00000" & Written_MonBuf(1) & "00000" & Written_MonBuf(0);
2244 when x"a" => ipb_rdata <= "00000" & Written_MonBuf(3) & "00000" & Written_MonBuf(2);
2245 when x"b" => ipb_rdata <= '0' & ReadBusy & x"000" & "00" & sfp_pd(2) & sfp_pd(1) & sfp_pd(0) & '0' & SFP_TX_FSM_RESET_DONE & '0' & SFP_RX_FSM_RESET_DONE;
2246 when x"c" => ipb_rdata <= x"000" & SFP2TCPIP(2) & SFP2TCPIP(1) & SFP2TCPIP(0) & TCPIP2SFP_sel(2) & TCPIP2SFP_sel(1) & TCPIP2SFP_sel(0) & '0' & EnTCPIP & '0' & LINK_down;
2247 when x"d" => ipb_rdata <= cmsCRC_errCntr(0);
2248 when x"e" => ipb_rdata <= cmsCRC_errCntr(1);
2249 when others => ipb_rdata <= cmsCRC_errCntr(2);
2252 case ipb_addr(3 downto 0) is
2253 when x"0" => ipb_rdata <= '0' & RETX_ddr_rrqst & '0' & RETX_ddr_wrqst & '0' & EVENTdata_avl & '0' & AddrBuf_full & '0' & evt_FIFO_full & '0' & wport_FIFO_full & '0' & wport_rdy & '0' & evt_data_rdy;
2254 when x"1" => ipb_rdata <= TCP_rrqst_i & TCP_rFIFO_ra & "000" & TCP_rFIFO_wa & "00" & rrqstMask & '0' & RETXdataAck & '0' & RETXdataRqst;
2255 when x"2" => ipb_rdata <= "00000" & MonBuf_wa & "00000" & MonBuf_ra;
2256 when x"3" => ipb_rdata <= EventData_reCntr(0);
2257 when x"4" => ipb_rdata <= EventData_reCntr(1);
2258 when x"5" => ipb_rdata <= EventData_reCntr(2);
2259 when x"6" => ipb_rdata <= EventBufAddr_weCntr(0);
2260 when x"7" => ipb_rdata <= EventBufAddr_weCntr(1);
2261 when x"8" => ipb_rdata <= EventBufAddr_weCntr(2);
2262 when x"9" => ipb_rdata <= EventData_weCntr(0);
2263 when x"a" => ipb_rdata <= EventData_weCntr(1);
2264 when x"b" => ipb_rdata <= EventData_weCntr(2);
2265 when x"c" => ipb_rdata <= SFP_IPADDR(0);
2266 when x"d" => ipb_rdata <= SFP_IPADDR(1);
2267 when x"e" => ipb_rdata <= SFP_IPADDR(2);
2268 when others => ipb_rdata <= CWND_max;
2271 case ipb_addr(3 downto 0) is
2272 when x"0" => ipb_rdata <= x"000000" & "000" & en_stop;
2273 when x"4" => ipb_rdata <= SFP_evt_cntr(0);
2274 when x"5" => ipb_rdata <= SFP_evt_cntr(1);
2275 when x"6" => ipb_rdata <= SFP_evt_cntr(2);
2276 when x"8" => ipb_rdata <= SFP_word_cntr(0);
2277 when x"9" => ipb_rdata <= SFP_word_cntr(1);
2278 when x"a" => ipb_rdata <= SFP_word_cntr(2);
2279 when x"c" => ipb_rdata <= SFP_blk_cntr(0);
2280 when x"d" => ipb_rdata <= SFP_blk_cntr(1);
2281 when x"e" => ipb_rdata <= SFP_blk_cntr(2);
2282 when others => ipb_rdata <= (others => '0');
2284 when others => ipb_rdata <= (others => '0');
2288 ipb_rdata <= (others => '0');
2293 if(ipb_clk'event and ipb_clk = '1')then
2294 if(ipb_addr(27) = '0' and ipb_addr(15 downto 2) = "00011100000111" and ipb_strobe = '1' and ipb_write = '1')then
2295 if(ipb_addr(1 downto 0) = "11")then
2296 CWND_max <= x"0" & ipb_wdata(27 downto 0);
2298 SFP_IPADDR(conv_integer(ipb_addr(1 downto 0))) <= ipb_wdata;