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

Bits to keep: output FIR

Altera_Forum
Honored Contributor II
1,494 Views

Hi everybody, 

 

I’m working with a Stratix II and I generate a FIR Raised Cosine with DSP builder Megafunction (Matlab/Simulink). 

 

The output bits are 22 bits, but I can keep only 14 bits for DAC. 

How manages the other 8 bits? 

N MSB saturate/truncate, n LSB round/truncate…? 

 

Thanks for attention 

Fabio
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
817 Views

If any MSB is not used at all then you need to discard it freely. You can easily know the maximum swing of your output by finding out the maximum input value and the gain of your filter(sum of coefficients in hardware). 

 

If one MSB is used scarcely then you may opt to discard it with saturation. 

In principle it is better not to saturate. To avoid saturation you can lift up the filter gain to occupy that bit well or lift down to avoid it completely. 

 

Once you know how many MSBs to chop off then you discard the LSBs accordingly. You may round up for LSBs but this is optional to improve the result.
0 Kudos
Altera_Forum
Honored Contributor II
817 Views

Thanks Kaz! 

OUTPUT = 22 (14-22=8) 

 

I have 12 bit (cpl 2) input then => 2^(12-1)-1 = 2.047 

The sum coeffiecients (101) = 0,98707... 

 

2.047*0,98707 = 2.020,5420... <- the max value of convolution (right?) 

 

then 11 bit 

 

bits to keep = 14 

LSB = 0 

MSB = 8 TRUNCATE 

 

Is correct? 

 

thank a lot of!! 

 

Fabio
0 Kudos
Altera_Forum
Honored Contributor II
817 Views

your input statement is correct: 

When using 2's complement(signed), your 12 bit input can swing between 0 + 2047 

 

your coeff statement is incomplete: 

dc gain of your filter(strictly speaking your convolution) in hardware is the sum of all coefficients as scaled for hardware. Your figure of 0.98707 suggests a normalised dc gain.  

What happens to this gain in hardware depends on how you scale there, your convolution gain goes up by same factor used to scale coeffs.  

 

for example if your scale factor = 1022 (511/.5, assuming peak normalised coeff = .5) then convolution gain becomes .98707 x 1022 = 1009 in hardware. 

then max convolution output = 1009 x +2047 = + 2064984  

this requires 22 bits (2^21 = 2097152) 

Hence you need to keep all Msbs and truncate 8 Lsb 

 

You can fine tune the convolution sum under your control through this scale factor.  

A practical scale factor is the one that keeps unity filter dc gain after Lsb truncation i.e. a scale factor that equals your division(Lsb truncation). 

In my example I removed 8 Lsb(this means division by 2^8 = 256). Hence the filter which was scaled up by 1022 during convolution but then divided down by 256 after truncation gets a dc gain of 1022/256 = nearly 4 in hardware. In short: scale the normalised coeffs by a value such that their sum = 2^n (512 if 10 bits used) rather than the peak. 

 

It will help if you break above as three stages: 

normalisation(at modelling) 

scaling then convolution(mult-add in hardware) 

truncation(division by lsb truncation) to match signal resolution 

 

Details of gain control described here: 

 

http://www.digital-filters.co.uk/static/filter_gain
0 Kudos
Altera_Forum
Honored Contributor II
817 Views

!!!! Thanks Kaz very much !!!! 

 

Your example is my case, because i used 10 bit for the filter !!! 

 

Fabio ^_^
0 Kudos
Reply