-- The multichannel TDC: -- -- 1. Time-to-digital converters for the drift time and -- the particle's range measurements. The interval is -- given by two timing markers: the start signal in each -- detector's arm is taken from the time-of-flight system -- while the stop pulse is derived from the Bragg peak -- crossing the discriminator's threshold. The leading -- edge of this signal is used to measure the drift time -- in the Bragg chamber and the trailing edge - for the -- particle range measurements in the gas volume. The TDC's -- range is 0 to 20 us with a 2.5 ns resolution. An overflow -- bit is set when the measurement interval is longer than -- the range. -- 2. Timer to measure an inteval between the reactor flash -- and the physical event in the spectrometer with a 50 ns -- resolution. This helps to reject the random background -- and to estimate the neutron energy for the induced -- fission events.The result is kept in three registers -- for ms, us and ns grades. -- Version 1. Started 17.01.06. Copyright I.Tsurin, FLNR JINR. -- Module functions: -------------------------------------------- -- NA(I)F(0) - read registers -- NA(I)F(2) - read and clear registers; -------------------------------------------- -- Group #1 (I) counters: -------------------------------------------- -- Drift1 (R) NA(0)F(0)/F(2) - drift time in the left arm; -- Drift2 (R) NA(1)F(0)/F(2) - drift time in the right arm; -- Range1 (R) NA(2)F(0)/F(2) - particle range in the left arm; -- Range2 (R) NA(3)F(0)/F(2) - particle range in the right arm; -- Time_ms (R) NA(4)F(0)/F(2) - Time after the flash, ms; -- Time_us (R) NA(5)F(0)/F(2) - Time after the flash, us; -- Time_ns (R) NA(6)F(0)/F(2) - Time after the flash, ns; ------------------------------------------- library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_arith.all; use IEEE.numeric_std.all; -- OK. Here the entity starts... -------------------------------------------- entity Long is port( -- CAMAC signals -------------------------------------------- N_COM: in std_logic; B_COM: in std_logic; Z_COM: in std_logic; C_COM: in std_logic; I_COM: in std_logic; Strobe1: in std_logic; Strobe2: in std_logic; X_RES: out std_logic; Q_RES: out std_logic; L_RES: out std_logic; WRI_DAT: in std_logic_vector(23 downto 0); RDA_DAT: out std_logic_vector(23 downto 0); F_BUS: in std_logic_vector(4 downto 0); A_BUS: in std_logic_vector(3 downto 0); -------------------------------------------- -- Detector signals -------------------------------------------- Clear: in std_logic; Start_T1: in std_logic; Start_T2: in std_logic; Stop_T1: in std_logic; Stop_T2: in std_logic; Nflash: in std_logic; Event: in std_logic; -------------------------------------------- -- Clock frequency -------------------------------------------- DEL_OUT: out std_logic; DEL_INP: in std_logic_vector(9 downto 0); Clock: in std_logic ); attribute pinnum: string; attribute pinnum of N_COM: signal is "18"; attribute pinnum of B_COM: signal is "7"; attribute pinnum of Z_COM: signal is "27"; attribute pinnum of C_COM: signal is "16"; attribute pinnum of I_COM: signal is "14"; attribute pinnum of Strobe1: signal is "26"; attribute pinnum of Strobe2: signal is "28"; attribute pinnum of X_RES: signal is "12"; attribute pinnum of Q_RES: signal is "29"; attribute pinnum of L_RES: signal is "24"; attribute pinnum of WRI_DAT: signal is "30,31,36,37,38,39,40,41,44,45,46,47,53,54,55,56,57,58,60,61,62,63,64,65"; attribute pinnum of RDA_DAT: signal is "67,68,69,70,71,73,74,75,83,85,86,87,88,89,90,92,93,94,95,96,97,99,100,101"; attribute pinnum of F_BUS: signal is "8,9,10,11,13"; attribute pinnum of A_BUS: signal is "15,17,19,25"; attribute pinnum of Clear: signal is "169"; attribute pinnum of Nflash: signal is "157"; attribute pinnum of Event: signal is "147"; attribute pinnum of Start_T1: signal is "143"; attribute pinnum of Stop_T1: signal is "141"; attribute pinnum of Start_T2: signal is "139"; attribute pinnum of Stop_T2: signal is "135"; -- 50A ALTERA -- pins pins -- --- --- --- -- 13 113 TAP10 -- 2 112 - -- 3 114 TAP1 -- 12 115 TAP9 -- 4 116 TAP2 -- 11 119 TAP8 -- 5 120 TAP3 -- 10 121 TAP7 -- 6 122 TAP4 -- 9 125 TAP6 -- 8 127 TAP5 attribute pinnum of DEL_OUT: signal is "104"; attribute pinnum of DEL_INP: signal is "113,115,119,121,125,127,122,120,116,114"; attribute pinnum of Clock: signal is "208"; end; architecture behavior of Long is -- Start-up variables -------------------------------------------- signal INI_CNT: natural range 0 to 524287; signal DUM_RES: std_logic; signal PWR_ON: std_logic; -------------------------------------------- -- CAMAC variables -------------------------------------------- signal COM_SET: std_logic; signal SEL_SET: std_logic; signal R29_D1: std_logic; signal R29_D2: std_logic; signal R29_R1: std_logic; signal R29_R2: std_logic; signal R29_TMS: std_logic; signal R29_TUS: std_logic; signal R29_TNS: std_logic; signal Drift1: std_logic_vector(12 downto 0); signal Drift2: std_logic_vector(12 downto 0); signal Range1: std_logic_vector(12 downto 0); signal Range2: std_logic_vector(12 downto 0); signal D1_STP: std_logic; signal D2_STP: std_logic; signal R1_STP: std_logic; signal R2_STP: std_logic; signal D1_GTE: std_logic; signal D2_GTE: std_logic; signal R1_GTE: std_logic; signal R2_GTE: std_logic; signal D1_TDC0: natural range 0 to 8191; signal D1_TDC1: natural range 0 to 8191; signal D1_TDC2: natural range 0 to 8191; signal D1_TDC3: natural range 0 to 8191; signal D1_TDC4: natural range 0 to 8191; signal D1_TDC5: natural range 0 to 8191; signal D1_TDC6: natural range 0 to 8191; signal D1_TDC7: natural range 0 to 8191; signal D1_TDC8: natural range 0 to 8191; signal D1_TDC9: natural range 0 to 8191; signal D1_TDC10: natural range 0 to 8191; signal D1_TDC11: natural range 0 to 8191; signal D1_TDC12: natural range 0 to 8191; signal D1_TDC13: natural range 0 to 8191; signal D1_TDC14: natural range 0 to 8191; signal D1_TDC15: natural range 0 to 8191; signal D1_TDC16: natural range 0 to 8191; signal D1_TDC17: natural range 0 to 8191; signal D1_TDC18: natural range 0 to 8191; signal D1_TDC19: natural range 0 to 8191; signal D2_TDC0: natural range 0 to 8191; signal D2_TDC1: natural range 0 to 8191; signal D2_TDC2: natural range 0 to 8191; signal D2_TDC3: natural range 0 to 8191; signal D2_TDC4: natural range 0 to 8191; signal D2_TDC5: natural range 0 to 8191; signal D2_TDC6: natural range 0 to 8191; signal D2_TDC7: natural range 0 to 8191; signal D2_TDC8: natural range 0 to 8191; signal D2_TDC9: natural range 0 to 8191; signal D2_TDC10: natural range 0 to 8191; signal D2_TDC11: natural range 0 to 8191; signal D2_TDC12: natural range 0 to 8191; signal D2_TDC13: natural range 0 to 8191; signal D2_TDC14: natural range 0 to 8191; signal D2_TDC15: natural range 0 to 8191; signal D2_TDC16: natural range 0 to 8191; signal D2_TDC17: natural range 0 to 8191; signal D2_TDC18: natural range 0 to 8191; signal D2_TDC19: natural range 0 to 8191; signal R1_TDC0: natural range 0 to 8191; signal R1_TDC1: natural range 0 to 8191; signal R1_TDC2: natural range 0 to 8191; signal R1_TDC3: natural range 0 to 8191; signal R1_TDC4: natural range 0 to 8191; signal R1_TDC5: natural range 0 to 8191; signal R1_TDC6: natural range 0 to 8191; signal R1_TDC7: natural range 0 to 8191; signal R1_TDC8: natural range 0 to 8191; signal R1_TDC9: natural range 0 to 8191; signal R1_TDC10: natural range 0 to 8191; signal R1_TDC11: natural range 0 to 8191; signal R1_TDC12: natural range 0 to 8191; signal R1_TDC13: natural range 0 to 8191; signal R1_TDC14: natural range 0 to 8191; signal R1_TDC15: natural range 0 to 8191; signal R1_TDC16: natural range 0 to 8191; signal R1_TDC17: natural range 0 to 8191; signal R1_TDC18: natural range 0 to 8191; signal R1_TDC19: natural range 0 to 8191; signal R2_TDC0: natural range 0 to 8191; signal R2_TDC1: natural range 0 to 8191; signal R2_TDC2: natural range 0 to 8191; signal R2_TDC3: natural range 0 to 8191; signal R2_TDC4: natural range 0 to 8191; signal R2_TDC5: natural range 0 to 8191; signal R2_TDC6: natural range 0 to 8191; signal R2_TDC7: natural range 0 to 8191; signal R2_TDC8: natural range 0 to 8191; signal R2_TDC9: natural range 0 to 8191; signal R2_TDC10: natural range 0 to 8191; signal R2_TDC11: natural range 0 to 8191; signal R2_TDC12: natural range 0 to 8191; signal R2_TDC13: natural range 0 to 8191; signal R2_TDC14: natural range 0 to 8191; signal R2_TDC15: natural range 0 to 8191; signal R2_TDC16: natural range 0 to 8191; signal R2_TDC17: natural range 0 to 8191; signal R2_TDC18: natural range 0 to 8191; signal R2_TDC19: natural range 0 to 8191; signal D1_OVF: std_logic; signal D2_OVF: std_logic; signal R1_OVF: std_logic; signal R2_OVF: std_logic; signal Sync: std_logic; signal Time_ms: std_logic_vector(9 downto 0); signal Time_us: std_logic_vector(9 downto 0); signal Time_ns: std_logic_vector(9 downto 0); signal TIM_RUN: std_logic; signal TIM_STP: std_logic; signal TIM_CLR: std_logic; signal TIM_CNT: natural range 0 to 1; signal NS_CNT: natural range 0 to 1023; signal US_CNT: natural range 0 to 1023; signal MS_CNT: natural range 0 to 1023; signal US_SET: std_logic; signal MS_SET: std_logic; signal SS_SET: std_logic; ------------------------------------------- begin -- Permanent statements -------------------------------------------- DUM_RES <= '0'; Q_RES <= 'Z'; L_RES <= '1'; DEL_OUT <= Clock; Sync <= DEL_INP(0); -------------------------------------------- -- Start-up reset -------------------------------------------- process(DUM_RES, Clock, PWR_ON) begin if (DUM_RES = '1') then INI_CNT <= 0; elsif (Clock'event and Clock = '1') then if (PWR_ON = '1') then INI_CNT <= INI_CNT + 1; else null; end if; end if; end process; ------------------------- process(DUM_RES, Clock, INI_CNT) begin if (DUM_RES = '1') then PWR_ON <= '1'; elsif (Clock'event and Clock = '0') then if (INI_CNT = 524287) then PWR_ON <= '0'; else PWR_ON <= '1'; end if; end if; end process; -------------------------------------------- -- Common CAMAC reset -- (reset registers group #1) -------------------------------------------- process(PWR_ON, Z_COM, Strobe2) begin if (PWR_ON = '1' or Z_COM = '1') then COM_SET <= '0'; elsif (Strobe2'event and Strobe2 = '0') then COM_SET <= '1'; end if; end process; -------------------------------------------- -- Selective CAMAC reset -- (reset registers group #1) -------------------------------------------- process(PWR_ON, C_COM, Strobe2) begin if (PWR_ON = '1' or C_COM = '1') then SEL_SET <= '0'; elsif (Strobe2'event and Strobe2 = '0') then SEL_SET <= '1'; end if; end process; -------------------------------------------- -- Reset group #1 by NA(0)F(2)S(2) -------------------------------------------- process(PWR_ON, Z_COM, N_COM, Strobe2, F_BUS, A_BUS) begin if (PWR_ON = '1' or Z_COM = '0' or N_COM = '1') then R29_D1 <= '0'; elsif (Strobe2'event and Strobe2 = '0') then if (F_BUS = "11101" and A_BUS = "1111") then R29_D1 <= '1'; else null; end if; end if; end process; -------------------------------------------- -- Reset group #1 by NA(1)F(2)S(2) -------------------------------------------- process(PWR_ON, Z_COM, N_COM, Strobe2, F_BUS, A_BUS) begin if (PWR_ON = '1' or Z_COM = '0' or N_COM = '1') then R29_D2 <= '0'; elsif (Strobe2'event and Strobe2 = '0') then if (F_BUS = "11101" and A_BUS = "1110") then R29_D2 <= '1'; else null; end if; end if; end process; -------------------------------------------- -- Reset group #1 by NA(2)F(2)S(2) -------------------------------------------- process(PWR_ON, Z_COM, N_COM, Strobe2, F_BUS, A_BUS) begin if (PWR_ON = '1' or Z_COM = '0' or N_COM = '1') then R29_R1 <= '0'; elsif (Strobe2'event and Strobe2 = '0') then if (F_BUS = "11101" and A_BUS = "1101") then R29_R1 <= '1'; else null; end if; end if; end process; -------------------------------------------- -- Reset group #1 by NA(3)F(2)S(2) -------------------------------------------- process(PWR_ON, Z_COM, N_COM, Strobe2, F_BUS, A_BUS) begin if (PWR_ON = '1' or Z_COM = '0' or N_COM = '1') then R29_R2 <= '0'; elsif (Strobe2'event and Strobe2 = '0') then if (F_BUS = "11101" and A_BUS = "1100") then R29_R2 <= '1'; else null; end if; end if; end process; -------------------------------------------- -- Reset group #1 by NA(4)F(2)S(2) -------------------------------------------- process(PWR_ON, Z_COM, N_COM, Strobe2, F_BUS, A_BUS) begin if (PWR_ON = '1' or Z_COM = '0' or N_COM = '1') then R29_TMS <= '0'; elsif (Strobe2'event and Strobe2 = '0') then if (F_BUS = "11101" and A_BUS = "1011") then R29_TMS <= '1'; else null; end if; end if; end process; -------------------------------------------- -- Reset group #1 by NA(5)F(2)S(2) -------------------------------------------- process(PWR_ON, Z_COM, N_COM, Strobe2, F_BUS, A_BUS) begin if (PWR_ON = '1' or Z_COM = '0' or N_COM = '1') then R29_TUS <= '0'; elsif (Strobe2'event and Strobe2 = '0') then if (F_BUS = "11101" and A_BUS = "1010") then R29_TUS <= '1'; else null; end if; end if; end process; -------------------------------------------- -- Reset group #1 by NA(6)F(2)S(2) -------------------------------------------- process(PWR_ON, Z_COM, N_COM, Strobe2, F_BUS, A_BUS) begin if (PWR_ON = '1' or Z_COM = '0' or N_COM = '1') then R29_TNS <= '0'; elsif (Strobe2'event and Strobe2 = '0') then if (F_BUS = "11101" and A_BUS = "1001") then R29_TNS <= '1'; else null; end if; end if; end process; -------------------------------------------- -- Read group #1 registers -------------------------------------------- process(PWR_ON, Z_COM, N_COM, F_BUS, A_BUS, D1_OVF, Drift1, D2_OVF, Drift2, R1_OVF, Range1, R2_OVF, Range2, Time_ms, Time_us, Time_ns) begin if (PWR_ON = '1' or Z_COM = '0' or N_COM = '1') then RDA_DAT <= (others => 'Z'); elsif (F_BUS = "11111" or F_BUS = "11101") then if (A_BUS = "1111") then RDA_DAT(23 downto 14) <= "1111111111"; RDA_DAT(13) <= D1_OVF; RDA_DAT(12 downto 0) <= Drift1; elsif (A_BUS = "1110") then RDA_DAT(23 downto 14) <= "1111111111"; RDA_DAT(13) <= D2_OVF; RDA_DAT(12 downto 0) <= Drift2; elsif (A_BUS = "1101") then RDA_DAT(23 downto 14) <= "1111111111"; RDA_DAT(13) <= R1_OVF; RDA_DAT(12 downto 0) <= Range1; elsif (A_BUS = "1100") then RDA_DAT(23 downto 14) <= "1111111111"; RDA_DAT(13) <= R2_OVF; RDA_DAT(12 downto 0) <= Range2; elsif (A_BUS = "1011") then RDA_DAT(23 downto 10) <= "11111111111111"; RDA_DAT(9 downto 0) <= Time_ms; elsif (A_BUS = "1010") then RDA_DAT(23 downto 10) <= "11111111111111"; RDA_DAT(9 downto 0) <= Time_us; elsif (A_BUS = "1001") then RDA_DAT(23 downto 10) <= "11111111111111"; RDA_DAT(9 downto 0) <= Time_ns; else RDA_DAT <= (others => 'Z'); end if; else RDA_DAT <= (others => 'Z'); end if; end process; -------------------------------------------- -- Genarating X - command response -- NA(I)F(0) - read registers; -- NA(I)F(2) - read and clear registers; -------------------------------------------- process(PWR_ON, Z_COM, N_COM, F_BUS, A_BUS) begin if (PWR_ON = '0' and Z_COM = '1' and N_COM = '0') then if (F_BUS = "11111" or F_BUS = "11101") then if (A_BUS = "1111") then X_RES <= '0'; elsif (A_BUS = "1110") then X_RES <= '0'; elsif (A_BUS = "1101") then X_RES <= '0'; elsif (A_BUS = "1100") then X_RES <= '0'; elsif (A_BUS = "1011") then X_RES <= '0'; elsif (A_BUS = "1010") then X_RES <= '0'; elsif (A_BUS = "1001") then X_RES <= '0'; else X_RES <= 'Z'; end if; else X_RES <= 'Z'; end if; else X_RES <= 'Z'; end if; end process; -------------------------------------------- -------------------------------------------- -- Latching the leading edge of the Stop_T1 signal -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, Stop_T1, I_COM) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0') then D1_STP <= '0'; elsif (Stop_T1'event and Stop_T1 = '0') then if (I_COM = '1') then D1_STP <= '1'; else null; end if; end if; end process; -------------------------------------------- -- Latching the leading edge of the Stop_T2 signal -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, Stop_T2, I_COM) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0') then D2_STP <= '0'; elsif (Stop_T2'event and Stop_T2 = '0') then if (I_COM = '1') then D2_STP <= '1'; else null; end if; end if; end process; -------------------------------------------- -- Latching the trailing edge of the Stop_T1 signal -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, Stop_T1, I_COM) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0') then R1_STP <= '0'; elsif (Stop_T1'event and Stop_T1 = '1') then if (I_COM = '1') then R1_STP <= '1'; else null; end if; end if; end process; -------------------------------------------- -- Latching the trailing edge of the Stop_T2 signal -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, Stop_T2, I_COM) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0') then R2_STP <= '0'; elsif (Stop_T2'event and Stop_T2 = '1') then if (I_COM = '1') then R2_STP <= '1'; else null; end if; end if; end process; -------------------------------------------- -- TDC counter gates -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, D1_STP, Start_T1, I_COM) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or D1_STP = '1') then D1_GTE <= '0'; elsif (Start_T1'event and Start_T1 = '0') then if (I_COM = '1') then D1_GTE <= '1'; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, D2_STP, Start_T2, I_COM) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or D2_STP = '1') then D2_GTE <= '0'; elsif (Start_T2'event and Start_T2 = '0') then if (I_COM = '1') then D2_GTE <= '1'; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R1_STP, Stop_T1, I_COM) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R1_STP = '1') then R1_GTE <= '0'; elsif (Stop_T1'event and Stop_T1 = '0') then if (I_COM = '1') then R1_GTE <= '1'; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R2_STP, Stop_T2, I_COM) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R2_STP = '1') then R2_GTE <= '0'; elsif (Stop_T2'event and Stop_T2 = '0') then if (I_COM = '1') then R2_GTE <= '1'; else null; end if; end if; end process; -------------------------------------------- -- TDC counters for Drift1 -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D1, DEL_INP(0), D1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D1 = '1') then D1_TDC0 <= 0; elsif (DEL_INP(0)'event and DEL_INP(0) = '1') then if (D1_GTE = '1') then D1_TDC0 <= D1_TDC0 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D1, DEL_INP(1), D1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D1 = '1') then D1_TDC1 <= 0; elsif (DEL_INP(1)'event and DEL_INP(1) = '1') then if (D1_GTE = '1') then D1_TDC1 <= D1_TDC1 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D1, DEL_INP(2), D1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D1 = '1') then D1_TDC2 <= 0; elsif (DEL_INP(2)'event and DEL_INP(2) = '1') then if (D1_GTE = '1') then D1_TDC2 <= D1_TDC2 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D1, DEL_INP(3), D1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D1 = '1') then D1_TDC3 <= 0; elsif (DEL_INP(3)'event and DEL_INP(3) = '1') then if (D1_GTE = '1') then D1_TDC3 <= D1_TDC3 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D1, DEL_INP(4), D1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D1 = '1') then D1_TDC4 <= 0; elsif (DEL_INP(4)'event and DEL_INP(4) = '1') then if (D1_GTE = '1') then D1_TDC4 <= D1_TDC4 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D1, DEL_INP(5), D1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D1 = '1') then D1_TDC5 <= 0; elsif (DEL_INP(5)'event and DEL_INP(5) = '1') then if (D1_GTE = '1') then D1_TDC5 <= D1_TDC5 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D1, DEL_INP(6), D1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D1 = '1') then D1_TDC6 <= 0; elsif (DEL_INP(6)'event and DEL_INP(6) = '1') then if (D1_GTE = '1') then D1_TDC6 <= D1_TDC6 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D1, DEL_INP(7), D1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D1 = '1') then D1_TDC7 <= 0; elsif (DEL_INP(7)'event and DEL_INP(7) = '1') then if (D1_GTE = '1') then D1_TDC7 <= D1_TDC7 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D1, DEL_INP(8), D1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D1 = '1') then D1_TDC8 <= 0; elsif (DEL_INP(8)'event and DEL_INP(8) = '1') then if (D1_GTE = '1') then D1_TDC8 <= D1_TDC8 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D1, DEL_INP(9), D1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D1 = '1') then D1_TDC9 <= 0; elsif (DEL_INP(9)'event and DEL_INP(9) = '1') then if (D1_GTE = '1') then D1_TDC9 <= D1_TDC9 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D1, DEL_INP(0), D1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D1 = '1') then D1_TDC10 <= 0; elsif (DEL_INP(0)'event and DEL_INP(0) = '0') then if (D1_GTE = '1') then D1_TDC10 <= D1_TDC10 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D1, DEL_INP(1), D1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D1 = '1') then D1_TDC11 <= 0; elsif (DEL_INP(1)'event and DEL_INP(1) = '0') then if (D1_GTE = '1') then D1_TDC11 <= D1_TDC11 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D1, DEL_INP(2), D1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D1 = '1') then D1_TDC12 <= 0; elsif (DEL_INP(2)'event and DEL_INP(2) = '0') then if (D1_GTE = '1') then D1_TDC12 <= D1_TDC12 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D1, DEL_INP(3), D1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D1 = '1') then D1_TDC13 <= 0; elsif (DEL_INP(3)'event and DEL_INP(3) = '0') then if (D1_GTE = '1') then D1_TDC13 <= D1_TDC13 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D1, DEL_INP(4), D1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D1 = '1') then D1_TDC14 <= 0; elsif (DEL_INP(4)'event and DEL_INP(4) = '0') then if (D1_GTE = '1') then D1_TDC14 <= D1_TDC14 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D1, DEL_INP(5), D1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D1 = '1') then D1_TDC15 <= 0; elsif (DEL_INP(5)'event and DEL_INP(5) = '0') then if (D1_GTE = '1') then D1_TDC15 <= D1_TDC15 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D1, DEL_INP(6), D1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D1 = '1') then D1_TDC16 <= 0; elsif (DEL_INP(6)'event and DEL_INP(6) = '0') then if (D1_GTE = '1') then D1_TDC16 <= D1_TDC16 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D1, DEL_INP(7), D1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D1 = '1') then D1_TDC17 <= 0; elsif (DEL_INP(7)'event and DEL_INP(7) = '0') then if (D1_GTE = '1') then D1_TDC17 <= D1_TDC17 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D1, DEL_INP(8), D1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D1 = '1') then D1_TDC18 <= 0; elsif (DEL_INP(8)'event and DEL_INP(8) = '0') then if (D1_GTE = '1') then D1_TDC18 <= D1_TDC18 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D1, DEL_INP(9), D1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D1 = '1') then D1_TDC19 <= 0; elsif (DEL_INP(9)'event and DEL_INP(9) = '0') then if (D1_GTE = '1') then D1_TDC19 <= D1_TDC19 + 1; else null; end if; end if; end process; -------------------------------------------- -- TDC counters for Drift2 -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D2, DEL_INP(0), D2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D2 = '1') then D2_TDC0 <= 0; elsif (DEL_INP(0)'event and DEL_INP(0) = '1') then if (D2_GTE = '1') then D2_TDC0 <= D2_TDC0 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D2, DEL_INP(1), D2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D2 = '1') then D2_TDC1 <= 0; elsif (DEL_INP(1)'event and DEL_INP(1) = '1') then if (D2_GTE = '1') then D2_TDC1 <= D2_TDC1 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D2, DEL_INP(2), D2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D2 = '1') then D2_TDC2 <= 0; elsif (DEL_INP(2)'event and DEL_INP(2) = '1') then if (D2_GTE = '1') then D2_TDC2 <= D2_TDC2 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D2, DEL_INP(3), D2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D2 = '1') then D2_TDC3 <= 0; elsif (DEL_INP(3)'event and DEL_INP(3) = '1') then if (D2_GTE = '1') then D2_TDC3 <= D2_TDC3 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D2, DEL_INP(4), D2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D2 = '1') then D2_TDC4 <= 0; elsif (DEL_INP(4)'event and DEL_INP(4) = '1') then if (D2_GTE = '1') then D2_TDC4 <= D2_TDC4 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D2, DEL_INP(5), D2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D2 = '1') then D2_TDC5 <= 0; elsif (DEL_INP(5)'event and DEL_INP(5) = '1') then if (D2_GTE = '1') then D2_TDC5 <= D2_TDC5 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D2, DEL_INP(6), D2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D2 = '1') then D2_TDC6 <= 0; elsif (DEL_INP(6)'event and DEL_INP(6) = '1') then if (D2_GTE = '1') then D2_TDC6 <= D2_TDC6 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D2, DEL_INP(7), D2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D2 = '1') then D2_TDC7 <= 0; elsif (DEL_INP(7)'event and DEL_INP(7) = '1') then if (D2_GTE = '1') then D2_TDC7 <= D2_TDC7 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D2, DEL_INP(8), D2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D2 = '1') then D2_TDC8 <= 0; elsif (DEL_INP(8)'event and DEL_INP(8) = '1') then if (D2_GTE = '1') then D2_TDC8 <= D2_TDC8 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D2, DEL_INP(9), D2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D2 = '1') then D2_TDC9 <= 0; elsif (DEL_INP(9)'event and DEL_INP(9) = '1') then if (D2_GTE = '1') then D2_TDC9 <= D2_TDC9 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D2, DEL_INP(0), D2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D2 = '1') then D2_TDC10 <= 0; elsif (DEL_INP(0)'event and DEL_INP(0) = '0') then if (D2_GTE = '1') then D2_TDC10 <= D2_TDC10 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D2, DEL_INP(1), D2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D2 = '1') then D2_TDC11 <= 0; elsif (DEL_INP(1)'event and DEL_INP(1) = '0') then if (D2_GTE = '1') then D2_TDC11 <= D2_TDC11 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D2, DEL_INP(2), D2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D2 = '1') then D2_TDC12 <= 0; elsif (DEL_INP(2)'event and DEL_INP(2) = '0') then if (D2_GTE = '1') then D2_TDC12 <= D2_TDC12 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D2, DEL_INP(3), D2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D2 = '1') then D2_TDC13 <= 0; elsif (DEL_INP(3)'event and DEL_INP(3) = '0') then if (D2_GTE = '1') then D2_TDC13 <= D2_TDC13 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D2, DEL_INP(4), D2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D2 = '1') then D2_TDC14 <= 0; elsif (DEL_INP(4)'event and DEL_INP(4) = '0') then if (D2_GTE = '1') then D2_TDC14 <= D2_TDC14 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D2, DEL_INP(5), D2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D2 = '1') then D2_TDC15 <= 0; elsif (DEL_INP(5)'event and DEL_INP(5) = '0') then if (D2_GTE = '1') then D2_TDC15 <= D2_TDC15 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D2, DEL_INP(6), D2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D2 = '1') then D2_TDC16 <= 0; elsif (DEL_INP(6)'event and DEL_INP(6) = '0') then if (D2_GTE = '1') then D2_TDC16 <= D2_TDC16 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D2, DEL_INP(7), D2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D2 = '1') then D2_TDC17 <= 0; elsif (DEL_INP(7)'event and DEL_INP(7) = '0') then if (D2_GTE = '1') then D2_TDC17 <= D2_TDC17 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D2, DEL_INP(8), D2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D2 = '1') then D2_TDC18 <= 0; elsif (DEL_INP(8)'event and DEL_INP(8) = '0') then if (D2_GTE = '1') then D2_TDC18 <= D2_TDC18 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D2, DEL_INP(9), D2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D2 = '1') then D2_TDC19 <= 0; elsif (DEL_INP(9)'event and DEL_INP(9) = '0') then if (D2_GTE = '1') then D2_TDC19 <= D2_TDC19 + 1; else null; end if; end if; end process; -------------------------------------------- -- TDC counters for Range1 -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R1, DEL_INP(0), R1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R1 = '1') then R1_TDC0 <= 0; elsif (DEL_INP(0)'event and DEL_INP(0) = '1') then if (R1_GTE = '1') then R1_TDC0 <= R1_TDC0 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R1, DEL_INP(1), R1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R1 = '1') then R1_TDC1 <= 0; elsif (DEL_INP(1)'event and DEL_INP(1) = '1') then if (R1_GTE = '1') then R1_TDC1 <= R1_TDC1 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R1, DEL_INP(2), R1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R1 = '1') then R1_TDC2 <= 0; elsif (DEL_INP(2)'event and DEL_INP(2) = '1') then if (R1_GTE = '1') then R1_TDC2 <= R1_TDC2 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R1, DEL_INP(3), R1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R1 = '1') then R1_TDC3 <= 0; elsif (DEL_INP(3)'event and DEL_INP(3) = '1') then if (R1_GTE = '1') then R1_TDC3 <= R1_TDC3 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R1, DEL_INP(4), R1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R1 = '1') then R1_TDC4 <= 0; elsif (DEL_INP(4)'event and DEL_INP(4) = '1') then if (R1_GTE = '1') then R1_TDC4 <= R1_TDC4 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R1, DEL_INP(5), R1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R1 = '1') then R1_TDC5 <= 0; elsif (DEL_INP(5)'event and DEL_INP(5) = '1') then if (R1_GTE = '1') then R1_TDC5 <= R1_TDC5 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R1, DEL_INP(6), R1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R1 = '1') then R1_TDC6 <= 0; elsif (DEL_INP(6)'event and DEL_INP(6) = '1') then if (R1_GTE = '1') then R1_TDC6 <= R1_TDC6 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R1, DEL_INP(7), R1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R1 = '1') then R1_TDC7 <= 0; elsif (DEL_INP(7)'event and DEL_INP(7) = '1') then if (R1_GTE = '1') then R1_TDC7 <= R1_TDC7 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R1, DEL_INP(8), R1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R1 = '1') then R1_TDC8 <= 0; elsif (DEL_INP(8)'event and DEL_INP(8) = '1') then if (R1_GTE = '1') then R1_TDC8 <= R1_TDC8 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R1, DEL_INP(9), R1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R1 = '1') then R1_TDC9 <= 0; elsif (DEL_INP(9)'event and DEL_INP(9) = '1') then if (R1_GTE = '1') then R1_TDC9 <= R1_TDC9 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R1, DEL_INP(0), R1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R1 = '1') then R1_TDC10 <= 0; elsif (DEL_INP(0)'event and DEL_INP(0) = '0') then if (R1_GTE = '1') then R1_TDC10 <= R1_TDC10 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R1, DEL_INP(1), R1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R1 = '1') then R1_TDC11 <= 0; elsif (DEL_INP(1)'event and DEL_INP(1) = '0') then if (R1_GTE = '1') then R1_TDC11 <= R1_TDC11 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R1, DEL_INP(2), R1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R1 = '1') then R1_TDC12 <= 0; elsif (DEL_INP(2)'event and DEL_INP(2) = '0') then if (R1_GTE = '1') then R1_TDC12 <= R1_TDC12 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R1, DEL_INP(3), R1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R1 = '1') then R1_TDC13 <= 0; elsif (DEL_INP(3)'event and DEL_INP(3) = '0') then if (R1_GTE = '1') then R1_TDC13 <= R1_TDC13 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R1, DEL_INP(4), R1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R1 = '1') then R1_TDC14 <= 0; elsif (DEL_INP(4)'event and DEL_INP(4) = '0') then if (R1_GTE = '1') then R1_TDC14 <= R1_TDC14 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R1, DEL_INP(5), R1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R1 = '1') then R1_TDC15 <= 0; elsif (DEL_INP(5)'event and DEL_INP(5) = '0') then if (R1_GTE = '1') then R1_TDC15 <= R1_TDC15 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R1, DEL_INP(6), R1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R1 = '1') then R1_TDC16 <= 0; elsif (DEL_INP(6)'event and DEL_INP(6) = '0') then if (R1_GTE = '1') then R1_TDC16 <= R1_TDC16 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R1, DEL_INP(7), R1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R1 = '1') then R1_TDC17 <= 0; elsif (DEL_INP(7)'event and DEL_INP(7) = '0') then if (R1_GTE = '1') then R1_TDC17 <= R1_TDC17 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R1, DEL_INP(8), R1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R1 = '1') then R1_TDC18 <= 0; elsif (DEL_INP(8)'event and DEL_INP(8) = '0') then if (R1_GTE = '1') then R1_TDC18 <= R1_TDC18 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R1, DEL_INP(9), R1_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R1 = '1') then R1_TDC19 <= 0; elsif (DEL_INP(9)'event and DEL_INP(9) = '0') then if (R1_GTE = '1') then R1_TDC19 <= R1_TDC19 + 1; else null; end if; end if; end process; -------------------------------------------- -- TDC counters for Range1 -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R2, DEL_INP(0), R2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R2 = '1') then R2_TDC0 <= 0; elsif (DEL_INP(0)'event and DEL_INP(0) = '1') then if (R2_GTE = '1') then R2_TDC0 <= R2_TDC0 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R2, DEL_INP(1), R2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R2 = '1') then R2_TDC1 <= 0; elsif (DEL_INP(1)'event and DEL_INP(1) = '1') then if (R2_GTE = '1') then R2_TDC1 <= R2_TDC1 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R2, DEL_INP(2), R2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R2 = '1') then R2_TDC2 <= 0; elsif (DEL_INP(2)'event and DEL_INP(2) = '1') then if (R2_GTE = '1') then R2_TDC2 <= R2_TDC2 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R2, DEL_INP(3), R2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R2 = '1') then R2_TDC3 <= 0; elsif (DEL_INP(3)'event and DEL_INP(3) = '1') then if (R2_GTE = '1') then R2_TDC3 <= R2_TDC3 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R2, DEL_INP(4), R2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R2 = '1') then R2_TDC4 <= 0; elsif (DEL_INP(4)'event and DEL_INP(4) = '1') then if (R2_GTE = '1') then R2_TDC4 <= R2_TDC4 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R2, DEL_INP(5), R2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R2 = '1') then R2_TDC5 <= 0; elsif (DEL_INP(5)'event and DEL_INP(5) = '1') then if (R2_GTE = '1') then R2_TDC5 <= R2_TDC5 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R2, DEL_INP(6), R2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R2 = '1') then R2_TDC6 <= 0; elsif (DEL_INP(6)'event and DEL_INP(6) = '1') then if (R2_GTE = '1') then R2_TDC6 <= R2_TDC6 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R2, DEL_INP(7), R2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R2 = '1') then R2_TDC7 <= 0; elsif (DEL_INP(7)'event and DEL_INP(7) = '1') then if (R2_GTE = '1') then R2_TDC7 <= R2_TDC7 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R2, DEL_INP(8), R2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R2 = '1') then R2_TDC8 <= 0; elsif (DEL_INP(8)'event and DEL_INP(8) = '1') then if (R2_GTE = '1') then R2_TDC8 <= R2_TDC8 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R2, DEL_INP(9), R2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R2 = '1') then R2_TDC9 <= 0; elsif (DEL_INP(9)'event and DEL_INP(9) = '1') then if (R2_GTE = '1') then R2_TDC9 <= R2_TDC9 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R2, DEL_INP(0), R2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R2 = '1') then R2_TDC10 <= 0; elsif (DEL_INP(0)'event and DEL_INP(0) = '0') then if (R2_GTE = '1') then R2_TDC10 <= R2_TDC10 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R2, DEL_INP(1), R2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R2 = '1') then R2_TDC11 <= 0; elsif (DEL_INP(1)'event and DEL_INP(1) = '0') then if (R2_GTE = '1') then R2_TDC11 <= R2_TDC11 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R2, DEL_INP(2), R2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R2 = '1') then R2_TDC12 <= 0; elsif (DEL_INP(2)'event and DEL_INP(2) = '0') then if (R2_GTE = '1') then R2_TDC12 <= R2_TDC12 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R2, DEL_INP(3), R2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R2 = '1') then R2_TDC13 <= 0; elsif (DEL_INP(3)'event and DEL_INP(3) = '0') then if (R2_GTE = '1') then R2_TDC13 <= R2_TDC13 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R2, DEL_INP(4), R2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R2 = '1') then R2_TDC14 <= 0; elsif (DEL_INP(4)'event and DEL_INP(4) = '0') then if (R2_GTE = '1') then R2_TDC14 <= R2_TDC14 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R2, DEL_INP(5), R2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R2 = '1') then R2_TDC15 <= 0; elsif (DEL_INP(5)'event and DEL_INP(5) = '0') then if (R2_GTE = '1') then R2_TDC15 <= R2_TDC15 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R2, DEL_INP(6), R2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R2 = '1') then R2_TDC16 <= 0; elsif (DEL_INP(6)'event and DEL_INP(6) = '0') then if (R2_GTE = '1') then R2_TDC16 <= R2_TDC16 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R2, DEL_INP(7), R2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R2 = '1') then R2_TDC17 <= 0; elsif (DEL_INP(7)'event and DEL_INP(7) = '0') then if (R2_GTE = '1') then R2_TDC17 <= R2_TDC17 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R2, DEL_INP(8), R2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R2 = '1') then R2_TDC18 <= 0; elsif (DEL_INP(8)'event and DEL_INP(8) = '0') then if (R2_GTE = '1') then R2_TDC18 <= R2_TDC18 + 1; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R2, DEL_INP(9), R2_GTE) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R2 = '1') then R2_TDC19 <= 0; elsif (DEL_INP(9)'event and DEL_INP(9) = '0') then if (R2_GTE = '1') then R2_TDC19 <= R2_TDC19 + 1; else null; end if; end if; end process; -------------------------------------------- -- Results -------------------------------------------- Drift1 <= conv_std_logic_vector((8191 - D1_TDC0 - D1_TDC1 - D1_TDC2 - D1_TDC3 - D1_TDC4 - D1_TDC5 - D1_TDC6 - D1_TDC7 - D1_TDC8 - D1_TDC9 - D1_TDC10 - D1_TDC11 - D1_TDC12 - D1_TDC13 - D1_TDC14 - D1_TDC15 - D1_TDC16 - D1_TDC17 - D1_TDC18 - D1_TDC19), 13); -------------------------------------------- Drift2 <= conv_std_logic_vector((8191 - D2_TDC0 - D2_TDC1 - D2_TDC2 - D2_TDC3 - D2_TDC4 - D2_TDC5 - D2_TDC6 - D2_TDC7 - D2_TDC8 - D2_TDC9 - D2_TDC10 - D2_TDC11 - D2_TDC12 - D2_TDC13 - D2_TDC14 - D2_TDC15 - D2_TDC16 - D2_TDC17 - D2_TDC18 - D2_TDC19), 13); -------------------------------------------- Range1 <= conv_std_logic_vector((8191 - R1_TDC0 - R1_TDC1 - R1_TDC2 - R1_TDC3 - R1_TDC4 - R1_TDC5 - R1_TDC6 - R1_TDC7 - R1_TDC8 - R1_TDC9 - R1_TDC10 - R1_TDC11 - R1_TDC12 - R1_TDC13 - R1_TDC14 - R1_TDC15 - R1_TDC16 - R1_TDC17 - R1_TDC18 - R1_TDC19), 13); -------------------------------------------- Range2 <= conv_std_logic_vector((8191 - R2_TDC0 - R2_TDC1 - R2_TDC2 - R2_TDC3 - R2_TDC4 - R2_TDC5 - R2_TDC6 - R2_TDC7 - R2_TDC8 - R2_TDC9 - R2_TDC10 - R2_TDC11 - R2_TDC12 - R2_TDC13 - R2_TDC14 - R2_TDC15 - R2_TDC16 - R2_TDC17 - R2_TDC18 - R2_TDC19), 13); -------------------------------------------- -- Overflow conditions -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D1, Sync, D1_TDC0) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D1 = '1') then D1_OVF <= '1'; elsif (Sync'event and Sync = '0') then if (D1_TDC0 = 400) then D1_OVF <= '0'; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R1, Sync, R1_TDC0) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R1 = '1') then R1_OVF <= '1'; elsif (Sync'event and Sync = '0') then if (R1_TDC0 = 400) then R1_OVF <= '0'; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_D2, Sync, D2_TDC0) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_D2 = '1') then D2_OVF <= '1'; elsif (Sync'event and Sync = '0') then if (D2_TDC0 = 400) then D2_OVF <= '0'; else null; end if; end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_R2, Sync, R2_TDC0) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_R2 = '1') then R2_OVF <= '1'; elsif (Sync'event and Sync = '0') then if (R2_TDC0 = 400) then R2_OVF <= '0'; else null; end if; end if; end process; -------------------------------------------- -------------------------------------------- -- Latching the leading edge of the Nflash signal -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, TIM_CLR, Nflash, I_COM) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or TIM_CLR = '1') then TIM_RUN <= '0'; elsif (Nflash'event and Nflash = '1') then if (I_COM = '1') then TIM_RUN <= '1'; else null; end if; end if; end process; -------------------------------------------- -- Latching the leading edge of the Event signal -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, Event, I_COM) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0') then TIM_STP <= '0'; elsif (Event'event and Event = '0') then if (I_COM = '1') then TIM_STP <= '1'; else null; end if; end if; end process; -------------------------------------------- -- Forming a short Nflash pulse -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, Sync, TIM_RUN) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1') then TIM_CNT <= 0; elsif (Sync'event and Sync = '1') then if (TIM_RUN = '1') then TIM_CNT <= TIM_CNT + 1; else TIM_CNT <= 0; end if; end if; end process; -------------------------------------------- -- Finishing the Nflash pulse -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, Sync, TIM_CNT) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1') then TIM_CLR <= '0'; elsif (Sync'event and Sync = '0') then if (TIM_CNT = 1) then TIM_CLR <= '1'; else TIM_CLR <= '0'; end if; end if; end process; -------------------------------------------- -- NS counter -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, TIM_RUN, Sync, US_SET) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or TIM_RUN = '1') then NS_CNT <= 50; elsif (Sync'event and Sync = '1') then if (US_SET = '0') then NS_CNT <= NS_CNT + 50; else NS_CNT <= 50; end if; end if; end process; -------------------------------------------- -- 1us interval -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, Sync, NS_CNT) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1') then US_SET <= '0'; elsif (Sync'event and Sync = '0') then if (NS_CNT = 1000) then US_SET <= '1'; else US_SET <= '0'; end if; end if; end process; -------------------------------------------- -- US counter -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, TIM_RUN, Sync, MS_SET, US_SET) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or TIM_RUN = '1') then US_CNT <= 0; elsif (Sync'event and Sync = '1') then if (MS_SET = '0') then if (US_SET = '1') then US_CNT <= US_CNT + 1; else null; end if; else US_CNT <= 0; end if; end if; end process; -------------------------------------------- -- 1ms interval -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, Sync, US_CNT) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1') then MS_SET <= '0'; elsif (Sync'event and Sync = '0') then if (US_CNT = 1000) then MS_SET <= '1'; else MS_SET <= '0'; end if; end if; end process; -------------------------------------------- -- MS counter -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, TIM_RUN, Sync, SS_SET, MS_SET) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or TIM_RUN = '1') then MS_CNT <= 0; elsif (Sync'event and Sync = '1') then if (SS_SET = '0') then if (MS_SET = '1') then MS_CNT <= MS_CNT + 1; else null; end if; else MS_CNT <= 0; end if; end if; end process; -------------------------------------------- -- 1sec interval -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, Sync, MS_CNT) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1') then SS_SET <= '0'; elsif (Sync'event and Sync = '0') then if (MS_CNT = 1000) then SS_SET <= '1'; else SS_SET <= '0'; end if; end if; end process; -------------------------------------------- -- Copy the timer values over registers -------------------------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_TMS, TIM_STP, MS_CNT) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_TMS = '1') then Time_ms <= (others => '1'); elsif (TIM_STP'event and TIM_STP = '1') then Time_ms <= conv_std_logic_vector((1023 - MS_CNT), 10); end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_TUS, TIM_STP, US_CNT) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_TUS = '1') then Time_us <= (others => '1'); elsif (TIM_STP'event and TIM_STP = '1') then Time_us <= conv_std_logic_vector((1023 - US_CNT), 10); end if; end process; ------------------------- process(PWR_ON, COM_SET, SEL_SET, Clear, R29_TNS, TIM_STP, NS_CNT) begin if (PWR_ON = '1' or COM_SET = '1' or SEL_SET = '1' or Clear = '0' or R29_TNS = '1') then Time_ns <= (others => '1'); elsif (TIM_STP'event and TIM_STP = '1') then Time_ns <= conv_std_logic_vector((1023 - NS_CNT), 10); end if; end process; -------------------------------------------- end;