2 /************************************************************
4 ** COPYRIGHT (C) 1988 UNIVERSITY OF PITTSBURGH
5 ** COPYRIGHT (C) 1988-1989 Alan R. Martello
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
39 ** Author: Lyn Ann Mears (LAM) - University of Pittsburgh, EE Dept.
40 ** Modified by: Alan R. Martello (ARM) - University of Pittsburgh, EE Dept.
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.
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 */
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 */
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 */
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
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
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 */
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
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
;
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 */
178 char *nname
; /* name of node, as found in .ivf file */
179 nptr nlink
; /* sundries list */
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) */
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 */
207 iptr next
; /* next element of list */
208 nptr inode
; /* pointer to this input node */
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
;
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
;
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
250 int repeat_count
; /* TRUE => '*' at end, FALSE
252 Vector
*next
; /* pointer to next vector in vector list,
256 /* definition of command and '$x' alias structure */
259 char alias_name
[MAX_ALIAS_NAME
];
260 char actual_cmd
[LSIZE
];
263 /* definition of sequential function names and addresses */
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 */
309 extern char *filename
;
311 extern struct Bits
*blist
;
312 extern FILE *logfile
;
314 extern struct command cmdtbl
[];
319 *******************************************************
320 ** external funtion definitions appear below **
321 *******************************************************
325 #define MAX(x,y) ( ((x)<(y)) ? (y) : (x) )
336 int cmd_doactivity ();
337 int cmd_dochanges ();
346 int cmd_print_node ();
353 int cmd_set_xinput ();
361 int cmd_vec_clear ();
362 int cmd_vec_clock ();
371 void clear_vectors ();
384 #define DEBUG_EVENTS 0x01
385 #define DEBUG_SYSTEM (~(DEBUG_EVENTS))
389 #define TIMER_ON_STR "on"
390 #define TIMER_OFF_STR "off"
391 #define TIMER_SHOW_STR "show"
396 extern int timer_state
;
397 extern long int elapsed_time
;
401 extern int interrupt_flag
;