1

On my mbed LPC1768 I have an ADC on a pin which when polled returns a 16-bit short number normalised to a floating point value between 0-1. Document here.

Because it converts it to a floating point number does that mean its 32-bits? Because the number I have is a number to six decimal places. Data Types here

I'm running Autocorrelation and I want to reduce the time it takes to complete the analysis. Is it correct that the floating point numbers are 32-bits long and if so is it correct that multiplying two 32-bit floating point numbers will take a lot longer than multiplying two 16-bit short value (non-demical) numbers together?

I am working with C to program the mbed.

Cheers.

4

2 回答 2

2

我应该能够非常准确地对此发表评论。我曾经做过 DSP 处理工作,我们会“整合”代码,这实际上意味着我们将采用信号/音频/视频算法,并用定点算法替换所有浮点逻辑(即:Q_mn 表示法等)。

在大多数现代系统上,与浮点运算相比,使用整数运算通常可以获得更好的性能,但代价是您必须编写更复杂的代码。

您使用的芯片(Cortex M3)没有专用的基于硬件的 FPU:它只模拟浮点运算,因此浮点运算会很昂贵(需要很多时间)。

在您的情况下,您可以通过 读取 16 位值read_u16(),然后将值右移 4 次,就完成了。如果您正在处理音频数据,您可能会考虑研究压扩算法(a-law、u-law),这将提供比简单地切断 4 个LSB以从 16 获得 12 位数字更好的主观性能-位号。

是的,该系统上的浮点数是 32bit,并且可能以IEEE754 格式表示。将一对 32 位值与一对 16 位值相乘可能需要相同的时间,具体取决于所使用的芯片以及 FPU 和 ALU 的存在。在您的芯片上,将两个浮点数相乘在时间上会非常昂贵。此外,如果您将两个 32 位整数相乘,它们可能会溢出,因此如果您不想实现定点算法,则有一个潜在的理由使用浮点逻辑。

于 2016-04-16T13:28:44.243 回答
1

如果处理器中不存在特殊硬件(浮点单元),则假设乘以两个 32 位浮点数将比乘以两个 16 位短值花费更长的时间是正确的。

于 2016-04-16T13:23:20.543 回答