Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / mbkvhdl / mvl_parse.c
1 /*
2 * This file is part of the Alliance CAD System
3 * Copyright (C) Laboratoire LIP6 - Département ASIM
4 * Universite Pierre et Marie Curie
5 *
6 * Home page : http://www-asim.lip6.fr/alliance/
7 * E-mail support : mailto:alliance-support@asim.lip6.fr
8 *
9 * This library is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Library General Public License as published
11 * by the Free Software Foundation; either version 2 of the License, or (at
12 * your option) any later version.
13 *
14 * Alliance VLSI CAD System is distributed in the hope that it will be
15 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17 * Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with the GNU C Library; see the file COPYING. If not, write to the Free
21 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24 /* ###--------------------------------------------------------------### */
25 /* */
26 /* file : mvl_parse.c */
27 /* date : Feb 15 1995 */
28 /* author : L.A TABUSSE & H.N. VUONG & P. BAZARGAN-SABET */
29 /* description : Parser VHDL --> MBK */
30 /* */
31 /* ###--------------------------------------------------------------### */
32
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #ifndef MACOS
37 #include <sys/types.h>
38 #endif
39 #include AVT_H
40 #include MUT_H
41 #include MLO_H
42 #include "mvl_parse.h"
43 #include "mvl_utdef.h"
44
45 char MVL_MBKMOD; /* The mode of getlofig */
46 char MVL_ERRFLG = 0; /* if = 1 no structure is made */
47 int MVL_LINNUM = 1; /* file's line number */
48 char MVL_CURFIL[200]; /* current file's name */
49
50 struct dct_entry **MVL_HSHTAB; /* dictionnary's entry points */
51
52 extern void mvl_scomprestart (FILE*);
53
54 static int MVL_PRELOAD = 0;
55 void
56 parsevhdlnetlist(libname)
57 char *libname;
58 {
59 MVL_PRELOAD = 1;
60 vhdlloadlofig(NULL, libname, 'A');
61 MVL_PRELOAD = 0;
62 }
63
64 void vhdlloadlofig (pt_lofig, figname, mode)
65
66 struct lofig *pt_lofig;
67 char *figname ;
68 char mode ;
69
70 {
71 struct lofig *pt_lofig_tmp;
72 struct loins *pt_loins ;
73 struct loins *pt_loinsaux;
74 struct locon *pt_locon ;
75 struct locon *pt_loconaux;
76 struct losig *pt_losig ;
77 struct losig *pt_losigaux;
78 char filename[120];
79 char local_mbk_fast_mode;
80 static int call_nbr = 0;
81 char *suffix = NULL;
82 char *str;
83
84 if (!MVL_PRELOAD) {
85 suffix = V_STR_TAB[__MVL_FILE_SUFFIX].VALUE;
86 if (suffix == NULL) suffix = IN_LO;
87 sprintf(filename,"%s.%s",figname,suffix);
88 }
89 else sprintf(filename,"%s",figname);
90
91 /* Initialization of some variables */
92 MVL_LINNUM = 1;
93 MVL_MBKMOD = mode;
94 strcpy (MVL_CURFIL, figname);
95
96 /* FAST_MODE asked for MBK */
97 local_mbk_fast_mode = FAST_MODE;
98 FAST_MODE = 'Y';
99
100 if ((mode != 'A') && (mode != 'P') && (mode != 'C'))
101 {
102 printf("vhdlloadfig : Bad mode '%c' asked\n", mode);
103 FAST_MODE = local_mbk_fast_mode;
104 EXIT(1);
105 }
106
107 /* Opening file */
108 mvl_scompin = (FILE *) mbkfopen(figname, suffix, READ_TEXT);
109
110 if(mvl_scompin == NULL)
111 {
112 (void)fprintf(stderr,"\n*** mbk error *** can't open file : %s\n",
113 filename);
114 FAST_MODE = local_mbk_fast_mode;
115 EXIT(1);
116 }
117
118 /* TRACE_MODE asked for MBK */
119 if(TRACE_MODE == 'Y')
120 {
121 (void)printf("\n--- mbk --- parsing file : %s in mode : %c\n",
122 filename, mode);
123 }
124
125 MVL_LOFPNT = pt_lofig; /* passing main parameter */
126 MVL_TOPPNT = pt_lofig; /* passing main parameter */
127
128 if (call_nbr != 0)
129 mvl_scomprestart (mvl_scompin);
130
131 call_nbr ++;
132
133 /* -------------------------------------------------------------------*/
134 /* Parsing : If mode is P or A, then normal parsing, if mode is C */
135 /* then parsing of a new figure, then from the new one, we fill the */
136 /* old one. */
137 /* -------------------------------------------------------------------*/
138
139 if((mode == 'P') || (mode == 'A'))
140 {
141 if(mvl_scompparse() != 0)
142 {
143 (void)fprintf(stderr,"\n*** mbk error *** abnormal parsing for : %s\n",filename);
144 FAST_MODE = local_mbk_fast_mode;
145 EXIT(1);
146 }
147 }
148
149 if(mode == 'C')
150 {
151 /* ---------------------------------------------------------------- */
152 /* Saving the lofig pointer, creating a new one to allow the */
153 /* parsing of the figure in 'A' mode. */
154 /* ---------------------------------------------------------------- */
155 pt_lofig_tmp = pt_lofig;
156 MVL_LOFPNT = (lofig_list *)mbkalloc(sizeof(lofig_list));
157 MVL_LOFPNT->MODE = 'A';
158 MVL_LOFPNT->NAME = namealloc(figname);
159 MVL_LOFPNT->MODELCHAIN = NULL;
160 MVL_LOFPNT->LOINS = NULL;
161 MVL_LOFPNT->LOTRS = NULL;
162 MVL_LOFPNT->LOCON = NULL;
163 MVL_LOFPNT->LOSIG = NULL;
164 mbk_init_NewBKSIG(&MVL_LOFPNT->BKSIG);
165 MVL_LOFPNT->USER = NULL;
166 MVL_LOFPNT->NEXT = NULL;
167
168 MVL_MBKMOD = 'A';
169
170 if(mvl_scompparse() != 0)
171 {
172 (void)fprintf(stderr,"\n*** mbk error *** abnormal parsing for : %s\n",filename);
173 FAST_MODE = local_mbk_fast_mode;
174 EXIT(1);
175 }
176 /* ---------------------------------------------------------------- */
177 /* Now, with the new figure, we duplicate the new informations */
178 /* to fill the old one. */
179 /* ---------------------------------------------------------------- */
180 pt_lofig = mvl_fill(pt_lofig_tmp, MVL_LOFPNT);
181 }
182
183 MVL_MBKMOD = mode;
184 /* Closing file */
185 if(fclose(mvl_scompin) != 0)
186 {
187 (void)fprintf(stderr,"\n*** mbk error *** can't close file : %s\n",filename);
188 FAST_MODE = local_mbk_fast_mode;
189 EXIT(1);
190 }
191
192 if(strcmp(IN_LO,"vbe") == 0)
193 {
194 strcpy(IN_LO,"vst");
195 return;
196 }
197
198 if (mode == 'P' )
199 {
200 pt_locon = MVL_LOFPNT->LOCON;
201 while (pt_locon != NULL)
202 {
203 if (pt_locon->TYPE == 'I')
204 {
205 pt_loconaux = pt_locon;
206 pt_locon = pt_locon->NEXT;
207 dellocon(MVL_LOFPNT, pt_loconaux->NAME);
208 }
209 else
210 {
211 /* pt_locon->SIG = NULL; */
212 pt_locon = pt_locon->NEXT;
213 }
214 }
215 pt_losig = MVL_LOFPNT->LOSIG;
216 while (pt_losig != NULL)
217 {
218 if (pt_losig->TYPE == 'E')
219 {
220 pt_losig = pt_losig->NEXT;
221 continue;
222 }
223 pt_losigaux = pt_losig;
224 pt_losig = pt_losig->NEXT;
225 dellosig(MVL_LOFPNT, pt_losigaux->INDEX);
226 }
227 pt_loins = MVL_LOFPNT->LOINS;
228 while (pt_loins != NULL)
229 {
230 pt_loinsaux = pt_loins;
231 pt_loins = pt_loins->NEXT;
232 delloins(MVL_LOFPNT, pt_loinsaux->INSNAME);
233 }
234 }
235 FAST_MODE = local_mbk_fast_mode;
236 }