Add support for text macros with arguments.
[iverilog.git] / ivl_target.h
blob5d75dd1501670b6f57b7c01cf147db4d1f53f388
1 #ifndef __ivl_target_H
2 #define __ivl_target_H
3 /*
4 * Copyright (c) 2000-2004 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
21 #ifdef HAVE_CVS_IDENT
22 #ident "$Id: ivl_target.h,v 1.182 2007/04/02 01:12:34 steve Exp $"
23 #endif
25 # include <inttypes.h>
27 #ifdef __cplusplus
28 #define _BEGIN_DECL extern "C" {
29 #define _END_DECL }
30 #else
31 #define _BEGIN_DECL
32 #define _END_DECL
33 #endif
36 _BEGIN_DECL
39 * This header file describes the API for the loadable target
40 * module. The main program can load these modules and access the
41 * functions within the loaded module to implement the backend
42 * behavior.
44 * The interface is divided into two parts: the entry points within
45 * the core that are called by the module, and the entry points in
46 * the module that are called by the core. It is the latter that
47 * causes the module to be invoked in the first place, but most of the
48 * interesting information about the design is accessed through the
49 * various access functions that the modules calls into the core.
54 * In order to grab onto data in the design, the core passes cookies
55 * to the various functions of the module. These cookies can in turn
56 * be passed to access functions in the core to get more detailed
57 * information.
59 * The following typedefs list the various cookies that may be passed
60 * around.
62 * ivl_array_t
63 * This object represent an array that can be a memory or a net
64 * array. (They are the same from the perspective of ivl_target.h.)
66 * ivl_design_t
67 * This object represents the entire elaborated design. Various
68 * global properties and methods are available from this.
70 * ivl_event_t
71 * This object represents an event node. An event node stands for
72 * named events written explicitly in the Verilog, and net events
73 * that are implicit when @ statements are used.
75 * ivl_expr_t
76 * This object represents a node of an expression. If the
77 * expression has sub-expressions, they can be accessed from
78 * various method described below. The ivl_expr_type method in
79 * particular gets the type of the node in the form of an
80 * ivl_expr_type_t enumeration value.
82 * Objects of this type represent expressions in
83 * processes. Structural expressions are instead treated as logic
84 * gates.
86 * ivl_lpm_t
87 * This object is the base class for all the various LPM type
88 * device nodes. This object carries a few base properties
89 * (including a type) including a handle to the specific type.
91 * ivl_net_logic_t
92 * This object represents various built in logic devices. In fact,
93 * this includes just about every directional device that has a
94 * single output, including logic gates and nmos, pmos and cmos
95 * devices. There is also the occasional Icarus Verilog creation.
96 * What is common about these devices is that they are
97 * bitwise. That is, when fed a vector, they produce a vector
98 * result where each bit of the output is made only from the same
99 * bits in the vector inputs.
101 * ivl_nexus_t
102 * Structural links within an elaborated design are connected
103 * together at each bit. The connection point is a nexus, so pins
104 * of devices refer to an ivl_nexus_t. Furthermore, from a nexus
105 * there are backward references to all the device pins that point
106 * to it.
108 * ivl_parameter_t
109 * Scopes have zero or more parameter objects that represent
110 * parameters that the source defined. The parameter has a value
111 * that is fully elaborated, with defparams and other parameter
112 * overrides taken care of.
114 * ivl_process_t
115 * A Verilog process is represented by one of these. A process may
116 * be an "initial" or an "always" process. These come from initial
117 * or always statements from the Verilog source.
119 * ivl_scope_t
120 * Elaborated scopes within a design are represented by this
121 * type. Objects of this type also act as containers for scoped
122 * objects such as signals.
124 * ivl_statement_t
125 * Statements within processes are represented by one of these. The
126 * ivl_process_t object holds one of these, but a statement may in
127 * turn contain other statements.
129 * -- A Note About Bit Sets --
130 * Some objects hold a value as an array of bits. In these cases there
131 * is some method that retrieves the width of the value and another
132 * that returns a "char*". The latter is a pointer to the least
133 * significant bit value. Bit values are represented by the characters
134 * '0', '1', 'x' and 'z'. Strengths are stored elsewhere.
136 * -- A Note About Names --
137 * The names of objects are complete, hierarchical names. That is,
138 * they include the instance name of the module that contains them.
140 * basenames are the name of the object without the containing
141 * scope. These names are unique within a scope, but not necessarily
142 * throughout the design.
144 typedef struct ivl_array_s *ivl_array_t;
145 typedef struct ivl_delaypath_s*ivl_delaypath_t;
146 typedef struct ivl_design_s *ivl_design_t;
147 typedef struct ivl_event_s *ivl_event_t;
148 typedef struct ivl_expr_s *ivl_expr_t;
149 typedef struct ivl_lpm_s *ivl_lpm_t;
150 typedef struct ivl_lval_s *ivl_lval_t;
151 typedef struct ivl_net_const_s*ivl_net_const_t;
152 typedef struct ivl_net_logic_s*ivl_net_logic_t;
153 typedef struct ivl_udp_s *ivl_udp_t;
154 typedef struct ivl_net_probe_s*ivl_net_probe_t;
155 typedef struct ivl_nexus_s *ivl_nexus_t;
156 typedef struct ivl_nexus_ptr_s*ivl_nexus_ptr_t;
157 typedef struct ivl_parameter_s*ivl_parameter_t;
158 typedef struct ivl_process_s *ivl_process_t;
159 typedef struct ivl_scope_s *ivl_scope_t;
160 typedef struct ivl_signal_s *ivl_signal_t;
161 typedef struct ivl_memory_s *ivl_memory_t; /* DEPRECATED */
162 typedef struct ivl_statement_s*ivl_statement_t;
165 * These are types that are defined as enumerations. These have
166 * explicit values so that the binary API is a bit more resilient to
167 * changes and additions to the enumerations.
170 typedef enum ivl_drive_e {
171 IVL_DR_HiZ = 0,
172 IVL_DR_SMALL = 1,
173 IVL_DR_MEDIUM = 2,
174 IVL_DR_WEAK = 3,
175 IVL_DR_LARGE = 4,
176 IVL_DR_PULL = 5,
177 IVL_DR_STRONG = 6,
178 IVL_DR_SUPPLY = 7
179 } ivl_drive_t;
181 /* This is the type of an ivl_expr_t object. The explicit numbers
182 allow additions to the enumeration without causing values to shift
183 and incompatibilities to be introduced. */
184 typedef enum ivl_expr_type_e {
185 IVL_EX_NONE = 0,
186 IVL_EX_ARRAY = 18,
187 IVL_EX_BINARY = 2,
188 IVL_EX_CONCAT = 3,
189 IVL_EX_EVENT = 17,
190 IVL_EX_MEMORY = 4,
191 IVL_EX_NUMBER = 5,
192 IVL_EX_SCOPE = 6,
193 IVL_EX_SELECT = 7,
194 IVL_EX_SFUNC = 8,
195 IVL_EX_SIGNAL = 9,
196 IVL_EX_STRING = 10,
197 IVL_EX_TERNARY = 11,
198 IVL_EX_UFUNC = 12,
199 IVL_EX_ULONG = 13,
200 IVL_EX_UNARY = 14,
201 IVL_EX_REALNUM = 16
202 } ivl_expr_type_t;
204 /* This is the type code for an ivl_net_logic_t object. */
205 typedef enum ivl_logic_e {
206 IVL_LO_NONE = 0,
207 IVL_LO_AND = 1,
208 IVL_LO_BUF = 2,
209 IVL_LO_BUFIF0 = 3,
210 IVL_LO_BUFIF1 = 4,
211 IVL_LO_BUFZ = 5,
212 IVL_LO_CMOS = 22,
213 IVL_LO_NAND = 6,
214 IVL_LO_NMOS = 7,
215 IVL_LO_NOR = 8,
216 IVL_LO_NOT = 9,
217 IVL_LO_NOTIF0 = 10,
218 IVL_LO_NOTIF1 = 11,
219 IVL_LO_OR = 12,
220 IVL_LO_PULLDOWN = 13,
221 IVL_LO_PULLUP = 14,
222 IVL_LO_RCMOS = 23,
223 IVL_LO_RNMOS = 15,
224 IVL_LO_RPMOS = 16,
225 IVL_LO_PMOS = 17,
226 IVL_LO_XNOR = 18,
227 IVL_LO_XOR = 19,
229 IVL_LO_UDP = 21
230 } ivl_logic_t;
232 /* This is the type of an LPM object. */
233 typedef enum ivl_lpm_type_e {
234 IVL_LPM_ADD = 0,
235 IVL_LPM_ARRAY = 30,
236 IVL_LPM_CONCAT = 16,
237 IVL_LPM_CMP_EEQ= 18, /* Case EQ (===) */
238 IVL_LPM_CMP_EQ = 10,
239 IVL_LPM_CMP_GE = 1,
240 IVL_LPM_CMP_GT = 2,
241 IVL_LPM_CMP_NE = 11,
242 IVL_LPM_CMP_NEE= 19, /* Case NE (!==) */
243 IVL_LPM_DIVIDE = 12,
244 IVL_LPM_FF = 3,
245 IVL_LPM_MOD = 13,
246 IVL_LPM_MULT = 4,
247 IVL_LPM_MUX = 5,
248 IVL_LPM_PART_BI= 28, /* part select: bi-directional (part on 0) */
249 IVL_LPM_PART_VP= 15, /* part select: vector to part */
250 IVL_LPM_PART_PV= 17, /* part select: part written to vector */
251 IVL_LPM_RE_AND = 20,
252 IVL_LPM_RE_NAND= 21,
253 IVL_LPM_RE_NOR = 22,
254 IVL_LPM_RE_OR = 23,
255 IVL_LPM_RE_XNOR= 24,
256 IVL_LPM_RE_XOR = 25,
257 IVL_LPM_REPEAT = 26,
258 IVL_LPM_SFUNC = 29,
259 IVL_LPM_SHIFTL = 6,
260 IVL_LPM_SHIFTR = 7,
261 IVL_LPM_SIGN_EXT=27,
262 IVL_LPM_SUB = 8,
263 /* IVL_LPM_RAM = 9, / obsolete */
264 IVL_LPM_UFUNC = 14
265 } ivl_lpm_type_t;
267 /* The path edge type is the edge type used to select a specific
268 delay. */
269 typedef enum ivl_path_edge_e {
270 IVL_PE_01 = 0, IVL_PE_10, IVL_PE_0z,
271 IVL_PE_z1, IVL_PE_1z, IVL_PE_z0,
272 IVL_PE_0x, IVL_PE_x1, IVL_PE_1x,
273 IVL_PE_x0, IVL_PE_xz, IVL_PE_zx,
274 IVL_PE_COUNT
275 } ivl_path_edge_t;
277 /* Processes are initial or always blocks with a statement. This is
278 the type of the ivl_process_t object. */
279 typedef enum ivl_process_type_e {
280 IVL_PR_INITIAL = 0,
281 IVL_PR_ALWAYS = 1
282 } ivl_process_type_t;
284 /* These are the sorts of reasons a scope may come to be. These types
285 are properties of ivl_scope_t objects. */
286 typedef enum ivl_scope_type_e {
287 IVL_SCT_MODULE = 0,
288 IVL_SCT_FUNCTION= 1,
289 IVL_SCT_TASK = 2,
290 IVL_SCT_BEGIN = 3,
291 IVL_SCT_FORK = 4,
292 IVL_SCT_GENERATE= 5
293 } ivl_scope_type_t;
295 /* Signals (ivl_signal_t) that are ports into the scope that contains
296 them have a port type. Otherwise, they are port IVL_SIP_NONE. */
297 typedef enum ivl_signal_port_e {
298 IVL_SIP_NONE = 0,
299 IVL_SIP_INPUT = 1,
300 IVL_SIP_OUTPUT= 2,
301 IVL_SIP_INOUT = 3
302 } ivl_signal_port_t;
304 /* This is the type code for an ivl_signal_t object. Implicit types
305 are resolved by the core compiler, and integers are converted into
306 signed registers. */
307 typedef enum ivl_signal_type_e {
308 IVL_SIT_NONE = 0,
309 IVL_SIT_REG = 1,
310 IVL_SIT_TRI = 4,
311 IVL_SIT_TRI0 = 5,
312 IVL_SIT_TRI1 = 6,
313 IVL_SIT_TRIAND = 7,
314 IVL_SIT_TRIOR = 8
315 } ivl_signal_type_t;
317 /* This is the type code for ivl_statement_t objects. */
318 typedef enum ivl_statement_type_e {
319 IVL_ST_NONE = 0,
320 IVL_ST_NOOP = 1,
321 IVL_ST_ASSIGN = 2,
322 IVL_ST_ASSIGN_NB = 3,
323 IVL_ST_BLOCK = 4,
324 IVL_ST_CASE = 5,
325 IVL_ST_CASER = 24, /* Case statement with real expressions. */
326 IVL_ST_CASEX = 6,
327 IVL_ST_CASEZ = 7,
328 IVL_ST_CASSIGN = 8,
329 IVL_ST_CONDIT = 9,
330 IVL_ST_DEASSIGN = 10,
331 IVL_ST_DELAY = 11,
332 IVL_ST_DELAYX = 12,
333 IVL_ST_DISABLE = 13,
334 IVL_ST_FORCE = 14,
335 IVL_ST_FOREVER = 15,
336 IVL_ST_FORK = 16,
337 IVL_ST_RELEASE = 17,
338 IVL_ST_REPEAT = 18,
339 IVL_ST_STASK = 19,
340 IVL_ST_TRIGGER = 20,
341 IVL_ST_UTASK = 21,
342 IVL_ST_WAIT = 22,
343 IVL_ST_WHILE = 23
344 } ivl_statement_type_t;
346 /* This is the type of a variable, and also used as the type for an
347 expression. */
348 typedef enum ivl_variable_type_e {
349 IVL_VT_VOID = 0, /* Not used */
350 IVL_VT_NO_TYPE = 1, /* Place holder for missing/unknown type. */
351 IVL_VT_REAL = 2,
352 IVL_VT_BOOL = 3,
353 IVL_VT_LOGIC = 4,
354 IVL_VT_VECTOR = IVL_VT_LOGIC /* For compatibility */
355 } ivl_variable_type_t;
357 /* This is the type of the function to apply to a process. */
358 typedef int (*ivl_process_f)(ivl_process_t net, void*cd);
360 /* This is the type of a function to apply to a scope. The ivl_scope_t
361 parameter is the scope, and the cd parameter is client data that
362 the user passes to the scanner. */
363 typedef int (ivl_scope_f)(ivl_scope_t net, void*cd);
365 /* Attributes, which can be attached to various object types, have
366 this form. */
367 typedef enum ivl_attribute_type_e {
368 IVL_ATT_VOID = 0,
369 IVL_ATT_STR,
370 IVL_ATT_NUM
371 } ivl_attribute_type_t;
373 struct ivl_attribute_s {
374 const char*key;
375 ivl_attribute_type_t type;
376 union val_ {
377 const char*str;
378 long num;
379 } val;
381 typedef const struct ivl_attribute_s*ivl_attribute_t;
383 /* DELAYPATH
384 * Delaypath objects represent delay paths called out by a specify
385 * block in the verilog source file. The destination signal references
386 * the path object, which in turn points to the source for the path.
388 * ivl_path_scope
389 * This returns the scope of the delay path. This scope corresponds
390 * to the scope of the specify-block that led to this path.
392 * ivl_path_source
393 * This returns the nexus that is the source end of the delay
394 * path. Transitions on the source are the start of the delay time
395 * for this path.
397 * ivl_path_condit
398 * This returns the nexus that tracks the condition for the
399 * delay. If the delay path is unconditional, this returns nil.
401 * ivl_path_srouce_posedge
402 * ivl_path_source_negedge
403 * These functions return true if the source is edge sensitive.
405 extern ivl_scope_t ivl_path_scope(ivl_delaypath_t obj);
406 extern ivl_nexus_t ivl_path_source(ivl_delaypath_t obj);
407 extern uint64_t ivl_path_delay(ivl_delaypath_t obj, ivl_path_edge_t pt);
408 extern ivl_nexus_t ivl_path_condit(ivl_delaypath_t obj);
410 extern int ivl_path_source_posedge(ivl_delaypath_t obj);
411 extern int ivl_path_source_negedge(ivl_delaypath_t obj);
413 /* DESIGN
414 * When handed a design (ivl_design_t) there are a few things that you
415 * can do with it. The Verilog program has one design that carries the
416 * entire program. Use the design methods to iterate over the elements
417 * of the design.
419 * ivl_design_flag
420 * This function returns the string value of a named flag. Flags
421 * come from the "-fkey=value" options to the iverilog command and
422 * are stored in a map for this function. Given the key, this
423 * function returns the value.
425 * The special key "-o" is the argument to the -o flag of the
426 * command line (or the default if the -o flag is not used) and is
427 * generally how the target learns the name of the output file.
429 * ivl_design_process
430 * This function scans the processes (threads) in the design. It
431 * calls the user supplied function on each of the processes until
432 * one of the functors returns non-0 or all the processes are
433 * scanned. This function will return 0, or the non-zero value that
434 * was returned from the last scanned process.
436 * ivl_design_root (ANACHRONISM)
437 * A design has a root named scope that is an instance of the top
438 * level module in the design. This is a hook for naming the
439 * design, or for starting the scope scan.
441 * ivl_design_roots
442 * A design has some number of root scopes. These are the starting
443 * points for structural elaboration. This function returns to the
444 * caller a pointer to an ivl_scope_t array, and the size of the
445 * array.
447 * ivl_design_time_precision
448 * A design as a time precision. This is the size in seconds (a
449 * signed power of 10) of a simulation tick.
452 extern const char* ivl_design_flag(ivl_design_t des, const char*key);
453 extern int ivl_design_process(ivl_design_t des,
454 ivl_process_f fun, void*cd);
455 extern ivl_scope_t ivl_design_root(ivl_design_t des);
456 extern void ivl_design_roots(ivl_design_t des,
457 ivl_scope_t **scopes,
458 unsigned int *nscopes);
459 extern int ivl_design_time_precision(ivl_design_t des);
461 extern unsigned ivl_design_consts(ivl_design_t des);
462 extern ivl_net_const_t ivl_design_const(ivl_design_t, unsigned idx);
464 /* LITERAL CONSTANTS
465 * Literal constants are nodes with no input and a single constant
466 * output. The form of the output depends on the type of the node.
467 * The output is an array of 4-value bits, using a single char
468 * value for each bit. The bits of the vector are in canonical (lsb
469 * first) order for the width of the constant.
471 * ivl_const_type
472 * The is the type of the node.
474 * ivl_const_bits
475 * This returns a pointer to an array of conststant characters,
476 * each byte a '0', '1', 'x' or 'z'. The array is *not* nul
477 * terminated.
479 * ivl_const_nex
480 * Return the ivl_nexus_t of the output for the constant.
482 * ivl_const_signed
483 * Return true (!0) if the constant is a signed value, 0 otherwise.
485 * ivl_const_width
486 * Return the width, in logical bits, of the constant.
488 * SEMANTIC NOTES
490 * The const_type of the literal constant must match the
491 * ivl_signal_data_type if the signals that share the nexus of this
492 * node. The compiler makes sure it is so, converting constant values
493 * as needed.
495 * - IVL_VT_LOGIC
497 * - IVL_VT_REAL
498 * Real valued constants have a width of 1. The value emitted to the
499 * output is ivl_const_real.
501 extern ivl_variable_type_t ivl_const_type(ivl_net_const_t net);
502 extern const char* ivl_const_bits(ivl_net_const_t net);
503 extern ivl_nexus_t ivl_const_nex(ivl_net_const_t net);
504 extern int ivl_const_signed(ivl_net_const_t net);
505 extern unsigned ivl_const_width(ivl_net_const_t net);
506 extern double ivl_const_real(ivl_net_const_t net);
508 /* extern ivl_nexus_t ivl_const_pin(ivl_net_const_t net, unsigned idx); */
509 /* extern unsigned ivl_const_pins(ivl_net_const_t net); */
511 /* EVENTS
513 * Events are a unification of named events and implicit events
514 * generated by the @ statements.
516 * FUNCTION SUMMARY
518 * ivl_event_name (Obsolete)
519 * ivl_event_basename
520 * Return the name of the event. The basename is the name within
521 * the scope, as declared by the user or generated by elaboration.
523 * ivl_event_scope
524 * All events exist within a scope.
526 * SEMANTICS NOTES
528 * Named events (i.e. event objects declared by the Verilog
529 * declaration "event foo") are recognized by the fact that they have
530 * no edge sources. The name of the event as given in the Verilog
531 * source is available from the ivl_event_basename function.
533 * Named events are referenced in trigger statements.
535 * Edge events are created implicitly by the @(...) Verilog syntax to
536 * watch for the correct type of edge for the functor being
537 * watched. The nodes to watch are collected into groups based on the
538 * type of edge to be watched for on that node. For example, nodes to
539 * be watched for positive edges are accessed via the ivl_event_npos
540 * and ivl_event_pos functions.
542 extern const char* ivl_event_name(ivl_event_t net);
543 extern const char* ivl_event_basename(ivl_event_t net);
544 extern ivl_scope_t ivl_event_scope(ivl_event_t net);
546 extern unsigned ivl_event_nany(ivl_event_t net);
547 extern ivl_nexus_t ivl_event_any(ivl_event_t net, unsigned idx);
549 extern unsigned ivl_event_nneg(ivl_event_t net);
550 extern ivl_nexus_t ivl_event_neg(ivl_event_t net, unsigned idx);
552 extern unsigned ivl_event_npos(ivl_event_t net);
553 extern ivl_nexus_t ivl_event_pos(ivl_event_t net, unsigned idx);
556 /* EXPRESSIONS
558 * These methods operate on expression objects from the
559 * design. Expressions mainly exist in behavioral code. The
560 * ivl_expr_type() function returns the type of the expression node,
561 * and the remaining functions access value bits of the expression.
563 * ivl_expr_signed
564 * This method returns true (!= 0) if the expression node
565 * represents a signed expression. It is possible for sub-
566 * expressions to be unsigned even if a node is signed, but the
567 * IVL core figures all this out for you. At any rate, this method
568 * can be applied to any expression node.
570 * ivl_expr_type
571 * Get the type of the expression node. Every expression node has a
572 * type, which can affect how some of the other expression methods
573 * operate on the node
575 * ivl_expr_value
576 * Get the data type of the expression node. This uses the variable
577 * type enum to express the type of the expression node.
579 * ivl_expr_width
580 * This method returns the bit width of the expression at this
581 * node. It can be applied to any expression node, and returns the
582 * *output* width of the expression node.
584 * ivl_expr_parameter
585 * This function returns the ivl_parameter_t object that represents
586 * this object, or 0 (nil) if it is not a parameter value. This
587 * function allows the code generator to detect the case where the
588 * expression is a parameter. This will normally only return a
589 * non-nil value for constants.
591 * ivl_expr_opcode
592 * IVL_EX_BINARY and IVL_EX_UNARY expression nodes include an
593 * opcode from this table:
594 * & -- AND
595 * A -- NAND (~&)
596 * X -- XNOR (~^)
597 * * -- Multiply
599 * SEMANTIC NOTES
601 * - IVL_EX_ARRAY
602 * This expression type is a special case of the IVL_EX_SIGNAL where
603 * the target is an array (ivl_signal_t with an array_count) but there
604 * is no index expression. This is used only in the special situation
605 * where the array is passed to a system task/function. The function
606 * ivl_expr_signal returns the ivl_signal_t of the array object, and
607 * from that all the properties of the array can be determined.
609 * - IVL_EX_BINARY
611 * - IVL_EX_SELECT
612 * This expression takes two operands, oper1 is the expression to
613 * select from, and oper2 is the selection base. The ivl_expr_width
614 * value is the width of the bit/part select. The ivl_expr_oper1 value
615 * is the base of a vector. The compiler has already figured out any
616 * conversion from signal units to vector units, so the result of
617 * ivl_expr_oper1 should range from 0 to ivl_expr_width().
619 * - IVL_EX_SIGNAL
620 * This expression references a signal vector. The ivl_expr_signal
621 * function gets a handle for the signal that is referenced. The
622 * signal may be an array (see the ivl_signal_array_count function)
623 * that is addressed by the expression returned by the ivl_expr_oper1
624 * function. This expression returns a *canonical* address. The core
625 * compiler already corrected the expression to account for index
626 * bases.
628 * The ivl_expr_width function returns the vector width of the signal
629 * word. The ivl_expr_value returns the data type of the word.
631 * Bit and part selects are not done here. The IVL_EX_SELECT
632 * expression does bit/part selects on the word read from the signal.
634 * - IVL_EX_STRING
635 * This expression refers to a string constant. The ivl_expr_string
636 * function returns a pointer to the first byte of the string. The
637 * compiler has translated it to a "vvp escaped string" which has
638 * quoting and escapes eliminated. The string may contain octal
639 * escapes (\<oct>) so that the string text returned by
640 * ivl_expr_string will only contain graphical characters. It is up to
641 * the target to change the escaped \NNN to the proper byte value when
642 * using this string. No other escape sequences will appear in the
643 * string. Quote (") and slash (\) characters will be delivered in
644 * \NNN form.
647 extern ivl_expr_type_t ivl_expr_type(ivl_expr_t net);
648 extern ivl_variable_type_t ivl_expr_value(ivl_expr_t net);
650 /* IVL_EX_NUMBER */
651 extern const char* ivl_expr_bits(ivl_expr_t net);
652 /* IVL_EX_UFUNC */
653 extern ivl_scope_t ivl_expr_def(ivl_expr_t net);
654 /* IVL_EX_REALNUM */
655 extern double ivl_expr_dvalue(ivl_expr_t net);
656 /* IVL_EX_SIGNAL, IVL_EX_SFUNC, IVL_EX_VARIABLE */
657 extern const char* ivl_expr_name(ivl_expr_t net);
658 /* IVL_EX_BINARY IVL_EX_UNARY */
659 extern char ivl_expr_opcode(ivl_expr_t net);
660 /* IVL_EX_BINARY IVL_EX_UNARY, IVL_EX_MEMORY IVL_EX_TERNARY */
661 extern ivl_expr_t ivl_expr_oper1(ivl_expr_t net);
662 /* IVL_EX_BINARY IVL_EX_TERNARY */
663 extern ivl_expr_t ivl_expr_oper2(ivl_expr_t net);
664 /* IVL_EX_TERNARY */
665 extern ivl_expr_t ivl_expr_oper3(ivl_expr_t net);
666 /* and expression */
667 extern ivl_parameter_t ivl_expr_parameter(ivl_expr_t net);
668 /* IVL_EX_CONCAT IVL_EX_UFUNC */
669 extern ivl_expr_t ivl_expr_parm(ivl_expr_t net, unsigned idx);
670 /* IVL_EX_CONCAT IVL_EX_SFUNC IVL_EX_UFUNC */
671 extern unsigned ivl_expr_parms(ivl_expr_t net);
672 /* IVL_EX_CONCAT */
673 extern unsigned ivl_expr_repeat(ivl_expr_t net);
674 /* IVL_EX_EVENT */
675 extern ivl_event_t ivl_expr_event(ivl_expr_t net);
676 /* IVL_EX_SCOPE */
677 extern ivl_scope_t ivl_expr_scope(ivl_expr_t net);
678 /* IVL_EX_SIGNAL */
679 extern ivl_signal_t ivl_expr_signal(ivl_expr_t net);
680 /* any expression */
681 extern int ivl_expr_signed(ivl_expr_t net);
682 /* IVL_EX_STRING */
683 extern const char* ivl_expr_string(ivl_expr_t net);
684 /* IVL_EX_ULONG */
685 extern unsigned long ivl_expr_uvalue(ivl_expr_t net);
686 /* any expression */
687 extern unsigned ivl_expr_width(ivl_expr_t net);
691 /* LOGIC
692 * These types and functions support manipulation of logic gates. The
693 * ivl_logic_t enumeration identifies the various kinds of gates that
694 * the ivl_net_logic_t can represent. The various functions then
695 * provide access to the bits of information for a given logic device.
697 * The ivl_net_logic_t nodes are bit-slice devices. That means that
698 * the device may have width (and therefore processes vectors) but
699 * each bit slice of the width is independent.
701 * ivl_logic_type
702 * This method returns the type of logic gate that the node
703 * represents. The logic type implies the meaning of the various pins.
705 * ivl_logic_name (obsolete)
706 * This method returns the complete name of the logic gate. Every
707 * gate has a complete name (that includes the scope) even if the
708 * Verilog source doesn't include one. The compiler will choose one
709 * if necessary.
711 * ivl_logic_basename
712 * This is the name of the gate without the scope part.
714 * ivl_logic_scope
715 * This is the scope that directly contains the logic device.
717 * ivl_logic_pins
718 * ivl_logic_pin
719 * Return the nexus for the pin. If two pins are connected
720 * together, then these values are the same. Use the nexus
721 * functions to find other pins that are connected to this nexus.
723 * ivl_logic_width
724 * This returns the width of the logic array. This does not affect
725 * the number of pins, but implies the width of the vector at each
726 * pin.
728 * ivl_logic_delay
729 * Logic devices have a delay for each transition (0, 1 and Z).
731 * ivl_logic_attr (obsolete)
732 * Return the value of a specific attribute, given the key name as
733 * a string. If the key is not defined, then return 0 (null).
735 * ivl_logic_attr_cnt
736 * ivl_logic_attr_val
737 * These support iterating over logic attributes. The _cnt method
738 * returns the number of attributes attached to the gate, and the
739 * ivl_logic_attr_val returns the value of the attribute.
741 * SEMANTIC NOTES
742 * The ivl_logic_width applies to all the pins of a logic device. If a
743 * logic device has width, that means that it is actually an array of
744 * logic devices tha each process a bit slice of the
745 * inputs/output. That implies that the widths of all the inputs and
746 * the output must be identical.
748 * The ivl_logic_width and ivl_logic_pins are *not* related. A logic
749 * device has a number of pins that is the number of inputs to a logic
750 * array of identical gates, and the ivl_logic_width, is the width of
751 * the vector into each input pin and out of the output pin.
753 * The output pin is pin-0. The ivl_logic_driveX functions return the
754 * drive strengths for the output pin-0, and match the drive values
755 * stored in the ivl_nexus_ptr_t object for the pin.
757 * Logic devices have a logic propagation delay. The delay can be any
758 * expression, although the most common expression is an IVL_EX_NUMBER
759 * for a number value. The expression already includes scaling for the
760 * containing module, so the delay value is always taken to be in
761 * simulation clock ticks.
763 * If the delay is present, then ivl_logic_delay returns a non-nil
764 * object. If any of the three delays is present, then all three are
765 * present, even if they are all the same. The compiler will translate
766 * shorthands into a complete set of delay expressions.
768 * The ivl_logic_delay expression will always be an IVL_EX_NUMBER, an
769 * IVL_EX_ULONG, or an IVL_EX_SIGNAL. These expressions can easily be
770 * used in structural contexts. The compiler will take care of
771 * elaborating more complex expressions to nets.
773 * - IVL_LO_PULLUP/IVL_LO_PULLDOWN
774 * These devices are grouped as logic devices with zero inputs because
775 * the outputs have the same characteristics as other logic
776 * devices. They are special only in that they have zero inputs, and
777 * their drivers typically have strength other than strong.
779 * - IVL_LO_UDP
780 * User defined primitives (UDPs) are like any other logic devices, in
781 * that they are bit-slice devices. If they have a width, then they
782 * are repeated to accommodate that width, and that implies that the
783 * output and all the inputs must have the same width.
785 * The IVL_LO_UDP represents instantiations of UDP devices. The
786 * ivl_udp_t describes the implementation.
789 extern const char* ivl_logic_name(ivl_net_logic_t net);
790 extern const char* ivl_logic_basename(ivl_net_logic_t net);
791 extern ivl_scope_t ivl_logic_scope(ivl_net_logic_t net);
792 extern ivl_logic_t ivl_logic_type(ivl_net_logic_t net);
793 extern ivl_nexus_t ivl_logic_pin(ivl_net_logic_t net, unsigned pin);
794 extern unsigned ivl_logic_pins(ivl_net_logic_t net);
795 extern ivl_udp_t ivl_logic_udp(ivl_net_logic_t net);
796 extern ivl_expr_t ivl_logic_delay(ivl_net_logic_t net, unsigned transition);
797 extern ivl_drive_t ivl_logic_drive0(ivl_net_logic_t net);
798 extern ivl_drive_t ivl_logic_drive1(ivl_net_logic_t net);
799 extern unsigned ivl_logic_width(ivl_net_logic_t net);
801 /* DEPRECATED */
802 extern const char* ivl_logic_attr(ivl_net_logic_t net, const char*key);
804 extern unsigned ivl_logic_attr_cnt(ivl_net_logic_t net);
805 extern ivl_attribute_t ivl_logic_attr_val(ivl_net_logic_t net, unsigned idx);
807 /* UDP
808 * These methods allow access to the ivl_udp_t definition of a UDP.
809 * The UDP definition is accessed through the ivl_logic_udp method of
810 * an ivl_net_logic_t object.
812 * ivl_udp_name
813 * This returns the name of the definition of the primitive.
815 * ivl_udp_nin
816 * This is the number of inputs for the UDP definition.
818 * ivl_udp_rows
819 * ivl_udp_row
820 * These methods give access to the rows that define the table of
821 * the primitive.
823 * SEMANTIC NOTES
825 * - Combinational primitives
826 * These devices have no edge dependencies, and have no table entry
827 * for the current input value. These have ivl_udp_sequ return 0
828 * (false) and the length of each row is the number of inputs plus 1.
829 * The first N characters correspond to the N inputs of the
830 * device. The next character, the last character, is the output for
831 * that row.
833 * - Sequential primitives
834 * These devices allow edge transitions, and the rows are 1+N+1
835 * characters long. The first character is the current output, the
836 * next N characters the current input and the last character is the
837 * new output.
839 * The ivl_udp_init value is only valid if the device is
840 * sequential. It is the initial value for the output of the storage
841 * element.
844 extern int ivl_udp_sequ(ivl_udp_t net);
845 extern unsigned ivl_udp_nin(ivl_udp_t net);
846 extern unsigned ivl_udp_init(ivl_udp_t net);
847 extern const char* ivl_udp_row(ivl_udp_t net, unsigned idx);
848 extern unsigned ivl_udp_rows(ivl_udp_t net);
849 extern const char* ivl_udp_name(ivl_udp_t net);
852 /* LPM
853 * These functions support access to the properties of LPM
854 * devices. LPM devices are a variety of devices that handle more
855 * complex structural semantics. They are based on EIA LPM standard
856 * devices, but vary to suite the technical situation.
858 * These are the functions that apply to all LPM devices:
860 * ivl_lpm_name (Obsolete)
861 * ivl_lpm_basename
862 * Return the name of the device. The name is the name of the
863 * device with the scope part, and the basename is without the scope.
865 * ivl_lpm_scope
866 * LPM devices exist within a scope. Return the scope that contains
867 * this device.
869 * ivl_lpm_type
870 * Return the ivl_lpm_type_t of the specific LPM device.
872 * ivl_lpm_width
873 * Return the width of the LPM device. What this means depends on
874 * the LPM type, but it generally has to do with the width of the
875 * output data path.
878 * These functions apply to a subset of the LPM devices, or may have
879 * varying meaning depending on the device:
881 * ivl_lpm_base
882 * The IVL_LPM_PART objects use this value as the base (first bit)
883 * of the part select. The ivl_lpm_width is the size of the part.
885 * ivl_lpm_data
886 * Return the input data nexus for device types that have input
887 * vectors. The "idx" parameter selects which data input is selected.
889 * ivl_lpm_datab (ANACHRONISM)
890 * This is the same as ivl_lpm_data(net,1), in other words the
891 * second data input. Use the ivl_lpm_data method instead.
893 * ivl_lpm_q
894 * Return the output data nexus for device types that have a single
895 * output vector. This is most devices, it turns out.
897 * ivl_lpm_selects
898 * This is the size of the select input for a LPM_MUX device, or the
899 * address bus width of an LPM_RAM.
901 * ivl_lpm_signed
902 * Arithmetic LPM devices may be signed or unsigned if there is a
903 * distinction. For some devices this gives the signedness of the
904 * output, but not all devices.
906 * ivl_lpm_size
907 * In addition to a width, some devices have a size. The size is
908 * often the number of inputs per out, i.e., the number of inputs
909 * per bit for a MUX.
911 * SEMANTIC NOTES
913 * - Concatenation (IVL_LPM_CONCAT)
914 * These devices take vectors in and combine them to form a single
915 * output the width specified by ivl_lpm_width.
917 * The ivl_lpm_q nexus is the output from the concatenation.
919 * The ivl_lpm_data function returns the connections for the inputs to
920 * the concatentation. The ivl_lpm_size function returns the number of
921 * inputs help by the device.
923 * - Divide (IVL_LPM_DIVIDE)
924 * The divide operators take two inputs and generate an output. The
925 * ivl_lpm_width returns the width of the result. The width of the
926 * inputs are their own.
928 * - Multiply (IVL_LPM_MULT)
929 * The multiply takes two inputs and generates an output. Unlike other
930 * arithmetic nodes, the width only refers to the output. The inputs
931 * have independent widths, to reflect the arithmetic truth that the
932 * width of a general multiply is the sum of the widths of the
933 * inputs. In fact, the compiler doesn't assure that the widths of the
934 * inputs add up to the width of the output, but the possibility
935 * exists. It is *not* an error for the sum of the input widths to be
936 * more than the width of the output, although the possibility of
937 * overflow exists at run time.
939 * Multiply may be signed. If so, the output should be sign extended
940 * to fill in its result.
942 * - Part Select (IVL_LPM_PART_VP and IVL_LPM_PART_PV)
943 * There are two part select devices, one that extracts a part from a
944 * vector, and another that writes a part of a vector. The _VP is
945 * Vector-to-Part, and _PV is Part-to-Vector. The _VP form is meant to
946 * model part/bin selects in r-value expressions, where the _PV from
947 * is meant to model part selects in l-value nets.
949 * In both cases, ivl_lpm_data(0) is the input pin, and ivl_lpm_q is the
950 * output. In the case of the _VP device, the vector is input and the
951 * part is the output. In the case of the _PV device, the part is the
952 * input and the vector is the output.
954 * If the base of the part select is non-constant, then
955 * ivl_lpm_data(1) is non-nil and is the select, or base, address of
956 * the part. If this pin is nil, then the constant base is used
957 * instead.
959 * Also in both cases, the width of the device is the width of the
960 * part. In the _VP case, this is obvious as the output nexus has the
961 * part width. In the _PV case, this is a little less obvious, but
962 * still correct. The output being written to the wider vector is
963 * indeed the width of the part, even though it is written to a wider
964 * gate. The target will need to handle this case specially.
966 * - Bi-directional Part Select (IVL_LPM_PART_BI)
967 * This is not exactly a part select but a bi-directional partial link
968 * of two nexa with different widths. This is used to implement tran
969 * devices and inout ports in certain cases. The device width is the
970 * width of the part. The ivl_lpm_q is the part end, and the
971 * ivl_lpm_data(0) is the non-part end.
973 * - Comparisons (IVL_LPM_CMP_GT/GE/EQ/NE/EEQ/NEE)
974 * These devices have two inputs, available by the ivl_lpm_data()
975 * function, and one output available by the ivl_lpm_q function. The
976 * output width is always 1, but the ivl_lpm_width() returns the width
977 * of the inputs. Both inputs must have the same width.
979 * The CMP_GE and CMP_GT nodes may also be signed or unsigned, with
980 * the obvious implications. The widths are matched by the compiler
981 * (so the target need not worry about sign extension) but when doing
982 * magnitude compare, the signedness does matter. In any case, the
983 * result of the compare is always unsigned.
985 * - Mux Device (IVL_LPM_MUX)
986 * The MUX device has a q output, a select input, and a number of data
987 * inputs. The ivl_lpm_q output and the ivl_lpm_data inputs all have
988 * the width from the ivl_lpm_width() method. The Select input, from
989 * ivl_lpm_select, has the width ivl_lpm_selects().
991 * The ivl_lpm_data() method returns the inputs of the MUX device. The
992 * ivl_lpm_size() method returns the number of data inputs there
993 * are. All the data inputs have the same width, the width of the
994 * ivl_lpm_q output. The type of the device is devined from the
995 * inputs and the Q. All the types must be exactly the same.
997 * - D-FlipFlop (IVL_LPM_FF)
998 * This data is an edge sensitive register. The ivl_lpm_q output and
999 * single ivl_lpm_data input are the same with, ivl_lpm_width. This
1000 * device carries a vector like other LPM devices.
1002 * - Memory port (IVL_LPM_RAM) (deprecated in favor of IVL_LPM_ARRAY)
1003 * These are structural ports into a memory device. They represent
1004 * address/data ports of a memory device that the context can hook to
1005 * for read or write. Read devices have an ivl_lpm_q output port that
1006 * is the data being read.
1008 * The ivl_lpm_memory function returns the ivl_memory_t for the memory
1009 * that the port access. The ivl_lpm_width for the port then must
1010 * match the ivl_memory_width of the memory device.
1012 * Read or write, the ivl_lpm_select nexus is the address. The
1013 * ivl_lpm_selects function returns the vector width of the
1014 * address. The range of the address is always from 0 to the memory
1015 * size-1 -- the canonical form. It is up to the compiler to generate
1016 * offsets to correct for a range declaration.
1018 * Read ports use the ivl_lpm_q as the data output, and write ports
1019 * use the ivl_lpm_data(0) as the input. In either case the width of
1020 * the vector matches the width of the memory itself.
1022 * - Reduction operators (IVL_LPM_RE_*)
1023 * These devices have one input, a vector, and generate a single bit
1024 * result. The width from the ivl_lpm_width is the width of the input
1025 * vector.
1027 * - Repeat Node (IVL_LPM_REPEAT)
1028 * This node takes as input a single vector, and outputs a single
1029 * vector. The ivl_lpm_width if this node is the width of the *output*
1030 * vector. The ivl_lpm_size() returns the number of times the input is
1031 * repeated to get the desired width. The ivl core assures that the
1032 * input vector is exactly ivl_lpm_width() / ivl_lpm_size() bits.
1034 * - Sign Exend (IVL_LPM_SIGN_EXT)
1035 * This node takes a single input and generates a single output. The
1036 * input must be signed, and the output will be a vector sign extended
1037 * to the desired width. The ivl_lpm_width() value is the output
1038 * width, the input will be whatever it wants to be.
1040 * - Shifts (IVL_LPM_SHIFTL/SHIFTR)
1041 * This node takes two inputs, a vector and a shift distance. The
1042 * ivl_lpm_data(0) nexus is the vector input, and the ivl_lpm_data(1)
1043 * the shift distance. The vector input is the same width as the
1044 * output, but the distance has its own width.
1046 * The ivl_lpm_signed() flag means for IVL_LPM_SHIFTR that the right
1047 * shift is *signed*. For SHIFTL, then signed-ness is emaningless.
1049 * - System function call (IVL_LPM_SFUNC)
1050 * This device represents a netlist call to a system function. The
1051 * inputs to the device are passed to a system function, and the
1052 * result is sent via the output. The ivl_lpm_q function returns the
1053 * output nexus.
1055 * The ivl_lpm_size function returns the number of arguments, and the
1056 * ivl_lpm_data(net,N) returns the nexa for the argument.
1058 * The ivl_lpm_string(net) function returns the name of the system
1059 * function (i.e. "$display") that was found in the source code. The
1060 * compiler does little checking of that name.
1062 * - User Function Call (IVL_LPM_UFUNC)
1063 * This device is special as it represents a call to a user defined
1064 * function (behavioral code) within a netlist. The inputs to the
1065 * function are connected to the net, as is the output.
1067 * The function definition is associated with a scope, and the
1068 * ivl_lpm_define fuction returns the scope that is that definition.
1069 * See the ivl_scope_* fuctions for how to get at the actual
1070 * definition.
1072 * As with many LPM nodes, the ivl_lpm_q function returns the nexus
1073 * for the signal function return value. The width of this nexus must
1074 * exactly match the width of the device from ivl_lpm_width.
1076 * The ivl_lpm_data function retrives the nexa for all the input
1077 * ports. The ivl_lpm_size function returns the number of inputs for
1078 * the device, and the ivl_lpm_data() function index argument selects
1079 * the port to retrieve. Each port is sized independently.
1082 extern const char* ivl_lpm_name(ivl_lpm_t net); /* (Obsolete) */
1083 extern const char* ivl_lpm_basename(ivl_lpm_t net);
1084 extern ivl_scope_t ivl_lpm_scope(ivl_lpm_t net);
1085 extern int ivl_lpm_signed(ivl_lpm_t net);
1086 extern ivl_lpm_type_t ivl_lpm_type(ivl_lpm_t net);
1087 extern unsigned ivl_lpm_width(ivl_lpm_t net);
1089 /* IVL_LPM_FF */
1090 extern ivl_nexus_t ivl_lpm_async_clr(ivl_lpm_t net);
1091 extern ivl_nexus_t ivl_lpm_async_set(ivl_lpm_t net);
1092 extern ivl_expr_t ivl_lpm_aset_value(ivl_lpm_t net);
1093 extern ivl_nexus_t ivl_lpm_sync_clr(ivl_lpm_t net);
1094 extern ivl_nexus_t ivl_lpm_sync_set(ivl_lpm_t net);
1095 extern ivl_expr_t ivl_lpm_sset_value(ivl_lpm_t net);
1096 /* IVL_LPM_ARRAY */
1097 extern ivl_signal_t ivl_lpm_array(ivl_lpm_t net);
1098 /* IVL_LPM_PART */
1099 extern unsigned ivl_lpm_base(ivl_lpm_t net);
1100 /* IVL_LPM_FF */
1101 extern ivl_nexus_t ivl_lpm_clk(ivl_lpm_t net);
1102 /* IVL_LPM_UFUNC */
1103 extern ivl_scope_t ivl_lpm_define(ivl_lpm_t net);
1104 /* IVL_LPM_FF */
1105 extern ivl_nexus_t ivl_lpm_enable(ivl_lpm_t net);
1106 /* IVL_LPM_ADD IVL_LPM_CONCAT IVL_LPM_FF IVL_LPM_PART IVL_LPM_MULT
1107 IVL_LPM_MUX IVL_LPM_SHIFTL IVL_LPM_SHIFTR IVL_LPM_SUB
1108 IVL_LPM_UFUNC */
1109 extern ivl_nexus_t ivl_lpm_data(ivl_lpm_t net, unsigned idx);
1110 /* IVL_LPM_ADD IVL_LPM_MULT IVL_LPM_SUB */
1111 extern ivl_nexus_t ivl_lpm_datab(ivl_lpm_t net, unsigned idx);
1112 /* IVL_LPM_ADD IVL_LPM_FF IVL_LPM_MULT IVL_LPM_PART
1113 IVL_LPM_SUB IVL_LPM_UFUNC */
1114 extern ivl_nexus_t ivl_lpm_q(ivl_lpm_t net, unsigned idx);
1115 /* IVL_LPM_MUX */
1116 extern unsigned ivl_lpm_selects(ivl_lpm_t net);
1117 /* IVL_LPM_MUX */
1118 extern ivl_nexus_t ivl_lpm_select(ivl_lpm_t net);
1119 /* IVL_LPM_CONCAT IVL_LPM_MUX IVL_LPM_REPEAT IVL_LPM_UFUNC */
1120 extern unsigned ivl_lpm_size(ivl_lpm_t net);
1121 /* IVL_LPM_SFUNC */
1122 extern const char*ivl_lpm_string(ivl_lpm_t net);
1124 /* LVAL
1125 * The l-values of assignments are concatenation of ivl_lval_t
1126 * objects. Each lvi_lval_t object is an assignment to a var or a
1127 * memory, through a bit select, part select or word select.
1129 * Var lvals are things like assignments to a part select or a bit
1130 * select. Assignment to the whole variable is a special case of a
1131 * part select, as is a bit select with a constant expression.
1133 * ivl_lval_width
1134 * The width of a vector that this lval can receive. This accounts
1135 * for the local part selecting I might to in the lval object, as
1136 * well as the target object width.
1138 * ivl_lval_mux
1139 * If the l-value includes a bit select expression, this method
1140 * returns an ivl_expr_t that represents that
1141 * expression. Otherwise, it returns 0.
1143 * (Should this be combined with ivl_lval_idx? -Ed)
1145 * ivl_lval_mem (deprecated)
1146 * If the l-value is a memory, this method returns an
1147 * ivl_memory_t that represents that memory. Otherwise, it
1148 * returns 0.
1150 * ivl_lval_sig
1151 * If the l-value is a variable, this method returns the signal
1152 * object that is the target of the assign.
1154 * ivl_lval_part_off
1155 * The part select of the signal is based here. This is the
1156 * canonical index of bit-0 of the part select. The return value is
1157 * an ivl_expr_t. If the return value is nil, then take the offset
1158 * as zero. Otherwise, evaluate the expression to get the offset.
1160 * ivl_lval_idx
1161 * If the l-value is a memory, this method returns an
1162 * ivl_expr_t that represents the index expression. Otherwise, it
1163 * returns 0.
1165 * SEMANTIC NOTES
1166 * The ivl_lval_width is not necessarily the same as the width of the
1167 * signal or memory word it represents. It is the width of the vector
1168 * it receives and assigns. This may be less then the width of the
1169 * signal (or even 1) if only a part of the l-value signal is to be
1170 * assigned.
1172 * The ivl_lval_part_off is the canonical base of a part or
1173 * bit select.
1175 * - Memory words (Replace this with Array words below)
1176 * If the l-value is a memory word, the ivl_lval_mem function returns
1177 * a non-nil value. The ivl_lval_idx function will return an
1178 * expression that calculates an address for the memory. The compiler
1179 * will assure that the ivl_lval_width will exactly match the
1180 * ivl_memory_width of the memory word.
1182 * - Array words
1183 * If the l-value is an array, then ivl_lval_idx function will return
1184 * an expression that calculates the address of the array word. If
1185 * the referenced signal has more than one word, this expression must
1186 * be present. If the signal has exactly one word (it is not an array)
1187 * then the ivl_lval_idx exression must *not* be present.
1189 * For array words, the ivl_lval_width is the width of the word.
1192 extern unsigned ivl_lval_width(ivl_lval_t net);
1193 extern ivl_expr_t ivl_lval_mux(ivl_lval_t net); // XXXX Obsolete?
1194 extern ivl_expr_t ivl_lval_idx(ivl_lval_t net);
1195 extern ivl_expr_t ivl_lval_part_off(ivl_lval_t net);
1196 extern ivl_signal_t ivl_lval_sig(ivl_lval_t net);
1199 /* NEXUS
1200 * connections of signals and nodes is handled by single-bit
1201 * nexus. These functions manage the ivl_nexus_t object. They also
1202 * manage the ivl_nexus_ptr_t objects that are closely related to the
1203 * nexus.
1205 * ivl_nexus_name
1206 * Each nexus is given a name, typically derived from the signals
1207 * connected to it, but completely made up if need be. The name of
1208 * every nexus is unique.
1210 * ivl_nexus_ptrs
1211 * This function returns the number of pointers that are held by
1212 * the nexus. It should always return at least 1. The pointer
1213 * proper is accessed by index.
1215 * ivl_nexus_ptr
1216 * Return a nexus pointer given the nexus and an index.
1218 * ivl_nexus_set_private
1219 * ivl_nexus_get_private
1220 * The target module often needs to associate data with a nexus for
1221 * later use when the nexus is encountered associated with a
1222 * device. These methods allow the code generator to store to or
1223 * retrieve from a nexus a void* of private data. This pointer is
1224 * guaranteed to be 0 before the target module is invoked.
1226 * Once an ivl_nexus_ptr_t is selected by the ivl_nexus_ptr method,
1227 * the properties of the pointer can be accessed by the following
1228 * methods:
1230 * ivl_nexus_ptr_pin
1231 * This returns the pin number of the device where this nexus
1232 * points. It is the bit within the signal or logic device that is
1233 * connected to the nexus.
1235 * If the target is an LPM device, then this value is zero, and it
1236 * is up to the application to find the pin that refers to this
1237 * nexus. The problem is that LPM devices do not have a pinout per
1238 * se, the pins all have specific names.
1240 * ivl_nexus_ptr_con
1241 * If this is a pointer to a magic constant device, then this
1242 * returns the net_const object.
1244 * ivl_nexus_ptr_drive0
1245 * ivl_nexus_ptr_drive1
1246 * These are the 0 and 1 strength values for the devices. For most
1247 * devices, these values are fixed by the description in the
1248 * original source, with the default as IVL_DR_STRONG. For pins
1249 * that are input only, drive0 and drive1 are both IVL_DR_HiZ.
1251 * The strength of strength-aware devices (such as nmos devices)
1252 * does not really matter, as long at the output is not
1253 * IVL_DR_HiZ. Testing for HiZ drivers is how code generators
1254 * detect inputs.
1256 * ivl_nexus_ptr_log
1257 * If the target object is an ivl_net_logic_t, this method returns
1258 * the object. Otherwise, this method returns 0.
1260 * ivl_nexus_ptr_lpm
1261 * If the target object is an ivl_lpm_t, this method returns the
1262 * object. Otherwise, this method returns 0.
1264 * ivl_nexus_ptr_sig
1265 * If the target object is an ivl_signal_t, this method returns the
1266 * object. If the target is not a signal, this method returns 0.
1268 * SEMANTIC NOTES
1269 * All the device pins that connect to a nexus have the same
1270 * type. That means, for example, that vector pins have the same
1271 * width. The compiler will insure this is so.
1274 extern const char* ivl_nexus_name(ivl_nexus_t net);
1275 extern unsigned ivl_nexus_ptrs(ivl_nexus_t net);
1276 extern ivl_nexus_ptr_t ivl_nexus_ptr(ivl_nexus_t net, unsigned idx);
1278 extern void ivl_nexus_set_private(ivl_nexus_t net, void*data);
1279 extern void* ivl_nexus_get_private(ivl_nexus_t net);
1282 extern ivl_drive_t ivl_nexus_ptr_drive0(ivl_nexus_ptr_t net);
1283 extern ivl_drive_t ivl_nexus_ptr_drive1(ivl_nexus_ptr_t net);
1284 extern unsigned ivl_nexus_ptr_pin(ivl_nexus_ptr_t net);
1285 extern ivl_net_const_t ivl_nexus_ptr_con(ivl_nexus_ptr_t net);
1286 extern ivl_net_logic_t ivl_nexus_ptr_log(ivl_nexus_ptr_t net);
1287 extern ivl_lpm_t ivl_nexus_ptr_lpm(ivl_nexus_ptr_t net);
1288 extern ivl_signal_t ivl_nexus_ptr_sig(ivl_nexus_ptr_t net);
1290 /* PARAMETER
1291 * Parameters are named constants associated with a scope. The user
1292 * may set in the Verilog source the value of parameters, and that
1293 * leads to ivl_parameter_t objects contained in the ivl_scope_t
1294 * objects.
1296 * Parameters are essentially named constants. These constant values
1297 * can be accessed by looking at the scope (using ivl_scope_param) or
1298 * they can be discovered when they are used, via the
1299 * ivl_expr_parameter function. The fact that a constant has a name
1300 * (i.e. is a parameter) does not otherwise impose on the value or
1301 * interpretation of the constant expression so far as ivl_target is
1302 * concerned. The target may need this information, or may choose to
1303 * completely ignore it.
1305 * ivl_parameter_basename
1306 * return the name of the parameter.
1308 * ivl_parameter_scope
1309 * Return the scope of the parameter. The parameter name is only
1310 * unique within its scope.
1312 * ivl_parameter_expr
1313 * Return the value of the parameter. This should be a simple
1314 * constant expression, an IVL_EX_STRING or IVL_EX_NUMBER.
1316 extern const char* ivl_parameter_basename(ivl_parameter_t net);
1317 extern ivl_scope_t ivl_parameter_scope(ivl_parameter_t net);
1318 extern ivl_expr_t ivl_parameter_expr(ivl_parameter_t net);
1321 /* SCOPE
1322 * Scopes of various sort have these properties. Use these methods to
1323 * access them. Scopes come to exist in the elaborated design
1324 * generally when a module is instantiated, though they also come from
1325 * named blocks, tasks and functions.
1327 * - module instances (IVL_SCT_MODULE)
1328 * A module instance scope may contain events, logic gates, lpm
1329 * nodes, signals, and possibly children. The children are further
1330 * instances, or function/task scopes. Module instances do *not*
1331 * contain a definition.
1333 * - function scopes (IVL_SCT_FUNCTION)
1334 * These scopes represent functions. A function may not be a root,
1335 * so it is contained within a module instance scope. A function is
1336 * required to have a definition (in the form of a statement) and a
1337 * signal (IVL_SIG_REG) that is its return value.
1339 * A single function scope is created each time the module with the
1340 * definition is instantiated.
1343 * - task scopes (IVL_SCT_TASK)
1344 * [...]
1346 * ivl_scope_attr_cnt
1347 * ivl_scope_attr_val
1348 * A scope may have attributes attached to it. These functions
1349 * allow the target to access the attributes values.
1351 * ivl_scope_children
1352 * A scope may in turn contain other scopes. This method iterates
1353 * through all the child scopes of a given scope. If the function
1354 * returns any value other than 0, the iteration stops and the
1355 * method returns that value. Otherwise, iteration continues until
1356 * the children run out.
1358 * If the scope has no children, this method will return 0 and
1359 * otherwise do nothing.
1361 * ivl_scope_def
1362 * Task definition scopes carry a task definition, in the form of
1363 * a statement. This method accesses that definition. The
1364 * ivl_scope_def function must return a statement for scopes that
1365 * are type FUNCTION or TASK, and must return nil otherwise.
1367 * ivl_scope_event
1368 * ivl_scope_events
1369 * Scopes have 0 or more event objects in them.
1371 * ivl_scope_var
1372 * ivl_scope_vars
1373 * REMOVED
1375 * ivl_scope_log
1376 * ivl_scope_logs
1377 * Scopes have 0 or more logic devices in them. A logic device is
1378 * represented by ivl_logic_t.
1380 * ivl_scope_lpm
1381 * ivl_scope_lpms
1382 * Scopes have 0 or more LPM devices in them. These functions access
1383 * those devices.
1385 * ivl_scope_name
1386 * ivl_scope_basename
1387 * Every scope has a hierarchical name. This name is also a prefix
1388 * of all the names of objects contained within the scope. The
1389 * ivl_scope_basename is the name of the scope without the included
1390 * hierarchy.
1392 * ivl_scope_param
1393 * ivl_scope_params
1394 * A scope has zero or more named parameters. These parameters have
1395 * a name and an expression value.
1397 * ivl_scope_parent
1398 * If this is a non-root scope, then the parent is the scope that
1399 * contains this scope. Otherwise, the parent is nil.
1401 * ivl_scope_port
1402 * ivl_scope_ports
1403 * Scopes that are functions or tasks have ports defined by
1404 * signals. These methods access the ports by name.
1406 * If this scope represents a function, then the ports list
1407 * includes the return value, as port 0. The remaining ports are
1408 * the input ports in order.
1410 * ivl_scope_sig
1411 * ivl_scope_sigs
1412 * Scopes have 0 or more signals in them. These signals are
1413 * anything that can become and ivl_signal_t, include synthetic
1414 * signals generated by the compiler.
1416 * ivl_scope_time_precision
1417 * Scopes have their own intrinsic time precision, typically from
1418 * the timescale compiler directive. This method returns the
1419 * precision as a signed power of 10 value.
1421 * ivl_scope_time_units
1422 * Scopes have their own intrinsic time units, typically from the
1423 * timescale compiler directive. This method returns the units as a
1424 * signed power of 10 value.
1426 * ivl_scope_type
1427 * ivl_scope_tname
1428 * Scopes have a type and a type name. For example, if a scope is
1429 * an instance of module foo, its type is IVL_SCT_MODULE and its
1430 * type name is "foo". This is different from the instance name
1431 * returned by ivl_scope_name above.
1434 extern unsigned ivl_scope_attr_cnt(ivl_scope_t net);
1435 extern ivl_attribute_t ivl_scope_attr_val(ivl_scope_t net, unsigned idx);
1437 extern int ivl_scope_children(ivl_scope_t net,
1438 ivl_scope_f func, void*cd);
1440 extern ivl_statement_t ivl_scope_def(ivl_scope_t net);
1442 extern unsigned ivl_scope_events(ivl_scope_t net);
1443 extern ivl_event_t ivl_scope_event(ivl_scope_t net, unsigned idx);
1444 extern unsigned ivl_scope_logs(ivl_scope_t net);
1445 extern ivl_net_logic_t ivl_scope_log(ivl_scope_t net, unsigned idx);
1446 extern unsigned ivl_scope_lpms(ivl_scope_t net);
1447 extern ivl_lpm_t ivl_scope_lpm(ivl_scope_t, unsigned idx);
1448 extern const char* ivl_scope_name(ivl_scope_t net);
1449 extern const char* ivl_scope_basename(ivl_scope_t net);
1450 extern unsigned ivl_scope_params(ivl_scope_t net);
1451 extern ivl_parameter_t ivl_scope_param(ivl_scope_t net, unsigned idx);
1452 extern ivl_scope_t ivl_scope_parent(ivl_scope_t net);
1453 extern unsigned ivl_scope_ports(ivl_scope_t net);
1454 extern ivl_signal_t ivl_scope_port(ivl_scope_t net, unsigned idx);
1455 extern unsigned ivl_scope_sigs(ivl_scope_t net);
1456 extern ivl_signal_t ivl_scope_sig(ivl_scope_t net, unsigned idx);
1457 extern ivl_scope_type_t ivl_scope_type(ivl_scope_t net);
1458 extern const char* ivl_scope_tname(ivl_scope_t net);
1459 extern int ivl_scope_time_precision(ivl_scope_t net);
1460 extern int ivl_scope_time_units(ivl_scope_t net);
1463 /* SIGNALS
1464 * Signals are named things in the Verilog source, like wires and
1465 * regs, and also named things that are created as temporaries during
1466 * certain elaboration or optimization steps. A signal may also be a
1467 * port of a module or task.
1469 * Signals have a name (obviously) and types. A signal may also be
1470 * signed or unsigned.
1472 * ivl_signal_nex
1473 * This is the nexus of the signal. This is used for managing
1474 * connections to the rest of the net. There is exactly one pin for
1475 * each word of a signal. Each word may in turn be a vector. The
1476 * word address is the zero-based index for the word. It is up to
1477 * the context to translate different bases to the canonical address.
1479 * ivl_signal_array_base
1480 * ivl_signal_array_count
1481 * The signal may be arrayed. If so, the array_count is >1. Each
1482 * word of the array has its own nexus. The array_base is the
1483 * address is the Verilg source for the canonical zero word. This
1484 * may be negative, positive or zero.
1486 * Note that arraying of the signal into words is distinct from the
1487 * vectors. The width of a signal is the width of a WORD.
1489 * ivl_signal_dimensions
1490 * The signal may be an array (of vectors) in which case this
1491 * function returns >0, the number of dimensions of the array.
1493 * ivl_signal_msb
1494 * ivl_signal_lsb
1495 * ivl_signal_width
1496 * These functions return the left and right indices, respectively,
1497 * of the signal. If the signal is a scalar, both return 0. However,
1498 * it doesn't mean that the signal is a scalar if both return 0, one
1499 * can have a vector with 0 as both indices.
1501 * ivl_signal_port
1502 * If the signal is a port to a module, this function returns the
1503 * port direction. If the signal is not a port, it returns
1504 * IVL_SIP_NONE.
1506 * ivl_signal_signed
1507 * A signal, which is a vector, may be signed. In Verilog 2000, any
1508 * net or variable may be signed. This function returns true if the
1509 * signal is signed.
1511 * ivl_signal_local
1512 * A signal that was generated by the compiler as a place holder is
1513 * marked as local.
1515 * ivl_signal_type
1516 * Return the type of the signal, i.e., reg, wire, tri0, etc.
1518 * ivl_signal_data_type
1519 * Return the data type of the signal, i.e. logic, real, bool,
1520 * etc. All the signals connected to a nexus should have the same
1521 * data type
1523 * ivl_signal_npath
1524 * ivl_signal_path
1525 * This function returns the delay path object for the signal. The
1526 * delay path has this signal as the output, the source is attached
1527 * to the delay path itself.
1529 * ivl_signal_name (DEPRECATED)
1530 * This function returns the fully scoped hierarchical name for the
1531 * signal. The name refers to the entire vector that is the signal.
1533 * NOTE: This function is deprecated. The hierarchical name is too
1534 * vague a construct when escaped names can have . characters in
1535 * them. Do no use this function in new code, it will disappear.
1537 * ivl_signal_basename
1538 * This function returns the name of the signal, without the scope
1539 * information. This is the tail of the signal name. Since Verilog
1540 * has an escape syntax, this name can contain any ASCII
1541 * characters, except NULL or white space. The leading \ and
1542 * trailing ' ' of escaped names in Verilog source are not part of
1543 * the name, so not included here.
1545 * ivl_signal_attr
1546 * Icarus Verilog supports attaching attributes to signals, with
1547 * the attribute value (a string) associated with a key. This
1548 * function returns the attribute value for the given key. If the
1549 * key does not exist, the function returns 0.
1552 extern ivl_nexus_t ivl_signal_nex(ivl_signal_t net, unsigned word);
1553 extern int ivl_signal_array_base(ivl_signal_t net);
1554 extern unsigned ivl_signal_array_count(ivl_signal_t net);
1555 extern unsigned ivl_signal_dimensions(ivl_signal_t net);
1556 extern int ivl_signal_msb(ivl_signal_t net);
1557 extern int ivl_signal_lsb(ivl_signal_t net);
1558 extern unsigned ivl_signal_width(ivl_signal_t net);
1559 extern ivl_signal_port_t ivl_signal_port(ivl_signal_t net);
1560 extern int ivl_signal_signed(ivl_signal_t net);
1561 extern int ivl_signal_integer(ivl_signal_t net);
1562 extern int ivl_signal_local(ivl_signal_t net);
1563 extern unsigned ivl_signal_npath(ivl_signal_t net);
1564 extern ivl_delaypath_t ivl_signal_path(ivl_signal_t net, unsigned idx);
1565 extern ivl_signal_type_t ivl_signal_type(ivl_signal_t net);
1566 extern ivl_variable_type_t ivl_signal_data_type(ivl_signal_t net);
1567 extern const char* ivl_signal_name(ivl_signal_t net);
1568 extern const char* ivl_signal_basename(ivl_signal_t net);
1569 extern const char* ivl_signal_attr(ivl_signal_t net, const char*key);
1571 extern unsigned ivl_signal_attr_cnt(ivl_signal_t net);
1572 extern ivl_attribute_t ivl_signal_attr_val(ivl_signal_t net, unsigned idx);
1574 /* ivl_nexus_t ivl_signal_pin(ivl_signal_t net, unsigned idx); */
1575 /* unsigned ivl_signal_pins(ivl_signal_t net); */
1578 * These functions get information about a process. A process is
1579 * an initial or always block within the original Verilog source, that
1580 * is translated into a type and a single statement. (The statement
1581 * may be a compound statement.)
1583 * The ivl_process_type function gets the type of the process,
1584 * an "initial" or "always" statement.
1586 * A process is placed in a scope. The statement within the process
1587 * operates within the scope of the process unless there are calls
1588 * outside the scope.
1590 * The ivl_process_stmt function gets the statement that forms the
1591 * process. See the statement related functions for how to manipulate
1592 * statements.
1594 * Processes can have attributes attached to them. the attr_cnt and
1595 * attr_val methods return those attributes.
1597 extern ivl_process_type_t ivl_process_type(ivl_process_t net);
1599 extern ivl_scope_t ivl_process_scope(ivl_process_t net);
1601 extern ivl_statement_t ivl_process_stmt(ivl_process_t net);
1603 extern unsigned ivl_process_attr_cnt(ivl_process_t net);
1604 extern ivl_attribute_t ivl_process_attr_val(ivl_process_t net, unsigned idx);
1607 * These functions manage statements of various type. This includes
1608 * all the different kinds of statements (as enumerated in
1609 * ivl_statement_type_t) that might occur in behavioral code.
1611 * The ivl_statement_type() function returns the type code for the
1612 * statement. This is the major type, and implies which of the later
1613 * functions are applicable to the statement.
1615 extern ivl_statement_type_t ivl_statement_type(ivl_statement_t net);
1618 * The following functions retrieve specific single values from the
1619 * statement. These values are the bits of data and parameters that
1620 * make up the statement. Many of these functions apply to more than
1621 * one type of statement, so the comment in front of them tells which
1622 * statement types can be passed to the function.
1624 * FUNCTION SUMMARY:
1626 * ivl_stmt_block_scope
1627 * If the block is named, then there is a scope associated with
1628 * this. The code generator may need to know this in order to
1629 * handle disable statements.
1631 * ivl_stmt_events
1632 * ivl_stmt_nevent
1633 * Statements that have event arguments (TRIGGER and WAIT) make
1634 * those event objects available through these methods.
1636 * ivl_stmt_lval
1637 * ivl_stmt_lvals
1638 * Return the number of l-values for an assignment statement, or
1639 * the specific l-value. If there is more than 1 l-value, then the
1640 * l-values are presumed to be vector values concatenated together
1641 * from msb (idx==0) to lsb.
1643 * ivl_stmt_rval
1644 * Return the rval expression of the assignment. This is the value
1645 * that is to be calculated and assigned to the l-value in all the
1646 * assignment statements.
1648 * ivl_stmt_sub_stmt
1649 * Some statements contain a single, subordinate statement. An
1650 * example is the IVL_ST_WAIT, which contains the statement to be
1651 * executed after the wait completes. This method retrieves that
1652 * sub-statement.
1654 * SEMANTIC NOTES:
1656 * - Assignments: IVL_ST_ASSIGN, IVL_ST_ASSIGN_NB, IVL_CASSIGN, IVL_ST_FORCE
1658 * The assignments support ivl_stmt_rval to get the r-value expression
1659 * that is to be assign to the l-value, and ivl_stmt_lval[s] to get
1660 * the l-value that receives the value. The compiler has already made
1661 * sure that the types (l-value and r-value) are compatible.
1663 * If the l-value is a vector, then the compiler also makes sure the
1664 * expression width of the r-values matches. It handles padding or
1665 * operator sizing as needed to get the width exactly right.
1667 * The blocking and non-blocking assignments may also have an internal
1668 * delay. These are of the form "lval = #<delay> rval;" and <delay> is
1669 * the internal delay expression. (It is internal because it is inside
1670 * the statement.) The ivl_stmt_delay_expr function returns the
1671 * expression for the delay, or nil if there is no delay expression.
1673 * - IVL_ST_CASSIGN
1674 * This reflects a procedural continuous assignment to an l-value. The
1675 * l-value is the same as any other assignment (use ivl_stmt_lval).
1677 * The value to be assigned is an ivl_expr_t retrieved by the
1678 * ivl_stmt_rval function. The run time is expected to calculate the
1679 * value of the expression at the assignment, then continuous assign
1680 * that constant value. If the expression is non-constant, the code
1681 * generator is supposed to know what to do about that, too.
1683 * - IVL_ST_DELAY, IVL_ST_DELAYX
1684 * These statement types are delay statements. They are a way to
1685 * attach a delay to a statement. The ivl_stmt_sub_stmt() function
1686 * gets the statement to be executed after the delay. If this is
1687 * IVL_ST_DELAY, then the ivl_stmt_delay_val function gets the
1688 * constant delay. If this is IVL_ST_DELAYX, then the
1689 * ivl_stmt_delay_expr gets the expression of the delay. In this case,
1690 * the expression is not necessarily constant.
1692 * Whether constant or calculated, the resulting delay is in units of
1693 * simulation ticks. The compiler has already taken care of converting
1694 * the delay to the time scale/precision of the scope.
1696 * - IVL_ST_FORCE
1697 * This is very much like IVL_ST_CASSIGN, but adds that l-values can
1698 * include nets (tri, wire, etc). Memory words are restricted from
1699 * force l-values, and also non-constant bit or part selects. The
1700 * compiler will assure these constraints are met.
1702 * - IVL_ST_TRIGGER
1703 * This represents the "-> name" statement that sends a trigger to a
1704 * named event. The ivl_stmt_nevent function should always return 1,
1705 * and the ivl_stmt_events(net,0) function returns the target event,
1706 * as an ivl_event_t. The only behavior of this statement is to send a
1707 * "trigger" to the target event.
1709 * - IVL_ST_WAIT
1710 * This is the edge sensitive wait (for event) statement. The
1711 * statement contains an array of events that are to be tested, and a
1712 * single statement that is to be executed when any of the array of
1713 * events triggers.
1715 * the ivl_stmt_events function accesses the array of events to wait
1716 * for, and the ivl_stmt_sub_stmt function gets the sub-statement,
1717 * which may be null, that is to be executed when an event
1718 * triggers. The statement waits even if the sub-statement is nul.
1721 /* IVL_ST_BLOCK, IVL_ST_FORK */
1722 extern unsigned ivl_stmt_block_count(ivl_statement_t net);
1723 /* IVL_ST_BLOCK, IVL_ST_FORK */
1724 extern ivl_scope_t ivl_stmt_block_scope(ivl_statement_t net);
1725 /* IVL_ST_BLOCK, IVL_ST_FORK */
1726 extern ivl_statement_t ivl_stmt_block_stmt(ivl_statement_t net, unsigned i);
1727 /* IVL_ST_UTASK IVL_ST_DISABLE */
1728 extern ivl_scope_t ivl_stmt_call(ivl_statement_t net);
1729 /* IVL_ST_CASE,IVL_ST_CASER,IVL_ST_CASEX,IVL_ST_CASEZ */
1730 extern unsigned ivl_stmt_case_count(ivl_statement_t net);
1731 /* IVL_ST_CASE,IVL_ST_CASER,IVL_ST_CASEX,IVL_ST_CASEZ */
1732 extern ivl_expr_t ivl_stmt_case_expr(ivl_statement_t net, unsigned i);
1733 /* IVL_ST_CASE,IVL_ST_CASER,IVL_ST_CASEX,IVL_ST_CASEZ */
1734 extern ivl_statement_t ivl_stmt_case_stmt(ivl_statement_t net, unsigned i);
1735 /* IVL_ST_CONDIT IVL_ST_CASE IVL_ST_REPEAT IVL_ST_WHILE */
1736 extern ivl_expr_t ivl_stmt_cond_expr(ivl_statement_t net);
1737 /* IVL_ST_CONDIT */
1738 extern ivl_statement_t ivl_stmt_cond_false(ivl_statement_t net);
1739 /* IVL_ST_CONDIT */
1740 extern ivl_statement_t ivl_stmt_cond_true(ivl_statement_t net);
1741 /* IVL_ST_ASSIGN IVL_ST_ASSIGN_NB IVL_ST_DELAYX */
1742 extern ivl_expr_t ivl_stmt_delay_expr(ivl_statement_t net);
1743 /* IVL_ST_DELAY */
1744 extern uint64_t ivl_stmt_delay_val(ivl_statement_t net);
1745 /* IVL_ST_WAIT IVL_ST_TRIGGER */
1746 extern unsigned ivl_stmt_nevent(ivl_statement_t net);
1747 extern ivl_event_t ivl_stmt_events(ivl_statement_t net, unsigned idx);
1748 /* IVL_ST_ASSIGN IVL_ST_ASSIGN_NB IVL_ST_CASSIGN IVL_ST_DEASSIGN
1749 IVL_ST_FORCE IVL_ST_RELEASE */
1750 extern ivl_lval_t ivl_stmt_lval(ivl_statement_t net, unsigned idx);
1751 /* IVL_ST_ASSIGN IVL_ST_ASSIGN_NB IVL_ST_CASSIGN IVL_ST_DEASSIGN
1752 IVL_ST_FORCE IVL_ST_RELEASE */
1753 extern unsigned ivl_stmt_lvals(ivl_statement_t net);
1754 /* IVL_ST_ASSIGN IVL_ST_ASSIGN_NB IVL_ST_CASSIGN */
1755 extern unsigned ivl_stmt_lwidth(ivl_statement_t net);
1756 /* IVL_ST_STASK */
1757 extern const char* ivl_stmt_name(ivl_statement_t net);
1758 /* IVL_ST_STASK */
1759 extern ivl_expr_t ivl_stmt_parm(ivl_statement_t net, unsigned idx);
1760 /* IVL_ST_STASK */
1761 extern unsigned ivl_stmt_parm_count(ivl_statement_t net);
1762 /* IVL_ST_ASSIGN IVL_ST_ASSIGN_NB IVL_ST_CASSIGN IVL_ST_FORCE */
1763 extern ivl_expr_t ivl_stmt_rval(ivl_statement_t net);
1764 /* IVL_ST_DELAY, IVL_ST_DELAYX, IVL_ST_FOREVER, IVL_ST_REPEAT
1765 IVL_ST_WAIT, IVL_ST_WHILE */
1766 extern ivl_statement_t ivl_stmt_sub_stmt(ivl_statement_t net);
1769 #if defined(__MINGW32__) || defined (__CYGWIN32__)
1770 # define DLLEXPORT __declspec(dllexport)
1771 #else
1772 # define DLLEXPORT
1773 #endif
1775 extern DLLEXPORT int target_design(ivl_design_t des);
1778 /* target_design
1780 The "target_design" function is called once after the whole design
1781 is processed and available to the target. The target doesn't return
1782 from this function until it is finished with the design.
1784 The return value of this function should normally be zero. If the
1785 code generator detects errors, however, then the code generator
1786 returns a positive number to indicate the approximate number of
1787 errors detected (before it gave up.) Return values <0 are reserved
1788 for system and infrastructure errors.
1790 This function is implemented in the loaded target, and not in the
1791 ivl core. This function is how the target module is invoked. */
1793 typedef int (*target_design_f)(ivl_design_t des);
1796 _END_DECL
1798 #endif