Commit 4bbd2889 authored by Tomasz Wlostowski's avatar Tomasz Wlostowski

fmc_tdc_core: fix 131us timestamp error

parent b10c63a4
...@@ -94,6 +94,7 @@ entity data_formatting is ...@@ -94,6 +94,7 @@ entity data_formatting is
clk_i_cycles_offset_i : in std_logic_vector(31 downto 0); clk_i_cycles_offset_i : in std_logic_vector(31 downto 0);
roll_over_nb_i : in std_logic_vector(31 downto 0); roll_over_nb_i : in std_logic_vector(31 downto 0);
retrig_nb_offset_i : in std_logic_vector(31 downto 0); retrig_nb_offset_i : in std_logic_vector(31 downto 0);
current_retrig_nb_i : in std_logic_vector(31 downto 0);
-- Signal from the WRabbit core or the one_hz_generator unit -- Signal from the WRabbit core or the one_hz_generator unit
utc_p_i : in std_logic; utc_p_i : in std_logic;
...@@ -138,6 +139,7 @@ architecture rtl of data_formatting is ...@@ -138,6 +139,7 @@ architecture rtl of data_formatting is
signal un_acam_fine_time : unsigned(31 downto 0); signal un_acam_fine_time : unsigned(31 downto 0);
signal previous_utc : std_logic_vector(31 downto 0); signal previous_utc : std_logic_vector(31 downto 0);
signal timestamp_valid_int : std_logic; signal timestamp_valid_int : std_logic;
signal timestamp_valid_int_d : std_logic;
--================================================================================================= --=================================================================================================
-- architecture begin -- architecture begin
...@@ -152,6 +154,7 @@ begin ...@@ -152,6 +154,7 @@ begin
timestamp_valid_int <= '0'; timestamp_valid_int <= '0';
else else
timestamp_valid_int <= acam_tstamp1_ok_p_i or acam_tstamp2_ok_p_i; timestamp_valid_int <= acam_tstamp1_ok_p_i or acam_tstamp2_ok_p_i;
timestamp_valid_int_d <= timestamp_valid_int;
end if; end if;
end if; end if;
end process; end process;
...@@ -200,13 +203,13 @@ begin ...@@ -200,13 +203,13 @@ begin
acam_channel <= "0" & acam_tstamp1_i(27 downto 26); acam_channel <= "0" & acam_tstamp1_i(27 downto 26);
acam_fine_timestamp <= acam_tstamp1_i(16 downto 0); acam_fine_timestamp <= acam_tstamp1_i(16 downto 0);
acam_slope <= acam_tstamp1_i(17); acam_slope <= acam_tstamp1_i(17);
acam_start_nb <= unsigned(acam_tstamp1_i(25 downto 18))-1; acam_start_nb <= unsigned(acam_tstamp1_i(25 downto 18));
elsif acam_tstamp2_ok_p_i = '1' then elsif acam_tstamp2_ok_p_i = '1' then
acam_channel <= "1" & acam_tstamp2_i(27 downto 26); acam_channel <= "1" & acam_tstamp2_i(27 downto 26);
acam_fine_timestamp <= acam_tstamp2_i(16 downto 0); acam_fine_timestamp <= acam_tstamp2_i(16 downto 0);
acam_slope <= acam_tstamp2_i(17); acam_slope <= acam_tstamp2_i(17);
acam_start_nb <= unsigned(acam_tstamp2_i(25 downto 18))-1; acam_start_nb <= unsigned(acam_tstamp2_i(25 downto 18));
end if; end if;
end if; end if;
end process; end process;
...@@ -290,7 +293,8 @@ begin ...@@ -290,7 +293,8 @@ begin
un_retrig_nb_offset <= unsigned(retrig_nb_offset_i); un_retrig_nb_offset <= unsigned(retrig_nb_offset_i);
utc <= utc_i; utc <= utc_i;
coarse_zero <= '0'; coarse_zero <= '0';
if roll_over_incr_recent_i = '1' and un_acam_start_nb > 192 then if acam_start_nb = 255 and unsigned(current_retrig_nb_i) = 0 then
ccase <= "010";
un_retrig_from_roll_over <= shift_left(unsigned(roll_over_nb_i)-1, 8); un_retrig_from_roll_over <= shift_left(unsigned(roll_over_nb_i)-1, 8);
else else
un_retrig_from_roll_over <= shift_left(unsigned(roll_over_nb_i), 8); un_retrig_from_roll_over <= shift_left(unsigned(roll_over_nb_i), 8);
......
...@@ -499,7 +499,7 @@ begin ...@@ -499,7 +499,7 @@ begin
--------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------
-- DATA FORMATTING -- -- DATA FORMATTING --
--------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------
data_formatting_block : data_formatting data_formatting_block : entity work.data_formatting
port map port map
(clk_i => clk_tdc_i, (clk_i => clk_tdc_i,
rst_i => rst_tdc_i, rst_i => rst_tdc_i,
...@@ -511,6 +511,7 @@ begin ...@@ -511,6 +511,7 @@ begin
clk_i_cycles_offset_i => clk_i_cycles_offset, clk_i_cycles_offset_i => clk_i_cycles_offset,
roll_over_nb_i => roll_over_nb, roll_over_nb_i => roll_over_nb,
retrig_nb_offset_i => retrig_nb_offset, retrig_nb_offset_i => retrig_nb_offset,
current_retrig_nb_i => current_retrig_nb,
utc_p_i => utc_p, utc_p_i => utc_p,
utc_i => utc, utc_i => utc,
timestamp_o => timestamp, timestamp_o => timestamp,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment