Capsim Block Documentation
This star compares two data streams for "equality" (use for BER). Appends to file.
| Port | Type | Name | |
|---|---|---|---|
| 0 | float | w | |
| 1 | float | x |
| Num | Type | Name | Description |
|---|---|---|---|
| 0 | float | BlockName_ber | The bit error rate (BER) |
| 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 |
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
|
|---|
fp=fopen(fileName,"a");
if(!fp) {
fprintf(stderr, "ecountfap: could not open file : %s for append\n",fileName);
return(2);
}
obufs = NO_OUTPUT_BUFFERS();
|
|---|
numin = MIN_AVAIL(); for(i=0; i |
|---|
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
|
|---|
/* 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://capsimtmk.sourceforge.net
XCAD Corporation
Raleigh, North Carolina */
|
|---|
/**********************************************************************
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.
|
|---|