Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / behvhdl / vhd_parse.c
1
2 /* ###--------------------------------------------------------------### */
3 /* */
4 /* file : vhd_parse.c */
5 /* date : Oct 30 1995 */
6 /* version : v11 */
7 /* author : L.A TABUSSE & H.N. VUONG & P. BAZARGAN-SABET */
8 /* content : vhdlloadbefig */
9 /* */
10 /* ###--------------------------------------------------------------### */
11
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
15 #include AVT_H
16 #include MUT_H
17 #include LOG_H
18 #include BEH_H
19 #include BHL_H
20 #include BVL_H
21 #include "bvl_utype.h"
22 #include "bvl_utdef.h"
23 #include "bvl_parse.h"
24
25
26 extern void vhd_bcomprestart (FILE *inputfile);
27
28
29
30 char *vhdfindbefig(char *name)
31 {
32 char *suffix ;
33 suffix = V_STR_TAB[__BVL_FILE_SUFFIX].VALUE;
34 if (suffix == NULL) suffix = namealloc("vhd");
35
36 return filepath(name, suffix);
37 }
38
39 /* ###--------------------------------------------------------------### */
40 /* function : vhdloadbefig */
41 /* description : analyze a behavioural VHDL description and produce a */
42 /* set of data structure. The function returns a pointer */
43 /* on a BEFIG. Errors are repported in the returned */
44 /* structure. */
45 /* ###--------------------------------------------------------------### */
46
47 struct befig *
48 vhdloadbefig (befig_list *pt_befig, char *figname, unsigned int trace_mode)
49 {
50 unsigned int check_mode ;
51 char *suffix ;
52 char *str ;
53 static unsigned int call_nbr = 0 ;
54
55 // added to prevent warning
56 if (pt_befig) call_nbr =0 ;
57
58 suffix = V_STR_TAB[__BVL_FILE_SUFFIX].VALUE;
59 if (suffix == NULL) suffix = namealloc("vhd");
60
61 if ((vhd_bcompin = mbkfopen (figname, suffix, READ_TEXT)) != NULL)
62 {
63 sprintf (BVL_CURFIL, "%s.%s", figname, suffix);
64 }
65
66 if (vhd_bcompin == NULL)
67 {
68 beh_error (100, figname);
69 EXIT (1);
70 }
71
72 /* ###------------------------------------------------------### */
73 /* call the compiler on the current file */
74 /* - print a message if the trace mode is actif */
75 /* - add internal signals to the primary input list if */
76 /* "keep auxiliary" mode is actif */
77 /* ###------------------------------------------------------### */
78
79 if ((trace_mode & BVL_TRACE) != 0)
80 beh_message (3, BVL_CURFIL);
81
82 if ((trace_mode & BVL_KEEPAUX) != 0)
83 BVL_AUXMOD = 1;
84 else
85 BVL_AUXMOD = 0;
86
87 BEH_LINNUM = 1;
88
89 if ((trace_mode & BVL_CHECKEMPTY) != 0)
90 BVL_CHECK = 0;
91 else
92 BVL_CHECK = 1;
93
94 if (call_nbr != 0)
95 vhd_bcomprestart (vhd_bcompin);
96 call_nbr++;
97
98 vhd_bcompparse ();
99 fclose (vhd_bcompin);
100 vhd_bcompin = NULL;
101
102 /* ###------------------------------------------------------### */
103 /* check the consistency of the compiled description */
104 /* ###------------------------------------------------------### */
105
106 if ((trace_mode & BVL_CHECKEMPTY) != 0)
107 {
108 check_mode = BEH_CHK_EMPTY;
109 BVL_HEDFIG->FLAG = BEH_ARC_C ;
110 }
111 else
112 {
113 check_mode = BEH_CHK_DRIVERS;
114 BVL_HEDFIG->FLAG = BEH_ARC_VHDL ;
115 }
116
117 if (BVL_HEDFIG->ERRFLG == 0)
118 BVL_HEDFIG->ERRFLG = beh_chkbefig (BVL_HEDFIG, check_mode);
119
120 // fprintf( stdout, "BVL (vhd) : parse completed\n");
121 return (BVL_HEDFIG);
122 }