【发布时间】:2017-12-11 02:09:34
【问题描述】:
我正在使用 Quartus Prime Pro。
我正在处理这样一个函数:
library ieee ;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
function round_resize (a : unsigned; b : integer) return unsigned is
variable c : signed (a'length - 1 downto 0); --problem child
variable d : signed (b - 1 downto 0);
begin
c := a + to_signed(2**(b-2), a'length);
d := to_unsigned(c(c'length-2 downto (c'length-b-1)));
return d;
end function;
但我得到了错误:
错误(13643):file.vhd(109)处的 VHDL 错误:无法确定运算符“+”的定义——找到 0 个可能的定义
所以我把问题子改成这样:
c := to_unsigned( a + to_signed(2**(b-2), a'length), a'length);
但我收到以下错误:
Error(13815): VHDL Qualified Expression error at cpmmod.vhd(110): to_unsigned type specified in Qualified Expression must match signed type that is implicitly for expression by context
我还能尝试什么来完成这项工作?
【问题讨论】:
-
嗯,你可以respect types,但不清楚你为什么要这么做。
-
@user1155120 我真的不明白你为什么不把它放在答案中......相反,你只是链接到有答案的代码图像!为什么尽管付出了所有这些努力,但仍然拒绝发布答案?