signal hit_in_reg : std_logic_vector(CHANNEL_NUMBER-1 downto 1);
signal ref_in_reg : std_logic;
-
+ signal trg_handler_trg_valid : std_logic;
attribute syn_keep : boolean;
attribute syn_keep of reset_tdc : signal is true;
if FPGA_TYPE = 3 then
cal_cntr <= "11100";
elsif FPGA_TYPE = 5 then
- cal_cntr <= "01000";
+ cal_cntr <= "11000";
end if;
else
cal_cntr <= std_logic_vector(unsigned(cal_cntr) + to_unsigned(1, 5));
RESET_TRG => reset_rdo,
RESET_RDO => reset_rdo,
RESET_TDC => reset_tdc,
- VALID_TIMING_TRG_IN => busreadout_rx.valid_timing_trg,
+ VALID_TIMING_TRG_IN => trg_handler_trg_valid,
VALID_NOTIMING_TRG_IN => busreadout_rx.valid_notiming_trg,
TRG_TYPE_IN => busreadout_rx.trg_type,
TRG_RELEASE_IN => busreadout_tx.busy_release,
DEBUG_OUT => trg_handler_status_registers
);
trg_in <= REFERENCE_TIME;
-
+ trg_handler_trg_valid <= busreadout_rx.valid_timing_trg or busreadout_rx.invalid_trg;
+
-------------------------------------------------------------------------------
-- Readout
-------------------------------------------------------------------------------
trg_in_2r <= trg_in_r when rising_edge(CLK_TDC);
trg_in_3r <= trg_in_2r when rising_edge(CLK_TDC);
- GEN_TRIGGER : for i in 0 to TRIGGER_NUM-1 generate
- Validation : process (CLK_TDC)
- begin
- if rising_edge(CLK_TDC) then
-
- -- calculate trigger length
- if trg_in_3r(i) = '0' then
- trg_length(i) <= (others => '0');
- else
- trg_length(i) <= trg_length(i) + to_unsigned(1, 5);
- end if;
-
- -- accept trigger if it is longer than 100 ns
- if RESET_TDC = '1' then
- trg_pulse_tdc(i) <= '0';
- elsif trg_length(i) = to_unsigned(15, 5) then
- trg_pulse_tdc(i) <= '1';
- else
- trg_pulse_tdc(i) <= '0';
- end if;
+-- GEN_TRIGGER : for i in 0 to TRIGGER_NUM-1 generate
+-- Validation : process (CLK_TDC)
+-- begin
+-- if rising_edge(CLK_TDC) then
+--
+-- -- calculate trigger length
+-- if trg_in_3r(i) = '0' then
+-- trg_length(i) <= (others => '0');
+-- else
+-- trg_length(i) <= trg_length(i) + to_unsigned(1, 5);
+-- end if;
+--
+-- -- accept trigger if it is longer than 100 ns
+-- if RESET_TDC = '1' then
+-- trg_pulse_tdc(i) <= '0';
+-- elsif trg_length(i) = to_unsigned(15, 5) then
+-- trg_pulse_tdc(i) <= '1';
+-- else
+-- trg_pulse_tdc(i) <= '0';
+-- end if;
+--
+-- end if;
+-- end process Validation;
+-- end generate GEN_TRIGGER;
+trg_pulse_tdc(0) <= valid_timing_200;
- end if;
- end process Validation;
- end generate GEN_TRIGGER;
-- sync the strobes to the readout clock domain
GEN_TDC : for i in 0 to TRIGGER_NUM-1 generate
case STATE_TW_CURRENT is
when IDLE =>
- if trg_in_3r(0) = '1' then
+ if valid_timing_200 = '1' and trg_in_3r(0) = '1' then
if TRG_WIN_EN_IN = '1' then
STATE_TW_NEXT <= COUNT;
else