library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

package test_package is
    --generic( generic_var : natural := 1 );
    
    -- Number of Domains    
    constant NUM_DOMAIN             : integer := 1;
    -----------------------------------------------------------------------------------------------------
    -- *DO NOT MODIFY BEGIN*
    type USER_DOMAIN_ID_TYPE is array (NUM_DOMAIN-1 downto 0) of integer;
    -- *DO NOT MODIFY END*
    -----------------------------------------------------------------------------------------------------
    -- Array of Domain IDs
    constant USER_DOMAIN_ID     : USER_DOMAIN_ID_TYPE := (0 => 1);
    
    constant DOMAIN_ID_WIDTH    : integer := 32;
    
	 type TEST_ARRAY_TYPE is array (1 downto 0) of string(1 to 10);
    constant TEST1 : string(1 to 10) := "Blah" & (1 to 6 => NUL);
    constant TEST2 : TEST_ARRAY_TYPE := (0 => "Blah" & (1 to 6 => NUL),
														1 => "Baba" & (1 to 6 => NUL));
	 
    type DOMAIN_ID_TYPE is array (NUM_DOMAIN-1 downto 0) of std_logic_vector(DOMAIN_ID_WIDTH-1 downto 0);
    
    type TEST_ARRAY is array (natural range <>) of string(1 to 256);
    
    function gen_domain_ids (user_id : USER_DOMAIN_ID_TYPE) return DOMAIN_ID_TYPE;
    
    
    
end package;

package body test_package is

    function gen_domain_ids (user_id : USER_DOMAIN_ID_TYPE) return DOMAIN_ID_TYPE is
        variable ret : DOMAIN_ID_TYPE;
    begin
        ret := (others => (others => '0'));
        for i in 0 to user_id'length-1 loop
            -- Check if User provided Domain ID fits
            -- NOTE: Cannot assert due to vhdl integer overflow.
            --assert (user_id(i) < (2**DOMAIN_ID_WIDTH-1 - PORT_CONFIG_PB) / PORT_CONFIG_DG) report "Domain ID range exceeded" severity failure;
            ret(i) := std_logic_vector(to_unsigned(user_id(i), ret(i)'length));
        end loop;
        return ret;
    end function;
    
    constant DOMAIN_ID : DOMAIN_ID_TYPE := gen_domain_ids(USER_DOMAIN_ID);
    
end package body;
