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 : mailto:alliance-users@asim.lip6.fr
8 *
9 * This progam is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 */
23
24 /****************************************************************************/
25 /* */
26 /* ALLIANCE CAO & VLSI CAD */
27 /* */
28 /* Product : (S)ymbolic (2)to (R)eal translater */
29 /* File : main.c */
30 /* */
31 /* (c) copyright 1992 MASI laboratory CAO & VLSI team */
32 /* All Right Reserved */
33 /* Support : e-mail cao-vlsi@masi.ibp.fr */
34 /* */
35 /****************************************************************************/
36 /* */
37 /* Main of Symbolic to Real */
38 /* */
39 /****************************************************************************/
40
41 #ident "@(#)s2r 3.8 30/01/02 ALLIANCE 4.5 (S)ymbolic (2)to (R)eal converter"
42
43 #include <string.h>
44
45 #include <mph.h>
46 #include <mut.h>
47 #include <rds.h>
48 #include <rwi.h>
49 #include <rtl.h>
50 #include <rut.h>
51 #include <rfm.h>
52 #include <rpr.h>
53
54 #include "generic.h"
55 #include "rdsacces.h"
56 #include "statistics.h"
57 #include "postrat.h"
58
Usage(Name)59 void Usage (Name)
60 char *Name;
61 {
62 fprintf (stderr, "\tUsage : %s [-1cCinstrv] source [result]\n\n", Name);
63 fprintf (stderr, "\tsource\t: filename of symbolic layout circuit\n");
64 fprintf (stderr, "\t\t to translate to real layout\n");
65 fprintf (stderr, "\tresult\t: result filename of real layout circuit\n");
66 fprintf (stderr, "\t\t source name is used, if result is absent\n\n");
67 fprintf (stderr, "\toptionnal options (any order, any occurence) :\n");
68 fprintf (stderr, "\t-1\t: only (1) level is translated, all otherwise.\n");
69 fprintf (stderr, "\t-c\t: deletes top-level (c)onnectors, keeps all others\n");
70 fprintf (stderr, "\t-C\t: keeps top-level (c)onnectors, deletes all others\n");
71 fprintf (stderr, "\t-i\t: generate implants from NWELL\n");
72 fprintf (stderr, "\t-n\t: deletes all signal names, but connectors\n");
73 fprintf (stderr, "\t-s\t: (s)cotchs are created\n");
74 fprintf (stderr, "\t-t\t: layout is just (t)ranslated, not post-treated\n");
75 fprintf (stderr, "\t-r\t: black boxes are not (r)eplaced\n");
76 fprintf (stderr, "\t-v\t: (v)erbose mode armed\n");
77 exit (1);
78 }
79
main(argc,argv)80 int main (argc, argv)
81 int argc;
82 char **argv;
83 {
84 rdsfig_list *rds_model;
85 phfig_list *mbk_model;
86
87 /*\
88 * banner and parameters
89 \*/
90
91 char *source_name = NULL; /* need default values */
92 char *result_name = NULL; /* need default values */
93 int root_conn = 1; /* keep top-level figure connectors by default */
94 int sub_conn = 1; /* keep sub-level figure connectors by default */
95 int signal_name = 1; /* keep signal names by default */
96 int autoimp = 0; /* do not generate implant from NWELL by default */
97 int scotch_on = 0; /* scotchs are not created by default */
98 int one_level = 0; /* all hierarchy level translated by default */
99 int do_post_treat = 1; /* post-treatment is done by default */
100 int do_replace_cells = 1; /* cells_replacement is done by default */
101 int verbose = 0; /* verbose mode desarmed by default */
102 int flat = 0; /* flat mode desarmed by default */
103 int physical = 0; /* physical mode desarmed by default */
104 int split_layer = 0; /* split_layer mode desarmed by default */
105 int shift;
106
107 alliancebanner ("s2r", VERSION, "Symbolic to Real layout converter", "2002", ALLIANCE_VERSION);
108
109 {
110 char *debug_env;
111 if ((debug_env = getenv ("S2RDEBUG")) != NULL)
112 {
113 unsigned char v = *debug_env - '0';
114 s2rdebug = (v <= 9) ? v : 0;
115 }
116 }
117
118 if (argc < 2)
119 Usage (argv[0]);
120
121 mbkenv ();
122 rdsenv ();
123
124 for (shift = 1; shift < argc; shift++)
125 {
126 char *arg = argv[shift];
127 if (*arg == '-')
128 {
129 while (*++arg)
130 {
131 switch (*arg)
132 {
133 case 'C':
134 sub_conn = 0;
135 break;
136 case 'c':
137 root_conn = 0;
138 break;
139 case 'n':
140 signal_name = 0;
141 break;
142 case 'i':
143 autoimp = 1;
144 break;
145 case 's':
146 scotch_on = 1;
147 break;
148 case '1':
149 one_level = 1;
150 break;
151 case 't':
152 do_post_treat = 0;
153 break;
154 case 'r':
155 do_replace_cells = 0;
156 break;
157 case 'v':
158 verbose = 1;
159 break;
160 case 'l':
161 split_layer = 1;
162 break;
163 case 'f':
164 flat = 1;
165 break;
166 case 'p':
167 physical = 1;
168 break;
169 default:
170 Usage (argv[0]);
171 }
172 }
173 }
174 else
175 {
176 if (!source_name)
177 source_name = namealloc (argv[shift]);
178 else if (!result_name)
179 {
180 result_name = namealloc (argv[shift]);
181 }
182 else
183 Usage (argv[0]);
184 continue;
185 }
186 }
187
188 if (!source_name)
189 {
190 Usage (argv[0]);
191 }
192
193 if (!result_name)
194 {
195 result_name = source_name;
196 }
197
198 /*\
199 * setting environement
200 * MBK_CATAL_NAME : file where file name to be replaced are put
201 * MBK_CATA_LIB : where cells, catal file and techno file are
202 * MBK_WORK_LIB : where result file is written or where techno file is
203 * WORK_LIB is watched before CATA_LIB
204 * MBK_WORK_LIB : where result file is placed
205 * MBK_IN_PH : file format of symbolic figure
206 * RDS_TECHNO_NAME : techno file name
207 * RDS_IN : file format of real figures to replace
208 * RDS_OUT : file format of result file
209 \*/
210
211 /*\
212 * Read the techno file
213 \*/
214 printf ("\n\to loading technology file : %s\n", RDS_TECHNO_NAME);
215 fflush (stdout);
216 loadrdsparam ();
217
218 /*
219 printf ("RDS_UNIT %ld\n", RDS_UNIT);
220 printf ("RDS_PHYSICAL_GRID %ld\n", RDS_PHYSICAL_GRID);
221 */
222
223 /*\
224 * Read the model file
225 \*/
226 if (physical)
227 {
228 printf ("\to loading %s level of real layout : %s\n", one_level ? "one" : "all", source_name);
229 fflush (stdout);
230 rds_model = getrdsfig (source_name, one_level ? 'P' : 'A', 0);
231 }
232 else
233 {
234 printf ("\to loading %s level of symbolic layout : %s\n", one_level ? "one" : "all", source_name);
235 fflush (stdout);
236
237 mbk_model = getphfig (source_name, 'A');
238 if (!root_conn)
239 mbk_model->PHCON = NULL;
240 rds_model = S2Rfigmbkrds (mbk_model, one_level ? 0 : 1, sub_conn);
241
242 /* Removing symbolic data structure */
243
244 printf ("\to removing symbolic data structure \n");
245 rds_mbk_kill ();
246 }
247
248 /*\
249 * flattening
250 \*/
251 if (flat)
252 {
253 printf ("\to flattening figure\n");
254 rflattenrdsfig (rds_model, RDS_NO, RDS_NO);
255 }
256
257 /*\
258 * post treatement
259 \*/
260 rds_model = rds_model_out (source_name);
261
262 if (do_post_treat)
263 {
264 printf ("\to layout post-treating\n ");
265 if (root_conn)
266 printf ("\t\twith top connectors,\n ");
267 else
268 printf ("\t\twithout top connector,\n ");
269 if (sub_conn)
270 printf ("\t\twith sub connectors,\n ");
271 else
272 printf ("\t\twithout sub connector,\n ");
273 if (signal_name)
274 printf ("\t\twith signal names,\n ");
275 else
276 printf ("\t\twithout signal name,\n ");
277 if (scotch_on)
278 printf ("\t\twith scotchs.\n");
279 else
280 printf ("\t\twithout scotch.\n");
281 post_treat (rds_model, scotch_on, verbose, autoimp);
282 fflush (stdout);
283 }
284
285 /*\
286 * Replace cells
287 \*/
288
289 if (do_replace_cells)
290 {
291 replace_cells (verbose);
292 }
293
294 /*\
295 * save file
296 \*/
297 printf ("\to saving %s.%s\n", result_name, RDS_OUT);
298 rds_model->NAME = result_name;
299
300 if (split_layer)
301 {
302 char *RDS_CIF_LAYER_TABLE_BAK[RDS_ALL_LAYER][RDS_CIF_LAYER_FIELD];
303 unsigned char RDS_GDS_LAYER_TABLE_BAK[RDS_ALL_LAYER][RDS_GDS_LAYER_FIELD];
304 char WORK_LIB_TMP[256];
305 char WORK_LIB_BAK[256];
306 int layer;
307
308 strcpy (WORK_LIB_BAK, WORK_LIB);
309 for (layer = 0; layer < RDS_ALL_LAYER; layer++)
310 {
311 *strchr (RDS_LAYER_NAME[layer], ' ') = '\0';
312 RDS_CIF_LAYER_TABLE_BAK[layer][0] = RDS_CIF_LAYER_TABLE[layer][0];
313 RDS_GDS_LAYER_TABLE_BAK[layer][0] = RDS_GDS_LAYER_TABLE[layer][0];
314 RDS_GDS_LAYER_TABLE[layer][0] = RDS_GDS_LAYER_EMPTY;
315 RDS_CIF_LAYER_TABLE[layer][0] = RDS_CIF_LAYER_EMPTY;
316 }
317
318 for (layer = 0; layer < RDS_ALL_LAYER; layer++)
319 {
320 if (!strcmp (RDS_OUT, "gds"))
321 {
322 if (RDS_GDS_LAYER_TABLE_BAK[layer][0] != RDS_GDS_LAYER_EMPTY)
323 {
324 sprintf (WORK_LIB_TMP, "%s/%s/", WORK_LIB_BAK, RDS_LAYER_NAME[layer]);
325 WORK_LIB = WORK_LIB_TMP;
326 if (verbose)
327 {
328 printf ("\t - %s\n", WORK_LIB);
329 fflush (stdout);
330 }
331
332 RDS_GDS_LAYER_TABLE[layer][0] = RDS_GDS_LAYER_TABLE_BAK[layer][0];
333 saverdsfig (rds_model);
334 RDS_GDS_LAYER_TABLE[layer][0] = RDS_GDS_LAYER_EMPTY;
335 }
336 }
337 else
338 {
339 if (RDS_CIF_LAYER_TABLE_BAK[layer][0] != RDS_CIF_LAYER_EMPTY)
340 {
341 sprintf (WORK_LIB_TMP, "%s/%s/", WORK_LIB_BAK, RDS_LAYER_NAME[layer]);
342 WORK_LIB = WORK_LIB_TMP;
343 if (verbose)
344 {
345 printf ("\t - %s\n", WORK_LIB);
346 fflush (stdout);
347 }
348
349 RDS_CIF_LAYER_TABLE[layer][0] = RDS_CIF_LAYER_TABLE_BAK[layer][0];
350 saverdsfig (rds_model);
351 RDS_CIF_LAYER_TABLE[layer][0] = RDS_CIF_LAYER_EMPTY;
352 }
353 }
354 }
355 }
356 else
357 saverdsfig (rds_model);
358
359 if (verbose)
360 print_statistics (scotch_on);
361
362 return (0);
363 }
364