These forums are read only, please use our new forums here.

Main :: ToneCore Development Kit



Simple Multiplication Question
by cheezor on 2013-02-07 10:58:14

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?



Re: Simple Multiplication Question
by clangen on 2013-02-07 12:12:47

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



Re: Simple Multiplication Question
by cheezor on 2013-02-09 13:35:00

Thanks for your response. I think my problem is that I dont have a very good grasp on the numbering format, but your explaination helps. From what you are saying, I'm assuming that the numbers are always in the range of -1 to 1.

Here is the code that I was using for the timer: https://www.dropbox.com/s/pdkfejzshz8bki9/Tutorial%2004%20-%20Timer.asm

I have been posting some beginner tutorials at Freestompboxes.org to hopefully get some more interest with this pedal. I just hope Im not explaining everything wrong. lol At least it will give people a starting point with some really simple programs.

Anyways, the code in that link just has the timer set up. I basically start off with a counter value and decrement that on every interupt until the value is equal to 0. Then I flip the bit I was talking about in my previous post and reset the counter value and the cycle continues all over again. If I understood your post correctly, couldn't I just flip a different bit to achieve a value of 1? Thus making the multiplying the signal by the flag value a viable option?

Is there a good tutorial for the fractional numberin format that I could read up on? I feel like this is the area that is really holding me back from making more complex programs.



Re: Simple Multiplication Question
by clangen on 2013-02-12 06:05:10

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




The information above may not be current, and you should direct questions to the current forum or review the manual.