1 /*
2  * Copyright (c) 2001 Tony Bybell.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef L2V_ANALYZER_H
24 #define L2V_ANALYZER_H
25 
26 #include <stdio.h>
27 #include <stdlib.h>
28 #include <string.h>
29 #include <ctype.h>
30 #include <fcntl.h>
31 #include <errno.h>
32 #include <sys/types.h>
33 #include <sys/stat.h>
34 #include "v2l_debug.h"
35 #include "lxt_write.h"
36 
37 #ifndef _MSC_VER
38 #include <unistd.h>
39 #endif
40 
41 
42 #define SYMPRIME 500009
43 #define WAVE_DECOMPRESSOR "gzip -cd "	/* zcat alone doesn't cut it for AIX */
44 
45 
46 typedef struct Node	 *nptr;
47 typedef struct HistEnt	 *hptr;
48 
49 
50 typedef struct HistEnt
51 {
52 hptr next;	      /* next transition in history */
53 TimeType time;        /* time of transition */
54 TimeType previous_width; /* to avoid thrashing */
55 
56 union
57   {
58   unsigned char val;    /* value: "0XU1"[val] */
59   char *vector;		/* pointer to a whole vector */
60   } v;
61 
62 } HistEnt;
63 
64 
65 typedef struct ExtNode
66   {
67   int msi, lsi;
68   } ExtNode;
69 
70 struct Node
71   {
72     char     *nname;	/* ascii name of node */
73     ExtNode  *ext;	/* extension to node for vectors */
74     HistEnt  head;	/* first entry in transition history */
75     hptr     curr;      /* ptr. to current history entry */
76 
77     hptr     *harray;   /* fill this in when we make a trace.. contains  */
78 			/*  a ptr to an array of histents for bsearching */
79     int      numhist;	/* number of elements in the harray */
80     char     notdead;	/* indicates if this node gets a non-x value */
81     int      numtrans;  /* number of transitions */
82 
83     struct Node *substnode;  /* pointer to substitutions on buses */
84     struct Node *substhead;  /* pointer to substitution head (originator) on buses */
85   };
86 
87 
88 struct symbol
89 {
90 struct symbol *nextinaet;/* for aet node chaining */
91 struct HistEnt *h;	 /* points to previous one */
92 
93 struct symbol *next;	/* for hash chain */
94 char *name;
95 char selected;		/* for the clist object */
96 
97 struct Node *n;
98 
99 };
100 
101 
102 struct slist
103 {
104 struct slist *next;
105 char *str;
106 int len;
107 };
108 
109 
110 struct vcdsymbol
111 {
112 struct vcdsymbol *next;
113 struct lt_symbol *ltsym;
114 char *name;
115 char *id;
116 char *value;
117 struct queuedevent *ev; /* only if vartype==V_EVENT */
118 struct Node **narray;
119 unsigned int nid;
120 int msi, lsi;
121 int size;
122 unsigned char vartype;
123 };
124 
125 
126 struct queuedevent
127 {
128 struct queuedevent *next;
129 struct vcdsymbol *sym;
130 TimeType last_event_time;    /* make +1 == 0 if there's not an event there too */
131 };
132 
133 
134 struct symbol *symfind(char *);
135 struct symbol *symadd(char *, int);
136 int hash(char *s);
137 int sigcmp(char *, char *);
138 void quicksort(struct symbol **, int, int);
139 
140 TimeType vcd_main(char *fname, char *lxname, int dostats, int doclock, int dochange, int dodict, int linear);
141 void append_vcd_slisthier(char *str);
142 
143 #endif
144 
145