--==================================================================== library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; use work.tcds2_bx_and_orbit_pkg.all; --==================================================================== entity orbit_monitor is generic ( G_COUNTER_WIDTH : positive := 32 ); port ( reset_i : in std_logic; bunch_clock_i : in std_logic; orbit_strobe_i : in std_logic; first_strobe_detected_o : out std_logic; missed_strobe_detected_o : out std_logic; early_strobe_detected_o : out std_logic; missed_strobe_count_o : out std_logic_vector(G_COUNTER_WIDTH - 1 downto 0); early_strobe_count_o : out std_logic_vector(G_COUNTER_WIDTH - 1 downto 0) ); end entity orbit_monitor; --================================================== architecture arch of orbit_monitor is begin process (bunch_clock_i) is variable bx_cnt : bx_num; variable first_strobe_detected : boolean; variable missed_strobe_detected : boolean; variable early_strobe_detected : boolean; variable num_missed_strobes : natural; variable num_early_strobes : natural; begin if rising_edge(bunch_clock_i) then if reset_i = '1' then bx_cnt := C_LHC_MIN_BX_NUM; first_strobe_detected := false; missed_strobe_detected := false; early_strobe_detected := false; num_missed_strobes := 0; num_early_strobes := 0; elsif not first_strobe_detected then if orbit_strobe_i = '1' then first_strobe_detected := true; else first_strobe_detected := first_strobe_detected; end if; else if bx_cnt = C_LHC_MAX_BX_NUM and orbit_strobe_i /= '1' then missed_strobe_detected := true; num_missed_strobes := num_missed_strobes + 1; else missed_strobe_detected := missed_strobe_detected; num_missed_strobes := num_missed_strobes; end if; if bx_cnt /= C_LHC_MAX_BX_NUM and orbit_strobe_i = '1' then early_strobe_detected := true; num_early_strobes := num_early_strobes + 1; else early_strobe_detected := early_strobe_detected; num_early_strobes := num_early_strobes; end if; bx_cnt := next_bx(bx_cnt); end if; end if; if first_strobe_detected then first_strobe_detected_o <= '1'; else first_strobe_detected_o <= '0'; end if; if missed_strobe_detected then missed_strobe_detected_o <= '1'; else missed_strobe_detected_o <= '0'; end if; if early_strobe_detected then early_strobe_detected_o <= '1'; else early_strobe_detected_o <= '0'; end if; missed_strobe_count_o <= std_logic_vector(to_unsigned(num_missed_strobes, missed_strobe_count_o'length)); early_strobe_count_o <= std_logic_vector(to_unsigned(num_early_strobes, early_strobe_count_o'length)); end process; end architecture arch; --====================================================================