我在TOP文件中声明了一个矩阵和一个信号:
type scanImage is array (0 to 7,0 to 7) of std_logic_vector(2 downto 0);
signal image_matrix : scanImage;
现在,我想将上述信号发送到一个函数,该函数计算矩阵中不是""的单元格数。
我的包装如下:
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;
编译后我收到此错误: 错误(10476):vision_ctrl.vhd(112)处的VHDL错误:标识符的类型" image_matrix"不同意它的用法" double_array"型
感谢您的帮助。
答案 0 :(得分:3)
两个数组scanImage
和double_array
的类型不同;恰好以同样的方式宣布。
因此请使用image_matrix
类型声明double_array
,而不是使用新类型scanImage
:
signal image_matrix : my_pack.double_array;
然后,您可以将my_pack.square_calculation
与image_matrix
参数一起使用。