Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / mbkspf / spf_annot.c
1 /****************************************************************************/
2 /* */
3 /* Chaine de CAO & VLSI AVERTEC */
4 /* */
5 /* Produit : SPF Version 1.00 */
6 /* Fichier : spf_annot.c */
7 /* */
8 /* (c) copyright 2000 AVERTEC */
9 /* Tous droits reserves */
10 /* */
11 /* Auteur(s) : Gilles Augustins */
12 /* */
13 /****************************************************************************/
14
15 /****************************************************************************/
16 /* includes */
17 /****************************************************************************/
18
19 #include AVT_H
20 #include "spf_annot.h"
21 #include "spf_actions.h"
22 #include "spf_util.h"
23
24 /****************************************************************************/
25 /* globals */
26 /****************************************************************************/
27
28 lofig_list *spf_Lofig ;
29 int spf_Line ;
30 int spf_Mode ;
31
32 /****************************************************************************/
33 /* externs */
34 /****************************************************************************/
35
36 extern int spfparse() ;
37 extern FILE *spfin ;
38 extern int spf_missing_signals;
39 int /*SPF_KEEPM, SPF_KEEPX,*/ SPF_PREVERSE_RC, SPF_CARDS;
40
41 /****************************************************************************/
42 /* functions */
43 /****************************************************************************/
44
45 static void spf_checkenv()
46 {
47 char *env;
48 int SPF_KEEPM, SPF_KEEPX;
49 mbk_options_pack_struct spf_device_opack[] = {
50 {"Transistor", KEEP__TRANSISTOR},
51 {"Resistance", KEEP__RESISTANCE},
52 {"Instance", KEEP__INSTANCE},
53 {"Capacitance", KEEP__CAPA},
54 {"Diode", KEEP__DIODE},
55 {"None", KEEP__NONE},
56 {"All", KEEP__ALL}
57 };
58
59 SPF_KEEPM=1;
60 SPF_KEEPX=1;
61
62
63 SPF_PREVERSE_RC=0;
64
65 SPF_KEEPM=V_BOOL_TAB[__ANNOT_KEEP_M].VALUE;
66 SPF_KEEPX=V_BOOL_TAB[__ANNOT_KEEP_X].VALUE;
67 SPF_PREVERSE_RC=V_BOOL_TAB[__DSPF_PRESERVE_RC].VALUE;
68
69 SPF_CARDS =
70 mbk_ReadFlags (__ANNOT_KEEP_CARDS, spf_device_opack,
71 sizeof (spf_device_opack) / sizeof (*spf_device_opack), 1, 0);
72
73 if (SPF_CARDS!=0)
74 {
75 if (SPF_CARDS & KEEP__NONE)
76 SPF_CARDS = 0;
77
78 if (SPF_CARDS & KEEP__TRANSISTOR) SPF_KEEPM=1; else SPF_KEEPM=0;
79 if (SPF_CARDS & KEEP__INSTANCE) SPF_KEEPX=1; else SPF_KEEPX=0;
80 }
81 else
82 {
83 if (SPF_KEEPM) SPF_CARDS|=KEEP__TRANSISTOR;
84 if (SPF_KEEPX) SPF_CARDS|=KEEP__INSTANCE;
85 }
86 }
87
88
89 void spf_Annotate(lofig_list *ptlofig)
90 {
91 char buf[1024];
92 groundlosig = NULL;
93
94 spf_checkenv();
95
96 if ((spfin = mbkfopen(ptlofig->NAME, IN_PARASITICS, READ_TEXT))!=NULL)
97 {
98 spf_Lofig = ptlofig;
99 spf_Line = 1;
100 sprintf(buf,"%s.%s",ptlofig->NAME, IN_PARASITICS);
101 spf_ParsedFile=buf;
102
103 // spf_destroyexistingRC(spf_Lofig);
104 spf_initBUSDelimiters("", ""); // no delimiter
105 spf_setDelimiter('.');
106 spf_setDivider('|');
107 spf_missing_signals=0;
108
109 spfparse();
110
111 spf_destroy_lotrs_htable();
112 spf_destroy_loins_htable();
113 spf_destroy_losig_htable();
114 spf_finish_pending_capacitances();
115
116 if (spf_missing_signals>0)
117 {
118 avt_errmsg(SPF_ERRMSG, "021", AVT_WARNING, spf_missing_signals);
119 }
120 spf_checklofigsignal(spf_Lofig);
121 fclose(spfin);
122 mbk_commit_errors(spf_ParsedFile);
123 }
124 }
125
126 void parsespf(char *filename)
127 {
128 char buf[1024], *fp;
129 groundlosig = NULL;
130
131 spf_checkenv();
132
133 if ((spfin = mbkfopen(filename, NULL, READ_TEXT))!=NULL)
134 {
135 spf_Lofig = NULL;
136 spf_Line = 1;
137 if ((fp=filepath(filename, NULL))!=NULL)
138 strcpy(buf,filepath(filename, NULL));
139 else
140 strcpy(buf,filename);
141 spf_ParsedFile=buf;
142
143 // spf_destroyexistingRC(spf_Lofig);
144 spf_initBUSDelimiters("", ""); // no delimiter
145 spf_setDelimiter('.');
146 spf_setDivider('|');
147 spf_missing_signals=0;
148
149 spfparse();
150
151 spf_destroy_lotrs_htable();
152 spf_destroy_loins_htable();
153 spf_destroy_losig_htable();
154 spf_finish_pending_capacitances();
155
156 if (spf_missing_signals>0)
157 {
158 avt_errmsg(SPF_ERRMSG, "021", AVT_WARNING, spf_missing_signals);
159 }
160 spf_checklofigsignal(spf_Lofig);
161 fclose(spfin);
162 mbk_commit_errors(spf_ParsedFile);
163 }
164 else
165 avt_errmsg(SPF_ERRMSG, "024", AVT_FATAL, filename);
166
167 }