library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; use work.math_pkg.all; use work.test_package.all; use work.rtps_package.all; -- TODO: Remove alignment logic for RTPS Submessages, since all Submessages are 32-bit aligned -- Checksum has to be checked before entity test is port ( clk : in std_logic; -- Input Clock reset : in std_logic; -- Synchronous Reset input : in std_logic_vector(31 downto 0); cnt : out natural range 0 to NUM_ENDPOINTS ); end entity; architecture arch of test is signal test_var : natural := 0; -- Compares argument 'ref' with every element of 'ar', and returns the index of the last match. -- If no match is found, array length is returned. function match_id_endpoint (ref : std_logic_vector(ENTITYID_WIDTH-1 downto 0); ar : ENTITYID_TYPE) return natural is variable id : natural := 0; begin id := ar'length; for i in 0 to ar'length-1 loop if(ref = ar(i)) then id := i; end if; end loop; return id; end function; begin process(all) begin cnt <= 0; if (test_var < to_unsigned(input)) then cnt <= match_id_endpoint(input, ENTITYID); end if; end process; end architecture;