【问题标题】:convert float to integer in vhdl using fphdl使用 fphdl 在 vhdl 中将浮点数转换为整数
【发布时间】:2016-02-19 23:53:16
【问题描述】:

我想在我的 vhdl 代码中使用 fphdl 包将浮点数转换为整数。但是,我什至无法编译使用相关函数 to_integer 的赋值。我总是收到错误“子程序没有可行的整数条目”

函数声明为

  function to_integer (
arg                : UNRESOLVED_float;  -- floating point input
constant round_style : round_type := float_round_style;  -- rounding option
constant check_error : BOOLEAN    := float_check_error)  -- check for errors
return INTEGER;

我尝试过像这样使用它:

library ieee;
use ieee.fixed_float_types.all;
use ieee.fixed_pkg.all;
use ieee.float_pkg.all;
......

test_sig<=to_integer(sig_name); or 
test_sig<=to_integer(sig_name,round_zero,false);

但两者都不起作用

来自成功使用此包的人的帮助?

【问题讨论】:

  • sig_nametest_sig 的声明可能很重要。错误消息表明没有与参数和返回类型匹配的to_integer 的可见定义,或者有多个(因此它不知道选择哪个)。我还建议为参数命名关联,以便更容易发现问题。 (而且你在 VHDL-2008 模式下编译,对吧?)
  • 您可能还想提供Minimal, Complete, and Verifiable example。两个带有悬空“或”的信号分配并不能让读者清楚地了解您的问题是否与 to_integer 调用之外的其他内容有关。
  • 是的,我用 vhdl 2008 编译。这两个信号被声明为 std_logic_vectors(31 downto 0);我认为问题在于它无法区分这个包的 to_integer 函数和数字包的 to_integer 函数。我试图重命名函数和包(在前面添加 my_)但仍然没有运气......也许有一种特殊的方式来调用这个 fphdl 函数?

标签: integer vhdl point floating


【解决方案1】:

好吧,看来我找到了这样的解决方案:使用包中的 float32 子类型作为 _integer 函数的输入,在此之前我还必须使用 to_float 函数将 std_logic_vector 转换为浮点数。结果看起来不错!谢谢你的cmets!!!我希望合成一切顺利:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-27
    • 2014-02-13
    • 1970-01-01
    相关资源
    最近更新 更多