title: Passing a generic to a package in VHDL
body: <p>I am trying to implement a generic (parameterizable) matrix adder. </p>
  
  <p>So far I just have a matrix adder for two 3x3 matrices. Here is matrix_add:</p>
  
  <pre><code>LIBRARY IEEE;
  USE IEEE.std_logic_1164.all;
  USE IEEE.STD_LOGIC_ARITH.ALL;
  USE IEEE.std_logic_UNSIGNED.all;
  USE ieee.numeric_std.all;
  
  LIBRARY work;
  USE work.matrix_pack.all;
  
  ENTITY matrix_add  is
    PORT (
      t_clk_i          : IN    STD_LOGIC;  -- System Clock (66.6667 MHz) (
      s_rst_l_i        : IN    STD_LOGIC;  -- Reset input
      d_mat1_i         : IN    matrix_t; -- Matrix 1 
      d_mat2_i         : IN    matrix_t; -- Matrix 2 
      d_result_o       : OUT   matrix_t  -- Addition Result  
    );
  END matrix_add;
  
  ARCHITECTURE rtl_matrix_add OF matrix_add IS
  
  BEGIN
    p_add : PROCESS(t_clk_i, s_rst_l_i)
    BEGIN
      IF s_rst_l_i = '0' THEN
        d_result_o &lt;= (OTHERS =&gt; (OTHERS =&gt; (OTHERS =&gt; '1')));
      ELSIF RISING_EDGE(t_clk_i) THEN
        FOR i IN 0 TO (d_mat1_i'LENGTH(1)-1) LOOP
          FOR j IN 0 TO (d_mat1_i'LENGTH(2)-1) LOOP
            d_result_o(i, j) &lt;= d_mat1_i(i, j) + d_mat2_i(i, j);
          END LOOP;
        END LOOP;
      END IF;
    END PROCESS p_add;
  
  END rtl_matrix_add;
  </code></pre>
  
  <p>and here is the package:</p>
  
  <pre><code>LIBRARY IEEE;
  USE IEEE.std_logic_1164.all;
  USE IEEE.STD_LOGIC_ARITH.ALL;
  USE IEEE.std_logic_UNSIGNED.all;
  USE ieee.numeric_std.all;
  
  PACKAGE matrix_pack IS
    TYPE matrix_t is ARRAY (0 TO 2, 0 TO 2) OF STD_LOGIC_VECTOR(7 DOWNTO 0);
  END matrix_pack;
  </code></pre>
  
  <p>How can I make the size of the matrix generic? Unfortunately I have to use a package because Quartus will not accept <em>ARRAY (0 TO 2, 0 TO 2) OF STD_LOGIC_VECTOR(7 DOWNTO 0)</em> as a signal input type otherwise I wouldn't need a package and my problem would be solved.</p>
  
  <p>I've heard this can be done in VHDL 2008, but how so and will Quartus or Modelsim even accept this?</p>
  
  <p>Thanks</p>