Merge branch 'master' into verilog-ams
[sverilog.git] / compiler.h
blob2b38802bef55bb812e146fcda11c2df4d1c59c48
1 #ifndef __compiler_H
2 #define __compiler_H
3 /*
4 * Copyright (c) 1999-2008 Stephen Williams (steve@icarus.com)
6 * This source code is free software; you can redistribute it
7 * and/or modify it in source code form under the terms of the GNU
8 * General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
10 * any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
22 # include <list>
23 # include <map>
24 # include "netlist.h"
25 # include "StringHeap.h"
28 * This defines constants and defaults for the compiler in general.
33 * The integer_width is the width of integer variables. This is also
34 * the minimum width of unsized integers when they are found in
35 * self-determined contexts.
37 extern unsigned integer_width;
39 /* The TIME_WIDTH is the width of time variables. */
40 #ifndef TIME_WIDTH
41 # define TIME_WIDTH 64
42 #endif
45 * When doing dynamic linking, we need a uniform way to identify the
46 * symbol. Some compilers put leading _, some trailing _. The
47 * configure script figures out which is the local convention and
48 * defines NEED_LU and NEED_TU as required.
50 #ifdef NEED_LU
51 #define LU "_"
52 #else
53 #define LU ""
54 #endif
56 #ifdef NEED_TU
57 #define TU "_"
58 #else
59 #define TU ""
60 #endif
64 * These are flags to enable various sorts of warnings. By default all
65 * the warnings are off, the -W<list> parameter arranges for each to be
66 * enabled.
69 /* Implicit definitions of wires. */
70 extern bool warn_implicit;
71 extern bool error_implicit;
73 /* inherit timescales across files. */
74 extern bool warn_timescale;
76 /* Warn about legal but questionable module port bindings. */
77 extern bool warn_portbinding;
79 /* Warn about structures that may have infinite loops. */
80 extern bool warn_inf_loop;
82 /* This is true if verbose output is requested. */
83 extern bool verbose_flag;
85 extern bool debug_scopes;
86 extern bool debug_eval_tree;
87 extern bool debug_elaborate;
88 extern bool debug_synth2;
89 extern bool debug_optimizer;
91 /* Path to a directory useful for finding subcomponents. */
92 extern const char*basedir;
94 /* This is an ordered list of library suffixes to search. */
95 extern list<const char*>library_suff;
96 extern int build_library_index(const char*path, bool key_case_sensitive);
98 /* This is the generation of Verilog that the compiler is asked to
99 support. Then there are also more detailed controls for more
100 specific language features. */
101 enum generation_t {
102 GN_VER1995 = 1,
103 GN_VER2001 = 2,
104 GN_VER2005 = 3,
105 GN_DEFAULT = 3
108 extern generation_t generation_flag;
110 /* If this flag is true, enable extended types support. */
111 extern bool gn_cadence_types_flag;
113 /* If this flag is true, enable miscellaneous extensions. */
114 extern bool gn_icarus_misc_flag;
116 /* If this flag is true, then elaborate specify blocks. If this flag
117 is false, then skip elaboration of specify behavior. */
118 extern bool gn_specify_blocks_flag;
120 /* If this flag is true, then support/elaborate Verilog-AMS. */
121 extern bool gn_verilog_ams_flag;
123 /* If this flag is false a warning is printed when the port declaration
124 is scalar and the net/register definition is vectored. */
125 extern bool gn_io_range_error_flag;
127 /* The bits of these GN_KEYWORDS_* constants define non-intersecting
128 sets of keywords. The compiler enables groups of keywords by setting
129 lexor_keyword_mask with the OR of the bits for the keywords to be
130 enabled. */
131 enum { GN_KEYWORDS_1364_1995 = 0x0001,
132 GN_KEYWORDS_1364_2001 = 0x0002,
133 GN_KEYWORDS_1364_2001_CONFIG = 0x0004,
134 GN_KEYWORDS_1364_2005 = 0x0008,
135 GN_KEYWORDS_VAMS_2_3 = 0x0010,
136 GN_KEYWORDS_ICARUS = 0x8000
138 extern int lexor_keyword_mask;
140 /* This is the string to use to invoke the preprocessor. */
141 extern char*ivlpp_string;
143 extern map<perm_string,unsigned> missing_modules;
145 /* Files that are library files are in this map. The lexor compares
146 file names as it processes `line directives, and if the file name
147 matches an entry in this table, it will turn on the
148 library_active_flag so that modules know that they are in a
149 library. */
150 extern map<perm_string,bool> library_file_map;
153 * the lex_strings are perm_strings made up of tokens from the source
154 * file. Identifiers are so likely to be used many times that it makes
155 * much sense to use a StringHeapLex to hold them.
157 extern StringHeapLex lex_strings;
158 extern StringHeap misc_strings;
161 * The filename_strings are perm_strings for file names. They are put
162 * into their own StringHeapLex because these paths are used a *lot*
163 * and this makes them more sure to hash together.
165 extern StringHeapLex filename_strings;
169 * system task/function listings.
172 * This table describes all the return values of various system
173 * functions. This table is used to elaborate expressions that are
174 * system function calls.
176 struct sfunc_return_type {
177 const char* name;
178 ivl_variable_type_t type;
179 unsigned wid;
180 int signed_flag;
183 extern const struct sfunc_return_type* lookup_sys_func(const char*name);
184 extern int load_sys_func_table(const char*path);
186 #endif