predlms

Capsim Block Documentation

Short Description

This star implements a multichannel input/output FIR predictor, which is adapted using the power normalized LMS algorithm.

Top
Parameters
Num Description Type Name Default Value
0 Name of ASCII input specification file. file ifile_name prfile
1 Name of ASCII output specification file. file ofile_name prfileo
2 LMS loop gain float lambda 1.0
3 LMS tap leakage factor float delta 1.0
4 Number of samples to skip before starting adaptation int wait 0
5 Number of samples to adapt. Freeze after this number of iterations int adapt -1
Top
States
Num Type Name Initial Value Description
0 int* orders
1 float* W
2 int N
3 int p
4 int q
5 float* Z
6 FILE* fp
7 float* xpower
8 float* epower
Top

Declarations


 

	int i,j,k,jj;
	float xdata;
	float error[Mch];
	float z[Mch];
	int index;
	float estimate;		/* prediction to output */
	float xalpha;		/* lms adaptation variable */



Top

Initialization Code



 

	if(NO_OUTPUT_BUFFERS() < 1) {
		fprintf(stderr,"pred: no output data channels\n");
		return(1);
	}
	if(NO_INPUT_BUFFERS() < NO_OUTPUT_BUFFERS() +1) {
		fprintf(stderr,"pred: not enough input buffers\n");
		return(2);
	}
	if((fp = fopen(ifile_name, "r")) == NULL) {
		fprintf(stderr,"pred: can't open spec file %s\n",
			ifile_name);
		return(3);
	}
	fscanf(fp, "%d", &q);
	fscanf(fp, "%d", &p);
	if(p > Mch || q > Mch) {
		fprintf(stderr,"pred: more than %d i/o channels\n",Mch);
		return(4);
	}
	if( q != NO_OUTPUT_BUFFERS() ||
	    p != NO_INPUT_BUFFERS() - q ) {
		fprintf(stderr,
		"pred: spec file %s does not agree with topology\n",
			ifile_name);
		return(5);
	}
	if(   (orders = (int*)calloc(p,sizeof(float))) == NULL
	   || (xpower = (float*)calloc(p,sizeof(float))) == NULL
	   || (epower = (float*)calloc(q,sizeof(float))) == NULL  ) {
		fprintf(stderr,"pred: can't allocate filter space\n");
		return(6);
	}
	N = 0;
	for(j=0; j
    
Top

Main Code



 

#if 0
if(MIN_AVAIL() == 0) return(0);
#endif

for(jj = MIN_AVAIL(); jj>0; jj--) {

if(wait > 0) {
	wait--;
	for(k=0; k0; i--)
	Z[i] = Z[i-1];
index = 0;
for(j=0; j 0) adapt--;

}
return(0);





Top

Wrapup Code



 

for(k=0; k
    
Top

License



/*  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
*/


Top

Description



 

/**********************************************************************
                predlms()
***********************************************************************
This star implements a multichannel input/output FIR predictor, which
is adapted using the power normalized LMS algorithm.
It can be used as an equalizer, FSE, DFE, or echo canceller.
An arbitrary number p input channels are transversal filtered
to produce an arbitrary number q output estimate signals.
Note: each output buffer connected to this star implies a separate
output channel, and identically numbered error input channel.
Input signal channels are then connected to higher numbered buffers.
It is assumed that the estimate error is computed externally.
Do NOT implement an external (causality) unit-delay from
output estimate to input error; this delay is handled automatically.
Param.	1 - Name of ASCII input specification file.  Filter orders
		and initial tap values are given.  default => prfile
The proper specification file format is:
  (int) # output channels, q
  (int) # input channels, p
  (int) order of in ch.#1  . . .  (int) order of in ch.#p
  (float) ch.#1, tap 1 . . .  (float) ch.#1, tap last
      .                                                {output ch.1}
      .
  (float) ch.#p, tap 1 . . .  (float) ch.#p, tap last
   .
   .
   .
  (float) ch.#1, tap 1 . . .  (float) ch.#1, tap last
      .                                                {output ch.q}
      .
  (float) ch.#p, tap 1 . . .  (float) ch.#p, tap last
Param.	2 - Name of output file, for final adapted filter values.
	  default => prfileo.  The file is written in proper
	  input-file format.  This file can then be used to initialize
	  the filter for the next run, if desired.
It is assumed that each output prediction filter will create one
estimate output for EACH input sample/error sample pair.
Any decimation, etc. must occur externally.
Param.	3 - (float) lambda.  It is a multiplicative factor to
	  control adaptation rate.  default => 1.0
Param.	4 - (float) delta.  Tap leakage factor.  default => 1.0
	  Default implies no tap leakage occurs.
	5 - (int) wait.  number of samples to skip before starting
	  adaptation.  The predictor still inputs samples, and
	  outputs a zero estimate.  default => 0
	6 - (int) adapt.  number of samples to adapt filter.  After
 	  this number, filter taps are fixed, and estimates are still
	  produced.  default => -1  (implies always adapt)

predlms


This star implements a multichannel input/output FIR predictor, which
is adapted using the power normalized LMS algorithm.
It can be used as an equalizer, FSE, DFE, or echo canceller.
An arbitrary number p input channels are transversal filtered
to produce an arbitrary number q output estimate signals.
Note: each output buffer connected to this star implies a separate
output channel, and identically numbered error input channel.
Input signal channels are then connected to higher numbered buffers.
It is assumed that the estimate error is computed externally.
Do NOT implement an external (causality) unit-delay from
output estimate to input error; this delay is handled automatically.
Param.	1 - Name of ASCII input specification file.  Filter orders
		and initial tap values are given.  default => prfile
The proper specification file format is:
  (int) # output channels, q
  (int) # input channels, p
  (int) order of in ch.#1  . . .  (int) order of in ch.#p
  (float) ch.#1, tap 1 . . .  (float) ch.#1, tap last
      .                                                {output ch.1}
      .
  (float) ch.#p, tap 1 . . .  (float) ch.#p, tap last
   .
   .
   .
  (float) ch.#1, tap 1 . . .  (float) ch.#1, tap last
      .                                                {output ch.q}
      .
  (float) ch.#p, tap 1 . . .  (float) ch.#p, tap last
Param.	2 - Name of output file, for final adapted filter values.
	  default => prfileo.  The file is written in proper
	  input-file format.  This file can then be used to initialize
	  the filter for the next run, if desired.
It is assumed that each output prediction filter will create one
estimate output for EACH input sample/error sample pair.
Any decimation, etc. must occur externally.
Param.	3 - (float) lambda.  It is a multiplicative factor to
	  control adaptation rate.  default => 1.0
Param.	4 - (float) delta.  Tap leakage factor.  default => 1.0
	  Default implies no tap leakage occurs.
	5 - (int) wait.  number of samples to skip before starting
	  adaptation.  The predictor still inputs samples, and
	  outputs a zero estimate.  default => 0
	6 - (int) adapt.  number of samples to adapt filter.  After
 	  this number, filter taps are fixed, and estimates are still
	  produced.  default => -1  (implies always adapt)


Programmer: L.J. Faber 
Date: April 1988
Modified: May 1988  add multichannel output
Modified: June 1988  estimate-referenced prediction energy
Modified: Aug 1988  est. input power.  new parameter delta.
Modified: Sept 1988  add parameters 5,6 and associated.

*/