This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

使用DSP28335如何在一个指令周期完成乘加运算



我看书上说现代DSP内置MAC硬核,可以在一个时钟周期完成取数相乘并累加。

实验如下,例如c=a*b+c;

反汇编如下

可以看到有七句汇编,先用2个周期取ab值,1个周期相乘,1个周期取c值,1个周期想加,然后空1个周期(不懂这里为什么会出来一个NOP指令,同求解释),再1个周期赋值,与CCS内置的计时器吻合,都是七个时钟周期。

我想知道怎么样可以在一个时钟周期完成c=a*b+c这句指令,是CCS优化的问题吗?

  • 首先,浮点运算没有浮点乗加指令。其次,定点的乗加指令是将乘积与累加器相加,而不是你理解的这样。

  • C28有直接的乘加汇编指令,一个系统周期就可以执行完。

     你可以参照SPRU430E,这个应用文档,比如里面有一条指令,

    IMPYAL 就可以执行,但是前提是必须所有程序用汇编写,并且指令原型是乘加ACC 以及P T寄存器中的值

    IMPYAL  P,XT,loc32

    Add the unsigned content of the P register, ignoring the product shift mode
    (PM), to the ACC register. Multiply the signed 32-bit content of the XT
    register by the signed 32-bit content of the location pointed to by the “loc32”
    addressing mode. The product shift mode (PM) then determines which part
    of the lower 38 bits of the 64-bit result are stored in the P register:

  • 搞清楚了 谢谢