DSPRelated.com
Forums

CMPY in c64+ (complex number representation convention)

Started by Michael Anburaj February 22, 2007
Michael-

> I am confused. Can you please let me know the correct
> ordering for R/I pair in memory for TI architectures?
>
> Is it 1 or 2?
>
> 1.
> struct complex
> {
> short Real;
> Short Imag;
> };
>
> 2.
> struct complex
> {
> short Imag;
> Short Real;
> };

First one.

-Jeff

PS. Please reply to the group. My job does not permit me to discuss outside the
group.

-Jeff

> --- Jeff Brower wrote:
>
> > Michael-
> >
> > > Till now I have been following the real first
> > > imaginary second convention for representing
> > complex
> > > numbers -- Cause the dsplib functions for complex
> > fft
> > > stated so & much of Ti literature.
> > >
> > > a[0], a[1] -- where a[0] is real part & a[1]
> > imaginary
> > > part
> > >
> > > But now I came across CMPY instruction in c64+, so
> > > though of replacing it with DOTP2 & DOTNP2 pair.
> > But,
> > > its explanation seem to direct to imaginary first
> > &
> > > real second kind of ordering both for the inputs &
> > for
> > > the product.
> > >
> > > Can someone give me the reason behind this & also
> > let
> > > me know the right convention for c64 architecture
> > > [Tis literature seem to be confusing the reader,
> > > clearly some places follow one convention & some
> > the
> > > other different pages of the same document do
> > have
> > > this problem].
> >
> > It would be very unlikely after all these years and
> > established conventions for DSP for TI programmers
> > to try and
> > switch around R/I pair ordering in memory. Which TI
> > document is it?
> >
> > One thing you might do is write directly to the TI
> > authors of the document and ask "why". If they
> > really did that,
> > then they would need to have a very good reason.
> >
> > -Jeff
> >
> >
> ____________________________________________________________________________________
> Be a PS3 game guru.
> Get your game face on with the latest PS3 news and previews at Yahoo! Games.
> http://videogames.yahoo.com/platform?platform0121
> Re: CMPY in c64+ (complex number representation convention)
> Posted by: "Michael Anburaj" e...@yahoo.com michaelanburaj
> Date: Fri Feb 23, 2007 6:32 am ((PST))
>
> Just now received a reply from Ti-Support.
>
> Yes indeed the CMPY x64+ instruction assumes a0j + a1
> approach; as this is used quite extensively in Ti
> fft16 libraries, as per the reply (may be internally).

Nevermind :) Below is an excerpt for fft16x16_1.asm (of
the C64+ DSPlib, entry point _DSP_fft16x16_imre). This is
the very first time the function appears, the C62/C64 DSPlibs
do not have a function with similar complex data layout:

* input to this routine is in Imaginary/Real order instead of the *
* traditional Real/Imaginary order. *

Thus, the "traditional" layout function _DSP_fft16x16 (in fft16x16_0.asm)
still assumes that a register's contents is lsb16=re, msb16=im.

I beleive that the architect for DOTP2, DOTPN2 was more concerned with
"classic" dot product, rather than with complex multiplication, and
it just "occured" that these instructions may as well be used to
calculate complex multiplications, as a byproduct and with pre and post
data shuffling.

However, there is no excuse for the C64+'s CMPY, CMPYR input layout
to assume that ordering, which is nominated as "non-traditional" :)
It seem (for me) that CMPY was designed to "mock" the two from the
C64 architecture, however strange that might be, taking into account
that the real part is anyway hi*lo-lo*hi, while DOTPN2 calculates
hi*hi-lo*lo.

The only "consolation" might be that the ADT "complex" is don't-care
about specific hardware ordering of real and imaginary parts :)

Sorry for this completely useless reply.

Rgds,

Andrew