I have the following VHDL function that multiples a given mxn matrix a
by a nx1 vector b
:
function matrix_multiply_by_vector(a: integer_matrix; b: integer_vector; m: integer; n: integer)
return integer_vector is variable c : integer_vector(m-1 downto 0) := (others => 0);
begin
for i in 0 to m-1 loop
for j in 0 to n-1 loop
c(i) := c(i) + (a(i,j) * b(j));
end loop;
end loop;
return c;
end matrix_multiply_by_vector;
It works well but what does this actually implement in hardware? Specifically, what I want to know is if it is smart enough to realize that it can parallelize the inner for loop, essentially computing a dot product for each row of the matrix. If not, what is the simplest (i.e. nice syntax) way to parallelize matrix-vector multiplication?