1 /*
2  * Copyright (c) Tony Bybell 1999-2010.
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 VCD_H
13 #define VCD_H
14 
15 #include <stdio.h>
16 #include <stdlib.h>
17 
18 #ifndef _MSC_VER
19 #include <unistd.h>
20 #endif
21 
22 #ifndef HAVE_FSEEKO
23 #define fseeko fseek
24 #define ftello ftell
25 #endif
26 
27 #include <setjmp.h>
28 #include <sys/types.h>
29 #ifdef HAVE_SYS_STAT_H
30 #include <sys/stat.h>
31 #endif
32 #include <fcntl.h>
33 #include <errno.h>
34 #include "symbol.h"
35 #include "wavealloca.h"
36 #include "debug.h"
37 #include "tree.h"
38 
39 #define VCD_SIZE_WARN (256)	/* number of MB size where converter warning message appears */
40 #define VCD_BSIZ 32768	/* size of getch() emulation buffer--this val should be ok */
41 #define VCD_INDEXSIZ  (8 * 1024 * 1024)
42 
43 #define vcd_exit(x) \
44 	if(GLOBALS->vcd_jmp_buf) \
45 		{ \
46 		splash_finalize(); \
47 		longjmp(*(GLOBALS->vcd_jmp_buf), x); \
48 		} \
49 		else \
50 		{ \
51 		exit(x); \
52 		}
53 
54 enum VCDName_ByteSubstitutions { VCDNAM_NULL=0,
55 #ifdef WAVE_HIERFIX
56 VCDNAM_HIERSORT,
57 #endif
58 VCDNAM_ESCAPE };
59 
60 /* fix for contrib/rtlbrowse */
61 #ifndef VLEX_DEFINES_H
62 enum VarTypes { V_EVENT, V_PARAMETER,
63                 V_INTEGER, V_REAL, V_REAL_PARAMETER=V_REAL, V_REALTIME=V_REAL, V_SHORTREAL=V_REAL, V_REG, V_SUPPLY0,
64                 V_SUPPLY1, V_TIME, V_TRI, V_TRIAND, V_TRIOR,
65                 V_TRIREG, V_TRI0, V_TRI1, V_WAND, V_WIRE, V_WOR, V_PORT, V_IN=V_PORT, V_OUT=V_PORT, V_INOUT=V_PORT,
66 		V_BIT, V_LOGIC, V_INT, V_SHORTINT, V_LONGINT, V_BYTE, V_ENUM,
67 		V_STRINGTYPE,
68                 V_END, V_LB, V_COLON, V_RB, V_STRING
69 };
70 #endif
71 
72 /* for vcd_recoder.c */
73 enum FastloadState  { VCD_FSL_NONE, VCD_FSL_WRITE, VCD_FSL_READ };
74 
75 TimeType vcd_main(char *fname);
76 TimeType vcd_recoder_main(char *fname);
77 
78 TimeType vcd_partial_main(char *fname);
79 void vcd_partial_mark_and_sweep(int mandclear);
80 void kick_partial_vcd(void);
81 
82 
83 struct sym_chain
84 {
85 struct sym_chain *next;
86 struct symbol *val;
87 };
88 
89 struct slist
90 {
91 struct slist *next;
92 char *str;
93 struct tree *mod_tree_parent;
94 int len;
95 };
96 
97 
98 #ifdef WAVE_USE_STRUCT_PACKING
99 #pragma pack(push)
100 #pragma pack(1)
101 #endif
102 
103 struct vcdsymbol
104 {
105 struct vcdsymbol *root, *chain;
106 struct symbol *sym_chain;
107 
108 struct vcdsymbol *next;
109 char *name;
110 char *id;
111 char *value;
112 struct Node **narray;
113 hptr *tr_array;   /* points to synthesized trailers (which can move) */
114 hptr *app_array;   /* points to hptr to append to (which can move) */
115 
116 unsigned int nid;
117 int msi, lsi;
118 int size;
119 
120 unsigned char vartype;
121 };
122 
123 #ifdef WAVE_USE_STRUCT_PACKING
124 #pragma pack(pop)
125 #endif
126 
127 
128 char *build_slisthier(void);
129 void append_vcd_slisthier(char *str);
130 
131 struct HistEnt *histent_calloc(void);
132 void strcpy_vcdalt(char *too, char *from, char delim);
133 int strcpy_delimfix(char *too, char *from);
134 void vcd_sortfacs(void);
135 void set_vcd_vartype(struct vcdsymbol *v, nptr n);
136 
137 void vcd_import_masked(void);
138 void vcd_set_fac_process_mask(nptr np);
139 void import_vcd_trace(nptr np);
140 
141 int vcd_keyword_code(const char *s, unsigned int len);
142 
143 #endif
144 
145