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.

DSPBIOS: How to implement _cmpyr1 to C-code?

Part Number: DSPBIOS


Hi team,

We want to convert some function to c-code.

_loll、_hill、_cmpyr1

static inline unsigned int _loll(long long src)
{
return (unsigned int)src;
}

static inline unsigned int _hill(long long src)
{
return (unsigned int)(src >> 32);
}

Do you know how to implement _cmpyr1 function in C-code?

Thanks

  • Hello,

    Which device and compiler were you using?

    E.g.: For a C6000 device with TI C compiler version 8.2.x:
    www.ti.com/.../sprui04b.pdf
    The pragma FUNC_CANNOT_INLINE prevents a function from being inlined.

    regards,
    David
  • Hi David,
    Because we have a plan to develop a DSP simulator in Visual C++.
    So we need to porting TI code to Visual C++.
    And we will develop same function like _loll() to simulate the DSP code in Windows platform.
    But we don't know how to implement _cmpyr1() to standard C-code in Visual C++.
    Could you tell me how to implement _cmpyr1() in Visual C++?
    Thanks.
  • Have tried looking at DSP instruction doc?

    www.ti.com/.../sprufe8
    TMS320C674x DSP CPU and Instruction Set User's Guide
    CMPYR1 Complex Multiply Two Pairs, Signed, Packed 16-Bit With Rounding
    sat((lsb16(src1) × msb16(src2)) + (msb16(src1) × lsb16(src2))) → tmp_e
    msb16(sat((tmp_e + 0000 4000h) << 1)) → lsb16(dst)
    sat((msb16(src1) × msb16(src2)) - (lsb16(src1) × lsb16(src2))) → tmp_o
    msb16(sat((tmp_e + 0000 4000h) << 1)) → msb16(dst)

    Your will have to implement the sat(), msb16() and lsb16() functions to faithfully reproduce the behavior of the DSP.
  • Hi Norman,

    It doesn't use tmp_o variable in document, so why we need to calculate tmp_o?

    sat((lsb16(src1) × msb16(src2)) + (msb16(src1) × lsb16(src2))) → tmp_e
    msb16(sat((tmp_e + 0000 4000h) << 1)) → lsb16(dst)
    sat((msb16(src1) × msb16(src2)) - (lsb16(src1) × lsb16(src2))) → tmp_o
    msb16(sat((tmp_e + 0000 4000h) << 1)) → msb16(dst)

    Thanks

  • Hi,

    The last line should be temp_o, this is a typo in the document. The cmpyr1 is explained in www.ti.com/.../sprugh7.pdf, page 259. See: e2e.ti.com/.../298247 for document errors. Unfortunately there was no new document revised for this. Sorry for the confusion!

    Regards, Eric