CMX
CMX firmware code in-line documentation
 All Classes Namespaces Files Functions Variables
CMX_flavor_package.vhd
Go to the documentation of this file.
1 
9 
10 library IEEE;
11 use IEEE.STD_LOGIC_1164.ALL;
12 use IEEE.NUMERIC_STD.ALL;
13 
14 library work;
15 
16 use work.CMXpackage.all;
18 
20 
21 
22  constant version_flavor_common : std_logic_vector(15 downto 0):=x"F0A2";
23 
24  --from the array types
25  CONSTANT max_tobs_tot : integer := 64;
26  CONSTANT max_tobs_topo : integer := 32;
27  CONSTANT max_jems : integer := 16;
28  CONSTANT max_tobs_pjem : integer := 4;
29  CONSTANT et2_width : integer := 10;
30  CONSTANT et1_width : integer := 9;
31  CONSTANT pos_width : integer := 9;
32  CONSTANT thresholds_num : integer := 25;
33  CONSTANT thresholds_width : integer := 10;
34  constant max_threshold : std_logic_vector((thresholds_width-1) downto 0) := (others => '1');
35  constant max_eta_slices : integer := 4;
36 
37  constant num_presence_bits_pjem : integer :=8;
38 
39 
40  --type arr_RTM_sdr is array(num_RTM_cables-1 downto 0) of std_logic_vector((numbits_in_RTM_connector*2)-1 downto 0);
41 
42  type arr_s0word is array(3 downto 0) of std_logic_vector(12 downto 0);
43  type arr_s1word is array(3 downto 0) of std_logic_vector(10 downto 0);
44 
45  type Low_word is array (integer range <>) of arr_s0word;
46  type High_word is array (integer range <>) of arr_s1word;
47  type num_tobs is array(15 downto 0) of std_logic_vector(3 downto 0);
48  type ntobs_type is array(15 downto 0) of std_logic_vector(2 downto 0);
49  type ptr_sort is array(15 downto 0) of std_logic_vector(6 downto 0);
50  type ptr_presort is array(15 downto 0) of std_logic_vector(3 downto 0);
51  type ptr_jem is array(16 downto 0) of std_logic_vector(6 downto 0);
52  type pos_type is array(15 downto 0) of std_logic_vector(11 downto 0);
53  type thPatG_type is array(integer range <>) of std_logic_vector(120 downto 0);
54 
55  type JetTOB is record
56  Et1 : std_logic_vector (8 downto 0);
57  Et2: std_logic_vector (9 downto 0);
58  pos: std_logic_vector (8 downto 0);
59  end record;
60 
61  type arr_TOB is array (integer range <>) of JetTOB;
62 
63 
64  constant num_copies : integer :=3;
65 
66  type copy_arr_TOB is array (num_copies-1 downto 0) of arr_TOB(max_tobs_topo-1 downto 0);
67 
68  constant num_sort_layers: integer := 21;
69  type type_TOB_sort_layers is array(num_sort_layers-1 downto 0) of arr_TOB(max_tobs_tot-1 downto 0);
70 
71 
72  --this defines position ranges and sizes of the Et1 field in the backplane data
73  type t_arr_addr_Et1 is array(3 downto 0) of integer range 0 to 82;
74  constant arr_addr_Et1_MSword_loc_Hi : t_arr_addr_Et1 := (82,73,51,29);
75  constant arr_addr_Et1_MSword_loc_Lo : t_arr_addr_Et1 := (78,72,48,24);
76  constant arr_addr_Et1_MSword_size : t_arr_addr_Et1 := (5,2,4,6);
77  constant arr_addr_Et1_LSword_loc_Hi : t_arr_addr_Et1 := (77,58,34,10);
78  constant arr_addr_Et1_LSword_loc_Lo : t_arr_addr_Et1 := (74,52,30,8);
79  constant arr_addr_Et1_LSword_size : t_arr_addr_Et1 := (4,7,5,3);
80 
81 
82 
83  type fpos_type is array(integer range <>) of std_logic_vector(19 downto 0);
84  type thPatL_type is array(integer range <>) of std_logic_vector(99 downto 0);
85 
86  type par_type is array(integer range <>) of std_logic;
87 
88  type presortEt2_type is array(integer range <>) of std_logic_vector(39 downto 0);
89  type presortEt1_type is array(integer range <>) of std_logic_vector(35 downto 0);
90  type presortpos_type is array(integer range <>) of std_logic_vector(35 downto 0);
91 
92  constant zero : std_logic:='0';
93  constant frame_16 : std_logic_vector(15 downto 0):=(others => '0');
94  constant frame_17 : std_logic_vector(16 downto 0):=(others => '0');
95  constant frame_18 : std_logic_vector(17 downto 0):=(others => '0');
96 
97 
98  subtype T_SL is std_logic;
99  subtype T_SLV2 is std_logic_vector(1 downto 0);
100  subtype T_SLV3 is std_logic_vector(2 downto 0);
101  subtype T_SLV4 is std_logic_vector(3 downto 0);
102  subtype T_SLV12 is std_logic_vector(11 downto 0);
103  subtype T_SLV13 is std_logic_vector(12 downto 0);
104  subtype T_SLV24 is std_logic_vector(23 downto 0);
105  subtype T_SLV25 is std_logic_vector(24 downto 0);
106  subtype T_SLV30 is std_logic_vector(29 downto 0);
107  subtype T_SLV32 is std_logic_vector(31 downto 0);
108  subtype T_SLV16 is std_logic_vector(15 downto 0);
109  subtype T_SLV60 is std_logic_vector(59 downto 0);
110  subtype T_SLV61 is std_logic_vector(60 downto 0);
111  subtype T_SLV62 is std_logic_vector(61 downto 0);
112  subtype T_SLV65 is std_logic_vector(64 downto 0);
113  subtype T_SLV75 is std_logic_vector(74 downto 0);
114  subtype T_SLV120 is std_logic_vector(119 downto 0);
115  subtype T_SLV121 is std_logic_vector(120 downto 0);
116  subtype T_SLV1936 is std_logic_vector(1935 downto 0);
117 
118 
119  type nx3_array is array (integer range <>) of std_logic_vector ( 2 downto 0);
120  type nx4_array is array(integer range <>) of std_logic_vector(3 downto 0);
121  type nx8_array is array (integer range <>) of std_logic_vector(7 downto 0);
122  type nx13_array is array (integer range <>) of std_logic_vector(12 downto 0);
123  type nx24_array is array (integer range <>) of std_logic_vector(23 downto 0);
124  type nx25_array is array (integer range <>) of std_logic_vector(24 downto 0);
125  type nx26_array is array (integer range <>) of std_logic_vector(25 downto 0);
126  type nx32_array is array (integer range <>) of std_logic_vector(31 downto 0);
127  type nx35_array is array (integer range <>) of std_logic_vector(34 downto 0);
128  type nx60_array is array (integer range <>) of std_logic_vector(59 downto 0);
129  type nx100_array is array(integer range <>) of std_logic_vector(99 downto 0);
130  type nx121_array is array(integer range <>) of std_logic_vector(120 downto 0);
131 
132  type nxmx4_array is array(integer range <>,integer range <> ) of std_logic_vector(3 downto 0);
133 
134  type int_array is array (integer range <>) of integer;
135 
136  type threshold_slice is array(integer range <>) of std_logic_vector(10 downto 0);
137  type threshold_jem is array(integer range <>) of threshold_slice(max_eta_slices-1 downto 0);
138  type threshold_type is array(integer range <>) of threshold_jem(thresholds_num-1 downto 0);
139 
140  type mult_type_a is array (integer range <>) of std_logic_vector(2 downto 0);
141  type mult_type is array (integer range <>) of mult_type_a(24 downto 0);
142 
143  type xsum_type_a is array(integer range <>) of std_logic_vector(3 downto 0);
144  type xsum_type is array(integer range <>) of xsum_type_a(7 downto 0);
145 
146  type totsum_type is array(integer range <>) of integer;
147 
148  constant TO_Jet_Et1_size : integer := 9;
149  constant TO_Jet_Et2_size : integer := 10;
150  -- constant TO_Jet_eta_size : integer := 5;
151  -- constant TO_Jet_phi_size : integer := 5;
152  constant TO_Jet_pos_size : integer := 9;
153 
155  constant Num_TO_Jet : integer := 32;
156 
157 
158  type adder_type is array(15 downto 0) of std_logic_vector(2 downto 0);
159  constant mult_i : adder_type:=("100","011","011","010",
160  "011","010","010","001",
161  "011","010","010","001",
162  "010","001","001","000");
163 
164  type arr_TO_Jet is array (Num_TO_Jet - 1 downto 0) of STD_LOGIC_VECTOR(TO_Jet_size - 1 downto 0);
165 
166 
167  CONSTANT slot11reduced : boolean := false;
168 
169  TYPE del_register_rtm_arr_type is array (num_RTM_cables - 1 downto 0) of del_register_rtm_type;
170 
171 
172  type loc_type_a is array(integer range <>) of std_logic_vector(1 downto 0);
173  type loc_type is array(integer range <>) of loc_type_a(max_tobs_pjem-1 downto 0);
174 
175 
176  type xpos_sort_type is array(15 downto 0) of std_logic_vector(3 downto 0);
177  constant xpos_sort : xpos_sort_type:=("0000","1000","1000","1100",
178  "1000","1100","1100","1110",
179  "1000","1100","1100","1110",
180  "1100","1110","1110","1111");
181 
182 
183  type calc_parity_typa_a is array(integer range <>) of T_SL;
184  type calc_parity_type is array(integer range <>) of calc_parity_typa_a(3 downto 0);
185 
186  type xpos_type is array(integer range <>) of std_logic_vector(3 downto 0);
187 
188 type ofwntobs_type is array(0 to 255) of std_logic_vector(3 downto 0);
190 "0000",
191 "0001",
192 "0001",
193 "0010",
194 "0001",
195 "0010",
196 "0010",
197 "0011",
198 "0001",
199 "0010",
200 "0010",
201 "0011",
202 "0010",
203 "0011",
204 "0011",
205 "0100",
206 "0001",
207 "0010",
208 "0010",
209 "0011",
210 "0010",
211 "0011",
212 "0011",
213 "0100",
214 "0010",
215 "0011",
216 "0011",
217 "0100",
218 "0011",
219 "0100",
220 "0100",
221 "1111",
222 "0001",
223 "0010",
224 "0010",
225 "0011",
226 "0010",
227 "0011",
228 "0011",
229 "0100",
230 "0010",
231 "0011",
232 "0011",
233 "0100",
234 "0011",
235 "0100",
236 "0100",
237 "1111",
238 "0010",
239 "0011",
240 "0011",
241 "0100",
242 "0011",
243 "0100",
244 "0100",
245 "1111",
246 "0011",
247 "0100",
248 "0100",
249 "1111",
250 "0100",
251 "1111",
252 "1111",
253 "1111",
254 "0001",
255 "0010",
256 "0010",
257 "0011",
258 "0010",
259 "0011",
260 "0011",
261 "0100",
262 "0010",
263 "0011",
264 "0011",
265 "0100",
266 "0011",
267 "0100",
268 "0100",
269 "1111",
270 "0010",
271 "0011",
272 "0011",
273 "0100",
274 "0011",
275 "0100",
276 "0100",
277 "1111",
278 "0011",
279 "0100",
280 "0100",
281 "1111",
282 "0100",
283 "1111",
284 "1111",
285 "1111",
286 "0010",
287 "0011",
288 "0011",
289 "0100",
290 "0011",
291 "0100",
292 "0100",
293 "1111",
294 "0011",
295 "0100",
296 "0100",
297 "1111",
298 "0100",
299 "1111",
300 "1111",
301 "1111",
302 "0011",
303 "0100",
304 "0100",
305 "1111",
306 "0100",
307 "1111",
308 "1111",
309 "1111",
310 "0100",
311 "1111",
312 "1111",
313 "1111",
314 "1111",
315 "1111",
316 "1111",
317 "1111",
318 "0001",
319 "0010",
320 "0010",
321 "0011",
322 "0010",
323 "0011",
324 "0011",
325 "0100",
326 "0010",
327 "0011",
328 "0011",
329 "0100",
330 "0011",
331 "0100",
332 "0100",
333 "1111",
334 "0010",
335 "0011",
336 "0011",
337 "0100",
338 "0011",
339 "0100",
340 "0100",
341 "1111",
342 "0011",
343 "0100",
344 "0100",
345 "1111",
346 "0100",
347 "1111",
348 "1111",
349 "1111",
350 "0010",
351 "0011",
352 "0011",
353 "0100",
354 "0011",
355 "0100",
356 "0100",
357 "1111",
358 "0011",
359 "0100",
360 "0100",
361 "1111",
362 "0100",
363 "1111",
364 "1111",
365 "1111",
366 "0011",
367 "0100",
368 "0100",
369 "1111",
370 "0100",
371 "1111",
372 "1111",
373 "1111",
374 "0100",
375 "1111",
376 "1111",
377 "1111",
378 "1111",
379 "1111",
380 "1111",
381 "1111",
382 "0010",
383 "0011",
384 "0011",
385 "0100",
386 "0011",
387 "0100",
388 "0100",
389 "1111",
390 "0011",
391 "0100",
392 "0100",
393 "1111",
394 "0100",
395 "1111",
396 "1111",
397 "1111",
398 "0011",
399 "0100",
400 "0100",
401 "1111",
402 "0100",
403 "1111",
404 "1111",
405 "1111",
406 "0100",
407 "1111",
408 "1111",
409 "1111",
410 "1111",
411 "1111",
412 "1111",
413 "1111",
414 "0011",
415 "0100",
416 "0100",
417 "1111",
418 "0100",
419 "1111",
420 "1111",
421 "1111",
422 "0100",
423 "1111",
424 "1111",
425 "1111",
426 "1111",
427 "1111",
428 "1111",
429 "1111",
430 "0100",
431 "1111",
432 "1111",
433 "1111",
434 "1111",
435 "1111",
436 "1111",
437 "1111",
438 "1111",
439 "1111",
440 "1111",
441 "1111",
442 "1111",
443 "1111",
444 "1111",
445 "1111");
446 
447 type cnt_mult_arr is array(integer range <>) of std_logic_vector(31 downto 0);
448 type cnt_mult_arr_2x16 is array(integer range <>) of std_logic_vector(15 downto 0);
449 
450 
451  procedure Conv3to2
452  ( signal a: in std_logic_vector (2 downto 0);
453  signal b: out std_logic_vector (1 downto 0)) is
454  begin
455  if a(2) = '1' then
456  b <= "11";
457  else
458  b <= a(1 downto 0);
459  end if;
460  end Conv3to2;
461 
462  ----------
463  function add3x2 (
464  a: std_logic_vector (2 downto 0);
465  b: std_logic_vector (2 downto 0)
466  )
467  return std_logic_vector is
468  ----------
469  -- add two 3-bit numbers, return 4-bit sum
470  --
471  variable isum: integer range 0 to 15;
472  variable vsum: std_logic_vector(3 downto 0);
473  ----------
474  begin
475  isum := to_integer(unsigned(a))
476  + to_integer(unsigned(b));
477  vsum := std_logic_vector(to_unsigned(isum,4));
478  return vsum;
479  end add3x2;
480 
481 
482 
483 end CMX_flavor_package;
std_logic_vector (3 downto 0) T_SLV4
array (15 downto 0 ) of std_logic_vector (3 downto 0) ptr_presort
std_logic_vector (12 downto 0) T_SLV13
std_logic_vector (59 downto 0) T_SLV60
array ( integer range<> ) of std_logic_vector (35 downto 0) presortpos_type
t_arr_addr_Et1 := ( 77,58,34,10 ) arr_addr_Et1_LSword_loc_Hi
array (num_copies - 1 downto 0 ) of arr_TOB (max_tobs_topo - 1 downto 0) copy_arr_TOB
std_logic_vector (15 downto 0) T_SLV16
array ( integer range<> ) of std_logic_vector (23 downto 0) nx24_array
array (num_sort_layers - 1 downto 0 ) of arr_TOB (max_tobs_tot - 1 downto 0) type_TOB_sort_layers
array (16 downto 0 ) of std_logic_vector (6 downto 0) ptr_jem
array ( integer range<> ) of std_logic_vector (35 downto 0) presortEt1_type
integer :=21 num_sort_layers
array ( integer range<> , integer range<> ) of std_logic_vector (3 downto 0) nxmx4_array
array ( integer range<> ) of std_logic_vector (24 downto 0) nx25_array
array ( integer range<> ) of std_logic_vector (39 downto 0) presortEt2_type
array ( integer range<> ) of std_logic calc_parity_typa_a
std_logic_vector (15 downto 0) :=x"F0A5" version_flavor_common
integer :=25 thresholds_num
t_arr_addr_Et1 := ( 78,72,48,24 ) arr_addr_Et1_MSword_loc_Lo
array ( integer range<> ) of std_logic_vector (3 downto 0) xpos_type
array ( integer range<> ) of std_logic_vector (59 downto 0) nx60_array
array ( integer range<> ) of std_logic_vector (3 downto 0) xsum_type_a
integer :=10 thresholds_width
std_logic_vector (2 downto 0) T_SLV3
Et1:std_logic_vector (8 downto 0)# Et2:std_logic_vector (9 downto 0)# pos:std_logic_vector (8 downto 0)# JetTOBrecordEt1:std_logic_vector%(8%%%downto%%%0)#%%Et2:std_logic_vector%(9%%%downto%%%0)#%pos:std_logic_vector%(8%%%downto%%%0)#
_library_ workwork
array (0 to 255 ) of std_logic_vector (3 downto 0) ofwntobs_type
std_logic_vector (60 downto 0) T_SLV61
t_arr_addr_Et1 := ( 5,2,4,6 ) arr_addr_Et1_MSword_size
std_logic_vector (31 downto 0) T_SLV32
t_arr_addr_Et1 := ( 4,7,5,3 ) arr_addr_Et1_LSword_size
t_arr_addr_Et1 := ( 74,52,30,8 ) arr_addr_Et1_LSword_loc_Lo
array ( integer range<> ) of threshold_slice (max_eta_slices - 1 downto 0) threshold_jem
array ( integer range<> ) of std_logic_vector (10 downto 0) threshold_slice
std_logic_vector (120 downto 0) T_SLV121
std_logic_vector (11 downto 0) T_SLV12
array ( integer range<> ) of std_logic_vector (120 downto 0) thPatG_type
std_logic_vector (17 downto 0) :=( others =>'0' ) frame_18
array ( integer range<> ) of std_logic_vector (31 downto 0) cnt_mult_arr
array (15 downto 0 ) of std_logic_vector (6 downto 0) ptr_sort
array ( integer range<> ) of std_logic_vector (2 downto 0) mult_type_a
array ( integer range<> ) of std_logic_vector (31 downto 0) nx32_array
array (num_RTM_cables - 1 downto 0 ) of del_register_rtm_type del_register_rtm_arr_type
array ( integer range<> ) of std_logic_vector (2 downto 0) nx3_array
std_logic :='0' zero
array (3 downto 0 ) of integer range 0 to 82 t_arr_addr_Et1
std_logic_vector (23 downto 0) T_SLV24
array (15 downto 0 ) of std_logic_vector (3 downto 0) num_tobs
boolean :=false slot11reduced
std_logic_vector (24 downto 0) T_SLV25
std_logic_vector (119 downto 0) T_SLV120
array ( integer range<> ) of std_logic_vector (12 downto 0) nx13_array
array ( integer range<> ) of std_logic_vector (99 downto 0) nx100_array
std_logic_vector ((thresholds_width - 1) downto 0) :=( others =>'1' ) max_threshold
array ( integer range<> ) of arr_s1word High_word
_library_ ieeeieee
array ( integer range<> ) of std_logic_vector (99 downto 0) thPatL_type
array (3 downto 0 ) of std_logic_vector (15 downto 0) arr_s0word
std_logic_vector (64 downto 0) T_SLV65
array ( integer range<> ) of xsum_type_a (7 downto 0) xsum_type
array ( integer range<> ) of std_logic par_type
integer :=32 max_tobs_topo
std_logic_vector (61 downto 0) T_SLV62
adder_type := ( "100","011","011","010","011","010","010","001","011","010","010","001","010","001","001","000" ) mult_i
integer :=8 num_presence_bits_pjem
array (15 downto 0 ) of std_logic_vector (3 downto 0) xpos_sort_type
ofwntobs_type := ( "0000","0001","0001","0010","0001","0010","0010","0011","0001","0010","0010","0011","0010","0011","0011","0100","0001","0010","0010","0011","0010","0011","0011","0100","0010","0011","0011","0100","0011","0100","0100","1111","0001","0010","0010","0011","0010","0011","0011","0100","0010","0011","0011","0100","0011","0100","0100","1111","0010","0011","0011","0100","0011","0100","0100","1111","0011","0100","0100","1111","0100","1111","1111","1111","0001","0010","0010","0011","0010","0011","0011","0100","0010","0011","0011","0100","0011","0100","0100","1111","0010","0011","0011","0100","0011","0100","0100","1111","0011","0100","0100","1111","0100","1111","1111","1111","0010","0011","0011","0100","0011","0100","0100","1111","0011","0100","0100","1111","0100","1111","1111","1111","0011","0100","0100","1111","0100","1111","1111","1111","0100","1111","1111","1111","1111","1111","1111","1111","0001","0010","0010","0011","0010","0011","0011","0100","0010","0011","0011","0100","0011","0100","0100","1111","0010","0011","0011","0100","0011","0100","0100","1111","0011","0100","0100","1111","0100","1111","1111","1111","0010","0011","0011","0100","0011","0100","0100","1111","0011","0100","0100","1111","0100","1111","1111","1111","0011","0100","0100","1111","0100","1111","1111","1111","0100","1111","1111","1111","1111","1111","1111","1111","0010","0011","0011","0100","0011","0100","0100","1111","0011","0100","0100","1111","0100","1111","1111","1111","0011","0100","0100","1111","0100","1111","1111","1111","0100","1111","1111","1111","1111","1111","1111","1111","0011","0100","0100","1111","0100","1111","1111","1111","0100","1111","1111","1111","1111","1111","1111","1111","0100","1111","1111","1111","1111","1111","1111","1111","1111","1111","1111","1111","1111","1111","1111","1111" ) ofwntobs
array ( integer range<> ) of threshold_jem (thresholds_num - 1 downto 0) threshold_type
array ( integer range<> ) of std_logic_vector (19 downto 0) fpos_type
array (3 downto 0 ) of std_logic_vector (7 downto 0) arr_s1word
xpos_sort_type := ( "0000","1000","1000","1100","1000","1100","1100","1110","1000","1100","1100","1110","1100","1110","1110","1111" ) xpos_sort
integer :=10 TO_Jet_Et2_size
array (15 downto 0 ) of std_logic_vector (2 downto 0) adder_type
array ( integer range<> ) of integer totsum_type
array ( integer range<> ) of integer int_array
array ( integer range<> ) of calc_parity_typa_a (3 downto 0) calc_parity_type
array ( integer range<> ) of std_logic_vector (3 downto 0) nx4_array
array ( integer range<> ) of std_logic_vector (25 downto 0) nx26_array
t_arr_addr_Et1 := ( 82,73,51,29 ) arr_addr_Et1_MSword_loc_Hi
array ( integer range<> ) of std_logic_vector (34 downto 0) nx35_array
array ( integer range<> ) of std_logic_vector (7 downto 0) nx8_array
array ( integer range<> ) of loc_type_a (max_tobs_pjem - 1 downto 0) loc_type
integer :=TO_Jet_Et1_size + TO_Jet_Et2_size + TO_Jet_pos_size TO_Jet_size
array ( integer range<> ) of JetTOB arr_TOB
std_logic_vector (74 downto 0) T_SLV75
std_logic_vector (15 downto 0) :=( others =>'0' ) frame_16
std_logic_vector (16 downto 0) :=( others =>'0' ) frame_17
array ( integer range<> ) of arr_s0word Low_word
array ( integer range<> ) of mult_type_a (24 downto 0) mult_type
array (15 downto 0 ) of std_logic_vector (2 downto 0) ntobs_type
array (15 downto 0 ) of std_logic_vector (11 downto 0) pos_type
array ( integer range<> ) of std_logic_vector (120 downto 0) nx121_array
array ( integer range<> ) of std_logic_vector (1 downto 0) loc_type_a
std_logic_vector (1 downto 0) T_SLV2
array ( integer range<> ) of std_logic_vector (15 downto 0) cnt_mult_arr_2x16
array (Num_TO_Jet - 1 downto 0 ) of STD_LOGIC_VECTOR (TO_Jet_size - 1 downto 0) arr_TO_Jet
std_logic_vector (29 downto 0) T_SLV30
std_logic_vector (1935 downto 0) T_SLV1936