00001
00021 #include "io.h"
00022 #include "mainInt.h"
00023
00027
00028 static int IoCommandRead ( Abc_Frame_t * pAbc, int argc, char **argv );
00029 static int IoCommandReadAiger ( Abc_Frame_t * pAbc, int argc, char **argv );
00030 static int IoCommandReadBaf ( Abc_Frame_t * pAbc, int argc, char **argv );
00031 static int IoCommandReadBlif ( Abc_Frame_t * pAbc, int argc, char **argv );
00032 static int IoCommandReadBlifMv ( Abc_Frame_t * pAbc, int argc, char **argv );
00033 static int IoCommandReadBench ( Abc_Frame_t * pAbc, int argc, char **argv );
00034 static int IoCommandReadDsd ( Abc_Frame_t * pAbc, int argc, char **argv );
00035 static int IoCommandReadEdif ( Abc_Frame_t * pAbc, int argc, char **argv );
00036 static int IoCommandReadEqn ( Abc_Frame_t * pAbc, int argc, char **argv );
00037 static int IoCommandReadInit ( Abc_Frame_t * pAbc, int argc, char **argv );
00038 static int IoCommandReadPla ( Abc_Frame_t * pAbc, int argc, char **argv );
00039 static int IoCommandReadTruth ( Abc_Frame_t * pAbc, int argc, char **argv );
00040 static int IoCommandReadVerilog ( Abc_Frame_t * pAbc, int argc, char **argv );
00041 static int IoCommandReadVer ( Abc_Frame_t * pAbc, int argc, char **argv );
00042 static int IoCommandReadVerLib ( Abc_Frame_t * pAbc, int argc, char **argv );
00043
00044 static int IoCommandWrite ( Abc_Frame_t * pAbc, int argc, char **argv );
00045 static int IoCommandWriteHie ( Abc_Frame_t * pAbc, int argc, char **argv );
00046 static int IoCommandWriteAiger ( Abc_Frame_t * pAbc, int argc, char **argv );
00047 static int IoCommandWriteBaf ( Abc_Frame_t * pAbc, int argc, char **argv );
00048 static int IoCommandWriteBlif ( Abc_Frame_t * pAbc, int argc, char **argv );
00049 static int IoCommandWriteBlifMv ( Abc_Frame_t * pAbc, int argc, char **argv );
00050 static int IoCommandWriteBench ( Abc_Frame_t * pAbc, int argc, char **argv );
00051 static int IoCommandWriteCellNet( Abc_Frame_t * pAbc, int argc, char **argv );
00052 static int IoCommandWriteCnf ( Abc_Frame_t * pAbc, int argc, char **argv );
00053 static int IoCommandWriteCounter( Abc_Frame_t * pAbc, int argc, char **argv );
00054 static int IoCommandWriteDot ( Abc_Frame_t * pAbc, int argc, char **argv );
00055 static int IoCommandWriteEqn ( Abc_Frame_t * pAbc, int argc, char **argv );
00056 static int IoCommandWriteGml ( Abc_Frame_t * pAbc, int argc, char **argv );
00057 static int IoCommandWriteList ( Abc_Frame_t * pAbc, int argc, char **argv );
00058 static int IoCommandWritePla ( Abc_Frame_t * pAbc, int argc, char **argv );
00059 static int IoCommandWriteVerilog( Abc_Frame_t * pAbc, int argc, char **argv );
00060 static int IoCommandWriteVerLib ( Abc_Frame_t * pAbc, int argc, char **argv );
00061
00062 extern int glo_fMapped;
00063
00067
00079 void Io_Init( Abc_Frame_t * pAbc )
00080 {
00081 Cmd_CommandAdd( pAbc, "I/O", "read", IoCommandRead, 1 );
00082 Cmd_CommandAdd( pAbc, "I/O", "read_aiger", IoCommandReadAiger, 1 );
00083 Cmd_CommandAdd( pAbc, "I/O", "read_baf", IoCommandReadBaf, 1 );
00084 Cmd_CommandAdd( pAbc, "I/O", "read_blif", IoCommandReadBlif, 1 );
00085 Cmd_CommandAdd( pAbc, "I/O", "read_blif_mv", IoCommandReadBlifMv, 1 );
00086 Cmd_CommandAdd( pAbc, "I/O", "read_bench", IoCommandReadBench, 1 );
00087 Cmd_CommandAdd( pAbc, "I/O", "read_dsd", IoCommandReadDsd, 1 );
00088
00089 Cmd_CommandAdd( pAbc, "I/O", "read_eqn", IoCommandReadEqn, 1 );
00090 Cmd_CommandAdd( pAbc, "I/O", "read_init", IoCommandReadInit, 1 );
00091 Cmd_CommandAdd( pAbc, "I/O", "read_pla", IoCommandReadPla, 1 );
00092 Cmd_CommandAdd( pAbc, "I/O", "read_truth", IoCommandReadTruth, 1 );
00093 Cmd_CommandAdd( pAbc, "I/O", "read_verilog", IoCommandReadVerilog, 1 );
00094
00095
00096
00097 Cmd_CommandAdd( pAbc, "I/O", "write", IoCommandWrite, 0 );
00098 Cmd_CommandAdd( pAbc, "I/O", "write_hie", IoCommandWriteHie, 0 );
00099 Cmd_CommandAdd( pAbc, "I/O", "write_aiger", IoCommandWriteAiger, 0 );
00100 Cmd_CommandAdd( pAbc, "I/O", "write_baf", IoCommandWriteBaf, 0 );
00101 Cmd_CommandAdd( pAbc, "I/O", "write_blif", IoCommandWriteBlif, 0 );
00102 Cmd_CommandAdd( pAbc, "I/O", "write_blif_mv", IoCommandWriteBlifMv, 0 );
00103 Cmd_CommandAdd( pAbc, "I/O", "write_bench", IoCommandWriteBench, 0 );
00104 Cmd_CommandAdd( pAbc, "I/O", "write_cellnet", IoCommandWriteCellNet, 0 );
00105 Cmd_CommandAdd( pAbc, "I/O", "write_counter", IoCommandWriteCounter, 0 );
00106 Cmd_CommandAdd( pAbc, "I/O", "write_cnf", IoCommandWriteCnf, 0 );
00107 Cmd_CommandAdd( pAbc, "I/O", "write_dot", IoCommandWriteDot, 0 );
00108 Cmd_CommandAdd( pAbc, "I/O", "write_eqn", IoCommandWriteEqn, 0 );
00109 Cmd_CommandAdd( pAbc, "I/O", "write_gml", IoCommandWriteGml, 0 );
00110
00111 Cmd_CommandAdd( pAbc, "I/O", "write_pla", IoCommandWritePla, 0 );
00112 Cmd_CommandAdd( pAbc, "I/O", "write_verilog", IoCommandWriteVerilog, 0 );
00113
00114 }
00115
00127 void Io_End()
00128 {
00129 }
00130
00142 int IoCommandRead( Abc_Frame_t * pAbc, int argc, char ** argv )
00143 {
00144 Abc_Ntk_t * pNtk;
00145 char * pFileName;
00146 int fCheck;
00147 int c;
00148
00149 fCheck = 1;
00150 glo_fMapped = 0;
00151 Extra_UtilGetoptReset();
00152 while ( ( c = Extra_UtilGetopt( argc, argv, "mch" ) ) != EOF )
00153 {
00154 switch ( c )
00155 {
00156 case 'm':
00157 glo_fMapped ^= 1;
00158 break;
00159 case 'c':
00160 fCheck ^= 1;
00161 break;
00162 case 'h':
00163 goto usage;
00164 default:
00165 goto usage;
00166 }
00167 }
00168 if ( argc != globalUtilOptind + 1 )
00169 goto usage;
00170
00171 pFileName = argv[globalUtilOptind];
00172
00173 pNtk = Io_Read( pFileName, Io_ReadFileType(pFileName), fCheck );
00174 if ( pNtk == NULL )
00175 return 1;
00176
00177 Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
00178 return 0;
00179
00180 usage:
00181 fprintf( pAbc->Err, "usage: read [-mch] <file>\n" );
00182 fprintf( pAbc->Err, "\t replaces the current network by the network read from <file>\n" );
00183 fprintf( pAbc->Err, "\t by calling the parser that matches the extension of <file>\n" );
00184 fprintf( pAbc->Err, "\t (to read a hierarchical design, use \"read_hie\")\n" );
00185 fprintf( pAbc->Err, "\t-m : toggle reading mapped Verilog [default = %s]\n", glo_fMapped? "yes":"no" );
00186 fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
00187 fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
00188 fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
00189 return 1;
00190 }
00191
00203 int IoCommandReadAiger( Abc_Frame_t * pAbc, int argc, char ** argv )
00204 {
00205 Abc_Ntk_t * pNtk;
00206 char * pFileName;
00207 int fCheck;
00208 int c;
00209
00210 fCheck = 1;
00211 Extra_UtilGetoptReset();
00212 while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
00213 {
00214 switch ( c )
00215 {
00216 case 'c':
00217 fCheck ^= 1;
00218 break;
00219 case 'h':
00220 goto usage;
00221 default:
00222 goto usage;
00223 }
00224 }
00225 if ( argc != globalUtilOptind + 1 )
00226 goto usage;
00227
00228 pFileName = argv[globalUtilOptind];
00229
00230 pNtk = Io_Read( pFileName, IO_FILE_AIGER, fCheck );
00231 if ( pNtk == NULL )
00232 return 1;
00233
00234 Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
00235 return 0;
00236
00237 usage:
00238 fprintf( pAbc->Err, "usage: read_aiger [-ch] <file>\n" );
00239 fprintf( pAbc->Err, "\t read the network in the AIGER format (http://fmv.jku.at/aiger)\n" );
00240 fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
00241 fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
00242 fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
00243 return 1;
00244 }
00245
00257 int IoCommandReadBaf( Abc_Frame_t * pAbc, int argc, char ** argv )
00258 {
00259 Abc_Ntk_t * pNtk;
00260 char * pFileName;
00261 int fCheck;
00262 int c;
00263
00264 fCheck = 1;
00265 Extra_UtilGetoptReset();
00266 while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
00267 {
00268 switch ( c )
00269 {
00270 case 'c':
00271 fCheck ^= 1;
00272 break;
00273 case 'h':
00274 goto usage;
00275 default:
00276 goto usage;
00277 }
00278 }
00279 if ( argc != globalUtilOptind + 1 )
00280 goto usage;
00281
00282 pFileName = argv[globalUtilOptind];
00283
00284 pNtk = Io_Read( pFileName, IO_FILE_BAF, fCheck );
00285 if ( pNtk == NULL )
00286 return 1;
00287
00288 Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
00289 return 0;
00290
00291 usage:
00292 fprintf( pAbc->Err, "usage: read_baf [-ch] <file>\n" );
00293 fprintf( pAbc->Err, "\t read the network in Binary Aig Format (BAF)\n" );
00294 fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
00295 fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
00296 fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
00297 return 1;
00298 }
00299
00311 int IoCommandReadBlif( Abc_Frame_t * pAbc, int argc, char ** argv )
00312 {
00313 Abc_Ntk_t * pNtk;
00314 char * pFileName;
00315 int fReadAsAig;
00316 int fCheck;
00317 int c;
00318 extern Abc_Ntk_t * Io_ReadBlifAsAig( char * pFileName, int fCheck );
00319
00320 fCheck = 1;
00321 fReadAsAig = 0;
00322 Extra_UtilGetoptReset();
00323 while ( ( c = Extra_UtilGetopt( argc, argv, "ach" ) ) != EOF )
00324 {
00325 switch ( c )
00326 {
00327 case 'a':
00328 fReadAsAig ^= 1;
00329 break;
00330 case 'c':
00331 fCheck ^= 1;
00332 break;
00333 case 'h':
00334 goto usage;
00335 default:
00336 goto usage;
00337 }
00338 }
00339 if ( argc != globalUtilOptind + 1 )
00340 goto usage;
00341
00342 pFileName = argv[globalUtilOptind];
00343
00344 if ( fReadAsAig )
00345 pNtk = Io_ReadBlifAsAig( pFileName, fCheck );
00346 else
00347
00348 {
00349 Abc_Ntk_t * pTemp;
00350 pNtk = Io_ReadBlif( pFileName, fCheck );
00351 pNtk = Abc_NtkToLogic( pTemp = pNtk );
00352 Abc_NtkDelete( pTemp );
00353 }
00354
00355 if ( pNtk == NULL )
00356 return 1;
00357
00358 Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
00359 return 0;
00360
00361 usage:
00362 fprintf( pAbc->Err, "usage: read_blif [-ach] <file>\n" );
00363 fprintf( pAbc->Err, "\t read the network in binary BLIF format\n" );
00364 fprintf( pAbc->Err, "\t-a : toggle creating AIG while reading the file [default = %s]\n", fReadAsAig? "yes":"no" );
00365 fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
00366 fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
00367 fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
00368 return 1;
00369 }
00370
00382 int IoCommandReadBlifMv( Abc_Frame_t * pAbc, int argc, char ** argv )
00383 {
00384 Abc_Ntk_t * pNtk;
00385 char * pFileName;
00386 int fCheck;
00387 int c;
00388
00389 fCheck = 1;
00390 Extra_UtilGetoptReset();
00391 while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
00392 {
00393 switch ( c )
00394 {
00395 case 'c':
00396 fCheck ^= 1;
00397 break;
00398 case 'h':
00399 goto usage;
00400 default:
00401 goto usage;
00402 }
00403 }
00404 if ( argc != globalUtilOptind + 1 )
00405 goto usage;
00406
00407 pFileName = argv[globalUtilOptind];
00408
00409 pNtk = Io_Read( pFileName, IO_FILE_BLIFMV, fCheck );
00410 if ( pNtk == NULL )
00411 return 1;
00412
00413 Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
00414 return 0;
00415
00416 usage:
00417 fprintf( pAbc->Err, "usage: read_blif_mv [-ch] <file>\n" );
00418 fprintf( pAbc->Err, "\t read the network in BLIF-MV format\n" );
00419 fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
00420 fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
00421 fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
00422 return 1;
00423 }
00424
00436 int IoCommandReadBench( Abc_Frame_t * pAbc, int argc, char ** argv )
00437 {
00438 Abc_Ntk_t * pNtk;
00439 char * pFileName;
00440 int fCheck;
00441 int c;
00442
00443 fCheck = 1;
00444 Extra_UtilGetoptReset();
00445 while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
00446 {
00447 switch ( c )
00448 {
00449 case 'c':
00450 fCheck ^= 1;
00451 break;
00452 case 'h':
00453 goto usage;
00454 default:
00455 goto usage;
00456 }
00457 }
00458 if ( argc != globalUtilOptind + 1 )
00459 goto usage;
00460
00461 pFileName = argv[globalUtilOptind];
00462
00463 pNtk = Io_Read( pFileName, IO_FILE_BENCH, fCheck );
00464 if ( pNtk == NULL )
00465 return 1;
00466
00467 Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
00468 return 0;
00469
00470 usage:
00471 fprintf( pAbc->Err, "usage: read_bench [-ch] <file>\n" );
00472 fprintf( pAbc->Err, "\t read the network in BENCH format\n" );
00473 fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
00474 fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
00475 fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
00476 return 1;
00477 }
00478
00490 int IoCommandReadDsd( Abc_Frame_t * pAbc, int argc, char ** argv )
00491 {
00492 Abc_Ntk_t * pNtk;
00493 char * pString;
00494 int fCheck;
00495 int c;
00496 extern Abc_Ntk_t * Io_ReadDsd( char * pFormula );
00497
00498 fCheck = 1;
00499 Extra_UtilGetoptReset();
00500 while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
00501 {
00502 switch ( c )
00503 {
00504 case 'c':
00505 fCheck ^= 1;
00506 break;
00507 case 'h':
00508 goto usage;
00509 default:
00510 goto usage;
00511 }
00512 }
00513 if ( argc != globalUtilOptind + 1 )
00514 goto usage;
00515
00516 pString = argv[globalUtilOptind];
00517
00518 pNtk = Io_ReadDsd( pString );
00519 if ( pNtk == NULL )
00520 return 1;
00521
00522 Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
00523 return 0;
00524
00525 usage:
00526 fprintf( pAbc->Err, "usage: read_dsd [-h] <formula>\n" );
00527 fprintf( pAbc->Err, "\t parses a formula representing DSD of a function\n" );
00528 fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
00529 fprintf( pAbc->Err, "\tformula : the formula representing disjoint-support decomposition (DSD)\n" );
00530 fprintf( pAbc->Err, "\t Example of a formula: !(a*(b+CA(!d,e*f,c))*79B3(g,h,i,k))\n" );
00531 fprintf( pAbc->Err, "\t where \'!\' is an INV, \'*\' is an AND, \'+\' is an XOR, \n" );
00532 fprintf( pAbc->Err, "\t CA and 79B3 are hexadecimal representations of truth tables\n" );
00533 fprintf( pAbc->Err, "\t (in this case CA=11001010 is truth table of MUX(Data0,Data1,Ctrl))\n" );
00534 fprintf( pAbc->Err, "\t The lower chars (a,b,c,etc) are reserved for elementary variables.\n" );
00535 fprintf( pAbc->Err, "\t The upper chars (A,B,C,etc) are reserved for hexadecimal digits.\n" );
00536 fprintf( pAbc->Err, "\t No spaces are allowed in formulas. In parantheses, LSB goes first.\n" );
00537 return 1;
00538 }
00539
00551 int IoCommandReadEdif( Abc_Frame_t * pAbc, int argc, char ** argv )
00552 {
00553 Abc_Ntk_t * pNtk;
00554 char * pFileName;
00555 int fCheck;
00556 int c;
00557
00558 fCheck = 1;
00559 Extra_UtilGetoptReset();
00560 while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
00561 {
00562 switch ( c )
00563 {
00564 case 'c':
00565 fCheck ^= 1;
00566 break;
00567 case 'h':
00568 goto usage;
00569 default:
00570 goto usage;
00571 }
00572 }
00573 if ( argc != globalUtilOptind + 1 )
00574 goto usage;
00575
00576 pFileName = argv[globalUtilOptind];
00577
00578 pNtk = Io_Read( pFileName, IO_FILE_EDIF, fCheck );
00579 if ( pNtk == NULL )
00580 return 1;
00581
00582 Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
00583 return 0;
00584
00585 usage:
00586 fprintf( pAbc->Err, "usage: read_edif [-ch] <file>\n" );
00587 fprintf( pAbc->Err, "\t read the network in EDIF (works only for ISCAS benchmarks)\n" );
00588 fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
00589 fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
00590 fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
00591 return 1;
00592 }
00593
00605 int IoCommandReadEqn( Abc_Frame_t * pAbc, int argc, char ** argv )
00606 {
00607 Abc_Ntk_t * pNtk;
00608 char * pFileName;
00609 int fCheck;
00610 int c;
00611
00612 fCheck = 1;
00613 Extra_UtilGetoptReset();
00614 while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
00615 {
00616 switch ( c )
00617 {
00618 case 'c':
00619 fCheck ^= 1;
00620 break;
00621 case 'h':
00622 goto usage;
00623 default:
00624 goto usage;
00625 }
00626 }
00627 if ( argc != globalUtilOptind + 1 )
00628 goto usage;
00629
00630 pFileName = argv[globalUtilOptind];
00631
00632 pNtk = Io_Read( pFileName, IO_FILE_EQN, fCheck );
00633 if ( pNtk == NULL )
00634 return 1;
00635
00636 Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
00637 return 0;
00638
00639 usage:
00640 fprintf( pAbc->Err, "usage: read_eqn [-ch] <file>\n" );
00641 fprintf( pAbc->Err, "\t read the network in equation format\n" );
00642 fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
00643 fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
00644 fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
00645 return 1;
00646 }
00647
00659 int IoCommandReadInit( Abc_Frame_t * pAbc, int argc, char ** argv )
00660 {
00661 FILE * pOut, * pErr;
00662 Abc_Ntk_t * pNtk;
00663 char * pFileName;
00664 int c;
00665 extern void Io_ReadBenchInit( Abc_Ntk_t * pNtk, char * pFileName );
00666
00667 pNtk = Abc_FrameReadNtk(pAbc);
00668 pOut = Abc_FrameReadOut(pAbc);
00669 pErr = Abc_FrameReadErr(pAbc);
00670
00671 Extra_UtilGetoptReset();
00672 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
00673 {
00674 switch ( c )
00675 {
00676 case 'h':
00677 goto usage;
00678 default:
00679 goto usage;
00680 }
00681 }
00682 if ( argc != globalUtilOptind + 1 )
00683 goto usage;
00684
00685 if ( pNtk == NULL )
00686 {
00687 fprintf( pErr, "Empty network.\n" );
00688 return 1;
00689 }
00690
00691 pFileName = argv[globalUtilOptind];
00692
00693 pNtk = Abc_NtkDup( pNtk );
00694 Io_ReadBenchInit( pNtk, pFileName );
00695
00696 Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
00697 return 0;
00698
00699 usage:
00700 fprintf( pAbc->Err, "usage: read_init [-h] <file>\n" );
00701 fprintf( pAbc->Err, "\t reads initial state of the network in BENCH format\n" );
00702 fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
00703 fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
00704 return 1;
00705 }
00706
00718 int IoCommandReadPla( Abc_Frame_t * pAbc, int argc, char ** argv )
00719 {
00720 Abc_Ntk_t * pNtk;
00721 char * pFileName;
00722 int fCheck;
00723 int c;
00724
00725 fCheck = 1;
00726 Extra_UtilGetoptReset();
00727 while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
00728 {
00729 switch ( c )
00730 {
00731 case 'c':
00732 fCheck ^= 1;
00733 break;
00734 case 'h':
00735 goto usage;
00736 default:
00737 goto usage;
00738 }
00739 }
00740 if ( argc != globalUtilOptind + 1 )
00741 goto usage;
00742
00743 pFileName = argv[globalUtilOptind];
00744
00745 pNtk = Io_Read( pFileName, IO_FILE_PLA, fCheck );
00746 if ( pNtk == NULL )
00747 return 1;
00748
00749 Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
00750 return 0;
00751
00752 usage:
00753 fprintf( pAbc->Err, "usage: read_pla [-ch] <file>\n" );
00754 fprintf( pAbc->Err, "\t read the network in PLA\n" );
00755 fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
00756 fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
00757 fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
00758 return 1;
00759 }
00760
00772 int IoCommandReadTruth( Abc_Frame_t * pAbc, int argc, char ** argv )
00773 {
00774 Abc_Ntk_t * pNtk;
00775 char * pSopCover;
00776 int fHex;
00777 int c;
00778
00779 fHex = 1;
00780 Extra_UtilGetoptReset();
00781 while ( ( c = Extra_UtilGetopt( argc, argv, "xh" ) ) != EOF )
00782 {
00783 switch ( c )
00784 {
00785 case 'x':
00786 fHex ^= 1;
00787 break;
00788 case 'h':
00789 goto usage;
00790 default:
00791 goto usage;
00792 }
00793 }
00794
00795 if ( argc != globalUtilOptind + 1 )
00796 {
00797 goto usage;
00798 }
00799
00800
00801 if ( fHex )
00802 pSopCover = Abc_SopFromTruthHex(argv[globalUtilOptind]);
00803 else
00804 pSopCover = Abc_SopFromTruthBin(argv[globalUtilOptind]);
00805 if ( pSopCover == NULL )
00806 {
00807 fprintf( pAbc->Err, "Reading truth table has failed.\n" );
00808 return 1;
00809 }
00810
00811 pNtk = Abc_NtkCreateWithNode( pSopCover );
00812 free( pSopCover );
00813 if ( pNtk == NULL )
00814 {
00815 fprintf( pAbc->Err, "Deriving the network has failed.\n" );
00816 return 1;
00817 }
00818
00819 Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
00820 return 0;
00821
00822 usage:
00823 fprintf( pAbc->Err, "usage: read_truth [-xh] <truth>\n" );
00824 fprintf( pAbc->Err, "\t creates network with node having given truth table\n" );
00825 fprintf( pAbc->Err, "\t-x : toggles between bin and hex representation [default = %s]\n", fHex? "hex":"bin" );
00826 fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
00827 fprintf( pAbc->Err, "\ttruth : truth table with most signficant bit first (e.g. 1000 for AND(a,b))\n" );
00828 return 1;
00829 }
00830
00842 int IoCommandReadVerilog( Abc_Frame_t * pAbc, int argc, char ** argv )
00843 {
00844 Abc_Ntk_t * pNtk;
00845 char * pFileName;
00846 int fCheck;
00847 int c;
00848
00849 fCheck = 1;
00850 glo_fMapped = 0;
00851 Extra_UtilGetoptReset();
00852 while ( ( c = Extra_UtilGetopt( argc, argv, "mch" ) ) != EOF )
00853 {
00854 switch ( c )
00855 {
00856 case 'm':
00857 glo_fMapped ^= 1;
00858 break;
00859 case 'c':
00860 fCheck ^= 1;
00861 break;
00862 case 'h':
00863 goto usage;
00864 default:
00865 goto usage;
00866 }
00867 }
00868 if ( argc != globalUtilOptind + 1 )
00869 goto usage;
00870
00871 pFileName = argv[globalUtilOptind];
00872
00873 pNtk = Io_Read( pFileName, IO_FILE_VERILOG, fCheck );
00874 if ( pNtk == NULL )
00875 return 1;
00876
00877 Abc_FrameReplaceCurrentNetwork( pAbc, pNtk );
00878 return 0;
00879
00880 usage:
00881 fprintf( pAbc->Err, "usage: read_verilog [-mch] <file>\n" );
00882 fprintf( pAbc->Err, "\t read the network in Verilog (IWLS 2002/2005 subset)\n" );
00883 fprintf( pAbc->Err, "\t-m : toggle reading mapped Verilog [default = %s]\n", glo_fMapped? "yes":"no" );
00884 fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
00885 fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
00886 fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
00887 return 1;
00888 }
00889
00901 int IoCommandReadVer( Abc_Frame_t * pAbc, int argc, char ** argv )
00902 {
00903 Abc_Ntk_t * pNtk, * pNtkNew;
00904 Abc_Lib_t * pDesign;
00905 char * pFileName;
00906 FILE * pFile;
00907 int fCheck;
00908 int c;
00909 extern Abc_Ntk_t * Abc_LibDeriveAig( Abc_Ntk_t * pNtk, Abc_Lib_t * pLib );
00910 extern Abc_Lib_t * Ver_ParseFile( char * pFileName, Abc_Lib_t * pGateLib, int fCheck, int fUseMemMan );
00911
00912 printf( "Stand-alone structural Verilog reader is available as command \"read_verilog\".\n" );
00913 return 0;
00914
00915 fCheck = 1;
00916 Extra_UtilGetoptReset();
00917 while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
00918 {
00919 switch ( c )
00920 {
00921 case 'c':
00922 fCheck ^= 1;
00923 break;
00924 case 'h':
00925 goto usage;
00926 default:
00927 goto usage;
00928 }
00929 }
00930
00931 if ( argc != globalUtilOptind + 1 )
00932 {
00933 goto usage;
00934 }
00935
00936
00937 pFileName = argv[globalUtilOptind];
00938 if ( (pFile = fopen( pFileName, "r" )) == NULL )
00939 {
00940 fprintf( pAbc->Err, "Cannot open input file \"%s\". ", pFileName );
00941 if ( pFileName = Extra_FileGetSimilarName( pFileName, ".blif", ".bench", ".pla", ".baf", ".aig" ) )
00942 fprintf( pAbc->Err, "Did you mean \"%s\"?", pFileName );
00943 fprintf( pAbc->Err, "\n" );
00944 return 1;
00945 }
00946 fclose( pFile );
00947
00948
00949 pDesign = Ver_ParseFile( pFileName, Abc_FrameReadLibVer(), fCheck, 1 );
00950 if ( pDesign == NULL )
00951 {
00952 fprintf( pAbc->Err, "Reading network from the verilog file has failed.\n" );
00953 return 1;
00954 }
00955
00956
00957 pNtk = Abc_LibDeriveRoot( pDesign );
00958 Abc_LibFree( pDesign, NULL );
00959 if ( pNtk == NULL )
00960 {
00961 fprintf( pAbc->Err, "Deriving root module has failed.\n" );
00962 return 1;
00963 }
00964
00965
00966 pNtkNew = Abc_LibDeriveAig( pNtk, Abc_FrameReadLibVer() );
00967 Abc_NtkDelete( pNtk );
00968 if ( pNtkNew == NULL )
00969 {
00970 fprintf( pAbc->Err, "Converting root module to AIG has failed.\n" );
00971 return 1;
00972 }
00973
00974 Abc_FrameReplaceCurrentNetwork( pAbc, pNtkNew );
00975 return 0;
00976
00977 usage:
00978 fprintf( pAbc->Err, "usage: read_ver [-ch] <file>\n" );
00979 fprintf( pAbc->Err, "\t read a network in structural verilog (using current library)\n" );
00980 fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
00981 fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
00982 fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
00983 return 1;
00984 }
00985
00997 int IoCommandReadVerLib( Abc_Frame_t * pAbc, int argc, char ** argv )
00998 {
00999 Abc_Lib_t * pLibrary;
01000 char * pFileName;
01001 FILE * pFile;
01002 int fCheck;
01003 int c;
01004 extern Abc_Lib_t * Ver_ParseFile( char * pFileName, Abc_Lib_t * pGateLib, int fCheck, int fUseMemMan );
01005
01006 fCheck = 1;
01007 Extra_UtilGetoptReset();
01008 while ( ( c = Extra_UtilGetopt( argc, argv, "ch" ) ) != EOF )
01009 {
01010 switch ( c )
01011 {
01012 case 'c':
01013 fCheck ^= 1;
01014 break;
01015 case 'h':
01016 goto usage;
01017 default:
01018 goto usage;
01019 }
01020 }
01021
01022 if ( argc != globalUtilOptind + 1 )
01023 {
01024 goto usage;
01025 }
01026
01027
01028 pFileName = argv[globalUtilOptind];
01029 if ( (pFile = fopen( pFileName, "r" )) == NULL )
01030 {
01031 fprintf( pAbc->Err, "Cannot open input file \"%s\". ", pFileName );
01032 if ( pFileName = Extra_FileGetSimilarName( pFileName, ".blif", ".bench", ".pla", ".baf", ".aig" ) )
01033 fprintf( pAbc->Err, "Did you mean \"%s\"?", pFileName );
01034 fprintf( pAbc->Err, "\n" );
01035 return 1;
01036 }
01037 fclose( pFile );
01038
01039
01040 pLibrary = Ver_ParseFile( pFileName, NULL, fCheck, 0 );
01041 if ( pLibrary == NULL )
01042 {
01043 fprintf( pAbc->Err, "Reading library from the verilog file has failed.\n" );
01044 return 1;
01045 }
01046 printf( "The library contains %d gates.\n", st_count(pLibrary->tModules) );
01047
01048 if ( Abc_FrameReadLibVer() )
01049 Abc_LibFree( Abc_FrameReadLibVer(), NULL );
01050
01051 Abc_FrameSetLibVer( pLibrary );
01052 return 0;
01053
01054 usage:
01055 fprintf( pAbc->Err, "usage: read_verlib [-ch] <file>\n" );
01056 fprintf( pAbc->Err, "\t read a gate library in structural verilog\n" );
01057 fprintf( pAbc->Err, "\t-c : toggle network check after reading [default = %s]\n", fCheck? "yes":"no" );
01058 fprintf( pAbc->Err, "\t-h : prints the command summary\n" );
01059 fprintf( pAbc->Err, "\tfile : the name of a file to read\n" );
01060 return 1;
01061 }
01062
01063
01075 int IoCommandWrite( Abc_Frame_t * pAbc, int argc, char **argv )
01076 {
01077 char * pFileName;
01078 int c;
01079
01080 Extra_UtilGetoptReset();
01081 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
01082 {
01083 switch ( c )
01084 {
01085 case 'h':
01086 goto usage;
01087 default:
01088 goto usage;
01089 }
01090 }
01091 if ( argc != globalUtilOptind + 1 )
01092 goto usage;
01093
01094 pFileName = argv[globalUtilOptind];
01095
01096 Io_Write( pAbc->pNtkCur, pFileName, Io_ReadFileType(pFileName) );
01097 return 0;
01098
01099 usage:
01100 fprintf( pAbc->Err, "usage: write [-h] <file>\n" );
01101 fprintf( pAbc->Err, "\t writes the current network into <file> by calling\n" );
01102 fprintf( pAbc->Err, "\t the writer that matches the extension of <file>\n" );
01103 fprintf( pAbc->Err, "\t-h : print the help massage\n" );
01104 fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
01105 return 1;
01106 }
01107
01119 int IoCommandWriteHie( Abc_Frame_t * pAbc, int argc, char **argv )
01120 {
01121 char * pBaseName, * pFileName;
01122 int c;
01123
01124 glo_fMapped = 0;
01125 Extra_UtilGetoptReset();
01126 while ( ( c = Extra_UtilGetopt( argc, argv, "mh" ) ) != EOF )
01127 {
01128 switch ( c )
01129 {
01130 case 'm':
01131 glo_fMapped ^= 1;
01132 break;
01133 case 'h':
01134 goto usage;
01135 default:
01136 goto usage;
01137 }
01138 }
01139 if ( argc != globalUtilOptind + 2 )
01140 goto usage;
01141
01142 pBaseName = argv[globalUtilOptind];
01143 pFileName = argv[globalUtilOptind+1];
01144
01145
01146 Io_WriteHie( pAbc->pNtkCur, pBaseName, pFileName );
01147 return 0;
01148
01149 usage:
01150 fprintf( pAbc->Err, "usage: write_hie [-h] <orig> <file>\n" );
01151 fprintf( pAbc->Err, "\t writes the current network into <file> by calling\n" );
01152 fprintf( pAbc->Err, "\t the hierarchical writer that matches the extension of <file>\n" );
01153 fprintf( pAbc->Err, "\t-m : toggle reading mapped Verilog for <orig> [default = %s]\n", glo_fMapped? "yes":"no" );
01154 fprintf( pAbc->Err, "\t-h : print the help massage\n" );
01155 fprintf( pAbc->Err, "\torig : the name of the original file with the hierarchical design\n" );
01156 fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
01157 return 1;
01158 }
01159
01171 int IoCommandWriteAiger( Abc_Frame_t * pAbc, int argc, char **argv )
01172 {
01173 char * pFileName;
01174 int fWriteSymbols;
01175 int c;
01176
01177 fWriteSymbols = 1;
01178 Extra_UtilGetoptReset();
01179 while ( ( c = Extra_UtilGetopt( argc, argv, "sh" ) ) != EOF )
01180 {
01181 switch ( c )
01182 {
01183 case 's':
01184 fWriteSymbols ^= 1;
01185 break;
01186 case 'h':
01187 goto usage;
01188 default:
01189 goto usage;
01190 }
01191 }
01192 if ( argc != globalUtilOptind + 1 )
01193 goto usage;
01194
01195 pFileName = argv[globalUtilOptind];
01196
01197 if ( fWriteSymbols )
01198 Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_AIGER );
01199 else
01200 {
01201 if ( !Abc_NtkIsStrash(pAbc->pNtkCur) )
01202 {
01203 fprintf( stdout, "Writing this format is only possible for structurally hashed AIGs.\n" );
01204 return 1;
01205 }
01206 Io_WriteAiger( pAbc->pNtkCur, pFileName, 0 );
01207 }
01208 return 0;
01209
01210 usage:
01211 fprintf( pAbc->Err, "usage: write_aiger [-sh] <file>\n" );
01212 fprintf( pAbc->Err, "\t write the network in the AIGER format (http://fmv.jku.at/aiger)\n" );
01213 fprintf( pAbc->Err, "\t-s : toggle saving I/O names [default = %s]\n", fWriteSymbols? "yes" : "no" );
01214 fprintf( pAbc->Err, "\t-h : print the help massage\n" );
01215 fprintf( pAbc->Err, "\tfile : the name of the file to write (extension .aig)\n" );
01216 return 1;
01217 }
01218
01230 int IoCommandWriteBaf( Abc_Frame_t * pAbc, int argc, char **argv )
01231 {
01232 char * pFileName;
01233 int c;
01234
01235 Extra_UtilGetoptReset();
01236 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
01237 {
01238 switch ( c )
01239 {
01240 case 'h':
01241 goto usage;
01242 default:
01243 goto usage;
01244 }
01245 }
01246 if ( argc != globalUtilOptind + 1 )
01247 goto usage;
01248
01249 pFileName = argv[globalUtilOptind];
01250
01251 Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_BAF );
01252 return 0;
01253
01254 usage:
01255 fprintf( pAbc->Err, "usage: write_baf [-h] <file>\n" );
01256 fprintf( pAbc->Err, "\t write the network into a BLIF file\n" );
01257 fprintf( pAbc->Err, "\t-h : print the help massage\n" );
01258 fprintf( pAbc->Err, "\tfile : the name of the file to write (extension .baf)\n" );
01259 return 1;
01260 }
01261
01273 int IoCommandWriteBlif( Abc_Frame_t * pAbc, int argc, char **argv )
01274 {
01275 char * pFileName;
01276 int c;
01277
01278 Extra_UtilGetoptReset();
01279 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
01280 {
01281 switch ( c )
01282 {
01283 case 'h':
01284 goto usage;
01285 default:
01286 goto usage;
01287 }
01288 }
01289 if ( argc != globalUtilOptind + 1 )
01290 goto usage;
01291
01292 pFileName = argv[globalUtilOptind];
01293
01294 Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_BLIF );
01295 return 0;
01296
01297 usage:
01298 fprintf( pAbc->Err, "usage: write_blif [-h] <file>\n" );
01299 fprintf( pAbc->Err, "\t write the network into a BLIF file\n" );
01300 fprintf( pAbc->Err, "\t-h : print the help massage\n" );
01301 fprintf( pAbc->Err, "\tfile : the name of the file to write (extension .blif)\n" );
01302 return 1;
01303 }
01304
01316 int IoCommandWriteBlifMv( Abc_Frame_t * pAbc, int argc, char **argv )
01317 {
01318 char * pFileName;
01319 int c;
01320
01321 Extra_UtilGetoptReset();
01322 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
01323 {
01324 switch ( c )
01325 {
01326 case 'h':
01327 goto usage;
01328 default:
01329 goto usage;
01330 }
01331 }
01332 if ( argc != globalUtilOptind + 1 )
01333 goto usage;
01334
01335 pFileName = argv[globalUtilOptind];
01336
01337 Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_BLIFMV );
01338 return 0;
01339
01340 usage:
01341 fprintf( pAbc->Err, "usage: write_blif_mv [-h] <file>\n" );
01342 fprintf( pAbc->Err, "\t write the network into a BLIF-MV file\n" );
01343 fprintf( pAbc->Err, "\t-h : print the help massage\n" );
01344 fprintf( pAbc->Err, "\tfile : the name of the file to write (extension .mv)\n" );
01345 return 1;
01346 }
01347
01359 int IoCommandWriteBench( Abc_Frame_t * pAbc, int argc, char **argv )
01360 {
01361 char * pFileName;
01362 int fUseLuts;
01363 int c;
01364
01365 fUseLuts = 1;
01366 Extra_UtilGetoptReset();
01367 while ( ( c = Extra_UtilGetopt( argc, argv, "lh" ) ) != EOF )
01368 {
01369 switch ( c )
01370 {
01371 case 'l':
01372 fUseLuts ^= 1;
01373 break;
01374 case 'h':
01375 goto usage;
01376 default:
01377 goto usage;
01378 }
01379 }
01380 if ( argc != globalUtilOptind + 1 )
01381 goto usage;
01382
01383 pFileName = argv[globalUtilOptind];
01384
01385 if ( !fUseLuts )
01386 Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_BENCH );
01387 else
01388 {
01389 Abc_Ntk_t * pNtkTemp;
01390 pNtkTemp = Abc_NtkToNetlist( pAbc->pNtkCur );
01391 Abc_NtkToAig( pNtkTemp );
01392 Io_WriteBenchLut( pNtkTemp, pFileName );
01393 Abc_NtkDelete( pNtkTemp );
01394 }
01395 return 0;
01396
01397 usage:
01398 fprintf( pAbc->Err, "usage: write_bench [-lh] <file>\n" );
01399 fprintf( pAbc->Err, "\t write the network in BENCH format\n" );
01400 fprintf( pAbc->Err, "\t-l : toggle using LUTs in the output [default = %s]\n", fUseLuts? "yes" : "no" );
01401 fprintf( pAbc->Err, "\t-h : print the help massage\n" );
01402 fprintf( pAbc->Err, "\tfile : the name of the file to write (extension .bench)\n" );
01403 return 1;
01404 }
01405
01417 int IoCommandWriteCellNet( Abc_Frame_t * pAbc, int argc, char **argv )
01418 {
01419 Abc_Ntk_t * pNtk;
01420 char * pFileName;
01421 int c;
01422 extern void Io_WriteCellNet( Abc_Ntk_t * pNtk, char * pFileName );
01423
01424 Extra_UtilGetoptReset();
01425 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
01426 {
01427 switch ( c )
01428 {
01429 case 'h':
01430 goto usage;
01431 default:
01432 goto usage;
01433 }
01434 }
01435 if ( argc != globalUtilOptind + 1 )
01436 goto usage;
01437 pNtk = pAbc->pNtkCur;
01438 if ( pNtk == NULL )
01439 {
01440 fprintf( pAbc->Out, "Empty network.\n" );
01441 return 0;
01442 }
01443
01444 pFileName = argv[globalUtilOptind];
01445
01446 if ( !Abc_NtkIsLogic(pNtk) )
01447 {
01448 fprintf( pAbc->Out, "The network should be a logic network (if it an AIG, use command \"logic\")\n" );
01449 return 0;
01450 }
01451 Io_WriteCellNet( pNtk, pFileName );
01452 return 0;
01453
01454 usage:
01455 fprintf( pAbc->Err, "usage: write_cellnet [-h] <file>\n" );
01456 fprintf( pAbc->Err, "\t write the network is the cellnet format\n" );
01457 fprintf( pAbc->Err, "\t-h : print the help massage\n" );
01458 fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
01459 return 1;
01460 }
01461
01473 int IoCommandWriteCnf( Abc_Frame_t * pAbc, int argc, char **argv )
01474 {
01475 char * pFileName;
01476 int c;
01477 int fAllPrimes;
01478 int fNewAlgo;
01479 extern Abc_Ntk_t * Abc_NtkDarToCnf( Abc_Ntk_t * pNtk, char * pFileName );
01480
01481 fNewAlgo = 1;
01482 fAllPrimes = 0;
01483 Extra_UtilGetoptReset();
01484 while ( ( c = Extra_UtilGetopt( argc, argv, "nph" ) ) != EOF )
01485 {
01486 switch ( c )
01487 {
01488 case 'n':
01489 fNewAlgo ^= 1;
01490 break;
01491 case 'p':
01492 fAllPrimes ^= 1;
01493 break;
01494 case 'h':
01495 goto usage;
01496 default:
01497 goto usage;
01498 }
01499 }
01500 if ( argc != globalUtilOptind + 1 )
01501 goto usage;
01502
01503 pFileName = argv[globalUtilOptind];
01504
01505 if ( Abc_NtkIsStrash(pAbc->pNtkCur) && fAllPrimes )
01506 {
01507 fAllPrimes = 0;
01508 printf( "Warning: Selected option to write all primes has no effect when deriving CNF from AIG.\n" );
01509 }
01510
01511 if ( fNewAlgo )
01512 Abc_NtkDarToCnf( pAbc->pNtkCur, pFileName );
01513 else if ( fAllPrimes )
01514 Io_WriteCnf( pAbc->pNtkCur, pFileName, 1 );
01515 else
01516 Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_CNF );
01517 return 0;
01518
01519 usage:
01520 fprintf( pAbc->Err, "usage: write_cnf [-nph] <file>\n" );
01521 fprintf( pAbc->Err, "\t write the miter cone into a CNF file\n" );
01522 fprintf( pAbc->Err, "\t-n : toggle using new algorithm [default = %s]\n", fNewAlgo? "yes" : "no" );
01523 fprintf( pAbc->Err, "\t-p : toggle using all primes to enhance implicativity [default = %s]\n", fAllPrimes? "yes" : "no" );
01524 fprintf( pAbc->Err, "\t-h : print the help massage\n" );
01525 fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
01526 return 1;
01527 }
01528
01540 int IoCommandWriteDot( Abc_Frame_t * pAbc, int argc, char **argv )
01541 {
01542 char * pFileName;
01543 int c;
01544
01545 Extra_UtilGetoptReset();
01546 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
01547 {
01548 switch ( c )
01549 {
01550 case 'h':
01551 goto usage;
01552 default:
01553 goto usage;
01554 }
01555 }
01556 if ( argc != globalUtilOptind + 1 )
01557 goto usage;
01558
01559 pFileName = argv[globalUtilOptind];
01560
01561 Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_DOT );
01562 return 0;
01563
01564 usage:
01565 fprintf( pAbc->Err, "usage: write_dot [-h] <file>\n" );
01566 fprintf( pAbc->Err, "\t write the current network into a DOT file\n" );
01567 fprintf( pAbc->Err, "\t-h : print the help massage\n" );
01568 fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
01569 return 1;
01570 }
01571
01583 int IoCommandWriteCounter( Abc_Frame_t * pAbc, int argc, char **argv )
01584 {
01585 Abc_Ntk_t * pNtk;
01586 char * pFileName;
01587 int c;
01588 int fNames;
01589
01590 fNames = 0;
01591 Extra_UtilGetoptReset();
01592 while ( ( c = Extra_UtilGetopt( argc, argv, "nh" ) ) != EOF )
01593 {
01594 switch ( c )
01595 {
01596 case 'n':
01597 fNames ^= 1;
01598 break;
01599 case 'h':
01600 goto usage;
01601 default:
01602 goto usage;
01603 }
01604 }
01605
01606 pNtk = pAbc->pNtkCur;
01607 if ( pNtk == NULL )
01608 {
01609 fprintf( pAbc->Out, "Empty network.\n" );
01610 return 0;
01611 }
01612
01613 if ( argc != globalUtilOptind + 1 )
01614 {
01615 goto usage;
01616 }
01617
01618 pFileName = argv[globalUtilOptind];
01619
01620 if ( pNtk->pModel == NULL )
01621 {
01622 fprintf( pAbc->Out, "Counter-example is not available.\n" );
01623 return 0;
01624 }
01625
01626
01627 {
01628 Abc_Obj_t * pObj;
01629 FILE * pFile = fopen( pFileName, "w" );
01630 int i;
01631 if ( pFile == NULL )
01632 {
01633 fprintf( stdout, "IoCommandWriteCounter(): Cannot open the output file \"%s\".\n", pFileName );
01634 return 1;
01635 }
01636 if ( fNames )
01637 {
01638 Abc_NtkForEachPi( pNtk, pObj, i )
01639 fprintf( pFile, "%s=%c ", Abc_ObjName(pObj), '0'+(pNtk->pModel[i]==1) );
01640 }
01641 else
01642 {
01643 Abc_NtkForEachPi( pNtk, pObj, i )
01644 fprintf( pFile, "%c", '0'+(pNtk->pModel[i]==1) );
01645 }
01646 fprintf( pFile, "\n" );
01647 fclose( pFile );
01648 }
01649
01650 return 0;
01651
01652 usage:
01653 fprintf( pAbc->Err, "usage: write_counter [-nh] <file>\n" );
01654 fprintf( pAbc->Err, "\t writes the counter-example derived by \"prove\" or \"sat\"\n" );
01655 fprintf( pAbc->Err, "\t the file contains values for each PI in the natural order\n" );
01656 fprintf( pAbc->Err, "\t-n : write input names into the file [default = %s]\n", fNames? "yes": "no" );
01657 fprintf( pAbc->Err, "\t-h : print the help massage\n" );
01658 fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
01659 return 1;
01660 }
01661
01662
01674 int IoCommandWriteEqn( Abc_Frame_t * pAbc, int argc, char **argv )
01675 {
01676 char * pFileName;
01677 int c;
01678
01679 Extra_UtilGetoptReset();
01680 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
01681 {
01682 switch ( c )
01683 {
01684 case 'h':
01685 goto usage;
01686 default:
01687 goto usage;
01688 }
01689 }
01690 if ( argc != globalUtilOptind + 1 )
01691 goto usage;
01692
01693 pFileName = argv[globalUtilOptind];
01694
01695 Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_EQN );
01696 return 0;
01697
01698 usage:
01699 fprintf( pAbc->Err, "usage: write_eqn [-h] <file>\n" );
01700 fprintf( pAbc->Err, "\t write the current network in the equation format\n" );
01701 fprintf( pAbc->Err, "\t-h : print the help massage\n" );
01702 fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
01703 return 1;
01704 }
01705
01717 int IoCommandWriteGml( Abc_Frame_t * pAbc, int argc, char **argv )
01718 {
01719 char * pFileName;
01720 int c;
01721
01722 Extra_UtilGetoptReset();
01723 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
01724 {
01725 switch ( c )
01726 {
01727 case 'h':
01728 goto usage;
01729 default:
01730 goto usage;
01731 }
01732 }
01733 if ( argc != globalUtilOptind + 1 )
01734 goto usage;
01735
01736 pFileName = argv[globalUtilOptind];
01737
01738 Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_GML );
01739 return 0;
01740
01741 usage:
01742 fprintf( pAbc->Err, "usage: write_gml [-h] <file>\n" );
01743 fprintf( pAbc->Err, "\t write network using graph representation formal GML\n" );
01744 fprintf( pAbc->Err, "\t-h : print the help massage\n" );
01745 fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
01746 return 1;
01747 }
01748
01760 int IoCommandWriteList( Abc_Frame_t * pAbc, int argc, char **argv )
01761 {
01762 char * pFileName;
01763 int fUseHost;
01764 int c;
01765
01766 printf( "This command currently does not work.\n" );
01767 return 0;
01768
01769 fUseHost = 1;
01770 Extra_UtilGetoptReset();
01771 while ( ( c = Extra_UtilGetopt( argc, argv, "nh" ) ) != EOF )
01772 {
01773 switch ( c )
01774 {
01775 case 'n':
01776 fUseHost ^= 1;
01777 break;
01778 case 'h':
01779 goto usage;
01780 default:
01781 goto usage;
01782 }
01783 }
01784 if ( argc != globalUtilOptind + 1 )
01785 goto usage;
01786 if ( pAbc->pNtkCur == NULL )
01787 {
01788 fprintf( pAbc->Out, "Empty network.\n" );
01789 return 0;
01790 }
01791
01792
01793
01794
01795
01796
01797
01798
01799 pFileName = argv[globalUtilOptind];
01800
01801 Io_WriteList( pAbc->pNtkCur, pFileName, fUseHost );
01802 return 0;
01803
01804 usage:
01805 fprintf( pAbc->Err, "usage: write_list [-nh] <file>\n" );
01806 fprintf( pAbc->Err, "\t write network using graph representation formal GML\n" );
01807 fprintf( pAbc->Err, "\t-n : toggle writing host node [default = %s]\n", fUseHost? "yes":"no" );
01808 fprintf( pAbc->Err, "\t-h : print the help massage\n" );
01809 fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
01810 return 1;
01811 }
01812
01824 int IoCommandWritePla( Abc_Frame_t * pAbc, int argc, char **argv )
01825 {
01826 char * pFileName;
01827 int c;
01828
01829 Extra_UtilGetoptReset();
01830 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
01831 {
01832 switch ( c )
01833 {
01834 case 'h':
01835 goto usage;
01836 default:
01837 goto usage;
01838 }
01839 }
01840 if ( argc != globalUtilOptind + 1 )
01841 goto usage;
01842
01843 pFileName = argv[globalUtilOptind];
01844
01845 Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_PLA );
01846 return 0;
01847
01848 usage:
01849 fprintf( pAbc->Err, "usage: write_pla [-h] <file>\n" );
01850 fprintf( pAbc->Err, "\t write the collapsed network into a PLA file\n" );
01851 fprintf( pAbc->Err, "\t-h : print the help massage\n" );
01852 fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
01853 return 1;
01854 }
01855
01867 int IoCommandWriteVerilog( Abc_Frame_t * pAbc, int argc, char **argv )
01868 {
01869 char * pFileName;
01870 int c;
01871
01872 Extra_UtilGetoptReset();
01873 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
01874 {
01875 switch ( c )
01876 {
01877 case 'h':
01878 goto usage;
01879 default:
01880 goto usage;
01881 }
01882 }
01883 if ( argc != globalUtilOptind + 1 )
01884 goto usage;
01885
01886 pFileName = argv[globalUtilOptind];
01887
01888 Io_Write( pAbc->pNtkCur, pFileName, IO_FILE_VERILOG );
01889 return 0;
01890
01891 usage:
01892 fprintf( pAbc->Err, "usage: write_verilog [-h] <file>\n" );
01893 fprintf( pAbc->Err, "\t write the current network in Verilog format\n" );
01894 fprintf( pAbc->Err, "\t-h : print the help massage\n" );
01895 fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
01896 return 1;
01897 }
01898
01910 int IoCommandWriteVerLib( Abc_Frame_t * pAbc, int argc, char **argv )
01911 {
01912 Abc_Lib_t * pLibrary;
01913 char * pFileName;
01914 int c;
01915 extern void Io_WriteVerilogLibrary( Abc_Lib_t * pLibrary, char * pFileName );
01916
01917 Extra_UtilGetoptReset();
01918 while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
01919 {
01920 switch ( c )
01921 {
01922 case 'h':
01923 goto usage;
01924 default:
01925 goto usage;
01926 }
01927 }
01928 if ( argc != globalUtilOptind + 1 )
01929 goto usage;
01930
01931 pFileName = argv[globalUtilOptind];
01932
01933 pLibrary = Abc_FrameReadLibVer();
01934 if ( pLibrary == NULL )
01935 {
01936 fprintf( pAbc->Out, "Verilog library is not specified.\n" );
01937 return 0;
01938 }
01939
01940 return 0;
01941
01942 usage:
01943 fprintf( pAbc->Err, "usage: write_verlib [-h] <file>\n" );
01944 fprintf( pAbc->Err, "\t write the current verilog library\n" );
01945 fprintf( pAbc->Err, "\t-h : print the help massage\n" );
01946 fprintf( pAbc->Err, "\tfile : the name of the file to write\n" );
01947 return 1;
01948 }
01949
01953
01954