Re-ran aclocal and automake on an updated system.
[xcircuit.git] / asg / net.h
blob8e597373658947d7fe7b11a7da284ab9bd1e6b37
2 /************************************************************
3 **
4 ** COPYRIGHT (C) 1988 UNIVERSITY OF PITTSBURGH
5 ** COPYRIGHT (C) 1988-1989 Alan R. Martello
6 ** ALL RIGHTS RESERVED
7 **
8 ** This software is distributed on an as-is basis
9 ** with no warranty implied or intended. No author
10 ** or distributor takes responsibility to anyone
11 ** regarding its use of or suitability.
13 ** The software may be distributed and modified
14 ** freely for academic and other non-commercial
15 ** use but may NOT be utilized or included in whole
16 ** or part within any commercial product.
18 ** This copyright notice must remain on all copies
19 ** and modified versions of this software.
21 ************************************************************/
24 ** Global Include File
26 ** vsim VHDL Simulator
27 ** Copyright (C) 1988, University of Pittsburgh
32 ** File: net.h
34 ** Functions: N/A
36 ** Description:
39 ** Author: Lyn Ann Mears (LAM) - University of Pittsburgh, EE Dept.
40 ** Modified by: Alan R. Martello (ARM) - University of Pittsburgh, EE Dept.
42 ** Revision History
43 ** ----------------
44 ** Date Initials Description of change
46 ** thru 7/88 LAM Initial modification of RSIM along with writing
47 ** new routines, including debug of code.
48 ** 08/04/88 ARM Code cleanup; added comments.
51 ** Some code taken and adapted from RSIM work performed by Chris Terman.
55 #include <stdio.h>
57 #define INCLUDE_TIMER 1 /* switch to include timer calls / instruction */
61 * return values for all 'cmd_xxxx' calls
63 #define CMD_SAME_LEVEL 0 /* stay on the same command level */
64 #define CMD_UP_LEVEL 1 /* pop up one command level (file) */
66 #define FIRST_LEVEL_CALL 0 /* first call to print node's critical path */
68 #ifndef TRUE
69 #define TRUE 1
70 #endif
71 #ifndef FALSE
72 #define FALSE 0
73 #endif
75 /* alias definitions */
76 #define MAX_ALIAS 50 /* the maximum number of allowed alias */
77 #define MAX_ALIAS_NAME 10 /* the maximum length of an alias name */
79 #define BIG_NUMBER 0x7FFFFFFF /* used as a delta value to perform a sort */
81 /* delay equates */
82 #define TRANSPORT_DELAY 1
83 #define INERTIAL_DELAY 0
85 #define NO_DELTA 0L /* the delta value for the current time */
87 /* definitions for determining what vector list we want to deal with */
88 #define VLIST_CLOCK 1
89 #define VLIST_USER 2
91 /* usage: xxxxx command strings appear below */
92 #define USAGE_ACTIVITY "usage: activity starting_time [ending_time]"
93 #define USAGE_ALIAS "usage: alias [alias_name string_to_alias]"
94 #define USAGE_CL "usage: cl [number_of_clock_cycles]"
95 #define USAGE_CHANGES "usage: changes starting_time [ending_time]"
96 #define USAGE_CLOCK "usage: clock [node_name vector_string] ..."
97 #define USAGE_CLRVEC "usage: clrvec clock OR clrvec user"
98 #define USAGE_DEBUG "usage: debug [debug_level]"
99 #define USAGE_LOGFILE "usage: logfile [new_logfile_name]"
100 #define USAGE_NODE "usage: node [-l] node_name"
101 #define USAGE_PATH "usage: path node ..."
102 #define USAGE_RUNVEC "usage: runvec [number_of_cycles to run]"
103 #define USAGE_ST "usage: st [new_step_size]"
104 #define USAGE_STEPSIZE "usage: stepsize [new_step_size]"
105 #define USAGE_TRACE "usage: trace node ..."
106 #define USAGE_UVEC "usage: uvec [node_name vector_string] ..."
107 #define USAGE_WATCH "usage: watch [-]node_name ..."
108 #define USAGE_CMDFILE "usage: @ command_file_name"
109 #define USAGE_EFFECT_OTHERS "usage ? node ..."
110 #define USAGE_EFFECT_ME "usage: ! node ..."
113 #define MAXBITS 32 /* max number of bits in a bit vector */
115 /* possible values for nflags */
116 #define TRACED 0x0001
117 #define NAMED 0x0004
118 #define ALIAS 0x0008
119 #define DELETED 0x0010
120 #define STOPONCHANGE 0x0020
121 #define USERDELAY 0x0040
122 #define VISITED 0x0080
123 #define FORCE_VALUE 0x0100 /* set => node tied high/low */
124 #define FORCE_ONCE 0x0200 /* set => process as event to proogate
125 * results once */
127 /* definitions for 'oflags' below */
128 #define NORMAL_GATE 0x0001
129 #define PROCESS_GATE 0x0002
131 /* misc definitions */
132 #define NBUCKETS 20 /* number of buckets in histogram */
133 #define HASHSIZE 731 /* size of hash table (before chaining) */
134 #define MAXGLIST 10 /* maximum number of nodes in a gate list */
135 #define NFREE 4096
136 #define LSIZE 2000 /* max size of command line (in chars) */
137 #define MAXARGS 100 /* maximum number of command-line arguments */
138 #define MAXCOL 60 /* maximum width of print line */
140 #define INITED DELETED /* this flag used by init */
141 #define SETTLETIME 500 /* time in delta's to settle network */
142 #define MULT_LINE_ALIAS ';' /* the command for multiple line aliases */
144 #define TSIZE 1024 /* size of event array, must be power of two */
145 /* this is because we use (TSIZE - 1) to do a FAST modulo */
146 /* function in advance_simulated_time in queue.c */
148 #define NBUNCH 10 /* number of event structs to allocate at
149 * once */
153 *************************************************************
154 ** typedefs and structure definitions appear below **
155 *************************************************************
158 typedef struct Event *evptr;
159 typedef struct Node *nptr;
160 typedef struct Object *obptr;
161 typedef struct Input *iptr;
163 typedef struct nlist *nlptr;
164 typedef struct oblist *oblptr;
166 struct Event
168 evptr flink, blink; /* doubly-linked event list */
169 evptr nlink; /* link for list of events for this node */
170 nptr enode; /* node this event is all about */
171 nptr cause; /* node which caused this event to happen */
172 long ntime; /* time, in DELTAs, of this event */
173 char eval; /* new value */
176 struct Node
178 char *nname; /* name of node, as found in .ivf file */
179 nptr nlink; /* sundries list */
180 evptr events; /* */
181 oblptr in; /* list of objects with node as in */
182 oblptr out; /* list of objects with node as out */
183 nptr hnext; /* link in hash bucket */
184 long ctime; /* time in DELTAs of last transition */
185 nptr cause; /* node which caused last transition */
186 char nvalue; /* current value (lm npot in rsim) */
187 unsigned int nflags; /* flag word (see defs below) */
190 struct Object
192 char *oname; /* name of object */
193 char *otype; /* type of object */
194 nlptr in; /* list of nodes of mode in for object */
195 nlptr out; /* list of nodes of mode out for object */
196 char *eval; /* name of evaluation function for object */
197 int (*fun) (); /* evaluation function for object */
198 long delay; /* delay in deltas for object */
199 obptr hnext; /* link in hash bucket */
200 char oflags; /* flag word */
201 int dly_type; /* type of delay (transport or inertial) */
204 /* linked list of inputs */
205 struct Input
207 iptr next; /* next element of list */
208 nptr inode; /* pointer to this input node */
211 struct nlist
213 nlptr next;
214 nptr this;
217 struct oblist
219 oblptr next;
220 obptr this;
223 struct command
225 char *name; /* name of this command */
226 char *help_txt; /* help text for this command */
227 int (*handler) (); /* handler for this command */
230 typedef struct Bits *bptr;
232 struct Bits
234 bptr bnext; /* next bit vector in chain */
235 int bnbits; /* number of bits in this vector */
236 nptr bbits[MAXBITS]; /* pointers to the bits (nodes) */
237 char *bname; /* name of this vector of bits */
241 /* define the vector structure */
242 typedef struct VectorRecord Vector;
244 struct VectorRecord
246 char *vec_values; /* the vector of values */
247 nptr node; /* pointer to the node this vector refers to */
248 int num_elements; /* the number of elements in the
249 * vector */
250 int repeat_count; /* TRUE => '*' at end, FALSE
251 * otherwise */
252 Vector *next; /* pointer to next vector in vector list,
253 * NULL in none */
256 /* definition of command and '$x' alias structure */
257 struct alias_str
259 char alias_name[MAX_ALIAS_NAME];
260 char actual_cmd[LSIZE];
263 /* definition of sequential function names and addresses */
264 struct functions
266 char *name;
267 int (*fun) ();
271 *******************************************************
272 ** externs for global variables appear below **
273 *******************************************************
276 extern struct functions funs[];
277 extern struct functions proc_funs[];
279 extern oblptr seq_obs;
280 extern oblptr end_seq;
282 /* the clock vector list */
283 extern Vector *vec_clock;
285 /* the user-defined vector list */
286 extern Vector *vec_user;
288 extern struct alias_str alias_list[]; /* the alias list */
289 extern FILE *outfile; /* current output file */
290 extern char *targv[]; /* pointer to tokens on current command line */
291 extern int debug; /* <>0 means print lotsa interesting info */
292 extern int nfree; /* # of bytes of free storage remaining */
293 extern int nindex; /* number of nodes */
294 extern int pending; /* <>0 means events are still pending */
295 extern long stepsize; /* the current stepsize */
296 extern int targc; /* number of args on command line */
297 extern iptr hinputs; /* list of nodes to be driven high */
298 extern iptr infree; /* list of free input nodes */
299 extern iptr linputs; /* list of nodes to be driven low */
300 extern iptr wlist; /* list of watched nodes */
302 extern long cur_delta; /* the current time, in 0.1 ns increments */
304 extern long nevent; /* number of current event */
305 extern obptr curobj; /* pointer to current object */
307 extern int column;
308 extern int lineno;
309 extern char *filename;
311 extern struct Bits *blist;
312 extern FILE *logfile;
314 extern struct command cmdtbl[];
315 extern nptr hash[];
319 *******************************************************
320 ** external funtion definitions appear below **
321 *******************************************************
324 #ifndef CXREF
325 #define MAX(x,y) ( ((x)<(y)) ? (y) : (x) )
327 char *pnode ();
328 char *pnode_lc ();
329 double atof ();
331 int cmd_alias ();
332 int cmd_cmdfile ();
333 int cmd_comment ();
334 int cmd_cont ();
335 int cmd_display ();
336 int cmd_doactivity ();
337 int cmd_dochanges ();
338 int cmd_doclock ();
339 int cmd_doexit ();
340 int cmd_domsg ();
341 int cmd_dopath ();
342 int cmd_dostep ();
343 int cmd_excl ();
344 int cmd_help ();
345 int cmd_pnlist ();
346 int cmd_print_node ();
347 int cmd_quest ();
348 int cmd_quit ();
349 int cmd_sb_vec ();
350 int cmd_set_bits ();
351 int cmd_set_hi ();
352 int cmd_set_lo ();
353 int cmd_set_xinput ();
354 int cmd_setdbg ();
355 int cmd_setlog ();
356 int cmd_setstep ();
357 int cmd_settrace ();
358 #if INCLUDE_TIMER
359 int cmd_timer ();
360 #endif
361 int cmd_vec_clear ();
362 int cmd_vec_clock ();
363 int cmd_vec_run ();
364 int cmd_vec_user ();
365 long atol ();
367 nptr find ();
369 void info ();
370 void setin ();
371 void clear_vectors ();
372 void idelete ();
373 void iinsert ();
374 void init_hash ();
375 void init_nodes ();
376 void n_insert ();
377 void new_out ();
378 void presim ();
379 void prnode ();
380 void step ();
382 #endif
384 #define DEBUG_EVENTS 0x01
385 #define DEBUG_SYSTEM (~(DEBUG_EVENTS))
387 #if INCLUDE_TIMER
389 #define TIMER_ON_STR "on"
390 #define TIMER_OFF_STR "off"
391 #define TIMER_SHOW_STR "show"
393 #define TIMER_ON 1
394 #define TIMER_OFF 2
396 extern int timer_state;
397 extern long int elapsed_time;
399 #endif
401 extern int interrupt_flag;