Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
20785 Discussions

basic (stupid ?) filtering questions

Altera_Forum
Honored Contributor II
1,457 Views

Hi all,  

 

I.m playing with a self-made FIR filter (no fir compiler used).  

I have read the theory, but the devil is in the implementation, as they say :-P 

 

my ADC generates 8 bits values [0-255]. 

 

can I just feed these into the filter or do I need to "center the signal around 0", i.e. make sure that the signal value on average is 0 for the  

calculations to work ? 

(this would require signed values...) 

 

second question, assuming I need signed values: 

is this correct ? 

reg [7:0] unsignedval; 

reg signed [7:0] signedval; 

// from unsigned to signed 

signedval <= $signed(unsignedval - 8'd128); 

// and back : 

unsignedval <= $unsigned(signedval + 8'sd127 + 8'sd1); 

(since 8'sd128 does not fit in 8 bits 2scomplement) 

 

thanks for getting me up to speed ! 

 

ps I built my own filter in order to avoid the added complexity and choice offered by the FIR compiler.
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
747 Views

most DSP is done in 2's compliment, i would convert the ADC and DAC. that said i think it could be done in BCD, you won't find much reference material 

 

building a FIR by hand is a great learning experience and handy for when you run into something that the off the shelf IP does not support, but i had trouble meeting (let alone beating) FIR Compiler II's fmax and resource usage. and when the specs changed it took seconds to redo the filter instead of going back and analyzing which coefficients to put in fabric, etc
0 Kudos
Altera_Forum
Honored Contributor II
747 Views

regarding your conversions i'm not sure if you have to typecast the unsigned value before subtracting 128, i would run a sim as a sanity check. the general idea looks right

0 Kudos
Altera_Forum
Honored Contributor II
747 Views

Thank you ! I seem to have it working (except for a strange glitch now and then..)

0 Kudos
Reply