Capsim Block Documentation
This star implements a fixed point normalized lattice filter.
int buffer_no; float xf,tmp; int xq; int sum,ysum; float val; int xfq,yq; int n1,n2,i,j,m; int noSamples; FILE* fp; |
---|
if((numberInputBuffers = NO_INPUT_BUFFERS()) <= 0) { fprintf(stderr,"fxn1: no inputs connected\n"); return(1); } if(numberInputBuffers > 1) { fprintf(stderr,"fxnl: only one input allowed \n"); return(2); } if((numberOutputBuffers = NO_OUTPUT_BUFFERS()) > numberInputBuffers) { fprintf(stderr,"fxnl: too many outputs connected\n"); return(3); } if(numberOutputBuffers == 0) { fprintf(stderr,"fxnl: no output connected\n"); return(4); } if(strcmp(file_name,"stdin") == 0) fp = stdin; else if((fp = fopen(file_name,"r")) == NULL) { fprintf(stderr,"fxnl():can't open file \n"); return(1); /* nl() file cannot be opened */ } /***************************************************** read lattice filter parameters from file ****************************************************/ fscanf(fp,"%d",&n); n1=n+1; /* allocate work space */ if(((k=(int*)calloc(n,sizeof(int))) == NULL) || ((c=(int*)calloc(n,sizeof(int))) == NULL) || ((nu=(int*)calloc(n1,sizeof(int))) == NULL) || ((xb=(int*)calloc(n1,sizeof(int))) == NULL )) { fprintf(stderr,"fxnl(): can't allocate work space \n"); return(1); } bitPrec=1; bitPrec = bitPrec<< regBits; quant=1; quant = quant<< quantBits; for (i=0; i |
---|
for(noSamples=MIN_AVAIL();noSamples >0; --noSamples) { IT_IN(0); switch (bufferType) { case FLOAT_BUFFER: /* * input floating point sample and quantize */ xf=INF(0,0); xfq = (int) xf*quant/(2.0 * quantRange); break; case INTEGER_BUFFER: xq=INI(0,0); break; } for (m=0; m |
---|
free(k); free(nu); free(c); free(xb); |
---|
/* Capsim (r) Text Mode Kernel (TMK) Star Library (Blocks) Copyright (C) 1989-2017 Silicon DSP Corporation This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA http://www.silicondsp.com Silicon DSP Corporation Las Vegas, Nevada */ |
---|
/************************************************************* Fixed Point Normalized Lattice Filter fxnl() This star implements a fixed point normalized lattice filter. All variables used are of type integer so that the algorithm can be directly implemented on a Digital Signal Processor. This star supports both floating point and integer buffers. If floating point buffers are used, the input samples are quantized with the input quantizer range and number of bits specified as parameters. The output is also converted to floating point within the original quantizer range. e.g. +- 5 volts. If integer buffers are used, no quantization is used and the integer input samples are processed directly. This star can be replace the floating point normalized lattice star nl.s to analyze the effects of fixed point implementation with different word sizes. *************************************************************** (c) 1991-2002 XCAD Corporation, All Rights Reserved |
---|