0

我在我的 TOP 文件中声明了一个矩阵和一个信号,如下所示:

type scanImage is array (0 to 7,0 to 7) of std_logic_vector(2 downto 0);
signal image_matrix : scanImage;

现在,我想将上述信号发送到一个函数,该函数计算矩阵中不是“000”的单元格数。

我的包裹看起来像这样:


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”类型

谢谢你帮助我。

4

1 回答 1

3

这两个数组scanImagedouble_array不是同一类型;恰好以相同的方式声明。

所以image_matrix用类型声明double_array,而不是创建一个新类型scanImage

signal image_matrix : my_pack.double_array;

然后你可以使用my_pack.square_calculationwithimage_matrix参数。

于 2015-02-08T11:50:58.113 回答