ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
mio.c
Go to the documentation of this file.
1
18
19//#define _BSD_SOURCE
20
21#ifndef WIN32
22#ifndef _DEFAULT_SOURCE
23#define _DEFAULT_SOURCE
24#endif
25#include <unistd.h>
26#endif
27
28#include "base/main/main.h"
29#include "mio.h"
30#include "map/mapper/mapper.h"
31#include "map/amap/amap.h"
32
34
35
39
40static int Mio_CommandReadLiberty( Abc_Frame_t * pAbc, int argc, char **argv );
41static int Mio_CommandReadGenlib( Abc_Frame_t * pAbc, int argc, char **argv );
42static int Mio_CommandWriteGenlib( Abc_Frame_t * pAbc, int argc, char **argv );
43static int Mio_CommandPrintGenlib( Abc_Frame_t * pAbc, int argc, char **argv );
44static int Mio_CommandReadProfile( Abc_Frame_t * pAbc, int argc, char **argv );
45static int Mio_CommandWriteProfile( Abc_Frame_t * pAbc, int argc, char **argv );
46static int Mio_CommandPrintProfile( Abc_Frame_t * pAbc, int argc, char **argv );
47
48/*
49// internal version of genlib library
50static char * pMcncGenlib[] = {
51 "GATE inv1 1 O=!a; PIN * INV 1 999 0.9 0.0 0.9 0.0\n",
52 "GATE inv2 2 O=!a; PIN * INV 2 999 1.0 0.0 1.0 0.0\n",
53 "GATE inv3 3 O=!a; PIN * INV 3 999 1.1 0.0 1.1 0.0\n",
54 "GATE inv4 4 O=!a; PIN * INV 4 999 1.2 0.0 1.2 0.0\n",
55 "GATE nand2 2 O=!(a*b); PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
56 "GATE nand3 3 O=!(a*b*c); PIN * INV 1 999 1.1 0.0 1.1 0.0\n",
57 "GATE nand4 4 O=!(a*b*c*d); PIN * INV 1 999 1.4 0.0 1.4 0.0\n",
58 "GATE nor2 2 O=!(a+b); PIN * INV 1 999 1.4 0.0 1.4 0.0\n",
59 "GATE nor3 3 O=!(a+b+c); PIN * INV 1 999 2.4 0.0 2.4 0.0\n",
60 "GATE nor4 4 O=!(a+b+c+d); PIN * INV 1 999 3.8 0.0 3.8 0.0\n",
61 "GATE xora 5 O=a*!b+!a*b; PIN * UNKNOWN 2 999 1.9 0.0 1.9 0.0\n",
62 "GATE xorb 5 O=!(a*b+!a*!b); PIN * UNKNOWN 2 999 1.9 0.0 1.9 0.0\n",
63 "GATE xnora 5 O=a*b+!a*!b; PIN * UNKNOWN 2 999 2.1 0.0 2.1 0.0\n",
64 "GATE xnorb 5 O=!(!a*b+a*!b); PIN * UNKNOWN 2 999 2.1 0.0 2.1 0.0\n",
65 "GATE aoi21 3 O=!(a*b+c); PIN * INV 1 999 1.6 0.0 1.6 0.0\n",
66 "GATE aoi22 4 O=!(a*b+c*d); PIN * INV 1 999 2.0 0.0 2.0 0.0\n",
67 "GATE oai21 3 O=!((a+b)*c); PIN * INV 1 999 1.6 0.0 1.6 0.0\n",
68 "GATE oai22 4 O=!((a+b)*(c+d)); PIN * INV 1 999 2.0 0.0 2.0 0.0\n",
69 "GATE buf 1 O=a; PIN * NONINV 1 999 1.0 0.0 1.0 0.0\n",
70 "GATE zero 0 O=CONST0;\n",
71 "GATE one 0 O=CONST1;\n",
72 NULL
73};
74*/
75
76// internal version of genlib library
77static char * pAndGenlib[] = {
78 "GATE zero 0 O=CONST0;\n",
79 "GATE one 0 O=CONST1;\n",
80 "GATE buf 1 O=a; PIN * NONINV 1 999 1.0 0.0 1.0 0.0\n",
81 "GATE inv 1 O=!a; PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
82 "GATE and00 1 O=a*b; PIN * NONINV 1 999 1.0 0.0 1.0 0.0\n",
83 "GATE and01 1 O=a*!b; PIN * NONINV 1 999 1.0 0.0 1.0 0.0\n",
84 "GATE and10 1 O=!a*b; PIN * NONINV 1 999 1.0 0.0 1.0 0.0\n",
85 "GATE and11 1 O=!a*!b; PIN * NONINV 1 999 1.0 0.0 1.0 0.0\n",
86 "GATE nand00 1 O=!(a*b); PIN * NONINV 1 999 1.0 0.0 1.0 0.0\n",
87 "GATE nand01 1 O=!(a*!b); PIN * NONINV 1 999 1.0 0.0 1.0 0.0\n",
88 "GATE nand10 1 O=!(!a*b); PIN * NONINV 1 999 1.0 0.0 1.0 0.0\n",
89 "GATE nand11 1 O=!(!a*!b); PIN * NONINV 1 999 1.0 0.0 1.0 0.0\n",
90 NULL
91};
92
93// internal version of genlib library
94static char * pSimpleGenlib[] = {
95 "GATE zero 0 O=CONST0;\n",
96 "GATE one 0 O=CONST1;\n",
97 "GATE buf 4 O=a; PIN * NONINV 1 999 1.0 0.0 1.0 0.0\n",
98 "GATE inv 2 O=!a; PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
99 "GATE nand2 4 O=!(a*b); PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
100 "GATE nand3 6 O=!(a*b*c); PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
101 "GATE nor2 4 O=!(a+b); PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
102 "GATE nor3 6 O=!(a+b+c); PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
103 "GATE aoi21 6 O=!(a*b+c); PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
104 "GATE oai21 6 O=!((a+b)*c); PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
105 "GATE aoi22 8 O=!(a*b+c*d); PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
106 "GATE oai22 8 O=!((a+b)*(c+d)); PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
107 NULL
108};
109
110// internal version of genlib library
111static char * pSimpleGenlib2[] = {
112 "GATE zero 0 O=CONST0;\n",
113 "GATE one 0 O=CONST1;\n",
114 "GATE buf 4 O=a; PIN * NONINV 1 999 1.0 0.0 1.0 0.0\n",
115 "GATE inv 2 O=!a; PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
116 "GATE nand2 4 O=!(a*b); PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
117 "GATE nand3 6 O=!(a*b*c); PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
118 "GATE nand4 8 O=!(a*b*c*d); PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
119 "GATE nor2 4 O=!(a+b); PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
120 "GATE nor3 6 O=!(a+b+c); PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
121 "GATE nor4 6 O=!(a+b+c+d); PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
122 "GATE aoi21 6 O=!(a*b+c); PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
123 "GATE oai21 6 O=!((a+b)*c); PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
124 "GATE aoi22 8 O=!(a*b+c*d); PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
125 "GATE oai22 8 O=!((a+b)*(c+d)); PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
126 "GATE aoi211 8 O=!(a*b+c+d); PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
127 "GATE oai211 8 O=!((a+b)*c*d); PIN * INV 1 999 1.0 0.0 1.0 0.0\n",
128 NULL
129};
130
134
147{
148 extern Mio_Library_t * Mio_LibraryReadBuffer( char * pBuffer, int fExtendedFormat, st__table * tExcludeGate, int nFaninLimit, int fVerbose );
149 Vec_Str_t * vLibStr = Vec_StrAlloc( 1000 );
150 for ( int i = 0; pAndGenlib[i]; i++ )
151 Vec_StrAppend( vLibStr, pAndGenlib[i] );
152 Vec_Str_t * vLibStr2 = Vec_StrDup( vLibStr );
153 Vec_StrAppend( vLibStr2, ".end\n" );
154 Vec_StrPush( vLibStr2, '\0' );
155 Vec_StrPush( vLibStr, '\0' );
156 Mio_UpdateGenlib2( vLibStr, vLibStr2, "and.genlib", 0 );
157 Vec_StrFree( vLibStr );
158 Vec_StrFree( vLibStr2 );
159}
161{
162 extern Mio_Library_t * Mio_LibraryReadBuffer( char * pBuffer, int fExtendedFormat, st__table * tExcludeGate, int nFaninLimit, int fVerbose );
163 Mio_Library_t * pLib; int i;
164 Vec_Str_t * vLibStr = Vec_StrAlloc( 1000 );
165 for ( i = 0; pSimpleGenlib[i]; i++ )
166 Vec_StrAppend( vLibStr, pSimpleGenlib[i] );
167 Vec_StrPush( vLibStr, '\0' );
168 pLib = Mio_LibraryReadBuffer( Vec_StrArray(vLibStr), 0, NULL, 0, 0 );
169 Mio_LibrarySetName( pLib, Abc_UtilStrsav("simple.genlib") );
170 Mio_UpdateGenlib( pLib );
171 Vec_StrFree( vLibStr );
172}
174{
175 extern Mio_Library_t * Mio_LibraryReadBuffer( char * pBuffer, int fExtendedFormat, st__table * tExcludeGate, int nFaninLimit, int fVerbose );
176 Mio_Library_t * pLib; int i;
177 Vec_Str_t * vLibStr = Vec_StrAlloc( 1000 );
178 for ( i = 0; pSimpleGenlib2[i]; i++ )
179 Vec_StrAppend( vLibStr, pSimpleGenlib2[i] );
180 Vec_StrPush( vLibStr, '\0' );
181 pLib = Mio_LibraryReadBuffer( Vec_StrArray(vLibStr), 0, NULL, 0, 0 );
182 Mio_LibrarySetName( pLib, Abc_UtilStrsav("simple2.genlib") );
183 Mio_UpdateGenlib( pLib );
184 Vec_StrFree( vLibStr );
185}
186
198void Mio_Init( Abc_Frame_t * pAbc )
199{
200// Cmd_CommandAdd( pAbc, "SC mapping", "read_liberty", Mio_CommandReadLiberty, 0 );
201
202 Cmd_CommandAdd( pAbc, "SC mapping", "read_genlib", Mio_CommandReadGenlib, 0 );
203 Cmd_CommandAdd( pAbc, "SC mapping", "write_genlib", Mio_CommandWriteGenlib, 0 );
204 Cmd_CommandAdd( pAbc, "SC mapping", "print_genlib", Mio_CommandPrintGenlib, 0 );
205
206 Cmd_CommandAdd( pAbc, "SC mapping", "read_profile", Mio_CommandReadProfile, 0 );
207 Cmd_CommandAdd( pAbc, "SC mapping", "write_profile", Mio_CommandWriteProfile, 0 );
208 Cmd_CommandAdd( pAbc, "SC mapping", "print_profile", Mio_CommandPrintProfile, 0 );
209
210 Cmd_CommandAdd( pAbc, "SC mapping", "read_library", Mio_CommandReadGenlib, 0 );
211 Cmd_CommandAdd( pAbc, "SC mapping", "write_library", Mio_CommandWriteGenlib, 0 );
212 Cmd_CommandAdd( pAbc, "SC mapping", "print_library", Mio_CommandPrintGenlib, 0 );
213}
214
231
244{
245 // free the current superlib because it depends on the old Mio library
246 if ( Abc_FrameReadLibSuper() )
247 {
249 Abc_FrameSetLibSuper( NULL );
250 }
251
252 // replace the current library
254 Abc_FrameSetLibGen( pLib );
255
256 // replace the current library
258 Abc_FrameSetLibGen2( NULL );
259}
260int Mio_UpdateGenlib2( Vec_Str_t * vStr, Vec_Str_t * vStr2, char * pFileName, int fVerbose )
261{
262 Mio_Library_t * pLib;
263 // set the new network
264 pLib = Mio_LibraryRead( pFileName, Vec_StrArray(vStr), NULL, 0, fVerbose );
265 if ( pLib == NULL )
266 return 0;
267
268 // free the current superlib because it depends on the old Mio library
269 if ( Abc_FrameReadLibSuper() )
270 {
272 Abc_FrameSetLibSuper( NULL );
273 }
274
275 // replace the current library
277 Abc_FrameSetLibGen( pLib );
278
279 // set the new network
280 pLib = (Mio_Library_t *)Amap_LibReadAndPrepare( pFileName, Vec_StrArray(vStr2), 0, 0 );
281 if ( pLib == NULL )
282 return 0;
283
284 // replace the current library
286 Abc_FrameSetLibGen2( pLib );
287 return 1;
288}
289
301int Mio_CommandReadLiberty( Abc_Frame_t * pAbc, int argc, char **argv )
302{
303 int fUseFileInterface = 0;
304 char Command[1000];
305 FILE * pFile;
306 FILE * pOut, * pErr;
307 char * pFileName;
308 int fVerbose;
309 int c;
310
311 pOut = Abc_FrameReadOut(pAbc);
312 pErr = Abc_FrameReadErr(pAbc);
313
314 // set the defaults
315 fVerbose = 0;
317 while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF )
318 {
319 switch (c)
320 {
321 case 'v':
322 fVerbose ^= 1;
323 break;
324 case 'h':
325 goto usage;
326 break;
327 default:
328 goto usage;
329 }
330 }
331
332 if ( argc != globalUtilOptind + 1 )
333 goto usage;
334
335 // get the input file name
336 pFileName = argv[globalUtilOptind];
337 if ( (pFile = Io_FileOpen( pFileName, "open_path", "r", 0 )) == NULL )
338 {
339 fprintf( pErr, "Cannot open input file \"%s\". ", pFileName );
340 if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".genlib", ".lib", ".scl", ".g", NULL )) )
341 fprintf( pErr, "Did you mean \"%s\"?", pFileName );
342 fprintf( pErr, "\n" );
343 return 1;
344 }
345 fclose( pFile );
346
347 if ( fUseFileInterface )
348 {
349 if ( !Amap_LibertyParse( pFileName, fVerbose ) )
350 return 0;
351 assert( strlen(pFileName) < 900 );
352 sprintf( Command, "read_genlib %s", Extra_FileNameGenericAppend(pFileName, ".genlib") );
353 Cmd_CommandExecute( pAbc, Command );
354 }
355 else
356 {
357 Vec_Str_t * vStr, * vStr2;
358 int RetValue;
359 vStr = Amap_LibertyParseStr( pFileName, fVerbose );
360 if ( vStr == NULL )
361 return 0;
362 vStr2 = Vec_StrDup(vStr);
363 RetValue = Mio_UpdateGenlib2( vStr, vStr2, pFileName, fVerbose );
364 Vec_StrFree( vStr );
365 Vec_StrFree( vStr2 );
366 if ( !RetValue )
367 printf( "Reading library has filed.\n" );
368 }
369 return 0;
370
371usage:
372 fprintf( pErr, "usage: read_liberty [-vh]\n");
373 fprintf( pErr, "\t read standard cell library in Liberty format\n" );
374 fprintf( pErr, "\t (if the library contains more than one gate\n" );
375 fprintf( pErr, "\t with the same Boolean function, only the gate\n" );
376 fprintf( pErr, "\t with the smallest area will be used)\n" );
377 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
378 fprintf( pErr, "\t-h : enable verbose output\n");
379 return 1;
380}
381
393int Mio_CommandReadGenlib( Abc_Frame_t * pAbc, int argc, char **argv )
394{
395 FILE * pFile;
396 FILE * pOut, * pErr;
397 Mio_Library_t * pLib;
398 Amap_Lib_t * pLib2;
399 char * pFileName;
400 char * pExcludeFile = NULL;
401 double WireDelay = 0.0;
402 int fShortNames = 0;
403 int nFaninLimit = 0;
404 int c, fVerbose = 0;
405
406 pOut = Abc_FrameReadOut(pAbc);
407 pErr = Abc_FrameReadErr(pAbc);
409 while ( (c = Extra_UtilGetopt(argc, argv, "WEKnvh")) != EOF )
410 {
411 switch (c)
412 {
413 case 'W':
414 if ( globalUtilOptind >= argc )
415 {
416 Abc_Print( -1, "Command line switch \"-W\" should be followed by a floating point number.\n" );
417 goto usage;
418 }
419 WireDelay = (float)atof(argv[globalUtilOptind]);
421 if ( WireDelay <= 0.0 )
422 goto usage;
423 break;
424 case 'E':
425 if ( globalUtilOptind >= argc )
426 {
427 Abc_Print( -1, "Command line switch \"-E\" should be followed by a file name.\n" );
428 goto usage;
429 }
430 pExcludeFile = argv[globalUtilOptind];
432 break;
433 case 'K':
434 if ( globalUtilOptind >= argc )
435 {
436 Abc_Print( -1, "Command line switch \"-K\" should be followed by a file name.\n" );
437 goto usage;
438 }
439 nFaninLimit = atoi(argv[globalUtilOptind]);
441 break;
442 case 'n':
443 fShortNames ^= 1;
444 break;
445 case 'v':
446 fVerbose ^= 1;
447 break;
448 case 'h':
449 goto usage;
450 break;
451 default:
452 goto usage;
453 }
454 }
455 if ( argc != globalUtilOptind + 1 )
456 {
457 goto usage;
458 }
459
460 // get the input file name
461 pFileName = argv[globalUtilOptind];
462 if ( (pFile = Io_FileOpen( pFileName, "open_path", "r", 0 )) == NULL )
463 {
464 fprintf( pErr, "Cannot open input file \"%s\". ", pFileName );
465 if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".genlib", ".lib", ".scl", ".g", NULL )) )
466 fprintf( pErr, "Did you mean \"%s\"?", pFileName );
467 fprintf( pErr, "\n" );
468 return 1;
469 }
470 fclose( pFile );
471
472 // set the new network
473 pLib = Mio_LibraryRead( pFileName, NULL, pExcludeFile, nFaninLimit, fVerbose );
474 if ( pLib == NULL )
475 {
476 fprintf( pErr, "Reading genlib library has failed.\n" );
477 return 1;
478 }
479 if ( fVerbose )
480 printf( "Entered genlib library with %d gates from file \"%s\".\n", Mio_LibraryReadGateNum(pLib), pFileName );
481
482 // convert the library if needed
483 if ( fShortNames )
484 Mio_LibraryShortNames( pLib );
485
486 // add the fixed number (wire delay) to all delays in the library
487 if ( WireDelay != 0.0 )
488 Mio_LibraryShiftDelay( pLib, WireDelay );
489
490 // prepare libraries
491 Mio_UpdateGenlib( pLib );
492
493 // replace the current library
494 pLib2 = Amap_LibReadAndPrepare( pFileName, NULL, 0, 0 );
495 if ( pLib2 == NULL )
496 {
497 fprintf( pErr, "Reading second genlib library has failed.\n" );
498 return 1;
499 }
500 Abc_FrameSetLibGen2( pLib2 );
501 return 0;
502
503usage:
504 fprintf( pErr, "usage: read_genlib [-W float] [-E filename] [-K num] [-nvh]\n");
505 fprintf( pErr, "\t read the library from a genlib file\n" );
506 fprintf( pErr, "\t (if the library contains more than one gate\n" );
507 fprintf( pErr, "\t with the same Boolean function, only the gate\n" );
508 fprintf( pErr, "\t with the smallest area will be used)\n" );
509 fprintf( pErr, "\t-W float : wire delay (added to pin-to-pin gate delays) [default = %g]\n", WireDelay );
510 fprintf( pErr, "\t-E file : the file name with gates to be excluded [default = none]\n" );
511 fprintf( pErr, "\t-K num : the max number of gate fanins (0 = no limit) [default = %d]\n", nFaninLimit );
512 fprintf( pErr, "\t-n : toggle replacing gate/pin names by short strings [default = %s]\n", fShortNames? "yes": "no" );
513 fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
514 fprintf( pErr, "\t-h : enable verbose output\n");
515 return 1;
516}
517
529int Mio_CommandWriteGenlib( Abc_Frame_t * pAbc, int argc, char **argv )
530{
531 FILE * pOut, * pErr, * pFile;
532 char * pFileName;
533 int fSelected = 0;
534 int fVerilog = 0;
535 int fVerbose = 0;
536 int c;
537
538 pOut = Abc_FrameReadOut(pAbc);
539 pErr = Abc_FrameReadErr(pAbc);
540
542 while ( (c = Extra_UtilGetopt(argc, argv, "agvh")) != EOF )
543 {
544 switch (c)
545 {
546 case 'a':
547 fSelected ^= 1;
548 break;
549 case 'g':
550 fVerilog ^= 1;
551 break;
552 case 'v':
553 fVerbose ^= 1;
554 break;
555 case 'h':
556 goto usage;
557 break;
558 default:
559 goto usage;
560 }
561 }
562 if ( Abc_FrameReadLibGen() == NULL )
563 {
564 printf( "Library is not available.\n" );
565 return 1;
566 }
567 if ( argc != globalUtilOptind + 1 )
568 {
569 printf( "The file name is not given.\n" );
570 return 1;
571 }
572
573 pFileName = argv[globalUtilOptind];
574 pFile = fopen( pFileName, "w" );
575 if ( pFile == NULL )
576 {
577 printf( "Error! Cannot open file \"%s\" for writing the library.\n", pFileName );
578 return 1;
579 }
580 if ( fVerilog )
581 Mio_WriteLibraryVerilog( pFile, (Mio_Library_t *)Abc_FrameReadLibGen(), 0, 0, fSelected );
582 else
583 Mio_WriteLibrary( pFile, (Mio_Library_t *)Abc_FrameReadLibGen(), 0, 0, fSelected );
584 fclose( pFile );
585 printf( "The current genlib library is written into file \"%s\".\n", pFileName );
586 return 0;
587
588usage:
589 fprintf( pErr, "\nusage: write_genlib [-agvh] <file>\n");
590 fprintf( pErr, "\t writes the current genlib library into a file\n" );
591 fprintf( pErr, "\t-a : toggles writing min-area gates [default = %s]\n", fSelected? "yes" : "no" );
592 fprintf( pErr, "\t-g : toggles writing the library in Verilog [default = %s]\n", fVerilog? "yes" : "no" );
593 fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", fVerbose? "yes" : "no" );
594 fprintf( pErr, "\t-h : print the command usage\n");
595 fprintf( pErr, "\t<file> : optional file name to write the library\n");
596 return 1;
597}
598
610int Mio_CommandPrintGenlib( Abc_Frame_t * pAbc, int argc, char **argv )
611{
612 FILE * pOut, * pErr;
613 int fShort = 0;
614 int fSelected = 0;
615 int fVerbose = 0;
616 int c;
617
618 pOut = Abc_FrameReadOut(pAbc);
619 pErr = Abc_FrameReadErr(pAbc);
620
621 // set the defaults
623 while ( (c = Extra_UtilGetopt(argc, argv, "savh")) != EOF )
624 {
625 switch (c)
626 {
627 case 's':
628 fShort ^= 1;
629 break;
630 case 'a':
631 fSelected ^= 1;
632 break;
633 case 'v':
634 fVerbose ^= 1;
635 break;
636 case 'h':
637 goto usage;
638 break;
639 default:
640 goto usage;
641 }
642 }
643 if ( Abc_FrameReadLibGen() == NULL )
644 {
645 printf( "Library is not available.\n" );
646 return 1;
647 }
648 Mio_WriteLibrary( stdout, (Mio_Library_t *)Abc_FrameReadLibGen(), 0, fShort, fSelected );
649 return 0;
650
651usage:
652 fprintf( pErr, "\nusage: print_genlib [-savh]\n");
653 fprintf( pErr, "\t print the current genlib library\n" );
654 fprintf( pErr, "\t-s : toggles writing short form [default = %s]\n", fShort? "yes" : "no" );
655 fprintf( pErr, "\t-a : toggles writing min-area gates [default = %s]\n", fSelected? "yes" : "no" );
656 fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", fVerbose? "yes" : "no" );
657 fprintf( pErr, "\t-h : print the command usage\n");
658 return 1;
659}
660
661
673int Mio_CommandReadProfile( Abc_Frame_t * pAbc, int argc, char **argv )
674{
675 FILE * pFile, * pOut, * pErr;
676 Mio_Library_t * pLib;
677 char * pFileName;
678 int c;
679
680 pOut = Abc_FrameReadOut(pAbc);
681 pErr = Abc_FrameReadErr(pAbc);
682
683 // set the defaults
685 while ( (c = Extra_UtilGetopt(argc, argv, "h")) != EOF )
686 {
687 switch (c)
688 {
689 case 'h':
690 goto usage;
691 break;
692 default:
693 goto usage;
694 }
695 }
696 if ( argc != globalUtilOptind + 1 )
697 {
698 goto usage;
699 }
700
702 if ( pLib == NULL )
703 {
704 fprintf( pErr, "There is no Genlib library entered.\n" );
705 return 1;
706 }
707
708 // get the input file name
709 pFileName = argv[globalUtilOptind];
710 if ( (pFile = Io_FileOpen( pFileName, "open_path", "r", 0 )) == NULL )
711 {
712 fprintf( pErr, "Cannot open input file \"%s\". ", pFileName );
713 if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".profile", NULL, NULL, NULL, NULL )) )
714 fprintf( pErr, "Did you mean \"%s\"?", pFileName );
715 fprintf( pErr, "\n" );
716 return 1;
717 }
718
719 // set the new network
720 Mio_LibraryReadProfile( pFile, pLib );
721 fclose( pFile );
722 return 0;
723
724usage:
725 fprintf( pErr, "usage: read_profile [-h] <file>\n");
726 fprintf( pErr, "\t read a gate profile from a profile file\n" );
727 fprintf( pErr, "\t-h : enable verbose output\n");
728 fprintf( pErr, "\t<file> : file name to read the profile\n");
729 return 1;
730}
731
743int Mio_CommandWriteProfile( Abc_Frame_t * pAbc, int argc, char **argv )
744{
745 FILE * pOut, * pErr, * pFile;
746 char * pFileName;
747 int c;
748
749 pOut = Abc_FrameReadOut(pAbc);
750 pErr = Abc_FrameReadErr(pAbc);
751
753 while ( (c = Extra_UtilGetopt(argc, argv, "h")) != EOF )
754 {
755 switch (c)
756 {
757 case 'h':
758 goto usage;
759 break;
760 default:
761 goto usage;
762 }
763 }
764 if ( Abc_FrameReadLibGen() == NULL )
765 {
766 printf( "Library is not available.\n" );
767 return 1;
768 }
769 if ( argc != globalUtilOptind + 1 )
770 {
771 printf( "The file name is not given.\n" );
772 return 1;
773 }
774
775 pFileName = argv[globalUtilOptind];
776 pFile = fopen( pFileName, "w" );
777 if ( pFile == NULL )
778 {
779 printf( "Error! Cannot open file \"%s\" for writing the library.\n", pFileName );
780 return 1;
781 }
783 fclose( pFile );
784 printf( "The current profile is written into file \"%s\".\n", pFileName );
785 return 0;
786
787usage:
788 fprintf( pErr, "\nusage: write_profile [-h] <file>\n");
789 fprintf( pErr, "\t writes the current profile into a file\n" );
790 fprintf( pErr, "\t-h : print the command usage\n");
791 fprintf( pErr, "\t<file> : file name to write the profile\n");
792 return 1;
793}
794
806int Mio_CommandPrintProfile( Abc_Frame_t * pAbc, int argc, char **argv )
807{
808 FILE * pOut, * pErr;
809 int fShort = 0;
810 int fSelected = 0;
811 int fVerbose = 0;
812 int c;
813
814 pOut = Abc_FrameReadOut(pAbc);
815 pErr = Abc_FrameReadErr(pAbc);
816
817 // set the defaults
819 while ( (c = Extra_UtilGetopt(argc, argv, "savh")) != EOF )
820 {
821 switch (c)
822 {
823 case 's':
824 fShort ^= 1;
825 break;
826 case 'a':
827 fSelected ^= 1;
828 break;
829 case 'v':
830 fVerbose ^= 1;
831 break;
832 case 'h':
833 goto usage;
834 break;
835 default:
836 goto usage;
837 }
838 }
839 if ( Abc_FrameReadLibGen() == NULL )
840 {
841 printf( "Library is not available.\n" );
842 return 1;
843 }
845 return 0;
846
847usage:
848 fprintf( pErr, "\nusage: print_profile [-h]\n");
849 fprintf( pErr, "\t print the current gate profile\n" );
850 fprintf( pErr, "\t-h : print the command usage\n");
851 return 1;
852}
856
857
859
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
Definition abcapis.h:38
Amap_Lib_t * Amap_LibReadAndPrepare(char *pFileName, char *pBuffer, int fVerbose, int fVeryVerbose)
Definition amapLib.c:332
typedefABC_NAMESPACE_HEADER_START struct Amap_Lib_t_ Amap_Lib_t
INCLUDES ///.
Definition amap.h:42
Vec_Str_t * Amap_LibertyParseStr(char *pFileName, int fVerbose)
int Amap_LibertyParse(char *pFileName, int fVerbose)
void Amap_LibFree(Amap_Lib_t *p)
Definition amapLib.c:67
ABC_DLL void Abc_FrameSetLibGen(void *pLib)
Definition mainFrame.c:95
ABC_DLL void Abc_FrameSetLibSuper(void *pLib)
Definition mainFrame.c:97
ABC_DLL void * Abc_FrameReadLibGen()
Definition mainFrame.c:59
ABC_DLL void Abc_FrameSetLibGen2(void *pLib)
Definition mainFrame.c:96
ABC_DLL void * Abc_FrameReadLibGen2()
Definition mainFrame.c:60
ABC_DLL FILE * Abc_FrameReadErr(Abc_Frame_t *p)
Definition mainFrame.c:375
ABC_DLL void * Abc_FrameReadLibSuper()
Definition mainFrame.c:61
ABC_DLL FILE * Abc_FrameReadOut(Abc_Frame_t *p)
Definition mainFrame.c:359
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
void Cmd_CommandAdd(Abc_Frame_t *pAbc, const char *sGroup, const char *sName, Cmd_CommandFuncType pFunc, int fChanges)
Definition cmdApi.c:63
ABC_DLL int Cmd_CommandExecute(Abc_Frame_t *pAbc, const char *sCommand)
Definition cmdApi.c:193
int globalUtilOptind
char * Extra_FileGetSimilarName(char *pFileNameWrong, char *pS1, char *pS2, char *pS3, char *pS4, char *pS5)
int Extra_UtilGetopt(int argc, char *argv[], const char *optstring)
ABC_DLL void Extra_UtilGetoptReset()
char * Extra_FileNameGenericAppend(char *pBase, char *pSuffix)
FILE * Io_FileOpen(const char *FileName, const char *PathVar, const char *Mode, int fVerbose)
Definition ioUtil.c:828
struct Map_SuperLibStruct_t_ Map_SuperLib_t
Definition mapper.h:46
void Map_SuperLibFree(Map_SuperLib_t *p)
Definition mapperLib.c:170
Mio_Library_t * Mio_LibraryReadBuffer(char *pBuffer, int fExtendedFormat, st__table *tExcludeGate, int nFaninLimit, int fVerbose)
Definition mioRead.c:156
void Mio_IntallAndLibrary()
FUNCTION DEFINITIONS ///.
Definition mio.c:146
void Mio_Init(Abc_Frame_t *pAbc)
Definition mio.c:198
void Mio_IntallSimpleLibrary()
Definition mio.c:160
int Mio_UpdateGenlib2(Vec_Str_t *vStr, Vec_Str_t *vStr2, char *pFileName, int fVerbose)
Definition mio.c:260
void Mio_IntallSimpleLibrary2()
Definition mio.c:173
void Mio_UpdateGenlib(Mio_Library_t *pLib)
FUNCTION DEFINITIONS ///.
Definition mio.c:243
void Mio_End(Abc_Frame_t *pAbc)
Definition mio.c:226
void Mio_WriteLibraryVerilog(FILE *pFile, Mio_Library_t *pLib, int fPrintSops, int fShort, int fSelected)
Definition mioUtils.c:357
void Mio_LibraryReadProfile(FILE *pFile, Mio_Library_t *pLib)
Definition mioUtils.c:1523
void Mio_LibraryShortNames(Mio_Library_t *pLib)
Definition mioUtils.c:1711
void Mio_LibraryShiftDelay(Mio_Library_t *pLib, double Shift)
Definition mioUtils.c:1230
struct Mio_LibraryStruct_t_ Mio_Library_t
Definition mio.h:42
void Mio_LibraryDelete(Mio_Library_t *pLib)
DECLARATIONS ///.
Definition mioUtils.c:51
void Mio_WriteLibrary(FILE *pFile, Mio_Library_t *pLib, int fPrintSops, int fShort, int fSelected)
Definition mioUtils.c:262
int Mio_LibraryReadGateNum(Mio_Library_t *pLib)
Definition mioApi.c:45
void Mio_LibrarySetName(Mio_Library_t *pLib, char *pName)
Definition mioApi.c:68
Mio_Library_t * Mio_LibraryRead(char *FileName, char *pBuffer, char *ExcludeFile, int nFaninLimit, int fVerbose)
Definition mioRead.c:54
void Mio_LibraryWriteProfile(FILE *pFile, Mio_Library_t *pLib)
Definition mioUtils.c:1547
usage()
Definition main.c:626
Definition st.h:52
#define assert(ex)
Definition util_old.h:213
int strlen()
char * sprintf()
double atof()