22#ifndef _DEFAULT_SOURCE
23#define _DEFAULT_SOURCE
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 );
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",
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",
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",
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' );
157 Vec_StrFree( vLibStr );
158 Vec_StrFree( vLibStr2 );
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' );
171 Vec_StrFree( vLibStr );
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' );
184 Vec_StrFree( vLibStr );
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 );
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 );
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 );
264 pLib =
Mio_LibraryRead( pFileName, Vec_StrArray(vStr), NULL, 0, fVerbose );
301int Mio_CommandReadLiberty(
Abc_Frame_t * pAbc,
int argc,
char **argv )
303 int fUseFileInterface = 0;
337 if ( (pFile =
Io_FileOpen( pFileName,
"open_path",
"r", 0 )) == NULL )
339 fprintf( pErr,
"Cannot open input file \"%s\". ", pFileName );
341 fprintf( pErr,
"Did you mean \"%s\"?", pFileName );
342 fprintf( pErr,
"\n" );
347 if ( fUseFileInterface )
362 vStr2 = Vec_StrDup(vStr);
365 Vec_StrFree( vStr2 );
367 printf(
"Reading library has filed.\n" );
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");
393int Mio_CommandReadGenlib(
Abc_Frame_t * pAbc,
int argc,
char **argv )
400 char * pExcludeFile = NULL;
401 double WireDelay = 0.0;
416 Abc_Print( -1,
"Command line switch \"-W\" should be followed by a floating point number.\n" );
421 if ( WireDelay <= 0.0 )
427 Abc_Print( -1,
"Command line switch \"-E\" should be followed by a file name.\n" );
436 Abc_Print( -1,
"Command line switch \"-K\" should be followed by a file name.\n" );
462 if ( (pFile =
Io_FileOpen( pFileName,
"open_path",
"r", 0 )) == NULL )
464 fprintf( pErr,
"Cannot open input file \"%s\". ", pFileName );
466 fprintf( pErr,
"Did you mean \"%s\"?", pFileName );
467 fprintf( pErr,
"\n" );
473 pLib =
Mio_LibraryRead( pFileName, NULL, pExcludeFile, nFaninLimit, fVerbose );
476 fprintf( pErr,
"Reading genlib library has failed.\n" );
480 printf(
"Entered genlib library with %d gates from file \"%s\".\n",
Mio_LibraryReadGateNum(pLib), pFileName );
487 if ( WireDelay != 0.0 )
497 fprintf( pErr,
"Reading second genlib library has failed.\n" );
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");
529int Mio_CommandWriteGenlib(
Abc_Frame_t * pAbc,
int argc,
char **argv )
531 FILE * pOut, * pErr, * pFile;
564 printf(
"Library is not available.\n" );
569 printf(
"The file name is not given.\n" );
574 pFile = fopen( pFileName,
"w" );
577 printf(
"Error! Cannot open file \"%s\" for writing the library.\n", pFileName );
585 printf(
"The current genlib library is written into file \"%s\".\n", pFileName );
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");
610int Mio_CommandPrintGenlib(
Abc_Frame_t * pAbc,
int argc,
char **argv )
645 printf(
"Library is not available.\n" );
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");
673int Mio_CommandReadProfile(
Abc_Frame_t * pAbc,
int argc,
char **argv )
675 FILE * pFile, * pOut, * pErr;
704 fprintf( pErr,
"There is no Genlib library entered.\n" );
710 if ( (pFile =
Io_FileOpen( pFileName,
"open_path",
"r", 0 )) == NULL )
712 fprintf( pErr,
"Cannot open input file \"%s\". ", pFileName );
714 fprintf( pErr,
"Did you mean \"%s\"?", pFileName );
715 fprintf( pErr,
"\n" );
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");
743int Mio_CommandWriteProfile(
Abc_Frame_t * pAbc,
int argc,
char **argv )
745 FILE * pOut, * pErr, * pFile;
766 printf(
"Library is not available.\n" );
771 printf(
"The file name is not given.\n" );
776 pFile = fopen( pFileName,
"w" );
779 printf(
"Error! Cannot open file \"%s\" for writing the library.\n", pFileName );
784 printf(
"The current profile is written into file \"%s\".\n", pFileName );
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");
806int Mio_CommandPrintProfile(
Abc_Frame_t * pAbc,
int argc,
char **argv )
841 printf(
"Library is not available.\n" );
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");
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
Amap_Lib_t * Amap_LibReadAndPrepare(char *pFileName, char *pBuffer, int fVerbose, int fVeryVerbose)
typedefABC_NAMESPACE_HEADER_START struct Amap_Lib_t_ Amap_Lib_t
INCLUDES ///.
Vec_Str_t * Amap_LibertyParseStr(char *pFileName, int fVerbose)
int Amap_LibertyParse(char *pFileName, int fVerbose)
void Amap_LibFree(Amap_Lib_t *p)
ABC_DLL void Abc_FrameSetLibGen(void *pLib)
ABC_DLL void Abc_FrameSetLibSuper(void *pLib)
ABC_DLL void * Abc_FrameReadLibGen()
ABC_DLL void Abc_FrameSetLibGen2(void *pLib)
ABC_DLL void * Abc_FrameReadLibGen2()
ABC_DLL FILE * Abc_FrameReadErr(Abc_Frame_t *p)
ABC_DLL void * Abc_FrameReadLibSuper()
ABC_DLL FILE * Abc_FrameReadOut(Abc_Frame_t *p)
struct Vec_Str_t_ Vec_Str_t
void Cmd_CommandAdd(Abc_Frame_t *pAbc, const char *sGroup, const char *sName, Cmd_CommandFuncType pFunc, int fChanges)
ABC_DLL int Cmd_CommandExecute(Abc_Frame_t *pAbc, const char *sCommand)
FILE * Io_FileOpen(const char *FileName, const char *PathVar, const char *Mode, int fVerbose)
struct Map_SuperLibStruct_t_ Map_SuperLib_t
void Map_SuperLibFree(Map_SuperLib_t *p)
Mio_Library_t * Mio_LibraryReadBuffer(char *pBuffer, int fExtendedFormat, st__table *tExcludeGate, int nFaninLimit, int fVerbose)
void Mio_IntallAndLibrary()
FUNCTION DEFINITIONS ///.
void Mio_Init(Abc_Frame_t *pAbc)
void Mio_IntallSimpleLibrary()
int Mio_UpdateGenlib2(Vec_Str_t *vStr, Vec_Str_t *vStr2, char *pFileName, int fVerbose)
void Mio_IntallSimpleLibrary2()
void Mio_UpdateGenlib(Mio_Library_t *pLib)
FUNCTION DEFINITIONS ///.
void Mio_End(Abc_Frame_t *pAbc)
void Mio_WriteLibraryVerilog(FILE *pFile, Mio_Library_t *pLib, int fPrintSops, int fShort, int fSelected)
void Mio_LibraryReadProfile(FILE *pFile, Mio_Library_t *pLib)
void Mio_LibraryShortNames(Mio_Library_t *pLib)
void Mio_LibraryShiftDelay(Mio_Library_t *pLib, double Shift)
struct Mio_LibraryStruct_t_ Mio_Library_t
void Mio_LibraryDelete(Mio_Library_t *pLib)
DECLARATIONS ///.
void Mio_WriteLibrary(FILE *pFile, Mio_Library_t *pLib, int fPrintSops, int fShort, int fSelected)
int Mio_LibraryReadGateNum(Mio_Library_t *pLib)
void Mio_LibrarySetName(Mio_Library_t *pLib, char *pName)
Mio_Library_t * Mio_LibraryRead(char *FileName, char *pBuffer, char *ExcludeFile, int nFaninLimit, int fVerbose)
void Mio_LibraryWriteProfile(FILE *pFile, Mio_Library_t *pLib)