1 ----------------------------------------------------------------------------------
5 -- Create Date: 14:
49:
29 05/12/2010
7 -- Module Name: DTC_T2 - 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;
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;
41 VAUXP : in (12 downto 0);
42 VAUXN : in (12 downto 0);
46 SFP_SCL : out (3 downto 0);
47 SFP_SDA : inout (3 downto 0);
49 SFP_LOS : in (2 downto 0);
50 SFP_ABS : in (3 downto 0);
51 TxFault : in (3 downto 0);
52 TxDisable : out (3 downto 0);
53 -- RATE : out (3 downto 0);
77 ddr3_dq : inout (31 downto 0);
78 ddr3_addr : out (13 downto 0);
79 ddr3_ba : out (2 downto 0);
80 ddr3_dm : out (3 downto 0);
81 ddr3_dqs_p : inout (3 downto 0);
82 ddr3_dqs_n : inout (3 downto 0);
87 ddr3_cke : out (0 to 0);
88 ddr3_odt : out (0 to 0);
89 ddr3_ck_p : out (0 to 0);
90 ddr3_ck_n : out (0 to 0);
109 AMC_RXN : in (12 downto 1);
110 AMC_RXP : in (12 downto 1);
111 AMC_TXN : out (12 downto 1);
112 AMC_TXP : out (12 downto 1);
113 -- signal to/from DTC_T2
136 Trigdata :
in array12x8;
138 AMC_en :
in (
11 downto 0);
139 BC0_lock :
in (
11 downto 0);
140 BX_offset2SC :
out (
11 downto 0);
144 ipb_addr :
IN (
31 downto 0);
145 ipb_wdata :
IN (
31 downto 0);
150 ipb_rdata :
OUT (
31 downto 0);
161 TTS :
IN (
3 downto 0);
186 BCN_off :
IN (
12 downto 0);
187 OC_off :
IN (
3 downto 0);
189 trig_BX :
IN (
12 downto 0);
190 cal_win_high :
IN (
11 downto 0);
191 cal_win_low :
IN (
11 downto 0);
193 LocalL1A_cfg :
IN (
31 downto 0);
204 ipb_addr :
IN (
31 downto 0);
205 ipb_wdata :
IN (
31 downto 0);
207 state :
IN (
3 downto 0);
217 CalType :
OUT (
3 downto 0);
218 TTC_Brcst :
OUT (
3 downto 0);
219 localL1A_periodic :
OUT ;
220 ipb_rdata :
OUT (
31 downto 0);
223 ttc_soft_reset :
OUT ;
235 ttc_evcnt_reset :
OUT ;
236 event_number_avl :
OUT ;
237 event_number :
OUT (
59 downto 0)
241 Generic (simulation : := false);
252 AllEventBuilt :
OUT ;
256 enSFP :
IN (
3 downto 0);
261 fake_length :
IN (
19 downto 0);
262 T1_version :
IN (
7 downto 0);
263 Source_ID :
IN array3x12;
264 AMC_en :
IN (
11 downto 0);
265 TTS_disable :
IN (
11 downto 0);
268 AMC_RXN :
IN (
12 downto 1);
269 AMC_RXP :
IN (
12 downto 1);
270 evt_data_re :
IN (
2 downto 0);
271 evt_buf_full :
IN (
2 downto 0);
272 ddr_pa :
IN (
9 downto 0);
278 ipb_addr :
IN (
31 downto 0);
279 ipb_wdata :
IN (
31 downto 0);
283 ttc_evcnt_reset :
IN ;
284 event_number_avl :
IN ;
285 event_number :
IN (
59 downto 0);
286 AMC_Ready :
OUT (
11 downto 0);
288 BC0_lock :
OUT (
11 downto 0);
289 AMC_TXN :
OUT (
12 downto 1);
290 AMC_TXP :
OUT (
12 downto 1);
291 AMC_status :
OUT (
31 downto 0);
292 evt_data :
OUT array3x67;
293 evt_data_we :
OUT (
2 downto 0);
294 evt_data_rdy :
OUT (
2 downto 0);
295 mon_evt_wc :
OUT (
47 downto 0);
296 mon_ctrl :
OUT (
31 downto 0);
297 buf_rqst :
OUT (
3 downto 0);
298 ipb_rdata :
OUT (
31 downto 0);
302 TrigData :
OUT array12x8;
303 TTS_RQST :
OUT (
2 downto 0);
304 TTS_coded :
OUT (
4 downto 0)
312 addr :
IN (
31 downto 0);
313 SFP_ABS :
IN (
3 downto 0);
314 SFP_LOS :
IN (
2 downto 0);
316 SFP_SDA :
INOUT (
3 downto 0);
317 rdata :
OUT (
31 downto 0);
320 SFP_SCL :
OUT (
3 downto 0)
328 SN :
IN (
8 downto 0);
331 SPI_rdata :
IN (
7 downto 0);
336 IPADDR :
OUT (
31 downto 0);
337 SPI_wdata :
OUT (
7 downto 0);
338 SPI_addr :
OUT (
7 downto 0)
352 mem_test :
in (
1 downto 0);
353 EventData :
in array3X67;
354 EventData_we :
in (
2 downto 0);
355 wport_rdy :
out (
2 downto 0);
356 WrtMonBlkDone :
OUT (
2 downto 0);
357 WrtMonEvtDone :
OUT (
2 downto 0);
358 KiloByte_toggle :
OUT (
2 downto 0);
359 EoB_toggle :
OUT (
2 downto 0);
360 EventBufAddr :
in array3x14;
361 EventBufAddr_we :
in (
2 downto 0);
362 EventFIFOfull :
out (
2 downto 0);
363 TCP_din :
in (
31 downto 0);
364 TCP_channel :
in (
1 downto 0);
366 TCP_wcount :
out (
2 downto 0);
367 TCP_dout :
out (
31 downto 0);
-- TCP data are written in unit of 32-bit words
368 TCP_dout_type :
out (
2 downto 0);
-- TCP data destination
369 TCP_raddr :
in (
28 downto 0);
-- 28-26 encoded request source 25-0 address in 64 word
370 TCP_length :
in (
12 downto 0);
-- in 64 word, actual length -
1
371 TCP_dout_valid :
out ;
375 cs_out :
out (
511 downto 0);
380 page_addr :
in (
9 downto 0);
381 ipb_addr :
in (
31 downto 0);
382 ipb_wdata :
in (
31 downto 0);
383 ipb_rdata :
out (
31 downto 0);
385 mem_stat :
out (
63 downto 0);
386 device_temp :
in (
11 downto 0);
388 ddr3_dq :
inout (
31 downto 0);
389 ddr3_dm :
out (
3 downto 0);
390 ddr3_addr :
out (
13 downto 0);
391 ddr3_ba :
out (
2 downto 0);
392 ddr3_dqs_p :
inout (
3 downto 0);
393 ddr3_dqs_n :
inout (
3 downto 0);
398 ddr3_cke :
out (
0 to 0);
399 ddr3_odt :
out (
0 to 0);
400 ddr3_ck_p :
out (
0 to 0);
401 ddr3_ck_n :
out (
0 to 0)
405 generic(RXPOLARITY : := '
0'; TXPOLARITY : := '
0');
419 amc_en :
in (
11 downto 0);
421 IPADDR :
in (
31 downto 0);
422 MACADDR :
in (
47 downto 0);
423 ipb_out :
out ipb_wbus;
424 ipb_in :
in ipb_rbus;
425 SN :
out (
8 downto 0);
426 debug_in :
IN (
31 downto 0);
427 debug_out :
OUT (
127 downto 0)
434 SN :
IN (
8 downto 0);
435 VAUXN_IN :
IN (
12 downto 0);
436 VAUXP_IN :
IN (
12 downto 0);
437 addr :
IN (
15 downto 0);
438 data :
OUT (
31 downto 0);
439 device_temp :
OUT (
11 downto 0);
440 ALM :
OUT (
7 downto 0);
456 enSFP :
IN (
3 downto 0);
457 SFP_ABS :
IN (
2 downto 0);
458 LSC_ID :
IN (
15 downto 0);
460 evt_data_rdy :
IN (
2 downto 0);
461 EventData_in :
IN array3x67;
462 EventData_we :
IN (
2 downto 0);
463 buf_rqst :
IN (
3 downto 0);
465 WrtMonBlkDone :
IN (
2 downto 0);
466 WrtMonEvtDone :
IN (
2 downto 0);
467 wport_rdy :
IN (
2 downto 0);
468 wport_FIFO_full :
IN (
2 downto 0);
481 ipb_addr :
IN (
31 downto 0);
482 ipb_wdata :
IN (
31 downto 0);
483 SFP_down :
OUT (
2 downto 0);
484 EventData_re :
OUT (
2 downto 0);
485 evt_buf_full :
OUT (
2 downto 0);
486 MonBufOverWrite :
IN ;
491 mon_evt_cnt :
OUT (
31 downto 0);
492 EventBufAddr_we :
OUT (
2 downto 0);
493 EventBufAddr :
OUT array3x14;
500 ipb_rdata :
OUT (
31 downto 0);
505 generic (simulation : := false; en_KEEPALIVE : := '
1');
512 SN :
IN (
8 downto 0);
514 enSFP :
IN (
3 downto 0);
515 SFP_down :
OUT (
2 downto 0);
518 evt_data_rdy :
in (
2 downto 0);
519 EventData_in :
in array3X67;
520 EventData_we :
in (
2 downto 0);
521 EventData_re :
out (
2 downto 0);
--
522 evt_buf_full :
out (
2 downto 0);
523 buf_rqst :
in (
3 downto 0);
525 MonBufOverWrite :
in ;
530 mon_evt_cnt :
out (
31 downto 0);
531 WrtMonBlkDone :
in (
2 downto 0);
532 WrtMonEvtDone :
in (
2 downto 0);
533 KiloByte_toggle :
in (
2 downto 0);
534 EoB_toggle :
in (
2 downto 0);
536 wport_rdy :
in (
2 downto 0);
537 wport_FIFO_full :
in (
2 downto 0);
538 -- signal to ddr_if, AMC_if to start moving data
539 EventBufAddr_we :
out (
2 downto 0);
540 EventBufAddr :
out array3X14;
541 -- ddr wportB signals in sysclk domain
543 TCP_dout :
out (
31 downto 0);
-- TCP data are written in unit of 32-bit words
544 TCP_channel :
out (
1 downto 0);
-- Each entry has four 32bit words, each address saves two entries. Addresses are kept in ddr_wportB
546 TCP_wcount :
in (
2 downto 0);
548 TCP_raddr :
out (
28 downto 0);
-- 28-26 encoded request source 25-0 address in 64 word
549 TCP_length :
out (
12 downto 0);
-- in 64 word, actual length -
1
552 TCP_din :
in (
31 downto 0);
-- TCP data are written in unit of 32-bit words
553 TCP_din_type :
in (
2 downto 0);
-- TCP data destination
571 cs_out :
out (
511 downto 0);
576 ipb_addr :
in (
31 downto 0);
577 ipb_wdata :
in (
31 downto 0);
578 ipb_rdata :
out (
31 downto 0)
594 state :
IN (
3 downto 0);
596 ipb_addr :
IN (
15 downto 0);
597 ipb_rdata :
OUT (
31 downto 0)
600 constant ipbus_ver_addr : (15 downto 0) := x"0000";
601 constant ipbus_sfp_addr: (15 downto 0) := x"0002";
602 constant CDRclk_pol : := '0';
603 constant CDRdata_pol : := '1';
604 constant TTCclk_pol : := '1';
605 constant TTCdata_pol : := '1';
606 constant Coarse_Delay: (3 downto 0) := x"0";
607 signal rst_ipbus : := '0';
608 signal LDC_UsrClk : := '0';
609 signal wr_AMC_en : := '0';
610 signal wr_EnSFP : := '0';
611 signal fake_length : (19 downto 0) := x"00400";
612 signal AMC_en : (11 downto 0) := (others =>'0');
613 signal TTS_disable : (11 downto 0) := (others =>'0');
614 signal AMC_Ready : (11 downto 0) := (others =>'0');
615 signal TTC_lock : := '0';
616 signal BC0_lock : (11 downto 0) := (others =>'0');
617 signal AMC_status : (31 downto 0) := (others =>'0');
618 signal AMC_DATA : (31 downto 0) := (others =>'0');
619 signal AMC_ack : := '0';
620 signal L1Aovfl_warning : := '0';
621 signal HCAL_trigger : := '0';
622 signal TRIGDATA : array12x8 := (others => (others => '0'));
623 signal TTS_coded : (4 downto 0) := (others =>'0');
624 signal TTS_RQST : (2 downto 0) := (others =>'0');
625 signal pattern : (3 downto 0) := (others =>'0');
626 --signal Trig_mask : (7 downto 0) := (
others =>'0');
627 signal SPI_SCK_buf : := '0';
628 signal CLK_rdy : := '0';
629 signal I2C_data : (31 downto 0) := (others =>'0');
630 signal TTCclk_in : := '0';
631 signal TTC_Clk : := '0';
632 signal TTC_strobe : := '0';
633 signal BcntErr_cnt : (7 downto 0) := (others =>'0');
634 signal SinErr_cnt : (7 downto 0) := (others =>'0');
635 signal DbErr_cnt : (7 downto 0) := (others =>'0');
636 signal L1_reg : (15 downto 0) := (others =>'0');
637 signal Bcnt_reg : (11 downto 0) := (others =>'0');
638 signal OC_reg : (31 downto 0) := (others =>'0');
639 signal DB_cmd : := '0';
642 signal S2V_cntr : (5 downto 0) := (others => '0');
643 signal S2V_sr : (3 downto 0) := (others => '0');
644 signal ddr_rdata : (7 downto 0) := (others =>'0');
645 signal ipb_clk_dcm : := '0';
646 signal ipb_clk : := '0';
647 signal clk125_dcm : := '0';
648 signal clk125 : := '0';
649 signal DRPclk_dcm : := '0';
650 signal DRPclk : := '0';
651 signal sysclk_dcm : := '0';
652 signal sysclk : := '0';
653 signal clkfb : := '0';
654 signal refclk_dcm : := '0';
655 signal refclk : := '0';
656 signal mem_clk_dcm : := '0';
657 signal mem_clk : := '0';
658 signal sysclk_inp : := '0';
659 signal sysclk_in : := '0';
660 --signal clk125 : := '0';
661 signal sys_lock : := '0';
662 signal sys_lock_n : := '0';
663 signal ldc_reset : := '0';
664 signal ldc_GTXreset : := '0';
665 signal lsc_start : := '0';
666 signal lsc_reset : := '0';
667 signal lsc_GTXreset : := '0';
668 signal amc_reset : := '0';
669 signal amc_GTXreset : := '0';
670 signal conf7_q : := '0';
671 signal conf7_fall : := '0';
673 signal LSC_LinkDown : := '0';
674 signal mem_rst : := '0';
675 signal mem_test : (1 downto 0) := (others =>'0');
676 signal mem_stat : (63 downto 0) := (others =>'0');
677 signal mem_ack : := '0';
678 signal mem_data : (31 downto 0) := (others =>'0');
679 signal EventData : array3X67 := (others => (others => '0'));
680 signal wport_rdy : (2 downto 0) := (others =>'0');
681 signal EventBufAddr : array3x14 := (others => (others => '0'));
682 signal EventBufAddr_we : (2 downto 0) := (others =>'0');
683 signal evt_buf_full : (2 downto 0) := (others =>'0');
684 signal wport_FIFO_full : (2 downto 0) := (others =>'0');
685 signal TCPclk : := '0';
686 signal TCP_din : (31 downto 0) := (others =>'0');
687 signal TCP_channel : (1 downto 0) := (others =>'0');
688 signal TCP_we : := '0';
689 signal TCP_wcount : (2 downto 0) := (others =>'0');
690 signal TCP_dout : (31 downto 0) := (others =>'0');
691 signal TCP_dout_type : (2 downto 0) := (others =>'0');
692 signal TCP_raddr : (28 downto 0) := (others =>'0');
693 signal TCP_length : (12 downto 0) := (others =>'0');
694 signal TCP_dout_valid : := '0';
695 signal TCP_rrqst : := '0';
696 signal TCP_rack : := '0';
697 signal TCP_lastword : := '0';
698 signal TCPIP_GTXreset : := '0';
699 signal MonBufOvfl : := '0';
700 signal MonBuf_empty : := '0';
701 --signal inc_mon_cntr : := '0';
702 signal mon_evt_wc : (47 downto 0) := (others =>'0');
703 signal mon_evt_cnt : (31 downto 0) := (others =>'0');
704 signal mon_ctrl : (31 downto 0) := (others =>'0');
705 signal TCPbuf_avl : := '0';
706 signal mon_buf_avl : := '0';
707 signal EventBufAddrAvl : := '0';
708 signal EventBufAddrRe : := '0';
709 signal mon_wp : (31 downto 0) := (others =>'0');
710 --signal TCP_releaseAck : (2 downto 0) := (
others =>'0');
711 --signal TCP_releaseRqst : (2 downto 0) := (
others =>'0');
712 --signal TCP_releaseAddr : array3X13 := (others => (others => '0'));
713 signal EventBuf_rqst : (3 downto 0) := (others =>'0');
714 signal rst_cntr : := '0';
715 signal rst_ddr_pa : := '0';
716 signal inc_ddr_pa : := '0';
717 signal Source_ID : array3X12 := (others => (others => '0'));
718 signal ddr_pa : (9 downto 0) := (others =>'0');
719 signal CDRclk : := '0';
720 signal TTS_clk : := '0';
721 signal chk_lock : := '0';
722 signal chk_lock_q : := '0';
724 signal BC0_dl : := '0';
725 signal T3_trigger : := '0';
726 signal BX_offset2SC : (11 downto 0) := (others =>'0');
727 signal bcnt : (11 downto 0) := x"000";
728 signal LocalL1A_cfg : (31 downto 0) := (others =>'0');
729 signal BCN_off : (12 downto 0) := (others =>'0');
730 signal OC_off : (3 downto 0) := (others =>'0');
731 signal en_cal_win : := '0';
732 signal CalibCtrl : (31 downto 0) := x"0d800d80";
733 signal cal_win_high : (11 downto 0) := (others =>'0');
734 signal cal_win_low : (11 downto 0) := (others =>'0');
735 signal CalType : (3 downto 0) := (others =>'0');
736 signal TTC_Brcst : (3 downto 0) := (others =>'0');
737 signal local_TTCcmd : := '0';
738 --signal IsG2 : := '0';
739 signal en_brcst : := '0';
740 signal ttc_start : := '0';
741 signal ttc_stop : := '0';
742 signal ttc_soft_reset : := '0';
743 signal ttc_soft_resetp : := '0';
744 signal ttc_ready : := '0';
745 signal ttc_serr : := '0';
746 signal ttc_derr : := '0';
747 signal ttc_bcnt_err : := '0';
748 signal ttc_evcnt_reset : := '0';
749 signal inc_rate_ofw : := '0';
750 signal rate_ofw : := '0';
751 signal rate_ofwp : := '0';
752 signal rate_ofw_q : := '0';
753 signal sync_lost : := '0';
754 signal oc_cntr : (3 downto 0) := (others =>'0');
755 signal trig_BX : (12 downto 0) := "0000111110100";
756 signal ttc_resync : := '0';
757 signal AllEventBuilt : := '0';
758 signal dcc_quiet : := '0';
759 signal inc_oc : := '0';
760 signal inc_L1ac : := '0';
761 signal inc_bcnterr : := '0';
762 signal inc_serr : := '0';
763 signal inc_derr : := '0';
764 signal evn_fifo_full : := '0';
765 signal event_number_avl : := '0';
766 signal state : (3 downto 0) := (others =>'0');
767 signal TTS_wait : (20 downto 0) := (others =>'0');
768 signal event_number : (59 downto 0) := (others =>'0');
769 signal status_l : (22 downto 0) := (others =>'0');
770 signal SFP_down_l : (2 downto 0) := (others =>'0');
771 signal SFP_status_l : (11 downto 0) := (others =>'0');
772 signal AMC_status_l : (31 downto 0) := (others =>'0');
773 signal TTC_cntr_data : (31 downto 0) := (others => '0');
774 signal got_SN : := '0';
775 signal ipb_strobe_q : := '0';
776 signal SFP_clk : := '0';
777 signal AMC_clk : := '0';
778 signal AMC_clk_in : := '0';
779 signal SV_Cntr : (7 downto 0) := (others => '0');
780 signal sysclk_div : (7 downto 0) := (others => '0');
781 signal SFP_UsrClk : := '0';
782 signal SFP_TxOutClk : := '0';
783 signal I2C_debug_out : (15 downto 0) := (others =>'0');
784 signal SFPOSC_rdy : := '0';
785 signal reset : := '0';
786 signal DAQ_reset : := '0';
787 signal AMCOSC_rdy : := '0';
788 --signal cs_clk_in : := '0';
789 --signal cs_clk : := '0';
790 signal TTC_debug : (63 downto 0) := (others =>'0');
791 signal TxDisable_i : (3 downto 0) := (others => '0');
792 signal DAQfifo_re : := '0';
793 signal DAQfifoAlmostEmpty : := '0';
794 signal DAQfifoEmpty : := '0';
795 signal DAQfifo_do : (63 downto 0) := (others =>'0');
796 signal DAQ_debug_in : (63 downto 0) := (others =>'0');
797 signal LDC_debug_out : (63 downto 0) := (others =>'0');
798 signal LSC_debug_out : (63 downto 0) := (others =>'0');
799 signal ddr_debug_in : (31 downto 0) := (others =>'0');
800 signal ddr_debug_out : (127 downto 0) := (others =>'0');
801 signal GbE_REFCLK : := '0';
802 signal S6Link_debug_in : (31 downto 0) := (others =>'0');
803 signal S6Link_debug_out : (127 downto 0) := (others =>'0');
804 signal GbE_debug_in : (31 downto 0) := (others =>'0');
805 signal GbE_debug_out : (127 downto 0) := (others =>'0');
806 signal AMC_debug_in : (255 downto 0) := (others =>'0');
807 signal AMC_debug_out : (255 downto 0) := (others =>'0');
808 signal SFP0_debug_in : (31 downto 0) := (others =>'0');
809 signal SFP0_debug_out : (127 downto 0) := (others =>'0');
810 signal SFP1_debug_in : (31 downto 0) := (others =>'0');
811 signal SFP1_debug_out : (127 downto 0) := (others =>'0');
812 signal ipb_master_out : ipb_wbus;
813 signal ipb_master_in : ipb_rbus;
814 signal SN : (8 downto 0) := (others =>'0');
815 signal MACADDR : (47 downto 0) := (others =>'0');
816 signal ipaddr : (31 downto 0) := (others =>'0');
817 signal en_RARP : := '0';
818 --signal SPI_IP : (31 downto 0) := (
others =>'0');
819 signal status : (31 downto 0) := (others =>'0');
820 signal cmd : (31 downto 0) := (others =>'0');
821 signal cmd0_dl : (1 downto 0) := (others =>'0');
822 signal cmd2_dl : (1 downto 0) := (others =>'0');
823 signal conf : (15 downto 0) := (others =>'0');
824 signal LSC_ID : (15 downto 0) := x"1234";
826 signal inc_HTRCRC_err : := '0';
827 signal ttc_data : (31 downto 0) := (others => '0');
828 signal sysmon_data : (31 downto 0) := (others => '0');
829 signal HCAL_trig_data : (31 downto 0) := (others => '0');
830 signal device_temp : (11 downto 0) := (others =>'0');
831 signal ALM : (7 downto 0) := (others =>'0');
832 signal evt_data_rdy : (2 downto 0) := (others => '0');
833 signal evt_data_re : (2 downto 0) := (others => '0');
834 signal evt_data_we : (2 downto 0) := (others => '0');
835 --signal event_size : array3x13;
836 signal SFP_data : (31 downto 0) := (others =>'0');
837 signal SFP_ack : := '0';
838 --signal TCP_data : (31 downto 0) := (
others =>'0');
839 --signal TCP_ack : := '0';
840 signal S2V_SyncRegs : (2 downto 0) := (others => '0');
841 signal resetSyncRegs : (2 downto 0) := (others => '0');
842 signal sysclk_div7SyncRegs : (3 downto 0) := (others => '0');
843 signal resetCntr_SyncRegs : (2 downto 0) := (others =>'0');
844 signal newIPADDR : := '0';
845 signal newIPADDRSyncRegs : (2 downto 0) := (others =>'0');
846 signal DNA_out : := '0';
847 signal load_DNA : := '0';
848 signal shift_DNA : (2 downto 0) := (others =>'0');
849 signal DNA_cntr : (5 downto 0) := (others =>'0');
850 signal DNA : (56 downto 0) := (others =>'0');
851 signal Dis_pd : := '0';
852 signal DAQ_bp : := '0';
853 signal IgnoreDAQ : := '0';
854 signal WaitMonBuf : := '0';
855 signal enSFP : (3 downto 0) := (others =>'0');
856 signal SFP_down : (2 downto 0) := (others =>'0');
857 signal WrtMonBlkDone : (2 downto 0) := (others =>'0');
858 signal WrtMonEvtDone : (2 downto 0) := (others =>'0');
859 signal KiloByte_toggle : (2 downto 0) := (others =>'0');
860 signal EoB_toggle : (2 downto 0) := (others =>'0');
861 signal Cntr2ms : (18 downto 0) := (others => '0');
862 signal LiveTime : (7 downto 0) := (others => '0');
863 signal LiveTime_l : (7 downto 0) := (others => '0');
864 signal LiveTimeCntr : (18 downto 0) := (others => '0');
865 signal DataRate : array3x19 := (others => (others => '0'));
866 signal DataRate_l : array3x19 := (others => (others => '0'));
867 signal DataRateCntr : array3x19 := (others => (others => '0'));
870 CONTROL0 :
INOUT (
35 DOWNTO 0);
871 CONTROL1 :
INOUT (
35 DOWNTO 0));
876 CONTROL :
INOUT (
35 DOWNTO 0);
878 DATA :
IN (
15 DOWNTO 0);
879 TRIG0 :
IN (
7 DOWNTO 0));
882 signal CONTROL0 : (35 downto 0) := (others => '0');
883 signal CONTROL1 : (35 downto 0) := (others => '0');
884 signal TRIG0 : (7 downto 0) := (others => '0');
885 signal TRIG1 : (7 downto 0) := (others => '0');
886 signal DATA0 : (15 downto 0) := (others => '0');
887 signal DATA1 : (15 downto 0) := (others => '0');
891 -- CONTROL0 => CONTROL0,
892 -- CONTROL1 => CONTROL1);
895 -- CONTROL => CONTROL0,
899 --DATA0(14) <= evt_buf_full(
0);
900 --DATA0(13) <= evt_data_re(
0);
901 --DATA0(12) <= evt_data_rdy(
0);
902 --DATA0(11 downto 10) <= EventBufAddr(
0)(
5 downto 4);
903 --DATA0(9 downto 8) <= EventData(
0)(
65 downto 64);
904 --DATA0(7) <= wport_rdy(
0);
905 --DATA0(6) <= wport_FIFO_full(
0);
906 --DATA0(5) <= evt_data_we(
0);
907 --DATA0(4) <= EventBufAddr_we(
0);
908 --DATA0(3 downto 0) <= mem_stat(
3 downto 0);
909 --TRIG0(7 downto 4) <= (
others => '0');
910 --TRIG0(3) <= wport_rdy(
0);
911 --TRIG0(2) <= EventBufAddr_we(
0);
912 --TRIG0(1) <= evt_data_re(
0);
913 --TRIG0(0) <= evt_data_rdy(
0);
917 -- CONTROL => CONTROL1,
918 -- CLK => mem_stat(19),
921 --DATA1(14 downto 0) <= mem_stat(
18 downto 4);
922 --TRIG1(7 downto 2) <= (
others => '0');
923 --TRIG1(1 downto 0) <= mem_stat(
18 downto 17);
924 --IsG2 <= '1' when flavor = "G2" else '0';
925 i_TTS_if:
TTS_if PORT MAP(
934 g_HCAL_trig : if(flavor = "HCAL") generate
939 SFP_ABS => SFP_ABS
(2),
942 Trigdata => Trigdata,
943 triggerOut => HCAL_trigger,
944 TTC_lock => TTC_lock,
945 BC0_lock => BC0_lock,
947 BX_offset2SC => BX_offset2SC,
949 ipb_write => ipb_master_out.ipb_write ,
950 ipb_strobe => ipb_master_out.ipb_strobe ,
951 ipb_addr => ipb_master_out.ipb_addr ,
952 ipb_wdata => ipb_master_out.ipb_wdata ,
953 ipb_rdata => HCAL_trig_data ,
954 GTX_REFCLKp => CDR_REFCLK_P,
955 GTX_REFCLKn => CDR_REFCLK_N,
961 end generate g_HCAL_trig;
962 TxDisable <= TxDisable_i;
967 addr => ipb_master_out.ipb_addr,
977 i_SPI_SCK_buf: bufh
port map(i => SPI_SCK, o => SPI_SCK_buf
);
978 i_SPI_if:
SPI_if PORT MAP(
988 newIPADDR => newIPADDR,
990 SPI_rdata =>
(others => '0'
),
994 i_ttc_if:
ttc_if PORT MAP(
1000 DB_cmd_in => cmd
(9),
1001 DB_cmd_out => DB_cmd,
1002 IgnoreDAQ => IgnoreDAQ,
1003 TTC_strobe => TTC_strobe,
1004 sys_lock => sys_lock,
1006 local_TTCcmd => local_TTCcmd,
1007 single_TTCcmd => cmd
(8),
1011 DIV_nRST => DIV_nRST,
1012 CDRclk_p => CDRclk_p,
1013 CDRclk_n => CDRclk_n,
1014 CDRclk_out => CDRclk,
1015 CDRdata_p => CDRdata_p,
1016 CDRdata_n => CDRdata_n,
1017 TTCdata_p => TTCdata_p,
1018 TTCdata_n => TTCdata_n,
1023 en_cal_win => en_cal_win,
1024 cal_win_high => cal_win_high,
1025 cal_win_low => cal_win_low,
1027 TTC_Brcst => TTC_Brcst,
1028 ovfl_warning => L1Aovfl_warning,
1030 ipb_write => ipb_master_out.ipb_write ,
1031 ipb_strobe => ipb_master_out.ipb_strobe ,
1032 ipb_addr => ipb_master_out.ipb_addr ,
1033 ipb_wdata => ipb_master_out.ipb_wdata ,
1034 ipb_rdata => ttc_data,
1035 en_localL1A => conf
(2),
1037 LocalL1A_cfg => LocalL1A_cfg,
1038 localL1A_s => cmd
(26),
1039 localL1A_r => cmd
(10),
1040 localL1A_periodic => status
(10),
1041 T3_trigger => T3_trigger,
1042 HCAL_trigger => HCAL_trigger,
1043 EvnRSt_l => cmd
(11),
1044 OcnRSt_l => cmd
(12),
1045 en_brcst => en_brcst,
1046 ttc_start => ttc_start,
1047 ttc_stop => ttc_stop,
1048 ttc_soft_reset => ttc_soft_reset ,
1049 ttc_ready => ttc_ready,
1050 ttc_serr => ttc_serr,
1051 ttc_derr => ttc_derr,
1052 ttc_bcnt_err => ttc_bcnt_err,
1053 rate_OFW => rate_OFW,
1054 sync_lost => sync_lost,
1056 inc_l1ac => inc_l1ac,
1057 inc_bcnterr => inc_bcnterr,
1058 inc_serr => inc_serr,
1059 inc_derr => inc_derr,
1061 evn_fifo_full => evn_fifo_full,
1062 ttc_evcnt_reset => ttc_evcnt_reset,
1063 event_number_avl => event_number_avl,
1064 event_number => event_number
1066 local_TTCcmd <= conf(
5)
or conf(
8);
1067 --local_TTCcmd <= conf(5);
1068 CalibCtrl(31) <= en_cal_win;
1069 CalibCtrl(30 downto 28) <= "000";
1070 CalibCtrl(27 downto 16) <= cal_win_high;
1071 CalibCtrl(15 downto 12) <= CalType;
1072 CalibCtrl(11 downto 0) <= cal_win_low;
1073 cal_win_high(11 downto 6) <= "110110";
1074 cal_win_low(11 downto 6) <= "110110";
1075 i_S2V: IBUFDS
generic map(DIFF_TERM => TRUE,IOSTANDARD =>
"LVDS_25") port map(i => S2V_p, ib => S2V_n, o => S2V
);
1078 if(CDRclk'event and CDRclk = '1')then
1079 if(conf(15) = '0')then
1086 i_GbE_REFCLK: IBUFDS_GTE2
1092 I => GbE_REFCLK_P,
-- Connect to package pin AB6
1093 IB => GbE_REFCLK_N
-- Connect to package pin AB5
1095 i_TTCclk_in : IBUFGDS
generic map (DIFF_TERM => TRUE,IOSTANDARD =>
"LVDS_25")
1097 O => TTCclk_in,
-- Clock buffer output
1098 I => TTCclk_p,
-- Diff_p clock buffer input
1099 IB => TTCclk_n
-- Diff_n clock buffer input
1101 i_TTC_CLK_buf: bufg
port map(i => TTCclk_in, o => TTC_Clk
);
1102 i_sysclk_in_buf: bufh
port map(i => GbE_REFCLK, o => sysclk_in
);
1103 i_PLL_sysclk : PLLE2_BASE
1105 BANDWIDTH =>
"OPTIMIZED",
-- OPTIMIZED, HIGH, LOW
1106 CLKFBOUT_MULT =>
8,
-- Multiply value for all CLKOUT, (2-64)
1107 CLKFBOUT_PHASE =>
0.0,
-- Phase offset in degrees of CLKFB, (-360.000-360.000).
1108 CLKIN1_PERIOD =>
8.0,
-- Input clock period in ns to ps resolution (i.e. 33.
333 is 30 MHz).
1109 -- CLKOUT0_DIVIDE - CLKOUT5_DIVIDE: Divide amount for each CLKOUT (1-128)
1110 CLKOUT0_DIVIDE =>
5,
1111 CLKOUT1_DIVIDE =>
32,
1112 CLKOUT2_DIVIDE =>
20,
1113 DIVCLK_DIVIDE =>
1,
-- Master division value, (1-56)
1114 REF_JITTER1 =>
0.0,
-- Reference input jitter in UI, (0.000-0.
999).
1115 STARTUP_WAIT =>
"FALSE" -- Delay DONE until PLL Locks, ("TRUE"/"FALSE")
1118 -- Clock Outputs: 1-bit (each) output: User configurable clock outputs
1119 CLKOUT0 => sysclk_dcm,
1120 CLKOUT1 => ipb_clk_dcm,
1121 CLKOUT2 => DRPclk_dcm,
1122 -- Feedback Clocks: 1-bit (each) output: Clock feedback ports
1123 CLKFBOUT => clk125_dcm,
-- 1-bit output: Feedback clock
1124 -- Status Port: 1-bit (each) output: PLL status ports
1125 LOCKED => sys_lock,
-- 1-bit output: LOCK
1126 -- Clock Input: 1-bit (each) input: Clock input
1127 CLKIN1 => sysclk_in,
-- 1-bit input: Input clock
1128 -- Control Ports: 1-bit (each) input: PLL control ports
1129 PWRDWN => '0',
-- 1-bit input: Power-down
1130 RST => '0',
-- 1-bit input: Reset
1131 -- Feedback Clocks: 1-bit (each) input: Clock feedback ports
1132 CLKFBIN => clk125
-- 1-bit input: Feedback clock
1134 i_clk125_buf: bufg
port map(i => clk125_dcm, o => clk125
);
1135 i_ipb_clk_buf: bufg
port map(i => ipb_clk_dcm, o => ipb_clk
);
1136 i_DRPclk_buf: bufg
port map(i => DRPclk_dcm, o => DRPclk
);
1137 i_sysclk_buf: bufg
port map(i => sysclk_dcm, o => sysclk
);
1138 --i_refclk_buf: bufg port map(i => refclk_dcm, o => refclk);
1139 reset <= not sys_lock or cmd(0);
1141 process(sysclk,reset)
1144 resetSyncRegs <= (others => '1');
1145 elsif(sysclk'event and sysclk = '1')then
1146 resetSyncRegs <= resetSyncRegs(1 downto 0) & '0';
1149 i_ddr_if:
ddr_if PORT MAP(
1150 mem_clk_p => sys_clk_p,
1151 mem_clk_n => sys_clk_n,
1157 resetsys => resetSyncRegs
(2),
1159 mem_test => mem_test,
1160 EventData => EventData,
1161 EventData_we => evt_data_we,
1162 wport_rdy => wport_rdy,
1163 WrtMonBlkDone => WrtMonBlkDone,
1164 WrtMonEvtDone => WrtMonEvtDone,
1165 KiloByte_toggle => KiloByte_toggle,
1166 EoB_toggle => EoB_toggle,
1167 EventBufAddr => EventBufAddr,
1168 EventBufAddr_we => EventBufAddr_we,
1169 EventFIFOfull => wport_FIFO_full,
1171 TCP_channel => TCP_channel,
1173 TCP_wcount => TCP_wcount,
1174 TCP_dout => TCP_dout,
1175 TCP_dout_type => TCP_dout_type,
1176 TCP_raddr => TCP_raddr,
1177 TCP_length => TCP_length,
1178 TCP_dout_valid => TCP_dout_valid ,
1179 TCP_rrqst => TCP_rrqst,
1180 TCP_rack => TCP_rack,
1181 TCP_lastword => TCP_lastword,
1182 page_addr => ddr_pa,
1184 ipb_write => ipb_master_out.ipb_write ,
1185 ipb_strobe => ipb_master_out.ipb_strobe ,
1186 ipb_addr => ipb_master_out.ipb_addr ,
1187 ipb_wdata => ipb_master_out.ipb_wdata ,
1188 ipb_rdata => mem_data,
1190 mem_stat => mem_stat,
1191 device_temp => device_temp,
1194 ddr3_addr => ddr3_addr,
1196 ddr3_dqs_p => ddr3_dqs_p,
1197 ddr3_dqs_n => ddr3_dqs_n,
1198 ddr3_ras_n => ddr3_ras_n,
1199 ddr3_cas_n => ddr3_cas_n,
1200 ddr3_we_n => ddr3_we_n,
1201 ddr3_reset_n => ddr3_reset_n,
1202 ddr3_cke => ddr3_cke,
1203 ddr3_odt => ddr3_odt,
1204 ddr3_ck_p => ddr3_ck_p,
1205 ddr3_ck_n => ddr3_ck_n
1207 --mem_rst <= not sys_lock or not CLK_rdy or cmd(5)
or cmd(
0);
1208 mem_rst <= not sys_lock or not CLK_rdy or cmd(5);
1209 MACADDR <= x"080030f30" & '0' & not SN(8) & '0' & not SN(7 downto 6) & '1' & SN(5 downto 0);
1215 GTX_RESET => sys_lock_n,
1216 MACADDR => MACADDR,
-- new mac range 08-00-30-F3-00-00 to 08-00-30-F3-00-7F
1219 GbE_REFCLK => GbE_REFCLK,
1220 S6LINK_RXN => S6LINK_RXN,
1221 S6LINK_RXP => S6LINK_RXP,
1222 S6LINK_TXN => S6LINK_TXN,
1223 S6LINK_TXP => S6LINK_TXP,
1224 wr_AMC_en => wr_AMC_en,
1226 ipb_out => ipb_master_out ,
1227 ipb_in => ipb_master_in,
1230 debug_in =>
(others => '0'
),
1233 --LSC_LinkDown <= '1' when conf(1) = '0'
or or_reduce(EnSFP(
2 downto 0)
and SFP_down) = '1'
else '0';
1234 --status(0) <= LSC_LinkDown;
1235 status(0) <= or_reduce(SFP_down);
1236 status(1) <= MonBufOvfl;
1237 status(2) <= mon_evt_cnt(10);
1238 status(3) <= MonBuf_empty;
1239 status(4) <= mem_stat(0);
-- monitor input FIFO overflow
1240 status(5) <= not ttc_ready;
1241 status(6) <= ttc_bcnt_err;
1242 status(7) <= ttc_serr;
1243 status(8) <= ttc_derr;
1244 status(9) <= sync_lost;
1245 status(13) <= L1Aovfl_warning;
1246 status(15) <= mem_stat(63);
1249 EnSFP(3) <= not conf(1);
1250 mem_test <= conf(6) & conf(4);
1251 --en_brcst <= conf(5);
1255 Q => cmd0_dl
(0),
-- SRL data output
1256 A0 => '1',
-- Select[0] input
1257 A1 => '1',
-- Select[1] input
1258 A2 => '1',
-- Select[2] input
1259 A3 => '0',
-- Select[3] input
1260 CE => '1',
-- Clock enable input
1261 CLK => ipb_clk,
-- Clock input
1262 D => cmd
(0) -- SRL data input
1266 Q => cmd0_dl
(1),
-- SRL data output
1267 A0 => '1',
-- Select[0] input
1268 A1 => '1',
-- Select[1] input
1269 A2 => '1',
-- Select[2] input
1270 A3 => '0',
-- Select[3] input
1271 CE => '1',
-- Clock enable input
1272 CLK => ipb_clk,
-- Clock input
1273 D => cmd0_dl
(0) -- SRL data input
1277 Q => cmd2_dl
(0),
-- SRL data output
1278 A0 => '1',
-- Select[0] input
1279 A1 => '1',
-- Select[1] input
1280 A2 => '1',
-- Select[2] input
1281 A3 => '0',
-- Select[3] input
1282 CE => '1',
-- Clock enable input
1283 CLK => ipb_clk,
-- Clock input
1284 D => cmd
(2) -- SRL data input
1288 Q => cmd2_dl
(1),
-- SRL data output
1289 A0 => '1',
-- Select[0] input
1290 A1 => '1',
-- Select[1] input
1291 A2 => '1',
-- Select[2] input
1292 A3 => '0',
-- Select[3] input
1293 CE => '1',
-- Clock enable input
1294 CLK => ipb_clk,
-- Clock input
1295 D => cmd2_dl
(0) -- SRL data input
1299 if(ipb_clk'event and ipb_clk = '1')then
1300 if(ipb_master_out.ipb_addr(27) = '0' and ipb_master_out.ipb_addr(15 downto 0) = CSR_addr and ipb_master_out.ipb_write = '1' and ipb_master_out.ipb_strobe = '1')then
1301 cmd <= ipb_master_out.ipb_wdata;
1303 cmd <= (others => '0');
1306 conf7_fall <= conf7_q and not conf(7);
1307 if(ipb_master_out.ipb_addr(27) = '0' and ipb_master_out.ipb_addr(15 downto 0) = CFG_addr and ipb_master_out.ipb_write = '1' and ipb_master_out.ipb_strobe = '1')then
1308 conf <= ipb_master_out.ipb_wdata(15 downto 0);
1310 if(ipb_master_out.ipb_addr(27) = '0' and ipb_master_out.ipb_addr(15 downto 0) = HTR_EN_addr and ipb_master_out.ipb_write = '1' and ipb_master_out.ipb_strobe = '1')then
1314 IgnoreDAQ <= ipb_master_out.ipb_wdata(31);
1316 Dis_pd <= ipb_master_out.ipb_wdata(15);
1318 EnSFP(2) <= ipb_master_out.ipb_wdata(14);
1322 EnSFP(1 downto 0) <= ipb_master_out.ipb_wdata(13 downto 12);
1323 AMC_en <= ipb_master_out.ipb_wdata(11 downto 0);
1324 if(AMC_en = ipb_master_out.ipb_wdata(11 downto 0))then
1329 if(flavor /= "HCAL" and EnSFP(2) /= ipb_master_out.ipb_wdata(14))then
1331 elsif(EnSFP(1 downto 0) /= ipb_master_out.ipb_wdata(13 downto 12))then
1340 if(ipb_master_out.ipb_addr(27) = '0' and ipb_master_out.ipb_addr(15 downto 0) = x"001a" and ipb_master_out.ipb_write = '1' and ipb_master_out.ipb_strobe = '1')then
1341 TTS_disable <= ipb_master_out.ipb_wdata(11 downto 0);
1343 if(ipb_master_out.ipb_addr(27) = '0' and ipb_master_out.ipb_addr(15 downto 0) = TTC_cal_addr and ipb_master_out.ipb_write = '1' and ipb_master_out.ipb_strobe = '1')then
1344 en_cal_win <= ipb_master_out.ipb_wdata(31);
1345 cal_win_high(5 downto 0) <= ipb_master_out.ipb_wdata(21 downto 16);
1346 cal_win_low(5 downto 0) <= ipb_master_out.ipb_wdata(5 downto 0);
1348 if(ipb_master_out.ipb_addr(27) = '0' and ipb_master_out.ipb_addr(15 downto 0) = SRC_id_addr and ipb_master_out.ipb_write = '1' and ipb_master_out.ipb_strobe = '1')then
1349 Source_ID(0)(11 downto 0) <= ipb_master_out.ipb_wdata(11 downto 0);
1351 if(ipb_master_out.ipb_addr(27) = '0' and ipb_master_out.ipb_addr(15 downto 0) = SRC_id1_addr and ipb_master_out.ipb_write = '1' and ipb_master_out.ipb_strobe = '1')then
1352 Source_ID(1)(11 downto 0) <= ipb_master_out.ipb_wdata(11 downto 0);
1354 if(ipb_master_out.ipb_addr(27) = '0' and ipb_master_out.ipb_addr(15 downto 0) = x"001c" and ipb_master_out.ipb_write = '1' and ipb_master_out.ipb_strobe = '1')then
1355 LocalL1A_cfg <= ipb_master_out.ipb_wdata;
1357 if(ipb_master_out.ipb_addr(27) = '0' and ipb_master_out.ipb_addr(15 downto 0) = x"001b" and ipb_master_out.ipb_write = '1' and ipb_master_out.ipb_strobe = '1')then
1358 trig_BX(11 downto 0) <= ipb_master_out.ipb_wdata(11 downto 0);
1360 if(ipb_master_out.ipb_addr(27) = '0' and ipb_master_out.ipb_addr(15 downto 0) = SFP_CSR_addr and ipb_master_out.ipb_write = '1' and ipb_master_out.ipb_strobe = '1')then
1361 LSC_ID(15 downto 2) <= ipb_master_out.ipb_wdata(31 downto 18);
1362 TxDisable_i <= ipb_master_out.ipb_wdata(15 downto 12);
1364 if(ipb_master_out.ipb_addr(27) = '0' and ipb_master_out.ipb_addr(15 downto 0) = TTC_bcnt_addr and ipb_master_out.ipb_write = '1' and ipb_master_out.ipb_strobe = '1')then
1365 OC_OFF <= ipb_master_out.ipb_wdata(19 downto 16);
1366 BCN_OFF <= ipb_master_out.ipb_wdata(12 downto 0);
1368 if(ipb_master_out.ipb_addr(27) = '0' and ipb_master_out.ipb_addr(15 downto 0) = fake_length_addr and ipb_master_out.ipb_write = '1' and ipb_master_out.ipb_strobe = '1')then
1369 fake_length <= ipb_master_out.ipb_wdata(19 downto 0);
1371 if(ipb_master_out.ipb_addr(27) = '0' and ipb_master_out.ipb_addr(15 downto 0) = x"0019" and ipb_master_out.ipb_write = '1' and ipb_master_out.ipb_strobe = '1')then
1372 pattern <= ipb_master_out.ipb_wdata(11 downto 8);
1373 -- Trig_mask <= ipb_master_out.ipb_wdata(7 downto 0);
1375 if(reset = '1' or (ipb_master_out.ipb_addr(27) = '0' and ipb_master_out.ipb_addr(15 downto 0) = MON_ctrl_addr and ipb_master_out.ipb_write = '1' and ipb_master_out.ipb_strobe = '1'))then
1376 ddr_pa <= (others => '0');
1377 elsif(ipb_master_out.ipb_addr(27) = '0' and ipb_master_out.ipb_addr(15 downto 0) = PAGE_addr and ipb_master_out.ipb_write = '1' and ipb_master_out.ipb_strobe = '1')then
1379 if(MonBuf_empty = '0')then
1380 ddr_pa <= ddr_pa + 1;
1383 ddr_pa <= ipb_master_out.ipb_wdata(9 downto 0);
1386 if(ipb_master_out.ipb_addr(27) = '0' and ipb_master_out.ipb_addr(15 downto 0) = PAGE_addr and ipb_master_out.ipb_write = '1' and ipb_master_out.ipb_strobe = '1' and run = '1' and MonBuf_empty = '0')then
1391 if(DB_cmd = '1')then
1392 status_l <= status(22 downto 0);
1393 SFP_down_l <= SFP_down;
1394 SFP_status_l <= TxFault & (TTC_LOL or TTC_LOL) & SFP_LOS & SFP_ABS;
1395 AMC_status_l <= AMC_status;
1396 DataRate_l <= DataRate;
1397 LiveTime_l <= LiveTime;
1401 ipb_master_in.ipb_ack <= ipb_master_out.ipb_strobe when ipb_master_out.ipb_addr(27) = '0' and ipb_master_out.ipb_addr(17) = '0' else mem_ack;
1402 process(ipb_master_out.ipb_addr)
1404 if(ipb_master_out.ipb_addr(27) = '1' or ipb_master_out.ipb_addr(17) = '1')then
1405 ipb_master_in.ipb_rdata <= mem_data;
1406 elsif(ipb_master_out.ipb_addr(14 downto 5) = CSR_addr(14 downto 5))then
1407 if(ipb_master_out.ipb_addr(15) = '0')then
1408 case ipb_master_out.ipb_addr(4 downto 0) is
1409 when "00000" => ipb_master_in.ipb_rdata <= not SN(7 downto 0) & not SN(8) & status(22 downto 0);
1410 when "00001" => ipb_master_in.ipb_rdata <= K7version & conf;
1411 when "00010" => ipb_master_in.ipb_rdata <= mon_ctrl;
1412 when "00011" => ipb_master_in.ipb_rdata <= IgnoreDAQ & SFP_down & AMC_Ready & Dis_pd & EnSFP(2 downto 0) & AMC_en;
1413 when "00100" => ipb_master_in.ipb_rdata <= LSC_ID & TxDisable_i & TxFault & (TTC_LOL or TTC_LOL) & SFP_LOS & SFP_ABS;
1414 when "00101" => ipb_master_in.ipb_rdata <= AMC_status;
1415 when "00110" => ipb_master_in.ipb_rdata <= x"0" & BC0_lock & x"0" & BX_offset2SC;
1416 when "00111" => ipb_master_in.ipb_rdata <= x"00000" & Source_ID(0);
1417 when "01000" => ipb_master_in.ipb_rdata <= x"000" & OC_OFF & "000" & BCN_OFF;
1418 when "01001" => ipb_master_in.ipb_rdata <= CalibCtrl;
1419 when "01010" => ipb_master_in.ipb_rdata <= mem_stat(31 downto 0);
1420 when "01011" => ipb_master_in.ipb_rdata <= mem_stat(63 downto 32);
1421 when "01100" => ipb_master_in.ipb_rdata <= x"00000" & "00" & ddr_pa;
1422 when "01101" => ipb_master_in.ipb_rdata <= x"000" & "000" & mon_evt_wc(15 downto 0) & '0';
1423 when "01110" => ipb_master_in.ipb_rdata <= mon_evt_cnt;
1424 when "01111" => ipb_master_in.ipb_rdata <= x"000" & "000" & mon_evt_wc(31 downto 16) & '0';
1425 when "10000" => ipb_master_in.ipb_rdata <= x"000" & "00" & mon_buf_avl & '1' & '0' & wport_FIFO_full & '0' & wport_rdy & x"0" & '0' & evt_data_rdy;
1426 when "10001" => ipb_master_in.ipb_rdata <= x"00000" & Source_ID(1);
1427 when "10010" => ipb_master_in.ipb_rdata <= x"00000" & Source_ID(2);
1428 when "10100" => ipb_master_in.ipb_rdata <= x"000" & '0' & DataRate(0);
1429 when "10101" => ipb_master_in.ipb_rdata <= x"000" & '0' & DataRate(1);
1430 when "10110" => ipb_master_in.ipb_rdata <= x"000" & '0' & DataRate(2);
1431 when "10111" => ipb_master_in.ipb_rdata <= x"000000" & LiveTime;
1432 when "11000" => ipb_master_in.ipb_rdata <= x"000" & fake_length;
1433 when "11001" => ipb_master_in.ipb_rdata <= x"00" & "000" & TTS_coded & state & pattern & x"0" & '0' & TTS_RQST;
1434 when "11010" => ipb_master_in.ipb_rdata <= x"00000" & TTS_disable;
1435 when "11011" => ipb_master_in.ipb_rdata <= x"00000" & trig_BX(11 downto 0);
1436 when "11100" => ipb_master_in.ipb_rdata <= LocalL1A_cfg;
1437 when "11101" => ipb_master_in.ipb_rdata <= x"000" & "000" & mon_evt_wc(47 downto 32) & '0';
1438 when "11110" => ipb_master_in.ipb_rdata <= DNA(31 downto 0);
1439 when "11111" => ipb_master_in.ipb_rdata <= "0000000" & DNA(56 downto 32);
1440 when others => ipb_master_in.ipb_rdata <= (others => '0');
1443 case ipb_master_out.ipb_addr(4 downto 0) is
1444 when "00000" => ipb_master_in.ipb_rdata <= not SN(7 downto 0) & not SN(8) & status_l;
1445 when "00001" => ipb_master_in.ipb_rdata <= K7version & conf;
1446 when "00010" => ipb_master_in.ipb_rdata <= mon_ctrl;
1447 when "00011" => ipb_master_in.ipb_rdata <= IgnoreDAQ & SFP_down_l & AMC_Ready & Dis_pd & EnSFP(2 downto 0) & AMC_en;
1448 when "00100" => ipb_master_in.ipb_rdata <= LSC_ID & TxDisable_i & SFP_status_l;
1449 when "00101" => ipb_master_in.ipb_rdata <= AMC_status_l;
1450 when "00110" => ipb_master_in.ipb_rdata <= x"0" & BC0_lock & x"0" & BX_offset2SC;
1451 when "00111" => ipb_master_in.ipb_rdata <= x"00000" & Source_ID(0);
1452 when "01000" => ipb_master_in.ipb_rdata <= x"000" & OC_OFF & "000" & BCN_OFF;
1453 when "01001" => ipb_master_in.ipb_rdata <= CalibCtrl;
1454 when "01010" => ipb_master_in.ipb_rdata <= mem_stat(31 downto 0);
1455 when "01011" => ipb_master_in.ipb_rdata <= mem_stat(63 downto 32);
1456 when "01100" => ipb_master_in.ipb_rdata <= x"00000" & "00" & ddr_pa;
1457 when "01101" => ipb_master_in.ipb_rdata <= x"000" & "000" & mon_evt_wc(15 downto 0) & '0';
1458 when "01110" => ipb_master_in.ipb_rdata <= mon_evt_cnt;
1459 when "01111" => ipb_master_in.ipb_rdata <= x"000" & "000" & mon_evt_wc(31 downto 16) & '0';
1460 when "10000" => ipb_master_in.ipb_rdata <= x"000" & "00" & mon_buf_avl & '1' & '0' & wport_FIFO_full & '0' & wport_rdy & x"0" & '0' & evt_data_rdy;
1461 when "10001" => ipb_master_in.ipb_rdata <= x"00000" & Source_ID(1);
1462 when "10010" => ipb_master_in.ipb_rdata <= x"00000" & Source_ID(2);
1463 when "10100" => ipb_master_in.ipb_rdata <= x"000" & '0' & DataRate_l(0);
1464 when "10101" => ipb_master_in.ipb_rdata <= x"000" & '0' & DataRate_l(1);
1465 when "10110" => ipb_master_in.ipb_rdata <= x"000" & '0' & DataRate_l(2);
1466 when "10111" => ipb_master_in.ipb_rdata <= x"000000" & LiveTime_l;
1467 when "11000" => ipb_master_in.ipb_rdata <= x"000" & fake_length;
1468 when "11001" => ipb_master_in.ipb_rdata <= x"00" & "000" & TTS_coded & state & pattern & x"00";
1469 when "11010" => ipb_master_in.ipb_rdata <= x"00000" & TTS_disable;
1470 when "11011" => ipb_master_in.ipb_rdata <= x"00000" & trig_BX(11 downto 0);
1471 when "11100" => ipb_master_in.ipb_rdata <= LocalL1A_cfg;
1472 when "11101" => ipb_master_in.ipb_rdata <= x"000" & "000" & mon_evt_wc(47 downto 32) & '0';
1473 when "11110" => ipb_master_in.ipb_rdata <= DNA(31 downto 0);
1474 when "11111" => ipb_master_in.ipb_rdata <= "0000000" & DNA(56 downto 32);
1475 when others => ipb_master_in.ipb_rdata <= (others => '0');
1479 ipb_master_in.ipb_rdata <= AMC_data or TTC_cntr_data or I2C_data or sysmon_data or SFP_data or ttc_data or HCAL_trig_data;
1482 rst_cntr <= cmd(1) or cmd(0);
1483 ttc_resync <= ttc_soft_reset;
1486 if(sysClk'event and sysClk = '1')then
1487 if(Cntr2ms(18 downto 17) = "11" and Cntr2ms(14) = '1')then
1488 Cntr2ms <= (others => '0');
1489 LiveTimeCntr <= (others => '0');
1490 LiveTime <= '0' & LiveTimeCntr(18 downto 12);
1491 DataRateCntr <= (others => (others => '0'));
1492 DataRate <= DataRateCntr;
1494 Cntr2ms <= Cntr2ms + 1;
1495 if(state = x"8")then
1496 LiveTimeCntr <= LiveTimeCntr + 1;
1498 for i in 0 to 2 loop
1499 if(evt_data_we(i) = '1')then
1500 DataRateCntr(i) <= DataRateCntr(i) + 1;
1506 process(sysClk,reset)
1509 TTS_wait <= (others => '0');
1510 elsif(sysClk'event and sysClk = '1')then
1511 if(ttc_resync = '1')then
1512 TTS_wait <= (others => '0');
1513 elsif(TTS_wait(20) = '0' and sync_lost = '0' and AllEventBuilt = '1')then
1514 TTS_wait <= TTS_wait + 1;
1520 if(sysClk'event and sysClk = '1')then
1521 if(flavor = "G2" or conf(1) = '0' or conf(9) = '0')then
1524 DAQ_bp <= or_reduce(EnSFP(2 downto 0) and (evt_buf_full or SFP_down));
1528 process(sysClk,reset)
1532 elsif(sysClk'event and sysClk = '1')then
1533 if(run = '0' and conf(12) = '1')then
1535 elsif(run = '0')then
1536 state <= x"4";
-- changed upon request starting version 0x3023
1537 elsif(ttc_resync = '1')then
1541 when x"8" | x"9" | x"a" | x"b" => -- Ready
1542 if(TTS_coded(4) = '1')then
1544 elsif(TTS_coded(3) = '1')then
1546 elsif(sync_lost = '1' or TTS_coded(2) = '1')then
1548 elsif(L1Aovfl_warning = '1' or evn_fifo_full = '1' or rate_OFWp = '1' or TTS_coded(1) = '1' or TTS_coded(0) = '1')then
1549 if(DAQ_bp = '1')then
1555 state(3 downto 2) <= "10";
1556 state(1) <= (TTS_RQST(2) or TTS_RQST(1)) and conf(9);
1557 state(0) <= (TTS_RQST(2) or (not TTS_RQST(1) and TTS_RQST(0))) and conf(9);
1559 when x"1" | x"6" => -- OFW
1560 if(TTS_coded(4) = '1')then
1562 elsif(TTS_coded(3) = '1')then
1564 elsif(sync_lost = '1' or TTS_coded(2) = '1')then
1566 elsif(evn_fifo_full = '1' or rate_OFWp = '1' or TTS_coded(1) = '1')then
1568 elsif(L1Aovfl_warning = '0' and rate_OFWp = '0' and TTS_coded(0) = '0')then
1569 state(3 downto 2) <= "10";
1570 state(1) <= (TTS_RQST(2) or TTS_RQST(1)) and conf(9);
1571 state(0) <= (TTS_RQST(2) or (not TTS_RQST(1) and TTS_RQST(0))) and conf(9);
1572 elsif(DAQ_bp = '1')then
1577 when x"4" => -- Busy
1578 if(TTS_wait(20) = '0')then
1579 elsif(TTS_coded(4) = '1')then
1581 elsif(TTS_coded(3) = '1')then
1583 elsif(sync_lost = '1' or TTS_coded(2) = '1')then
1585 elsif(evn_fifo_full = '0' and rate_OFWp = '0' and TTS_coded(1) = '0')then
1586 if(DAQ_bp = '1')then
1592 -- when others => null; -- x"0" or x"f" disconnected, x"2" OOS, x"c" error
1594 if(IgnoreDAQ = '1')then
1595 if(TTS_coded(4) = '1')then
1597 elsif(TTS_coded(3) = '1')then
1599 elsif(TTS_coded(2) = '1')then
1601 elsif(TTS_coded(1) = '1')then
1611 ipb_master_in.ipb_err <= '0';
1612 i_AMC_if:
AMC_if PORT MAP(
1619 ReSync => ttc_resync,
1620 GTXreset => amc_GTXreset,
1621 resetCntr => rst_cntr,
1622 AllEventBuilt => AllEventBuilt,
1624 en_inject_err => conf
(10),
1628 NoReSyncFake => conf
(11),
1629 WaitMonBuf => WaitMonBuf,
1630 fake_length => fake_length,
1631 en_localL1A => conf
(2),
1632 T1_version => K7version
(7 downto 0),
1633 Source_ID => Source_ID,
1635 TTS_disable => TTS_disable,
1636 AMC_Ready => AMC_Ready,
1637 TTC_lock => TTC_lock,
1638 BC0_lock => BC0_lock,
1639 AMC_REFCLK_P => AMC_REFCLK_P,
1640 AMC_REFCLK_N => AMC_REFCLK_N,
1645 AMC_status => AMC_status,
1646 evt_data => EventData,
1647 evt_data_we => evt_data_we,
1648 evt_buf_full => evt_buf_full,
1649 evt_data_re => evt_data_re,
1650 evt_data_rdy => evt_data_rdy,
1652 MonBuf_empty => MonBuf_empty,
1653 mon_evt_wc => mon_evt_wc,
1654 mon_ctrl => mon_ctrl,
1655 mon_buf_avl => mon_buf_avl,
1656 TCPbuf_avl => TCPbuf_avl,
1657 buf_rqst => EventBuf_rqst,
1658 ipb_write => ipb_master_out.ipb_write ,
1659 ipb_strobe => ipb_master_out.ipb_strobe ,
1660 ipb_addr => ipb_master_out.ipb_addr ,
1661 ipb_wdata => ipb_master_out.ipb_wdata ,
1662 ipb_rdata => AMC_data,
1667 ttc_evcnt_reset => ttc_evcnt_reset,
1668 event_number_avl => event_number_avl,
1669 event_number => event_number,
1670 evn_buf_full => evn_fifo_full,
1671 ovfl_warning => L1Aovfl_warning,
1672 TrigData => TrigData,
1673 TTS_RQST => TTS_RQST,
1674 TTS_coded => TTS_coded
1676 AMC_reset <= not sys_lock or cmd(0) or cmd0_dl(1);
1677 amc_GTXreset <= wr_AMC_en or conf7_fall or not sys_lock;
1678 sys_lock_n <= not sys_lock;
1679 g_DAQLSC_if : if(flavor /= "G2") generate
1685 daq_reset => lsc_reset,
1686 gtx_reset => lsc_GTXreset,
1687 rstCntr => rst_cntr,
1692 SFP_ABS => SFP_ABS
(2 downto 0),
1694 SFP_down => SFP_down,
1695 inc_ddr_pa => inc_ddr_pa,
1696 evt_data_rdy => evt_data_rdy,
1697 EventData_in => EventData,
1698 EventData_we => evt_data_we,
1699 EventData_re => evt_data_re,
1700 evt_buf_full => evt_buf_full,
1701 buf_rqst => EventBuf_rqst,
1702 WaitMonBuf => WaitMonBuf,
1703 MonBufOverWrite => conf
(13),
1704 TCPBuf_avl => TCPbuf_avl,
1705 MonBuf_avl => mon_buf_avl,
1706 MonBuf_empty => MonBuf_empty,
1707 MonBufOvfl => MonBufOvfl,
1708 mon_evt_cnt => mon_evt_cnt,
1709 WrtMonBlkDone => WrtMonBlkDone,
1710 WrtMonEvtDone => WrtMonEvtDone,
1711 wport_rdy => wport_rdy,
1712 wport_FIFO_full => wport_FIFO_full,
1713 EventBufAddr_we => EventBufAddr_we,
1714 EventBufAddr => EventBufAddr,
1715 SFP0_RXN => SFP0_RXN,
1716 SFP0_RXP => SFP0_RXP,
1717 SFP1_RXN => SFP1_RXN,
1718 SFP1_RXP => SFP1_RXP,
1719 SFP2_RXN => SFP2_RXN,
1720 SFP2_RXP => SFP2_RXP,
1721 SFP0_TXN => SFP0_TXN,
1722 SFP0_TXP => SFP0_TXP,
1723 SFP1_TXN => SFP1_TXN,
1724 SFP1_TXP => SFP1_TXP,
1725 SFP2_TXN => SFP2_TXN,
1726 SFP2_TXP => SFP2_TXP,
1727 SFP_REFCLK_P => SFP_REFCLK_P,
1728 SFP_REFCLK_N => SFP_REFCLK_N,
1729 GbE_REFCLK => GbE_REFCLK,
1731 ipb_write => ipb_master_out.ipb_write ,
1732 ipb_strobe => ipb_master_out.ipb_strobe ,
1733 ipb_addr => ipb_master_out.ipb_addr ,
1734 ipb_wdata => ipb_master_out.ipb_wdata ,
1735 ipb_rdata => SFP_data,
1738 lsc_reset <= lsc_start or cmd(2) or cmd2_dl(1);
1739 lsc_GTXreset <= lsc_start or cmd2_dl(0);
1740 end generate g_DAQLSC_if;
1741 WaitMonBuf <= conf(14) when flavor /= "G2" else '1' when conf(14) = '1' and (conf(1) = '0' or enSFP(2 downto 0) = "000") else '0';
1742 g_TCPIP_if : if(flavor = "G2") generate
1747 TCPreset => TCPIP_GTXreset ,
1748 rstCntr => rst_cntr,
1753 SFP_down => SFP_down,
1754 inc_ddr_pa => inc_ddr_pa,
1755 evt_data_rdy => evt_data_rdy,
1756 EventData_in => EventData,
1757 EventData_we => evt_data_we,
1758 EventData_re => evt_data_re,
1759 evt_buf_full => evt_buf_full,
1760 buf_rqst => EventBuf_rqst,
1761 TCPBuf_avl => TCPbuf_avl,
1762 MonBuf_avl => mon_buf_avl,
1763 WaitMonBuf => WaitMonBuf,
1764 MonBufOverWrite => conf
(13),
1765 MonBuf_empty => MonBuf_empty,
1766 MonBufOvfl => MonBufOvfl,
1767 mon_evt_cnt => mon_evt_cnt,
1768 WrtMonBlkDone => WrtMonBlkDone,
1769 WrtMonEvtDone => WrtMonEvtDone,
1770 KiloByte_toggle => KiloByte_toggle,
1771 EoB_toggle => EoB_toggle,
1772 wport_rdy => wport_rdy,
1773 wport_FIFO_full => wport_FIFO_full,
1774 EventBufAddr_we => EventBufAddr_we,
1775 EventBufAddr => EventBufAddr,
1777 TCP_dout => TCP_din,
1778 TCP_channel => TCP_channel,
1780 TCP_wcount => TCP_wcount,
1781 TCP_raddr => TCP_raddr,
1782 TCP_length => TCP_length,
1783 TCP_rrqst => TCP_rrqst,
1784 TCP_rack => TCP_rack,
1785 TCP_din => TCP_dout,
1786 TCP_din_type => TCP_dout_type,
1787 TCP_din_valid => TCP_dout_valid ,
1788 TCP_lastword => TCP_lastword,
1789 SFP0_RXN => SFP0_RXN,
1790 SFP0_RXP => SFP0_RXP,
1791 SFP1_RXN => SFP1_RXN,
1792 SFP1_RXP => SFP1_RXP,
1793 SFP2_RXN => SFP2_RXN,
1794 SFP2_RXP => SFP2_RXP,
1795 SFP0_TXN => SFP0_TXN,
1796 SFP0_TXP => SFP0_TXP,
1797 SFP1_TXN => SFP1_TXN,
1798 SFP1_TXP => SFP1_TXP,
1799 SFP2_TXN => SFP2_TXN,
1800 SFP2_TXP => SFP2_TXP,
1801 SFP_REFCLK_N => SFP_REFCLK_N,
1802 SFP_REFCLK_P => SFP_REFCLK_P,
1805 ipb_write => ipb_master_out.ipb_write ,
1806 ipb_strobe => ipb_master_out.ipb_strobe ,
1807 ipb_addr => ipb_master_out.ipb_addr ,
1808 ipb_wdata => ipb_master_out.ipb_wdata ,
1809 ipb_rdata => SFP_data
1811 TCPIP_GTXreset <= wr_AMC_en or not sys_lock or cmd(4) or cmd0_dl(0);
1812 end generate g_TCPIP_if;
1813 process(DRPclk, sys_lock)
1815 if(sys_lock = '0')then
1817 elsif(DRPclk'event and DRPclk = '1')then
1818 if(CLK_rdy = '1')then
1829 addr => ipb_master_out.ipb_addr
(15 downto 0),
1830 data => sysmon_data,
1831 device_temp => device_temp,
1837 if(ipb_clk'event and ipb_clk = '1')then
1838 newIPADDRSyncRegs <= newIPADDRSyncRegs(1 downto 0) & newIPADDR;
1839 rst_ipbus <= not newIPADDRSyncRegs(2) and newIPADDR;
1847 rst_cntr => rst_cntr,
1849 inc_serr => inc_serr,
1850 inc_derr => inc_derr,
1851 inc_bcnterr => inc_bcnterr,
1852 inc_l1ac => inc_l1ac,
1855 ttc_resync => ttc_resync,
1856 ipb_addr => ipb_master_out.ipb_addr
(15 downto 0),
1857 ipb_rdata => TTC_cntr_data
1859 i_DNA_PORT : DNA_PORT
1861 SIM_DNA_VALUE => X"00123456789abcd"
-- Specifies a sample 57-bit DNA value for simulation
1864 DOUT => DNA_out,
-- 1-bit output: DNA output data.
1865 CLK => ipb_clk,
-- 1-bit input: Clock input.
1866 DIN => '0',
-- 1-bit input: User data input pin.
1867 READ => load_DNA,
-- 1-bit input: Active high load DNA, active low read input.
1868 SHIFT => shift_DNA
(1) -- 1-bit input: Active high shift enable input.
1872 if(ipb_clk'event and ipb_clk = '1')then
1873 load_DNA <= not sys_lock;
1874 if(sys_lock = '0')then
1875 shift_DNA(0) <= '0';
1876 elsif(load_DNA = '1')then
1877 shift_DNA(0) <= '1';
1878 elsif(shift_DNA(2) = '1' and or_reduce(DNA_cntr(5 downto 1)) = '0')then
1879 shift_DNA(0) <= '0';
1881 shift_DNA(2) <= shift_DNA(0);
1882 if(shift_DNA(2) = '1')then
1883 DNA_cntr <= DNA_cntr - 1;
1884 elsif(shift_DNA(0) = '1')then
1885 DNA_cntr <= "110111";
1887 if(shift_DNA(2) = '1')then
1888 DNA <= DNA(55 downto 0) & DNA_OUT;
1894 if(ipb_clk'event and ipb_clk = '0')then
1895 shift_DNA(1) <= shift_DNA(0);