1 --********************************************************************************* 3 -- Center for Exploration of Energy and Matter (CEEM) 7 -- Author: Brandon Kunkler 11 --********************************************************************************* 14 -- Top level KLM SCROD design for Data Concentrator interface integration. 16 -- There are four data streams: 17 -- 1) Trigger data stream. The TARGET trigger bits are connected directly to and 18 -- processed by the conc_intfc. 19 -- 2) The DAQ data stream. This is an entire triggers worth of DAQ data that will 20 -- be forwarded to the COPPER. As of creation the DAQ data stream from each 21 -- TARGET must be combined before transmitting to the conc_intfc. The DAQ data 22 -- format was not known at time of creation. Connecting all TARGETs to the 23 -- conc_intfc and combing there would be more consistent. The con_intfc 24 -- inserts the lowest 16-bits of the trigger tag to be used for combing scint 26 -- 3) Status data stream. All status registers will be forward to the Data Concentrator 27 -- every so many DAQ packets (trigger cycles). 28 -- 4) Control data stream. The Data Concentrator will transmit a single (large) packet 29 -- containing all run control values as specified in the interface document. 31 -- B2TT Modifications: 32 -- 1) Add dblclock to b2tt_clk_s6. 35 -- 1) The delay (in clocks) between b2tt runreset and the TDC counter sync must be 36 -- known (controlled) to keep scint and RPC TDCs in phase. 37 -- 2) MAXDELAY constraints may need to be placed on the b2tt runreset signal shift 38 -- register in the timing_ctrl entity to distribute the FFs across the chip. 39 -- 3) The asynchronous nature of tx_dst_rdy_n may cause issues in the conc_intfc 41 -- 4) The Aurora core is modified; the files in the ipore directory are not used 42 -- during implementation. 43 -- 5) Search on --? or --! for other important notes. 46 -- 1) Will only work when the FTSW clock is used for both the MGT and 47 -- TXUSERCLK/TXUSERCLK2 (the onboard oscillator cannot be used). The GTPOUTCLK 48 -- will need to be used for all Aurora logic to use oscillator - requires clock 50 -- 2. line 451: exttb <= target_tb_i; -- FIXME 51 -- Not sure what is up with "FIXME." 52 -- This assignment explains all the warnings about ext_tb_format 53 --********************************************************************************* 55 use ieee.std_logic_1164.
all;
56 use ieee.numeric_std.
all;
57 use ieee.std_logic_unsigned.
all;
58 use ieee.std_logic_misc.
all;
60 use work.time_order_pkg.
all;
64 -- synthesis translate_off 66 use unisim.vcomponents.
all;
67 -- synthesis translate_on 72 REVISION : := "A5";
--A2,A3,A4,A5 73 CLKSRC : := "FTSW";
--FTSW, OBOSC 74 AURORA_CC_USE : := FALSE;
76 TB_PERIOD : (15 downto 0) := X"2112";
77 DAQ_GEN_SIM_SPEEDUP : := '0';
78 SIM_REFSELDYPLL : (2 downto 0) := "000";
79 USE_4NS_TDC_CLK : := '0');
86 -- b2tt_b2ttup : in std_logic; 87 -- b2tt_trgout : in std_logic; 88 -- b2tt_b2plllk : out std_logic; --aurora_stat.gtlock 89 b2tt_ctime : in (26 downto 0);
90 b2tt_divclk1 : in (1 downto 0);
91 b2tt_divclk2 : in (1 downto 0);
93 -- b2tt_feereset : in std_logic; 96 -- b2tt_b2lreset : in std_logic; 98 b2tt_fifodata : in (95 downto 0);
101 b2tt_trgtag : in (31 downto 0);
104 target_tb : in tb_vec_type;
107 mgttxfault : in (1 to NUM_GTS);
108 mgtmod0 : in (1 to NUM_GTS);
109 mgtlos : in (1 to NUM_GTS);
110 mgttxdis : out (1 to NUM_GTS);
111 mgtmod2 : out (1 to NUM_GTS);
112 mgtmod1 : out (1 to NUM_GTS);
121 sfp_stat : out SFP_Status_t;
122 aurora_stat : out Aurora_Status_t;
123 -- Run control local link output 124 -- rcl_dst_rdy_n : in std_logic; 125 -- rcl_sof_n : out std_logic; 126 -- rcl_eof_n : out std_logic; 127 rcl_src_rdy_n : out ;
128 rcl_data : out (15 downto 0);
130 qt_fifo_rd_en : out ;
131 qt_fifo_rd_d : in (17 downto 0);
133 qt_fifo_evt_rdy : in ;
136 exttb : out tb_vec_type;
--re-timed trigger bits for ASIC read 139 klm_status_upd : in ;
140 stat_tx_in_progress : out ;
141 klm_status_regs : in stat_reg_type );
144 --- architecture ------------------------------------------------------- 149 DIFF_TERM : := TRUE;
-- Differential Termination 150 IBUF_LOW_PWR : := FALSE;
-- Low power (TRUE) vs. performance (FALSE) setting for referenced I/O standards 151 IOSTANDARD : :=
"DEFAULT");
153 O :
out ;
-- Buffer output 154 I :
in ;
-- Diff_p buffer input (connect directly to top-level port) 155 IB :
in );
-- Diff_n buffer input (connect directly to top-level port) 160 O :
out ;
-- buffer output 161 I :
in );
-- buffer input (connect directly to top-level port) 166 O :
out ;
-- buffer output 167 I :
in );
-- buffer input (connect directly to top-level port) 176 tdcrst :
out (
1 to 3);
--vector so we can distribute to meet timing 177 tdcce_2x :
out (
1 to 5));
-- _Nx is N times clock period 182 SIM_GTPRESET_SPEEDUP : ;
185 refseldypll :
in (
2 downto 0);
193 -- LocalLink TX Interface 200 -- LocalLink RX Interface 205 rx_d :
out (
0 to 15);
217 loopback :
in (
2 downto 0);
227 USE_4NS_TDC_CLK : := '
0');
229 -- inputs --------------------------------------------- 235 b2tt_runreset_tdc :
in (
1 to 3);
239 b2tt_fifodata :
in (
95 downto 0);
240 b2tt_fifonext :
out ;
241 --TARGET ASIC trigger interface (trigger bits) 242 target_tb :
in tb_vec_type;
243 -- target_tb16 : in std_logic_vector(1 to TDC_NASICS); 244 -- status sent to concentrator 246 stat_tx_in_progress :
out ;
247 status_regs :
in stat_reg_type;
248 -- Aurora local input local link (from Concentrator) 249 -- rx_dst_rdy_n : out std_logic; 250 -- rx_sof_n : in std_logic; 251 -- rx_eof_n : in std_logic; 253 rx_data :
in (
15 downto 0);
254 -- DAQ data local link input (TARGET DAQ data when triggered) 255 daq_dst_rdy_n :
out ;
256 daq_sof_n :
in ;
--start of trigger 257 daq_eof_n :
in ;
--end of trigger 259 daq_data :
in (
15 downto 0);
260 -- outputs -------------------------------------------- 262 exttb :
out tb_vec_type;
263 -- Aurora local ouptput local link (to Concentrator) 268 tx_data :
out (
15 downto 0);
270 -- Run control local link output 271 -- rcl_dst_rdy_n : in std_logic; 272 -- rcl_sof_n : out std_logic; 273 -- rcl_eof_n : out std_logic; 274 rcl_src_rdy_n :
out ;
275 rcl_data :
out (
15 downto 0));
284 txfault :
in (
1 to NUM_GTS);
285 txdis :
out (
1 to NUM_GTS);
286 mod2 :
out (
1 to NUM_GTS);
287 mod1 :
out (
1 to NUM_GTS);
288 mod0 :
in (
1 to NUM_GTS);
289 los :
in (
1 to NUM_GTS);
295 alias NUM_ASICS is TDC_NASICS;
297 constant NUM_ATBS : := 5;
--ASIC trigger bits 299 constant REFCLKSEL : (2 downto 0) := "000";
307 signal mgttxfault_i : (1 to NUM_GTS);
308 signal mgtmod0_i : (1 to NUM_GTS);
309 signal mgtlos_i : (1 to NUM_GTS);
311 signal mgttxdis_i : (1 to NUM_GTS);
312 signal mgtmod2_i : (1 to NUM_GTS);
313 signal mgtmod1_i : (1 to NUM_GTS);
315 signal target_tb_i : tb_vec_type;
316 -- signal target_tb16_i : std_logic_vector(1 to TDC_NASICS) := (others => '0'); 318 signal control_fake_i : := '0';
319 signal status_fake_i : := '0';
321 signal sys_clk_ib : ;
322 signal sys_clk2x_ib : ;
324 signal mgttxfault_qi : (1 to NUM_GTS);
325 signal mgtmod0_qi : (1 to NUM_GTS);
326 signal mgtlos_qi : (1 to NUM_GTS);
328 signal mgttxdis_iq : (1 to NUM_GTS);
329 signal mgtmod2_iq : (1 to NUM_GTS);
330 signal mgtmod1_iq : (1 to NUM_GTS);
333 signal b2tt_b2clkup_i : ;
334 -- signal b2tt_b2ttup_i : std_logic; 335 -- signal b2tt_trgout_i : std_logic; 336 signal b2tt_ctime_i : (26 downto 0);
337 signal b2tt_divclk1_i : (1 downto 0);
338 signal b2tt_divclk2_i : (1 downto 0);
339 signal b2tt_runreset_i : ;
340 -- signal b2tt_feereset_i : std_logic; 341 signal b2tt_gtpreset_i : ;
342 -- signal b2tt_b2lreset_i : std_logic; 343 signal b2tt_b2ttver_i : (15 downto 0);
344 signal b2tt_fifordy_i : ;
345 signal b2tt_fifodata_i : (95 downto 0);
346 signal b2tt_exprun_i : (31 downto 0);
347 signal b2tt_frame_i : ;
348 signal b2tt_frame9_i : ;
349 signal b2tt_trgtag_i : (31 downto 0);
350 signal b2tt_fifonext_i : ;
352 signal b2tt_ctime_or : ;
354 -- signal rx_dst_rdy_n : std_logic; 355 -- signal rx_sof_n : std_logic; 356 -- signal rx_eof_n : std_logic; 357 signal rx_src_rdy_n : ;
358 signal rx_data : (15 downto 0);
360 signal tx_dst_rdy_n : ;
363 signal tx_src_rdy_n : ;
364 signal tx_data : (15 downto 0);
367 signal tdc_ce : (1 to 5);
368 signal b2tt_frame2x : (1 to 3);
369 signal b2tt_runreset2x : (1 to 3);
370 signal b2tt_runreset_tdc : (1 to 3);
372 signal status_regs : stat_reg_type;
373 signal ctrl_regs : ctrl_reg_type;
374 signal daq_dst_rdy_n : ;
377 signal daq_src_rdy_n : ;
378 signal daq_data : (15 downto 0);
379 signal inttb : tb_vec_type;
383 -- attribute keep of b2tt_runreset2x : signal is "true"; -- WHY? does not have a driver. CK. 384 attribute keep of b2tt_trgtag_i : signal is "true";
389 sys_clk_ib <= sysclk;
390 sys_clk2x_ib <= sysclk2x;
394 if rising_edge(sysclk) then 395 b2tt_b2clkup_i <= b2tt_b2clkup;
396 -- b2tt_b2ttup_i <= b2tt_b2ttup; 397 -- b2tt_trgout_i <= b2tt_trgout; 398 b2tt_ctime_i <= b2tt_ctime;
399 -- b2tt_feereset_i <= b2tt_feereset; 400 b2tt_gtpreset_i <= b2tt_gtpreset;
401 -- b2tt_b2lreset_i <= b2tt_b2lreset; 402 b2tt_fifordy_i <= b2tt_fifordy;
403 b2tt_fifodata_i <= b2tt_fifodata;
404 b2tt_frame_i <= b2tt_frame;
405 b2tt_trgtag_i <= b2tt_trgtag;
406 b2tt_runreset_i <= b2tt_runreset;
408 b2tt_fifonext <= b2tt_fifonext_i;
413 ------------------------------------------------- 415 ------------------------------------------------- 416 mgtclk0_inst : IBUFDS
418 O => mgtclk0_i,
-- Buffer output 419 I => mgtclk0p,
-- Diff_p buffer input (connect directly to top-level port) 420 IB => mgtclk0n
-- Diff_n buffer input (connect directly to top-level port) 423 mgtclk1_inst : IBUFDS
425 O => mgtclk1_i,
-- Buffer output 426 I => mgtclk1p,
-- Diff_p buffer input (connect directly to top-level port) 427 IB => mgtclk1n
-- Diff_n buffer input (connect directly to top-level port) 431 for I in 1 to 10 generate 433 for J in 5 downto 1 generate 436 O => target_tb_i
(I
)(J
),
442 exttb <= target_tb_i;
-- FIXME 444 mgttxfault_IBUF_GEN : 445 for I in 1 to NUM_GTS generate 446 mgttxfault_IBUF : IBUF
448 O => mgttxfault_i
(I
),
454 for I in 1 to NUM_GTS generate 463 for I in 1 to NUM_GTS generate 483 ------------------------------------------------- 485 ------------------------------------------------- 487 for I in 1 to NUM_GTS generate 496 for I in 1 to NUM_GTS generate 505 for I in 1 to NUM_GTS generate 526 ---------------------------------------------------------------- 527 -- Clock enables, resets, strobes, etc. 528 ---------------------------------------------------------------- 532 clk2x => sys_clk2x_ib,
533 tdc_sync => b2tt_frame_i,
--tdc_sync,--! 534 runreset => b2tt_runreset_i,
535 tdcrst => b2tt_frame2x,
539 fast_tdc_clk:
if USE_4NS_TDC_CLK = '1'
generate 540 tdc_clk <= sys_clk2x_ib;
541 b2tt_runreset_tdc <= b2tt_runreset2x;
544 reg_tdc_clk:
if USE_4NS_TDC_CLK = '0'
generate 545 tdc_clk <= sys_clk_ib;
546 b2tt_runreset_tdc <= (others => b2tt_runreset_i);
549 ---------------------------------------------------------------- 551 ---------------------------------------------------------------- 554 SIM_GTPRESET_SPEEDUP =>
1,
555 CLK_CORRECT_USE => AURORA_CC_USE
) 557 refseldypll => refclksel,
558 ref_clk0 => mgtclk0_i,
559 ref_clk1 => mgtclk1_i,
560 user_clk => sys_clk_ib,
561 sync_clk => sys_clk2x_ib,
562 reset => b2tt_runreset_i,
--b2tt_b2lreset, 563 gt_reset => b2tt_runreset_i,
--b2tt_gtpreset,-- 564 plllock => b2tt_b2clkup_i,
--b2tt_b2plllk, 565 -- LocalLink TX Interface 566 tx_dst_rdy_n => tx_dst_rdy_n,
567 tx_src_rdy_n => tx_src_rdy_n,
568 tx_sof_n => tx_sof_n,
569 tx_eof_n => tx_eof_n,
572 -- LocalLink RX Interface 573 rx_src_rdy_n => rx_src_rdy_n,
574 rx_sof_n =>
open,
--rx_sof_n, (CK) 575 rx_eof_n =>
open,
--rx_eof_n, (CK) 579 gtlock => aurora_stat.gtlock,
580 hard_err => aurora_stat.hard_err,
581 soft_err => aurora_stat.soft_err,
582 frame_err => aurora_stat.frame_err,
583 channel_up => aurora_stat.channel_up,
584 lane_up => aurora_stat.lane_up,
585 warn_cc => aurora_stat.warn_cc,
-- the may help in conc interface 586 do_cc => aurora_stat.do_cc,
597 ---------------------------------------------------------------- 598 -- Data Concentrator interface. Generate and time-order TDC. 599 -- Combine trigger, DAQ, and status data. Receive control data. 600 ---------------------------------------------------------------- 603 USE_4NS_TDC_CLK => USE_4NS_TDC_CLK
606 -- inputs --------------------------------------------- 607 sys_clk => sys_clk_ib,
611 b2tt_runreset => b2tt_runreset_i,
612 b2tt_runreset_tdc => b2tt_runreset_tdc,
613 b2tt_frame2x => b2tt_frame2x
(1),
614 b2tt_gtpreset => b2tt_gtpreset_i,
615 b2tt_fifordy => b2tt_fifordy_i ,
616 b2tt_fifodata => b2tt_fifodata_i,
617 b2tt_fifonext => b2tt_fifonext_i,
618 --TARGET ASIC trigger interface (trigger bits) 620 -- target_tb16 => target_tb16_i, 621 -- status sent to concentrator 622 status_upd => klm_status_upd,
623 stat_tx_in_progress => stat_tx_in_progress,
624 status_regs => status_regs,
625 -- Aurora local input local link (from Concentrator) 626 -- rx_dst_rdy_n => rx_dst_rdy_n, 627 -- rx_sof_n => rx_sof_n, 628 -- rx_eof_n => rx_eof_n, 629 rx_src_rdy_n => rx_src_rdy_n,
631 -- DAQ data local link input (TARGET DAQ data when triggered) 632 daq_dst_rdy_n => daq_dst_rdy_n,
633 daq_sof_n => daq_sof_n,
--start of trigger 634 daq_eof_n => daq_eof_n,
--end of trigger 635 daq_src_rdy_n => daq_src_rdy_n,
636 daq_data => daq_data,
637 -- outputs -------------------------------------------- 640 -- Aurora local ouptput local link (to Concentrator) 641 tx_dst_rdy_n => tx_dst_rdy_n,
642 tx_sof_n => tx_sof_n,
643 tx_eof_n => tx_eof_n,
644 tx_src_rdy_n => tx_src_rdy_n,
646 -- Run control local link output 647 -- rcl_dst_rdy_n => rcl_dst_rdy_n, 648 -- rcl_sof_n => rcl_sof_n, 649 -- rcl_eof_n => rcl_eof_n, 650 rcl_src_rdy_n => rcl_src_rdy_n,
654 ---------------------------------------------------------------- 655 -- Create a single DAQ data stream from all ASICs. 658 -- VS: TODO move this entity to the top level 659 -- VS: There is something wrong with fifonext signal. FIXME 660 ---------------------------------------------------------------- 664 reset => b2tt_runreset_i,
666 tx_dst_rdy_n => daq_dst_rdy_n,
667 tx_src_rdy_n => daq_src_rdy_n,
668 tx_sof_n => daq_sof_n,
669 tx_eof_n => daq_eof_n,
672 qt_fifo_rd_en => qt_fifo_rd_en,
673 qt_fifo_rd_d => qt_fifo_rd_d,
674 qt_fifo_empty => qt_fifo_empty,
675 qt_fifo_evt_rdy => qt_fifo_evt_rdy
678 inttb <= target_tb_i when trgon = '1' else (others => (others => '0'));
680 ---------------------------------------------------------------- 681 -- Deal with the SFP connections. // VS: do we need this? 682 ---------------------------------------------------------------- 688 txfault => mgttxfault_qi,
694 fault_flag => sfp_stat.fault_flag,
695 mod_flag => sfp_stat.mod_flag,
696 los_flag => sfp_stat.los_flag
699 --------------------------------------------------------------------- 700 -- Concurrent statements 701 --------------------------------------------------------------------- 703 -------------------------------------- 704 -- Map the status registers 705 -------------------------------------- 706 STAT_GEN : for I in 0 to NUM_SCROD_REGS-1 generate 707 status_regs(I) <= klm_status_regs(I);
711 b2tt_b2linkwe <= (not tx_src_rdy_n);
713 --------------------------------------------------------------------- 714 -- Synchronous processes 715 --------------------------------------------------------------------- 716 ---------------------------------------------------------------- 717 -- Input registers to be placed in the I/O ring 718 ---------------------------------------------------------------- 720 -------------------------------------- 721 -- System clock domain input registers 722 -------------------------------------- 723 sysin_regs :
process(sys_clk_ib)
725 if (sys_clk_ib'event and sys_clk_ib = '1') then 726 mgttxfault_qi <= mgttxfault_i;
727 mgtmod0_qi <= mgtmod0_i;
728 mgtlos_qi <= mgtlos_i;
732 ---------------------------------------------------------------- 733 -- Output registers to be placed in the I/O ring 734 ---------------------------------------------------------------- 736 -------------------------------------- 737 -- System clock domain output registers 738 -------------------------------------- 739 sout_regs :
process(sys_clk_ib)
741 if (sys_clk_ib'event and sys_clk_ib = '1') then 742 mgttxdis_iq <= mgttxdis_i;
743 mgtmod2_iq <= mgtmod2_i;
744 mgtmod1_iq <= mgtmod1_i;