形式大小没有实际值或默认值vhdl

形式大小没有实际值或默认值vhdl,vhdl,xilinx,Vhdl,Xilinx,我试图在xilinx vivado suite上模拟一个程序,该程序旨在找到给定整数的平方。我节目的一部分- 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 " &

我试图在xilinx vivado suite上模拟一个程序,该程序旨在找到给定整数的平方。我节目的一部分-

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 ;
对于j in(位的数量-1)向下至0的循环

res您需要将
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 ;
对于j in(位的数量-1)向下至0的循环

哎呀!谢谢这消除了我的“那个”错误。但现在我在运行时遇到了不同的错误。它告诉错误:索引-2147483640越界7到0时间:0 ps迭代:0进程:/strt_sqr/line__121第121行是进程(num),其中num是前面告诉的整数输入。请原谅!我是一个vhdlHard的新手,在vhdlHard中不需要说任何事情,但你可能需要发起一些事情。提示:下次不要把所有事情都内联起来。A) 这使得阅读变得困难,B)这使得出错更容易。