50 use IEEE.STD_LOGIC_1164.
all;
51 use IEEE.NUMERIC_STD.
all;
54 use work.ipbus_decode_efex_algorithm.
all;
64 use ipbus_lib.ipbus_reg_types.
all;
66 use ipbus_lib.ipbus.
all;
68 library infrastructure_lib;
73 generic (ENCODING_MODE : integer;
74 USE_INPUT_RAM : boolean := false;
75 EFEX_POSITION : integer := 0;
76 USE_OUTPUT_RAMS : boolean := false;
78 EG_ALGO_VERSION : std_logic_vector(1 downto 0);
79 TAU_ALGO_VERSION : std_logic_vector(1 downto 0));
91 IN_BCN : in std_logic_vector(11 downto 0);
98 OUT_eg_sync_XTOB : out std_logic;
99 OUT_tau_sync_XTOB : out std_logic;
128 signal eg_Control : AlgoRegister := (others => '0');
129 signal tau_Control : AlgoRegister := (others => '0');
130 signal eg_Status : AlgoRegister;
131 signal tau_Status : AlgoRegister;
133 signal glob_Control : AlgoRegister := (others => '0');
134 signal glob_Status : AlgoRegister;
135 signal debug_Status : AlgoRegisters(15 downto 0);
136 signal debug_Control : AlgoRegisters(15 downto 0);
137 signal NoiseThresholds : AlgoRegisters(29 downto 0);
139 signal eg_Energy_threshold : DataWord;
140 signal eg_Condition_threshold : DataWord;
142 signal tau_Energy_threshold : DataWord;
143 signal tau_Condition_threshold : DataWord;
144 signal tau_BDT_min_energy_threshold : DataWord;
148 signal BCN280, BCNOut, BCN_to_output_ram : std_logic_vector(11 downto 0);
149 signal BCN200, FakeBCN : std_logic_vector(11 downto 0);
151 signal EnableSpyBCN_eg, EnableSpyBCN_tau : std_logic := '0';
156 signal EnableInputSpy, EnableOutputEgSpy, EnableOutputTauSpy : std_logic := '0';
157 signal EnableFakeAlgoInput, EnableFakeTOBeg, EnableFakeTOBtau : std_logic := '0';
161 signal ipb_to_slaves : ipb_wbus_array(N_SLAVES - 1 downto 0);
162 signal ipb_from_slaves : ipb_rbus_array(N_SLAVES - 1 downto 0) := (others => IPB_RBUS_NULL);
164 signal write_reg : ipb_reg_v(N_STAT - 1 downto 0) := (others => (others => '0'));
165 signal read_reg : ipb_reg_v(N_CTRL - 1 downto 0);
169 signal ParRamData : std_logic_vector(PARAMETER_RAM_DATA_WIDTH-1 downto 0);
170 signal ParRamAddress : std_logic_vector(2 downto 0);
172 signal Load : std_logic;
174 signal IS_Data : TriggerTowerMatrix;
175 signal IS_Thresholds_l0 : AlgoWords(5 downto 0);
176 signal IS_Thresholds_l1 : AlgoWords(5 downto 0);
177 signal IS_Thresholds_l2 : AlgoWords(5 downto 0);
178 signal IS_Thresholds_l3 : AlgoWords(5 downto 0);
179 signal IS_Thresholds_had_tile : AlgoWords(5 downto 0);
180 signal IS_Thresholds_had_lar : AlgoWords(5 downto 0);
183 signal TOB_Start : std_logic;
184 signal TOB_Counter : std_logic_vector(2 downto 0);
185 signal eg_TOBs : TriggerObjects_eg(OUTPUT_TOBS-1 downto 0);
186 signal eg_in_TOBs : TriggerObjects_eg(OUTPUT_TOBS-1 downto 0);
190 signal eg_sorted_TOB_Start : std_logic_vector(OUTPUT_TOBS-1 downto 0);
191 signal tau_TOBs : TriggerObjects_tau(OUTPUT_TOBS-1 downto 0);
192 signal tau_in_TOBs : TriggerObjects_tau(OUTPUT_TOBS-1 downto 0);
196 signal tau_sorted_TOB_Start : std_logic_vector(OUTPUT_TOBS-1 downto 0);
198 signal eg_tob_empty : std_logic_vector(OUTPUT_TOBS-1 downto 0);
199 signal tau_tob_empty : std_logic_vector(OUTPUT_TOBS-1 downto 0);
201 signal eg_xtob_valid : std_logic_vector(OUTPUT_TOBS-1 downto 0);
202 signal tau_xtob_valid : std_logic_vector(OUTPUT_TOBS-1 downto 0);
205 signal eg_DMC_b0, eg_DMC_b1, eg_DMC_b2, eg_DMC_b3 : AlgoParameter;
207 signal Load280 : std_logic;
208 signal Load200 : std_logic;
209 signal Count280 : std_logic_vector(2 downto 0) := (others => '0');
210 signal Count200 : std_logic_vector(2 downto 0) := (others => '0');
211 signal OutLoad : std_logic;
219 attribute keep : string;
220 attribute max_fanout : integer;
221 attribute keep of eg_Control : signal is "true";
222 attribute max_fanout of eg_Control : signal is 1000;
223 attribute keep of tau_Control : signal is "true";
224 attribute max_fanout of tau_Control : signal is 1000;
225 attribute keep of glob_Control : signal is "true";
226 attribute max_fanout of glob_Control : signal is 1000;
227 attribute keep of debug_Control : signal is "true";
228 attribute max_fanout of debug_Control : signal is 1000;
231 attribute keep of NoiseThresholds : signal is "true";
232 attribute max_fanout of NoiseThresholds : signal is 1000;
243 OUT_Load280 => Load280,
244 OUT_Load200 => Load200
);
247 AlgoDataInput <= FakeInput when EnableFakeAlgoInput = '1' else IN_Data;
249 THRESHOLD_FOR : for i in 0 to 5 generate
250 IS_Thresholds_l0 (i) <= NoiseThresholds(i*5+0)(9 downto 0);
251 IS_Thresholds_l1 (i) <= NoiseThresholds(i*5+1)(9 downto 0);
252 IS_Thresholds_l2 (i) <= NoiseThresholds(i*5+2)(9 downto 0);
253 IS_Thresholds_l3 (i) <= NoiseThresholds(i*5+3)(9 downto 0);
254 IS_Thresholds_had_lar (i) <= NoiseThresholds(i*5+4)(9 downto 0);
255 IS_Thresholds_had_tile(i) <= NoiseThresholds(i*5+4)(25 downto 16);
259 generic map (ENCODING_MODE => ENCODING_MODE
)
263 IN_Data => AlgoDataInput,
267 IN_threshold_l0 => IS_Thresholds_l0,
268 IN_threshold_l1 => IS_Thresholds_l1,
269 IN_threshold_l2 => IS_Thresholds_l2,
270 IN_threshold_l3 => IS_Thresholds_l3,
271 IN_threshold_had_lar => IS_Thresholds_had_lar,
272 IN_threshold_had_tile => IS_Thresholds_had_tile,
274 OUT_BCN_200 => BCN200,
276 OUT_Data => IS_Data
);
280 BCN_sync_proc :
process (
CLK280)
282 if rising_edge(CLK280) then
283 if Count280 = "010" then
284 if EnableFakeAlgoInput = '1' then
294 end process BCN_sync_proc;
298 EG_ALGO_VERSION => EG_ALGO_VERSION,
299 TAU_ALGO_VERSION => TAU_ALGO_VERSION
)
306 OUT_ParameterRAMaddress => ParRamAddress,
320 IN_ParDeadMat_b1 => eg_DMC_b1,
321 IN_ParDeadMat_b2 => eg_DMC_b2,
322 IN_ParDeadMat_b3 => eg_DMC_b3,
331 IN_tau_Control => tau_Control,
332 OUT_tau_Status => tau_Status,
337 IN_glob_Control => glob_Control,
338 OUT_glob_Status => glob_Status,
340 OUT_TOB_Start => TOB_Start,
341 OUT_TOB_Counter => TOB_Counter,
343 OUT_eg_TOB => eg_TOBs,
345 OUT_tau_TOB => tau_TOBs
);
347 Counter_280 :
process (
CLK280)
349 if rising_edge(CLK280) then
350 if Load280 = '1' then
351 Count280 <= (others => '0');
353 Count280 <= std_logic_vector(unsigned(Count280)+1);
358 Counter_200 :
process (
CLK200)
360 if rising_edge(CLK200) then
361 if Load200 = '1' then
362 Count200 <= (others => '0');
364 Count200 <= std_logic_vector(unsigned(Count200)+1);
371 out_tob_for : for i in 0 to OUTPUT_TOBS-1 generate
376 eg_in_TOBs(i).Core <= validate_core(eg_TOBs(i).Core);
377 eg_in_TOBs(i).Position.Phi <= std_logic_vector(to_unsigned(i, 3));
378 tau_in_TOBs(i).Core <= validate_core(tau_TOBs(i).Core);
379 tau_in_TOBs(i).Position.Phi <= std_logic_vector(to_unsigned(i, 3));
385 tau_in_TOBs(i).Position.Eta <= TOB_Counter when glob_Position(1 downto 0) = "11" else std_logic_vector(unsigned(TOB_Counter) + 1);
386 eg_in_TOBs(i).Position.Eta <= TOB_Counter when glob_Position(1 downto 0) = "11" else std_logic_vector(unsigned(TOB_Counter) + 1);
388 Input_TOBs_eg(i) <= to_AlgoTriggerObject(eg_in_TOBs(i), FPGA);
389 Input_TOBs_tau(i) <= to_AlgoTriggerObject(tau_in_TOBs(i), FPGA);
391 SerialSorterEgInput(i) <= FakeEgOutput(i) when EnableFakeTOBeg = '1' else Input_TOBs_eg(i);
392 Serialsortertauinput(i) <= FakeTauOutput(i) when EnableFakeTOBtau = '1' else Input_TOBs_tau(i);
399 IN_Clear => TOB_Start,
400 IN_Data => SerialSorterEgInput
(i
),
401 OUT_Start => eg_sorted_TOB_Start
(i
),
402 OUT_Data => eg_sorted_TOBs
(i
));
409 IN_Clear => TOB_Start,
410 IN_Data => SerialSorterTauInput
(i
),
411 OUT_Start => tau_sorted_TOB_Start
(i
),
412 OUT_Data => tau_sorted_TOBs
(i
));
413 end generate out_tob_for;
415 valid_for : for i in OUTPUT_TOBS-1 downto 0 generate
418 end generate valid_for;
427 OUT_tau_Sync_XTOB <= TOB_Start;
428 OUT_eg_Sync_XTOB <= TOB_Start;
429 valid_xtob_for : for i in OUTPUT_TOBS-1 downto 0 generate
430 eg_xtob_valid(i) <= is_valid_core(eg_in_TOBS(i).Core);
431 tau_xtob_valid(i) <= is_valid_core(tau_in_TOBS(i).Core);
444 ipb_in => ipb_to_slaves
(N_SLV_ALGO_RATE_MONITOR
),
445 ipb_out => ipb_from_slaves
(N_SLV_ALGO_RATE_MONITOR
),
448 IN_BCN => BCN_to_output_RAM,
450 IN_synch => TOB_Start,
452 IN_eta => eg_in_TOBS
(0).Position.Eta,
454 IN_eg_energies =>
(7 => eg_in_TOBS
(7).Core.Energy,
6 => eg_in_TOBS
(6).Core.Energy,
5 => eg_in_TOBS
(5).Core.Energy,
4 => eg_in_TOBS
(4).Core.Energy,
455 3 => eg_in_TOBS
(3).Core.Energy,
2 => eg_in_TOBS
(2).Core.Energy,
1 => eg_in_TOBS
(1).Core.Energy,
0 => eg_in_TOBS
(0).Core.Energy
),
456 IN_eg_valids => eg_xtob_valid,
458 IN_tau_energies =>
(7 => tau_in_TOBS
(7).Core.Energy,
6 => tau_in_TOBS
(6).Core.Energy,
5 => tau_in_TOBS
(5).Core.Energy,
4 => tau_in_TOBS
(4).Core.Energy,
459 3 => tau_in_TOBS
(3).Core.Energy,
2 => tau_in_TOBS
(2).Core.Energy,
1 => tau_in_TOBS
(1).Core.Energy,
0 => tau_in_TOBS
(0).Core.Energy
),
460 IN_tau_valids => tau_xtob_valid
464 IPBUS_FABRIC :
entity ipbus_lib.ipbus_fabric_sel
467 SEL_WIDTH => IPBUS_SEL_WIDTH
)
469 sel => ipbus_sel_efex_algorithm
(ipb_in.ipb_addr
),
473 ipb_to_slaves => ipb_to_slaves,
474 ipb_from_slaves => ipb_from_slaves
);
476 IPBUS_ALGO_REGISTERS :
entity ipbus_lib.ipbus_ctrlreg_v
483 ipbus_in => ipb_to_slaves
(N_SLV_ALGO_REGISTERS
),
484 ipbus_out => ipb_from_slaves
(N_SLV_ALGO_REGISTERS
),
494 ipb_in => ipb_to_slaves
(N_SLV_ALGO_PARAMETER_RAM
),
495 ipb_out => ipb_from_slaves
(N_SLV_ALGO_PARAMETER_RAM
),
499 addr => ParRamAddress
);
501 INPUT_RAM_IF : if USE_INPUT_RAM generate
506 ipb_in => ipb_to_slaves
(N_SLV_ALGO_INPUT_RAM
),
507 ipb_out => ipb_from_slaves
(N_SLV_ALGO_INPUT_RAM
),
513 we => EnableInputSpy,
515 AlgoOut => FakeInput
);
518 ipb_from_slaves(N_SLV_ALGO_INPUT_RAM) <= IPB_RBUS_NULL;
519 FakeBCN <= (others => '0');
520 FakeInput <= ZERO_ALGO_INPUT;
524 OUTPUT_RAM_IF : if USE_OUTPUT_RAMS generate
530 ipb_in => ipb_to_slaves
(N_SLV_ALGO_OUTPUT_EG_RAM
),
531 ipb_out => ipb_from_slaves
(N_SLV_ALGO_OUTPUT_EG_RAM
),
533 BCNIn => BCN_to_output_ram,
534 SpyBCNIn => EnableSpyBCN_eg,
538 AlgoIn => to_AlgoOutput
(Input_TOBs_eg
),
539 we => EnableOutputEgSpy,
540 AlgoOut => FakeEgOutput
);
546 ipb_in => ipb_to_slaves
(N_SLV_ALGO_OUTPUT_TAU_RAM
),
547 ipb_out => ipb_from_slaves
(N_SLV_ALGO_OUTPUT_TAU_RAM
),
549 BCNIn => BCN_to_output_ram,
550 SpyBCNIn => EnableSpyBCN_tau,
554 AlgoIn => to_AlgoOutput
(Input_TOBs_tau
),
555 we => EnableOutputTauSpy,
556 AlgoOut => FakeTauOutput
);
558 ipb_from_slaves(N_SLV_ALGO_OUTPUT_EG_RAM) <= IPB_RBUS_NULL;
559 ipb_from_slaves(N_SLV_ALGO_OUTPUT_TAU_RAM) <= IPB_RBUS_NULL;
560 FakeEgOutput <= (others => (others => '0'));
561 FakeTauOutput <= (others => (others => '0'));
565 BCN_Delay_internal :
entity infrastructure_lib.
GeneralDelay
572 data_out => BCN_to_output_ram
);
575 BCN_Delay_to_Readout :
entity infrastructure_lib.
GeneralDelay
587 EnableFakeAlgoInput <= glob_Control(0);
588 EnableFakeTOBeg <= eg_Control(0);
589 EnableFakeTOBtau <= tau_Control(0);
592 EnableInputSpy <= glob_Control(1);
593 EnableOutputEgSpy <= eg_Control(1);
594 EnableOutputTauSpy <= tau_Control(1);
596 EnableSpyBCN_eg <= eg_Control(2);
597 EnableSpyBCN_tau <= tau_Control(2);
601 eg_Control <= read_reg(00);
602 tau_Control <= read_reg(01);
603 glob_Control <= read_reg(02);
604 glob_Position <= read_reg(03) when EFEX_POSITION = 0 else f_efex_position(FPGA, EFEX_POSITION);
607 thr_connection: for i in 29 downto 0 generate
608 NoiseThresholds(i) <= read_reg(i+8);
612 write_reg(1) <= x"0000000" & '0' & TOB_Counter;
613 write_reg(2) <= x"0000000" & '0' & Count280;
614 write_reg(3) <= (others => '0');
623 eg_DMC_b0 <= ParRamData(31 downto 24);
625 eg_ParWs(0) <= ParRamData(7+32 downto 0+32);
626 eg_ParWs(1) <= ParRamData(15+32 downto 8+32);
627 eg_ParWs(2) <= ParRamData(23+32 downto 16+32);
628 eg_DMC_b1 <= ParRamData(31+32 downto 24+32);
633 eg_DMC_b2 <= ParRamData(31+64 downto 24+64);
635 eg_Energy_threshold <= ParRamData(15+96 downto 0+96);
636 eg_Condition_threshold <= ParRamData(31+96 downto 16+96);
640 tau_ParFrac(2) <= ParRamData(23+128 downto 16+128);
641 eg_DMC_b3 <= ParRamData(31+128 downto 24+128);
644 tau_ParJet(0) <= ParRamData(7+160 downto 0+160);
645 tau_ParJet(1) <= ParRamData(15+160 downto 8+160);
646 tau_ParJet(2) <= ParRamData(23+160 downto 16+160);
649 tau_Energy_threshold <= ParRamData(15+192 downto 0+192);
650 tau_Condition_threshold <= ParRamData(31+192 downto 16+192);
652 tau_BDT_min_energy_threshold <= ParRamData(15+224 downto 0+224);
External data-types and functions.
array(natural range <> ) of AlgoWord AlgoWords
External arra of AlgoWord.
( OUTPUT_TOBS- 1 downto 0) AlgoTriggerObject AlgoOutput
Algorithm OUTPUT port.
array(natural range <> ) of AlgoTriggerObject AlgoTriggerObjects
Algorithm OUTPUT port.
( INPUT_COLUMNS- 1 downto 0) AlgoColumn AlgoInput
Algorithm INPUT port.
( OUTPUT_TOBS- 1 downto 0) AlgoXTriggerObject AlgoXOutput
Algorithm XOUTPUT port.
in ipb_rst std_logic
IPBus reset.
in ipb_clk std_logic
IPBus clk.
out ipb_out ipb_rbus
IPBus read bus.
in ipb_in ipb_wbus
IPBus write bus.
Shift register for data delay.
Top feature extracting algorithm module with IPBus interface.
AlgoParameters( 2 downto 0) eg_ParReta
Reta condition thresholds.
AlgoRegister :=( others => '0') glob_Position
Bit 0 eFEX on edge, bit 1 eFEX on left edge.
AlgoParameters( 2 downto 0) eg_ParWs
Ws condition thresholds.
AlgoParameters( 2 downto 0) tau_ParJet
Tau Jet condition thresholds.
integer := 6 PHASE200
Synchrnoisation phase between 40MHZ and 200MHz clocks.
positive := 64 N_STAT
Number of status IPBus reg.
AlgoParameters( 2 downto 0) eg_ParHadron
Hadronic condition thresholds.
positive := 64 N_CTRL
Number of control IPBus reg.
AlgoParameters( 2 downto 0) tau_ParFrac
Tau Frac condition thresholds.
integer := 5 PHASE280
Synchrnoisation phase between 200MHZ and 280MHz clocks.
Top feature extracting algorithm module with IPBus interface.
in CLK200 std_logic
200 MHz clock
in ipb_rst std_logic
IPBus reset.
out OUT_eg_Valid std_logic_vector( OUTPUT_TOBS- 1 downto 0)
Output data valid, high when correspondent output data are valid.
in IN_Load std_logic
40 MHz clock, 12% duty cycle
out OUT_eg_Valid_XTOB std_logic_vector( OUTPUT_TOBS- 1 downto 0)
Output data valid, high when correspondent output data are valid.
out OUT_BCN_TOB std_logic_vector( 11 downto 0)
Delayed crossing number as decoded from input data.
in CLK280 std_logic
280 MHz clock, used in the output stage
out OUT_tau_TOB AlgoOutput
Algorithm external data structure, defined in AlgoDataTypes.vhd.
out OUT_tau_XTOB AlgoXOutput
Algorithm external XTOB data structure, defined in AlgoDataTypes.vhd.
out OUT_eg_XTOB AlgoXOutput
Algorithm external XTOB data structure, defined in AlgoDataTypes.vhd.
out OUT_eg_Sync std_logic
Output sync, high on the first clock cycle of the BC.
out OUT_tau_Valid std_logic_vector( OUTPUT_TOBS- 1 downto 0)
Output data valid, high when correspondent output data are valid.
in IN_Data AlgoInput
Algorithm external data structure, defined in AlgoDataTypes.vhd.
out OUT_tau_Sync std_logic
Output sync, high on the first clock cycle of the BC.
in ipb_clk std_logic
IPBus clk.
out ipb_out ipb_rbus
IPBus read bus.
out OUT_eg_TOB AlgoOutput
Algorithm external data structure, defined in AlgoDataTypes.vhd.
in ipb_in ipb_wbus
IPBus write bus.
out OUT_eFEXPosition std_logic_vector( 31 downto 0)
Geographic position of eFEX Module, to be used in the mapping logic.
out OUT_BCN_XTOB std_logic_vector( 11 downto 0)
Delayed crossing number as decoded from input data.
out OUT_tau_Valid_XTOB std_logic_vector( OUTPUT_TOBS- 1 downto 0)
Output data valid, high when correspondent output data are valid.
Top feature-extracting algorithm module.
in IN_tau_Cond_threshold DataWord
Energy threshold for Jet and Frac condition;.
in IN_eg_Cond_threshold DataWord
Energy threshold for Reta, Wstot and Had conditions;.
in IN_tau_ParJet AlgoParameters( 2 downto 0)
Thresholds for specific condition taken from parameter RAM.
in IN_eg_ParHadron AlgoParameters( 2 downto 0)
Thresholds for specific condition taken from parameter RAM.
in IN_ParDeadMat_b0 AlgoParameter
enable bit mask for dead material correction
in IN_eg_Control AlgoRegister
Control register for eg algorithm.
in IN_tau_BDT_min_energy_threshold DataWord
Min. energy threshold for tau BDT condition;.
in IN_eg_Energy_threshold DataWord
Energy threshold for TOB production;.
in IN_glob_Position AlgoRegister :=( others => '0')
out OUT_eg_Status AlgoRegister
Status register for eg algorithm.
in IN_eg_ParWs AlgoParameters( 2 downto 0)
Thresholds for specific condition taken from parameter RAM.
in IN_tau_Energy_threshold DataWord
IPBus wrapper for output spy/playback RAM for Algorithm module.