正式尺寸没有实际或默认值 vhdl

formal size has no actual or default value vhdl

我正在尝试在 xilinx vivado 套件上模拟一个程序,该程序旨在找到给定整数的平方。我的程序的一部分-

for j in (num_of_bits-1) downto 0 loop 
    res <=res+to_integer(unsigned(dvandha(shln(std_logic_vector(to_unsigned(num)),j)))); -- I get error here
    report "The resulting square is " & integer'image(res);
    res <= to_integer(unsigned(shln(std_logic_vector(to_unsigned(res)),1))); --I get error here
end loop ;

这里'res'是整数类型的inout。 dvandha 是我写的一个函数。它的输入参数是 std_logic_vector 和整数。 shln 是具有 'n' 班次的左移函数。 num 是我的整数输入。我收到以下错误 -

"formal size has no actual or default value "

我不知道错误是什么以及如何消除它。我没有在我的程序中按名称 "size" 使用任何 variable/signal。它指出我的尺寸是多少?我想这是类型转换的错误。我使用 'numeric_std' 库进行类型转换。请帮忙!提前致谢。

你需要给to_unsigned函数添加size参数,大概是这样的:

for j in (num_of_bits-1) downto 0 loop 
    res <=res+to_integer(unsigned(dvandha(shln(std_logic_vector(to_unsigned(num,j)),j))));
    report "The resulting square is " & integer'image(res);
    res <= to_integer(unsigned(shln(std_logic_vector(to_unsigned(res,1)),1))); 
end loop ;

sizeto_unsigned函数中vector的大小