Capsim Block Documentation
Block implements fixed point cascade form IIR digital filter.
Port | Type | Name | |
---|---|---|---|
0 | int | x |
Port | Type | Name | |
---|---|---|---|
0 | int | y |
int i,j,jj,jt; float wnorm; FILE *ird_F; int val; float factor; int fxfactor; int xs01,xs00,xs0less; int xs11,xs10,xs1less; int xs21,xs20,xs2less; int ys11,ys10,ys1less; int ys21,ys20,ys2less; int sum0,sum1; int out0,out1; double poleSec1_A[MAX_SECTIONS]; double poleSec2_A[MAX_SECTIONS]; double zeroSec1_A[MAX_SECTIONS]; double zeroSec2_A[MAX_SECTIONS]; |
---|
/* * open file containing filter coefficients. Check * to see if it exists. * */ if( (ird_F = fopen(filename,"r")) == NULL) { fprintf(stderr,"Casfil: File could not be opened \n"); return(4); } /* * Read in the filter coefficients and filter parameters. * */ fscanf(ird_F,"%d",&ns); if( ns > MAX_SECTIONS) { fprintf(stderr,"Casfil: Too many sections \n"); return(5); } for (i=0; i |
---|
while (IT_IN(0)) { for (j=0; j< ns; j++){ if (j==0){ xs_A[1]=0; xs_A[2]=0; xs_A[0]=x(0); if (n>0) xs_A[1]=x(1); if (n>1) xs_A[2]=x(2); } if (j>0) { for (jj=0; jj<3; jj++) xs_A[jj] = ys_A[jj]; } jt = j*3; for (jj=0; jj<2; jj++) ys_A[jj+1] = ycas_A[jt+jj]; /* * Implementing: * ys_A[0]=xs_A[0]+(zeroSec1_A[j]*xs_A[1])+(zeroSec2_A[j]*xs_A[2])-(poleSec1_A[j]*ys_A[1])-(poleSec2_A[j]*ys_A[2]); */ Fx_Part(size,xs_A[0],&xs01,&xs00,&xs0less); Fx_Part(size,xs_A[1],&xs11,&xs10,&xs1less); Fx_Part(size,xs_A[2],&xs21,&xs20,&xs2less); Fx_Part(size,ys_A[1],&ys11,&ys10,&ys1less); Fx_Part(size,ys_A[2],&ys21,&ys20,&ys2less); Fx_MultVar(xs0less,factorOneLess,size,xs01,xs00, factorOne1,factorOne0,&sum1,&sum0); Fx_MultVar(zeroSec1LessFlag_A[j],xs1less,size,zeroSec1FxFact1_A[j],zeroSec1FxFact0_A[j], xs11,xs10,&out1,&out0); Fx_AddVar(size,saturation_mode,sum1,sum0,out1,out0,&sum1,&sum0); Fx_MultVar(zeroSec2LessFlag_A[j],xs2less,size,zeroSec2FxFact1_A[j],zeroSec2FxFact0_A[j], xs21,xs20,&out1,&out0); Fx_AddVar(size,saturation_mode,out1,out0,sum1,sum0,&sum1,&sum0); Fx_MultVar(poleSec1LessFlag_A[j],ys1less,size,poleSec1FxFact1_A[j],poleSec1FxFact0_A[j], ys11,ys10,&out1,&out0); Fx_AddVar(size,saturation_mode,out1,out0,sum1,sum0,&sum1,&sum0); Fx_MultVar(poleSec2LessFlag_A[j],ys2less,size,poleSec2FxFact1_A[j],poleSec2FxFact0_A[j], ys21,ys20,&out1,&out0); Fx_AddVar(size,saturation_mode,out1,out0,sum1,sum0,&sum1,&sum0); Fx_RoundVar(size,accumSizeRound,roundoff_bits,sum1,sum0,&ys_A[0]); for (jj=0; jj<2; jj++) ycas_A[jt+jj] = ys_A[jj]; } if(IT_OUT(0)) { KrnOverflow("casfil",0); return(99); } //y(0) = ys_A[0]*wnorminv; y(0) = ys_A[0]; n = n+1; } return(0); |
---|
/* Capsim (r) Text Mode Kernel (TMK) Star Library (Blocks) Copyright (C) 1989-2002 XCAD 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.xcad.com XCAD Corporation Raleigh, North Carolina */ |
---|
/* casfil.s */ /*********************************************************************** fxcasfil() ************************************************************************ Star implements cascade form IIR digital filter. Parameter: (file) File with the filter coefficients and parameters The inputs from the file are as follows; ns: Number of sections zeroSec_A[i] zeroSec2_A[i] i=1 to ns the numerator coefficients poleSec1_A[i] poleSec2_A[i] i=1 to ns the denominator coefficients in the Z-domain. Date: October 15, 1988 Programmer: Tulay Adali Modified: Sasan Ardalan Modified: Sasan Ardalan, Fixed Point June 17, 2007 |
---|