You should define matrixsignal as a 2-dimensional array instead of a one-dimensional array that nests another 1-dimensional array.
type matrixsignal is array(LEVELS downto 0, NBIT - 1 downto 0) of std_logic;
The PoC-Library offers that type as T_SLM (std_logic_matrix) together lot's of manipulation functions and procedures in package PoC.vectors. E.g. PoC defines a get_col function like this:
function get_col(slm : T_SLM; ColIndex : natural) return std_logic_vector is
variable slv : std_logic_vector(slm'range(1));
begin
for i in slm'range(1) loop
slv(i) := slm(i, ColIndex);
end loop;
return slv;
end function;
Usage:
subtype matrixsignal is T_SLM(LEVELS downto 0, NBIT - 1 downto 0);
signal p_matrix, g_matrix : matrixsignal;
signal col_temp_g, col_temp_p : std_logic_vector(LEVELS downto 0);
...
col_temp_p <= get_col(p_matrix, j - 1);
col_temp_g <= get_col(g_matrix, j - 1);
The package PoC.vectors can be synthesized.
Further functions are provided like:
- slicing a complete row
- slicing sub matrixes
- flattening / serialization
- creating matrix from vector / deserialization
- overloaded boolean operators
- row / column assignment
- matrix merging
- conversion to/from 1-dimensional array types containing another 1-dimensional array type
- ...