Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

Another way to make Fir Filter

DSP related issues, mathematics, processing and techniques

Another way to make Fir Filter

Postby Tepeix » Fri Feb 17, 2023 3:19 am

I forget a little my previous experience with fir and how much it become hard when trying to do lot of tap..
Having to read a cycling memory and a fixed one. (which is more hard with the instruction set of 3.6)


So i got this idea. (But maybe it already existed ?)

Each new sample, is like adding an array (or some lfo/wave) multiplied by this sample.

So why not an array of wave reader that will cycle all at 1 sample interval,
each time one of the wave-reader reset it load the current sample and store it in his how variable.
It will now be multiply by this value ;)

So this little example, a 64 tap fir filter that is composed by 64 wave reader ;) A little boring code to write, i wish i had made a text code compositor to make it but i copy paste and edit the number...

So the code work a little like this (but the line must be repeated and incremented for each tap..)

Code: Select all
int x=0;
//Main Cycle//
mov eax,x[0]; add eax,16; and eax,1023;
mov x[0],eax;

//WaveReader1//
cmp eax,0; jnz v1;
movaps xmm0,in; movaps i1,xmm0;
v1:
movaps xmm0,co[eax]; mulps xmm0,i1;

//WaveReader2//
add eax,16; and eax,1023; cmp eax,0; jnz v2;
movaps xmm1,in; movaps i2,xmm1;
v2:
movaps xmm1,co[eax]; mulps xmm1,i2; addps xmm0,xmm1;

Etc Etc .... Then movaps out,xmm0;
Attachments
Fir as MultiWaveReader.fsm
(53.72 KiB) Downloaded 487 times
Tepeix
 
Posts: 354
Joined: Sat Oct 16, 2021 3:11 pm

Re: Another way to make Fir Filter

Postby Tepeix » Mon Feb 20, 2023 11:17 pm

I find another trick... But i don't know if those are the best optimized way to do..
First, it's streaming so if one don't need 4 channel of the same filtering they must be faster way..
Then if the coefficient are symmetrical, some improvement could be done..
(And most time we want symmetrical fir...)
I have yet to test and compare with greater tap number...

This time the Brigade Technique !)
Instead of variable we will use a mem to store the signal but in a brigade way..

We will cycle each used memory, read it then write it to the next memory location..
This way memory and coefficient are aligned.

So in code that do this (repeating the 2 3 step for the desired amount of tap..)

Code: Select all
streamin in; streamout out;
memin co[32]; float mem[32];

//1
mov eax,0;
movaps xmm0,in;
movaps xmm7,co[eax];
mulps xmm7,xmm0;
//2 3
add eax,16; movaps xmm2,mem[eax];
movaps mem[eax],xmm0; movaps xmm6,co[eax];
mulps xmm6,xmm2; addps xmm7,xmm6;

add eax,16; movaps xmm0,mem[eax];
movaps mem[eax],xmm2; movaps xmm6,co[eax];
mulps xmm6,xmm0; addps xmm7,xmm6;
//////////////
Movaps out,xmm7;
Attachments
Fir as brigade.fsm
(5.14 KiB) Downloaded 452 times
Tepeix
 
Posts: 354
Joined: Sat Oct 16, 2021 3:11 pm


Return to DSP

Who is online

Users browsing this forum: No registered users and 45 guests