X
RSS YouTube LinkedIn Twitter Facebook

Search




Post new topic Reply to topic   [ 40 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
792
PostPosted: Sat May 12, 2012 6:11 am 
Joined: Fri Mar 19, 2010 4:49 am
Posts: 248
I found my results of my testing of the 48 bit IIR's. This example is an IIR filter of many ten's of order. All measurements were from a digital loopback with full accuracy (full 24 bits resolution with no operating system issues). No analog at all.
The Noise level is:
Attachment:
IIR Hi-Res Noise Level.png
IIR Hi-Res Noise Level.png [ 4.29 KiB | Viewed 1226 times ]

Here's the THD:
Attachment:
IIR Hi-Res THD.png
IIR Hi-Res THD.png [ 4.89 KiB | Viewed 1226 times ]


The 48 bit filter shows basically no harmonic distortions. The noise margin is +10dB for the 48 bit.

But both 32 bit and 48 bit are quite good.

Edit: to highlight differences.


Last edited by bearcat on Sun May 13, 2012 2:05 am, edited 2 times in total.

Top
Offline Profile View all posts by this user  
 
792
PostPosted: Sat May 12, 2012 6:22 am 
Joined: Fri Mar 19, 2010 4:49 am
Posts: 248
My code performs no sign testing.


Top
Offline Profile View all posts by this user  
 
2655
PostPosted: Sat May 12, 2012 6:23 am 
User avatar
XCore Expert
Joined: Sun Jul 11, 2010 1:31 am
Posts: 824
lilltroll wrote:
Bearcat, do you use 2-comp. longmult or do test the sign and then branch to unsigned longmult ?

You can calculate everything as unsigned always, by biasing all
numbers (by 0x8000_0000_0000_0000). You'll end up with an
accumulator that is biased by some constant number (because
your filter coefficients are fixed), so just add its negative at the
end. You can totally ignore overflow, all of this is integer after
all :-)


Top
Offline Profile View all posts by this user  
 
792
PostPosted: Sat May 12, 2012 10:00 pm 
Joined: Fri Mar 19, 2010 4:49 am
Posts: 248
I do plan on using the 48bit filters for subwoofer processing and crossovers, unlike the application shown above which I had written the filter for. Limit cycles are certainly an issue down there. I plan on performing similiar measurements in the future when I actually use the 48 bit version.


Top
Offline Profile View all posts by this user  
 
3032
PostPosted: Sun May 13, 2012 2:09 am 
User avatar
XCore Moderator
Joined: Fri Dec 11, 2009 3:53 am
Posts: 803
segher wrote:
lilltroll wrote:
Bearcat, do you use 2-comp. longmult or do test the sign and then branch to unsigned longmult ?

You can calculate everything as unsigned always, by biasing all
numbers (by 0x8000_0000_0000_0000). You'll end up with an
accumulator that is biased by some constant number (because
your filter coefficients are fixed), so just add its negative at the
end. You can totally ignore overflow, all of this is integer after
all :-)


Do you mean like this ?
int64y(n) is the signal
int32A is the signed filter coeff that is only changed every now and then, but not every sample
k=0x8000_0000_0000_0000 is the offset
hi:mi:lo is the result as a int96

If(A>=0)
offset= -k*A is precalculated when the filter coef. is updated
(y(n)+k)*A + offset = A*y(n)+k*A - k*A = A*y(n)
end

if(A<0)
offset = k*|A| is precalculated when the filter coef. is updated
(y(n)+k)*(-|A|) + offset = -|A|*y(n) - k*|A|+k*|A|=-(|A|*y(n))
end


Top
Offline Profile View all posts by this user  
 
2655
PostPosted: Sun May 13, 2012 9:50 pm 
User avatar
XCore Expert
Joined: Sun Jul 11, 2010 1:31 am
Posts: 824
Yes, something like that. It saves instructions because the correction
it has to do at the end is always the same, not dependent on the sign
bit of things; so a) it does not have to calculate with the sign bits, and
b) some expressions can be combined in the end.

Even easier of course is to use the MACCUS instruction, which
unfortunately does not exist ;-)


Top
Offline Profile View all posts by this user  
 
3032
PostPosted: Mon May 14, 2012 4:37 am 
User avatar
XCore Moderator
Joined: Fri Dec 11, 2009 3:53 am
Posts: 803
segher wrote:
Yes, something like that. It saves instructions because the correction
it has to do at the end is always the same, not dependent on the sign
bit of things; so a) it does not have to calculate with the sign bits, and
b) some expressions can be combined in the end.
The 96-bit result exists in hi:mi:lo

