Microchip
直播中

王峰

8年用户 189经验值
私信 关注
[问答]

dsPIC30F4013内联汇编浮点乘法

嗨,我试着使用内嵌程序集XC16编译器来执行浮点乘法。该设备是30F4013。第一个值来自查找表,它是一个浮动值,在2和1之间变化,因此,0.9,0.3,0.4等。它与音频样本乘以一个已签名的int。是否有一种在内联汇编中这样做的方法,因为C是非常慢的。我需要执行每一个采样周期乘以48千赫。本质上,结果=AudioSoint(int)* LUTvalue(浮点)。我知道我可以把所有的浮点都转换成整数和比例,但这对于应用来说是不理想的。谢谢。

以上来自于百度翻译


      以下为原文

    Hi,

I'm trying to perform a floating point multiply using inline assembly, XC16 compiler. The device is the 30F4013.

The first value comes from a look up table and it's a float value which varies between 2.0 and 1.0, so, 0.9, 0.3, 0.4 etc.

It's getting multiplied with an audio sample which is a signed int.

Is there a way of doing this in inline assembly as doing it is C is woefully slow. I need to perform the multiply every sample period, running at 48Khz.

In essence, Results = AudioSample(INT) * LUTvalue(Float).

I understand I can covert all the floats to integers and scale but that isn't ideal for the application.

Thanks.


回帖(14)

张润佘

2018-11-27 11:06:30
这是我的代码,它似乎不工作。CONCONBITES.IF=0;/*分数模式*/易失性寄存器INT ASM(“A”);ASM(“MOV.W.Audio,W4”);/*已初始化int音频*/ASM(“MOV.W.TrimValuy,W5”);/*浮点LUT值*/ASM(“MPY W4*W5,A”);

以上来自于百度翻译


      以下为原文

    This is my code, that doesn't appear to work. 
 
CORCONbits.IF = 0; /* FRACTION MODE */
volatile register int A asm("A");
asm("MOV.W _AUDIO, W4"); /*Singned Int Audio */
asm("MOV.W _TREMVALUE, W5"); /*Float LUT value */
asm("MPY W4*W5, A");
_FLOATAUDIO = __builtin_ACCL(A);
举报

李维兴

2018-11-27 11:11:50
用这个或这个替换这个,或者你可以这样做

以上来自于百度翻译


      以下为原文

    Replace this
_FLOATAUDIO = __builtin_ACCL(A);
with this
FLOATAUDIO = __builtin_ACCH(A);
or this
FLOATAUDIO = __builtin_sac(A,0);
 
Or you can do this
A = __builtin_mpy(AUDIO, TREMVALUE, NULL, NULL, 0, NULL, NULL, 0);
FLOATAUDIO = __builtin_sac(A, 0);
举报

李维兴

2018-11-27 11:17:17
你的意思是数字在0到1之间吗?

以上来自于百度翻译


      以下为原文

   
Do you mean the number is between 0.0 and 1.0?
举报

张润佘

2018-11-27 11:26:23
谢谢,我现在就试一试。LUT可以保持任何浮点值,在我的例子中,它是一个正弦波,它在1开始,在π/ 2上升到2,在π处上升到1,然后在π/3处上升到0。

以上来自于百度翻译


      以下为原文

    Thanks, I'll give that a try now. The LUT can hold any float value, in my case, it's a sine wave which starts at 1.0, rises to 2.0 at pi/2, 1.0 at pi ..then 0.0 at pi/3 etc.
举报

更多回帖

发帖
×
20
完善资料,
赚取积分