ecountfap

Capsim Block Documentation

Short Description

This star compares two data streams for "equality" (use for BER). Appends to file.

Top
Input Connections
Port Type Name
0 float w
1 float x
Top
Parameters
Num Description Type Name Default Value
0 Number of samples to ignore for final error tally int ignore 0
1 Index after which each error is printed to terminal int err_msg 30000
2 File name to append results file fileName ecount.dat
Top
Result Variables (TCL)
Num Type Name Description
0 float BlockName_ber The bit error rate (BER)
Top
States
Num Type Name Initial Value Description
0 int samples 0
1 int error_count 0
2 int hits 0
3 int obufs
4 FILE* fp
Top

Declarations


 

	int i,j;
	int numin;
	int err_out;
	char theVar[100];
	char theName[100];
#ifdef TCL_SUPPORT
        Tcl_Obj *varNameObj_P;
        Tcl_Obj *objVar_P;
#endif	



Top

Initialization Code



 

        fp=fopen(fileName,"a");
       if(!fp) {
          fprintf(stderr, "ecountfap: could not open file : %s for append\n",fileName);
          return(2);
       }
	obufs = NO_OUTPUT_BUFFERS();




Top

Main Code



 


	numin = MIN_AVAIL();
	for(i=0; i x(0) + GBAND || w(0) < x(0) - GBAND ) {
			hits++;
			if(samples >= ignore) {
				err_out = 1.;
				error_count++;
				if(samples >= err_msg)
	fprintf(stderr, "ecount: symbol error @%d\n",samples);

			}
			else {
				if(samples >= err_msg)
	fprintf(stderr, "ecount: symbol error @%d  (ignore)\n",samples);
			}
		}
		samples++;

		for(j=0; j
    
Top

Wrapup Code



 

	fprintf(stderr,"ecount: hits/samples = %d/%d  (ignore %d)  BER = %d/%d = %.4g\n",
		hits, samples, samples>ignore? ignore:samples,
		error_count, samples>ignore? samples-ignore:0,
		samples>ignore? (float)error_count/(samples-ignore):0);
	fprintf(fp,"%d  %d   %d  %d %d  %.4g \n",
		hits, samples, samples>ignore? ignore:samples,
		error_count, samples>ignore? samples-ignore:0,
		samples>ignore? (float)error_count/(samples-ignore):0);
       fclose(fp);
       
#ifdef TCL_SUPPORT
       if(!krn_TCL_Interp) {
          
	  return(0);
       }
       sprintf(theVar,"%.4g",samples>ignore? (float)error_count/(samples-ignore):0);
       sprintf(theName,"%s_ber",STAR_NAME);
       
	
	varNameObj_P=Tcl_NewStringObj(theName, strlen(theName));
	objVar_P=Tcl_NewObj();
		   
	Tcl_SetDoubleObj(objVar_P,samples>ignore? (float)error_count/(samples-ignore):0);
	Tcl_ObjSetVar2(krn_TCL_Interp,varNameObj_P,NULL,objVar_P,TCL_NAMESPACE_ONLY);
       
       
#endif       
  




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



 

/**********************************************************************
                ecountfap()
***********************************************************************
"error counter"
This star compares two data streams for "equality".  (Since the input
streams are floating point, a guard band is used.) An output stream
is created, with 'zero' output for equality, and 'one' if there is a
difference.  (Note: the output stream is optional--if no star is
connected to the output, there is no output.)
Param. 1 selects an initial number of samples to be ignored for
the final error tally (used during training sequences); default zero.
Param 2 sets an index, after which a message is printed to stderr for
each error.  It defaults to "infinity", i.e. no error messages.
This star prints a final message to stderr giving the error rate
(errors/smpl), disregarding the initial ignored samples.

ecountfap


"error counter"
This star compares two data streams for "equality".  (Since the input
streams are floating point, a guard band is used.) An output stream
is created, with 'zero' output for equality, and 'one' if there is a
difference.  (Note: the output stream is optional--if no star is
connected to the output, there is no output.)
Param. 1 selects an initial number of samples to be ignored for
the final error tally (used during training sequences); default zero.
Param 2 sets an index, after which a message is printed to stderr for
each error.  It defaults to "infinity", i.e. no error messages.
This star prints a final message to stderr giving the error rate
(errors/smpl), disregarding the initial ignored samples.
This star appends results to file. Useful for BER in batch mode.


Programmer: L.J. Faber 
Date: Dec 1987
Modified: April 1988
Modified: May 1988--Fix report print
Modified: June 1988--Fix report print

*/