Even easier of course is to use the MACCUS instruction, which
unfortunately does not exist ;-)


ASM-master segher, I might need some helt with negative coeffs.

For positive coeffs, you can do it like this, and with only one coef. A as in this example, the Offset Ohi:Omi can be pre-negated and replace the zero's in the lmul avoiding the lsub in the end.
Insignal: Yhi:Ylo
Coeff: A
Result: hi:mi:lo

Code:
POS:
lmul Ohi,Omi,A,offset,zero,zero // Calculate the offset
POSloop:
add Yhi,Yhi,offset //add offset to in-signal
lmul carry, lo, Ylo, A, zero, zero
lmul hi, mi, Yhi, A, zero, carry
//Calc 2-comp. value by subtracting the offset.
lsub borrow,hi,hi,Ohi,zero
lsub s0,mi,mi,Omi,borrow
sub lo,lo,borrow


But what about the negative case ? Can I avoid the negate at the end.

Code:
NEG:
lmul Ohi,Omi,A,offset,zero,zero
NEGloop:
add Yhi,Yhi,offset //add offset to in-signal
lmul carry, lo, Ylo, A, zero, zero
lmul hi, mi, Yhi, A, zero, carry
//Calc 2-comp.
lsub borrow,hi,Ohi,hi,zero
lsub borrow,mi,Omi,mi,borrow
sub lo,lo,borrow
//negate hi:mi:lo
not hi,hi
not mi,mi
neg lo,lo


Top
Offline Profile View all posts by this user  
 
2655
PostPosted: Mon May 14, 2012 11:33 pm 
User avatar
XCore Expert
Joined: Sun Jul 11, 2010 1:31 am
Posts: 824
Your "negate" at the end is incorrect, it does not carry.

You're doing Ox-x, and then negating it; you can just do x-Ox
instead.

If you do things right, there is no difference whatsoever between
positive and negative numbers, which is the point. By adding the
offset, you're shifting the [-80000000..7fffffff] range to [0..ffffffff],
which is much nicer to compute with. Say for example you are
jut doing a*b, and write D=80000000, then you instead compute
(a+D)*(b+D) which is a*b+(a+b+D)*D, so you get a*b by subtracting
the right side of that (which is cheaper than it looks!)

Nothing in there is dependent on sign, it works exactly the same for
positive and negative numbers, which is the point :-)


Top
Offline Profile View all posts by this user  
 
3032
PostPosted: Tue May 15, 2012 3:33 pm 
User avatar
XCore Moderator
Joined: Fri Dec 11, 2009 3:53 am
Posts: 803
If you look at the expression above, "Ox-x" is correct, the incorrect thing is the order of lsub together with the borrow.

I believe this has a chance of beeing correct, and it is "Ox-x" all the way.

Code:
NEGloop:
add Yhi,Yhi,offset //add offset to in-signal
lmul s0, s2, Ylo, A, zero, zero
lmul hi, mi, Yhi, A, zero, s0
lsub s0,lo,zero,s2,zero
lsub s0,mi,Omi,mi,s0
lsub s0,hi,Ohi,hi,s0


Thank's anyway


Top
Offline Profile View all posts by this user  
 
3032
PostPosted: Tue May 15, 2012 3:56 pm 
User avatar
XCore Moderator
Joined: Fri Dec 11, 2009 3:53 am
Posts: 803
segher wrote:
Your "negate" at the end is incorrect, it does not carry.

You're doing Ox-x, and then negating it; you can just do x-Ox
instead.

If you do things right, there is no difference whatsoever between
positive and negative numbers, which is the point. By adding the
offset, you're shifting the [-80000000..7fffffff] range to [0..ffffffff],
which is much nicer to compute with. Say for example you are
jut doing a*b, and write D=80000000, then you instead compute
(a+D)*(b+D) which is a*b+(a+b+D)*D, so you get a*b by subtracting
the right side of that (which is cheaper than it looks!)

Nothing in there is dependent on sign, it works exactly the same for
positive and negative numbers, which is the point :-)


The thing is that multiplication works exactly the same for
positive and negative numbers as well, as long as you sign extend the numbers.

The question is thus, when is it cheaper to add an offset and subtract it on the XMOS ISA, compared to just multiply direct?
Assume that both a and b are a(n) and b(n), (time-dependent), is it better to use the bias method? Or is it only when one coefficient becomes static over a longer time-window the total instruction count is reduced.


Top
Offline Profile View all posts by this user  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic   [ 40 posts ]  Go to page Previous  1, 2, 3, 4  Next


Who is online

Users browsing this forum: Google [Bot] and 1 guest



Search for:
Jump to: