CMX
CMX firmware code in-line documentation
 All Classes Namespaces Files Functions Variables
adder_top_vs_cp.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.CMXpackage.all;
24 use work.CMX_VME_defs.all;
25 use work.CMX_flavor_package.all;
26 
27 
28 entity adder_top is
29  generic(
31  gen_system : std_logic := '1'
32  );
33  port(
34  clk : in T_SL; -- clock
35  thresholds : in arr_16(max_cps*16*4-1 downto 0); -- thresholds
36  datai : in arr_4Xword(max_cps-1 downto 0); -- input data
37  din_cbl : in T_SLV150; -- remote input (multiplicty)
38  din_cbla_ro : in T_SL; -- remote overflow
39  din_cblb_ro : in T_SL; -- remote overflow
40  din_cblc_ro : in T_SL; -- remote overflow
41  dout_lcl : out T_SLV48; -- local multiplicity
42  dout_lcl_ro : out T_SL; -- local overflow
43  dout : out T_SLV62; -- global output data (multiplicity), including parity
44  dout_ro : out T_SL; -- global overflow
45  dout_cbla_mux0 : out std_logic_vector(33 downto 0); -- cable output data (multiplicity), including parity
46  dout_cbla_mux1 : out std_logic_vector(33 downto 0); -- cable output data (multiplicity), including parity
47  --VME control:
48  ncs : in std_logic;
49  rd_nwr : in std_logic;
50  ds : in std_logic;
51  addr_vme : in std_logic_vector (15 downto 0);
52  data_vme_in : in std_logic_vector (15 downto 0);
53  data_vme_out : out std_logic_vector (15 downto 0);
54  bus_drive : out std_logic;
55  -- parity error and force handling
56  par_err : in T_SLV2; -- parity error (input module - 0, RTM - 1)
57  force : in T_SL; -- force
58  -- counter signals
59  reset : in T_SL;
60  inhibit : in T_SL
61  );
62 
63 -- Declarations
64 
65 end adder_top ;
66 
67 architecture struct of adder_top is
68 
69  -- Internal signal declarations
70  signal mult_local : T_SLV48;
71  signal internal_dout : T_SLV62;
72  signal internal_dout_cnt : T_SLV48;
73 
74 
75  signal cbla_mux0 : std_logic_vector(33 downto 0);
76  signal cbla_mux1 : std_logic_vector(33 downto 0);
77 
78  signal parity_cbla_mux0 : std_logic;
79  signal parity_cbla_mux1 : std_logic;
80 
81  signal dout_lcl_ro_int : T_SL;
82 
83  signal bus_drive_local : std_logic_vector(12*thresholds_num+1 downto 0);
84  signal data_vme_out_local : arr_16(12*thresholds_num+1 downto 0);
85 
86  signal cnt_mult_local : cnt_mult_arr(thresholds_num-1 downto 0);
87  signal cnt_mult_remote : cnt_mult_arr((3*thresholds_num)-1 downto 0);
88  signal cnt_mult_total : cnt_mult_arr(thresholds_num-1 downto 0);
89 
90  signal cnt_mult_local_2x16 : cnt_mult_arr_2x16((2*thresholds_num)-1 downto 0);
91  signal cnt_mult_remote_2x16 : cnt_mult_arr_2x16((3*2*thresholds_num)-1 downto 0);
92  signal cnt_mult_total_2x16 : cnt_mult_arr_2x16((2*thresholds_num)-1 downto 0);
93 
94  -- Component Declarations
95  component main_crt
96  port (
97  clk : in T_SL; -- clock
98  thresholds : in arr_16(max_cps*16*4-1 downto 0); -- thresholds
99  datai : in arr_4Xword(max_cps-1 downto 0); -- input data
100  dout_lcl : out T_SLV48; -- local output (multiplicity), excluding parity
101  dout_lcl_ro : out T_SL; -- local overflow
102  par_err_lcl : in T_SL; -- parity error local
103  force : in T_SL; -- force
104  disable_overflow_mask : in std_logic_vector(15 downto 0)
105  );
106  end component;
107 
108  signal disable_overflow_mask : std_logic_vector(15 downto 0);
109 
110  component main_sys
111  generic(
112  ADDR_REG_RW_PIPELINE_DELAY_LENGTH : integer := 0;
113  gen_system : std_logic := '1');
114  port (
115  clk : in T_SL; -- clock
116  din_cbl : in T_SLV150; -- remote input (multiplicity)
117  din_cbla_ro : in T_SL; -- remote overflow cbla
118  din_cblb_ro : in T_SL; -- remote overflow cblb
119  din_cblc_ro : in T_SL; -- remote overflow cblc
120  din_lcl : in T_SLV48; -- local input (multiplicity), excluding parity
121  din_lcl_ro : in T_SL; -- local overflow
122  dout : out T_SLV62; -- global output (mutliplicity) to CTP
123  dout_ro : out T_SL; -- global overflow
124  par_err_cbl : in T_SL; -- parity error
125  force : in T_SL; -- force
126  --VME control:
127  ncs : in std_logic;
128  rd_nwr : in std_logic;
129  ds : in std_logic;
130  addr_vme : in std_logic_vector (15 downto 0);
131  data_vme_in : in std_logic_vector (15 downto 0);
132  data_vme_out : out std_logic_vector (15 downto 0);
133  bus_drive : out std_logic
134  );
135  end component;
136 
137  component parity_gen
138  GENERIC(
139  width : integer := 60
140  );
141  PORT(
142  din : IN std_logic_vector (width-1 downto 0);
143  parity : OUT std_logic
144  );
145  end component;
146 
147  component vme_local_switch is
148  port (
149  data_vme_up : out std_logic_vector (15 downto 0);
150  data_vme_from_below : in arr_16;
151  bus_drive_up : out std_logic;
152  bus_drive_from_below : in std_logic_vector);
153  end component vme_local_switch;
154 
155 
156  component adder_counter is
157  generic(
158  flavor : T_SLV2 := "00"; -- JET/CPM
159  thresholds_num : integer := 25;
160  width : integer := 60
161  );
162  port(
163  clk : in std_logic; -- clock
164  reset : in std_logic; -- reset
165  inhibit : in std_logic; -- inhibit
166  data : in std_logic_vector(width-1 downto 0); -- data
167  cnt_arr : out cnt_mult_arr(thresholds_num-1 downto 0)); -- counters
168  end component adder_counter;
169 
170  component vme_outreg_notri_async is
171  generic (
172  ia_vme : integer;
173  width : integer);
174  port (
175  ncs : in std_logic;
176  rd_nwr : in std_logic;
177  ds : in std_logic;
178  addr_vme : in std_logic_vector (15 downto 0);
179  data_vme : out std_logic_vector (15 downto 0);
180  bus_drive : out std_logic;
181  data_to_vme : in std_logic_vector (width-1 downto 0));
182  end component vme_outreg_notri_async;
183 
184  component vme_inreg_notri_async is
185  generic (
186  ia_vme : integer;
187  width : integer);
188  port (
189  ncs : in std_logic;
190  rd_nwr : in std_logic;
191  ds : in std_logic;
192  addr_vme : in std_logic_vector (15 downto 0);
193  data_vme_in : in std_logic_vector (15 downto 0);
194  data_vme_out : out std_logic_vector (15 downto 0);
195  bus_drive : out std_logic;
196  data_from_vme : out std_logic_vector (width-1 downto 0);
197  data_to_vme : in std_logic_vector (width-1 downto 0));
198  end component vme_inreg_notri_async;
199 
200  signal data_from_vme_REG_RW_DISABLE_OVERFLOW_MASK : std_logic_vector(15 downto 0);
201  signal data_to_vme_REG_RW_DISABLE_OVERFLOW_MASK : std_logic_vector(15 downto 0);
202 
203 
204 begin
205 
206  vme_local_switch_inst: entity work.vme_local_switch
207  port map (
212 
213  I12 : main_crt
214  port map (
215  clk => clk,
217  datai => datai,
218  dout_lcl => mult_local,
220  par_err_lcl => par_err(0),
221  force => force,
222  disable_overflow_mask => disable_overflow_mask
223  );
224 
225  I13 : main_sys
226  generic map(
229  )
230  port map (
231  clk => clk,
232  din_cbl => din_cbl,
236  din_lcl => mult_local,
238  dout => internal_dout ,
239  dout_ro => dout_ro,
240  par_err_cbl => par_err(1),
241  force => force,
242  -- VME control:
243  ncs => ncs,
244  rd_nwr => rd_nwr,
245  ds => ds,
246  addr_vme => addr_vme,
247  data_vme_in => data_vme_in,
248  data_vme_out => data_vme_out_local(0),
249  bus_drive => bus_drive_local(0)
250  );
251 
252  dout <= internal_dout;
253 
254  I14 : parity_gen
255  generic map (
256  width => 24
257  )
258  port map (
259  din => internal_dout(23 downto 0),
261  );
262 
263  I15 : parity_gen
264  generic map (
265  width => 25
266  )
267  port map (
268  din => dout_lcl_ro_int & internal_dout (54 downto 31),
270  );
271 
272 
273  --
274  -- DAQ output:
275 
276  dout_lcl <= mult_local;
278 
279  dout_cbla_mux0 <= zero & parity_cbla_mux0 & frame_8 & internal_dout(23 downto 0);
280  dout_cbla_mux1 <= zero & parity_cbla_mux1 & frame_7 & dout_lcl_ro_int & internal_dout(54 downto 31);
281 
282 -- ------------------------------------------------------------------------------------
283 -- MULT LOCAL COUNTERS - SYSTEM
284 -- ------------------------------------------------------------------------------------
285 
286  gen_mult_counters_system: if gen_system = '1' generate
287 
288 
289  mult_2x16_general: for i in 0 to thresholds_num-1 generate
290 
291  cnt_mult_local_2x16(2*i) <= cnt_mult_local(i)(15 downto 0);
292  cnt_mult_local_2x16(2*i+1) <= cnt_mult_local(i)(31 downto 16);
293 
294  cnt_mult_total_2x16(2*i) <= cnt_mult_total(i)(15 downto 0);
295  cnt_mult_total_2x16(2*i+1) <= cnt_mult_total(i)(31 downto 16);
296 
297  end generate mult_2x16_general;
298 
299  mult_2x16_remote: for i in 0 to (3*thresholds_num)-1 generate
300 
301  cnt_mult_remote_2x16(2*i) <= cnt_mult_remote(i)(15 downto 0);
302  cnt_mult_remote_2x16(2*i+1) <= cnt_mult_remote(i)(31 downto 16);
303 
304  end generate mult_2x16_remote;
305 
306 
307 
308 --
309 --
310 --
311  adder_cnt_mult_local: adder_counter
312  generic map(
313  flavor => "01",
314  thresholds_num => thresholds_num,
315  width => 48
316  )
317  port map(
318  clk => clk,
319  reset => reset,
320  inhibit => inhibit,
321  data => mult_local,
322  cnt_arr => cnt_mult_local(thresholds_num-1 downto 0)
323  );
324 
325 --
326 -- VME
327 --
328  VME_CNT_MULT_LOCAL_COUNTER_i: for i in 0 to (2*thresholds_num)-1 generate
329 
330  VME_CNT_MULT_LOCAL_COUNTER: vme_outreg_notri_async
331  generic map (
332  ia_vme => ADDR_REG_RO_MULT_LOCAL_COUNTER+(2*i),
333  width => 16)
334  port map (
335  addr_vme => addr_vme,
336  ncs => ncs,
337  rd_nwr => rd_nwr ,
338  ds => ds,
340  data_vme => data_vme_out_local (i+1),
341  bus_drive => bus_drive_local(i+1)
342  );
343 
344  end generate VME_CNT_MULT_LOCAL_COUNTER_i;
345 
346 -- ------------------------------------------------------------------------------------
347 -- MULT REMOTE COUNTERS
348 -- ------------------------------------------------------------------------------------
349 --
350 --
351 --
352  adder_cnt_mult_remote: adder_counter
353  generic map(
354  flavor => "01",
355  thresholds_num => thresholds_num*3 ,
356  width => 144
357  )
358  port map(
359  clk => clk,
360  reset => reset,
361  inhibit => inhibit,
362  data => din_cbl(143 downto 0),
363  cnt_arr => cnt_mult_remote((thresholds_num*3)-1 downto 0)
364  );
365 
366 
367 --
368 -- VME
369 --
370  VME_CNT_MULT_REMOTE_COUNTER_i: for i in 0 to (3*2*thresholds_num)-1 generate
371 
372  VME_CNT_MULT_REMOTE_COUNTER: vme_outreg_notri_async
373  generic map (
374  ia_vme => ADDR_REG_RO_MULT_REMOTE_COUNTER+(2*i),
375  width => 16)
376  port map (
377  addr_vme => addr_vme,
378  ncs => ncs,
379  rd_nwr => rd_nwr ,
380  ds => ds,
382  data_vme => data_vme_out_local (i+1+2*thresholds_num),
383  bus_drive => bus_drive_local(i+1+2*thresholds_num)
384  );
385 
386  end generate VME_CNT_MULT_REMOTE_COUNTER_i;
387 
388 
389 -- ------------------------------------------------------------------------------------
390 -- MULT TOTAL COUNTERS
391 -- ------------------------------------------------------------------------------------
392 --
393 -- The parity excluded.
394 --
395 
396  internal_dout_cnt(23 downto 0) <= internal_dout(23 downto 0); -- 3 bit mutliplicity
397  internal_dout_cnt(47 downto 24) <= internal_dout(54 downto 31); -- 2 bit mutliplicity
398 
399 
400  adder_cnt_mult_total: adder_counter
401  generic map(
402  flavor => "01",
403  thresholds_num => thresholds_num,
404  width => 48
405  )
406  port map(
407  clk => clk,
408  reset => reset,
409  inhibit => inhibit,
411  cnt_arr => cnt_mult_total(thresholds_num-1 downto 0)
412  );
413 
414 --
415 -- VME
416 --
417  VME_CNT_MULT_TOTAL_COUNTER_i: for i in 0 to (2*thresholds_num)-1 generate
418 
419  VME_CNT_MULT_TOTAL_COUNTER: vme_outreg_notri_async
420  generic map (
421  ia_vme => ADDR_REG_RO_MULT_TOTAL_COUNTER+(2*i),
422  width => 16)
423  port map (
424  addr_vme => addr_vme,
425  ncs => ncs,
426  rd_nwr => rd_nwr ,
427  ds => ds,
429  data_vme => data_vme_out_local (i+1+2*thresholds_num+3*2*thresholds_num),
430  bus_drive => bus_drive_local(i+1+2*thresholds_num+3*2*thresholds_num)
431  );
432 
433  end generate VME_CNT_MULT_TOTAL_COUNTER_i;
434 
435 
436  end generate gen_mult_counters_system;
437 
438 
439 
440 -- ------------------------------------------------------------------------------------
441 -- MULT LOCAL COUNTERS - CRATE
442 -- ------------------------------------------------------------------------------------
443 
444  gen_mult_counters_crate: if gen_system = '0' generate
445 
446  mult_2x16: for i in 0 to thresholds_num-1 generate
447 
448  cnt_mult_local_2x16(2*i) <= cnt_mult_local(i)(15 downto 0);
449  cnt_mult_local_2x16(2*i+1) <= cnt_mult_local(i)(31 downto 16);
450 
451  end generate mult_2x16;
452 
453 
454  adder_cnt_mult_local: adder_counter
455  generic map(
456  flavor => "01",
457  thresholds_num => thresholds_num,
458  width => 48
459  )
460  port map(
461  clk => clk,
462  reset => reset,
463  inhibit => inhibit,
464  data => mult_local,
465  cnt_arr => cnt_mult_local(thresholds_num-1 downto 0)
466  );
467 
468 --
469 -- VME
470 --
471  VME_CNT_MULT_LOCAL_COUNTER_i: for i in 0 to (2*thresholds_num)-1 generate
472 
473  VME_CNT_MULT_LOCAL_COUNTER: vme_outreg_notri_async
474  generic map (
475  ia_vme => ADDR_REG_RO_MULT_LOCAL_COUNTER+(2*i),
476  width => 16)
477  port map (
478  addr_vme => addr_vme,
479  ncs => ncs,
480  rd_nwr => rd_nwr ,
481  ds => ds,
483  data_vme => data_vme_out_local (i+1),
484  bus_drive => bus_drive_local(i+1)
485  );
486 
487  end generate VME_CNT_MULT_LOCAL_COUNTER_i;
488 
489 
490  end generate gen_mult_counters_crate;
491 
492 
493 
494  vme_inreg_notri_async_REG_RW_DISABLE_OVERFLOW_MASK : entity work.vme_inreg_notri_async
495  generic map (
496  ia_vme => ADDR_REG_RW_DISABLE_OVERFLOW_MASK,
497  width => 16)
498  port map (
499  ncs => ncs,
500  rd_nwr => rd_nwr,
501  ds => ds,
502  addr_vme => addr_vme,
504  data_vme_out => data_vme_out_local(12*thresholds_num+1),
505  bus_drive => bus_drive_local(12*thresholds_num+1),
506  data_from_vme => data_from_vme_REG_RW_DISABLE_OVERFLOW_MASK,
507  data_to_vme => data_to_vme_REG_RW_DISABLE_OVERFLOW_MASK);
508 
509  data_to_vme_REG_RW_DISABLE_OVERFLOW_MASK<=data_from_vme_REG_RW_DISABLE_OVERFLOW_MASK;
510  disable_overflow_mask<=data_from_vme_REG_RW_DISABLE_OVERFLOW_MASK;
511 
512 end struct;
513 
514 
515 
516 
517 
thresholds_numinteger :=25
cnt_mult_arr_2x16 ((2 * thresholds_num) - 1 downto 0) cnt_mult_total_2x16)
T_SLV62 internal_dout
in addr_vmestd_logic_vector (15 downto 0)
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
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 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
in din_cblb_roT_SL
out doutT_SLV62
out doutT_SLV62
Definition: main_sys.vhd:40
in din_cblb_roT_SL
Definition: main_sys_cp.vhd:36
in datastd_logic_vector (width - 1 downto 0)
gen_systemstd_logic :='1'
Definition: main_sys.vhd:32
out data_vme_outstd_logic_vector (15 downto 0)
out paritystd_logic
Definition: parity_gen.vhd:24
flavorT_SLV2 :="00"
in din_cblc_roT_SL
out dout_cbla_mux1std_logic_vector (33 downto 0)
in din_cblc_roT_SL
Definition: main_sys_cp.vhd:37
_library_ ieeeieee
Definition: add3x4.vhd:13
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)
in din_cbla_roT_SL
Definition: main_sys_cp.vhd:35
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
_library_ workwork
Definition: add3x4.vhd:16
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 din_cbla_roT_SL
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
in thresholdsarr_16 (max_jems * 25 * 4 - 1 downto 0)
std_logic_vector (33 downto 0) cbla_mux0
in clkstd_logic
Definition: main_crt_vs.vhd:41
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
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