I declared a matrix and a signal in my TOP file like this:
type scanImage is array (0 to 7,0 to 7) of std_logic_vector(2 downto 0);
signal image_matrix : scanImage;
Now, I want to send the above signal to a function which calculates number of cells in the matrix which are not "000".
My package looks like this:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
use IEEE.std_logic_arith.all;
use IEEE.NUMERIC_STD.ALL;
USE IEEE.NUMERIC_BIT.ALL;
PACKAGE my_pack IS
type double_array is array (0 to 7,0 to 7) of std_logic_vector(2 downto 0);
--------------------square calculation declaration--------------------------
function square_calculation(matrix : double_array) return integer;
---------------------------------------------------------------------
function square_calculation(matrix : double_array) return integer IS
variable tmp: integer range 0 to 64;
begin
tmp:=0;
for i in 0 to 7 loop
for j in 0 to 7 loop
if matrix(i,j)/="000" then
tmp:=tmp+1;
end if;
end loop;
end loop;
return tmp;
end function square_calculation;
END my_pack;
After compilizing I get this error: Error (10476): VHDL error at vision_ctrl.vhd(112): type of identifier "image_matrix" does not agree with its usage as "double_array" type
Thanks for helping me.
The two arrays scanImage
and double_array
are not the same type; just happens to be declared the same way.
So declare image_matrix
with the type double_array
, instead of making a new type scanImage
:
signal image_matrix : my_pack.double_array;
Then you can use my_pack.square_calculation
with the image_matrix
argument.