eFEX firmware  1.7.3
ATLAS l1-calo - electron and tau feature extraction firmware for eFEX boards

Back to eFEX documentation
efex_data_formats.vhd
Go to the documentation of this file.
1 
337 
338 
339 library IEEE;
340 use IEEE.STD_LOGIC_1164.all;
341 
342 use IEEE.NUMERIC_STD.all;
343 library algolib;
344 use algolib.AlgoDataTypes.all;
345 use algolib.DataTypes.all;
346 
347 library TOB_rdout_lib;
348 use TOB_rdout_lib.TOB_rdout_ip_pkg.all;
349 use TOB_rdout_lib.data_type_pkg.all;
350 
352 package EfexDataFormats is
353 
354  type enable_em_chan_type is array (0 to 39) of integer;
355  type enable_had_chan_type is array (0 to 17) of integer;
356  type enable_spare_chan_type is array (0 to 5) of integer;
357 
358  constant EN_EG1 : enable_em_chan_type := (34, 32, 36, 30, 37, 24, 39, 22, 26, 28, -- this array is (0 to 39)
359  31, 27, 38, 29, 35, 23, 33, 25, 20, 21,
360  14, 13, 15, 11, 17, 12, 19, 10, 18, 16,
361  05, 01, 06, 02, 08, 04, 07, 00, 09, 03);
362  constant EN_HAD1 : enable_had_chan_type := (55, 56, 54, 59, 57, 58,
363  42, 43, 40, 48, 41, 51,
364  44, 46, 45, 50, 47, 49);
365  constant EN_SPR1 : enable_spare_chan_type := (52, 53, 60, 61, 62, 63);
366 
367  constant EN_EG2 : enable_em_chan_type := (34, 36, 30, 35, 31, 38, 33, 39, 32, 37, -- this array is (0 to 39)
368  29, 28, 26, 27, 23, 25, 21, 24, 20, 22,
369  10, 11, 19, 12, 16, 13, 18, 15, 17, 14,
370  00, 09, 01, 07, 05, 08, 03, 04, 02, 06);
371  constant EN_HAD2 : enable_had_chan_type := (58, 56, 61, 55, 59, 52,
372  63, 54, 62, 53, 60, 57,
373  49, 48, 47, 46, 45, 44);
374  constant EN_SPR2 : enable_spare_chan_type := (63, 58, 51, 50, 61, 56);
375 
376  constant EN_EG3 : enable_em_chan_type := (54, 52, 51, 47, 49, 44, 50, 46, 45, 48, -- this array is (0 to 39)
377  57, 60, 62, 56, 63, 53, 61, 58, 59, 55,
378  21, 22, 23, 20, 25, 24, 27, 26, 18, 19,
379  11, 16, 08, 17, 09, 10, 14, 12, 13, 15);
380  constant EN_HAD3 : enable_had_chan_type := (39, 38, 30, 31, 37, 36,
381  35, 29, 34, 33, 32, 28,
382  01, 05, 06, 04, 07, 00);
383  constant EN_SPR3 : enable_spare_chan_type := (02, 03, 40, 41, 42, 4);
384 
385  constant EN_EG4 : enable_em_chan_type := (10, 18, 11, 19, 13, 17, 12, 16, 14, 15, -- this array is (0 to 39)
386  00, 08, 01, 09, 03, 06, 02, 07, 04, 05,
387  37, 38, 36, 42, 34, 43, 35, 41, 40, 39,
388  31, 27, 24, 30, 25, 33, 26, 29, 28, 32);
389  constant EN_HAD4 : enable_had_chan_type := (61, 60, 23, 22, 21, 20,
390  54, 48, 49, 55, 50, 51,
391  58, 52, 59, 53, 56, 57);
392 -- constant EN_SPR4 : enable_spare_chan_type := (63, 62, 47, 46, 45, 44, 21, 20);
393 
394 
395  -- Define the number of fibres needed to cover the environment area processed by an eFEX FPGA,
396  -- in eta and Phi...
397 
398  constant NUM_FIB_Em_ETA : integer := 4;
399  constant NUM_FIB_Em_PHI : integer := 10;
400 
401  constant NUM_FIB_Had_ETA : integer := 3;
402  constant NUM_FIB_Had_PHI : integer := 6;
403 
404  constant NUM_FIB_SPARE : integer := 8;
405 
406  constant N_MGT : integer := 64;
407 
408  type mgt_data_in is array (N_MGT-1 downto 0) of std_logic_vector(31 downto 0);
409  type mgt_data_out is array (N_MGT-1 downto 0) of std_logic_vector(227 downto 0);
410  type ram_data_in is array (N_MGT-1 downto 0) of std_logic_vector(227 downto 0);
411  -- define types to hold the fibre data
412 
414  type FibreColumnEm is array(NUM_FIB_Em_PHI-1 downto 0) of std_logic_vector(227 downto 0);
415 
417  type FibreAllEm is array(NUM_FIB_Em_ETA-1 downto 0) of FibreColumnEm;
418 
420  type FibreColumnHad is array(NUM_FIB_Had_PHI-1 downto 0) of std_logic_vector(227 downto 0);
421 
423  type FibreAllHad is array(NUM_FIB_Had_ETA-1 downto 0) of FibreColumnHad;
424 
426  type FibreAllSpare is array(NUM_FIB_SPARE-1 downto 0) of std_logic_vector(227 downto 0);
427 
428  subtype SuperCell is std_logic_vector(9 downto 0);
429 
430  type SuperCellData is array(19 downto 0) of SuperCell;
431  type SuperCells is record
432  Data : SuperCellData;
433  CRC : std_logic_vector(8 downto 0);
434  BCID : BCID_t;
435  Quality : std_logic_vector(7 downto 0);
436  end record;
437 
438 
439  function AlgoTowerBuilder
440  (
441  EmDataIn : FibreAllEm;
442  HadDataIn : FibreAllHad;
443  SpareDataIn : FibreAllSpare;
444  eFEXPosition : std_logic_vector(31 downto 0)
445  )
446  return Algoinput;
447 
448  function MGT_to_SuperCells (MGT : std_logic_vector(227 downto 0)) return SuperCells;
449 
450  function to_raw_data(em : FibreAllEm; had : FibreAllHad) return RAW_data_227_type;
451 
452 
453  -- Inputs:
454  -- Outputs: procedure FibreArrayBuilder (
455  signal fpga_number : in integer;
456  signal MGT_DATA : in mgt_data_out;
457  signal EmData : out FibreAllEm;
458  signal HadData : out FibreAllHad;
459  signal SpareData : out FibreAllSpare
460  );
461 
462  function ReadoutMGTEnable (fpga_number : integer; mgt_enable_in : std_logic_vector(63 downto 0)) return std_logic_vector;
463 
464  function f_efex_position (fpga_number : integer; efex_position : integer) return std_logic_vector;
465 
466 end EfexDataFormats;
467 
469 package body EfexDataFormats is
470 
475  function MGT_to_SuperCells (MGT : std_logic_vector(227 downto 0)) return SuperCells is
476  variable SC : SuperCells;
477  begin
478  SC.Quality := MGT(7 downto 0);
479  SC.CRC := MGT(223 downto 215);
480 
481  if MGT(226) = '1' then -- alignment frame flag
482  SC.BCID := MGT(198 downto 192);
483  -- the whole BCID could be retrieved if MGT(226) = '1' MGT(203 downto 192)
484  else
485  SC.BCID := MGT(9 downto 8) & MGT(31 downto 30) & MGT(214 downto 212);
486  end if;
487 
488  if MGT(227 downto 224) = "0000" then -- if no error and no alignment frame
489  SC.Data(0) := MGT(19 downto 10);
490  SC.Data(1) := MGT(29 downto 20);
491 
492  SC.Data(2) := MGT(41 downto 32);
493  SC.Data(3) := MGT(51 downto 42);
494  SC.Data(4) := MGT(61 downto 52);
495 
496  SC.Data(5) := MGT(73 downto 64);
497  SC.Data(6) := MGT(83 downto 74);
498  SC.Data(7) := MGT(93 downto 84);
499 
500  SC.Data(8) := MGT(105 downto 96);
501  SC.Data(9) := MGT(115 downto 106);
502  SC.Data(10) := MGT(125 downto 116);
503 
504  SC.Data(11) := MGT(137 downto 128);
505  SC.Data(12) := MGT(147 downto 138);
506  SC.Data(13) := MGT(157 downto 148);
507 
508  SC.Data(14) := MGT(169 downto 160);
509  SC.Data(15) := MGT(179 downto 170);
510  SC.Data(16) := MGT(189 downto 180);
511 
512  SC.Data(17) := MGT(201 downto 192);
513  SC.Data(18) := MGT(211 downto 202);
514 
515  SC.Data(19) := MGT(63 downto 62)&MGT(95 downto 94)&MGT(127 downto 126)&MGT(159 downto 158)&MGT(191 downto 190);
516  else
517  SC.Data := (others => (others => '0'));
518  end if;
519 
520  return SC;
521  end;
522 
550  function AlgoTowerBuilder
551  (
552  EmDataIn : FibreAllEm;
553  HadDataIn : FibreAllHad;
554  SpareDataIn : FibreAllSpare;
555  eFEXPosition : std_logic_vector(31 downto 0)
556  )
557  return Algoinput is
558 
559  variable AlgoData : AlgoInput;
560  variable Position_on_eta_edge : std_logic;
561  variable Position_on_eta_left_edge : std_logic;
562  variable Position_positive_eta_left : std_logic;
563  variable Position_positive_eta_right : std_logic;
564  variable Position_positive_eta_centre : std_logic;
565  variable Position_hadronic : std_logic_vector(2 downto 0); --! 0 Centre, 1 Near negative eta, 2 Near positive Eta, 3 Far negative eta, 4 Far positive eta
566 
567 
568 
569  begin
570 
571  if eFEXPosition(EM_POSITION_ETA_ON_EDGE) = '1' then
572  Position_on_eta_edge := '1';
573  if eFEXPosition(EM_POSITION_ETA_ON_LEFT_EDGE) = '1' then
574  Position_on_eta_left_edge := '1';
575  else
576  Position_on_eta_left_edge := '0';
577  end if;
578  else
579  Position_on_eta_edge := '0';
580  Position_on_eta_left_edge := '0';
581  end if;
582 
583  Position_positive_eta_left := eFEXPosition(EM_POSITION_POSITIVE_ETA_LEFT);
584  Position_positive_eta_centre := eFEXPosition(EM_POSITION_POSITIVE_ETA_CENTRE);
585  Position_positive_eta_right := eFEXPosition(EM_POSITION_POSITIVE_ETA_RIGHT);
586  Position_hadronic := eFEXPosition(HADRONIC_POSITION_BIT_END downto HADRONIC_POSITION_BIT_START);
587 
588 
589  --ECal (2 TTs per MGT)
590  for phi in 0 to NUM_FIB_Em_PHI-1 loop
591  -- Eta = 0
592  if Position_positive_eta_left = '1' then
593  AlgoData(0)(phi).Layer0(0) := MGT_to_SuperCells(EmDataIn(0)(phi)).Data(14);
594  for i in 0 to 3 loop
595  AlgoData(0)(phi).Layer1(i) := MGT_to_SuperCells(EmDataIn(0)(phi)).Data(i + 15);
596  AlgoData(0)(phi).Layer2(i) := MGT_to_SuperCells(EmDataIn(0)(phi)).Data(i + 4);
597  end loop;
598  AlgoData(0)(phi).Layer3(0) := MGT_to_SuperCells(EmDataIn(0)(phi)).Data(19);
599  else
600  AlgoData(0)(phi).Layer0(0) := MGT_to_SuperCells(EmDataIn(0)(phi)).Data(8);
601  for i in 0 to 3 loop
602  AlgoData(0)(phi).Layer1(i) := MGT_to_SuperCells(EmDataIn(0)(phi)).Data(i + 9);
603  AlgoData(0)(phi).Layer2(i) := MGT_to_SuperCells(EmDataIn(0)(phi)).Data(i + 0);
604  end loop;
605  AlgoData(0)(phi).Layer3(0) := MGT_to_SuperCells(EmDataIn(0)(phi)).Data(13);
606  end if;
607 
608  -- Eta = 1,2,3,4 or 4,3,2,1
609  if Position_positive_eta_centre = '1' then
610  AlgoData(1)(phi).Layer0(0) := MGT_to_SuperCells(EmDataIn(1)(phi)).Data(8);
611  AlgoData(2)(phi).Layer0(0) := MGT_to_SuperCells(EmDataIn(1)(phi)).Data(14);
612  AlgoData(3)(phi).Layer0(0) := MGT_to_SuperCells(EmDataIn(2)(phi)).Data(8);
613  AlgoData(4)(phi).Layer0(0) := MGT_to_SuperCells(EmDataIn(2)(phi)).Data(14);
614 
615  for i in 0 to 3 loop
616  AlgoData(1)(phi).Layer1(i) := MGT_to_SuperCells(EmDataIn(1)(phi)).Data(i + 9);
617  AlgoData(1)(phi).Layer2(i) := MGT_to_SuperCells(EmDataIn(1)(phi)).Data(i + 0);
618  AlgoData(2)(phi).Layer1(i) := MGT_to_SuperCells(EmDataIn(1)(phi)).Data(i + 15);
619  AlgoData(2)(phi).Layer2(i) := MGT_to_SuperCells(EmDataIn(1)(phi)).Data(i + 4);
620  AlgoData(3)(phi).Layer1(i) := MGT_to_SuperCells(EmDataIn(2)(phi)).Data(i + 9);
621  AlgoData(3)(phi).Layer2(i) := MGT_to_SuperCells(EmDataIn(2)(phi)).Data(i + 0);
622  AlgoData(4)(phi).Layer1(i) := MGT_to_SuperCells(EmDataIn(2)(phi)).Data(i + 15);
623  AlgoData(4)(phi).Layer2(i) := MGT_to_SuperCells(EmDataIn(2)(phi)).Data(i + 4);
624  end loop;
625  AlgoData(1)(phi).Layer3(0) := MGT_to_SuperCells(EmDataIn(1)(phi)).Data(13);
626  AlgoData(2)(phi).Layer3(0) := MGT_to_SuperCells(EmDataIn(1)(phi)).Data(19);
627  AlgoData(3)(phi).Layer3(0) := MGT_to_SuperCells(EmDataIn(2)(phi)).Data(13);
628  AlgoData(4)(phi).Layer3(0) := MGT_to_SuperCells(EmDataIn(2)(phi)).Data(19);
629 
630  else
631  AlgoData(1)(phi).Layer0(0) := MGT_to_SuperCells(EmDataIn(1)(phi)).Data(14);
632  AlgoData(2)(phi).Layer0(0) := MGT_to_SuperCells(EmDataIn(1)(phi)).Data(8);
633  AlgoData(3)(phi).Layer0(0) := MGT_to_SuperCells(EmDataIn(2)(phi)).Data(14);
634  AlgoData(4)(phi).Layer0(0) := MGT_to_SuperCells(EmDataIn(2)(phi)).Data(8);
635 
636  for i in 0 to 3 loop
637  AlgoData(1)(phi).Layer1(i) := MGT_to_SuperCells(EmDataIn(1)(phi)).Data(i + 15);
638  AlgoData(1)(phi).Layer2(i) := MGT_to_SuperCells(EmDataIn(1)(phi)).Data(i + 4);
639  AlgoData(2)(phi).Layer1(i) := MGT_to_SuperCells(EmDataIn(1)(phi)).Data(i + 9);
640  AlgoData(2)(phi).Layer2(i) := MGT_to_SuperCells(EmDataIn(1)(phi)).Data(i + 0);
641  AlgoData(3)(phi).Layer1(i) := MGT_to_SuperCells(EmDataIn(2)(phi)).Data(i + 15);
642  AlgoData(3)(phi).Layer2(i) := MGT_to_SuperCells(EmDataIn(2)(phi)).Data(i + 4);
643  AlgoData(4)(phi).Layer1(i) := MGT_to_SuperCells(EmDataIn(2)(phi)).Data(i + 9);
644  AlgoData(4)(phi).Layer2(i) := MGT_to_SuperCells(EmDataIn(2)(phi)).Data(i + 0);
645  end loop;
646  AlgoData(1)(phi).Layer3(0) := MGT_to_SuperCells(EmDataIn(1)(phi)).Data(19);
647  AlgoData(2)(phi).Layer3(0) := MGT_to_SuperCells(EmDataIn(1)(phi)).Data(13);
648  AlgoData(3)(phi).Layer3(0) := MGT_to_SuperCells(EmDataIn(2)(phi)).Data(19);
649  AlgoData(4)(phi).Layer3(0) := MGT_to_SuperCells(EmDataIn(2)(phi)).Data(13);
650  end if;
651 
652  -- Eta = 5
653  if Position_positive_eta_right = '1' then
654  AlgoData(5)(phi).Layer0(0) := MGT_to_SuperCells(EmDataIn(3)(phi)).Data(8);
655  for i in 0 to 3 loop
656  AlgoData(5)(phi).Layer1(i) := MGT_to_SuperCells(EmDataIn(3)(phi)).Data(i + 9);
657  AlgoData(5)(phi).Layer2(i) := MGT_to_SuperCells(EmDataIn(3)(phi)).Data(i + 0);
658  end loop;
659  AlgoData(5)(phi).Layer3(0) := MGT_to_SuperCells(EmDataIn(3)(phi)).Data(13);
660  else
661  AlgoData(5)(phi).Layer0(0) := MGT_to_SuperCells(EmDataIn(3)(phi)).Data(14);
662  for i in 0 to 3 loop
663  AlgoData(5)(phi).Layer1(i) := MGT_to_SuperCells(EmDataIn(3)(phi)).Data(i + 15);
664  AlgoData(5)(phi).Layer2(i) := MGT_to_SuperCells(EmDataIn(3)(phi)).Data(i + 4);
665  end loop;
666  AlgoData(5)(phi).Layer3(0) := MGT_to_SuperCells(EmDataIn(3)(phi)).Data(19);
667  end if;
668  end loop;
669 
670  -- Replace AlgoData(0) or AlgoData(5) in case f eFEX on edge
671  if Position_on_eta_edge = '1' and Position_on_eta_left_edge = '1' then
672  AlgoData(0)(0).Layer0(0) := MGT_to_SuperCells(EmDataIn(0)(0)).Data(18);
673  AlgoData(0)(1).Layer0(0) := MGT_to_SuperCells(EmDataIn(0)(1)).Data(12);
674  AlgoData(0)(2).Layer0(0) := MGT_to_SuperCells(EmDataIn(0)(1)).Data(18);
675  AlgoData(0)(3).Layer0(0) := MGT_to_SuperCells(EmDataIn(0)(2)).Data(12);
676  AlgoData(0)(4).Layer0(0) := MGT_to_SuperCells(EmDataIn(0)(2)).Data(18);
677  AlgoData(0)(5).Layer0(0) := MGT_to_SuperCells(EmDataIn(0)(3)).Data(12);
678  AlgoData(0)(6).Layer0(0) := MGT_to_SuperCells(EmDataIn(0)(3)).Data(18);
679  AlgoData(0)(7).Layer0(0) := MGT_to_SuperCells(EmDataIn(0)(4)).Data(12);
680  AlgoData(0)(8).Layer0(0) := MGT_to_SuperCells(EmDataIn(0)(4)).Data(18);
681  AlgoData(0)(9).Layer0(0) := MGT_to_SuperCells(EmDataIn(0)(5)).Data(12);
682  for i in 0 to 9 loop
683  AlgoData(0)(i).Layer1 := (others => (others => '0'));
684  end loop;
685 
686  for i in 0 to 3 loop
687  AlgoData(0)(0).Layer2(i) := MGT_to_SuperCells(EmDataIn(0)(0)).Data(i + 4);
688  AlgoData(0)(1).Layer2(i) := MGT_to_SuperCells(EmDataIn(0)(1)).Data(i);
689  AlgoData(0)(2).Layer2(i) := MGT_to_SuperCells(EmDataIn(0)(1)).Data(i + 4);
690  AlgoData(0)(3).Layer2(i) := MGT_to_SuperCells(EmDataIn(0)(2)).Data(i);
691  AlgoData(0)(4).Layer2(i) := MGT_to_SuperCells(EmDataIn(0)(2)).Data(i + 4);
692  AlgoData(0)(5).Layer2(i) := MGT_to_SuperCells(EmDataIn(0)(3)).Data(i);
693  AlgoData(0)(6).Layer2(i) := MGT_to_SuperCells(EmDataIn(0)(3)).Data(i + 4);
694  AlgoData(0)(7).Layer2(i) := MGT_to_SuperCells(EmDataIn(0)(4)).Data(i);
695  AlgoData(0)(8).Layer2(i) := MGT_to_SuperCells(EmDataIn(0)(4)).Data(i + 4);
696  AlgoData(0)(9).Layer2(i) := MGT_to_SuperCells(EmDataIn(0)(5)).Data(i);
697  end loop;
698 
699  AlgoData(0)(0).Layer3(0) := MGT_to_SuperCells(EmDataIn(0)(0)).Data(19);
700  AlgoData(0)(1).Layer3(0) := MGT_to_SuperCells(EmDataIn(0)(1)).Data(13);
701  AlgoData(0)(2).Layer3(0) := MGT_to_SuperCells(EmDataIn(0)(1)).Data(19);
702  AlgoData(0)(3).Layer3(0) := MGT_to_SuperCells(EmDataIn(0)(2)).Data(13);
703  AlgoData(0)(4).Layer3(0) := MGT_to_SuperCells(EmDataIn(0)(2)).Data(19);
704  AlgoData(0)(5).Layer3(0) := MGT_to_SuperCells(EmDataIn(0)(3)).Data(13);
705  AlgoData(0)(6).Layer3(0) := MGT_to_SuperCells(EmDataIn(0)(3)).Data(19);
706  AlgoData(0)(7).Layer3(0) := MGT_to_SuperCells(EmDataIn(0)(4)).Data(13);
707  AlgoData(0)(8).Layer3(0) := MGT_to_SuperCells(EmDataIn(0)(4)).Data(19);
708  AlgoData(0)(9).Layer3(0) := MGT_to_SuperCells(EmDataIn(0)(5)).Data(13);
709 
710  elsif Position_on_eta_edge = '1' and Position_on_eta_left_edge = '0' then
711 
712  AlgoData(5)(0).Layer0(0) := MGT_to_SuperCells(EmDataIn(3)(0)).Data(18);
713  AlgoData(5)(1).Layer0(0) := MGT_to_SuperCells(EmDataIn(3)(1)).Data(12);
714  AlgoData(5)(2).Layer0(0) := MGT_to_SuperCells(EmDataIn(3)(1)).Data(18);
715  AlgoData(5)(3).Layer0(0) := MGT_to_SuperCells(EmDataIn(3)(2)).Data(12);
716  AlgoData(5)(4).Layer0(0) := MGT_to_SuperCells(EmDataIn(3)(2)).Data(18);
717  AlgoData(5)(5).Layer0(0) := MGT_to_SuperCells(EmDataIn(3)(3)).Data(12);
718  AlgoData(5)(6).Layer0(0) := MGT_to_SuperCells(EmDataIn(3)(3)).Data(18);
719  AlgoData(5)(7).Layer0(0) := MGT_to_SuperCells(EmDataIn(3)(4)).Data(12);
720  AlgoData(5)(8).Layer0(0) := MGT_to_SuperCells(EmDataIn(3)(4)).Data(18);
721  AlgoData(5)(9).Layer0(0) := MGT_to_SuperCells(EmDataIn(3)(5)).Data(12);
722  for i in 0 to 9 loop
723  AlgoData(5)(i).Layer1 := (others => (others => '0'));
724  end loop;
725 
726  for i in 0 to 3 loop
727  AlgoData(5)(0).Layer2(i) := MGT_to_SuperCells(EmDataIn(3)(0)).Data(i + 4);
728  AlgoData(5)(1).Layer2(i) := MGT_to_SuperCells(EmDataIn(3)(1)).Data(i);
729  AlgoData(5)(2).Layer2(i) := MGT_to_SuperCells(EmDataIn(3)(1)).Data(i + 4);
730  AlgoData(5)(3).Layer2(i) := MGT_to_SuperCells(EmDataIn(3)(2)).Data(i);
731  AlgoData(5)(4).Layer2(i) := MGT_to_SuperCells(EmDataIn(3)(2)).Data(i + 4);
732  AlgoData(5)(5).Layer2(i) := MGT_to_SuperCells(EmDataIn(3)(3)).Data(i);
733  AlgoData(5)(6).Layer2(i) := MGT_to_SuperCells(EmDataIn(3)(3)).Data(i + 4);
734  AlgoData(5)(7).Layer2(i) := MGT_to_SuperCells(EmDataIn(3)(4)).Data(i);
735  AlgoData(5)(8).Layer2(i) := MGT_to_SuperCells(EmDataIn(3)(4)).Data(i + 4);
736  AlgoData(5)(9).Layer2(i) := MGT_to_SuperCells(EmDataIn(3)(5)).Data(i);
737  end loop;
738 
739  AlgoData(5)(0).Layer3(0) := MGT_to_SuperCells(EmDataIn(3)(0)).Data(19);
740  AlgoData(5)(1).Layer3(0) := MGT_to_SuperCells(EmDataIn(3)(1)).Data(13);
741  AlgoData(5)(2).Layer3(0) := MGT_to_SuperCells(EmDataIn(3)(1)).Data(19);
742  AlgoData(5)(3).Layer3(0) := MGT_to_SuperCells(EmDataIn(3)(2)).Data(13);
743  AlgoData(5)(4).Layer3(0) := MGT_to_SuperCells(EmDataIn(3)(2)).Data(19);
744  AlgoData(5)(5).Layer3(0) := MGT_to_SuperCells(EmDataIn(3)(3)).Data(13);
745  AlgoData(5)(6).Layer3(0) := MGT_to_SuperCells(EmDataIn(3)(3)).Data(19);
746  AlgoData(5)(7).Layer3(0) := MGT_to_SuperCells(EmDataIn(3)(4)).Data(13);
747  AlgoData(5)(8).Layer3(0) := MGT_to_SuperCells(EmDataIn(3)(4)).Data(19);
748  AlgoData(5)(9).Layer3(0) := MGT_to_SuperCells(EmDataIn(3)(5)).Data(13);
749  end if;
750 
751 
752  --Hadron (16 TTs per MGT of which 9 are used)
753  --Position_hadronic = 0 Centre, 1 Near negative eta, 2 Near positive Eta, 3 Far negative eta, 4 Far positive eta
754 
755  -- Hadronic centre
756  if Position_hadronic = "000" then
757  -- Eta = 0
758  AlgoData(0)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(0)).Data(07);
759  AlgoData(0)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(0)).Data(10);
760  AlgoData(0)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(0)).Data(11);
761  AlgoData(0)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(06);
762  AlgoData(0)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(07);
763  AlgoData(0)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(10);
764  AlgoData(0)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(11);
765  AlgoData(0)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(2)).Data(06);
766  AlgoData(0)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(2)).Data(07);
767  AlgoData(0)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(2)).Data(10);
768 
769  -- Eta = 1
770  AlgoData(1)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(01);
771  AlgoData(1)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(12);
772  AlgoData(1)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(13);
773  AlgoData(1)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(00);
774  AlgoData(1)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(01);
775  AlgoData(1)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(12);
776  AlgoData(1)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(13);
777  AlgoData(1)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(00);
778  AlgoData(1)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(01);
779  AlgoData(1)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(12);
780 
781  -- Eta = 2
782  AlgoData(2)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(03);
783  AlgoData(2)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(14);
784  AlgoData(2)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(15);
785  AlgoData(2)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(02);
786  AlgoData(2)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(03);
787  AlgoData(2)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(14);
788  AlgoData(2)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(15);
789  AlgoData(2)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(02);
790  AlgoData(2)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(03);
791  AlgoData(2)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(14);
792 
793  -- Eta = 3
794  AlgoData(3)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(05);
795  AlgoData(3)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(08);
796  AlgoData(3)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(09);
797  AlgoData(3)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(04);
798  AlgoData(3)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(05);
799  AlgoData(3)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(08);
800  AlgoData(3)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(09);
801  AlgoData(3)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(04);
802  AlgoData(3)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(05);
803  AlgoData(3)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(08);
804 
805  -- Eta = 4
806  AlgoData(4)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(07);
807  AlgoData(4)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(10);
808  AlgoData(4)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(11);
809  AlgoData(4)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(06);
810  AlgoData(4)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(07);
811  AlgoData(4)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(10);
812  AlgoData(4)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(11);
813  AlgoData(4)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(06);
814  AlgoData(4)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(07);
815  AlgoData(4)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(10);
816 
817  -- Eta = 5
818  AlgoData(5)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(0)).Data(01);
819  AlgoData(5)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(0)).Data(12);
820  AlgoData(5)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(0)).Data(13);
821  AlgoData(5)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(00);
822  AlgoData(5)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(01);
823  AlgoData(5)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(12);
824  AlgoData(5)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(13);
825  AlgoData(5)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(2)).Data(00);
826  AlgoData(5)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(2)).Data(01);
827  AlgoData(5)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(2)).Data(12);
828  end if;
829 
830  -- Hadronic near negative
831  if Position_hadronic = "001" then
832  -- Eta = 0
833  AlgoData(0)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(0)).Data(05);
834  AlgoData(0)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(0)).Data(09);
835  AlgoData(0)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(0)).Data(13);
836  AlgoData(0)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(01);
837  AlgoData(0)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(05);
838  AlgoData(0)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(09);
839  AlgoData(0)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(13);
840  AlgoData(0)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(2)).Data(01);
841  AlgoData(0)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(2)).Data(05);
842  AlgoData(0)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(2)).Data(09);
843 
844  -- Eta = 1
845  AlgoData(1)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(0)).Data(04);
846  AlgoData(1)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(0)).Data(08);
847  AlgoData(1)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(0)).Data(12);
848  AlgoData(1)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(00);
849  AlgoData(1)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(04);
850  AlgoData(1)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(08);
851  AlgoData(1)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(12);
852  AlgoData(1)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(2)).Data(00);
853  AlgoData(1)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(2)).Data(04);
854  AlgoData(1)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(2)).Data(08);
855 
856  -- Eta = 2
857  AlgoData(2)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(03);
858  AlgoData(2)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(14);
859  AlgoData(2)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(15);
860  AlgoData(2)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(02);
861  AlgoData(2)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(03);
862  AlgoData(2)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(14);
863  AlgoData(2)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(15);
864  AlgoData(2)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(02);
865  AlgoData(2)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(03);
866  AlgoData(2)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(14);
867 
868  -- Eta = 3
869  AlgoData(3)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(05);
870  AlgoData(3)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(08);
871  AlgoData(3)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(09);
872  AlgoData(3)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(04);
873  AlgoData(3)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(05);
874  AlgoData(3)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(08);
875  AlgoData(3)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(09);
876  AlgoData(3)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(04);
877  AlgoData(3)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(05);
878  AlgoData(3)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(08);
879 
880  -- Eta = 4
881  AlgoData(4)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(07);
882  AlgoData(4)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(10);
883  AlgoData(4)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(11);
884  AlgoData(4)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(06);
885  AlgoData(4)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(07);
886  AlgoData(4)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(10);
887  AlgoData(4)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(11);
888  AlgoData(4)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(06);
889  AlgoData(4)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(07);
890  AlgoData(4)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(10);
891 
892  -- Eta = 5
893  AlgoData(5)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(0)).Data(01);
894  AlgoData(5)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(0)).Data(12);
895  AlgoData(5)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(0)).Data(13);
896  AlgoData(5)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(00);
897  AlgoData(5)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(01);
898  AlgoData(5)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(12);
899  AlgoData(5)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(13);
900  AlgoData(5)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(2)).Data(00);
901  AlgoData(5)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(2)).Data(01);
902  AlgoData(5)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(2)).Data(12);
903  end if;
904 
905  --Hadronic near positive
906  if Position_hadronic = "010" then
907  -- Eta = 0
908  AlgoData(0)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(0)).Data(07);
909  AlgoData(0)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(0)).Data(10);
910  AlgoData(0)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(0)).Data(11);
911  AlgoData(0)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(06);
912  AlgoData(0)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(07);
913  AlgoData(0)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(10);
914  AlgoData(0)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(11);
915  AlgoData(0)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(2)).Data(06);
916  AlgoData(0)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(2)).Data(07);
917  AlgoData(0)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(2)).Data(10);
918 
919  -- Eta = 1
920  AlgoData(1)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(01);
921  AlgoData(1)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(12);
922  AlgoData(1)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(13);
923  AlgoData(1)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(00);
924  AlgoData(1)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(01);
925  AlgoData(1)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(12);
926  AlgoData(1)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(13);
927  AlgoData(1)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(00);
928  AlgoData(1)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(01);
929  AlgoData(1)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(12);
930 
931  -- Eta = 2
932  AlgoData(2)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(03);
933  AlgoData(2)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(14);
934  AlgoData(2)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(15);
935  AlgoData(2)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(02);
936  AlgoData(2)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(03);
937  AlgoData(2)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(14);
938  AlgoData(2)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(15);
939  AlgoData(2)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(02);
940  AlgoData(2)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(03);
941  AlgoData(2)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(14);
942 
943  -- Eta = 3
944  AlgoData(3)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(05);
945  AlgoData(3)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(08);
946  AlgoData(3)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(09);
947  AlgoData(3)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(04);
948  AlgoData(3)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(05);
949  AlgoData(3)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(08);
950  AlgoData(3)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(09);
951  AlgoData(3)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(04);
952  AlgoData(3)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(05);
953  AlgoData(3)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(08);
954 
955  -- Eta = 4
956  AlgoData(4)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(0)).Data(04);
957  AlgoData(4)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(0)).Data(08);
958  AlgoData(4)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(0)).Data(12);
959  AlgoData(4)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(00);
960  AlgoData(4)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(04);
961  AlgoData(4)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(08);
962  AlgoData(4)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(12);
963  AlgoData(4)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(2)).Data(00);
964  AlgoData(4)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(2)).Data(04);
965  AlgoData(4)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(2)).Data(08);
966 
967  -- Eta = 5
968  AlgoData(5)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(0)).Data(05);
969  AlgoData(5)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(0)).Data(09);
970  AlgoData(5)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(0)).Data(13);
971  AlgoData(5)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(01);
972  AlgoData(5)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(05);
973  AlgoData(5)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(09);
974  AlgoData(5)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(13);
975  AlgoData(5)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(2)).Data(01);
976  AlgoData(5)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(2)).Data(05);
977  AlgoData(5)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(2)).Data(09);
978  end if;
979 
980  -- Hadronic far negative
981  if Position_hadronic = "011" then
982  -- Eta = 0
983  AlgoData(0)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(0)).Data(05);
984  AlgoData(0)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(0)).Data(09);
985  AlgoData(0)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(0)).Data(13);
986  AlgoData(0)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(01);
987  AlgoData(0)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(05);
988  AlgoData(0)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(09);
989  AlgoData(0)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(13);
990  AlgoData(0)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(2)).Data(01);
991  AlgoData(0)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(2)).Data(05);
992  AlgoData(0)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(2)).Data(09);
993 
994  -- Eta = 1
995  AlgoData(1)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(0)).Data(04);
996  AlgoData(1)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(0)).Data(08);
997  AlgoData(1)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(0)).Data(12);
998  AlgoData(1)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(00);
999  AlgoData(1)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(04);
1000  AlgoData(1)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(08);
1001  AlgoData(1)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(1)).Data(12);
1002  AlgoData(1)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(2)).Data(00);
1003  AlgoData(1)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(2)).Data(04);
1004  AlgoData(1)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(0)(2)).Data(08);
1005 
1006  -- Eta = 2
1007  AlgoData(2)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(07);
1008  AlgoData(2)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(11);
1009  AlgoData(2)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(15);
1010  AlgoData(2)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(03);
1011  AlgoData(2)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(07);
1012  AlgoData(2)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(11);
1013  AlgoData(2)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(15);
1014  AlgoData(2)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(03);
1015  AlgoData(2)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(07);
1016  AlgoData(2)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(11);
1017 
1018  -- Eta = 3
1019  AlgoData(3)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(06);
1020  AlgoData(3)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(10);
1021  AlgoData(3)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(14);
1022  AlgoData(3)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(02);
1023  AlgoData(3)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(06);
1024  AlgoData(3)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(10);
1025  AlgoData(3)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(14);
1026  AlgoData(3)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(02);
1027  AlgoData(3)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(06);
1028  AlgoData(3)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(10);
1029 
1030  -- Eta = 4
1031  AlgoData(4)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(05);
1032  AlgoData(4)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(09);
1033  AlgoData(4)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(13);
1034  AlgoData(4)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(01);
1035  AlgoData(4)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(05);
1036  AlgoData(4)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(09);
1037  AlgoData(4)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(13);
1038  AlgoData(4)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(01);
1039  AlgoData(4)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(05);
1040  AlgoData(4)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(09);
1041 
1042  -- Eta = 5
1043  AlgoData(5)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(04);
1044  AlgoData(5)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(08);
1045  AlgoData(5)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(12);
1046  AlgoData(5)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(00);
1047  AlgoData(5)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(04);
1048  AlgoData(5)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(08);
1049  AlgoData(5)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(12);
1050  AlgoData(5)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(00);
1051  AlgoData(5)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(04);
1052  AlgoData(5)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(08);
1053  end if;
1054 
1055  -- Hadronic far positive
1056  if Position_hadronic = "100" then
1057  -- Eta = 0
1058  AlgoData(0)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(04);
1059  AlgoData(0)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(08);
1060  AlgoData(0)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(12);
1061  AlgoData(0)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(00);
1062  AlgoData(0)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(04);
1063  AlgoData(0)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(08);
1064  AlgoData(0)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(12);
1065  AlgoData(0)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(00);
1066  AlgoData(0)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(04);
1067  AlgoData(0)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(08);
1068 
1069  -- Eta = 1
1070  AlgoData(1)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(05);
1071  AlgoData(1)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(09);
1072  AlgoData(1)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(13);
1073  AlgoData(1)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(01);
1074  AlgoData(1)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(05);
1075  AlgoData(1)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(09);
1076  AlgoData(1)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(13);
1077  AlgoData(1)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(01);
1078  AlgoData(1)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(05);
1079  AlgoData(1)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(09);
1080 
1081  -- Eta = 2
1082  AlgoData(2)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(06);
1083  AlgoData(2)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(10);
1084  AlgoData(2)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(14);
1085  AlgoData(2)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(02);
1086  AlgoData(2)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(06);
1087  AlgoData(2)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(10);
1088  AlgoData(2)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(14);
1089  AlgoData(2)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(02);
1090  AlgoData(2)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(06);
1091  AlgoData(2)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(10);
1092 
1093  -- Eta = 3
1094  AlgoData(3)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(07);
1095  AlgoData(3)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(11);
1096  AlgoData(3)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(0)).Data(15);
1097  AlgoData(3)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(03);
1098  AlgoData(3)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(07);
1099  AlgoData(3)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(11);
1100  AlgoData(3)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(1)).Data(15);
1101  AlgoData(3)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(03);
1102  AlgoData(3)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(07);
1103  AlgoData(3)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(1)(2)).Data(11);
1104 
1105  -- Eta = 4
1106  AlgoData(4)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(0)).Data(04);
1107  AlgoData(4)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(0)).Data(08);
1108  AlgoData(4)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(0)).Data(12);
1109  AlgoData(4)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(00);
1110  AlgoData(4)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(04);
1111  AlgoData(4)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(08);
1112  AlgoData(4)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(12);
1113  AlgoData(4)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(2)).Data(00);
1114  AlgoData(4)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(2)).Data(04);
1115  AlgoData(4)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(2)).Data(08);
1116 
1117  -- Eta = 5
1118  AlgoData(5)(0).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(0)).Data(05);
1119  AlgoData(5)(1).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(0)).Data(09);
1120  AlgoData(5)(2).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(0)).Data(13);
1121  AlgoData(5)(3).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(01);
1122  AlgoData(5)(4).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(05);
1123  AlgoData(5)(5).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(09);
1124  AlgoData(5)(6).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(1)).Data(13);
1125  AlgoData(5)(7).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(2)).Data(01);
1126  AlgoData(5)(8).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(2)).Data(05);
1127  AlgoData(5)(9).Hadron(0) := MGT_to_SuperCells(HadDataIn(2)(2)).Data(09);
1128  end if;
1129 
1130  return AlgoData;
1131  end AlgoTowerBuilder;
1132 
1133 
1139  -- Inputs:
1140  -- Outputs: procedure FibreArrayBuilder
1141  (
1142  signal fpga_number : in integer;
1143  signal MGT_DATA : in mgt_data_out;
1144  signal EmData : out FibreAllEm;
1145  signal HadData : out FibreAllHad;
1146  signal SpareData : out FibreAllSpare
1147  ) is
1148  ----------
1149 
1150  variable EmData_int : FibreAllEm;
1151  variable HadData_int : FibreAllHad;
1152  variable SpareData_int : FibreAllSpare;
1153  begin
1154 
1155  if fpga_number = 1 then
1156  EmData_int := (
1157  (MGT_DATA(EN_EG1(00)), MGT_DATA(EN_EG1(01)), MGT_DATA(EN_EG1(02)), MGT_DATA(EN_EG1(03)), MGT_DATA(EN_EG1(04)), MGT_DATA(EN_EG1(05)), MGT_DATA(EN_EG1(06)), MGT_DATA(EN_EG1(07)), MGT_DATA(EN_EG1(08)), MGT_DATA(EN_EG1(09))),
1158  (MGT_DATA(EN_EG1(10)), MGT_DATA(EN_EG1(11)), MGT_DATA(EN_EG1(12)), MGT_DATA(EN_EG1(13)), MGT_DATA(EN_EG1(14)), MGT_DATA(EN_EG1(15)), MGT_DATA(EN_EG1(16)), MGT_DATA(EN_EG1(17)), MGT_DATA(EN_EG1(18)), MGT_DATA(EN_EG1(19))),
1159  (MGT_DATA(EN_EG1(20)), MGT_DATA(EN_EG1(21)), MGT_DATA(EN_EG1(22)), MGT_DATA(EN_EG1(23)), MGT_DATA(EN_EG1(24)), MGT_DATA(EN_EG1(25)), MGT_DATA(EN_EG1(26)), MGT_DATA(EN_EG1(27)), MGT_DATA(EN_EG1(28)), MGT_DATA(EN_EG1(29))),
1160  (MGT_DATA(EN_EG1(30)), MGT_DATA(EN_EG1(31)), MGT_DATA(EN_EG1(32)), MGT_DATA(EN_EG1(33)), MGT_DATA(EN_EG1(34)), MGT_DATA(EN_EG1(35)), MGT_DATA(EN_EG1(36)), MGT_DATA(EN_EG1(37)), MGT_DATA(EN_EG1(38)), MGT_DATA(EN_EG1(39)))
1161  );
1162  HadData_int := (
1163  (MGT_DATA(EN_HAD1(00)), MGT_DATA(EN_HAD1(01)), MGT_DATA(EN_HAD1(02)), MGT_DATA(EN_HAD1(03)), MGT_DATA(EN_HAD1(04)), MGT_DATA(EN_HAD1(05))),
1164  (MGT_DATA(EN_HAD1(06)), MGT_DATA(EN_HAD1(07)), MGT_DATA(EN_HAD1(08)), MGT_DATA(EN_HAD1(09)), MGT_DATA(EN_HAD1(10)), MGT_DATA(EN_HAD1(11))),
1165  (MGT_DATA(EN_HAD1(12)), MGT_DATA(EN_HAD1(13)), MGT_DATA(EN_HAD1(14)), MGT_DATA(EN_HAD1(15)), MGT_DATA(EN_HAD1(16)), MGT_DATA(EN_HAD1(17)))
1166  );
1167 
1168  SpareData_int := (others => (others => '0'));
1169 
1170  elsif fpga_number = 2 then
1171  EmData_int := (
1172  (MGT_DATA(EN_EG2(00)), MGT_DATA(EN_EG2(01)), MGT_DATA(EN_EG2(02)), MGT_DATA(EN_EG2(03)), MGT_DATA(EN_EG2(04)), MGT_DATA(EN_EG2(05)), MGT_DATA(EN_EG2(06)), MGT_DATA(EN_EG2(07)), MGT_DATA(EN_EG2(08)), MGT_DATA(EN_EG2(09))),
1173  (MGT_DATA(EN_EG2(10)), MGT_DATA(EN_EG2(11)), MGT_DATA(EN_EG2(12)), MGT_DATA(EN_EG2(13)), MGT_DATA(EN_EG2(14)), MGT_DATA(EN_EG2(15)), MGT_DATA(EN_EG2(16)), MGT_DATA(EN_EG2(17)), MGT_DATA(EN_EG2(18)), MGT_DATA(EN_EG2(19))),
1174  (MGT_DATA(EN_EG2(20)), MGT_DATA(EN_EG2(21)), MGT_DATA(EN_EG2(22)), MGT_DATA(EN_EG2(23)), MGT_DATA(EN_EG2(24)), MGT_DATA(EN_EG2(25)), MGT_DATA(EN_EG2(26)), MGT_DATA(EN_EG2(27)), MGT_DATA(EN_EG2(28)), MGT_DATA(EN_EG2(29))),
1175  (MGT_DATA(EN_EG2(30)), MGT_DATA(EN_EG2(31)), MGT_DATA(EN_EG2(32)), MGT_DATA(EN_EG2(33)), MGT_DATA(EN_EG2(34)), MGT_DATA(EN_EG2(35)), MGT_DATA(EN_EG2(36)), MGT_DATA(EN_EG2(37)), MGT_DATA(EN_EG2(38)), MGT_DATA(EN_EG2(39)))
1176  );
1177  HadData_int := (
1178  (MGT_DATA(EN_HAD2(00)), MGT_DATA(EN_HAD2(01)), MGT_DATA(EN_HAD2(02)), MGT_DATA(EN_HAD2(03)), MGT_DATA(EN_HAD2(04)), MGT_DATA(EN_HAD2(05))),
1179  (MGT_DATA(EN_HAD2(06)), MGT_DATA(EN_HAD2(07)), MGT_DATA(EN_HAD2(08)), MGT_DATA(EN_HAD2(09)), MGT_DATA(EN_HAD2(10)), MGT_DATA(EN_HAD2(11))),
1180  (MGT_DATA(EN_HAD2(12)), MGT_DATA(EN_HAD2(13)), MGT_DATA(EN_HAD2(14)), MGT_DATA(EN_HAD2(15)), MGT_DATA(EN_HAD2(16)), MGT_DATA(EN_HAD2(17)))
1181  );
1182  SpareData_int := (others => (others => '0'));
1183 
1184  elsif fpga_number = 3 then
1185  EmData_int := (
1186  (MGT_DATA(EN_EG3(00)), MGT_DATA(EN_EG3(01)), MGT_DATA(EN_EG3(02)), MGT_DATA(EN_EG3(03)), MGT_DATA(EN_EG3(04)), MGT_DATA(EN_EG3(05)), MGT_DATA(EN_EG3(06)), MGT_DATA(EN_EG3(07)), MGT_DATA(EN_EG3(08)), MGT_DATA(EN_EG3(09))),
1187  (MGT_DATA(EN_EG3(10)), MGT_DATA(EN_EG3(11)), MGT_DATA(EN_EG3(12)), MGT_DATA(EN_EG3(13)), MGT_DATA(EN_EG3(14)), MGT_DATA(EN_EG3(15)), MGT_DATA(EN_EG3(16)), MGT_DATA(EN_EG3(17)), MGT_DATA(EN_EG3(18)), MGT_DATA(EN_EG3(19))),
1188  (MGT_DATA(EN_EG3(20)), MGT_DATA(EN_EG3(21)), MGT_DATA(EN_EG3(22)), MGT_DATA(EN_EG3(23)), MGT_DATA(EN_EG3(24)), MGT_DATA(EN_EG3(25)), MGT_DATA(EN_EG3(26)), MGT_DATA(EN_EG3(27)), MGT_DATA(EN_EG3(28)), MGT_DATA(EN_EG3(29))),
1189  (MGT_DATA(EN_EG3(30)), MGT_DATA(EN_EG3(31)), MGT_DATA(EN_EG3(32)), MGT_DATA(EN_EG3(33)), MGT_DATA(EN_EG3(34)), MGT_DATA(EN_EG3(35)), MGT_DATA(EN_EG3(36)), MGT_DATA(EN_EG3(37)), MGT_DATA(EN_EG3(38)), MGT_DATA(EN_EG3(39)))
1190  );
1191  HadData_int := (
1192  (MGT_DATA(EN_HAD3(00)), MGT_DATA(EN_HAD3(01)), MGT_DATA(EN_HAD3(02)), MGT_DATA(EN_HAD3(03)), MGT_DATA(EN_HAD3(04)), MGT_DATA(EN_HAD3(05))),
1193  (MGT_DATA(EN_HAD3(06)), MGT_DATA(EN_HAD3(07)), MGT_DATA(EN_HAD3(08)), MGT_DATA(EN_HAD3(09)), MGT_DATA(EN_HAD3(10)), MGT_DATA(EN_HAD3(11))),
1194  (MGT_DATA(EN_HAD3(12)), MGT_DATA(EN_HAD3(13)), MGT_DATA(EN_HAD3(14)), MGT_DATA(EN_HAD3(15)), MGT_DATA(EN_HAD3(16)), MGT_DATA(EN_HAD3(17)))
1195  );
1196  SpareData_int := (others => (others => '0'));
1197 
1198  elsif fpga_number = 4 then
1199  EmData_int := (
1200  (MGT_DATA(EN_EG4(00)), MGT_DATA(EN_EG4(01)), MGT_DATA(EN_EG4(02)), MGT_DATA(EN_EG4(03)), MGT_DATA(EN_EG4(04)), MGT_DATA(EN_EG4(05)), MGT_DATA(EN_EG4(06)), MGT_DATA(EN_EG4(07)), MGT_DATA(EN_EG4(08)), MGT_DATA(EN_EG4(09))),
1201  (MGT_DATA(EN_EG4(10)), MGT_DATA(EN_EG4(11)), MGT_DATA(EN_EG4(12)), MGT_DATA(EN_EG4(13)), MGT_DATA(EN_EG4(14)), MGT_DATA(EN_EG4(15)), MGT_DATA(EN_EG4(16)), MGT_DATA(EN_EG4(17)), MGT_DATA(EN_EG4(18)), MGT_DATA(EN_EG4(19))),
1202  (MGT_DATA(EN_EG4(20)), MGT_DATA(EN_EG4(21)), MGT_DATA(EN_EG4(22)), MGT_DATA(EN_EG4(23)), MGT_DATA(EN_EG4(24)), MGT_DATA(EN_EG4(25)), MGT_DATA(EN_EG4(26)), MGT_DATA(EN_EG4(27)), MGT_DATA(EN_EG4(28)), MGT_DATA(EN_EG4(29))),
1203  (MGT_DATA(EN_EG4(30)), MGT_DATA(EN_EG4(31)), MGT_DATA(EN_EG4(32)), MGT_DATA(EN_EG4(33)), MGT_DATA(EN_EG4(34)), MGT_DATA(EN_EG4(35)), MGT_DATA(EN_EG4(36)), MGT_DATA(EN_EG4(37)), MGT_DATA(EN_EG4(38)), MGT_DATA(EN_EG4(39)))
1204  );
1205  HadData_int := (
1206  (MGT_DATA(EN_HAD4(00)), MGT_DATA(EN_HAD4(01)), MGT_DATA(EN_HAD4(02)), MGT_DATA(EN_HAD4(03)), MGT_DATA(EN_HAD4(04)), MGT_DATA(EN_HAD4(05))),
1207  (MGT_DATA(EN_HAD4(06)), MGT_DATA(EN_HAD4(07)), MGT_DATA(EN_HAD4(08)), MGT_DATA(EN_HAD4(09)), MGT_DATA(EN_HAD4(10)), MGT_DATA(EN_HAD4(11))),
1208  (MGT_DATA(EN_HAD4(12)), MGT_DATA(EN_HAD4(13)), MGT_DATA(EN_HAD4(14)), MGT_DATA(EN_HAD4(15)), MGT_DATA(EN_HAD4(16)), MGT_DATA(EN_HAD4(17)))
1209  );
1210  SpareData_int := (others => (others => '0'));
1211 
1212  end if;
1213 
1214  EmData <= EmData_int;
1215  HadData <= HadData_int;
1216  SpareData <= SpareData_int;
1217  end FibreArrayBuilder;
1218 
1219  function to_raw_data(em : FibreAllEm; had : FibreAllHad) return RAW_data_227_type is
1220  variable ret : RAW_data_227_type;
1221  begin
1222  for eta in 0 to 3 loop
1223  for phi in 0 to 9 loop
1224  ret(eta*10+phi) := em(eta)(phi)(227) & em(eta)(phi)(225 downto 0); -- remove align frame bit (226)
1225  end loop;
1226  end loop;
1227 
1228  for eta in 0 to 2 loop
1229  for phi in 0 to 2 loop
1230  ret(40+eta*3+phi) := had(eta)(phi)(227) & had(eta)(phi)(225 downto 0); --remove align frame bit (226)
1231  end loop;
1232  end loop;
1233 
1234  return ret;
1235 
1236  end function;
1237 
1238  function ReadoutMGTEnable (fpga_number : integer; mgt_enable_in : std_logic_vector(63 downto 0)) return std_logic_vector is
1239 
1240  variable v_en_out : std_logic_vector(48 downto 0);
1241 
1242  begin -- procedure ReadoutMGTEnable
1243  if fpga_number = 1 then
1244  --em
1245  v_en_out(39 downto 0) := mgt_enable_in(EN_EG1(00))&mgt_enable_in(EN_EG1(01))&mgt_enable_in(EN_EG1(02))&mgt_enable_in(EN_EG1(03))&mgt_enable_in(EN_EG1(04))&
1246  mgt_enable_in(EN_EG1(05))&mgt_enable_in(EN_EG1(06))&mgt_enable_in(EN_EG1(07))&mgt_enable_in(EN_EG1(08))&mgt_enable_in(EN_EG1(09))&
1247  mgt_enable_in(EN_EG1(10))&mgt_enable_in(EN_EG1(11))&mgt_enable_in(EN_EG1(12))&mgt_enable_in(EN_EG1(13))&mgt_enable_in(EN_EG1(14))&
1248  mgt_enable_in(EN_EG1(15))&mgt_enable_in(EN_EG1(16))&mgt_enable_in(EN_EG1(17))&mgt_enable_in(EN_EG1(18))&mgt_enable_in(EN_EG1(19))&
1249  mgt_enable_in(EN_EG1(20))&mgt_enable_in(EN_EG1(21))&mgt_enable_in(EN_EG1(22))&mgt_enable_in(EN_EG1(23))&mgt_enable_in(EN_EG1(24))&
1250  mgt_enable_in(EN_EG1(25))&mgt_enable_in(EN_EG1(26))&mgt_enable_in(EN_EG1(27))&mgt_enable_in(EN_EG1(28))&mgt_enable_in(EN_EG1(29))&
1251  mgt_enable_in(EN_EG1(30))&mgt_enable_in(EN_EG1(31))&mgt_enable_in(EN_EG1(32))&mgt_enable_in(EN_EG1(33))&mgt_enable_in(EN_EG1(34))&
1252  mgt_enable_in(EN_EG1(35))&mgt_enable_in(EN_EG1(36))&mgt_enable_in(EN_EG1(37))&mgt_enable_in(EN_EG1(38))&mgt_enable_in(EN_EG1(39));
1253  --hadronic
1254  v_en_out(48 downto 40) := mgt_enable_in(EN_HAD1(03))&mgt_enable_in(EN_HAD1(04))&mgt_enable_in(EN_HAD1(05)) &
1255  mgt_enable_in(EN_HAD1(09))&mgt_enable_in(EN_HAD1(10))&mgt_enable_in(EN_HAD1(11)) &
1256  mgt_enable_in(EN_HAD1(15))&mgt_enable_in(EN_HAD1(16))&mgt_enable_in(EN_HAD1(17));
1257 
1258  elsif fpga_number = 2 then
1259  --em
1260  v_en_out(39 downto 0) := mgt_enable_in(EN_EG2(00))&mgt_enable_in(EN_EG2(01))&mgt_enable_in(EN_EG2(02))&mgt_enable_in(EN_EG2(03))&mgt_enable_in(EN_EG2(04))&
1261  mgt_enable_in(EN_EG2(05))&mgt_enable_in(EN_EG2(06))&mgt_enable_in(EN_EG2(07))&mgt_enable_in(EN_EG2(08))&mgt_enable_in(EN_EG2(09))&
1262  mgt_enable_in(EN_EG2(10))&mgt_enable_in(EN_EG2(11))&mgt_enable_in(EN_EG2(12))&mgt_enable_in(EN_EG2(13))&mgt_enable_in(EN_EG2(14))&
1263  mgt_enable_in(EN_EG2(15))&mgt_enable_in(EN_EG2(16))&mgt_enable_in(EN_EG2(17))&mgt_enable_in(EN_EG2(18))&mgt_enable_in(EN_EG2(19))&
1264  mgt_enable_in(EN_EG2(20))&mgt_enable_in(EN_EG2(21))&mgt_enable_in(EN_EG2(22))&mgt_enable_in(EN_EG2(23))&mgt_enable_in(EN_EG2(24))&
1265  mgt_enable_in(EN_EG2(25))&mgt_enable_in(EN_EG2(26))&mgt_enable_in(EN_EG2(27))&mgt_enable_in(EN_EG2(28))&mgt_enable_in(EN_EG2(29))&
1266  mgt_enable_in(EN_EG2(30))&mgt_enable_in(EN_EG2(31))&mgt_enable_in(EN_EG2(32))&mgt_enable_in(EN_EG2(33))&mgt_enable_in(EN_EG2(34))&
1267  mgt_enable_in(EN_EG2(35))&mgt_enable_in(EN_EG2(36))&mgt_enable_in(EN_EG2(37))&mgt_enable_in(EN_EG2(38))&mgt_enable_in(EN_EG2(39));
1268  --hadronic
1269  v_en_out(48 downto 40) := mgt_enable_in(EN_HAD2(03))&mgt_enable_in(EN_HAD2(04))&mgt_enable_in(EN_HAD2(05))&
1270  mgt_enable_in(EN_HAD2(09))&mgt_enable_in(EN_HAD2(10))&mgt_enable_in(EN_HAD2(11))&
1271  mgt_enable_in(EN_HAD2(15))&mgt_enable_in(EN_HAD2(16))&mgt_enable_in(EN_HAD2(17));
1272 
1273  elsif fpga_number = 3 then
1274  --em
1275  v_en_out(39 downto 0) := mgt_enable_in(EN_EG3(00))&mgt_enable_in(EN_EG3(01))&mgt_enable_in(EN_EG3(02))&mgt_enable_in(EN_EG3(03))&mgt_enable_in(EN_EG3(04))&
1276  mgt_enable_in(EN_EG3(05))&mgt_enable_in(EN_EG3(06))&mgt_enable_in(EN_EG3(07))&mgt_enable_in(EN_EG3(08))&mgt_enable_in(EN_EG3(09))&
1277  mgt_enable_in(EN_EG3(10))&mgt_enable_in(EN_EG3(11))&mgt_enable_in(EN_EG3(12))&mgt_enable_in(EN_EG3(13))&mgt_enable_in(EN_EG3(14))&
1278  mgt_enable_in(EN_EG3(15))&mgt_enable_in(EN_EG3(16))&mgt_enable_in(EN_EG3(17))&mgt_enable_in(EN_EG3(18))&mgt_enable_in(EN_EG3(19))&
1279  mgt_enable_in(EN_EG3(20))&mgt_enable_in(EN_EG3(21))&mgt_enable_in(EN_EG3(22))&mgt_enable_in(EN_EG3(23))&mgt_enable_in(EN_EG3(24))&
1280  mgt_enable_in(EN_EG3(25))&mgt_enable_in(EN_EG3(26))&mgt_enable_in(EN_EG3(27))&mgt_enable_in(EN_EG3(28))&mgt_enable_in(EN_EG3(29))&
1281  mgt_enable_in(EN_EG3(30))&mgt_enable_in(EN_EG3(31))&mgt_enable_in(EN_EG3(32))&mgt_enable_in(EN_EG3(33))&mgt_enable_in(EN_EG3(34))&
1282  mgt_enable_in(EN_EG3(35))&mgt_enable_in(EN_EG3(36))&mgt_enable_in(EN_EG3(37))&mgt_enable_in(EN_EG3(38))&mgt_enable_in(EN_EG3(39));
1283  --hadronic
1284  v_en_out(48 downto 40) := mgt_enable_in(EN_HAD3(03))&mgt_enable_in(EN_HAD3(04))&mgt_enable_in(EN_HAD3(05))&
1285  mgt_enable_in(EN_HAD3(09))&mgt_enable_in(EN_HAD3(10))&mgt_enable_in(EN_HAD3(11))&
1286  mgt_enable_in(EN_HAD3(15))&mgt_enable_in(EN_HAD3(16))&mgt_enable_in(EN_HAD3(17));
1287 
1288  elsif fpga_number = 4 then
1289  --em
1290  v_en_out(39 downto 0) := mgt_enable_in(EN_EG4(00))&mgt_enable_in(EN_EG4(01))&mgt_enable_in(EN_EG4(02))&mgt_enable_in(EN_EG4(03))&mgt_enable_in(EN_EG4(04))&
1291  mgt_enable_in(EN_EG4(05))&mgt_enable_in(EN_EG4(06))&mgt_enable_in(EN_EG4(07))&mgt_enable_in(EN_EG4(08))&mgt_enable_in(EN_EG4(09))&
1292  mgt_enable_in(EN_EG4(10))&mgt_enable_in(EN_EG4(11))&mgt_enable_in(EN_EG4(12))&mgt_enable_in(EN_EG4(13))&mgt_enable_in(EN_EG4(14))&
1293  mgt_enable_in(EN_EG4(15))&mgt_enable_in(EN_EG4(16))&mgt_enable_in(EN_EG4(17))&mgt_enable_in(EN_EG4(18))&mgt_enable_in(EN_EG4(19))&
1294  mgt_enable_in(EN_EG4(20))&mgt_enable_in(EN_EG4(21))&mgt_enable_in(EN_EG4(22))&mgt_enable_in(EN_EG4(23))&mgt_enable_in(EN_EG4(24))&
1295  mgt_enable_in(EN_EG4(25))&mgt_enable_in(EN_EG4(26))&mgt_enable_in(EN_EG4(27))&mgt_enable_in(EN_EG4(28))&mgt_enable_in(EN_EG4(29))&
1296  mgt_enable_in(EN_EG4(30))&mgt_enable_in(EN_EG4(31))&mgt_enable_in(EN_EG4(32))&mgt_enable_in(EN_EG4(33))&mgt_enable_in(EN_EG4(34))&
1297  mgt_enable_in(EN_EG4(35))&mgt_enable_in(EN_EG4(36))&mgt_enable_in(EN_EG4(37))&mgt_enable_in(EN_EG4(38))&mgt_enable_in(EN_EG4(39));
1298  --hadronic
1299  v_en_out(48 downto 40) := mgt_enable_in(EN_HAD4(03))&mgt_enable_in(EN_HAD4(04))&mgt_enable_in(EN_HAD4(05))&
1300  mgt_enable_in(EN_HAD4(09))&mgt_enable_in(EN_HAD4(10))&mgt_enable_in(EN_HAD4(11))&
1301  mgt_enable_in(EN_HAD4(15))&mgt_enable_in(EN_HAD4(16))&mgt_enable_in(EN_HAD4(17));
1302 
1303  end if;
1304  return v_en_out;
1305  end function ReadoutMGTEnable;
1306 
1307  function f_efex_position (fpga_number : integer; efex_position : integer) return std_logic_vector is
1308  variable pos : std_logic_vector(31 downto 0);
1309  begin
1310 
1311  if fpga_number = 1 and efex_position = 1 then --A
1312  pos := x"0000001c";
1313  elsif fpga_number = 1 and efex_position = 2 then --B
1314  pos := x"00000000";
1315  elsif fpga_number = 1 and efex_position = 3 then --C
1316  pos := x"00000063";
1317 
1318  elsif fpga_number = 2 and efex_position = 1 then --A
1319  pos := x"0000009d";
1320  elsif fpga_number = 2 and efex_position = 2 then --B
1321  pos := x"0000001c";
1322  elsif fpga_number = 2 and efex_position = 3 then --C
1323  pos := x"00000000";
1324 
1325  elsif fpga_number = 3 and efex_position = 1 then --A
1326  pos := x"0000005c";
1327  elsif fpga_number = 3 and efex_position = 2 then --B
1328  pos := x"00000010";
1329  elsif fpga_number = 3 and efex_position = 3 then --C
1330  pos := x"00000060";
1331 
1332  elsif fpga_number = 4 and efex_position = 1 then --A
1333  pos := x"0000009c";
1334  elsif fpga_number = 4 and efex_position = 2 then --B
1335  pos := x"00000018";
1336  elsif fpga_number = 4 and efex_position = 3 then --C
1337  pos := x"00000020";
1338 
1339  else
1340  pos := (others => '1');
1341 
1342  end if;
1343 
1344  return pos;
1345  end function f_efex_position;
1346 
1347 end EfexDataFormats;
External data-types and functions.
( INPUT_COLUMNS- 1 downto 0) AlgoColumn AlgoInput
Algorithm INPUT port.
eFEX data-types and functions
( NUM_FIB_SPARE- 1 downto 0) std_logic_vector( 227 downto 0) FibreAllSpare
This holds all data from the spare fibres:
integer := 10 NUM_FIB_Em_PHI
Height (phi) of Proc FPGA Environment area in Em Fibres.
( NUM_FIB_Had_ETA- 1 downto 0) FibreColumnHad FibreAllHad
This holds all data from Had for 1 Proc FPGA:
integer := 6 NUM_FIB_Had_PHI
Height (phi) of Proc FPGA Environment area in Had Fibres.
( NUM_FIB_Had_PHI- 1 downto 0) std_logic_vector( 227 downto 0) FibreColumnHad
This holds all Had data from a column of fibres in phi for 1 Proc FPGA:
integer := 8 NUM_FIB_SPARE
No. Spare Fibres.
( NUM_FIB_Em_ETA- 1 downto 0) FibreColumnEm FibreAllEm
This holds all data from Em for 1 Proc FPGA:
integer := 4 NUM_FIB_Em_ETA
Width (eta) of Proc FPGA Environment area in Em Fibres.
integer := 3 NUM_FIB_Had_ETA
Width (eta) ofEN_HAD3 Proc FPGA Environment area in Had Fibres.
( NUM_FIB_Em_PHI- 1 downto 0) std_logic_vector( 227 downto 0) FibreColumnEm
This holds all Em data from a column of fibres in phi for 1 Proc FPGA: