File: reader.h

package info (click to toggle)
gwave 0.0.4-2
  • links: PTS
  • area: main
  • in suites: slink
  • size: 1,216 kB
  • ctags: 429
  • sloc: ansic: 4,514; makefile: 120; sh: 17
file content (101 lines) | stat: -rw-r--r-- 2,619 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

/*
 * Definitions common to data-file readers.
 * At the moment this is somewhat specific to analog data.
 *
 * $Log: reader.h,v $
 * Revision 1.2  1998/09/17 18:22:39  tell
 * split typedef and struct decls to allow forward references.
 * added user-data pointer to DVar
 * Added binary HSPICE format and tracking of variable types
 *
 * Revision 1.1  1998/08/31 21:00:41  tell
 * Initial revision
 *
 */

#define DS_DBLKSIZE	8192
#define DS_INBLKS	1024
#define ds_blockno(n) ((n) / DS_DBLKSIZE)
#define ds_offset(n) ((n) % DS_DBLKSIZE)

typedef enum {
	UNKNOWN = 0,
	TIME = 1,
	VOLTAGE = 2,
	CURRENT = 3,
	FREQUENCY = 4,
} VarType;

typedef struct _DVar DVar;
typedef struct _DataFile DataFile;
typedef struct _IVar IVar;
typedef struct _DataSet DataSet;

/*
 * an array of values, the common part at the start of both DVar and IVar.
 */ 
struct _DataSet {
	char *name;
	DataFile *dfile;  /* backpointer to file */
	VarType type;
	int nvalues;
	double min;
	double max;
	
	/* remaining stuff is an array storage structure 
	 * that could be abstracted out and/or replaced with somthing else */
	/* pointer to array of pointers to blocks of doubles */
	double **bptr;
	int bpsize; /* size of array of pointers */
	int bpused; /* number of blocks actually allocated */
};

/* independent variable, for example time
 * values are expected to be monotonicly increasing. 
 * (or at least nondecreasing)
 */
struct _IVar {
	DataSet d;
	/* possible enhancement if needed for speed: add tree-structure 
	 * for fast access to particular value or ranges of values
	 */
};

/* dependent variable, for example voltage */
struct _DVar {
	DataSet d;
	IVar *iv;
	void *udata;
};

struct _DataFile {
	char *filename;
	IVar *iv;
	int ndv;
	DVar **dv;
};

/* defined in rd_cazm.c */
extern DataFile *cz_read_file(char *name, FILE *fp);

/* defined in rd_hspice.c */
extern DataFile *hs_read_file_ascii(char *name, FILE *fp);
extern DataFile *hs_read_file_bin(char *name, FILE *fp);

/* defined in reader.c */
extern DataFile *analog_read_file(char *name, char *format);
extern double an_interp_value(DVar *dv, double ival);
extern int an_find_point(IVar *iv, double ival);
extern double an_get_point(DataSet *ds, int n);

extern int fread_line(FILE *fp, char **bufp, int *bufsize);
extern void an_free_datafile(DataFile *df);
extern void an_init_dataset(DataSet *ds, DataFile *df, 
			    char *name, VarType type);
extern void an_free_dataset(DataSet *ds);
extern void an_set_point(DataSet *ds, int n, double val);
extern void an_expand_dset(DataSet *ds);
extern char *vartype_name_str(VarType type);

extern int analog_read_debug;