CMX
CMX firmware code in-line documentation
 All Classes Namespaces Files Functions Variables
system_summing_module.vhd
Go to the documentation of this file.
1 
5 
6 library IEEE;
7 
8 use ieee.std_logic_1164.all;
9 use ieee.numeric_std.all;
10 use work.CMX_flavor_package.all;
11 use work.CMXpackage.all;
12 use work.CMX_VME_defs.all;
13 
15  port (
16  CLK : in std_logic;
17 
18  ENERGY_CRATE : in std_logic_vector(26*4-1 downto 0);
19  ENERGY_REMOTE : in std_logic_vector(26*4-1 downto 0);
20  CTP_CABLE_0 : out std_logic_vector(23 downto 0);
21  CTP_CABLE_1 : out std_logic_vector(23 downto 0);
22 
23  -- thresholds
24  MISS_E_THR : in arr_ctr_31bit(num_thresholds-1 downto 0);
25  MISS_E_RES_THR : in arr_ctr_31bit(num_thresholds-1 downto 0);
26  SUM_ET_THR : in arr_ctr_15bit(num_thresholds-1 downto 0);
27  SUM_ET_RES_THR : in arr_ctr_15bit(num_thresholds-1 downto 0);
28  XS_T2_A2 : in arr_ctr_31bit(num_thresholds-1 downto 0);
29  -- parameters
30  T_MISS_E_MIN : in arr_ctr_31bit(num_thresholds-1 downto 0);
31  T_MISS_E_MAX : in arr_ctr_31bit(num_thresholds-1 downto 0);
32  T_SUM_E_MIN : in arr_ctr_15bit(num_thresholds-1 downto 0);
33  T_SUM_E_MAX : in arr_ctr_15bit(num_thresholds-1 downto 0);
34  XS_B2 : in arr_ctr_15bit(num_thresholds-1 downto 0);
35 
36  sums_all_out : out arr_ctr_15bit(5 downto 0);
37  ov_all_out : out std_logic_vector(5 downto 0);
38 
39  par_err_cbl : in T_SL; -- parity error local
40  force : in T_SL; -- force
41 
42  --VME
43  ncs : in std_logic;
44  rd_nwr : in std_logic;
45  ds : in std_logic;
46  addr_vme : in std_logic_vector (15 downto 0);
47  data_vme_in : in std_logic_vector (15 downto 0);
48  data_vme_out : out std_logic_vector (15 downto 0);
49  bus_drive : out std_logic
50  );
51 end system_summing_module;
52 
54  signal energy_crate_delayed : std_logic_vector(ENERGY_CRATE'range);
55  signal energy_crate_delayed_l, energy_remote_l : std_logic_vector(15*6+6-1 downto 0);
56  signal sums_all : sum_array;
57  signal ov_all : std_logic_vector(5 downto 0) := (others => '0');
58 
59  signal miss_map, res_miss_map, sumet_map, res_sumet_map : std_logic_vector(7 downto 0);
60  signal xs_map: std_logic_vector(7 downto 0);
61 
62 
63 
64  signal EX_local : signed(max_bits_ExEy-1 downto 0);
65  signal EY_local : signed(max_bits_ExEy-1 downto 0);
66  signal TE_local : unsigned(max_bits_TE-1 downto 0);
67  signal EX_res_local : signed(max_bits_ExEy-1 downto 0);
68  signal EY_res_local : signed(max_bits_ExEy-1 downto 0);
69  signal TE_res_local : unsigned(max_bits_TE-1-1 downto 0); --the partial sums
70  --are 14 bits
71  signal ov_EX_local : std_logic;
72  signal ov_EY_local : std_logic;
73  signal ov_TE_local : std_logic;
74  signal ov_EX_res_local : std_logic;
75  signal ov_EY_res_local : std_logic;
76  signal ov_TE_res_local : std_logic;
77 
78  signal ov_EX_local_r : std_logic;
79  signal ov_EY_local_r : std_logic;
80  signal ov_TE_local_r : std_logic;
81  signal ov_EX_res_local_r : std_logic;
82  signal ov_EY_res_local_r : std_logic;
83  signal ov_TE_res_local_r : std_logic;
84 
85 
86  signal EX_remote : signed(max_bits_ExEy-1 downto 0);
87  signal EY_remote : signed(max_bits_ExEy-1 downto 0);
88  signal TE_remote : unsigned(max_bits_TE-1 downto 0);
89  signal EX_res_remote : signed(max_bits_ExEy-1 downto 0);
90  signal EY_res_remote : signed(max_bits_ExEy-1 downto 0);
91  signal TE_res_remote : unsigned(max_bits_TE-1-1 downto 0);
92 
93  signal ov_EX_remote : std_logic;
94  signal ov_EY_remote : std_logic;
95  signal ov_TE_remote : std_logic;
96  signal ov_EX_res_remote : std_logic;
97  signal ov_EY_res_remote : std_logic;
98  signal ov_TE_res_remote : std_logic;
99 
100  signal ov_EX_remote_r : std_logic;
101  signal ov_EY_remote_r : std_logic;
102  signal ov_TE_remote_r : std_logic;
103  signal ov_EX_res_remote_r : std_logic;
104  signal ov_EY_res_remote_r : std_logic;
105  signal ov_TE_res_remote_r : std_logic;
106 
107 
108  signal EX_total : signed(max_bits_ExEy downto 0); --one bit over, will be trimmed...
109  signal EY_total : signed(max_bits_ExEy downto 0);
110 
111  signal TE_total : unsigned(max_bits_TE-1 downto 0);
112 
113 
114  signal EX_res_total : signed(max_bits_ExEy downto 0); --one bit over, will be trimmed...
115  signal EY_res_total : signed(max_bits_ExEy downto 0);
116 
117  signal TE_res_total : unsigned(max_bits_TE-1 downto 0);
118 
119 
120  signal EX_total_trunc : signed(max_bits_ExEy-1 downto 0);
121  signal EY_total_trunc : signed(max_bits_ExEy-1 downto 0);
122 
123  signal EX_res_total_trunc : signed(max_bits_ExEy-1 downto 0);
124  signal EY_res_total_trunc : signed(max_bits_ExEy-1 downto 0);
125 
126 
127  signal ov_EX_sum : std_logic;
128  signal ov_EY_sum : std_logic;
129 
130  signal ov_EX_res_sum : std_logic;
131  signal ov_EY_res_sum : std_logic;
132 
133 
134  signal ov_EX : std_logic;
135  signal ov_EY : std_logic;
136  signal ov_TE : std_logic;
137 
138  signal ov_EX_res : std_logic;
139  signal ov_EY_res : std_logic;
140  signal ov_TE_res : std_logic;
141 
142  signal EX_total_abs : unsigned(max_bits_ExEy-1 downto 0);
143  signal EY_total_abs : unsigned(max_bits_ExEy-1 downto 0);
144 
145  signal EX_res_total_abs : unsigned(max_bits_ExEy-1 downto 0);
146  signal EY_res_total_abs : unsigned(max_bits_ExEy-1 downto 0);
147 
148  signal EX2 : unsigned(max_bits_ExEy*2 -1 downto 0);
149  signal EY2 : unsigned(max_bits_ExEy*2 -1 downto 0);
150 
151  signal EX2_res : unsigned(max_bits_ExEy*2 -1 downto 0);
152  signal EY2_res : unsigned(max_bits_ExEy*2 -1 downto 0);
153 
154  signal ov_EX_r : std_logic;
155  signal ov_EY_r : std_logic;
156  signal ov_EX_rr : std_logic;
157  signal ov_EY_rr : std_logic;
158 
159  signal ov_EX_res_r : std_logic;
160  signal ov_EY_res_r : std_logic;
161  signal ov_EX_res_rr : std_logic;
162  signal ov_EY_res_rr : std_logic;
163 
164  --the missing energy squared
165  signal XE2 : unsigned(max_bits_XE2-1 downto 0);
166  signal XE2_res : unsigned(max_bits_XE2-1 downto 0);
167 
168  signal s_XE2 : signed(max_bits_XE2 downto 0);
169 
170  signal T2_A2_B2 : arr_ctr_46bit(num_thresholds-1 downto 0);
171  signal T4_A4 : arr_ctr_62bit(num_thresholds-1 downto 0);
172  signal T4_A4_B2 : arr_ctr_77bit(num_thresholds-1 downto 0);
173 
174  signal us_T4_A4_B2_TE : arr_ctr_92bit(num_thresholds-1 downto 0);
175  signal X4_T4_A4_B2_TE : arr_sig_95bit(num_thresholds-1 downto 0);
176  signal X4_T4_A4_B2_TE_r : arr_sig_95bit(num_thresholds-1 downto 0);
177  signal X4_T4_A4_B2_TE_rr : arr_sig_95bit(num_thresholds-1 downto 0);
178  signal X4_T4_A4_B2_TE_rrr : arr_sig_95bit(num_thresholds-1 downto 0);
179 
180  signal T2_A2_TE : arr_ctr_47bit(num_thresholds-1 downto 0);
181 
182  signal us_T2_A2_TE_PLUS_T2_A2_B2 : arr_ctr_47bit(num_thresholds-1 downto 0);
183  signal T2_A2_TE_PLUS_T2_A2_B2 : arr_sig_49bit(num_thresholds-1 downto 0);
184 
185  signal T2_A2_TE_PLUS_T2_A2_B2_MINUS_XE2 : arr_sig_49bit(num_thresholds-1 downto 0);
186 
187  signal T2_A2_TE_PLUS_T2_A2_B2_MINUS_XE2_ALL2 : arr_sig_98bit(num_thresholds-1 downto 0);
188 
189 
190 
191  --criterion signal missing ET
192  signal c_XE : std_logic_vector(num_thresholds-1 downto 0);
193  signal c_XE_res : std_logic_vector(num_thresholds-1 downto 0);
194 
195  --register to align with TE and XS
196  signal c_XE_r : std_logic_vector(num_thresholds-1 downto 0);
197  signal c_XE_res_r : std_logic_vector(num_thresholds-1 downto 0);
198  signal c_XE_rr : std_logic_vector(num_thresholds-1 downto 0);
199  signal c_XE_res_rr : std_logic_vector(num_thresholds-1 downto 0);
200 
201  --delayed parity error flag to sync with the logic
202  signal par_err_cbl_l : std_logic;
203  signal par_err_cbl_l_0 : std_logic;
204  signal par_err_cbl_l_r : std_logic;
205  signal par_err_cbl_l_rr : std_logic;
206  signal par_err_cbl_l_rrr : std_logic;
207  signal par_err_cbl_l_rrrr : std_logic;
208  signal par_err_cbl_l_rrrrr : std_logic;
209 
210 
211  --criterion for sum ET
212  signal c_TE : std_logic_vector(num_thresholds-1 downto 0);
213  signal c_TE_res : std_logic_vector(num_thresholds-1 downto 0);
214 
215  --register to align with missing ET and XS
216  signal c_TE_r : std_logic_vector(num_thresholds-1 downto 0);
217  signal c_TE_res_r : std_logic_vector(num_thresholds-1 downto 0);
218  signal c_TE_rr : std_logic_vector(num_thresholds-1 downto 0);
219  signal c_TE_res_rr : std_logic_vector(num_thresholds-1 downto 0);
220  signal c_TE_rrr : std_logic_vector(num_thresholds-1 downto 0);
221  signal c_TE_res_rrr : std_logic_vector(num_thresholds-1 downto 0);
222  signal c_TE_rrrr : std_logic_vector(num_thresholds-1 downto 0);
223  signal c_TE_res_rrrr : std_logic_vector(num_thresholds-1 downto 0);
224 
225 
226 
227  --criterion signals for missing energy significance
228  signal c_XS_0 : std_logic_vector(num_thresholds-1 downto 0);
229  signal c_XS_1 : std_logic_vector(num_thresholds-1 downto 0);
230  signal c_XS_2 : std_logic_vector(num_thresholds-1 downto 0);
231  signal c_XS_3 : std_logic_vector(num_thresholds-1 downto 0);
232  signal c_XS_4A : std_logic_vector(num_thresholds-1 downto 0);
233  signal c_XS_4A_r : std_logic_vector(num_thresholds-1 downto 0);
234  signal c_XS_4B : std_logic_vector(num_thresholds-1 downto 0);
235 
236  signal c_XS_0_r : std_logic_vector(num_thresholds-1 downto 0);
237  signal c_XS_1_r : std_logic_vector(num_thresholds-1 downto 0);
238  signal c_XS_0_rr : std_logic_vector(num_thresholds-1 downto 0);
239  signal c_XS_1_rr : std_logic_vector(num_thresholds-1 downto 0);
240 
241  signal c_XS_2_r : std_logic_vector(num_thresholds-1 downto 0);
242  signal c_XS_3_r : std_logic_vector(num_thresholds-1 downto 0);
243  signal c_XS_2_rr : std_logic_vector(num_thresholds-1 downto 0);
244  signal c_XS_3_rr : std_logic_vector(num_thresholds-1 downto 0);
245  signal c_XS_2_rrr : std_logic_vector(num_thresholds-1 downto 0);
246  signal c_XS_3_rrr : std_logic_vector(num_thresholds-1 downto 0);
247  signal c_XS_2_rrrr : std_logic_vector(num_thresholds-1 downto 0);
248  signal c_XS_3_rrrr : std_logic_vector(num_thresholds-1 downto 0);
249 
250 
251 
252  signal bus_drive_local : std_logic_vector(0 downto 0);
253  signal data_vme_out_local : arr_16(0 downto 0);
254 
255  constant gnd32: std_logic_vector(31 downto 0):=x"00000000";
256  constant ones32: std_logic_vector(31 downto 0):=x"FFFFFFFF";
257 
258 begin
259 
260  CMX_PIPELINE_MODULE_INST : entity work.CMX_pipeline_module
261  generic map (
262  ADDR_REG_RW_PIPELINE_DELAY_LENGTH => ADDR_REG_RW_DELAY_INPUT_DATA_ADDER)
263  port map (
264  clk => CLK,
265  din => ENERGY_CRATE ,
267  ncs => ncs,
268  rd_nwr => rd_nwr,
269  ds => ds,
270  addr_vme => addr_vme,
271  data_vme_in => data_vme_in,
272  data_vme_out => data_vme_out,
273  bus_drive => bus_drive
274  );
275  --energy_crate_delayed <= ENERGY_CRATE;
276  energy_crate_delayed_l <= crate_cable_in(energy_crate_delayed);
277  --register the remote data in the system domain
278  process(CLK)
279  begin
280  if rising_edge(CLK) then
281  energy_remote_l <= crate_cable_in(ENERGY_REMOTE);
283  end if;
284  end process;
285 
286  --decipher the remote and local quantities and overflows
287  EX_local<=signed(energy_crate_delayed_l(14 downto 0));
288  EY_local<=signed(energy_crate_delayed_l(29 downto 15));
289  TE_local<=unsigned('0'&energy_crate_delayed_l(43 downto 30)); --14 bits!
290  EX_res_local<=signed(energy_crate_delayed_l(59 downto 45));
291  EY_res_local<=signed(energy_crate_delayed_l(74 downto 60));
292  TE_res_local<=unsigned(energy_crate_delayed_l(88 downto 75)); --14 bits!
299 
300  EX_remote<=signed(energy_remote_l(14 downto 0));
301  EY_remote<=signed(energy_remote_l(29 downto 15));
302  TE_remote<=unsigned('0'&energy_remote_l(43 downto 30)); --14 bits!
303  EX_res_remote<=signed(energy_remote_l(59 downto 45));
304  EY_res_remote<=signed(energy_remote_l(74 downto 60));
305  TE_res_remote<=unsigned(energy_remote_l(88 downto 75)); --14 bits!
312 
313  process(CLK)
314  begin
315  if rising_edge(CLK) then
316 
317  --tick 0
318  EX_total<=resize(EX_remote,16)-resize(EX_local,16); --local coordinate x is
319  --negative on the
320  --'system' CMX
321  EY_total<=resize(EY_remote,16)+resize(EY_local,16); --y points up on 'crate'
322  --and 'system'
323  TE_total<=resize(TE_remote,15)+resize(TE_local,15); --14 bits from local and
324  --remote make 15 bits after addition
325 
326 
327  EX_res_total<=resize(EX_res_remote,16)-resize(EX_res_local,16);
328  EY_res_total<=resize(EY_res_remote,16)+resize(EY_res_local,16);
329  TE_res_total<=resize(TE_res_remote,15)+resize(TE_res_local,15);
330 
332 
336 
340 
344 
348 
349  end if;
350  end process;
351 
352  --truncate to maximum number of bits
353  EX_total_trunc<=resize(EX_total,max_bits_ExEy);
354  --if top bits (from msb downto max_bits-2 are all '0' or all '1' then there
355  --is no overflow; not that to signal an overflow
356  ov_EX_sum<='0' when ( std_logic_vector(EX_total(EX_total'length-1 downto max_bits_ExEy-2)) = ones32( EX_total'length-1 downto max_bits_ExEy-2)
357  or
358  std_logic_vector(EX_total(EX_total'length-1 downto max_bits_ExEy-2)) = gnd32( EX_total'length-1 downto max_bits_ExEy-2 ) ) else '1';
359 
360  --repeat for EY
361  EY_total_trunc<=resize(EY_total,max_bits_ExEy);
362  ov_EY_sum<='0' when (std_logic_vector(EY_total(EY_total'length-1 downto max_bits_ExEy-2)) = ones32( EY_total'length-1 downto max_bits_ExEy-2 )
363  or
364  std_logic_vector(EY_total(EY_total'length-1 downto max_bits_ExEy-2)) = gnd32( EY_total'length-1 downto max_bits_ExEy-2 ) ) else '1';
365 
366  --restricted range EX EY truncation and overflow
367  EX_res_total_trunc<=resize(EX_res_total,max_bits_ExEy);
368  ov_EX_res_sum<='0' when (std_logic_vector(EX_res_total(EX_res_total'length-1 downto max_bits_ExEy-2)) = ones32( EX_res_total'length-1 downto max_bits_ExEy-2 )
369  or
370  std_logic_vector(EX_res_total(EX_res_total'length-1 downto max_bits_ExEy-2)) = gnd32( EX_res_total'length-1 downto max_bits_ExEy-2 ) ) else '1';
371  EY_res_total_trunc<=resize(EY_res_total,max_bits_ExEy);
372  ov_EY_res_sum<='0' when (std_logic_vector(EY_res_total(EY_res_total'length-1 downto max_bits_ExEy-2)) = ones32( EY_res_total'length-1 downto max_bits_ExEy-2 )
373  or
374  std_logic_vector(EY_res_total(EY_res_total'length-1 downto max_bits_ExEy-2)) = gnd32( EY_res_total'length-1 downto max_bits_ExEy-2 ) ) else '1';
375 
376  --combine overflows; note that we need to use the registered local and remote
377  --overflows to keep the total overflow consistent in time
381 
385 
386  EX_total_abs<=unsigned(std_logic_vector(abs(EX_total_trunc)));
387  EY_total_abs<=unsigned(std_logic_vector(abs(EY_total_trunc)));
388 
389  EX_res_total_abs<=unsigned(std_logic_vector(abs(EX_res_total_trunc)));
390  EY_res_total_abs<=unsigned(std_logic_vector(abs(EY_res_total_trunc)));
391 
392 
393  --to preserve the interfaces we 're-cipher' the quantities
394  sums_all(0)<=unsigned(std_logic_vector(EX_total_trunc));
395  sums_all(1)<=unsigned(std_logic_vector(EY_total_trunc));
396  sums_all(2)<=TE_total;
397 
398  sums_all(3)<=unsigned(std_logic_vector(EX_res_total_trunc));
399  sums_all(4)<=unsigned(std_logic_vector(EY_res_total_trunc));
401 
402  ov_all(0)<=ov_EX;
403  ov_all(1)<=ov_EY;
404  ov_all(2)<=ov_TE;
405 
406  ov_all(3)<=ov_EX_res;
407  ov_all(4)<=ov_EY_res;
408  ov_all(5)<=ov_TE_res;
409 
410 
411 
412  gen_XS_criteria: for i_thr in 0 to num_thresholds-1 generate
413 
414  --multiplication of the two register values
415  --no real timing requirements here
416  T2_A2_B2(i_thr)<=XS_T2_A2(i_thr)*XS_B2(i_thr);
417  T4_A4(i_thr)<=XS_T2_A2(i_thr)*XS_T2_A2(i_thr);
418  T4_A4_B2(i_thr)<=T4_A4(i_thr)*XS_B2(i_thr);
419 
420  --leading '0' is for a '+' sign, trailing "00" is a multiplication by 4
421  --(syntax error when I try & "00" don't know why)
422  X4_T4_A4_B2_TE(i_thr)<=signed( '0' & (std_logic_vector(us_T4_A4_B2_TE(i_thr))) & '0' & '0' );
423 
424  --first leading 0 is to convert to '+'ve signed, next '0' is to
425  --accommodate XE2 subtraction
426  --doesn't like "00"&
427  T2_A2_TE_PLUS_T2_A2_B2(i_thr)<=signed('0'& ('0'& (std_logic_vector( us_T2_A2_TE_PLUS_T2_A2_B2(i_thr) )) ) );
428 
429  process(CLK)
430  begin
431 
432  if rising_edge(CLK) then
433 
434  --tick 1
435 
436  --this is the LHS of the comparison for criterion c4
437  us_T4_A4_B2_TE(i_thr)<= T4_A4_B2(i_thr) * TE_total;
438 
439  --resize the result of the multiplication by 1 bit to accomodate
440  --subsequent addition
441  T2_A2_TE(i_thr)<=resize( XS_T2_A2(i_thr) * TE_total, max_bits_ExEy*2+1+max_bits_TE+1);
442 
443  if TE_total < T_SUM_E_MIN(i_thr) then
444  c_XS_2(i_thr)<='1';
445  else
446  c_XS_2(i_thr)<='0';
447  end if;
448 
449  if TE_total >= T_SUM_E_MAX(i_thr) or ov_TE='1' then
450  c_XS_3(i_thr)<='1';
451  else
452  c_XS_3(i_thr)<='0';
453  end if;
454 
455  --tick 2
456 
457  us_T2_A2_TE_PLUS_T2_A2_B2(i_thr)<=T2_A2_TE(i_thr) + T2_A2_B2(i_thr);
458 
459  --register LHS so it is matched with RHS latency
460  X4_T4_A4_B2_TE_r(i_thr)<=X4_T4_A4_B2_TE(i_thr);
461 
462  c_XS_2_r(i_thr)<=c_XS_2(i_thr);
463  c_XS_3_r(i_thr)<=c_XS_3(i_thr);
464 
465  --tick 3
467 
468  if XE2<T_MISS_E_MIN(i_thr) then
469  c_XS_0(i_thr)<='1';
470  else
471  c_XS_0(i_thr)<='0';
472  end if;
473 
474  if XE2>T_MISS_E_MAX(i_thr) or ov_EX_rr='1' or ov_EY_rr ='1' then
475  c_XS_1(i_thr)<='1';
476  else
477  c_XS_1(i_thr)<='0';
478  end if;
479 
480 
481  --register LHS so it is matched with RHS latency
482  X4_T4_A4_B2_TE_rr(i_thr)<=X4_T4_A4_B2_TE_r(i_thr);
483 
484  c_XS_2_rr(i_thr)<=c_XS_2_r(i_thr);
485  c_XS_3_rr(i_thr)<=c_XS_3_r(i_thr);
486 
487 
488  --tick 4
490 
491  if T2_A2_TE_PLUS_T2_A2_B2_MINUS_XE2(i_thr) < to_signed(0,48) then
492  c_XS_4A(i_thr)<='1';
493  else
494  c_XS_4A(i_thr)<='0';
495  end if;
496 
497  --register LHS so it is matched with RHS latency
498  X4_T4_A4_B2_TE_rrr(i_thr)<=X4_T4_A4_B2_TE_rr(i_thr);
499 
500  c_XS_0_r(i_thr)<=c_XS_0(i_thr);
501  c_XS_1_r(i_thr)<=c_XS_1(i_thr);
502  c_XS_2_rrr(i_thr)<=c_XS_2_rr(i_thr);
503  c_XS_3_rrr(i_thr)<=c_XS_3_rr(i_thr);
504 
505 
506  --tick 5
507 
509  c_XS_4B(i_thr)<='1';
510  else
511  c_XS_4B(i_thr)<='0';
512  end if;
513 
514  c_XS_0_rr(i_thr)<=c_XS_0_r(i_thr);
515  c_XS_1_rr(i_thr)<=c_XS_1_r(i_thr);
516  c_XS_2_rrrr(i_thr)<=c_XS_2_rrr(i_thr);
517  c_XS_3_rrrr(i_thr)<=c_XS_3_rrr(i_thr);
518 
519  c_XS_4A_r(i_thr)<=c_XS_4A(i_thr);
520 
521  --tick 6
522  if c_XS_0_rr(i_thr)='1' then
523  xs_map(i_thr)<='0' or ( par_err_cbl_l_rrrrr and force);
524  else
525  if c_XS_1_rr(i_thr)='1' then
526  xs_map(i_thr)<='1';
527  else
528  if c_XS_2_rrrr(i_thr)='1' or c_XS_3_rrrr(i_thr)='1' then
529  xs_map(i_thr)<='0' or ( par_err_cbl_l_rrrrr and force);
530  else
531  if c_XS_4A_r(i_thr)='1' then
532  xs_map(i_thr)<='1';
533  else
534  xs_map(i_thr)<=c_XS_4B(i_thr) or ( par_err_cbl_l_rrrrr and force);
535  end if;
536  end if;
537  end if;
538  end if;
539 
540 
541 
542  end if;
543  end process;
544 
545  end generate gen_XS_criteria;
546 
547 
548  gen_TE_criteria: for i_thr in 0 to num_thresholds-1 generate
549  process(CLK)
550  begin
551  if rising_edge(CLK) then
552 
553  --tick 1
554  if TE_total > SUM_ET_THR(i_thr) or ov_TE='1' then
555  c_TE(i_thr)<='1';
556  else
557  c_TE(i_thr)<='0';
558  end if;
559 
560 
561  if TE_res_total > SUM_ET_RES_THR(i_thr) or ov_TE_res='1' then
562  c_TE_res(i_thr)<='1';
563  else
564  c_TE_res(i_thr)<='0';
565  end if;
566 
567  --tick 2,3,4,5
568  c_TE_r(i_thr)<=c_TE(i_thr);
569  c_TE_res_r(i_thr)<=c_TE_res(i_thr);
570 
571  c_TE_rr(i_thr)<=c_TE_r(i_thr);
572  c_TE_res_rr(i_thr)<=c_TE_res_r(i_thr);
573 
574  c_TE_rrr(i_thr)<=c_TE_rr(i_thr);
575  c_TE_res_rrr(i_thr)<=c_TE_res_rr(i_thr);
576 
577  c_TE_rrrr(i_thr)<=c_TE_rrr(i_thr);
578  c_TE_res_rrrr(i_thr)<=c_TE_res_rrr(i_thr);
579 
580  --tick 6
581  sumet_map(i_thr)<=c_TE_rrrr(i_thr) or ( par_err_cbl_l_rrrrr and force);
582  res_sumet_map(i_thr)<=c_TE_res_rrrr(i_thr) or ( par_err_cbl_l_rrrrr and force);
583 
584  end if;
585  end process;
586  end generate gen_TE_criteria;
587 
588  gen_XE_criteria: for i_thr in 0 to num_thresholds-1 generate
589  process(CLK)
590  begin
591  if rising_edge(CLK) then
592 
593  --tick 3
594  if XE2> MISS_E_THR(i_thr) or ov_EX_rr='1' or ov_EY_rr='1' then
595  c_XE(i_thr)<='1';
596  else
597  c_XE(i_thr)<='0';
598  end if;
599 
600 
601  if XE2_res > MISS_E_RES_THR(i_thr) or ov_EX_res_rr='1' or ov_EY_res_rr='1'then
602  c_XE_res(i_thr)<='1';
603  else
604  c_XE_res(i_thr)<='0';
605  end if;
606 
607  --tick 4,5
608  c_XE_r(i_thr)<=c_XE(i_thr);
609  c_XE_res_r(i_thr)<=c_XE_res(i_thr);
610 
611  c_XE_rr(i_thr)<=c_XE_r(i_thr);
612  c_XE_res_rr(i_thr)<=c_XE_res_r(i_thr);
613 
614  --tick 6
615  miss_map(i_thr)<=c_XE_rr(i_thr) or ( par_err_cbl_l_rrrrr and force);
616  res_miss_map(i_thr)<=c_XE_res_rr(i_thr) or ( par_err_cbl_l_rrrrr and force);
617 
618  end if;
619  end process;
620  end generate gen_XE_criteria;
621 
622 
623  s_XE2<=signed('0'&(std_logic_vector(XE2)));
624 
625  --process that performs the sequence of common calculations
626  process(CLK)
627  begin
628  if rising_edge(CLK) then
629 
630  --tick 1
633 
636 
637 
638  ov_EX_r<=ov_EX;
639  ov_EY_r<=ov_EY;
640 
643 
645 
646  --tick 2
647  XE2<=resize(EX2,max_bits_ExEy*2+1)+EY2;
648 
649  XE2_res<=resize(EX2_res,max_bits_ExEy*2+1)+EY2_res;
650 
651 
652  ov_EX_rr<=ov_EX_r;
653  ov_EY_rr<=ov_EY_r;
654 
657 
659 
660  --tick 3
662 
663  --tick 4
665 
666  --tick 5
668 
669  end if;
670  end process;
671 
672 
674 
675  sums_all_out<=sums_all(5 downto 0);
676 
679 
680 
681 end system_summing_module;
unsigned (max_bits_XE2 - 1 downto 0) XE2
unsigned (max_bits_TE - 1 downto 0) TE_total
signed (max_bits_ExEy - 1 downto 0) EX_res_total_trunc
arr_ctr_92bit (num_thresholds - 1 downto 0) us_T4_A4_B2_TE
std_logic_vector (num_thresholds - 1 downto 0) c_XE
signed (max_bits_ExEy - 1 downto 0) EY_res_total_trunc
arr_sig_95bit (num_thresholds - 1 downto 0) X4_T4_A4_B2_TE_r
std_logic_vector (num_thresholds - 1 downto 0) c_XE_r
in addr_vmestd_logic_vector (15 downto 0)
signed (max_bits_ExEy - 1 downto 0) EX_local
unsigned (max_bits_ExEy - 1 downto 0) EY_total_abs
std_logic_vector (ENERGY_CRATE' range ) energy_crate_delayed
arr_sig_95bit (num_thresholds - 1 downto 0) X4_T4_A4_B2_TE
unsigned (max_bits_ExEy - 1 downto 0) EY_res_total_abs
unsigned (max_bits_ExEy - 1 downto 0) EX_res_total_abs
signed (max_bits_ExEy - 1 downto 0) EY_remote
arr_ctr_46bit (num_thresholds - 1 downto 0) T2_A2_B2
signed (max_bits_ExEy - 1 downto 0) EX_res_remote
arr_sig_98bit (num_thresholds - 1 downto 0) T2_A2_TE_PLUS_T2_A2_B2_MINUS_XE2_ALL2
std_logic_vector (num_thresholds - 1 downto 0) c_XE_res
signed (max_bits_ExEy - 1 downto 0) EY_res_remote
in dinstd_logic_vector
signed (max_bits_ExEy - 1 downto 0) EX_total_trunc
in MISS_E_RES_THRarr_ctr_31bit (num_thresholds - 1 downto 0)
out sums_all_outarr_ctr_15bit (5 downto 0)
std_logic_vector (num_thresholds - 1 downto 0) c_XS_3_r
unsigned (max_bits_TE - 1 downto 0) TE_res_total
in T_MISS_E_MAXarr_ctr_31bit (num_thresholds - 1 downto 0)
out doutstd_logic_vector
unsigned (max_bits_ExEy * 2 - 1 downto 0) EX2)
std_logic_vector (num_thresholds - 1 downto 0) c_XS_3_rrrr
arr_sig_95bit (num_thresholds - 1 downto 0) X4_T4_A4_B2_TE_rr
std_logic_vector (num_thresholds - 1 downto 0) c_XS_1
std_logic_vector (num_thresholds - 1 downto 0) c_XS_2_rrrr
std_logic_vector (num_thresholds - 1 downto 0) c_TE_rr
arr_ctr_62bit (num_thresholds - 1 downto 0) T4_A4
std_logic_vector (num_thresholds - 1 downto 0) c_XS_4A
signed (max_bits_ExEy - 1 downto 0) EX_res_local
unsigned (max_bits_TE - 1 downto 0) TE_local
std_logic_vector (num_thresholds - 1 downto 0) c_XS_1_r
std_logic_vector (num_thresholds - 1 downto 0) c_XS_3
signed (max_bits_ExEy - 1 downto 0) EY_res_local
std_logic_vector (num_thresholds - 1 downto 0) c_XS_2_r
unsigned (max_bits_ExEy - 1 downto 0) EX_total_abs
in SUM_ET_RES_THRarr_ctr_15bit (num_thresholds - 1 downto 0)
unsigned (max_bits_TE - 1 downto 0) TE_remote
unsigned (max_bits_ExEy * 2 - 1 downto 0) EY2)
out data_vme_outstd_logic_vector (15 downto 0)
std_logic_vector (num_thresholds - 1 downto 0) c_TE_res_rrr
std_logic_vector (5 downto 0) :=( others =>'0' ) ov_all
std_logic_vector (num_thresholds - 1 downto 0) c_TE_res_rrrr
ADDR_REG_RW_PIPELINE_DELAY_LENGTHinteger :=0
in T_SUM_E_MAXarr_ctr_15bit (num_thresholds - 1 downto 0)
arr_sig_95bit (num_thresholds - 1 downto 0) X4_T4_A4_B2_TE_rrr
std_logic_vector (num_thresholds - 1 downto 0) c_TE_rrrr
unsigned (max_bits_TE - 1 - 1 downto 0) TE_res_local
in XS_T2_A2arr_ctr_31bit (num_thresholds - 1 downto 0)
unsigned (max_bits_ExEy * 2 - 1 downto 0) EX2_res)
std_logic_vector (num_thresholds - 1 downto 0) c_XS_4A_r
out CTP_CABLE_1std_logic_vector (23 downto 0)
in ENERGY_CRATEstd_logic_vector (26 * 4 - 1 downto 0)
in T_MISS_E_MINarr_ctr_31bit (num_thresholds - 1 downto 0)
std_logic_vector (num_thresholds - 1 downto 0) c_XS_2_rr
out ov_all_outstd_logic_vector (5 downto 0)
std_logic_vector (num_thresholds - 1 downto 0) c_XS_3_rr
std_logic_vector (num_thresholds - 1 downto 0) c_TE
unsigned (max_bits_TE - 1 - 1 downto 0) TE_res_remote
std_logic_vector (15 * 6 + 6 - 1 downto 0) energy_remote_l)
in SUM_ET_THRarr_ctr_15bit (num_thresholds - 1 downto 0)
std_logic_vector (num_thresholds - 1 downto 0) c_TE_res_r
signed (max_bits_ExEy - 1 downto 0) EY_local
unsigned (max_bits_ExEy * 2 - 1 downto 0) EY2_res)
std_logic_vector (num_thresholds - 1 downto 0) c_TE_r
in XS_B2arr_ctr_15bit (num_thresholds - 1 downto 0)
std_logic_vector (num_thresholds - 1 downto 0) c_XE_res_r
arr_sig_49bit (num_thresholds - 1 downto 0) T2_A2_TE_PLUS_T2_A2_B2_MINUS_XE2
std_logic_vector (num_thresholds - 1 downto 0) c_TE_rrr
std_logic_vector (num_thresholds - 1 downto 0) c_XS_3_rrr
std_logic_vector (num_thresholds - 1 downto 0) c_XS_0_r
std_logic_vector (num_thresholds - 1 downto 0) c_TE_res_rr
std_logic_vector (num_thresholds - 1 downto 0) c_XS_2_rrr
signed (max_bits_ExEy - 1 downto 0) EY_total_trunc
std_logic_vector (num_thresholds - 1 downto 0) c_XS_2
arr_sig_49bit (num_thresholds - 1 downto 0) T2_A2_TE_PLUS_T2_A2_B2
std_logic_vector (31 downto 0) :=x"FFFFFFFF" ones32
std_logic_vector (num_thresholds - 1 downto 0) c_XS_1_rr
arr_ctr_77bit (num_thresholds - 1 downto 0) T4_A4_B2
in MISS_E_THRarr_ctr_31bit (num_thresholds - 1 downto 0)
in T_SUM_E_MINarr_ctr_15bit (num_thresholds - 1 downto 0)
std_logic_vector (15 * 6 + 6 - 1 downto 0) energy_crate_delayed_l)
unsigned (max_bits_XE2 - 1 downto 0) XE2_res
test registers
arr_ctr_47bit (num_thresholds - 1 downto 0) T2_A2_TE
std_logic_vector (num_thresholds - 1 downto 0) c_XE_res_rr
std_logic_vector (num_thresholds - 1 downto 0) c_XE_rr
in data_vme_instd_logic_vector (15 downto 0)
signed (max_bits_ExEy - 1 downto 0) EX_remote
in ENERGY_REMOTEstd_logic_vector (26 * 4 - 1 downto 0)
std_logic_vector (num_thresholds - 1 downto 0) c_XS_0_rr
std_logic_vector (num_thresholds - 1 downto 0) c_XS_0
std_logic_vector (num_thresholds - 1 downto 0) c_TE_res
out CTP_CABLE_0std_logic_vector (23 downto 0)
std_logic_vector (31 downto 0) :=x"00000000" gnd32
std_logic_vector (num_thresholds - 1 downto 0) c_XS_4B
arr_ctr_47bit (num_thresholds - 1 downto 0) us_T2_A2_TE_PLUS_T2_A2_B2