config.samples_after <= to_unsigned(8 ,11);
config.block_count <= to_unsigned(2 , 2);
config.trigger_threshold <= to_unsigned(30 ,18);
+config.trigger_threshold(16) <= '1'; -- invert polarity
config.readout_threshold <= to_unsigned(30 ,18);
config.presum <= to_unsigned(0 , 8);
config.averaging <= to_unsigned(6 , 4);
begin
wait until rising_edge(CLK);
- cfd_subtracted(ch) <= signed(resize(reg_ram_data_out(ch)(15 downto 0), cfd_subtracted(ch)'length)) - signed(resize(baseline(ch), cfd_subtracted(ch)'length));
-
+ if CONF.trigger_threshold(16) = '0' then
+ cfd_subtracted(ch) <= signed(resize(reg_ram_data_out(ch)(15 downto 0), cfd_subtracted(ch)'length))
+ - signed(resize(baseline(ch), cfd_subtracted(ch)'length));
+ else
+ cfd_subtracted(ch) <= signed(resize(baseline(ch), cfd_subtracted(ch)'length))
+ - signed(resize(reg_ram_data_out(ch)(15 downto 0), cfd_subtracted(ch)'length));
+ end if;
+
cfd_delay_ram(ch)(0) <= cfd_subtracted(ch);
gen_cfd_delay : for i in 0 to cfd_delay_ram(ch)'length - 2 loop
cfd_delay_ram(ch)(i + 1) <= cfd_delay_ram(ch)(i);