cxrdfile

Capsim Block Documentation

Short Description

This function performs the simple task of reading sample values in from a file, and then placing them on its output buffer.

Top
Parameters
Num Description Type Name Default Value
0 File that contains data file file_name stdin
Top
States
Num Type Name Initial Value Description
0 int obufs
1 FILE* fp
2 int done FALSE
Top

Declarations


 

	int i,j;
	complex x;



Top

Initialization Code



 

	if(strcmp(file_name,"stdin") == 0)
		fp = stdin;
	else if((fp = fopen(file_name,"r")) == NULL) {
		fprintf(stderr,"cxrdfile: cannot open file\n");
		return(1); /* file cannot be opened */
	}
	if( (obufs = NO_OUTPUT_BUFFERS()) < 1 ) {
		fprintf(stderr,"cxrdfile: no output buffers\n");
		return(2);
	}
        for(i=0; i
    
Top

Main Code



 

	if(done)return(0);
	/* output a maximum of NUMBER_SAMPLES_PER_VISIT samples to output buffer(s) */
	for(i=0; i < NUMBER_SAMPLES_PER_VISIT; ++i) {

		/* Read input lines until EOF */
		if(fscanf(fp,"%f %f",&x.re, &x.im) == EOF) {
			done=TRUE;
			return(0);

		}

		/* input sample available: */
		/* increment time on output buffer(s) */
		/* and output a sample */
		for(j=0; j
    
Top

Wrapup Code



 

        if (fp != stdout)
             fclose(fp);
        return(0);




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



 

/*************************************************************
		cxrdfile()
***************************************************************
This function performs the simple task of reading
sample values in from a file, and then placing them on
it's output buffer. The file may have multiple sample values
per line, which can be integer or float.
An example use for this routine is to access a stored waveform
as input to a simulation.
The parameters are:
	file_name = name of file to read from, defaults to "stdin"
Typical usage:
param file input_file
star Reader cxrdfile.s
param default
star Reader cxrdfile.s
(The first version will read from the file with name input_file,
	while the second version will read from standard input)

cxrdfile


This function performs the simple task of reading
sample values in from a file, and then placing them on
it's output buffer. The file may have multiple sample values
per line, which can be integer or float.
An example use for this routine is to access a stored waveform
as input to a simulation.
The parameters are:
	file_name = name of file to read from, defaults to "stdin"
Typical usage:
param file input_file
star Reader cxrdfile.s
param default
star Reader cxrdfile.s
(The first version will read from the file with name input_file,
	while the second version will read from standard input)


Programmer: R. T. Wietelmann / D.G.Messerschmitt
Date: June 5, 1982
Modified for V2.0 by D.G. Messerschmitt March 7, 1985
Modified: July 10, 1985 by D.J.Hait
Modified: April, 1988 L.J.Faber: add "auto-fanout"
Modified: August 27, 2001 Sasan Ardalan converted to complex
	
*/