Skip navigation
56 Views 3 Replies Latest reply: Feb 12, 2013 6:05 AM by clangen RSS
cheezor Just Startin' 6 posts since
Mar 18, 2011
Currently Being Moderated

Feb 7, 2013 10:58 AM

Simple Multiplication Question

So I have been struggling with figuring out how to do some simple multiplication on my ToneCore DSP. I have written a timer that basically flips a single bit on a "flag" so that I either have a 1 or a 0. This is the 0th bit in the register so I assume that the number in decimal is 1 or 0. Am I wrong?

 

So the timer works fine. But where I run into trouble is when I try to multiply my flag times the current sample. I would think that I would either have a muted signal or the original signal depending on the state of the flag, but I listen to the output I am getting nothing out. When I output the sample to the screen (after the multiplication) it seems to either be FFFFFF or 000000 but that value doesn't coincide with the value of the flag at all (which I am also outputting to the screen).

 

I could make this program so that it branched and either did nothing to the sample or wrote 0’s over it depending on the value of the flag bit, but that seems like it’s incredibly inefficient compared to just multiplying it. Any thoughts?

  • clangen Just Startin' 25 posts since
    Jul 8, 2009
    Currently Being Moderated
    Feb 7, 2013 12:12 PM (in response to cheezor)
    Re: Simple Multiplication Question

    Hi Cheesor,

     

    you're right, the problem lies in the number format of the DSP. Your 'counter' increments the least significant bit in the accumulator. The DSP fractional numbering format uses the MSB (most significant bit) as sign bit with the weighting -2^0 = -1.0 The following bits are weighted by the factors 2^-1 (1/2), 2^-2 (1/4) and so on. Doing a multiplication by the timer 'content' caused the input sample multiplied by 2^-24 if you copy (move) the register content a0 to one of the operand registers in advance. Just moving the incremented accumulator causes to copy the content of the accumulator a1 which is zero unless you incremented the counter 2^24 times.

     

    So the phenomenon is clear to me, the result yields zero (000000) or an even _very_ small negative number FFFFFF (-2^-23, to calculate this is left as an exercise to the reader, just follow the rule given above :-)).

     

    So in your case branching (i.e. muting the signal corresponding to the flag setting) is the only option I can see for the moment.

     

    If you give a concise description of the problem you intend to solve I could probably help more.

     

    Christian

      • clangen Just Startin' 25 posts since
        Jul 8, 2009
        Currently Being Moderated
        Feb 12, 2013 6:05 AM (in response to cheezor)
        Re: Simple Multiplication Question

        Dear cheezor,

         

        reviewing your code was not that easy. I can ee the timer checking the accumulator content for zero but not the influence on the audio signal. Anyways there are two other possibilities to mute the signal by flipping a bit:

         

        1.) Flip the sign bit, this is corresponding the guard bits in accumulator a2 correspinding to bit 23 in the operand registers. Be careful not to change bit 47 in the accumulator since this is _not_ the sign bit - this is inherent in the accumulator guard bits.

        The result is the same as moving -1.0 to any of those registers. Afterwards the polarity should be inverted in the accumulator by the 'neg a' instruction. Note that writing ~1.0 = 0.9999998 to a register is done by flipping _all_ bits except the sign bit, but maybe the right polarity of the output signal isn't an issue for your application.

         

        2.) Use the flipped bit to control writing 0.9999998 or 0.0000000 corresponding to 1.0 and 0.0 correspondingly. This is really annoying but the DSP can handle control istructions much worse than a microcontroller. Code branches are relatively unusual in DSP algorithms compared to the tight MAC loops this architecture was designed for. It is possible to code conditional code execution but this is more nasty than on ARM or even 8051. We can have conditional code execution but only for BRxx and Jxx (or BRSxx and JSxx for subroutines) where xx is corersponding to the status register flag settings combinations.

         

        In each case have a try with the Symphony Studio simulator for first. Small items like this can be observed conveniently by changing the register numbering formats from fractional, interger and hexadecimal on the fly.

         

        Have fun checking the DSP563xx architecture with the simulator,

         

        Christian

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • Correct Answers - 5 points
  • Helpful Answers - 3 points