WRITEDATA

Section: C Library Functions (3)
Updated: Aug 7, 1985
Index Return to Main Contents
 

NAME

wrd_open, wrd_run, wrd_init, wrd_command, wrd_output, wrd_point, wrd_end, wrd_close, wrd_chtrace, wrd_stopnow - spice output routines  

SYNOPSIS

#include "FTEwritedata.h"

int wrd_open(filename, title, asciiflag)
char *filename, *title;

int wrd_run(title)
char *title;

int wrd_init(plotname, flags)
char *plotname;
short flags;

int wrd_command(comm)
char *comm;

int wrd_output(name, type, flags)
char *name;
short flags;

int wrd_point(rdata, idata)
double *rdata, *idata;

int wrd_end()

int wrd_close()

int wrd_chtrace(name, addflag, what)
char *name;

int wrd_stopnow()
 

DESCRIPTION

These routines are used by SPICE3 to create raw data files. They can be used with any circuit simulator that outputs data similar to that of SPICE3, making it usable with nutmeg(1) and sconvert(1). See the manual page for sconvert(1) for details of the data file formats.

To compile a program with writedata, you should link with the files "writedata.o", "std.o", and "wrdfix.o". The file "std.c" contains some utility routines, and the file "wrdfix.c" contains dummy declarations that allow writedata to be used apart from the rest of the front-end.

Descriptions of the routines follow. Note that they must be called in the order given, except where noted.

wrd_open opens the file filename, and begins creating a raw file with the title title. If asciiflag is 1, then an ascii format file is created, otherwise a binary format file is written. Either this call or wrd_run must be the first call to a writedata routine.

wrd_run starts a run of a circuit with a title of title. All the data passed to writedata from now on is accumulated and is available to the user after the run is finished. This only works when the SPICE3 front-end (FTE) is compiled as a part of the simulator.

wrd_init starts a run. Any number of runs may be done with one call to wrd_open, with the result that they are placed in the file one after another.

wrd_command causes the SPICE3 or nutmeg command string comm to be written to the file, to be executed by nutmeg whenever the file is read in or made current with the setplot command. If the current run was started with a wrd_run, the command is executed immediately, in addition to being saved for setplot commands. Note that all commands must be given between the call to wrd_init and the first call to wrd_output. A common command is version version-id, which causes nutmeg to warn the user if the version-id is out of date.

wrd_output declares an output variable, with name name, variable type type, and variable flags determined by or'ing the flags given to wrd_init and the flags argument. Flags are as follows, defined in the file "FTEconstant.h" (which is included by "FTEwritedata.h"):

#define VF_REAL     (1 << 0) /* The data is complex. */
#define VF_COMPLEX  (1 << 1) /* The data is real. */
#define VF_ACCUM    (1 << 2) /* Save this vector. */
#define VF_PLOT     (1 << 3) /* Incrementally plot it. */
#define VF_PRINT    (1 << 4) /* Print this vector. */
#define VF_LOGSCALE (1 << 5) /* Use a log scale to plot this. */

Only the flags VF_REAL, VF_COMPLEX, and VF_LOGSCALE should be used. The variable types are defined as follows:

#define SV_NOTYPE   0
#define SV_TIME     1
#define SV_FREQUENCY    2
#define SV_VOLTAGE  3
#define SV_CURRENT  4
#define SV_OUTPUT_NOISE 5
#define SV_INPUT_NOISE  6
#define SV_HD2      7
#define SV_HD3      8
#define SV_DIM2     9
#define SV_SIM2     10
#define SV_DIM3     11

Any number of outputs may be declared. The types of variables and the order in which they are declared must be consistent with the succeeding calls to wrd_point.

wrd_point is given pointers to real and imaginary vectors, each point of which corresponds to a point to be added to one of the outputs declared above. If the outputs are all real, then the idata pointer may be NULL.

wrd_end is called when there are no more points to be output. A new call to wrd_init may now be given, if writedata is writing to a file.

wrd_close closes the current file, if there is one open.

wrd_chtrace changes the flag with value what in the variable named name - if addflag is 0, then the flag is cleared, otherwise it is set. This is mainly used by the FTE tracing routines.

wrd_stopnow returns a value of WRD_STOP if the user desires the simulation to stop, either because a breakpoint has been reached, or because he has typed interrupt. Otherwise, the value WRD_OK is returned. The next time wrd_stopnow is called, WRD_OK is returned, unless another interrupt has been typed in the meantime.  

DIAGNOSTICS

If everything went ok, the value WRD_OK is returned. If there was some error, WRD_ERROR is returned. Additionally wrd_stopnow may return WRD_STOP. These values are defined in "writedata.h".  

SEE ALSO

nutmeg(1), sconvert(1), spice(1)  

AUTHOR

Wayne Christopher (faustus@cad.berkeley.edu)  

BUGS


 

Index

NAME
SYNOPSIS
DESCRIPTION
DIAGNOSTICS
SEE ALSO
AUTHOR
BUGS

This document was created by man2html, using the manual pages.
Time: 15:58:06 GMT, February 14, 2023