8 use IEEE.STD_LOGIC_1164.
all;
9 use IEEE.NUMERIC_STD.
all;
11 library infrastructure_lib;
12 use infrastructure_lib.counter;
22 use ipbus_lib.ipbus_reg_types.
all;
24 use ipbus_lib.ipbus.
all;
35 IN_BCN : in std_logic_vector(11 downto 0);
36 IN_synch : in std_logic;
37 IN_eta : in std_logic_vector(2 downto 0);
39 IN_eg_energies : in array_std_logic_vector(OUTPUT_TOBS-1 downto 0)(ENERGY_WIDTH-1 downto 0);
40 IN_eg_valids : in std_logic_vector(OUTPUT_TOBS-1 downto 0);
42 IN_tau_energies : in array_std_logic_vector(OUTPUT_TOBS-1 downto 0)(ENERGY_WIDTH-1 downto 0);
43 IN_tau_valids : in std_logic_vector(OUTPUT_TOBS-1 downto 0));
52 signal write_reg : ipb_reg_v(N_STAT - 1 downto 0) := (others => (others => '0'));
53 signal read_reg : ipb_reg_v(N_CTRL - 1 downto 0);
55 signal enable, counter_reset, reset, sync : std_logic;
56 signal energy_threshold_eg, energy_threshold_tau : std_logic_vector(ENERGY_WIDTH-1 downto 0);
57 signal sync_d : std_logic_vector (2 downto 0);
58 signal counter_start, counter_stop : std_logic;
59 signal status, control : std_logic_vector(31 downto 0);
61 signal right_eta : std_logic_vector(5 downto 0);
62 signal eta_eg, eta_tau : std_logic_vector(7 downto 0);
63 signal normalisation_saturated : std_logic;
65 type STATE_TYPE is (ready, idle, run);
66 signal state : STATE_TYPE;
69 attribute keep : string ;
70 attribute max_fanout : integer;
71 attribute keep of read_reg : signal is "true" ;
72 attribute max_fanout of read_reg : signal is 1000;
73 attribute keep of reset : signal is "true" ;
74 attribute max_fanout of reset : signal is 1000;
79 IPBUS_ALGO_REGISTERS :
entity ipbus_lib.ipbus_ctrlreg_v
93 control <= read_reg(0);
94 energy_threshold_eg <= read_reg(1)(15 downto 0);
95 energy_threshold_tau <= read_reg(1)(31 downto 16);
97 write_reg(N_STAT-1) <= status;
100 counter_start <= control(0);
101 counter_stop <= control(1);
102 counter_reset <= control(2);
105 synch_delay :
process (clk)
107 if rising_edge(clk) then
108 sync_d(0) <= IN_synch;
109 sync_d(2 downto 1) <= sync_d(1 downto 0);
115 enable_proc :
process (clk)
117 if rising_edge(clk) then
119 if counter_reset = '1' then
130 if counter_start = '1' then
141 if counter_stop = '1' then
161 status(1 downto 0) <= "11" when state = run else
162 "01" when state = ready else
168 eg_tau_for : for phi in OUTPUT_TOBS-1 downto 0 generate
169 eta_eg(phi) <= '1' when IN_eg_valids(phi) = '1' and not (unsigned(IN_eg_energies(phi)) < unsigned(energy_threshold_eg)) else '0';
170 eta_tau(phi) <= '1' when IN_tau_valids(phi) = '1' and not (unsigned(IN_tau_energies(phi)) < unsigned(energy_threshold_tau)) else '0';
173 eta_for : for eta in 5 downto 0 generate
174 right_eta(eta) <= '1' when unsigned(IN_eta) = eta else '0';
175 phi_for : for phi in OUTPUT_TOBS-1 downto 0 generate
176 CNT_EG :
entity infrastructure_lib.
counter
177 generic map (DEPTH =>
32)
180 enable1 => enable
and right_eta
(eta
),
181 enable2 => eta_eg
(phi
) and not normalisation_saturated,
182 count => write_reg
(phi*6 + eta
),
186 CNT_TAU :
entity infrastructure_lib.
counter
187 generic map (DEPTH =>
32)
190 enable1 => enable
and right_eta
(eta
),
191 enable2 => eta_tau
(phi
) and not normalisation_saturated,
192 count => write_reg
(48 + phi*6 + eta
),
199 NORMALISATION_CNT :
entity infrastructure_lib.
counter
200 generic map (DEPTH =>
32)
External data-types and functions.
positive := 2 N_CTRL
Number of control IPBus reg.
positive := 98 N_STAT
Number of status IPBus reg.
in ipb_rst std_logic
IPBus reset.
in ipb_clk std_logic
IPBus clk.
out ipb_out ipb_rbus
IPBus read bus.
in ipb_in ipb_wbus
IPBus write bus.
Counter with double enable.
in enable1 std_logic
enable 1
out count std_logic_vector( DEPTH- 1 downto 0)
counter value
in enable2 std_logic := '1'
enable 2
out saturated std_logic
counter value