Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

How to improve this decimation FIR performance?

$
0
0

Hi,

I always get advice to write efficient C code on this forum. Here is an example I do not know how to write it in C, not in asm. The code is from Simulink DSP Coder generation. It is a decimation FIR (Decimation rate is 2).

for (j = 0; j < 27; j++) {
int da, db;
da = Hcic1_DWork.Hciccomp2_StatesBuff[curTapIdx];
db = (int32_T)Hcic1_ConstP.Hciccomp2_FILT[cffIdx];
tmp = _mpyilr(da, db);

tmp = tmp + Hcic1_DWork.Hciccomp2_Sums;
Hcic1_DWork.Hciccomp2_Sums = tmp;
cffIdx++;
curTapIdx -= 2;
if (curTapIdx < 0) {
curTapIdx += 54;
}
}

The decimation FIR  has 54 coefs. Each one of two filter phases pass through the above code for half coefs (27). The software pipeline is disabled because of the internal if clause.

I find that the FIR in DSPLIB are all block processed. There is no polyphase decimation FIR either. The input sampling data is at 96 KSPS in my project. The above code is a single data sample based, i.e. for each input data, the function is called once. I don't know how to write it in C to make the for loop efficiently although I know the assembly code can use circular buffer to pipeline the loop (but with some hard hand coding). I hope to get your opinion on efficient C coding, especially from RandyP.

Another question is about DSPLIB function DSP_fir_gen(). There are input data x[], FIR coef h[] and output data r[]. Where is the FIR internal states for repeat function calling? These function is only for one time call for initial state 0's?

Thanks,


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>