@@ -38,8 +38,6 @@ module tdc_core #(
3838 output wire [31 :0 ] event_cnt
3939);
4040
41-
42-
4341localparam dlyline_bits = 96 ; // TODO: should this be a localparam?
4442localparam clk_ratio = 3 ;
4543// The following numbers of bits should add up to 33, as the bus is 32 bit and
@@ -50,9 +48,7 @@ localparam fine_time_bits = 2; // We need that clk_ratio <= 2^fine_time_bits
5048localparam state_bits = 4 ;
5149localparam word_type_bits = 3 ; // TODO: this isn't yet parametric
5250
53-
54-
55- // corse counter.
51+ // Coarse counter
5652wire [corsebits- 1 :0 ] corse_count;
5753wire counter_count, counter_reset;
5854// TODO: should clip_reset be set?
@@ -81,6 +77,26 @@ clock_divider #(.DIVISOR(14)) calib_sig_gen (
8177 .CLOCK(sig_calib)
8278);
8379
80+ // Stretch trig_in to make sure we do not miss very short pulses (such as scintillator)
81+ reg [1 :0 ] cnt;
82+ reg trig_in_delayed;
83+ always @(posedge trig_in or posedge CLK or posedge rst) begin
84+ if (rst) begin
85+ trig_in_delayed <= 0 ;
86+ cnt <= 0 ;
87+ end
88+ else if (trig_in) begin // asynchronous trigger in
89+ trig_in_delayed <= 1'b1 ;
90+ cnt <= 2'd2 ;
91+ end
92+ else begin // synchronous trigger out
93+ if (cnt != 0 )
94+ cnt <= cnt - 1 ;
95+
96+ if (cnt == 1 )
97+ trig_in_delayed <= 0 ;
98+ end
99+ end
84100
85101// Input mux addresses for more verbose code
86102// For 4 inputs, 2 bits are sufficient
@@ -103,7 +119,7 @@ always @ (posedge CLK)
103119 input_mux_addr_buf <= input_mux_addr;
104120always @(* ) begin
105121 case (input_mux_addr_buf)
106- TRIG_IN: tdl_input <= trig_in ;
122+ TRIG_IN: tdl_input <= trig_in_delayed ;
107123 SIG_IN: tdl_input <= sig_in;
108124 SIG_IN_B: tdl_input <= ~ sig_in;
109125 CALIB_OSC: tdl_input <= sig_calib;
0 commit comments