CMX
CMX firmware code in-line documentation
 All Classes Namespaces Files Functions Variables
adder_counter.vhd
Go to the documentation of this file.
1 
10 
11 library ieee;
12 use ieee.std_logic_1164.all;
13 use IEEE.NUMERIC_STD.ALL;
14 library unisim;
15 use unisim.vcomponents.all;
16 
17 LIBRARY work;
18 use work.CMX_flavor_package.all;
19 
20 
21 entity adder_counter is
22  generic(
23  flavor : T_SLV2 := "00"; -- JET/CPM/SUMET
24  thresholds_num : integer := 25;
25  width : integer := 60
26  );
27  port(
28  clk : T_SL; -- clock
29  reset : T_SL; -- reset
30  inhibit : T_SL; -- inhibit
31  data : in std_logic_vector(width-1 downto 0); -- data
32  cnt_arr : out cnt_mult_arr(thresholds_num-1 downto 0) -- counters
33  );
34 
35 end adder_counter;
36 
37 architecture Behavioral of adder_counter is
38 
39  component mult_cnt is
40  generic(
41  width : integer := 3
42  );
43  port(
44  clk : in T_SL; -- clock
45  reset : in T_SL; -- reset
46  inhibit : in T_SL; -- inhibit
47  data : in std_logic_vector(width-1 downto 0); -- data
48  cnt_out : out T_SLV32 -- mult
49  );
50 
51  end component;
52 
53 
54 begin
55 
56 -- ------------------------------------------------------------------------------------
57 -- JETS MULTIPLICITY COUNTERS
58 -- ------------------------------------------------------------------------------------
59  gen_jet_mult_cnt: if flavor = "00" generate -- jets
60 
61 
62  cnt_mult_a: for i in 0 to thresholds_num-16 generate
63 
65  generic map(
66  width => 3
67  )
68  port map(
69  clk => clk, -- clock
70  reset => reset, -- reset
71  inhibit => inhibit , -- inhibit
72  data => data((3*i)+2 downto 3*i), -- data
73  cnt_out => cnt_arr (i) -- mult
74  );
75 
76  end generate cnt_mult_a;
77 
78  cnt_mult_b: for i in 0 to thresholds_num-11 generate
79 
81  generic map(
82  width => 2
83  )
84  port map(
85  clk => clk, -- clock
86  reset => reset, -- reset
87  inhibit => inhibit , -- inhibit
88  data => data(((2*i)+1)+30 downto (2*i)+30), -- data
89  cnt_out => cnt_arr (i+10) -- mult
90  );
91 
92  end generate cnt_mult_b;
93 
94  end generate gen_jet_mult_cnt;
95 
96 
97 -- ------------------------------------------------------------------------------------
98 -- CPMs MULTIPLICITY COUNTERS
99 -- ------------------------------------------------------------------------------------
100 
101  gen_cpm_mult_cnt: if flavor = "01" generate -- cpm
102 
103 
104  cnt_mult: for i in 0 to thresholds_num-1 generate
105 
106  cnt_mult_i: entity work.mult_cnt
107  generic map(
108  width => 3
109  )
110  port map(
111  clk => clk, -- clock
112  reset => reset, -- reset
113  inhibit => inhibit , -- inhibit
114  data => data((3*i)+2 downto 3*i), -- data
115  cnt_out => cnt_arr (i) -- mult
116  );
117 
118  end generate cnt_mult;
119 
120  end generate gen_cpm_mult_cnt;
121 
122 
123 
124 -- ------------------------------------------------------------------------------------
125 -- SUMEt COUNTERS
126 -- ------------------------------------------------------------------------------------
127 
128  gen_sumEt_cnt: if flavor = "10" generate -- sumEt
129 
130 
131  cnt_sumEt: for i in 0 to thresholds_num-1 generate
132 
133  cnt_sumEt_i: entity work.mult_cnt
134  generic map(
135  width => 1
136  )
137  port map(
138  clk => clk, -- clock
139  reset => reset, -- reset
140  inhibit => inhibit , -- inhibit
141  data => data(i downto i), -- data
142  cnt_out => cnt_arr (i) -- mult
143  );
144 
145  end generate cnt_sumEt;
146 
147  end generate gen_sumEt_cnt;
148 
149 
150 end Behavioral;
151 
thresholds_numinteger :=25
mult_cnt cnt_mult_a_icnt_mult_a_i
in resetT_SL
Definition: mult_cnt.vhd:30
in datastd_logic_vector (width - 1 downto 0)
flavorT_SLV2 :="00"
in inhibitT_SL
Definition: mult_cnt.vhd:31
in datastd_logic_vector (width - 1 downto 0)
Definition: mult_cnt.vhd:32
out cnt_outT_SLV32
Definition: mult_cnt.vhd:33
out cnt_arrcnt_mult_arr (thresholds_num - 1 downto 0)
mult_cnt cnt_mult_b_icnt_mult_b_i
widthinteger :=3
Definition: mult_cnt.vhd:26
widthinteger :=60
in clkT_SL
Definition: mult_cnt.vhd:29