CMX
CMX firmware code in-line documentation
 All Classes Namespaces Files Functions Variables
CMX_SumEt.vhd
Go to the documentation of this file.
1 
6 
7 library IEEE;
8 use IEEE.STD_LOGIC_UNSIGNED.all;
9 use ieee.std_logic_1164.all;
10 use ieee.numeric_std.all;
11 LIBRARY work;
13 use work.CMXpackage.all;
15 
16 
17 
18 entity CMX_Sum_Et is
19 
20  port (
21  CLK : in std_logic;
22  --SYSTEM
23  ENERGY_REMOTE : in std_logic_vector(26*4-1 downto 0);
24  CTP_CABLE_0 : out std_logic_vector(23 downto 0);
25  CTP_CABLE_1 : out std_logic_vector(23 downto 0);
26  -- thresholds
27  MISS_E_THR : in arr_ctr_31bit(num_thresholds-1 downto 0);
28  MISS_E_RES_THR : in arr_ctr_31bit(num_thresholds-1 downto 0);
29  SUM_ET_THR : in arr_ctr_15bit(num_thresholds-1 downto 0);
30  SUM_ET_RES_THR : in arr_ctr_15bit(num_thresholds-1 downto 0);
31  XS_T2_A2 : in arr_ctr_31bit(num_thresholds-1 downto 0);
32  -- parameters
33  T_MISS_E_MIN : in arr_ctr_31bit(num_thresholds-1 downto 0);
34  T_MISS_E_MAX : in arr_ctr_31bit(num_thresholds-1 downto 0);
35  T_SUM_E_MIN : in arr_ctr_15bit(num_thresholds-1 downto 0);
36  T_SUM_E_MAX : in arr_ctr_15bit(num_thresholds-1 downto 0);
37  XS_B2 : in arr_ctr_15bit(num_thresholds-1 downto 0);
38  ov_all_out : out std_logic_vector(5 downto 0);
39  sums_all_out : out arr_ctr_15bit(5 downto 0);
40  --CRATE
41  BACKPLANE_DATA_IN : in energy_array;
42  LOCAL_CABLE_OUT : out std_logic_vector(4*26-1 downto 0);
43  BCID_in : in std_logic_vector(11 downto 0);
44  BCID_delayed : out std_logic_vector(11 downto 0);
45  -- counter signals
46  counter_reset : in T_SL;
47  counter_inhibit : in T_SL;
48 
49  par_err : in std_logic_vector(1 downto 0); -- parity error (input module - 0, RTM - 1)
50  force : in T_SL; -- force
51  --VME
52  ncs : in std_logic; --ports forwarded to the vme register instances
53  rd_nwr : in std_logic;
54  ds : in std_logic;
55  addr_vme : in std_logic_vector (15 downto 0);
56  data_vme_in : in std_logic_vector (15 downto 0);
57  data_vme_out : out std_logic_vector (15 downto 0);
58  bus_drive : out std_logic
59 
60  );
61 end CMX_Sum_Et;
62 
63 architecture CMX_Sum_Et of CMX_Sum_Et is
64  signal local_cable_to_system : std_logic_vector(4*26-1 downto 0);
65 
66  component vme_local_switch is
67  port (
68  data_vme_up : out std_logic_vector (15 downto 0);
69  data_vme_from_below : in arr_16;
70  bus_drive_up : out std_logic;
71  bus_drive_from_below : in std_logic_vector);
72  end component vme_local_switch;
73 
74  signal bus_drive_local : std_logic_vector(1+(16*5) downto 0);
75  signal data_vme_out_local : arr_16(1+(16*5) downto 0);
76  signal ctp_cable_0_internal : std_logic_vector(23 downto 0);
77  signal ctp_cable_1_internal : std_logic_vector(23 downto 0);
78 
79  signal cnt_sum_et : cnt_mult_arr(7 downto 0);
80  signal cnt_missing_et : cnt_mult_arr(7 downto 0);
81  signal cnt_missing_et_sign : cnt_mult_arr(7 downto 0);
82  signal cnt_sum_et_weighted : cnt_mult_arr(7 downto 0);
83  signal cnt_missing_et_res : cnt_mult_arr(7 downto 0);
84 
85  signal cnt_sum_et_2x16 : cnt_mult_arr_2x16(15 downto 0);
86  signal cnt_missing_et_2x16 : cnt_mult_arr_2x16(15 downto 0);
87  signal cnt_missing_et_sign_2x16 : cnt_mult_arr_2x16(15 downto 0);
88  signal cnt_sum_et_weighted_2x16 : cnt_mult_arr_2x16(15 downto 0);
89  signal cnt_missing_et_res_2x16 : cnt_mult_arr_2x16(15 downto 0);
90 
91 
92  component parity_gen
93  GENERIC(
94  width : integer := 60
95  );
96  PORT(
97  din : IN std_logic_vector (width-1 downto 0) ;
98  parity : OUT std_logic
99  );
100  end component;
101 
102  component adder_counter is
103  generic(
104  flavor : T_SLV2 := "10"; -- JET/CPM/SUMET
105  thresholds_num : integer := 25;
106  width : integer := 60
107  );
108  port(
109  clk : in T_SL; -- clock
110  reset : in T_SL; -- reset
111  inhibit : in T_SL; -- inhibit
112  data : in std_logic_vector(width-1 downto 0); -- data
113  cnt_arr : out cnt_mult_arr(thresholds_num-1 downto 0)); -- counters
114  end component adder_counter;
115 
117  generic (
118  ia_vme : integer;
119  width : integer);
120  port (
121  ncs : in std_logic;
122  rd_nwr : in std_logic;
123  ds : in std_logic;
124  addr_vme : in std_logic_vector (15 downto 0);
125  data_vme : out std_logic_vector (15 downto 0);
126  bus_drive : out std_logic;
127  data_to_vme : in std_logic_vector (width-1 downto 0));
128  end component vme_outreg_notri_async;
129 
130 
131  signal counter_inhibit_r_local : std_logic;
132  signal counter_reset_r_local : std_logic;
133 
134 
135 begin
136 
137 
138 
139  vme_local_switch_inst: entity work.vme_local_switch
140  port map (
141  data_vme_up => data_vme_out,
143  bus_drive_up => bus_drive,
145 
146 
147  process(CLK)
148  begin
149  if rising_edge(CLK) then
152  end if;
153  end process;
154 
155 
156  CRATE_SUMMING_MODULE_INST : entity work.crate_summing_module
157  port map (
158  CLK => CLK,
161  BCID_in => BCID_in,
163  par_err_lcl => par_err(0),
164  force => force,
165  ncs => ncs,
166  rd_nwr => rd_nwr,
167  ds => ds,
168  addr_vme => addr_vme,
169  data_vme_in => data_vme_in,
170  data_vme_out => data_vme_out_local(0),
171  bus_drive => bus_drive_local(0)
172  );
173 
174  system_summing_module_inst: entity work.system_summing_module
175  port map (
176  CLK => CLK,
185  XS_T2_A2 => XS_T2_A2,
190  XS_B2 => XS_B2,
193 
194  par_err_cbl => par_err(1),
195  force => force,
196 
197  ncs => ncs,
198  rd_nwr => rd_nwr,
199  ds => ds,
200  addr_vme => addr_vme,
201  data_vme_in => data_vme_in,
202  data_vme_out => data_vme_out_local (1),
203  bus_drive => bus_drive_local (1));
204 
205  --SYSTEM_SUMMING_MODULE_INST : entity work.system_summing_module
206  -- port map (
207  -- CLK => CLK,
208  -- ENERGY_CRATE => local_cable_to_system,
209  -- ENERGY_REMOTE => ENERGY_REMOTE,
210  -- CTP_CABLE_0 => ctp_cable_0_internal, -- CTP_CABLE_0,
211  -- CTP_CABLE_1 => ctp_cable_1_internal, -- CTP_CABLE_1,
212  -- MISS_THR => MISS_THR,
213  -- SUMET_THR => SUMET_THR,
214  -- XS_THR => XS_THR,
215  -- XS_PARAM => XS_PARAM,
216  -- ov_all_out => ov_all_out,
217  -- sums_all_out => sums_all_out,
218  -- ncs => ncs,
219  -- rd_nwr => rd_nwr,
220  -- ds => ds,
221  -- addr_vme => addr_vme,
222  -- data_vme_in => data_vme_in,
223  -- data_vme_out => data_vme_out_local(1),
224  -- bus_drive => bus_drive_local(1)
225  -- );
226 
227 -- parity
228 
229  I14 : parity_gen
230  generic map (
231  width => 25
232  )
233  port map (
234  din => local_cable_to_system(24 downto 0),
235  parity => LOCAL_CABLE_OUT (25) -- cbla, mux0
236  );
237 
238  I15 : parity_gen
239  generic map (
240  width => 25
241  )
242  port map (
243  din => local_cable_to_system(50 downto 26),
244  parity => LOCAL_CABLE_OUT(51) -- cbla, mux1
245  );
246 
247  I16 : parity_gen
248  generic map (
249  width => 25
250  )
251  port map (
252  din => local_cable_to_system(76 downto 52),
253  parity => LOCAL_CABLE_OUT(77) -- cblb, mux0
254  );
255 
256  I17 : parity_gen
257  generic map (
258  width => 25
259  )
260  port map (
261  din => local_cable_to_system(102 downto 78),
262  parity => LOCAL_CABLE_OUT(103) -- cblb, mux1
263  );
264 
265 
266 
267  LOCAL_CABLE_OUT(24 downto 0) <= local_cable_to_system(24 downto 0);
268  LOCAL_CABLE_OUT(50 downto 26) <= local_cable_to_system(50 downto 26);
269  LOCAL_CABLE_OUT(76 downto 52) <= local_cable_to_system(76 downto 52);
270  LOCAL_CABLE_OUT(102 downto 78) <= local_cable_to_system(102 downto 78);
271 
272 
275 
276 -- ------------------------------------------------------------------------------------
277 -- COUNTERS
278 -- ------------------------------------------------------------------------------------
279 
280 mult_2x16: for i in 0 to 7 generate
281 
282 cnt_sum_et_2x16(2*i) <= cnt_sum_et(i)(15 downto 0);
283 cnt_sum_et_2x16(2*i+1) <= cnt_sum_et(i)(31 downto 16);
284 
285 cnt_missing_et_2x16(2*i) <= cnt_missing_et(i)(15 downto 0);
286 cnt_missing_et_2x16(2*i+1) <= cnt_missing_et(i)(31 downto 16);
287 
288 cnt_missing_et_sign_2x16(2*i) <= cnt_missing_et_sign(i)(15 downto 0);
289 cnt_missing_et_sign_2x16(2*i+1) <= cnt_missing_et_sign(i)(31 downto 16);
290 
291 cnt_sum_et_weighted_2x16(2*i) <= cnt_sum_et_weighted(i)(15 downto 0);
292 cnt_sum_et_weighted_2x16(2*i+1) <= cnt_sum_et_weighted(i)(31 downto 16);
293 
294 cnt_missing_et_res_2x16(2*i) <= cnt_missing_et_res(i)(15 downto 0);
295 cnt_missing_et_res_2x16(2*i+1) <= cnt_missing_et_res(i)(31 downto 16);
296 
297 
298 end generate mult_2x16;
299 
300 -- ------------------------------------------------------------------------------------
301 -- sum ET
302 -- ------------------------------------------------------------------------------------
303 
304 --
305 --
306 --
307 cnt_sumEt: adder_counter
308  generic map(
309  flavor => "10",
310  thresholds_num => 8,
311  width => 8
312  )
313  port map(
314  clk => clk,
317  data => ctp_cable_0_internal (7 downto 0), -- sumET
318  cnt_arr => cnt_sum_et (7 downto 0)
319  );
320 
321 --
322 -- VME
323 --
324 VME_CNT_SUM_ET_COUNTER_i: for i in 0 to 15 generate
325 
326 VME_CNT_SUM_ET_COUNTER: vme_outreg_notri_async
327  generic map (
328  ia_vme => ADDR_REG_RO_SUM_ET_COUNTER+ (2*i),
329  width => 16)
330  port map (
331  addr_vme => addr_vme,
332  ncs => ncs,
333  rd_nwr => rd_nwr,
334  ds => ds,
336  data_vme => data_vme_out_local (i+1+1),
337  bus_drive => bus_drive_local (i+1+1)
338  );
339 
340 end generate VME_CNT_SUM_ET_COUNTER_i;
341 
342 -- ------------------------------------------------------------------------------------
343 -- MISSING ET
344 -- ------------------------------------------------------------------------------------
345 --
346 --
347 --
348 cnt_missingEt: adder_counter
349  generic map(
350  flavor => "10",
351  thresholds_num => 8,
352  width => 8
353  )
354  port map(
355  clk => clk,
358  data => ctp_cable_0_internal (15 downto 8), -- missing Et
359  cnt_arr => cnt_missing_et (7 downto 0)
360  );
361 
362 
363 --
364 -- VME
365 --
366 VME_CNT_MISSING_ET_COUNTER_i: for i in 0 to 15 generate
367 
368 VME_CNT_MISSING_ET_COUNTER: vme_outreg_notri_async
369  generic map (
370  ia_vme => ADDR_REG_RO_MISSING_ET_COUNTER+ (2*i),
371  width => 16)
372  port map (
373  addr_vme => addr_vme,
374  ncs => ncs,
375  rd_nwr => rd_nwr,
376  ds => ds,
378  data_vme => data_vme_out_local (i+1+1+16),
379  bus_drive => bus_drive_local (i+1+1+16)
380  );
381 
382 end generate VME_CNT_MISSING_ET_COUNTER_i;
383 
384 
385 -- ------------------------------------------------------------------------------------
386 -- MISSING ET SIGNIFICANCE
387 -- ------------------------------------------------------------------------------------
388 --
389 
390 cnt_missingEt_sign: adder_counter
391  generic map(
392  flavor => "10",
393  thresholds_num => 8,
394  width => 8
395  )
396  port map(
397  clk => clk,
400  data => ctp_cable_0_internal (23 downto 16), -- missing ET significance
401  cnt_arr => cnt_missing_et_sign(7 downto 0)
402  );
403 
404 --
405 -- VME
406 --
407 VME_CNT_MISSING_ET_SIGN_COUNTER_i: for i in 0 to 15 generate
408 
409 VME_CNT_MISSING_ET_SIGN_COUNTER: vme_outreg_notri_async
410  generic map (
411  ia_vme => ADDR_REG_RO_MISSING_ET_SIGN_COUNTER+ (2*i),
412  width => 16)
413  port map (
414  addr_vme => addr_vme,
415  ncs => ncs,
416  rd_nwr => rd_nwr,
417  ds => ds,
419  data_vme => data_vme_out_local (i+1+1+16+16),
420  bus_drive => bus_drive_local (i+1+1+16+16)
421  );
422 
423 end generate VME_CNT_MISSING_ET_SIGN_COUNTER_i;
424 
425 
426 -- ------------------------------------------------------------------------------------
427 -- SUM ET WEIGHTED
428 -- ------------------------------------------------------------------------------------
429 --
430 
431 cnt_missingEt_weighted: adder_counter
432  generic map(
433  flavor => "10",
434  thresholds_num => 8,
435  width => 8
436  )
437  port map(
438  clk => clk,
441  data => ctp_cable_1_internal (7 downto 0), -- missing ET significance
442  cnt_arr => cnt_sum_et_weighted(7 downto 0)
443  );
444 
445 --
446 -- VME
447 --
448 VME_CNT_SUM_ET_WEIGHTED_COUNTER_i: for i in 0 to 15 generate
449 
450 VME_CNT_SUM_ET_WEIGHTED_COUNTER: vme_outreg_notri_async
451  generic map (
452  ia_vme => ADDR_REG_RO_SUM_ET_WEIGHTED_COUNTER+ (2*i),
453  width => 16)
454  port map (
455  addr_vme => addr_vme,
456  ncs => ncs,
457  rd_nwr => rd_nwr,
458  ds => ds,
460  data_vme => data_vme_out_local (i+1+1+16+16+16),
461  bus_drive => bus_drive_local (i+1+1+16+16+16)
462  );
463 
464 
465 end generate VME_CNT_SUM_ET_WEIGHTED_COUNTER_i;
466 
467 -- ------------------------------------------------------------------------------------
468 -- MISSING ET RESTRCITED
469 -- ------------------------------------------------------------------------------------
470 --
471 
472 cnt_missingEt_restricted: adder_counter
473  generic map(
474  flavor => "10",
475  thresholds_num => 8,
476  width => 8
477  )
478  port map(
479  clk => clk,
482  data => ctp_cable_1_internal (15 downto 8), -- missing ET restricted
483  cnt_arr => cnt_missing_et_res (7 downto 0)
484  );
485 
486 --
487 -- VME
488 --
489 VME_CNT_MISS_ET_RESCTRICTED_COUNTER_i: for i in 0 to 15 generate
490 
491 VME_CNT_MISS_ET_RESCTRICTED_COUNTER: vme_outreg_notri_async
492  generic map (
493  ia_vme => ADDR_REG_RO_MISSING_ET_RES_COUNTER+ (2*i),
494  width => 16)
495  port map (
496  addr_vme => addr_vme,
497  ncs => ncs,
498  rd_nwr => rd_nwr,
499  ds => ds,
501  data_vme => data_vme_out_local (i+1+1+16+16+16+16),
502  bus_drive => bus_drive_local (i+1+1+16+16+16+16)
503  );
504 
505 
506 end generate VME_CNT_MISS_ET_RESCTRICTED_COUNTER_i;
507 
508 
509 end CMX_Sum_Et;
in BACKPLANE_DATA_INenergy_array
thresholds_numinteger :=25
in counter_inhibitT_SL
Definition: CMX_SumEt.vhd:47
cnt_mult_arr_2x16 (15 downto 0) cnt_missing_et_2x16
Definition: CMX_SumEt.vhd:86
std_logic counter_inhibit_r_local
Definition: CMX_SumEt.vhd:131
out sums_all_outarr_ctr_15bit (5 downto 0)
Definition: CMX_SumEt.vhd:39
out data_vmestd_logic_vector (15 downto 0)
in BACKPLANE_DATA_INenergy_array
Definition: CMX_SumEt.vhd:41
in T_SUM_E_MAXarr_ctr_15bit (num_thresholds - 1 downto 0)
Definition: CMX_SumEt.vhd:36
cnt_mult_arr_2x16 (15 downto 0) cnt_sum_et_weighted_2x16
Definition: CMX_SumEt.vhd:88
in counter_resetT_SL
Definition: CMX_SumEt.vhd:46
std_logic_vector (4 * 26 - 1 downto 0) local_cable_to_system)
Definition: CMX_SumEt.vhd:64
in MISS_E_RES_THRarr_ctr_31bit (num_thresholds - 1 downto 0)
out sums_all_outarr_ctr_15bit (5 downto 0)
in T_MISS_E_MAXarr_ctr_31bit (num_thresholds - 1 downto 0)
arr_16 (1 + (16 * 5) downto 0) data_vme_out_local)
Definition: CMX_SumEt.vhd:75
in data_vme_from_belowarr_16
--! inputs from local registers and from
cnt_mult_arr (7 downto 0) cnt_missing_et_sign
Definition: CMX_SumEt.vhd:81
std_logic_vector (23 downto 0) ctp_cable_1_internal
Definition: CMX_SumEt.vhd:77
out LOCAL_CABLE_OUTstd_logic_vector (4 * 26 - 1 downto 0)
Definition: CMX_SumEt.vhd:42
in datastd_logic_vector (width - 1 downto 0)
_library_ workwork
in SUM_ET_RES_THRarr_ctr_15bit (num_thresholds - 1 downto 0)
in ENERGY_REMOTEstd_logic_vector (26 * 4 - 1 downto 0)
Definition: CMX_SumEt.vhd:23
out BCID_delayedstd_logic_vector (11 downto 0)
out paritystd_logic
Definition: parity_gen.vhd:24
in T_MISS_E_MINarr_ctr_31bit (num_thresholds - 1 downto 0)
Definition: CMX_SumEt.vhd:33
in T_SUM_E_MAXarr_ctr_15bit (num_thresholds - 1 downto 0)
flavorT_SLV2 :="00"
in XS_T2_A2arr_ctr_31bit (num_thresholds - 1 downto 0)
in T_MISS_E_MAXarr_ctr_31bit (num_thresholds - 1 downto 0)
Definition: CMX_SumEt.vhd:34
in BCID_instd_logic_vector (11 downto 0)
Definition: CMX_SumEt.vhd:43
in T_SUM_E_MINarr_ctr_15bit (num_thresholds - 1 downto 0)
Definition: CMX_SumEt.vhd:35
cnt_mult_arr (7 downto 0) cnt_missing_et_res
Definition: CMX_SumEt.vhd:83
out CTP_CABLE_1std_logic_vector (23 downto 0)
out LOCAL_CABLE_OUTstd_logic_vector (26 * 4 - 1 downto 0)
in ENERGY_CRATEstd_logic_vector (26 * 4 - 1 downto 0)
out data_vme_upstd_logic_vector (15 downto 0)
--! connect this to
in T_MISS_E_MINarr_ctr_31bit (num_thresholds - 1 downto 0)
out ov_all_outstd_logic_vector (5 downto 0)
in SUM_ET_RES_THRarr_ctr_15bit (num_thresholds - 1 downto 0)
Definition: CMX_SumEt.vhd:30
in addr_vmestd_logic_vector (15 downto 0)
cnt_mult_arr (7 downto 0) cnt_missing_et
Definition: CMX_SumEt.vhd:80
out BCID_delayedstd_logic_vector (11 downto 0)
Definition: CMX_SumEt.vhd:44
cnt_mult_arr_2x16 (15 downto 0) cnt_missing_et_res_2x16
Definition: CMX_SumEt.vhd:89
in SUM_ET_THRarr_ctr_15bit (num_thresholds - 1 downto 0)
std_logic_vector (1 + (16 * 5) downto 0) bus_drive_local)
Definition: CMX_SumEt.vhd:74
in par_errstd_logic_vector (1 downto 0)
Definition: CMX_SumEt.vhd:49
in SUM_ET_THRarr_ctr_15bit (num_thresholds - 1 downto 0)
Definition: CMX_SumEt.vhd:29
out bus_drive_upstd_logic
or of all bus drive requests from below
in XS_B2arr_ctr_15bit (num_thresholds - 1 downto 0)
widthinteger :=60
Definition: parity_gen.vhd:20
out cnt_arrcnt_mult_arr (thresholds_num - 1 downto 0)
cnt_mult_arr (7 downto 0) cnt_sum_et_weighted
Definition: CMX_SumEt.vhd:82
cnt_mult_arr_2x16 (15 downto 0) cnt_sum_et_2x16
Definition: CMX_SumEt.vhd:85
std_logic_vector (23 downto 0) ctp_cable_0_internal
Definition: CMX_SumEt.vhd:76
in MISS_E_THRarr_ctr_31bit (num_thresholds - 1 downto 0)
Definition: CMX_SumEt.vhd:27
cnt_mult_arr_2x16 (15 downto 0) cnt_missing_et_sign_2x16
Definition: CMX_SumEt.vhd:87
in CLKstd_logic
Definition: CMX_SumEt.vhd:21
in XS_B2arr_ctr_15bit (num_thresholds - 1 downto 0)
Definition: CMX_SumEt.vhd:37
in MISS_E_THRarr_ctr_31bit (num_thresholds - 1 downto 0)
in T_SUM_E_MINarr_ctr_15bit (num_thresholds - 1 downto 0)
widthinteger :=60
test registers
in MISS_E_RES_THRarr_ctr_31bit (num_thresholds - 1 downto 0)
Definition: CMX_SumEt.vhd:28
cnt_mult_arr (7 downto 0) cnt_sum_et
Definition: CMX_SumEt.vhd:79
in dinstd_logic_vector (width - 1 downto 0)
Definition: parity_gen.vhd:23
in XS_T2_A2arr_ctr_31bit (num_thresholds - 1 downto 0)
Definition: CMX_SumEt.vhd:31
out ov_all_outstd_logic_vector (5 downto 0)
Definition: CMX_SumEt.vhd:38
_library_ ieeeieee
out CTP_CABLE_1std_logic_vector (23 downto 0)
Definition: CMX_SumEt.vhd:25
in data_to_vmestd_logic_vector (width - 1 downto 0)
in BCID_instd_logic_vector (11 downto 0)
in ENERGY_REMOTEstd_logic_vector (26 * 4 - 1 downto 0)
in bus_drive_from_belowstd_logic_vector
out CTP_CABLE_0std_logic_vector (23 downto 0)
out CTP_CABLE_0std_logic_vector (23 downto 0)
Definition: CMX_SumEt.vhd:24
std_logic counter_reset_r_local
Definition: CMX_SumEt.vhd:132