signal final_cycle : std_logic;
signal final : std_logic_vector(8 downto 0);
signal finetime : std_logic_vector(5 downto 0); -- edge, error, fine_4
-
+ signal final_short : std_logic;
begin
if (TDCregs_slow(8) xor TDCregs_slow(0)) = '1' then
final <= TDCregs_slow(8 downto 0);
final_cycle <= '0';
+ final_short <= not (TDCregs_slow(0) xor TDCregs_slow(16));
else
final <= TDCregs_slow(16 downto 8);
final_cycle <= '1';
+ final_short <= '0';
end if;
end process;
finetime(3) <= final_cycle; --4th Bit
+ finetime(4) <= final_short; --only valid if valid;
finetime(5) <= final(8); --Edge
HIT_VALID <= final(8) xor final(0); --Valid
when others => finetime(4) <= '1'; --Error
end case;
+
end process;
HIT_OUT <= finetime;
READOUT_ACTIVE : in std_logic;
SPIKE_SETTING : in unsigned(3 downto 0);
MAXTOT_SETTING : in unsigned(7 downto 0);
+ WRITE_LONG_TOT : in std_logic;
DATA_OUT : out std_logic_vector(27 downto 0);
DATA_VALID : out std_logic;
maxtot_timer <= maxtot_timer - 1;
else
edge_rising_valid <= '0';
- -- if edge_rising_valid = '1' then
- -- count_edges3 <= count_edges3 + 1;
- -- end if;
end if;
+ if READOUT_ACTIVE = '1' then
+ maxtot_timer <= x"00";
+ end if;
+
+ if maxtot_timer = x"01" then
+ full_hit <= x"00" & '0' & edge_rising_error & edge_rising(12 downto 0) & std_logic_vector(unsigned(edge_rising(12 downto 0))+("0"&MAXTOT_SETTING&"1111"));
+ if READOUT_ACTIVE = '0' and WRITE_LONG_TOT = '1' and edge_rising_error = '0' and edge_rising_valid = '1' then
+ hit_buffer_write <= '1';
+ end if;
+ edge_rising_valid <= '0';
+ spike_timer <= x"0";
+ end if;
if cdc_valid = '1' and cdc_data(5) = '1' then
edge_rising <= '1' & cdc_data(4) & '0' & cdc_data(14 downto 6) & cdc_data(3 downto 0);
elsif spike_timer /= x"0" then
count_spike_en <= '1';
end if;
+ maxtot_timer <= x"00";
+ spike_timer <= x"0";
+
if cdc_data_error = '1' or edge_rising_error = '1' then
count_edges4 <= count_edges4 + 1;
end if;
if cdc_valid = '1' and cdc_data(5) = '0' and edge_rising_valid = '0' then
count_edges4 <= count_edges4 + 1;
+ maxtot_timer <= x"00";
+ spike_timer <= x"0";
end if;
signal CONF_enable : std_logic_vector(31 downto 0) := (others => '1');
signal CONF_configure : std_logic_vector(31 downto 0) := x"01139301";
alias CONF_externalcalibration : std_logic is CONF_configure(0);
+alias CONF_write_long_tot : std_logic is CONF_configure(1);
alias CONF_SPIKE : std_logic_vector(3 downto 0) is CONF_configure(11 downto 8);
alias CONF_window : std_logic_vector(8 downto 0) is CONF_configure(20 downto 12);
alias CONF_windowafter : std_logic_vector(7 downto 0) is CONF_configure(31 downto 24);
READOUT_ACTIVE => readout_active_i(i/16),
SPIKE_SETTING => unsigned(CONF_SPIKE),
MAXTOT_SETTING => unsigned(CONF_maxTot),
+ WRITE_LONG_TOT => CONF_write_long_tot,
DATA_OUT => tdc_data(i),
DATA_VALID => tdc_data_valid(i),