CMX
CMX firmware code in-line documentation
 All Classes Namespaces Files Functions Variables
adder_top_vs.vhd
Go to the documentation of this file.
1 
18 
19 LIBRARY ieee;
20 USE ieee.std_logic_1164.all;
21 USE ieee.numeric_std.all;
22 LIBRARY work;
23 use work.CMX_VME_defs.all;
24 use work.CMXpackage.all;
25 use work.CMX_flavor_package.all;
26 
27 
28 entity adder_top is
29  generic(
30  numactchan : integer := 16;
32  gen_system : std_logic := '1'
33  );
34  port(
35  clk : in T_SL; -- clock
36  thresholds : in arr_16(max_jems*25*4-1 downto 0); -- thresholds
37  datai : in arr_4Xword(max_jems-1 downto 0); -- input data
38  din_cbl : in T_SLV65; -- remote input (multiplicty)
39  din_cbl_ro : in T_SL; -- remote input (overflow)
40  dout_lcl : out std_logic_vector(59 downto 0); -- local multiplicity
41  dout_lcl_ro : out T_SL; -- local overflow
42  dout : out T_SLV62; -- global output data (multiplicity), including parity
43  dout_ro : out T_SL; -- global overflow
44  dout_cbla_mux0 : out std_logic_vector(33 downto 0); -- cable output data (multiplicity), including parity
45  dout_cbla_mux1 : out std_logic_vector(33 downto 0); -- cable output data (multiplicity), including parity
46  dout_cblb_mux0 : out std_logic_vector(33 downto 0); -- cable output data (multiplicity), including parity
47  dout_cblb_mux1 : out std_logic_vector(33 downto 0); -- cable output data (multiplicity), including parity
48  --VME control:
49  ncs : in std_logic;
50  rd_nwr : in std_logic;
51  ds : in std_logic;
52  addr_vme : in std_logic_vector (15 downto 0);
53  data_vme_in : in std_logic_vector (15 downto 0);
54  data_vme_out : out std_logic_vector (15 downto 0);
55  bus_drive : out std_logic;
56  -- parity error and quiet_force handling
57  par_err : in T_SLV2; -- parity error (input module - 0, RTM - 1)
58  force : in T_SL; -- force
59  -- counter signals
60  reset : in T_SL;
61  inhibit : in T_SL
62  );
63 
64 -- Declarations
65 
66 end adder_top;
67 
68 architecture struct of adder_top is
69 
70  -- Internal signal declarations
71  signal mult_local : T_SLV60;
72  signal internal_dout : T_SLV62;
73  signal internal_dout_cnt : T_SLV60;
74 
75  signal cbla_mux0 : std_logic_vector(33 downto 0);
76  signal cbla_mux1 : std_logic_vector(33 downto 0);
77  signal cblb_mux0 : std_logic_vector(33 downto 0);
78  signal cblb_mux1 : std_logic_vector(33 downto 0);
79 
80  signal parity_cbla_mux0 : std_logic;
81  signal parity_cbla_mux1 : std_logic;
82  signal parity_cblb_mux0 : std_logic;
83  signal parity_cblb_mux1 : std_logic;
84 
85  signal dout_lcl_ro_int : T_SL;
86 
87  signal bus_drive_local : std_logic_vector(6*thresholds_num+1 downto 0);
88  signal data_vme_out_local : arr_16(6*thresholds_num+1 downto 0);
89 
90  signal cnt_mult_local : cnt_mult_arr(thresholds_num-1 downto 0);
91  signal cnt_mult_remote : cnt_mult_arr(thresholds_num-1 downto 0);
92  signal cnt_mult_total : cnt_mult_arr(thresholds_num-1 downto 0);
93 
94  signal cnt_mult_local_2x16 : cnt_mult_arr_2x16((2*thresholds_num)-1 downto 0);
95  signal cnt_mult_remote_2x16 : cnt_mult_arr_2x16((2*thresholds_num)-1 downto 0);
96  signal cnt_mult_total_2x16 : cnt_mult_arr_2x16((2*thresholds_num)-1 downto 0);
97 
98 
99 
100  -- Component Declarations
101  component main_crt
102  generic(
103  numactchan : integer := 16);
104  port (
105  clk : in T_SL; -- clock
106  thresholds : in arr_16(max_jems*25*4-1 downto 0); -- thresholds
107  datai : in arr_4Xword(max_jems-1 downto 0); -- input data
108  dout_lcl : out T_SLV60; -- local output (multiplicity), excluding parity
109  dout_lcl_ro : out T_SL; -- overflow local
110  par_err_lcl : in T_SL; -- parity error local
111  force : in T_SL; -- force
112  disable_overflow_mask : in std_logic_vector(15 downto 0)
113  );
114  end component;
115 
116  signal disable_overflow_mask : std_logic_vector(15 downto 0);
117 
118  component main_sys
119  generic(
120  numactchan : integer := 16;
121  ADDR_REG_RW_PIPELINE_DELAY_LENGTH : integer := 0;
122  gen_system : std_logic := '1');
123  port (
124  clk : in T_SL; -- clock
125  din_cbl : in T_SLV65; -- remote input (multiplicity)
126  din_cbl_ro : in T_SL; -- remote input (overflow)
127  din_lcl : in T_SLV60; -- local input (multiplicity), excluding parity
128  din_lcl_ro : in T_SL; -- local input (overflow)
129  dout : out T_SLV62; -- global output (mutliplicity) to CTP
130  dout_ro : out T_SL; -- global overflow
131  par_err_cbl : in T_SL; -- parity error
132  force : in T_SL; -- force
133  --VME control:
134  ncs : in std_logic;
135  rd_nwr : in std_logic;
136  ds : in std_logic;
137  addr_vme : in std_logic_vector (15 downto 0);
138  data_vme_in : in std_logic_vector (15 downto 0);
139  data_vme_out : out std_logic_vector (15 downto 0);
140  bus_drive : out std_logic
141  );
142  end component;
143 
144  component parity_gen
145  GENERIC(
146  width : integer := 60
147  );
148  PORT(
149  din : IN std_logic_vector (width-1 downto 0);
150  parity : OUT std_logic
151  );
152  end component;
153 
154  component vme_local_switch is
155  port (
156  data_vme_up : out std_logic_vector (15 downto 0);
157  data_vme_from_below : in arr_16;
158  bus_drive_up : out std_logic;
159  bus_drive_from_below : in std_logic_vector);
160  end component vme_local_switch;
161 
162  component adder_counter is
163  generic(
164  flavor : T_SLV2 := "00"; -- JET/CPM/SUMET
165  thresholds_num : integer := 25;
166  width : integer := 60
167  );
168  port(
169  clk : in std_logic; -- clock
170  reset : in std_logic; -- reset
171  inhibit : in std_logic; -- inhibit
172  data : in std_logic_vector(width-1 downto 0); -- data
173  cnt_arr : out cnt_mult_arr(thresholds_num-1 downto 0)); -- counters
174  end component adder_counter;
175 
176  component vme_outreg_notri_async is
177  generic (
178  ia_vme : integer;
179  width : integer);
180  port (
181  ncs : in std_logic;
182  rd_nwr : in std_logic;
183  ds : in std_logic;
184  addr_vme : in std_logic_vector (15 downto 0);
185  data_vme : out std_logic_vector (15 downto 0);
186  bus_drive : out std_logic;
187  data_to_vme : in std_logic_vector (width-1 downto 0));
188  end component vme_outreg_notri_async;
189 
190  signal data_from_vme_REG_RW_DISABLE_OVERFLOW_MASK : std_logic_vector(15 downto 0);
191  signal data_to_vme_REG_RW_DISABLE_OVERFLOW_MASK : std_logic_vector(15 downto 0);
192 
193 
194 begin
195 
196  vme_local_switch_inst : entity work.vme_local_switch
197  port map (
202 
203  I12 : main_crt
204  generic map (
206  )
207  port map (
208  clk => clk,
210  datai => datai,
211  dout_lcl => mult_local,
213  par_err_lcl => par_err(0),
214  force => force,
215  disable_overflow_mask => disable_overflow_mask
216  );
217 
218  I13 : main_sys
219  generic map(
223  )
224  port map (
225  clk => clk,
226  din_cbl => din_cbl,
228  din_lcl => mult_local,
230  dout => internal_dout,
231  dout_ro => dout_ro,
232  par_err_cbl => par_err(1),
233  force => force,
234  -- VME control:
235  ncs => ncs,
236  rd_nwr => rd_nwr,
237  ds => ds,
238  addr_vme => addr_vme,
239  data_vme_in => data_vme_in,
240  data_vme_out => data_vme_out_local(0),
241  bus_drive => bus_drive_local(0)
242  );
243 
244  dout <= internal_dout;
245 
246  I14 : parity_gen
247  generic map (
248  width => 15
249  )
250  port map (
251  din => cbla_mux0(14 downto 0),
253  );
254 
255  I15 : parity_gen
256  generic map (
257  -- correction: overflow bit added, in total 16 bits
258  width => 16
259  )
260  port map (
261  din => cbla_mux1(15 downto 0),
263  );
264 
265  I16 : parity_gen
266  generic map (
267  width => 16
268  )
269  port map (
270  din => cblb_mux0(15 downto 0),
272  );
273 
274  I17 : parity_gen
275  generic map (
276  width => 14
277  )
278  port map (
279  din => cblb_mux1 (13 downto 0),
281  );
282 
283 --
284 -- DAQ output:
285 --
286  dout_lcl <= mult_local;
288 
289 --
290 -- Cable: Crate - System Output
291 --
292  cbla_mux0 <= zero & parity_cbla_mux0 & frame_17 & internal_dout(14 downto 0);
293  cbla_mux1 <= zero & parity_cbla_mux1 & frame_16 & dout_lcl_ro_int & internal_dout(29 downto 15);
294 
295  cblb_mux0 <= zero & parity_cblb_mux0 & frame_16 & internal_dout(46 downto 31);
296  cblb_mux1 <= zero & parity_cblb_mux1 & frame_18 & internal_dout(60 downto 47);
297 
298 
301 
304 
305 
306 -- ------------------------------------------------------------------------------------
307 -- MULT LOCAL COUNTERS - SYSTEM
308 -- ------------------------------------------------------------------------------------
309 
310  gen_mult_counters_system: if gen_system = '1' generate
311 
312 
313  mult_2x16: for i in 0 to thresholds_num-1 generate
314 
315  cnt_mult_local_2x16(2*i) <= cnt_mult_local(i)(15 downto 0);
316  cnt_mult_local_2x16(2*i+1) <= cnt_mult_local(i)(31 downto 16);
317 
318  cnt_mult_remote_2x16(2*i) <= cnt_mult_remote(i)(15 downto 0);
319  cnt_mult_remote_2x16(2*i+1) <= cnt_mult_remote(i)(31 downto 16);
320 
321  cnt_mult_total_2x16(2*i) <= cnt_mult_total(i)(15 downto 0);
322  cnt_mult_total_2x16(2*i+1) <= cnt_mult_total(i)(31 downto 16);
323 
324  end generate mult_2x16;
325 
326 
327 --
328 --
329 --
330  adder_cnt_mult_local: adder_counter
331  generic map(
332  flavor => "00",
333  thresholds_num => thresholds_num,
334  width => 60
335  )
336  port map(
337  clk => clk,
338  reset => reset,
339  inhibit => inhibit,
340  data => mult_local,
341  cnt_arr => cnt_mult_local(thresholds_num-1 downto 0)
342  );
343 
344 --
345 -- VME
346 --
347  VME_CNT_MULT_LOCAL_COUNTER_i: for i in 0 to (2*thresholds_num)-1 generate
348 
349  VME_CNT_MULT_LOCAL_COUNTER: vme_outreg_notri_async
350  generic map (
351  ia_vme => ADDR_REG_RO_MULT_LOCAL_COUNTER+(2*i),
352  width => 16)
353  port map (
354  addr_vme => addr_vme,
355  ncs => ncs,
356  rd_nwr => rd_nwr ,
357  ds => ds,
359  data_vme => data_vme_out_local (i+1),
360  bus_drive => bus_drive_local(i+1)
361  );
362 
363  end generate VME_CNT_MULT_LOCAL_COUNTER_i;
364 
365 -- ------------------------------------------------------------------------------------
366 -- MULT REMOTE COUNTERS
367 -- ------------------------------------------------------------------------------------
368 --
369 --
370 --
371  adder_cnt_mult_remote: adder_counter
372  generic map(
373  flavor => "00",
374  thresholds_num => 25,
375  width => 60
376  )
377  port map(
378  clk => clk,
379  reset => reset,
380  inhibit => inhibit,
381  data => din_cbl(59 downto 0),
382  cnt_arr => cnt_mult_remote(thresholds_num-1 downto 0)
383  );
384 
385 
386 --
387 -- VME
388 --
389  VME_CNT_MULT_REMOTE_COUNTER_i: for i in 0 to (2*thresholds_num)-1 generate
390 
391  VME_CNT_MULT_REMOTE_COUNTER: vme_outreg_notri_async
392  generic map (
393  ia_vme => ADDR_REG_RO_MULT_REMOTE_COUNTER+(2*i),
394  width => 16)
395  port map (
396  addr_vme => addr_vme,
397  ncs => ncs,
398  rd_nwr => rd_nwr ,
399  ds => ds,
401  data_vme => data_vme_out_local (i+1+2*thresholds_num),
402  bus_drive => bus_drive_local(i+1+2*thresholds_num)
403  );
404 
405  end generate VME_CNT_MULT_REMOTE_COUNTER_i;
406 
407 
408 -- ------------------------------------------------------------------------------------
409 -- MULT TOTAL COUNTERS
410 -- ------------------------------------------------------------------------------------
411 --
412 -- The parity excluded.
413 --
414  internal_dout_cnt(29 downto 0) <= internal_dout(29 downto 0); -- 3 bit mutliplicity
415  internal_dout_cnt(59 downto 30) <= internal_dout(60 downto 31); -- 2 bit mutliplicity
416 
417 
418  adder_cnt_mult_total: adder_counter
419  generic map(
420  flavor => "00",
421  thresholds_num => thresholds_num,
422  width => 60
423  )
424  port map(
425  clk => clk,
426  reset => reset,
427  inhibit => inhibit,
429  cnt_arr => cnt_mult_total(thresholds_num-1 downto 0)
430  );
431 
432 --
433 -- VME
434 --
435  VME_CNT_MULT_TOTAL_COUNTER_i: for i in 0 to (2*thresholds_num)-1 generate
436 
437  VME_CNT_MULT_TOTAL_COUNTER: vme_outreg_notri_async
438  generic map (
439  ia_vme => ADDR_REG_RO_MULT_TOTAL_COUNTER+(2*i),
440  width => 16)
441  port map (
442  addr_vme => addr_vme,
443  ncs => ncs,
444  rd_nwr => rd_nwr ,
445  ds => ds,
447  data_vme => data_vme_out_local (i+1+2*thresholds_num+2*thresholds_num),
448  bus_drive => bus_drive_local(i+1+2*thresholds_num+2*thresholds_num)
449  );
450 
451  end generate VME_CNT_MULT_TOTAL_COUNTER_i;
452 
453 
454  end generate gen_mult_counters_system;
455 
456 
457 
458 -- ------------------------------------------------------------------------------------
459 -- MULT LOCAL COUNTERS - CRATE
460 -- ------------------------------------------------------------------------------------
461 
462  gen_mult_counters_crate: if gen_system = '0' generate
463 
464  mult_2x16: for i in 0 to thresholds_num-1 generate
465 
466  cnt_mult_local_2x16(2*i) <= cnt_mult_local(i)(15 downto 0);
467  cnt_mult_local_2x16(2*i+1) <= cnt_mult_local(i)(31 downto 16);
468 
469  end generate mult_2x16;
470 
471 
472  adder_cnt_mult_local: adder_counter
473  generic map(
474  flavor => "00",
475  thresholds_num => thresholds_num,
476  width => 60
477  )
478  port map(
479  clk => clk,
480  reset => reset,
481  inhibit => inhibit,
482  data => mult_local,
483  cnt_arr => cnt_mult_local(thresholds_num-1 downto 0)
484  );
485 
486 --
487 -- VME
488 --
489  VME_CNT_MULT_LOCAL_COUNTER_i: for i in 0 to (2*thresholds_num)-1 generate
490 
491  VME_CNT_MULT_LOCAL_COUNTER: vme_outreg_notri_async
492  generic map (
493  ia_vme => ADDR_REG_RO_MULT_LOCAL_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),
502  bus_drive => bus_drive_local(i+1)
503  );
504 
505  end generate VME_CNT_MULT_LOCAL_COUNTER_i;
506 
507 
508  end generate gen_mult_counters_crate;
509 
510 
511 
512  vme_inreg_notri_async_REG_RW_DISABLE_OVERFLOW_MASK : entity work.vme_inreg_notri_async
513  generic map (
514  ia_vme => ADDR_REG_RW_DISABLE_OVERFLOW_MASK,
515  width => 16)
516  port map (
517  ncs => ncs,
518  rd_nwr => rd_nwr,
519  ds => ds,
520  addr_vme => addr_vme,
522  data_vme_out => data_vme_out_local(6*thresholds_num+1),
523  bus_drive => bus_drive_local(6*thresholds_num+1),
524  data_from_vme => data_from_vme_REG_RW_DISABLE_OVERFLOW_MASK,
525  data_to_vme => data_to_vme_REG_RW_DISABLE_OVERFLOW_MASK);
526 
527  data_to_vme_REG_RW_DISABLE_OVERFLOW_MASK<=data_from_vme_REG_RW_DISABLE_OVERFLOW_MASK;
528  disable_overflow_mask<=data_from_vme_REG_RW_DISABLE_OVERFLOW_MASK;
529 
530 
531 end struct;
532 
533 
534 
535 
536 
thresholds_numinteger :=25
cnt_mult_arr_2x16 ((2 * thresholds_num) - 1 downto 0) cnt_mult_total_2x16)
T_SLV62 internal_dout
numactchaninteger :=16
Definition: main_crt_vs.vhd:38
in addr_vmestd_logic_vector (15 downto 0)
std_logic_vector (33 downto 0) cblb_mux1
in din_cblT_SLV65
in dsstd_logic
out data_vmestd_logic_vector (15 downto 0)
in din_lcl_roT_SL
Definition: main_sys.vhd:39
numactchaninteger :=16
std_logic parity_cbla_mux1
in par_err_cblT_SL
Definition: main_sys.vhd:42
out dout_cbla_mux0std_logic_vector (33 downto 0)
cnt_mult_arr (thresholds_num - 1 downto 0) cnt_mult_local
out dout_lclstd_logic_vector (59 downto 0)
arr_16 (12 * thresholds_num + 1 downto 0) data_vme_out_local)
out dout_cblb_mux0std_logic_vector (33 downto 0)
out data_from_vmestd_logic_vector (width - 1 downto 0)
out dout_roT_SL
Definition: main_sys.vhd:41
cnt_mult_arr_2x16 ((3 * 2 * thresholds_num) - 1 downto 0) cnt_mult_remote_2x16)
out dout_lclT_SLV60
Definition: main_crt_vs.vhd:44
in data_vme_from_belowarr_16
--! inputs from local registers and from
in par_err_lclT_SL
Definition: main_crt_vs.vhd:46
cnt_mult_arr ((3 * thresholds_num) - 1 downto 0) cnt_mult_remote)
out dout_lcl_roT_SL
in data_vme_instd_logic_vector (15 downto 0)
in ncsstd_logic
out doutT_SLV62
out doutT_SLV62
Definition: main_sys.vhd:40
in datastd_logic_vector (width - 1 downto 0)
in din_cbl_roT_SL
gen_systemstd_logic :='1'
Definition: main_sys.vhd:32
in din_cbl_roT_SL
Definition: main_sys.vhd:37
out data_vme_outstd_logic_vector (15 downto 0)
out paritystd_logic
Definition: parity_gen.vhd:24
std_logic parity_cblb_mux1
flavorT_SLV2 :="00"
out dout_cbla_mux1std_logic_vector (33 downto 0)
numactchaninteger :=16
Definition: main_sys.vhd:30
in data_to_vmestd_logic_vector (width - 1 downto 0)
out dout_lcl_roT_SL
Definition: main_crt_vs.vhd:45
out data_vme_upstd_logic_vector (15 downto 0)
--! connect this to
in clkT_SL
in din_lclT_SLV60
Definition: main_sys.vhd:38
in din_cblT_SLV65
Definition: main_sys.vhd:36
in addr_vmestd_logic_vector (15 downto 0)
cnt_mult_arr_2x16 ((2 * thresholds_num) - 1 downto 0) cnt_mult_local_2x16)
ADDR_REG_RW_PIPELINE_DELAY_LENGTHinteger :=0
Definition: main_sys.vhd:31
out bus_drive_upstd_logic
or of all bus drive requests from below
std_logic_vector (33 downto 0) cbla_mux1
gen_systemstd_logic :='1'
widthinteger :=60
Definition: parity_gen.vhd:20
std_logic parity_cbla_mux0
in par_errT_SLV2
std_logic_vector (12 * thresholds_num + 1 downto 0) bus_drive_local)
out cnt_arrcnt_mult_arr (thresholds_num - 1 downto 0)
in dataiarr_4Xword (max_jems - 1 downto 0)
Definition: main_crt_vs.vhd:43
in clkT_SL
Definition: main_sys.vhd:35
out data_vme_outstd_logic_vector (15 downto 0)
out bus_drivestd_logic
out dout_roT_SL
widthinteger :=60
in dataiarr_4Xword (max_jems - 1 downto 0)
test registers
cnt_mult_arr (thresholds_num - 1 downto 0) cnt_mult_total
in dinstd_logic_vector (width - 1 downto 0)
Definition: parity_gen.vhd:23
std_logic parity_cblb_mux0
in thresholdsarr_16 (max_jems * 25 * 4 - 1 downto 0)
std_logic_vector (33 downto 0) cblb_mux0
std_logic_vector (33 downto 0) cbla_mux0
in clkstd_logic
Definition: main_crt_vs.vhd:41
out dout_cblb_mux1std_logic_vector (33 downto 0)
in data_vme_instd_logic_vector (15 downto 0)
in data_to_vmestd_logic_vector (width - 1 downto 0)
in thresholdsarr_16 (max_jems * 25 * 4 - 1 downto 0)
Definition: main_crt_vs.vhd:42
_library_ ieeeieee
Definition: add3x2.vhd:12
in addr_vmestd_logic_vector (15 downto 0)
in bus_drive_from_belowstd_logic_vector
in rd_nwrstd_logic
ADDR_REG_RW_PIPELINE_DELAY_LENGTHinteger :=0