This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Questions about on-chip Arithmetic capabilities of F132 series

Howdy all,
Recently I've been working on a Silicon Labs C8051F132 and am trying to implement a simple averaging filter using it. Unfortunately the time the cpu takes making the necessary calculations seems excessive, and enabling the on-chip arithmetic gains me no performance improvement. I was wondering if perhaps something else had to be initialized for the MAC to work.

I am using the Keil Compiler, uVision 3, and checking the box under the device settings, and see it add MDU_F120 to the Compiler control string. Unfortunately during the chip's operation from debug mode I can't witness the MAC doing anything. Thank you for any insight you can give me.

As I am new to this line of micro, the compiler, and all this stuff in general heh, please let me know if you need some more information. Thanks!

Parents
  • Well, the divison was happening as a necessity of the average filter. All the numbers were multiplied by a gain coefficient of 4096, and I was able to get divison via the shift function. A divide by 4096 is the same as left shifting the result until the significant bits filled the rounding registers. I don't have the code in front of me at the moment to explain it in much more detail, but that definately helped shave 20us or more off the overall filter operation.

    Aside from the division, the accumulates for the average filter is where I had hoped the MAC would improve performance the most. I had a loop that was something like:

    for(i=0;i<31;i++)
    {
    dm += buffer[i];
    }
    result = dm/4096;

    So I was able to plug that (and a bunch of calibration code above and below it) into the MAC and decreased the processing time from 40us for calibration and filtering, down to about 10us running a 96mhz sysclk. I think some of the confusion was a result of the MAC unit not having a true 32 bit output, it only supports 16 bit output which prevents WORD * WORD operations - UNLESS you pull the data out of the Accumulate registers (and that doesn't seem to be a standard operation). So in the end I suppose its difficult to have a compiler optimize code for a MAC.

    That being said, what does "supporting the MAC" really mean? I still wasn't able to get any examples of when the compiler would utilize the MAC. The project has really taken off now and I can't find time to look into the situation further. The filter works, its now quick enough and I'm moving on :P Just had to code the MAC as a peripheral and not rely on the compiler so much. Again I appreciate all the help. Much of the problem has been my inexperience in the matter and trying to find the simplest solution.

Reply
  • Well, the divison was happening as a necessity of the average filter. All the numbers were multiplied by a gain coefficient of 4096, and I was able to get divison via the shift function. A divide by 4096 is the same as left shifting the result until the significant bits filled the rounding registers. I don't have the code in front of me at the moment to explain it in much more detail, but that definately helped shave 20us or more off the overall filter operation.

    Aside from the division, the accumulates for the average filter is where I had hoped the MAC would improve performance the most. I had a loop that was something like:

    for(i=0;i<31;i++)
    {
    dm += buffer[i];
    }
    result = dm/4096;

    So I was able to plug that (and a bunch of calibration code above and below it) into the MAC and decreased the processing time from 40us for calibration and filtering, down to about 10us running a 96mhz sysclk. I think some of the confusion was a result of the MAC unit not having a true 32 bit output, it only supports 16 bit output which prevents WORD * WORD operations - UNLESS you pull the data out of the Accumulate registers (and that doesn't seem to be a standard operation). So in the end I suppose its difficult to have a compiler optimize code for a MAC.

    That being said, what does "supporting the MAC" really mean? I still wasn't able to get any examples of when the compiler would utilize the MAC. The project has really taken off now and I can't find time to look into the situation further. The filter works, its now quick enough and I'm moving on :P Just had to code the MAC as a peripheral and not rely on the compiler so much. Again I appreciate all the help. Much of the problem has been my inexperience in the matter and trying to find the simplest solution.

Children
No data