]> jspc29.x-matter.uni-frankfurt.de Git - clocked_tdc.git/commitdiff
add saving of hits exceeding maxToT
authorJan Michel <michel@physik.uni-frankfurt.de>
Fri, 23 May 2025 08:36:30 +0000 (10:36 +0200)
committerJan Michel <michel@physik.uni-frankfurt.de>
Fri, 23 May 2025 08:36:30 +0000 (10:36 +0200)
fix detection of short spikes between 8 and 16 bins

code/Decoder.vhd
code/HitBuffer.vhd
code/TDC_FF.vhd

index 267869f0e004eeee3e350b5110d4ef91820a2b31..eb5050b82041089ec7b2412954edc36593e82e50 100644 (file)
@@ -27,7 +27,7 @@ architecture arch of Decoder is
   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
 
@@ -42,9 +42,11 @@ PROC_SELECT : process 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;
 
@@ -54,6 +56,7 @@ PROC_DECODE : process begin
   
   
   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
   
@@ -69,6 +72,7 @@ PROC_DECODE : process begin
     when others => finetime(4) <= '1';  --Error
   end case;
   
+
 end process;      
 
 HIT_OUT <= finetime;
index 97805f428e57b5f8c6ca40ffbfa468330f2e6f0c..b03599789325b9e9f99c6c4ffe4bc5e10f92b2b1 100644 (file)
@@ -20,6 +20,7 @@ entity HitBuffer is
     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;
@@ -113,11 +114,20 @@ PROC_BUILD_HIT : process begin
     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);
@@ -133,6 +143,9 @@ PROC_BUILD_HIT : process begin
     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;
@@ -140,6 +153,8 @@ PROC_BUILD_HIT : process begin
 
   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;
   
 
index 8f48cea4df9a3c2459f81eed49c177838da24de7..3ad8357d234fa6a3202a4db1d8b8f28840bbc460 100644 (file)
@@ -54,6 +54,7 @@ signal hitbuffer_status : status_t;
 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);
@@ -132,6 +133,7 @@ gen_CHANNELS : for i in 0 to NUM_CHANNELS-1 generate
       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),