【问题标题】:How to send a floating point number to FPGA from HPS?如何从 HPS 向 FPGA 发送浮点数?
【发布时间】:2017-07-28 04:41:19
【问题描述】:

我正在使用 Altera DE0 nano SoC FPGA。我想知道如何从 HPS 向 FPGA 发送浮点数。

float ex_hps = 6000.9282;通过Avalon内存映射接口发送。如果Avalon_write_data address具有32位数据长度(可以从Qsys设置),在FPGA端这个数字存储在一个32位std_logic_vector对吗?

std_logic_vector 是否包含作为定点类型 (13 downto -14) 的浮点数和原始值?或者如何在VHDL中将这个数字放回FPGA端的定点数ex_fpga(13 downto -14)

【问题讨论】:

  • 您应该找到、阅读并理解定义 32 位浮点二进制表示的标准。接下来,您将了解在您的 FPGA 您的 CPU 中都可以使用相同的表示。
  • 6 到 -6 是 13 位,而不是 32...这里缺少信息。并且 737692.928203 不适合 6 到 -6 的 ufixed。
  • @JHBonarius 我确实更正了问题

标签: floating-point vhdl fixed-point intel-fpga soc


【解决方案1】:

这是你自己可以查到的。

您需要先将浮点数映射到 C 中的整数,使用有关系统的知识。

#include <math.h>

unsigned int PrepareForTransmission(float inputValue)
{
    if (inputValue < 0) return 0; /* underflow error: clip */
    if (inputValue >= powf(2.0f, 14)) return (unsigned int)pow(2.0, 28) - 1; /* overflow error: clip */
    return (unsigned int)(inputValue * pow(2.0, 14) + 0.5); /* +0.5 to round */
}

然后在 VHDL 中,您可以简单地将未签名的std_logic_vector(27 downto 0) 移植到ufixed(13 downto -14)。你(希望)知道怎么做。

【讨论】:

  • @komto909 说什么?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-25
  • 2017-06-27
  • 1970-01-01
  • 1970-01-01
  • 2011-11-05
  • 1970-01-01
相关资源
最近更新 更多