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

Back to eFEX documentation
TopAlgoModule.vhd
Go to the documentation of this file.
1 
11 
12 library IEEE;
13 use IEEE.STD_LOGIC_1164.all;
14 use IEEE.NUMERIC_STD.all;
15 
16 library work;
17 use work.DataTypes.all;
18 use work.AlgoDataTypes.all;
19 
21 entity TopAlgoModule is
22  generic (
23  EG_ALGO_VERSION : std_logic_vector(1 downto 0) := "00";
24  TAU_ALGO_VERSION : std_logic_vector(1 downto 0) := "00"
25  );
26  port (CLK200 : in std_logic;
27 
28  IN_Load : in std_logic;
29  IN_Data : in TriggerTowerMatrix;
30 
31  --control ports
32  OUT_ParameterRAMaddress : out std_logic_vector(2 downto 0);
33 
34  --configuration ports
36  IN_eg_ParWs : in AlgoParameters(2 downto 0);
38  IN_eg_ParREta : in AlgoParameters(2 downto 0);
40  IN_eg_ParHadron : in AlgoParameters(2 downto 0);
42  IN_eg_Control : in AlgoRegister;
44  IN_eg_Energy_threshold : in DataWord;
46  IN_eg_Cond_threshold : in DataWord;
47 
49  IN_ParDeadMat_b0 : in AlgoParameter;
50  IN_ParDeadMat_b1 : in AlgoParameter;
51  IN_ParDeadMat_b2 : in AlgoParameter;
52  IN_ParDeadMat_b3 : in AlgoParameter;
53 
55  OUT_eg_Status : out AlgoRegister;
56 
58  IN_tau_ParJet : in AlgoParameters(2 downto 0);
59  IN_tau_ParFrac : in AlgoParameters(2 downto 0);
60 
61  IN_tau_Control : in AlgoRegister;
64  IN_tau_Energy_threshold : in DataWord;
66  IN_tau_Cond_threshold : in DataWord;
69 
70  OUT_tau_Status : out AlgoRegister;
71 
74  IN_glob_Position : in AlgoRegister := (others => '0');
75  IN_glob_Control : in AlgoRegister := (others => '0');
76  OUT_glob_Status : out AlgoRegister;
77 
78  -- Output sync ports
79  OUT_TOB_Start : out std_logic;
80  OUT_TOB_Counter : out std_logic_vector(2 downto 0);
81 
82  -- out ports eg
83  OUT_eg_TOB : out TriggerObjects_eg(OUTPUT_TOBS-1 downto 0);
84 
85  -- out ports tau
86  OUT_tau_TOB : out TriggerObjects_tau(OUTPUT_TOBS-1 downto 0));
87 
88 end TopAlgoModule;
89 
91 architecture Behavioral of TopAlgoModule is
92 
93  signal OutEgTOB : TriggerObjects_eg(OUTPUT_TOBS-1 downto 0);
94 
95  signal OutTauTOB : TriggerObjects_tau(OUTPUT_TOBS-1 downto 0);
96 
97 -- Data Shift Register
98  signal SR_InData : TriggerTowerMatrix;
99  signal SR_Load : std_logic;
100  signal SR_LeftRight, SR_Edge : std_logic;
101  signal SR_OutData : TriggerTowers(29 downto 0);
102 
103 
104 -- e/gamma
105  signal eg_ParWs : AlgoParameters(2 downto 0);
106  signal eg_ParReta : AlgoParameters(2 downto 0);
107  signal eg_ParHadron : AlgoParameters(2 downto 0);
108  signal eg_Control : AlgoRegister;
109  signal eg_Status : AlgoRegister;
110  -- AlgoCores Towers in AC
111  signal eg_Data : TriggerTowersArray(7 downto 0)(8 downto 0);
112  signal eg_TOB : TriggerObjects_eg(7 downto 0);
113 
114  -- tau
115  signal tau_ParJet : AlgoParameters(2 downto 0);
116  signal tau_ParFrac : AlgoParameters(2 downto 0);
117 
118  signal tau_Control : AlgoRegister;
119  signal tau_Status : AlgoRegister;
120  -- AlgoCores Towers in AC
121  signal tau_Data : TriggerTowersArray(7 downto 0)(8 downto 0);
122  signal tau_TOB : TriggerObjects_tau(7 downto 0);
123 
124  signal RAMCounter : std_logic_vector(2 downto 0) := (others => '0');
125  signal InputCounter : std_logic_vector(2 downto 0) := (others => '0');
126  signal OutputCounter : std_logic_vector(2 downto 0) := (others => '0');
127  signal OutputValid : std_logic;
128 
129 -- ####### Mark signals ########
130  attribute keep : string ;
131  attribute max_fanout : integer;
132  attribute keep of OutputValid : signal is "true" ;
133  attribute max_fanout of OutputValid : signal is 80;
134 
135 begin
136  OUT_eg_Status <= x"a000e100";
137  OUT_tau_Status <= x"a0007a00";
138  OUT_glob_Status <= x"a0008100";
139 
140  -- Parameters connection
141  eg_ParWs <= IN_eg_ParWs;
142  eg_ParReta <= IN_eg_ParReta;
143  eg_ParHadron <= IN_eg_ParHadron;
144  eg_Control <= IN_eg_Control;
145  tau_ParJet <= IN_tau_ParJet;
146  tau_parFrac <= IN_tau_ParFrac;
147 
148  tau_Control <= IN_tau_Control;
149 
150 -- Boolean to specify if eFEX FPGA is on the edge i.e. handles 5 eta columns - or not.
151  SR_Edge <= IN_glob_Position(EM_POSITION_ETA_ON_EDGE);
152 -- Boolean to specify if eFEX FPGA is on the left edge (small eta) or right edge (high eta). Useless if the previous one is 0.
153  SR_LeftRight <= IN_glob_Position(EM_POSITION_ETA_ON_LEFT_EDGE);
154 
155 
156  COUNTERS : process (clk200)
157  begin
158  if rising_edge(clk200) then
159  if IN_Load = '1' then
160  -- reset values will determine the offesets
161  InputCounter <= "001"; --1 should always be one, it is used only as REFERENCE
162  RAMCounter <= "100"; --3, +3 after test with Steve
163  OutputCounter <= "011"; --3
164  else
165  -- increment
166  if InputCounter = "100" then
167  InputCounter <= "000";
168  else
169  InputCounter <= std_logic_vector(unsigned(InputCounter) + 1);
170  end if;
171 
172  if RAMCounter = "100" then
173  RAMCounter <= "000";
174  else
175  RAMCounter <= std_logic_vector(unsigned(RAMCounter) + 1);
176  end if;
177 
178  if OutputCounter = "100" then
179  OutputCounter <= "000";
180  else
181  OutputCounter <= std_logic_vector(unsigned(OutputCounter) + 1);
182  end if;
183  end if;
184  end if;
185  end process;
186 
187  OUTPUT_SIGNALS_PROCESS : process (clk200)
188  begin
189  if rising_edge(clk200) then
190  if OutputCounter = "100" then
191  OUT_TOB_Start <= '1';
192  else
193  OUT_TOB_Start <= '0';
194  end if;
195 
196  -- TOBs on the first 4 clock cycles are valid, while the 5th is valid only if eFEX is on eta edge
197  if OutputCounter = "011" and SR_Edge = '0' then
198  OutputValid <= '0';
199  else
200  OutputValid <= '1';
201  end if;
202 
203  end if;
204  end process;
205 
206  OUT_TOB_Counter <= OutputCounter;
207  OUT_ParameterRAMaddress <= RAMCounter;
208 
209  SR_InData <= IN_Data;
210  SR_Load <= IN_Load;
211 
212  DATA_SHIFT_REGISTER : entity work.AlgoShiftRegister
213  port map (
214  CLK200 => clk200,
215  IN_Load => SR_Load,
216  IN_Data => SR_INData,
217  IN_Edge => SR_Edge,
218  IN_LeftRight => SR_LeftRight,
219  OUT_Data => SR_OutData);
220 
221 
222  ALGO_GENERATION : for i in 0 to 7 generate
223 -- eg mapping
224  eg_Data(i) <= (6 => SR_OutData(i+02), 7 => SR_OutData(i+12), 8 => SR_OutData(i+22),
225  3 => SR_OutData(i+01), 4 => SR_OutData(i+11), 5 => SR_OutData(i+21),
226  0 => SR_OutData(i+00), 1 => SR_OutData(i+10), 2 => SR_OutData(i+20));
227 
228  AGLO_CORE_EG : entity work.AlgoCore_eg
229  generic map(
230  EG_ALGO_VERSION => EG_ALGO_VERSION)
231  port map (
232  CLK200 => clk200,
233  IN_ParWs => eg_ParWs,
234  IN_ParReta => eg_ParReta,
235  IN_ParHadron => eg_ParHadron,
236  IN_glob_Position => IN_glob_Position,
237  IN_Energy_threshold => IN_eg_Energy_threshold,
238  IN_Cond_threshold => IN_eg_cond_threshold,
239 
241  IN_ParDeadMat_b1 => IN_ParDeadMat_b1,
242  IN_ParDeadMat_b2 => IN_ParDeadMat_b2,
243  IN_ParDeadMat_b3 => IN_ParDeadMat_b3,
244 
245  IN_Data => eg_Data(i),
246  OUT_TOB => eg_TOB(i));
247 
248 -- tau mapping
249  tau_Data(i) <= (6 => SR_OutData(i+02), 7 => SR_OutData(i+12), 8 => SR_OutData(i+22),
250  3 => SR_OutData(i+01), 4 => SR_OutData(i+11), 5 => SR_OutData(i+21),
251  0 => SR_OutData(i+00), 1 => SR_OutData(i+10), 2 => SR_OutData(i+20));
252 
253 -- tau core (temporary: eg)
254  TAU_ALGO: if TAU_ALGO_VERSION = "01" or TAU_ALGO_VERSION = "10" generate
255  AGLO_CORE_TAU_BDT : entity work.AlgoCore_tau_bdt
256  generic map(
257  TAU_ALGO_VERSION => TAU_ALGO_VERSION)
258  port map (
259  CLK200 => clk200,
260  IN_ParBDT => tau_ParJet,
261  IN_ParFrac => tau_ParFrac,
262  IN_Min_E_threshold => IN_tau_Energy_threshold,
263  IN_Min_BDT_E_threshold => IN_tau_BDT_min_energy_threshold,
264  IN_Max_cond_E_threshold => IN_tau_cond_threshold,
265  IN_Data => tau_Data(i),
266  OUT_TOB => tau_TOB(i));
267  else generate
268  AGLO_CORE_TAU : entity work.AlgoCore_tau
269  port map (
270  CLK200 => clk200,
271  IN_ParJet => tau_ParJet,
272  IN_ParFrac => tau_ParFrac,
273  IN_Energy_threshold => IN_tau_Energy_threshold,
274  IN_Cond_threshold => IN_tau_cond_threshold,
275  IN_Data => tau_Data(i),
276  OUT_TOB => tau_TOB(i));
277  end generate;
278  end generate ALGO_GENERATION;
279 
280 
281 -- Invalidate TOBs at eta=4 if the eFEX is not on edge
282  EG_OUT_FOR : for i in 0 to OUT_eg_TOB'high generate
283  OUT_eg_TOB(i).Position <= eg_TOB(i).Position;
284  OUT_eg_TOB(i).Core <= eg_TOB(i).Core when OutputValid = '1' else invalidate_core(eg_TOB(i).Core);
285  end generate;
286 
287  TAU_OUT_FOR : for i in 0 to OUT_tau_TOB'high generate
288  OUT_tau_TOB(i).Position <= tau_TOB(i).position;
289  OUT_tau_TOB(i).Core <= tau_TOB(i).Core when OutputValid = '1' else invalidate_core(tau_TOB(i).Core);
290  end generate;
291 
292 end Behavioral;
Core of the electromagnetic algorithm.
Definition: AlgoCore_eg.vhd:49
in IN_ParDeadMat_b0 AlgoParameter
enable bit mask for material correction
Definition: AlgoCore_eg.vhd:61
Core of the electromagnetic algorithm.
Core of the electromagnetic algorithm.
External data-types and functions.
Algorithm input-data shift register.
in CLK200 std_logic
200 MHz clock
in IN_Edge std_logic
Signal indicating if eFEX is on edge position.
in IN_Load std_logic
In load signal, synch with data arrival.
in IN_LeftRight std_logic
Signal indicating if eFEX module position.
in IN_Data TriggerTowerMatrix
All TT input data defined in DataTypes.vhd.
out OUT_Data TriggerTowers( 3* INPUT_ROWS- 1 downto 0)
Output data to be fed to algorithm logic (3 columns)
Top feature-extracting algorithm module.
Top feature-extracting algorithm module.
in IN_tau_Cond_threshold DataWord
Energy threshold for Jet and Frac condition;.
in IN_eg_ParREta AlgoParameters( 2 downto 0)
Thresholds for specific condition taken from parameter RAM.
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