1 /*
2  * Copyright (c) Tony Bybell 1999-2014.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  */
9 
10 #include "globals.h"
11 
12 #ifndef ANALYZER_H
13 #define ANALYZER_H
14 
15 #include <gtk/gtk.h>
16 #include <stdlib.h>
17 #include "wavealloca.h"
18 #include "vlist.h"
19 #include "debug.h"
20 
21 #ifdef AET2_IS_PRESENT
22 #define WAVE_ARRAY_SUPPORT
23 #endif
24 
25 
26 /* struct Node bitfield widths */
27 #define WAVE_VARXT_WIDTH (16)
28 #define WAVE_VARXT_MAX_ID ((1 << WAVE_VARXT_WIDTH) - 1)
29 #define WAVE_VARDT_WIDTH (6)
30 #define WAVE_VARDIR_WIDTH (3)
31 #define WAVE_VARTYPE_WIDTH (6)
32 
33 
34 typedef struct _SearchProgressData {
35     GtkWidget *window;
36     GtkWidget *pbar;
37     GtkAdjustment *adj;
38     int timer;	/* might be used later.. */
39     gfloat value, oldvalue;
40 } SearchProgressData;
41 
42 
43 #define BITATTRIBUTES_MAX 32768
44 
45 typedef struct ExpandInfo *eptr;
46 typedef struct ExpandReferences *exptr;
47 typedef struct Node	  *nptr;
48 typedef struct HistEnt	  *hptr;
49 typedef struct Bits       *bptr;
50 typedef struct VectorEnt  *vptr;
51 typedef struct BitVector  *bvptr;
52 typedef struct BitAttributes *baptr;
53 
54 typedef unsigned long  Ulong;
55 typedef unsigned int   Uint;
56 
57 enum TraceReorderMode  { TR_SORT_INS, TR_SORT_NORM, TR_SORT_LEX, TR_SORT_RVS };
58 
59 
60 /* vvv   Bit representation   vvv */
61 
62 enum AnalyzerBits  { AN_0, AN_X, AN_Z, AN_1, AN_H, AN_U, AN_W, AN_L, AN_DASH, AN_RSV9, AN_RSVA, AN_RSVB, AN_RSVC, AN_RSVD, AN_RSVE, AN_RSVF, AN_COUNT };
63 #define AN_NORMAL  { AN_0, AN_X, AN_Z, AN_1, AN_H, AN_U, AN_W, AN_L, AN_DASH, AN_DASH, AN_DASH, AN_DASH, AN_DASH, AN_DASH, AN_DASH, AN_DASH }
64 #define AN_INVERSE { AN_1, AN_X, AN_Z, AN_0, AN_L, AN_U, AN_W, AN_H, AN_DASH, AN_DASH, AN_DASH, AN_DASH, AN_DASH, AN_DASH, AN_DASH, AN_DASH }
65 
66 #define AN_MSK     (AN_COUNT-1) /* max index into AN_STR, AN_COUNT *must* be a power of two unless logic AND with AN_MSK is changed */
67 
68 /* positional ascii 0123456789ABCDEF, question marks should not happen unless something slips through the cracks as AN_RSVA to AN_RSVF are reserved */
69 #define AN_STR      "0xz1huwl-???????"
70 #define AN_STR_INV  "1xz0luwh-???????"
71 
72 #define AN_USTR     "0XZ1HUWL-???????"
73 #define AN_USTR_INV "1XZ0LUWH-???????"
74 
75 /* for writing out 4 state formats (read GHW, write LXT) */
76 #define AN_STR4ST   "0xz11xz0xxxxxxxx"
77 #define AN_USTR4ST  "0XZ11XZ0XXXXXXXX"
78 
79 /* for hex/oct conversion in baseconvert.c */
80 #define AN_HEX_STR  "0123456789ABCDEFxzwu-XZWU"
81 #define AN_OCT_STR  "01234567xzwu-"
82 
83 /* now the recoded "extra" values... */
84 #define RCV_X (1 | (0<<1))
85 #define RCV_Z (1 | (1<<1))
86 #define RCV_H (1 | (2<<1))
87 #define RCV_U (1 | (3<<1))
88 #define RCV_W (1 | (4<<1))
89 #define RCV_L (1 | (5<<1))
90 #define RCV_D (1 | (6<<1))
91 
92 #define RCV_STR "xzhuwl-?"
93 /*               01234567 */
94 
95 /* ^^^   Bit representation   ^^^ */
96 
97 #if (SIZEOF_VOID_P == SIZEOF_DOUBLE)
98 #define WAVE_HAS_H_DOUBLE
99 #endif
100 
101 
102 #ifdef WAVE_USE_STRUCT_PACKING
103 #pragma pack(push)
104 #pragma pack(1)
105 #endif
106 
107 typedef struct HistEnt
108 {
109 hptr next;	      /* next transition in history */
110 
111 union
112   {
113   unsigned char h_val;  /* value: AN_STR[val] or AnalyzerBits which correspond */
114   char *h_vector;	/* pointer to a whole vector of h_val type bits */
115 #ifdef WAVE_HAS_H_DOUBLE
116   double h_double;
117 #endif
118   } v;
119 
120 TimeType time;        /* time of transition */
121 unsigned char flags;  /* so far only set on glitch/real condition */
122 } HistEnt;
123 
124 #ifdef WAVE_USE_STRUCT_PACKING
125 #pragma pack(pop)
126 #endif
127 
128 
129 enum HistEntFlagBits
130 { HIST_GLITCH_B, HIST_REAL_B, HIST_STRING_B };
131 
132 #define HIST_GLITCH (1<<HIST_GLITCH_B)
133 #define HIST_REAL   (1<<HIST_REAL_B)
134 #define HIST_STRING (1<<HIST_STRING_B)
135 
136 #ifdef WAVE_USE_STRUCT_PACKING
137 #pragma pack(push)
138 #pragma pack(1)
139 #endif
140 
141 typedef struct VectorEnt
142 {
143 TimeType time;
144 vptr next;
145 unsigned char flags;  /* so far only set on strings */
146 unsigned char v[]; /* C99 */
147 } VectorEnt;
148 
149 #ifdef WAVE_USE_STRUCT_PACKING
150 #pragma pack(pop)
151 #endif
152 
153 
154 #define MAX_HISTENT_TIME ((TimeType)(~( (ULLDescriptor(-1)) << (sizeof(TimeType) * 8 - 1))))
155 
156 
157 typedef struct ExpandInfo	/* only used when expanding atomic vex.. */
158 {
159 nptr	*narray;
160 int	msb, lsb;
161 int	width;
162 } ExpandInfo;
163 
164 typedef struct ExpandReferences
165 {
166 nptr   parent;			/* which atomic vec we expanded from */
167 int    parentbit;		/* which bit from that atomic vec */
168 int    actual;			/* bit number to be used in [] */
169 int    refcnt;
170 } ExpandReferences;
171 
172 #ifdef WAVE_USE_STRUCT_PACKING
173 #pragma pack(push)
174 #pragma pack(1)
175 #endif
176 
177 struct Node
178   {
179     exptr    expansion; /* indicates which nptr this node was expanded from (if it was expanded at all) and (when implemented) refcnts */
180     char     *nname;	/* ascii name of node */
181     HistEnt  head;	/* first entry in transition history */
182     hptr     curr;      /* ptr. to current history entry */
183 
184     hptr     *harray;   /* fill this in when we make a trace.. contains  */
185 			/*  a ptr to an array of histents for bsearching */
186     union {
187       struct fac *mvlfac; /* for use with mvlsim aets */
188       struct vlist_packer_t *mvlfac_packer_vlist;
189       struct vlist_t *mvlfac_vlist;
190       char *value;	/* for use when unrolling ae2 values */
191     } mv; 		/* anon union is a gcc extension so use mv instead.  using this union avoids crazy casting warnings */
192 
193     int msi, lsi;	/* for 64-bit, more efficient than having as an external struct ExtNode*/
194 
195     int      numhist;	/* number of elements in the harray */
196 
197 #ifdef WAVE_ARRAY_SUPPORT
198     unsigned int array_height, this_row;
199 #endif
200 
201     unsigned varxt   : WAVE_VARXT_WIDTH; /* reference inside subvar_pnt[] */
202     unsigned vardt   : WAVE_VARDT_WIDTH; /* see nodeVarDataType, this is an internal value */
203     unsigned vardir  : WAVE_VARDIR_WIDTH; /* see nodeVarDir, this is an internal value (currently used only by extload and FST) */
204     unsigned vartype : WAVE_VARTYPE_WIDTH; /* see nodeVarType, this is an internal value */
205 
206     unsigned extvals : 1; /* was formerly a pointer to ExtNode "ext", now simply a flag */
207   };
208 
209 
210 #ifdef WAVE_USE_STRUCT_PACKING
211 #pragma pack(pop)
212 #endif
213 
214 
215 #define WAVE_NODEVARTYPE_STR \
216 static const char *vartype_strings[] = { \
217     "", \
218     "event", \
219     "integer", \
220     "parm", \
221     "real", \
222     "real_parm", \
223     "reg", \
224     "supply0", \
225     "supply1", \
226     "time", \
227     "tri", \
228     "triand", \
229     "trior", \
230     "trireg", \
231     "tri0", \
232     "tri1", \
233     "wand", \
234     "wire", \
235     "wor", \
236     "array", \
237     "realtime", \
238     "port", \
239     "string", \
240     "bit", \
241     "logic", \
242     "int", \
243     "s_int", \
244     "l_int", \
245     "byte", \
246     "enum", \
247     "s_real", \
248     "signal", \
249     "var", \
250     "const", \
251     "file", \
252     "memory", \
253     "net", \
254     "alias", \
255     "missing" \
256 };
257 
258 
259 enum nodeVarType {
260     ND_UNSPECIFIED_DEFAULT = 0,
261 
262     ND_VCD_EVENT           = 1,
263     ND_VCD_INTEGER         = 2,
264     ND_VCD_PARAMETER       = 3,
265     ND_VCD_REAL            = 4,
266     ND_VCD_REAL_PARAMETER  = 5,
267     ND_VCD_REG             = 6,
268     ND_VCD_SUPPLY0         = 7,
269     ND_VCD_SUPPLY1         = 8,
270     ND_VCD_TIME            = 9,
271     ND_VCD_TRI             = 10,
272     ND_VCD_TRIAND          = 11,
273     ND_VCD_TRIOR           = 12,
274     ND_VCD_TRIREG          = 13,
275     ND_VCD_TRI0            = 14,
276     ND_VCD_TRI1            = 15,
277     ND_VCD_WAND            = 16,
278     ND_VCD_WIRE            = 17,
279     ND_VCD_WOR             = 18,
280     ND_VCD_ARRAY           = 19,    /* used to define the rownum (index) port on the array */
281     ND_VCD_REALTIME        = 20,
282 
283     ND_VCD_PORT		   = 21,
284     ND_GEN_STRING          = 22,    /* generic string type */
285 
286     ND_SV_BIT              = 23,    /* SV types */
287     ND_SV_LOGIC            = 24,
288     ND_SV_INT              = 25,
289     ND_SV_SHORTINT         = 26,
290     ND_SV_LONGINT          = 27,
291     ND_SV_BYTE             = 28,
292     ND_SV_ENUM             = 29,
293     ND_SV_SHORTREAL        = 30,
294 
295     ND_VHDL_SIGNAL         = 31,
296     ND_VHDL_VARIABLE       = 32,
297     ND_VHDL_CONSTANT       = 33,
298     ND_VHDL_FILE           = 34,
299     ND_VHDL_MEMORY         = 35,
300 
301     ND_GEN_NET		   = 36,    /* used for AE2 */
302     ND_GEN_ALIAS	   = 37,
303     ND_GEN_MISSING	   = 38,
304 
305     ND_VARTYPE_MAX	   = 38
306    /* if this exceeds 63, need to update struct Node's "unsigned vartype : 6" declaration */
307 };
308 
309 
310 #define WAVE_NODEVARDATATYPE_STR \
311 static const char *vardatatype_strings[] = { \
312     "", \
313     "boolean", \
314     "bit", \
315     "bit_vec", \
316     "ulogic", \
317     "ulogic_v", \
318     "logic", \
319     "logic_v", \
320     "unsigned", \
321     "signed", \
322     "integer", \
323     "real", \
324     "natural", \
325     "positive", \
326     "time", \
327     "char", \
328     "string" \
329 };
330 
331 
332 enum nodeVarDataType {
333     ND_VDT_NONE                   = 0,
334 
335     ND_VDT_VHDL_BOOLEAN           = 1,
336     ND_VDT_VHDL_BIT               = 2,
337     ND_VDT_VHDL_BIT_VECTOR        = 3,
338     ND_VDT_VHDL_STD_ULOGIC        = 4,
339     ND_VDT_VHDL_STD_ULOGIC_VECTOR = 5,
340     ND_VDT_VHDL_STD_LOGIC         = 6,
341     ND_VDT_VHDL_STD_LOGIC_VECTOR  = 7,
342     ND_VDT_VHDL_UNSIGNED          = 8,
343     ND_VDT_VHDL_SIGNED            = 9,
344     ND_VDT_VHDL_INTEGER           = 10,
345     ND_VDT_VHDL_REAL              = 11,
346     ND_VDT_VHDL_NATURAL           = 12,
347     ND_VDT_VHDL_POSITIVE          = 13,
348     ND_VDT_VHDL_TIME              = 14,
349     ND_VDT_VHDL_CHARACTER         = 15,
350     ND_VDT_VHDL_STRING            = 16,
351 
352     ND_VDT_MAX                    = 16
353    /* if this exceeds 63, need to update struct Node's "unsigned vardt : 6" declaration */
354 };
355 
356 
357 #define WAVE_NODEVARDIR_STR \
358 static const char *vardir_strings[] = { \
359     "", \
360     "I", \
361     "O", \
362     "IO", \
363     "B", \
364     "L" \
365 };
366 
367 
368 enum nodeVarDir {
369     ND_DIR_IMPLICIT        = 0,
370     ND_DIR_IN              = 1,
371     ND_DIR_OUT             = 2,
372     ND_DIR_INOUT           = 3,
373     ND_DIR_BUFFER          = 4,
374     ND_DIR_LINKAGE         = 5,
375 
376     ND_DIR_MAX             = 5,
377     ND_DIR_UNSPECIFIED     = 6
378    /* if ND_DIR_MAX exceeds 7, need to update struct Node's "unsigned vardir : 3" declaration */
379 };
380 
381 
382 typedef uint64_t TraceFlagsType;
383 #define TRACEFLAGSSCNFMT SCNx64
384 #define TRACEFLAGSPRIFMT PRIx64
385 #define TRACEFLAGSPRIuFMT PRIu64
386 
387 typedef struct BitAttributes
388   {
389   TimeType  shift;
390   TraceFlagsType flags;
391   } BitAttributes;
392 
393 
394 #ifdef WAVE_USE_STRUCT_PACKING
395 #pragma pack(push)
396 #pragma pack(1)
397 #endif
398 
399 typedef struct Bits
400   {
401     char    *name;		/* name of this vector of bits   */
402     int     nnbits;		/* number of bits in this vector */
403     baptr attribs;  		/* for keeping track of combined timeshifts and inversions (and for savefile) */
404 
405     nptr    nodes[];		/* C99 pointers to the bits (nodes)  */
406   } Bits;
407 
408 #ifdef WAVE_USE_STRUCT_PACKING
409 #pragma pack(pop)
410 #endif
411 
412 
413 #ifdef WAVE_USE_STRUCT_PACKING
414 #pragma pack(push)
415 #pragma pack(1)
416 #endif
417 
418 typedef struct BitVector
419   {
420     bvptr   transaction_cache;  /* for TR_TTRANSLATED traces */
421     bvptr   transaction_chain;	/* for TR_TTRANSLATED traces */
422     nptr    transaction_nd;	/* for TR_TTRANSLATED traces */
423 
424     char    *bvname;		/* name of this vector of bits           */
425     int     nbits;		/* number of bits in this vector         */
426     int     numregions;		/* number of regions that follow         */
427     bptr    bits;		/* pointer to Bits structs for save file */
428     vptr    vectors[];		/* C99 pointers to the vectors           */
429   } BitVector;
430 
431 #ifdef WAVE_USE_STRUCT_PACKING
432 #pragma pack(pop)
433 #endif
434 
435 
436 typedef struct
437   {
438     TimeType    first;		/* beginning time of trace */
439     TimeType    last;		/* end time of trace */
440     TimeType    start;		/* beginning time of trace on screen */
441     TimeType    end;		/* ending time of trace on screen */
442     TimeType    marker;
443     TimeType    prevmarker;	/* from last drawmarker()	        */
444     TimeType    resizemarker;   /* from last MaxSignalLength()          */
445     TimeType    resizemarker2;  /* from 2nd last MaxSignalLength()      */
446     TimeType    lmbcache;	/* initial marker pos                   */
447     TimeType    timecache;	/* to get around floating pt limitation */
448     TimeType    laststart;      /* caches last set value                */
449     TimeType    baseline;       /* baseline (center button) marker      */
450 
451     gdouble    	zoom;		/* current zoom  */
452     gdouble    	prevzoom;	/* for zoom undo */
453   } Times;
454 
455 typedef struct TraceEnt *Trptr;
456 
457 typedef struct
458   {
459     int      total;		/* total number of traces */
460     int      visible;		/* total number of (uncollapsed) traces */
461     Trptr    first;		/* ptr. to first trace in list */
462     Trptr    last;		/* end of list of traces */
463     Trptr    buffer;		/* cut/copy buffer of traces */
464     Trptr    bufferlast;	/* last element of bufferchain */
465     int      buffercount;	/* number of traces in buffer */
466 
467     Trptr    scroll_top;	/* for autoscrolling */
468     Trptr    scroll_bottom;
469     unsigned dirty : 1;		/* to notify Tcl that traces were added/deleted/moved */
470   } Traces;
471 
472 
473 typedef struct
474   {
475     Trptr    buffer;            /* cut/copy buffer of traces */
476     Trptr    bufferlast;        /* last element of bufferchain */
477     int      buffercount;       /* number of traces in buffer */
478   } TempBuffer;
479 
480 
481 typedef struct TraceEnt
482   {
483     Trptr    t_next;		/* doubly linked list of traces */
484     Trptr    t_prev;
485     Trptr    t_grp;             /* pointer to group I'm in */
486     Trptr    t_match;           /* If group begin pointer to group end and visa versa */
487 
488     char     *name;		/* current name */
489     char     *name_full;   	/* full name */
490     char     *asciivalue;	/* value that marker points to */
491     char     *transaction_args; /* for TR_TTRANSLATED traces */
492     TimeType asciitime;		/* time this value corresponds with */
493     TimeType shift;		/* offset added to all entries in the trace */
494     TimeType shift_drag;	/* cached initial offset for CTRL+LMB drag on highlighted */
495 
496     double   d_minval, d_maxval; /* cached value for when auto scaling is turned off */
497     int      d_num_ext;		/* need to regen if differs from current in analog! */
498 
499     union
500       {
501 	nptr    nd;		/* what makes up this trace */
502 	bvptr   vec;
503       } n;
504 
505     TraceFlagsType flags;		/* see def below in TraceEntFlagBits */
506     TraceFlagsType cached_flags;	/* used for tcl for saving flags during cut and paste */
507 
508     int	     f_filter;		/* file filter */
509     int	     p_filter;		/* process filter */
510     int	     t_filter;		/* transaction process filter */
511     int      e_filter;          /* enum filter (from FST) */
512 
513     unsigned int t_color;	/* trace color index */
514     unsigned char t_fpdecshift; /* for fixed point decimal */
515 
516     unsigned is_cursor : 1;     /* set to mark a cursor trace */
517     unsigned is_alias : 1;	/* set when it's an alias (safe to free t->name then) */
518     unsigned is_depacked : 1;	/* set when it's been depacked from a compressed entry (safe to free t->name then) */
519     unsigned vector : 1;	/* 1 if bit vector, 0 if node */
520     unsigned shift_drag_valid : 1; /* qualifies shift_drag above */
521     unsigned interactive_vector_needs_regeneration : 1; /* for interactive VCDs */
522     unsigned minmax_valid : 1;	/* for d_minval, d_maxval */
523     unsigned is_sort_group : 1; /* only used for sorting purposes */
524     unsigned t_filter_converted : 1; /* used to mark that data conversion already occurred if t_filter != 0*/
525   } TraceEnt;
526 
527 
528 enum TraceEntFlagBits
529 { TR_HIGHLIGHT_B, TR_HEX_B, TR_DEC_B, TR_BIN_B,
530   TR_OCT_B, TR_RJUSTIFY_B, TR_INVERT_B, TR_REVERSE_B,
531   TR_EXCLUDE_B, TR_BLANK_B, TR_SIGNED_B, TR_ASCII_B,
532   TR_COLLAPSED_B, TR_FTRANSLATED_B, TR_PTRANSLATED_B, TR_ANALOG_STEP_B,
533   TR_ANALOG_INTERPOLATED_B, TR_ANALOG_BLANK_STRETCH_B, TR_REAL_B, TR_ANALOG_FULLSCALE_B,
534   TR_ZEROFILL_B, TR_ONEFILL_B, TR_CLOSED_B, TR_GRP_BEGIN_B,
535   TR_GRP_END_B,
536   TR_BINGRAY_B, TR_GRAYBIN_B,
537   TR_REAL2BITS_B, TR_TTRANSLATED_B,
538   TR_POPCNT_B,
539   TR_FPDECSHIFT_B,
540   TR_TIME_B,
541   TR_ENUM_B,
542   TR_CURSOR_B,
543   TR_FFO_B,
544 
545   TR_RSVD_B /* for use internally such as temporary caching of highlighting, not for use in traces */
546 };
547 
548 #define TR_HIGHLIGHT 		(UINT64_C(1)<<TR_HIGHLIGHT_B)
549 #define TR_HEX			(UINT64_C(1)<<TR_HEX_B)
550 #define TR_ASCII		(UINT64_C(1)<<TR_ASCII_B)
551 #define TR_DEC			(UINT64_C(1)<<TR_DEC_B)
552 #define TR_BIN			(UINT64_C(1)<<TR_BIN_B)
553 #define TR_OCT			(UINT64_C(1)<<TR_OCT_B)
554 #define TR_RJUSTIFY		(UINT64_C(1)<<TR_RJUSTIFY_B)
555 #define TR_INVERT		(UINT64_C(1)<<TR_INVERT_B)
556 #define TR_REVERSE		(UINT64_C(1)<<TR_REVERSE_B)
557 #define TR_EXCLUDE		(UINT64_C(1)<<TR_EXCLUDE_B)
558 #define TR_BLANK		(UINT64_C(1)<<TR_BLANK_B)
559 #define TR_SIGNED		(UINT64_C(1)<<TR_SIGNED_B)
560 #define TR_ANALOG_STEP 		(UINT64_C(1)<<TR_ANALOG_STEP_B)
561 #define TR_ANALOG_INTERPOLATED	(UINT64_C(1)<<TR_ANALOG_INTERPOLATED_B)
562 #define TR_ANALOG_BLANK_STRETCH	(UINT64_C(1)<<TR_ANALOG_BLANK_STRETCH_B)
563 #define TR_REAL			(UINT64_C(1)<<TR_REAL_B)
564 #define TR_ANALOG_FULLSCALE	(UINT64_C(1)<<TR_ANALOG_FULLSCALE_B)
565 #define TR_ZEROFILL		(UINT64_C(1)<<TR_ZEROFILL_B)
566 #define TR_ONEFILL		(UINT64_C(1)<<TR_ONEFILL_B)
567 #define TR_CLOSED		(UINT64_C(1)<<TR_CLOSED_B)
568 
569 #define TR_GRP_BEGIN		(UINT64_C(1)<<TR_GRP_BEGIN_B)
570 #define TR_GRP_END		(UINT64_C(1)<<TR_GRP_END_B)
571 #define TR_GRP_MASK		(TR_GRP_BEGIN|TR_GRP_END)
572 
573 #define TR_BINGRAY		(UINT64_C(1)<<TR_BINGRAY_B)
574 #define TR_GRAYBIN		(UINT64_C(1)<<TR_GRAYBIN_B)
575 #define TR_GRAYMASK		(TR_BINGRAY|TR_GRAYBIN)
576 
577 #define TR_REAL2BITS            (UINT64_C(1)<<TR_REAL2BITS_B)
578 
579 #define TR_NUMMASK	(TR_ASCII|TR_HEX|TR_DEC|TR_BIN|TR_OCT|TR_SIGNED|TR_REAL|TR_TIME|TR_ENUM)
580 #define TR_ATTRIBS      (TR_RJUSTIFY|TR_INVERT|TR_REVERSE|TR_EXCLUDE|TR_POPCNT|TR_FFO)
581 
582 #define TR_COLLAPSED	(UINT64_C(1)<<TR_COLLAPSED_B)
583 #define TR_ISCOLLAPSED	(TR_BLANK|TR_COLLAPSED)
584 
585 #define TR_FTRANSLATED	(UINT64_C(1)<<TR_FTRANSLATED_B)
586 #define TR_PTRANSLATED	(UINT64_C(1)<<TR_PTRANSLATED_B)
587 #define TR_TTRANSLATED  (UINT64_C(1)<<TR_TTRANSLATED_B)
588 
589 #define TR_POPCNT	(UINT64_C(1)<<TR_POPCNT_B)
590 #define TR_FPDECSHIFT   (UINT64_C(1)<<TR_FPDECSHIFT_B)
591 
592 #define TR_TIME         (UINT64_C(1)<<TR_TIME_B)
593 #define TR_ENUM         (UINT64_C(1)<<TR_ENUM_B)
594 
595 #define TR_CURSOR	(UINT64_C(1)<<TR_CURSOR_B)
596 #define TR_FFO          (UINT64_C(1)<<TR_FFO_B)
597 
598 #define TR_ANALOGMASK	(TR_ANALOG_STEP|TR_ANALOG_INTERPOLATED)
599 
600 #define TR_RSVD		(UINT64_C(1)<<TR_RSVD_B)
601 
602 Trptr GiveNextTrace(Trptr t);
603 Trptr GivePrevTrace(Trptr t);
604 int UpdateTracesVisible(void);
605 
606 void DisplayTraces(int val);
607 int AddNodeTraceReturn(nptr nd, char *aliasname, Trptr *tret);
608 int AddNode(nptr nd, char *aliasname);
609 int AddNodeUnroll(nptr nd, char *aliasname);
610 int AddVector(bvptr vec, char *aliasname);
611 int AddBlankTrace(char *commentname);
612 int InsertBlankTrace(char *comment, TraceFlagsType different_flags);
613 void RemoveNode(nptr n);
614 void RemoveTrace(Trptr t, int dofree);
615 void FreeTrace(Trptr t);
616 Trptr CutBuffer(void);
617 void FreeCutBuffer(void);
618 Trptr PasteBuffer(void);
619 Trptr PrependBuffer(void);
620 int TracesReorder(int mode);
621 int DeleteBuffer(void);
622 
623 void import_trace(nptr np);
624 
625 eptr ExpandNode(nptr n);
626 void DeleteNode(nptr n);
627 nptr ExtractNodeSingleBit(nptr n, int bit);
628 
629 
630 
631 /* hierarchy depths */
632 char *hier_extract(char *pnt, int levels);
633 
634 /* vector matching */
635 char *attempt_vecmatch(char *s1, char *s2);
636 
637 void updateTraceGroup(Trptr t);
638 int GetTraceNumber(Trptr t);
639 void EnsureGroupsMatch(void);
640 
641 #define IsSelected(t)   (t->flags&TR_HIGHLIGHT)
642 #define IsGroupBegin(t) (t->flags&TR_GRP_BEGIN)
643 #define IsGroupEnd(t)   (t->flags&TR_GRP_END)
644 #define IsClosed(t)     (t->flags&TR_CLOSED)
645 #define HasWave(t)      (!(t->flags&(TR_BLANK|TR_ANALOG_BLANK_STRETCH)))
646 #define CanAlias(t)     HasWave(t)
647 #define HasAlias(t)     (t->name_full&&HasWave(t))
648 #define IsCollapsed(t)  (t->flags&TR_COLLAPSED)
649 
650 unsigned IsShadowed(Trptr t);
651 char*    GetFullName(Trptr t, int *was_packed);
652 
653 void OpenTrace(Trptr t);
654 void CloseTrace(Trptr t);
655 void ClearTraces(void);
656 void ClearGroupTraces(Trptr t);
657 void MarkTraceCursor(Trptr t);
658 
659 char *varxt_fix(char *s);
660 
661 #endif
662