00001
00019 #include "abc.h"
00020 #include "mainInt.h"
00021 #include "mio.h"
00022 #include "mapperInt.h"
00023
00027
00028 static int Map_CommandReadLibrary ( Abc_Frame_t * pAbc, int argc, char **argv );
00029
00033
00045 void Map_Init( Abc_Frame_t * pAbc )
00046 {
00047 Cmd_CommandAdd( pAbc, "SC mapping", "read_super", Map_CommandReadLibrary, 0 );
00048 }
00049
00061 void Map_End()
00062 {
00063
00064 Map_SuperLibFree( Abc_FrameReadLibSuper() );
00065 }
00066
00067
00079 int Map_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv )
00080 {
00081 FILE * pFile;
00082 FILE * pOut, * pErr;
00083 Map_SuperLib_t * pLib;
00084 Abc_Ntk_t * pNet;
00085 char * FileName, * ExcludeFile;
00086 int fVerbose;
00087 int fAlgorithm;
00088 int c;
00089
00090 pNet = Abc_FrameReadNtk(pAbc);
00091 pOut = Abc_FrameReadOut(pAbc);
00092 pErr = Abc_FrameReadErr(pAbc);
00093
00094
00095 fVerbose = 1;
00096 fAlgorithm = 1;
00097 ExcludeFile = 0;
00098 Extra_UtilGetoptReset();
00099 while ( (c = Extra_UtilGetopt(argc, argv, "eovh")) != EOF )
00100 {
00101 switch (c)
00102 {
00103 case 'e':
00104 ExcludeFile = argv[globalUtilOptind];
00105 if ( ExcludeFile == 0 )
00106 goto usage;
00107 globalUtilOptind++;
00108 break;
00109 case 'o':
00110 fAlgorithm ^= 1;
00111 break;
00112 case 'v':
00113 fVerbose ^= 1;
00114 break;
00115 case 'h':
00116 goto usage;
00117 break;
00118 default:
00119 goto usage;
00120 }
00121 }
00122
00123
00124 if ( argc != globalUtilOptind + 1 )
00125 {
00126 goto usage;
00127 }
00128
00129
00130 FileName = argv[globalUtilOptind];
00131 if ( (pFile = Io_FileOpen( FileName, "open_path", "r", 0 )) == NULL )
00132
00133 {
00134 fprintf( pErr, "Cannot open input file \"%s\". ", FileName );
00135 if ( FileName = Extra_FileGetSimilarName( FileName, ".genlib", ".lib", ".gen", ".g", NULL ) )
00136 fprintf( pErr, "Did you mean \"%s\"?", FileName );
00137 fprintf( pErr, "\n" );
00138 return 1;
00139 }
00140 fclose( pFile );
00141
00142
00143 pLib = Map_SuperLibCreate( FileName, ExcludeFile, fAlgorithm, fVerbose );
00144 if ( pLib == NULL )
00145 {
00146 fprintf( pErr, "Reading supergate library has failed.\n" );
00147 goto usage;
00148 }
00149
00150
00151
00152 Map_SuperLibFree( Abc_FrameReadLibSuper() );
00153 Abc_FrameSetLibSuper( pLib );
00154
00155
00156
00157 Mio_LibraryDelete( Abc_FrameReadLibGen() );
00158 Abc_FrameSetLibGen( pLib->pGenlib );
00159 return 0;
00160
00161 usage:
00162 fprintf( pErr, "\nusage: read_super [-ovh]\n");
00163 fprintf( pErr, "\t read the supergate library from the file\n" );
00164 fprintf( pErr, "\t-e file : file contains list of genlib gates to exclude\n" );
00165 fprintf( pErr, "\t-o : toggles the use of old file format [default = %s]\n", (fAlgorithm? "new" : "old") );
00166 fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") );
00167 fprintf( pErr, "\t-h : print the command usage\n");
00168 return 1;
00169 }
00170
00171
00175
00176