1; -*- scheme -*-
2
3(include "freehdl/vaul-chunk.t")
4
5(define (format-v2cc-kind name)
6  (upcase (concat-strings (cons "v2cc" (cdr (syllables name))) "_")))
7
8(chunk v2cc
9       (struct-fmt "~a")
10       (pointer-fmt "p~a")
11       (kind-fmt-func format-v2cc-kind)
12       )
13
14(header-add "#include <freehdl/vaul-chunk.h>")
15(header-add "#include <string>")
16(header-add "#include <set>")
17(header-add "#include <list>")
18(header-add "#include <vector>")
19(header-add "#include <map>")
20(header-add "#include <deque>")
21(header-add "#include <vector>")
22(header-add "#include <algorithm>")
23(header-add "#include \"v2cc.h\"")
24;; Returns kind of a VHDL operator:
25;;  NO_OP if the function does not denote an operator
26;;  STD_OP if the funcion denotes an predefined VHDL operator
27;;  BASIC_OP if the function denotes an operator defined in an
28;;           IEEE library (e.g. numeric_std)
29;;  USER_OP an user defined operator
30(header-add "enum op_type { NO_OP, STD_OP, BASIC_OP, USER_OP };")
31;;
32(impl-add "#include \"v2cc-chunk.h\"")
33
34;;(defctype int)
35(defctype set_string (cname "set<string>"))
36(defctype list_string (cname "list<string>"))
37(defctype list_expr_pair_ref (cname "list<pair<pIIR_Expression, pIIR_Root> >&"))
38(defctype vector_string (cname "vector<string>"))
39(defctype vector_string_ref (cname "vector<string>&"))
40(defctype vector_bool (cname "vector<bool>"))
41(defctype vector_lint_ref (cname "vector<long long int>&"))
42(defctype RegionStack (cname "RegionStack"))
43(defctype RegionStack_ref (cname "RegionStack &"))
44(defctype ContextInfo (cname "ContextInfo"))
45(defctype ContextInfo_ref (cname "ContextInfo &"))
46(defctype pContextInfo (cname "ContextInfo*"))
47(defctype pAccessDescriptor (cname "pAccessDescriptor"))
48(defctype lint (cname "long long int"))
49(defctype StaticDataType (cname "StaticDataType"))
50(defctype string (cname "string"))
51(defctype string_ref (cname "string&"))
52(defctype set_IIR_SimpleReference (name "set<IIR_SimpleReference>"))
53(defctype pIIR_ObjectDeclaration (cname "pIIR_ObjectDeclaration"))
54;(defctype IR_StaticLevel (cname "IR_StaticLevel"))
55(defctype RangeDescriptor_vec (cname "vector<RangeDescriptor>"))
56(defctype RuntimeCheckFlags (cname "RuntimeCheckFlags"))
57(defctype id_type)
58;;(defctype static_level_type)
59(defctype op_type)
60
61;;(defgeneric emit_def
62;;  (args (string_ref str) (RegionStack_ref ctxt))
63;;  (methods
64;;   IIR_Subtype IIR_IntegerType IIR_PhysicalType
65;;   IIR_FloatingType IIR_EnumerationType
66;;   IIR_ArrayType IIR_RecordType IIR_FileType IIR_Type))
67
68(defgeneric emit_decl
69  (args (string_ref str) (RegionStack_ref ctxt) (int l))
70  (methods
71   IIR_Declaration
72   IIR_SubprogramDeclaration
73   IIR_VariableDeclaration
74   IIR_ConstantDeclaration
75   IIR_FileDeclaration
76   IIR_SignalDeclaration
77   IIR_TypeDeclaration
78   IIR_PackageDeclaration
79   IIR_PackageBodyDeclaration
80   IIR_EntityDeclaration
81   IIR_ArchitectureDeclaration
82   IIR_ConfigurationDeclaration
83   IIR_ComponentDeclaration))
84
85(defgeneric emit_main
86  (args (string_ref str) (RegionStack_ref ctxt) (int l))
87  (methods
88   IIR_Declaration
89   IIR_ArchitectureDeclaration
90   IIR_ConfigurationDeclaration))
91
92(defgeneric emit_expr
93  (args (string_ref str) (RegionStack_ref ctxt) (id_type t))
94  (return bool)
95  (methods
96   IIR_FunctionCall
97   IIR_SimpleReference
98   IIR_AbstractLiteralExpression
99   IIR_TypeConversion
100   IIR_QualifiedExpression
101   IIR_EnumLiteralReference
102   IIR_ArrayReference
103   IIR_ArrayLiteralExpression
104   IIR_RecordReference
105   IIR_RecordAggregate
106   IIR_ArrayAggregate
107   IIR_SliceReference
108   IIR_AccessReference
109   IIR_SignalAttr
110   IIR_AttrSigFunc
111   IIR_AttrArrayFunc
112   IIR_AttrTypeFunc
113   IIR_AttrTypeValue
114   IIR_Expression
115   IIR_EnumerationLiteral
116   IIR_NullExpression
117   IIR_Allocator
118   ))
119
120(defgeneric cdfg_emit_expr
121  (args (string_ref str) (RegionStack_ref ctxt) (id_type t))
122  (return bool)
123  (methods
124   IIR_FunctionCall
125   IIR_SimpleReference
126   IIR_AbstractLiteralExpression
127   IIR_TypeConversion
128   IIR_QualifiedExpression
129   IIR_EnumLiteralReference
130   IIR_ArrayReference
131   IIR_ArrayLiteralExpression
132   IIR_RecordReference
133   IIR_RecordAggregate
134   IIR_ArrayAggregate
135   IIR_SliceReference
136   IIR_AccessReference
137   IIR_SignalAttr
138   IIR_AttrSigFunc
139   IIR_AttrArrayFunc
140   IIR_AttrTypeFunc
141   IIR_AttrTypeValue
142   IIR_Expression
143   IIR_EnumerationLiteral
144   IIR_NullExpression
145   IIR_Allocator
146   ))
147
148;;
149;;  emit class headers (AKA declarations)
150;;
151
152(defgeneric emit_hdr
153  (args (string_ref str) (RegionStack_ref ctxt) (int l))
154  (methods
155   IIR_EntityDeclaration
156   IIR_ArchitectureDeclaration
157   IIR_PackageDeclaration
158   IIR_PackageBodyDeclaration
159   IIR_ProcessStatement
160   IIR_ComponentInstantiationStatement
161   IIR_BlockStatement
162   IIR_ConcurrentGenerateStatement
163   IIR_ConcurrentStatement
164   IIR_ConcurrentStatementList
165   IIR_SubprogramDeclaration
166   IIR_PredefinedFunctionDeclaration
167   IIR_PredefinedProcedureDeclaration
168   IIR_EnumerationType
169   IIR_AccessType
170   IIR_FileType
171   IIR_ScalarSubtype
172   IIR_ArrayType
173   IIR_ArraySubtype
174   IIR_TypeDeclaration
175   IIR_RecordType
176   IIR_RecordSubtype
177   IIR_Root
178   ))
179
180;;
181;;  emit class implementation (AKA definition)
182;;
183
184(defgeneric emit_impl
185  (args (string_ref str) (RegionStack_ref ctxt) (int l))
186  (methods
187   IIR_NullStatement
188   IIR_ReturnStatement
189   IIR_VariableAssignmentStatement
190   IIR_IfStatement
191   IIR_CaseStatement
192   IIR_LoopStatement
193   IIR_NextStatement
194   IIR_ExitStatement
195   ;;IIR_LoopControlStatement
196   IIR_ProcedureCallStatement
197   IIR_WaitStatement
198   IIR_AssertionStatement
199   IIR_ReportStatement
200   IIR_SignalAssignmentStatement
201   IIR_SequentialStatement
202   IIR_EntityDeclaration
203   IIR_ArchitectureDeclaration
204   IIR_ProcessStatement
205   IIR_ComponentInstantiationStatement
206   IIR_PackageDeclaration
207   IIR_PackageBodyDeclaration
208   IIR_BlockStatement
209   IIR_ConcurrentGenerateStatement
210   IIR_SequentialStatementList
211   IIR_SequentialStatement
212   IIR_ConcurrentStatement
213   IIR_ConcurrentStatementList
214   IIR_SubprogramDeclaration
215   IIR_PredefinedFunctionDeclaration
216   IIR_PredefinedProcedureDeclaration
217   IIR_EnumerationType
218   IIR_ScalarSubtype
219   IIR_ArrayType
220   IIR_ArraySubtype
221   IIR_AccessType
222   IIR_FileType
223   IIR_RecordType
224   IIR_RecordSubtype
225   ))
226
227
228(defgeneric cdfg_emit_impl
229  (args (string_ref str) (RegionStack_ref ctxt) (int l))
230  (methods
231   IIR_NullStatement
232   IIR_ReturnStatement
233   IIR_VariableAssignmentStatement
234   IIR_IfStatement
235   IIR_CaseStatement
236   IIR_LoopStatement
237   IIR_NextStatement
238   IIR_ExitStatement
239   ;;IIR_LoopControlStatement
240   IIR_ProcedureCallStatement
241   IIR_WaitStatement
242   IIR_AssertionStatement
243   IIR_ReportStatement
244   IIR_SignalAssignmentStatement
245   IIR_SequentialStatement
246   IIR_EntityDeclaration
247   IIR_ArchitectureDeclaration
248   IIR_ProcessStatement
249   IIR_ComponentInstantiationStatement
250   IIR_PackageDeclaration
251   IIR_PackageBodyDeclaration
252   IIR_BlockStatement
253   IIR_ConcurrentGenerateStatement
254   IIR_SequentialStatementList
255   IIR_SequentialStatement
256   IIR_ConcurrentStatement
257   IIR_ConcurrentStatementList
258   IIR_SubprogramDeclaration
259   IIR_PredefinedFunctionDeclaration
260   IIR_PredefinedProcedureDeclaration
261   IIR_EnumerationType
262   IIR_ScalarSubtype
263   IIR_ArrayType
264   IIR_ArraySubtype
265   IIR_AccessType
266   IIR_FileType
267   ))
268
269
270;; ******************************************************************************************
271;; Name: m_emit_info_init , generic function
272;;
273;; Description: emits initialization code of type info instances
274;;
275;; Return value: Static level of the array info instance
276;;
277;; ******************************************************************************************
278(defgeneric emit_info_init
279  (args (string_ref str) (RegionStack_ref ctxt) (bool static_info) (int l))
280  (return IR_StaticLevel)
281  (methods
282   IIR_EnumerationType
283   IIR_ScalarSubtype
284   IIR_ArrayType
285   IIR_ArraySubtype
286   IIR_AccessType
287   IIR_FileType
288   IIR_RecordType
289   IIR_RecordSubtype
290   ))
291
292
293;;(defgeneric emit
294;;  (args (string_ref str) (RegionStack_ref ctxt) (int l))
295;;  (methods
296;;   IIR_Declaration
297;;   IIR_Type
298;;   IIR_InterfaceDeclaration
299;;   IIR_TypeList
300;;   ))
301
302
303(defgeneric get_acl
304  (args (list_expr_pair_ref alist) (RegionStack_ref ctxt) (IR_StaticLevel slevel) (bool start))
305  (return bool)
306  (methods
307   IIR_Expression
308   IIR_SimpleReference
309   IIR_ArrayReference
310   IIR_RecordReference
311   IIR_ExplicitRange
312   IIR_SliceReference
313   ))
314
315
316(defgeneric cdfg_get_static_expr
317  (args (string_ref str) (RegionStack_ref ctxt) (IR_StaticLevel slevel) (id_type t) (bool start))
318  (return bool)
319  (methods
320   IIR_Expression
321   IIR_SimpleReference
322   IIR_ArrayReference
323   IIR_ExplicitRange
324   IIR_SliceReference
325   ))
326
327;; ******************************************************************************************
328;; Name: m_explore_and_check, generic function
329;;
330;; Description: explore (collect informations about node) and check
331;; node for correctness
332;;
333;; Return value: returns number of errors found
334;;
335;; ******************************************************************************************
336(defgeneric explore_and_check
337  (args (RegionStack_ref rstack) (bool collect_access_info))
338  (return int)
339  (methods
340   IIR_EntityDeclaration
341   IIR_DeclarationList
342   IIR_InterfaceDeclaration
343   IIR_ArchitectureDeclaration
344   IIR_ConcurrentStatementList
345   IIR_ProcessStatement
346   IIR_PackageDeclaration
347   IIR_PackageBodyDeclaration
348   IIR_SubprogramDeclaration
349   IIR_ConfigurationDeclaration
350   IIR_ComponentDeclaration
351   IIR_SequentialStatementList
352   IIR_IfStatement
353   IIR_ForLoopStatement
354   IIR_WhileLoopStatement
355   IIR_LoopStatement
356   IIR_NextStatement
357   IIR_ExitStatement
358   IIR_CaseStatement
359   IIR_WaitStatement
360   IIR_AssociationElement
361   IIR_SignalAssignmentStatement
362   IIR_VariableAssignmentStatement
363   IIR_ComponentInstantiationStatement
364   IIR_AssertionStatement
365   IIR_ReportStatement
366   IIR_ProcedureCallStatement
367   IIR_EnumerationType
368   IIR_Type
369   IIR_RecordType
370   IIR_ArrayType
371   IIR_ArraySubtype
372   IIR_FileType
373   IIR_ScalarSubtype
374   IIR_Subtype
375   IIR_NullStatement
376   IIR_ReturnStatement
377   IIR_ConcurrentGenerateIfStatement
378   IIR_ConcurrentGenerateForStatement
379   IIR_PredefinedFunctionDeclaration
380   ))
381
382
383;; ******************************************************************************************
384;; Name: m_get_context, generic function
385;;
386;; Description: Analyzes statements and collects all abjects which are
387;; accessed. The information about the accessed objects are stored in
388;; a ContextInfo instance. A ContextInfo instance stores three
389;; different kinds of informations:
390;;
391;; 1. accessed_objects = all objects
392;; which are accessed (read, written, sensitive).
393;;
394;; 2. wait_statements = pointer to the wait statements included in the
395;; current context
396;;
397;; 3. signal_assignment_statements = list of pointers to all signal
398;; assignment statements included in the current context
399;;
400;; 4. internal_vars = internal objects required by the generated code
401;;
402;; Parameter: ctxt = context info instance
403;;   target = is true if the expression is target of an assignment
404;;   level = level the object is located at. The entire statement
405;; is assigned level 0. The level is increased each time an object is
406;; included in an argument to a subroutine or an index value of an
407;; array reference.
408;;
409;; Return value: returns a pointer to the corresponding access
410;; descriptor if an expression is analyzed. Otherwise, NULL is
411;; returned.
412;;
413;; ******************************************************************************************
414(defgeneric get_context
415  (args (ContextInfo_ref ctxt) (RegionStack_ref rstack) (bool target) (int level))
416  (return pAccessDescriptor)
417  (methods
418   IIR_FunctionCall
419   IIR_SimpleReference
420   IIR_ArrayReference
421   IIR_AccessReference
422   IIR_ArrayRange
423   IIR_ExplicitRange
424   IIR_OthersIndexedAssociation
425   IIR_RangeIndexedAssociation
426   IIR_SingleIndexedAssociation
427   IIR_ElementAssociation
428   IIR_SliceReference
429   IIR_RecordReference
430   IIR_Expression
431   IIR_ExpressionList
432   IIR_ArrayAggregate
433   IIR_RecordAggregate
434   IIR_WaitStatement
435   IIR_AttrSigFunc
436   IIR_TypeConversion
437   IIR_Type
438   IIR_QualifiedExpression
439   IIR_Allocator
440   IIR_AttrTypeFunc
441   IIR_AttrTypeValue
442   IIR_AttrArrayFunc
443   ))
444
445
446;; ******************************************************************************************
447;; Name: m_check_expression , generic function
448;;
449;; Description: checks whether expression is valid and contains no
450;; errors. Any errors found are reportet. Parameter rstack is a
451;; reference to the current regions stack
452;;
453;; Return value: returns number of errors which were found in the expression
454;;
455;; ******************************************************************************************
456(defgeneric check_expression
457  (args (RegionStack_ref rstack))
458  (return int)
459  (methods
460   IIR_FunctionCall
461   IIR_SimpleReference
462   IIR_AccessReference
463   IIR_ArrayReference
464   IIR_ArrayRange
465   IIR_ExplicitRange
466   IIR_OthersIndexedAssociation
467   IIR_RangeIndexedAssociation
468   IIR_SingleIndexedAssociation
469   IIR_SliceReference
470   IIR_RecordReference
471   IIR_Expression
472   IIR_ExpressionList
473   IIR_ArrayAggregate
474   IIR_RecordAggregate
475   IIR_AttrSigFunc
476   IIR_ArrayLiteralExpression
477   IIR_TypeConversion
478   IIR_QualifiedExpression
479   ))
480
481
482;; Returns kind of operator:
483;;  NO_OP if the function does not denote an operator
484;;  PREDEF_OP if the funcion denotes an predefined VHDL operator
485;;  BASIC_OP if the function denotes an operator defined in an
486;;           IEEE library (e.g. numeric_std)
487;;  OP else
488(defgeneric get_operator_type
489  (return op_type)
490  (methods
491   IIR_FunctionDeclaration
492   IIR_ProcedureDeclaration
493   ))
494
495
496(defextension IIR_Declaration
497  (
498   ;; Stores information about what must be checked at runtime
499   (RuntimeCheckFlags runtime_checks)
500   ))
501
502
503;; Some additional informations for all kind of nodes
504(defextension IIR_Root
505   (
506    ;; stores which kinds of optimization has been applied on node
507    (int done (= "0"))
508    ;; stores the uppermost declarative region to which the
509    ;; object/declaration/expression is static. E.g., if a constant is
510    ;; delcared within a process and initilized with a generic
511    ;; parameter then static_declarative_region is set to the entity
512    ;; declarative region (because the constant value is static with
513    ;; respect to the entity). Note that the value is set to NULL if
514    ;; the object/declaration/expression is not static at all!
515    (IIR_DeclarativeRegion static_declarative_region (= "NULL"))
516   ))
517
518;; Some additional information for library units (e.g., entity,
519;; architecture, configuration, package, package body)
520(defextension IIR_LibraryUnit
521  (
522   ;; stores whether code shall be omitted for this library unit. In
523   ;; some case (e.g., if an entity if overwritten by another entity)
524   ;; no code is generated for a specific library unit.
525   (bool generate_code (= "true"))
526   ))
527
528
529;; Some additional information about expressions and some literals nodes
530(defextension IIR_Expression
531  (
532   (StaticDataType folded_value) ;; Stores long long int/double value of a plain contant
533   (bool valid_folded_value (= "false")) ;; folded_value contains an valid value
534   ;; Stores information about what must be checked at runtime
535   (RuntimeCheckFlags runtime_checks)
536   ))
537
538(defextension IIR_Literal
539  (
540   (StaticDataType folded_value) ;; Stores long long int/double value of a plain contant
541   (bool valid_folded_value (= "false")) ;; folded_value contains an valid value
542   ))
543
544(defextension IIR_EnumerationLiteral
545  (
546   (StaticDataType folded_value) ;; Stores long long int/double value of a plain contant
547   (bool valid_folded_value (= "false")) ;; folded_value contains an valid value
548   ))
549
550(defextension IIR_PhysicalUnit
551  (
552   (StaticDataType folded_value) ;; Stores long long int/double value of a plain contant
553   (bool valid_folded_value (= "false")) ;; folded_value contains an valid value
554   ))
555
556(defextension IIR_Type
557  (
558   ;; Stores information about what must be checked at runtime
559   (RuntimeCheckFlags runtime_checks)
560   ))
561
562(defextension IIR_Subtype
563  (
564   ;; Anonymous types may be converted into a declared type via an
565   ;; implicit type declaration. Then, this slots points to the
566   ;; corresponding declaration.
567   (V2CC_ImplicitSubtypeDeclaration implicit_subtype_declaration (="NULL"))
568   ))
569
570;; stores the index number of the corresponding wait_info object which
571;; connected with the wait statement
572(defextension IIR_WaitStatement
573  ((int wait_info_index)))
574
575
576;; stores the index number of the corresponding wait_info object which
577;; connected with a procedure call statement that contains a wait.
578(defextension IIR_ProcedureCallStatement
579  ((int wait_info_index)))
580
581
582(defextension IIR_DeclarativeRegion
583  (
584   ;; Stores context information about the declaration region
585   (ContextInfo context)
586   ;; Includes all "normal" declarations of the current declaration
587   ;; list and additional implicit type declarations.
588   (IIR_DeclarationList extended_declarations (="NULL"))
589   ))
590
591
592(defextension IIR_EntityDeclaration
593  (
594   ;; Includes all "normal" declarations of the current declaration
595   ;; list and additional implicit type declarations.
596   (IIR_DeclarationList extended_generic_clause (="NULL"))
597   (IIR_DeclarationList extended_port_clause (="NULL"))
598   ))
599
600(defextension IIR_SubprogramDeclaration
601  (
602   ;; Includes all "normal" declarations of the current declaration
603   ;; list and additional implicit type declarations.
604   (IIR_DeclarationList extended_interface_declarations (="NULL"))
605   ))
606
607(defextension IIR_ConcurrentStatement
608  (
609   ;; Store all additional parameters required by the constructors of
610   ;; the corresponding C++ classes.
611   (IIR_DeclarationList extended_interface_declarations (="NULL"))
612   ))
613
614(defextension IIR_BlockStatement
615  (
616   ;; Includes all "normal" declarations of the current declaration
617   ;; list and additional implicit type declarations.
618   ;; Includes all "normal" declarations of the current declaration
619   ;; list and additional implicit type declarations.
620   (IIR_DeclarationList extended_generic_clause (="NULL"))
621   (IIR_DeclarationList extended_port_clause (="NULL"))
622   ))
623
624;; Store some additional information about the array aggregat
625(defextension IIR_ArrayAggregate
626  ((int dest_length) ;; length of the aggregate as determined form the aggregate subtype
627   (int dest_left) ;; left bound of aggregate as determined from the agregate subtype
628   (int dest_right) ;; right bound of aggregate as determined from the agregate subtype
629   (IR_Direction dest_direction) ;; direction of aggregate as determined from the agregate subtype
630   (bool named_association) ;; is true when the aggregate uses named association
631   (bool known_subtype) ;; is true if subtype of aggregate is known from the context
632   (bool has_others) ;; aggregat includes an others choice
633   (bool locally_static_ranges) ;; true if all index ranges of the choices are locally static
634   (int total_length) ;; total number of array elements (can be determined only if locally_static_ranges=true)
635   (int min_index) ;; minimal index number among all choices (if determinable, i.e. locally_static_ranges=true)
636   (int max_index))) ;; maximal index number among all choices (if determinable, i.e. locally_static_ranges=true)
637
638
639;; Some additional information about a specific indexed association
640(defextension IIR_IndexedAssociation
641  ((bool locally_static_range) ;; true if all choices are locally range
642   (int length) ;; number of elements (can be determined only if locally_static_range=true)
643   (int min_index) ;; minimal index number among all choices (if determinable, i.e. locally_static_range=true)
644   (int max_index))) ;; maximal index number among all choices (if determinable, i.e. locally_static_range=true)
645
646(defextension IIR_EnumerationType
647  ((int enum_item_number))) ;; number of enumeration items
648
649
650(defextension IIR_ObjectDeclaration
651  ((bool alias_check_bounds) ;; bounds must be checked at runtime
652   ))
653
654(defextension IIR_LoopStatement
655  ((bool next_statement_used (= "false")) ;; stores whether a next statement was used for this loop
656   (bool exit_statement_used (= "false")) ;; stores whether a exit statement was used for this loop
657   (int loop_id (= "-1")) ;; number used to create unique labels for loops
658   ))
659
660(defextension IIR_ProcessStatement
661  (
662   ;; is true when the process includes (directly or indirectly) a
663   ;; wait statement
664   (bool has_wait (= "false"))
665   ;; is true when the process includes (directly or indirectly) a
666   ;; wait statement with an "for" clause
667   (bool has_wait_for (= "false"))
668   ))
669
670
671(defextension IIR_ProcedureDeclaration
672  (
673   ;; is true when the process includes (directly or indirectly) a
674   ;; wait statement
675   (bool has_wait (= "false"))
676   ;; is true when the procedure includes (directly or indirectly) a
677   ;; wait statement with an "for" clause
678   (bool has_wait_for (= "false"))
679   ))
680
681
682;; ******************************************************************************************
683;; Name: m_get_object_declaration , generic function
684;;
685;; Description: Returns the object declaration a reference expression
686;; is based on. E.g. an expression "sig(3 downto 1)" will retrun the
687;; object delcration pointer associated with "sig". Note that if the
688;; prefix is a signal kind attribute then this signal attribute object
689;; is returned!
690;;
691;; Return value: returns object declaration
692;;
693;; ******************************************************************************************
694
695(defgeneric get_object_declaration
696  (return pIIR_ObjectDeclaration)
697  (methods
698   IIR_ObjectReference
699   IIR_SimpleReference
700   IIR_SliceReference
701   IIR_SignalAttr
702   IIR_ArrayReference
703   IIR_RecordReference
704   ))
705
706
707
708;; ******************************************************************************************
709;; Name: V2CC_InternalObjectDeclaration, node
710;;
711;; Description: A new declaration node type for internal objects which
712;; are created by the code generator. Nothe that internal objects are
713;; introduced by the code generation phase. They are needed by the
714;; generated code in order to successfully map VHDL code to C++.
715;;
716;;
717;;
718;; ******************************************************************************************
719
720(defnode V2CC_InternalObjectDeclaration (IIR_ObjectDeclaration)
721  (
722   ;; C++ type of the object plotted into a string. Note that if this
723   ;; string is empty then the type of the object is defined by the
724   ;; subtype slot of the inherited IIR_ObjectDeclaration class.
725   (string cpp_type_string)
726   ;; Initial value of the object. If the string is empty then the
727   ;; initial value may be specified by the corresponding expression
728   ;; pointer of the base class.
729   (string cpp_initial_string)
730   ;; Some additional information may be stored here
731   (int flags)
732  ))
733
734
735;; ******************************************************************************************
736;; Name: V2CC_ImplicitSignalDeclaration, node
737;;
738;; Description: A new declaration node type implicitly generated
739;; signals. Servers as a base type for several derived implicit
740;; signal types
741;;
742;; ******************************************************************************************
743
744(defnode V2CC_ImplicitSignalDeclaration (IIR_SignalDeclaration)
745  ())
746
747
748;; ******************************************************************************************
749;; Name: V2CC_ImplicitSignalDeclaration_WaitFor, node
750;;
751;; Description: An implicit signal which is used to implement wait
752;; for clauses of wait statements
753;;
754;; ******************************************************************************************
755
756(defnode V2CC_ImplicitSignalDeclaration_WaitFor (V2CC_ImplicitSignalDeclaration)
757  ())
758
759
760;; ******************************************************************************************
761;; Name: V2CC_ImplicitSignalDeclaration_Transaction, node
762;;
763;; Description: An implicit signal which is used to implement the
764;; 'transaction functionality of VHDL
765;;
766;; ******************************************************************************************
767
768(defnode V2CC_ImplicitSignalDeclaration_Transaction (V2CC_ImplicitSignalDeclaration)
769  ())
770
771
772;; ******************************************************************************************
773;; Name: V2CC_InternalCode, node
774;;
775;; Description: Stores generated C++ code sequences which shall be
776;; printed to the output file. Usually, it is used to store code
777;; generated from VHDL subprograms declarations.
778;;
779;;
780;; ******************************************************************************************
781
782(defnode V2CC_InternalCode (IIR_ObjectDeclaration)
783  (
784   ;; Header code
785   (string cpp_header_string)
786   ;; Implementation code
787   (string cpp_impl_string)
788   ;; Some additional information may be stored here
789   (int flags))
790  )
791
792
793;; ******************************************************************************************
794;; Name: V2CC_ImplicitSubtypeDeclaration
795;;
796;; Description: A subtype declaration which is created by the code
797;; generator from a implicit type declaration. E.g., for a declaration
798;; "variable v : bit_vector(0 to 7);" an anonymous type "subtype
799;; anonymous_type is bit_vector(0 to 7)" is generated and used in the
800;; subsequent variable declaration.
801;;
802;; ******************************************************************************************
803
804(defnode V2CC_ImplicitSubtypeDeclaration (IIR_SubtypeDeclaration)())
805
806
807;; ******************************************************************************************
808;; Name: V2CC_ImplicitInterfaceSubtypeDeclaration
809;;
810;; Description: A subtype declaration which is created by the code
811;; generator from a implicit type declaration. E.g., for a declaration
812;; "variable v : bit_vector(0 to 7);" an anonymous type "subtype
813;; anonymous_type is bit_vector(0 to 7)" is generated and used in the
814;; subsequent variable declaration.
815;;
816;; ******************************************************************************************
817
818;;(defnode V2CC_ImplicitInterfaceSubtypeDeclaration (IIR_InterfaceDeclaration)())
819
820
821;; ******************************************************************************************
822;; Name: m_qid , generic function
823;;
824;; Description: Returns get a fully qualified identifier name plus an
825;; appropriate prefix. I.e., if a identifier is used at a location in
826;; the code where it is not directly visible then some prefix code is
827;; needed in order to access it. E.g., if a generic parameter is used
828;; within process then it is accessed using a architecture pointer as
829;; the parameter is not directly visible within the process. parameter
830;; rstack determines the code region where the identifier is to be
831;; used. Parameter obj_access defines how the identifier is accessed.
832;;
833;; Return value: returns fully qualified string
834;;
835;; ******************************************************************************************
836
837(defgeneric qid
838  (args (RegionStack_ref rstack) (id_type obj_access))
839  (return string)
840  (methods
841   IIR_LibraryUnit
842   IIR_Declaration
843   IIR_SignalDeclaration
844   IIR_InterfaceDeclaration
845   IIR_SignalInterfaceDeclaration
846   V2CC_ImplicitSignalDeclaration_WaitFor
847   IIR_ObjectDeclaration
848   IIR_SignalDeclaration
849   IIR_SubprogramDeclaration
850   IIR_TypeDeclaration
851   IIR_Subtype
852   IIR_Type
853   ))
854
855
856;; ******************************************************************************************
857;; Name: m_get_type_info_obj , generic function
858;;
859;; Description: Returns type info object for a type or subtype. If the
860;; (sub)type is anonymous then code which generates a new type info
861;; objects is returned. static_object controls whether a new created
862;; info object shall be static (i.e., it is never removed) or not.
863;;
864;; Return value: string
865;;
866;; ******************************************************************************************
867(defgeneric get_type_info_obj
868  (args (RegionStack_ref rstack) (bool static_object))
869  (return string)
870  (methods
871   IIR_EnumerationType
872   IIR_IntegerType
873   IIR_PhysicalType
874   IIR_FloatingType
875   IIR_ScalarSubtype
876   IIR_RecordSubtype
877   IIR_Subtype
878   IIR_ArrayType
879   IIR_ArraySubtype
880   IIR_AccessType
881   IIR_FileType
882   IIR_RecordType
883   ))
884
885;; ******************************************************************************************
886;; Name: m_get_discrete_range , generic function
887;;
888;; Description: Returns an array of RangeDescriptors derived from the
889;; first parameter. Note that usually this function is called to
890;; determine the bounds on an scalar type or the index bounds on an
891;; array. In most cases it will return an array containing only a
892;; single element. However, when called to extract the index ranges
893;; from an array several RangeDescriptors may be returned where each
894;; one covers one index range.
895;;
896;; Return value: RangeDescriptor (see v2cc.h)
897;;
898;; ******************************************************************************************
899(defgeneric get_discrete_range
900  (args (RegionStack_ref rstack) (IR_StaticLevel slevel))
901  (return RangeDescriptor_vec)
902  (methods
903   IIR_EnumerationType
904   IIR_IntegerType
905   IIR_PhysicalType
906   IIR_FloatingType
907   IIR_ScalarSubtype
908   IIR_ExplicitRange
909   IIR_SliceReference
910   IIR_ArrayType
911   IIR_ArraySubtype
912   IIR_Attr_ArrayRANGE
913   IIR_Attr_ArrayREVERSE_RANGE
914   ))
915
916
917;; ******************************************************************************************
918;; Name: m_get_static_level , generic function
919;;
920;; Description: Determines static level of an type or expression
921;;
922;; Return value: returns static level
923;;
924;; ******************************************************************************************
925
926(defgeneric get_static_level
927  (args (RegionStack_ref rstack))
928  (return IR_StaticLevel)
929  (methods
930   IIR_Type
931   IIR_Expression))
932
933
934;; ******************************************************************************************
935;; Name: m_constant_fold , generic function
936;;
937;; Description: performs constant folding optimizations on nodes
938;;
939;; Return value: returns number of errors found during folding
940;;
941;; ******************************************************************************************
942
943(defgeneric constant_fold
944  (args (RegionStack_ref rstack))
945  (return int)
946  (methods
947   IIR_Type
948   IIR_PhysicalType
949   IIR_ScalarSubtype
950   IIR_ArrayType
951   IIR_ArraySubtype
952   IIR_AttrSigFunc
953   IIR_ArrayLiteralExpression
954   IIR_EnumLiteralReference
955   IIR_FunctionCall
956   IIR_SimpleReference
957   IIR_ArrayReference
958   IIR_ArrayRange
959   IIR_AttrArrayFunc
960   IIR_AttrTypeFunc
961   IIR_AttrTypeValue
962   IIR_ExplicitRange
963   IIR_OthersIndexedAssociation
964   IIR_SingleIndexedAssociation
965   IIR_RangeIndexedAssociation
966   IIR_SliceIndexedAssociation
967   IIR_SliceReference
968   IIR_RecordReference
969   IIR_Expression
970   IIR_TypeConversion
971   IIR_ExpressionList
972   IIR_ArrayAggregate
973   IIR_RecordAggregate
974   IIR_FloatingPointLiteral
975   IIR_IntegerLiteral
976   IIR_AbstractLiteralExpression
977   IIR_PhysicalLiteral
978   IIR_EnumerationLiteral
979   IIR_PhysicalUnit
980   IIR_QualifiedExpression
981   IIR_Allocator
982   ))
983
984
985;; ******************************************************************************************
986;; Name: m_optmize , generic function
987;;
988;; Description: performs some optimizations
989;;
990;; Return value: void
991;;
992;; ******************************************************************************************
993
994
995(defgeneric optimize
996  (args (RegionStack_ref rstack))
997  (methods
998   IIR_PredefinedFunctionDeclaration
999   IIR_SubprogramDeclaration
1000   IIR_EntityDeclaration
1001   IIR_Type
1002   IIR_ArchitectureDeclaration
1003   IIR_ConcurrentStatementList
1004   IIR_ProcessStatement
1005   IIR_PackageDeclaration
1006   IIR_PackageBodyDeclaration
1007   IIR_ConfigurationDeclaration
1008   IIR_ComponentDeclaration
1009   IIR_ComponentInstantiationStatement
1010   IIR_ConcurrentGenerateIfStatement
1011   IIR_ConcurrentGenerateForStatement
1012   ))
1013
1014
1015
1016
1017