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

Back to eFEX documentation
IPBusTopAlgoModule.vhd
Go to the documentation of this file.
1 
47 
49 library IEEE;
50 use IEEE.STD_LOGIC_1164.all;
51 use IEEE.NUMERIC_STD.all;
52 
54 use work.ipbus_decode_efex_algorithm.all;
55 
57 use work.DataTypes.all;
59 use work.AlgoDataTypes.all;
60 
62 library ipbus_lib;
64 use ipbus_lib.ipbus_reg_types.all;
66 use ipbus_lib.ipbus.all;
67 
68 library infrastructure_lib;
69 use infrastructure_lib.EfexDataFormats.all;
70 
73  generic (ENCODING_MODE : integer;
74  USE_INPUT_RAM : boolean := false;
75  EFEX_POSITION : integer := 0;
76  USE_OUTPUT_RAMS : boolean := false;
77  FPGA : integer := 1;
78  EG_ALGO_VERSION : std_logic_vector(1 downto 0);
79  TAU_ALGO_VERSION : std_logic_vector(1 downto 0));
80 
81  port (CLK200 : in std_logic;
82  CLK280 : in std_logic;
83  IN_Load : in std_logic;
84  ipb_clk : in std_logic;
85  ipb_rst : in std_logic;
86  ipb_in : in ipb_wbus;
87  ipb_out : out ipb_rbus;
88  OUT_eFEXPosition : out std_logic_vector(31 downto 0);
89 
91  IN_BCN : in std_logic_vector(11 downto 0);
92  OUT_eg_Sync : out std_logic;
93  OUT_eg_Valid : out std_logic_vector(OUTPUT_TOBS-1 downto 0);
94 
96 
97  OUT_BCN_XTOB : out std_logic_vector(11 downto 0);
98  OUT_eg_sync_XTOB : out std_logic;
99  OUT_tau_sync_XTOB : out std_logic;
102  OUT_eg_Valid_XTOB : out std_logic_vector(OUTPUT_TOBS-1 downto 0);
103  OUT_tau_Valid_XTOB : out std_logic_vector(OUTPUT_TOBS-1 downto 0);
104 
105  OUT_BCN_TOB : out std_logic_vector(11 downto 0);
106 
107  OUT_tau_Sync : out std_logic;
108  OUT_tau_Valid : out std_logic_vector(OUTPUT_TOBS-1 downto 0);
111 
113 architecture Behavioral of IPBusTopAlgoModule is
114 
115 
116  constant N_CTRL : positive := 64;
117  constant N_STAT : positive := 64;
118 
119  --Algorithm parameter
120  signal eg_ParWs : AlgoParameters(2 downto 0);
121  signal eg_ParReta : AlgoParameters(2 downto 0);
122  signal eg_ParHadron : AlgoParameters(2 downto 0);
123  signal tau_ParJet : AlgoParameters(2 downto 0);
124  signal tau_ParFrac : AlgoParameters(2 downto 0);
125 
126 
127  --Control and status registers
128  signal eg_Control : AlgoRegister := (others => '0');
129  signal tau_Control : AlgoRegister := (others => '0');
130  signal eg_Status : AlgoRegister;
131  signal tau_Status : AlgoRegister;
132  signal glob_Position : AlgoRegister := (others => '0');
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);
138 
139  signal eg_Energy_threshold : DataWord;
140  signal eg_Condition_threshold : DataWord;
141 
142  signal tau_Energy_threshold : DataWord;
143  signal tau_Condition_threshold : DataWord;
144  signal tau_BDT_min_energy_threshold : DataWord;
145  --Spy memories signals:
146  signal FakeInput : AlgoInput;
147 
148  signal BCN280, BCNOut, BCN_to_output_ram : std_logic_vector(11 downto 0);
149  signal BCN200, FakeBCN : std_logic_vector(11 downto 0);
150 
151  signal EnableSpyBCN_eg, EnableSpyBCN_tau : std_logic := '0';
152 
153  signal AlgoDataInput : AlgoInput;
154 
155  signal FakeEgOutput, FakeTauOutput : AlgoTriggerObjects(OUTPUT_TOBS-1 downto 0);
156  signal EnableInputSpy, EnableOutputEgSpy, EnableOutputTauSpy : std_logic := '0';
157  signal EnableFakeAlgoInput, EnableFakeTOBeg, EnableFakeTOBtau : std_logic := '0';
158 
159 
160 -- IPBus signals
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);
163 
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);
166 
167 
168 -- Parameter RAM signals
169  signal ParRamData : std_logic_vector(PARAMETER_RAM_DATA_WIDTH-1 downto 0);
170  signal ParRamAddress : std_logic_vector(2 downto 0);
171 
172  signal Load : std_logic;
173 
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);
181 
182 
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);
187  signal Input_TOBs_eg : AlgoTriggerObjects(OUTPUT_TOBS-1 downto 0);
188  signal SerialSorterEgInput : AlgoTriggerObjects(OUTPUT_TOBS-1 downto 0);
189  signal eg_sorted_TOBs : AlgoTriggerObjects(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);
193  signal Input_TOBs_tau : AlgoTriggerObjects(OUTPUT_TOBS-1 downto 0);
194  signal SerialSorterTauInput : AlgoTriggerObjects(OUTPUT_TOBS-1 downto 0);
195  signal tau_sorted_TOBs : AlgoTriggerObjects(OUTPUT_TOBS-1 downto 0);
196  signal tau_sorted_TOB_Start : std_logic_vector(OUTPUT_TOBS-1 downto 0);
197 
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);
200 
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);
203 
204 
205  signal eg_DMC_b0, eg_DMC_b1, eg_DMC_b2, eg_DMC_b3 : AlgoParameter;
206 
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;
212 
214  constant PHASE280 : integer := 5;
216  constant PHASE200 : integer := 6;
217 
218 -- ####### attributes ########
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;
229  attribute keep of glob_Position : signal is "true";
230  attribute max_fanout of glob_Position : signal is 1000;
231  attribute keep of NoiseThresholds : signal is "true";
232  attribute max_fanout of NoiseThresholds : signal is 1000;
233 
234 begin
235  LOAD_GENERATOR : entity work.LoadGenerator
236  generic map(
237  PHASE200 => PHASE200,
238  PHASE280 => PHASE280)
239  port map (
240  IN_Load => IN_Load,
241  CLK200 => CLK200,
242  CLK280 => CLK280,
243  OUT_Load280 => Load280,
244  OUT_Load200 => Load200);
245 
246 -- Data spy MUX
247  AlgoDataInput <= FakeInput when EnableFakeAlgoInput = '1' else IN_Data;
248 
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);
256  end generate;
257 
258  INPUT_STAGE : entity work.AlgoInputStage
259  generic map (ENCODING_MODE => ENCODING_MODE)
260  port map (
261  CLK200 => CLK200,
262  IN_Load => Load200,
263  IN_Data => AlgoDataInput,
264  IN_Position => glob_Position,
265  IN_BCN => IN_BCN,
266 
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,
273 
274  OUT_BCN_200 => BCN200, -- BCN synced with 200 MHz clock
275  OUT_Load => Load,
276  OUT_Data => IS_Data);
277 
279 
280  BCN_sync_proc : process (CLK280)
281  begin
282  if rising_edge(CLK280) then
283  if Count280 = "010" then -- to meet multicycle 2 constraint between 200 nad 280
284  if EnableFakeAlgoInput = '1' then
285  BCN280 <= FakeBCN; --Check THIS!!
286  else
287  BCN280 <= BCN200;
288  end if;
289 
290  else
291  BCN280 <= BCN280;
292  end if;
293  end if;
294  end process BCN_sync_proc;
295 
296  TOP_ALGO_MODULE : entity work.TopAlgoModule
297  generic map (
298  EG_ALGO_VERSION => EG_ALGO_VERSION,
299  TAU_ALGO_VERSION => TAU_ALGO_VERSION)
300  port map (
301  CLK200 => CLK200,
302  IN_Load => Load,
303 
304  IN_Data => IS_Data,
305 
306  OUT_ParameterRAMaddress => ParRamAddress,
307 
309  IN_eg_ParReta => eg_ParReta,
311 
312  IN_eg_Energy_threshold => eg_Energy_threshold,
313  IN_eg_Cond_threshold => eg_Condition_threshold,
314 
315  IN_tau_Energy_threshold => tau_Energy_threshold,
316  IN_tau_Cond_threshold => tau_Condition_threshold,
317  IN_tau_BDT_min_energy_threshold => tau_BDT_min_energy_threshold,
318 
319  IN_ParDeadMat_b0 => eg_DMC_b0,
320  IN_ParDeadMat_b1 => eg_DMC_b1,
321  IN_ParDeadMat_b2 => eg_DMC_b2,
322  IN_ParDeadMat_b3 => eg_DMC_b3,
323 
324  IN_eg_Control => eg_Control,
325  OUT_eg_Status => eg_Status,
326 
328  IN_tau_ParFrac => tau_ParFrac,
329 
330 
331  IN_tau_Control => tau_Control,
332  OUT_tau_Status => tau_Status,
333 
334 
335 
337  IN_glob_Control => glob_Control,
338  OUT_glob_Status => glob_Status,
339 
340  OUT_TOB_Start => TOB_Start,
341  OUT_TOB_Counter => TOB_Counter,
342 
343  OUT_eg_TOB => eg_TOBs,
344 
345  OUT_tau_TOB => tau_TOBs);
346 
347  Counter_280 : process (CLK280)
348  begin -- process dd
349  if rising_edge(CLK280) then
350  if Load280 = '1' then -- Reset the counter accordingly
351  Count280 <= (others => '0');
352  else
353  Count280 <= std_logic_vector(unsigned(Count280)+1);
354  end if;
355  end if;
356  end process;
357 
358  Counter_200 : process (CLK200)
359  begin -- process dd
360  if rising_edge(CLK200) then
361  if Load200 = '1' then -- Reset the counter accordingly
362  Count200 <= (others => '0');
363  else
364  Count200 <= std_logic_vector(unsigned(Count200)+1);
365  end if;
366  end if;
367  end process;
368 
369 
370 
371  out_tob_for : for i in 0 to OUTPUT_TOBS-1 generate
372 
373  --Eta is given by the TOB counter
374  --Phi is given by the index of this for
375 
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));
380 
381  -- Change Eta numbering as a function of position
382  -- When eFEX is on Left eta edge "11", eta goes from 0 to 4 (no + 1)
383  -- When eFEX is on Right Eta edge "01", eta goes from 1 to 5
384  -- When eFex is not on edge "x0", eta goes from 1 to 4
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);
387 
388  Input_TOBs_eg(i) <= to_AlgoTriggerObject(eg_in_TOBs(i), FPGA);
389  Input_TOBs_tau(i) <= to_AlgoTriggerObject(tau_in_TOBs(i), FPGA);
390 
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);
393 
394  SerialSorter_eg : entity work.SerialSorter
395  port map (
396  clk => CLK200,
397  clk_out => CLK280,
398  IN_Load => Load280,
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));
403 
404  SerialSorter_tau : entity work.SerialSorter
405  port map (
406  clk => CLK200,
407  clk_out => CLK280,
408  IN_Load => Load280,
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;
414 
415  valid_for : for i in OUTPUT_TOBS-1 downto 0 generate
416  OUT_eg_Valid(i) <= is_valid_TOB(eg_sorted_TOBs(i));
417  OUT_tau_Valid(i) <= is_valid_TOB(tau_sorted_TOBs(i));
418  end generate valid_for;
419  -- TOBS to be sent out of this module to parallel sorting *280
420  OUT_eg_Sync <= eg_sorted_TOB_Start(0); -- should be done better, what about
421  OUT_tau_Sync <= tau_sorted_TOB_Start(0); -- the other signals?
422  OUT_eg_TOB <= to_AlgoOutput(eg_sorted_TOBs);
423  OUT_tau_TOB <= to_AlgoOutput(tau_sorted_TOBs);
424 
425 
426  -- XTOBS to be sent to out of this module to readout @200
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); --this goes to rate monitor
431  tau_xtob_valid(i) <= is_valid_core(tau_in_TOBS(i).Core);
432  OUT_eg_Valid_XTOB(i) <= eg_xtob_valid(i);
433  OUT_tau_Valid_XTOB(i) <= tau_xtob_valid(i);
434  end generate;
435  OUT_eg_XTOB <= to_AlgoXOutput(eg_in_TOBS, FPGA);
436  OUT_tau_XTOB <= to_AlgoXOutput(tau_in_TOBs, FPGA);
437 
438  OUT_BCN_XTOB <= BCN_to_output_RAM;
439 
440  RATE_MONITOR : entity work.AlgoRateMonitor
441  port map (
442  ipb_clk => ipb_clk,
443  ipb_rst => ipb_rst,
444  ipb_in => ipb_to_slaves(N_SLV_ALGO_RATE_MONITOR),
445  ipb_out => ipb_from_slaves(N_SLV_ALGO_RATE_MONITOR),
446 
447  clk => clk200,
448  IN_BCN => BCN_to_output_RAM, --this is not used inside the block
449 
450  IN_synch => TOB_Start,
451 
452  IN_eta => eg_in_TOBS(0).Position.Eta,
453 
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,
457 
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
461 
462  );
463 
464  IPBUS_FABRIC : entity ipbus_lib.ipbus_fabric_sel
465  generic map (
466  NSLV => N_SLAVES, --defined in ipbus_sel_address_table_ALGO
467  SEL_WIDTH => IPBUS_SEL_WIDTH)
468  port map (
469  sel => ipbus_sel_efex_algorithm(ipb_in.ipb_addr), --function defined in ipbus_sel_address_table_ALGO
470 
471  ipb_in => ipb_in,
472  ipb_out => ipb_out,
473  ipb_to_slaves => ipb_to_slaves,
474  ipb_from_slaves => ipb_from_slaves);
475 
476  IPBUS_ALGO_REGISTERS : entity ipbus_lib.ipbus_ctrlreg_v
477  generic map (
478  N_CTRL => N_CTRL, --number of control reg
479  N_STAT => N_STAT) --number of status reg
480  port map (
481  clk => ipb_clk,
482  reset => ipb_rst,
483  ipbus_in => ipb_to_slaves(N_SLV_ALGO_REGISTERS),
484  ipbus_out => ipb_from_slaves(N_SLV_ALGO_REGISTERS),
485  d => write_reg,
486  q => read_reg,
487 -- qmask => (others => '0'),
488  stb => open);
489 
490  IPBUS_ALGO_PARAMETER_RAM : entity work.AlgoParameterRAM_wrapper
491  port map (
492  clk_ipb => ipb_clk,
493  rst => ipb_rst,
494  ipb_in => ipb_to_slaves(N_SLV_ALGO_PARAMETER_RAM),
495  ipb_out => ipb_from_slaves(N_SLV_ALGO_PARAMETER_RAM),
496  rclk => CLK200,
497  we => '0',
498  q => ParRamData,
499  addr => ParRamAddress);
500 
501  INPUT_RAM_IF : if USE_INPUT_RAM generate
502  IPBUS_INPUT_RAM : entity work.ipbus_inputRAM
503  port map (
504  clk_ipb => ipb_clk,
505  rst => ipb_rst,
506  ipb_in => ipb_to_slaves(N_SLV_ALGO_INPUT_RAM), --have to see how it is
507  ipb_out => ipb_from_slaves(N_SLV_ALGO_INPUT_RAM), -- generated by ipbus
508 
509  rclk => CLK200,
510  Load => Load200,
511  BCNIn => IN_BCN,
512  AlgoIn => IN_Data, -- connected to IN_Data used for data spy
513  we => EnableInputSpy, -- enabled in case of data spy
514  BCNOut => FakeBCN,
515  AlgoOut => FakeInput); -- used to feed data into Algorithm block
516 
517  else generate
518  ipb_from_slaves(N_SLV_ALGO_INPUT_RAM) <= IPB_RBUS_NULL;
519  FakeBCN <= (others => '0');
520  FakeInput <= ZERO_ALGO_INPUT;
521  end generate;
522 
523 
524  OUTPUT_RAM_IF : if USE_OUTPUT_RAMS generate
525 
526  IPBUS_OUTPUT_EG_RAM : entity work.ipbus_outputRAM_wrapper
527  port map (
528  clk_ipb => ipb_clk,
529  rst => ipb_rst,
530  ipb_in => ipb_to_slaves(N_SLV_ALGO_OUTPUT_EG_RAM), --have to see how it is
531  ipb_out => ipb_from_slaves(N_SLV_ALGO_OUTPUT_EG_RAM), -- generated by ipbus
532 
533  BCNIn => BCN_to_output_ram,
534  SpyBCNIn => EnableSpyBCN_eg,
535 
536  rclk => CLK200,
537  Sync => TOB_Start,
538  AlgoIn => to_AlgoOutput(Input_TOBs_eg),
539  we => EnableOutputEgSpy,
540  AlgoOut => FakeEgOutput);
541 
542  IPBUS_OUTPUT_TAU_RAM : entity work.ipbus_outputRAM_wrapper
543  port map (
544  clk_ipb => ipb_clk,
545  rst => ipb_rst,
546  ipb_in => ipb_to_slaves(N_SLV_ALGO_OUTPUT_TAU_RAM), --have to see how it is
547  ipb_out => ipb_from_slaves(N_SLV_ALGO_OUTPUT_TAU_RAM), -- generated by ipbus
548 
549  BCNIn => BCN_to_output_ram,
550  SpyBCNIn => EnableSpyBCN_tau,
551 
552  rclk => CLK200,
553  Sync => TOB_Start,
554  AlgoIn => to_AlgoOutput(Input_TOBs_tau),
555  we => EnableOutputTauSpy,
556  AlgoOut => FakeTauOutput);
557  else generate
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'));
562  end generate;
563 
564 
565  BCN_Delay_internal : entity infrastructure_lib.GeneralDelay
566  generic map (
567  delay => 12,
568  size => 12)
569  port map (
570  clk => CLk200,
571  data_in => BCN200,
572  data_out => BCN_to_output_ram);
573 
574 
575  BCN_Delay_to_Readout : entity infrastructure_lib.GeneralDelay
576  generic map (
577  delay => 24,
578  size => 12)
579  port map (
580  clk => CLk280,
581  data_in => BCN280,
582  data_out => BCNOut);
583 
584  OUT_BCN_TOB <= BCNOut;
585 
586 -- Algor register funcionality
587  EnableFakeAlgoInput <= glob_Control(0);
588  EnableFakeTOBeg <= eg_Control(0);
589  EnableFakeTOBtau <= tau_Control(0);
590 
591 
592  EnableInputSpy <= glob_Control(1);
593  EnableOutputEgSpy <= eg_Control(1);
594  EnableOutputTauSpy <= tau_Control(1);
595 
596  EnableSpyBCN_eg <= eg_Control(2);
597  EnableSpyBCN_tau <= tau_Control(2);
598 
599 
600 -- Algorithm registers connection
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);
605 
606 
607  thr_connection: for i in 29 downto 0 generate
608  NoiseThresholds(i) <= read_reg(i+8);
609  end generate;
610 
611  write_reg(0) <= glob_Position;
612  write_reg(1) <= x"0000000" & '0' & TOB_Counter;
613  write_reg(2) <= x"0000000" & '0' & Count280;
614  write_reg(3) <= (others => '0');
615 
616 -------------------------------------------------------------------------------
617 -- ALGORITHM PARAMETER CONNECTION
618 -------------------------------------------------------------------------------
619 -- Electromagnetic
620  eg_ParReta(0) <= ParRamData(7 downto 0); --ipbus word 0
621  eg_ParReta(1) <= ParRamData(15 downto 8);
622  eg_ParReta(2) <= ParRamData(23 downto 16);
623  eg_DMC_b0 <= ParRamData(31 downto 24);
624 
625  eg_ParWs(0) <= ParRamData(7+32 downto 0+32); --ipbus word 1
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);
629 
630  eg_ParHadron(0) <= ParRamData(7+64 downto 0+64); --ipbus word 2
631  eg_ParHadron(1) <= ParRamData(15+64 downto 8+64);
632  eg_ParHadron(2) <= ParRamData(23+64 downto 16+64);
633  eg_DMC_b2 <= ParRamData(31+64 downto 24+64);
634 
635  eg_Energy_threshold <= ParRamData(15+96 downto 0+96); --ipbus word 3
636  eg_Condition_threshold <= ParRamData(31+96 downto 16+96);
637 
638  tau_ParFrac(0) <= ParRamData(7+128 downto 0+128); --ipbus word 4
639  tau_ParFrac(1) <= ParRamData(15+128 downto 8+128);
640  tau_ParFrac(2) <= ParRamData(23+128 downto 16+128);
641  eg_DMC_b3 <= ParRamData(31+128 downto 24+128);
642 
643 -- Tau
644  tau_ParJet(0) <= ParRamData(7+160 downto 0+160); --ipbus word 5
645  tau_ParJet(1) <= ParRamData(15+160 downto 8+160);
646  tau_ParJet(2) <= ParRamData(23+160 downto 16+160);
647  -- 8 unused bits
648 
649  tau_Energy_threshold <= ParRamData(15+192 downto 0+192); -- ipbus word 6
650  tau_Condition_threshold <= ParRamData(31+192 downto 16+192);
651 
652  tau_BDT_min_energy_threshold <= ParRamData(15+224 downto 0+224); -- ipbus word 7
653  -- 16 unused bits
654 
655 end architecture;
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.
Input Stage Module.
Algo Rate Monitor.
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.
eFEX data-types and functions
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.
Load generator.
Serial sorter module.
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
Input spy/playback RAM for Algorithm block.
IPBus wrapper for output spy/playback RAM for Algorithm module.