105 use IEEE.STD_LOGIC_1164.
ALL;
107 use IEEE.NUMERIC_STD.
ALL;
110 library TOB_rdout_lib;
193 type FPGA_mapping_array is array(3 downto 0) of std_logic_vector(1 downto 0);
194 constant FPGA_mapping : FPGA_mapping_array := ("10", "01", "11", "00") ;
196 signal TOB_out_valid_i : std_logic;
197 signal TOB_rdout_fifo_rd_en_i : std_logic ;
198 signal corrective_trailer : std_logic ;
200 signal BCN_FIFO_rd_en_i : std_logic ;
201 signal BCN_FIFO_valid_in_i : std_logic ;
203 signal slice_count_i : unsigned (2 downto 0):= (others => '0');
204 signal link_err_flg_in_i : STD_LOGIC_VECTOR(3 downto 0):= (others => '0');
205 signal TOB_BCN_in_i : STD_LOGIC_VECTOR(7 downto 0):= (others => '0');
206 signal FIFO_BCN_in_i : STD_LOGIC_VECTOR(11 downto 0):= (others => '0');
207 signal XTOB_eg_BCN_in_i : std_logic_vector (7 downto 0):= (others => '0');
208 signal XTOB_hdr_BCN_in_i : std_logic_vector (7 downto 0):= (others => '0');
209 signal XTOB_tau_BCN_in_i : std_logic_vector (7 downto 0):= (others => '0');
210 signal FIFO_L1A_ID_i : STD_LOGIC_VECTOR(23 downto 0):= (others => '0');
211 signal FIFO_L1A_ID_EXT_i : STD_LOGIC_VECTOR(7 downto 0):= (others => '0');
213 signal TOBs_out_i : STD_LOGIC_VECTOR(31 downto 0):= (others => '0');
215 signal TOB_out_is_char_i : std_logic ;
216 signal write_in_LO_FIFO_i : std_logic ;
218 signal CLK_280M_i : std_logic ;
220 signal cntr_rst_i : std_logic ;
221 signal TOB_cntr_rst : std_logic ;
222 signal T_TOB_cntr_en_i : std_logic := '0' ;
223 signal T_TOB_cntr_i : std_logic_vector(3 downto 0) := (others => '0');
224 signal T_TOB_cntr_1dly : std_logic_vector(3 downto 0) := (others => '0');
226 signal XTOB_eg_cntr_en_i : std_logic := '0' ;
227 signal XTOB_eg_cntr_i : std_logic_vector(6 downto 0) := (others => '0');
228 signal XTOB_eg_cntr_1dly : std_logic_vector(6 downto 0) := (others => '0');
229 signal XTOB_tau_cntr_en_i : std_logic := '0' ;
230 signal XTOB_tau_cntr_i : std_logic_vector(6 downto 0) := (others => '0');
231 signal XTOB_tau_cntr_1dly : std_logic_vector(6 downto 0) := (others => '0');
233 signal trailer_cntr_en : std_logic ;
234 signal payld_cntr_rst : std_logic ;
235 signal payld_cntr_rst_i : std_logic ;
236 signal payld_cntr_en : std_logic := '0' ;
237 signal TOB_payld_cntr_i : std_logic_vector(11 downto 0) := (others => '0');
238 signal TOB_payld_cntr_1dly : std_logic_vector(11 downto 0) := (others => '0');
240 signal frame_cntr_en_i : std_logic ;
241 signal slice_no_txed : std_logic_vector(2 downto 0) := (others => '0');
243 signal T_TOB_eg_i : std_logic_vector(191 downto 0) := (others => '0');
244 signal T_TOB_eg_valid_i : std_logic_vector(5 downto 0) := (others => '0');
246 signal valid_XTOBs_eg_i : std_logic ;
247 signal valid_XTOBs_tau_i : std_logic ;
254 signal safe_mode_i : std_logic ;
255 signal miss_sop_i : std_logic ;
256 signal wr_en_i : std_logic ;
259 idle, idle_1, wait1, wait2, wait3, wait4, wait5,
261 norm_sop1, norm_sop2, norm_tlr, norm_eop,
262 rd_fifo, sub_trl_1, sub_trl_2,
264 rdout_XTOB_eg_a0, rdout_XTOB_eg_a, rdout_XTOB_eg_b, rdout_XTOB_tau_a0, rdout_XTOB_tau_a, rdout_XTOB_tau_b
267 SIGNAL current_state : STATE_TYPE;
268 signal i : integer range 0 to 9;
270 signal m_s_count : integer range 0 to 7;
273 attribute keep : string ;
274 attribute max_fanout : integer;
301 corrective_trailer <= '0';
302 CLK_280M_i <= CLK_280M_in ;
311 U1_clk_280_proc :
Process (CLK_280M_i)
313 if rising_edge (CLK_280M_i) then
335 T_TOB_cntr_1dly <= T_TOB_cntr_i ;
336 XTOB_eg_cntr_1dly <= XTOB_eg_cntr_i ;
337 XTOB_tau_cntr_1dly <= XTOB_tau_cntr_i ;
338 TOB_payld_cntr_1dly <= TOB_payld_cntr_i ;
350 CE => T_TOB_cntr_en_i ,
362 CE => XTOB_eg_cntr_en_i ,
374 CE => XTOB_tau_cntr_en_i ,
381 payld_cntr_en <= T_TOB_cntr_en_i OR XTOB_eg_cntr_en_i OR XTOB_tau_cntr_en_i OR trailer_cntr_en;
390 CE => payld_cntr_en ,
392 RST => payld_cntr_rst,
393 Q => TOB_payld_cntr_i
397 U3A_proc1 :
process (CLK_280M_i)
399 if rising_edge (CLK_280M_i) then
402 write_in_LO_FIFO_i <= '1';
404 write_in_LO_FIFO_i <= '0' ;
414 wr_en_i <= write_in_LO_FIFO_i ;
416 U4_rd_fsm :
process (CLK_280M_i)
417 variable k, j : integer range 0 to 10 ;
420 if CLK_280M_i'event and CLK_280M_i = '1' then
422 current_state <= idle ;
425 payld_cntr_rst_i <= '1' ;
426 T_TOB_cntr_en_i <= '0' ;
427 XTOB_eg_cntr_en_i <= '0' ;
428 XTOB_tau_cntr_en_i <= '0' ;
429 TOBs_out_i <= (others => '0') ;
432 CASE current_state is
438 payld_cntr_rst_i <= '0' ;
439 frame_cntr_en_i <= '0' ;
440 trailer_cntr_en <= '0' ;
441 BCN_FIFO_rd_en_i <= '0' ;
442 TOB_rdout_fifo_rd_en_i <= '0' ;
443 T_TOB_cntr_en_i <= '0' ;
444 XTOB_eg_cntr_en_i <= '0' ;
445 XTOB_tau_cntr_en_i <= '0' ;
446 TOB_out_valid_i <= '0' ;
447 TOB_out_is_char_i <= '0' ;
452 slice_no_txed <= "000";
453 if (write_in_LO_FIFO_i = '1' ) then
455 current_state <= idle_1 ;
457 current_state <= idle ;
466 current_state <= idle_1 ;
468 TOB_rdout_fifo_rd_en_i <= '1';
469 BCN_FIFO_rd_en_i <= '1' ;
470 current_state <= wait5 ;
473 current_state <= idle ;
478 trailer_cntr_en <= '0' ;
480 TOB_out_is_char_i <= '0';
481 TOB_out_valid_i <= '0' ;
482 BCN_FIFO_rd_en_i <= '0' ;
483 TOB_rdout_fifo_rd_en_i <= '0';
489 current_state <= norm_sop1 ;
493 current_state <= rd_fifo ;
499 XTOB_hdr_BCN_in_i <= std_logic_vector( unsigned ('0' & XTOBs_eg_in(0)(251 downto 245))
511 XTOB_eg_valid_i(0) <= XTOBs_eg_in(0)(244 downto 240);
512 XTOB_eg_valid_i(1) <= XTOBs_eg_in(1)(244 downto 240);
513 XTOB_eg_valid_i(2) <= XTOBs_eg_in(2)(244 downto 240);
514 XTOB_eg_valid_i(3) <= XTOBs_eg_in(3)(244 downto 240);
515 XTOB_eg_valid_i(4) <= XTOBs_eg_in(4)(244 downto 240);
516 XTOB_eg_valid_i(5) <= XTOBs_eg_in(5)(244 downto 240);
517 XTOB_eg_valid_i(6) <= XTOBs_eg_in(6)(244 downto 240);
518 XTOB_eg_valid_i(7) <= XTOBs_eg_in(7)(244 downto 240);
520 XTOB_eg_BCN_in_i <= '0' & XTOBs_eg_in(0)(251 downto 245);
540 XTOB_tau_BCN_in_i <= '0' & XTOBs_tau_in(0)(251 downto 245);
542 trailer_cntr_en <= '0' ;
543 TOB_rdout_fifo_rd_en_i <= '0' ;
544 TOB_out_valid_i <= '0' ;
545 if valid_XTOBs_eg_i = '1' then
546 if miss_sop_i = '0' then
547 current_state <= norm_sop1 ;
549 current_state <= rdout_T_TOB_eg ;
552 current_state <= rd_fifo ;
558 TOB_rdout_fifo_rd_en_i <= '0' ;
560 TOBs_out_i <= "0" & TOB_BCN_in_i(6 downto 0) & XTOB_hdr_BCN_in_i(3 downto 0) & FIFO_BCN_in_i & ch_sop1 ;
561 TOB_out_is_char_i <= '1';
562 TOB_out_valid_i <= '1' ;
563 current_state <= norm_sop2 ;
567 TOBs_out_i <= FIFO_L1A_ID_EXT_i & FIFO_L1A_ID_i ;
568 TOB_out_is_char_i <= '0';
569 TOB_out_valid_i <= '1' ;
570 if ( safe_mode_i = '1' ) then
571 current_state <= sub_trl_1 ;
573 current_state <= rdout_T_TOB_eg ;
576 when rdout_T_TOB_eg =>
578 TOB_out_is_char_i <= '0';
579 T_TOB_cntr_en_i <= T_TOB_eg_valid_i(i) AND wr_en_i;
580 TOBs_out_i <= T_TOB_eg_i((((i*32)+32)-1) downto (i*32));
581 TOB_out_valid_i <= T_TOB_eg_valid_i(i) AND wr_en_i;
584 current_state <= rdout_XTOB_eg_a0;
586 current_state <= rdout_T_TOB_eg ;
592 when rdout_XTOB_eg_a0 =>
596 T_TOB_cntr_en_i <= '0';
597 XTOB_eg_cntr_en_i <= XTOB_eg_valid_i(j)(k) AND wr_en_i;
598 TOB_out_valid_i <= XTOB_eg_valid_i(j)(k) AND wr_en_i;
599 TOBs_out_i <= XTOB_eg_i(j)(31 downto 0);
600 current_state <= rdout_XTOB_eg_b ;
602 when rdout_XTOB_eg_a =>
603 XTOB_eg_cntr_en_i <= XTOB_eg_valid_i(j)(k) AND wr_en_i;
604 TOB_out_valid_i <= XTOB_eg_valid_i(j)(k) AND wr_en_i;
605 TOBs_out_i <= XTOB_eg_i(j)(31 downto 0);
606 current_state <= rdout_XTOB_eg_b ;
608 when rdout_XTOB_eg_b =>
609 XTOB_eg_cntr_en_i <= XTOB_eg_valid_i(j)(k) AND wr_en_i;
610 TOB_out_valid_i <= XTOB_eg_valid_i(j)(k) AND wr_en_i;
612 XTOB_eg_i(j) <= X"000000000000" & XTOB_eg_i(j)(239 downto 48);
616 current_state <= rdout_XTOB_tau_a0;
620 current_state <= rdout_XTOB_eg_a;
624 current_state <= rdout_XTOB_eg_a;
629 when rdout_XTOB_tau_a0 =>
633 XTOB_eg_cntr_en_i <= '0' ;
634 XTOB_tau_cntr_en_i <= XTOB_tau_valid_i(j)(k) AND wr_en_i;
635 TOB_out_valid_i <= XTOB_tau_valid_i(j)(k) AND wr_en_i;
636 TOBs_out_i <= XTOB_tau_i(j)(31 downto 0);
637 current_state <= rdout_XTOB_tau_b ;
639 when rdout_XTOB_tau_a =>
640 XTOB_tau_cntr_en_i <= XTOB_tau_valid_i(j)(k) AND wr_en_i;
641 TOB_out_valid_i <= XTOB_tau_valid_i(j)(k) AND wr_en_i;
642 TOBs_out_i <= XTOB_tau_i(j)(31 downto 0);
643 current_state <= rdout_XTOB_tau_b ;
645 when rdout_XTOB_tau_b =>
646 XTOB_tau_cntr_en_i <= XTOB_tau_valid_i(j)(k) AND wr_en_i;
647 TOB_out_valid_i <= XTOB_tau_valid_i(j)(k) AND wr_en_i;
649 XTOB_tau_i(j) <= X"000000000000" & XTOB_tau_i(j)(239 downto 48);
653 current_state <= wait1;
657 current_state <= rdout_XTOB_tau_a;
661 current_state <= rdout_XTOB_tau_a;
666 XTOB_tau_cntr_en_i <= '0' ;
667 TOB_out_valid_i <= '0' ;
669 current_state <= sub_trl_1;
673 trailer_cntr_en <= '0' ;
674 TOB_out_is_char_i <= '0';
675 TOB_out_valid_i <= '0' ;
676 current_state <= sub_trl_1 ;
680 trailer_cntr_en <= '0' ;
682 TOB_rdout_fifo_rd_en_i <= '0';
683 slice_no_txed <= std_logic_vector(to_unsigned(m_s_count,3));
684 m_s_count <= m_s_count + 1 ;
685 TOB_out_valid_i <= '0' ;
686 TOB_out_is_char_i <= '0';
687 if TOB_payld_cntr_i(0) = '0' OR safe_mode_i = '1' then
688 TOB_out_valid_i <= '1' ;
689 TOBs_out_i <= X"00000000" ;
690 trailer_cntr_en <= '1' ;
692 current_state <= sub_trl_2 ;
696 trailer_cntr_en <= '1' ;
698 TOB_out_is_char_i <= '1';
699 TOB_out_valid_i <= '1' ;
701 TOBs_out_i <= '0' & read_on_err_in & FPGA_mapping(to_integer(unsigned(hw_addr))) & safe_mode_i & slice_no_txed &
702 XTOB_tau_cntr_1dly(6 downto 1) & XTOB_eg_cntr_1dly(6 downto 1) & T_TOB_cntr_1dly(2 downto 0) &
705 if m_s_count = slice_count_i then
706 current_state <= wait3 ;
709 if safe_mode_i = '0' then
711 TOB_rdout_fifo_rd_en_i <= '1';
712 current_state <= wait5 ;
715 TOB_rdout_fifo_rd_en_i <= '1';
716 current_state <= wait2 ;
722 trailer_cntr_en <= '0' ;
724 TOB_out_is_char_i <= '0';
725 TOB_out_valid_i <= '0' ;
726 current_state <= wait4 ;
729 TOB_out_valid_i <= '0' ;
730 current_state <= norm_eop ;
733 frame_cntr_en_i <= '1' ;
734 payld_cntr_rst_i <= '1' ;
736 TOB_out_is_char_i <= '1';
738 TOB_out_valid_i <= '1' ;
739 current_state <= idle ;
Generic Counter for process FPGA.
in CLK STD_LOGIC
Clock signal input.
in CE STD_LOGIC
Enable signal input.
out Q STD_LOGIC_VECTOR( width- 1 downto 0)
Counter Output signal.
in RST STD_LOGIC
Reset signal input.
( 7 downto 0) STD_LOGIC_VECTOR( 4 downto 0) array_8_of_5b
array of 8, holding 5b XTOB_valid_out signlas
( 7 downto 0) STD_LOGIC_VECTOR( 239 downto 0) array_8_of_240b
array of 8, holding 240b XTOB_data_out
( 7 downto 0) STD_LOGIC_VECTOR( 251 downto 0) array_8_of_252b
array of 8, holding XTOB_BCN (7b) & 5b valid & 240b XTOB_data_out
FSM to write Merged TOBs and Local XTOBs (tau & e/g) data to Link Output FIFO for process FPGA 1 and ...
FSM to write Merged TOBs and Local XTOBs (tau & e/g) data to Link Output FIFO for process FPGA 1 and ...
in valid_XTOBs_eg_in STD_LOGIC
XTOBs e/g valid signal.
in TOB_type_in STD_LOGIC
Sorted TOB data readout 32b * 7 in series, only 6 is used - F1 reads e/g TOBs and F2 reads tau TOBs.
in trigger_slice_in STD_LOGIC_VECTOR( 3 downto 0)
Trigger slice number - on L1A.
in DPR_locations_to_rd STD_LOGIC_VECTOR( 2 downto 0)
number of DRPAM locations to read for multi-slice (1 to 5)
in TOB_prog_full_flag_in std_logic
Input prog Full flag of all TOB FIFOs TTC, TOB & XTOB FIFOs.
in BCN_FIFO_prog_full_in STD_LOGIC
BCN & L1A FIFO prog full flag.
out tob_data_mux_fsm STD_LOGIC_VECTOR( 7 downto 0)
Monitor state machine status register.
in rdout_T_TOB_209b_in STD_LOGIC_VECTOR( 208 downto 0)
sorted TOBs 209b = 7b+4b+6b+192b TOB_BCN+ERR+valid+TOBs
in FIFO_L1A_ID_EXT STD_LOGIC_VECTOR( 7 downto 0)
Extended L1A ID from TTC input.
in XTOBs_eg_in array_8_of_252b
XTOBs e/g {array 8 of [(5*64b) + 5b valid]}.
in LO_FIFO_data_count_in STD_LOGIC_VECTOR( 12 downto 0)
Link Output FIFO data count.
in TOB_FIFO_empty_in std_logic
Input empty flag of all TOB FIFOs TTC, TOB & XTOB FIFOs.
out BCN_FIFO_rd_en_out STD_LOGIC
read enable signal to BCN & L1A_ID FIFOs
in shelf_number STD_LOGIC_VECTOR( 3 downto 0)
shelf number input
in efex_slot_num STD_LOGIC_VECTOR( 3 downto 0)
eFEX slot number input
in FIFO_BCN_in STD_LOGIC_VECTOR( 11 downto 0)
Bunch Crossing ID from BCN counter.
out TOB_rdout_fifo_rd_en_out STD_LOGIC
read enable signal to all TOB/XTOB FIFOs
out TOB_out_valid STD_LOGIC
sorted TOBsXTOBs data valid signal to Link_outpout_FIFO
in FIFO_L1A_ID STD_LOGIC_VECTOR( 23 downto 0)
L1A ID from TTC input.
FPGA_NUMBER integer := 1
Integer used to distinguish different FPGAs having a slightly different firmware.
in BCN_FIFO_valid_in STD_LOGIC
Data from TTC FIFO is valid.
in hw_addr STD_LOGIC_VECTOR( 1 downto 0)
FPGA Hardware Address.
in valid_XTOBs_tau_in STD_LOGIC
XTOBs tau valid signal.
in LO_FIFO_prog_full_in std_logic
Link Output FIFO partial FULL flag to receive RAW calorimeter data.
in valid_T_TOB_in std_logic
sorted TOBs valid signal
out TOB_safe_mode_out STD_LOGIC
Safe Mode operation flag for TOB readout.
out TOB_out_is_char STD_LOGIC
sorted TOBsXTOBs data is CHAR signal to Link_outpout_FIFO
in TOB_FIFO_sw_rst std_logic
TOB Readout FIFO reset Pulse by software command ORed with SYS_RST.
out frame_cntr_en STD_LOGIC
enable frame counter to count up by 1
out TOBs_out STD_LOGIC_VECTOR( 31 downto 0)
sorted TOBsXTOBs 32b data to Link_outpout_FIFO
in read_on_err_in STD_LOGIC
Read RAW data on error flag.
in clk_280M_in STD_LOGIC
280MHz clock input signal
in XTOBs_tau_in array_8_of_252b
XTOBs tau {array 8 of [(5*64b) + 5b valid]}.