2 * This file is part of the Alliance CAD System
3 * Copyright (C) Laboratoire LIP6 - Département ASIM
4 * Universite Pierre et Marie Curie
6 * Home page : http://www-asim.lip6.fr/alliance/
7 * E-mail support : mailto:alliance-support@asim.lip6.fr
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.
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.
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.
24 /*******************************************************************************
25 * mbk : hilo driver, mainly used as format for hardware test machine interface *
26 * written by Alain Greiner in october 1990 *
28 * mbk vector support by Fred Petrot, june 1992 *
30 * signal names are are prefixed by 'hilosig_' Olivier, September 94 *
31 * instances names are are prefixed by 'hilog_' Olivier, September 94 *
33 * date : 20 septembre 1994 *
34 *******************************************************************************/
41 /*******************************************************************************
42 * function legal_instance_name : prefixe le nom de l'instance avec "hilo_"
43 * et remplace '[',']' et '.' avec `_`
44 *******************************************************************************/
45 static char *legal_instance_name(s
)
48 static char buffer
[255];
51 sprintf(buffer
,"hilo_%s",s
);
54 while (buffer
[i
] != 0) {
55 if ((buffer
[i
] == '[') || (buffer
[i
] == ']') || (buffer
[i
] == '.'))
62 /*******************************************************************************
63 * function legal_signal_name : prefixe le nom du signal avec "hilosig_"
64 * et remplace '[',']',' ' et '.' avec `_`
65 *******************************************************************************/
66 static char *legal_signal_name(s
)
69 static char buffer
[255];
72 sprintf(buffer
,"hilosig_%s",s
);
75 while (buffer
[i
] != 0) {
76 if ((buffer
[i
] == '[') || (buffer
[i
] == ']') ||
77 (buffer
[i
] == ' ') || (buffer
[i
] == '.'))
84 /*******************************************************************************
85 * function busname : returns a legal hilo vector *
86 *******************************************************************************/
87 static char *busname(name
)
90 static char buffer
[255], *s
, *t
;
118 /*******************************************************************************
119 * function hilosavelofig *
120 *******************************************************************************/
122 void hilosavelofig(ptfig
)
125 loins_list
*ptins
= NULL
;
126 locon_list
*ptcon
= NULL
;
127 locon_list
*ptscan
= NULL
;
128 locon_list
*pt1
= NULL
;
129 locon_list
*pt2
= NULL
;
130 locon_list
*pthead
= NULL
;
131 locon_list
*ptsav
= NULL
;
132 losig_list
*ptsig
= NULL
;
133 losig_list
*ptsigdif
= NULL
;
134 lofig_list
*ptnewfig
= NULL
;
137 char *SigName
= NULL
;
140 if ((ptfile
= mbkfopen(ptfig
->NAME
, OUT_LO
, WRITE_TEXT
)) == NULL
)
142 (void)fprintf(stderr
, "*** mbk error ***\n");
143 (void)fprintf(stderr
, "cannot open file %s.%s\n", ptfig
->NAME
, OUT_LO
);
147 /* check signal name unicity */
149 for (ptsig
= ptfig
->LOSIG
; ptsig
->NEXT
; ptsig
= ptsig
->NEXT
)
151 amatla
= getsigname(ptsig
);
152 for (ptsigdif
= ptsig
->NEXT
; ptsigdif
; ptsigdif
= ptsigdif
->NEXT
)
153 if(amatla
== getsigname(ptsigdif
))
154 ptsig
->NAMECHAIN
= ptsigdif
->NAMECHAIN
= NULL
;
157 /* reverse external connectors & instances */
159 ptfig
->LOCON
= (locon_list
*)reverse((chain_list
*)ptfig
->LOCON
);
160 ptfig
->LOINS
= (loins_list
*)reverse((chain_list
*)ptfig
->LOINS
);
162 /* restore connector order for instances */
164 for (ptins
= ptfig
->LOINS
; ptins
; ptins
= ptins
->NEXT
)
167 ptnewfig
= getlofig(ptins
->FIGNAME
, 'P');
168 for (pt1
= ptnewfig
->LOCON
; pt1
; pt1
= pt1
->NEXT
)
170 for (pt2
= ptins
->LOCON
; pt2
; pt2
= pt2
->NEXT
)
172 if (pt2
->NAME
== pt1
->NAME
) break;
177 (void)fprintf(stderr
, "*** mbk error ***\n");
178 (void)fprintf(stderr
, "interface discrepancy between ");
179 (void)fprintf(stderr
, "instance %s and model %s",
180 ptins
->INSNAME
, ptins
->FIGNAME
);
181 (void)fprintf(stderr
, " driving file %s.cct\n", ptfig
->NAME
);
184 else if (pt2
== ptins
->LOCON
)
186 ptins
->LOCON
= pt2
->NEXT
;
190 ptsav
->NEXT
= pt2
->NEXT
;
195 if (ptins
->LOCON
!= NULL
)
197 (void)fprintf(stderr
, "*** mbk error ***\ninterface discrepancy");
198 (void)fprintf(stderr
, "between instance %s and", ptins
->INSNAME
);
199 (void)fprintf(stderr
, " model %s", ptins
->FIGNAME
);
200 (void)fprintf(stderr
, " driving file %s.cct\n", ptfig
->NAME
);
203 ptins
->LOCON
= pthead
;
206 (void)fprintf(ptfile
, "CIRCUIT %s(\n", ptfig
->NAME
);
208 for (ptcon
= ptfig
->LOCON
; ptcon
; ptcon
= ptcon
->NEXT
) {
209 if (mbk_LosigIsVDD(ptcon
->SIG
)) {
210 (void)fprintf(ptfile
, " supply1 %s", busname(ptcon
->NAME
));
213 if (mbk_LosigIsVSS(ptcon
->SIG
)) {
214 (void)fprintf(ptfile
, " supply0 %s", busname(ptcon
->NAME
));
217 switch (ptcon
->DIRECTION
)
223 (void)fprintf(ptfile
, " bidir %s", busname(ptcon
->NAME
));
226 (void)fprintf(ptfile
, " input %s", busname(ptcon
->NAME
));
230 (void)fprintf(ptfile
, " output %s", busname(ptcon
->NAME
));
233 (void)fprintf(stdout
,"Unknown direction on terminal %s :\n",
237 if (ptcon
->NEXT
!= NULL
) (void)fputs(",\n", ptfile
);
240 (void)fputs(");\n", ptfile
);
242 for (ptins
= ptfig
->LOINS
; ptins
; ptins
= ptins
->NEXT
)
244 strcpy(Buffer
,legal_instance_name(ptins
->INSNAME
));
245 fprintf(ptfile
, "%s %s(\n", ptins
->FIGNAME
, Buffer
);
246 for (ptcon
= ptins
->LOCON
; ptcon
; ptcon
= ptcon
->NEXT
)
248 ptsig
= getlosig(ptfig
, ptcon
->SIG
->INDEX
);
249 if (ptsig
->TYPE
== 'I')
251 SigName
= getsigname(ptsig
);
252 fprintf(ptfile
, " %s", legal_signal_name(SigName
));
256 for (ptscan
= ptfig
->LOCON
; ptscan
; ptscan
= ptscan
->NEXT
)
258 if (ptscan
->SIG
== ptsig
) break;
262 (void)fprintf(stderr
, "*** mbk error ***\nno external connec");
263 (void)fprintf(stderr
, "tor driving file %s.cct\n", ptfig
->NAME
);
267 fprintf(ptfile
, " %s", busname(ptscan
->NAME
));
270 if (ptcon
->NEXT
!= NULL
)
272 (void)fputs(",\n", ptfile
);
275 (void)fputs(");\n", ptfile
);
277 (void)fputs("ENDCIRCUIT\n", ptfile
);
278 dellofig(ptfig
->NAME
);
279 (void)fclose(ptfile
);