Commit 95207366 by Alan Mishchenko

Added several new APIs to GIA and for file management.

parent 9eb1be8e
...@@ -472,12 +472,20 @@ static inline int Gia_ManAppendCo( Gia_Man_t * p, int iLit0 ) ...@@ -472,12 +472,20 @@ static inline int Gia_ManAppendCo( Gia_Man_t * p, int iLit0 )
Gia_ObjAddFanout( p, Gia_ObjFanin0(pObj), pObj ); Gia_ObjAddFanout( p, Gia_ObjFanin0(pObj), pObj );
return Gia_ObjId( p, pObj ) << 1; return Gia_ObjId( p, pObj ) << 1;
} }
static inline int Gia_ManAppendOr( Gia_Man_t * p, int iLit0, int iLit1 )
{
return Abc_LitNot(Gia_ManAppendAnd( p, Abc_LitNot(iLit0), Abc_LitNot(iLit1) ));
}
static inline int Gia_ManAppendMux( Gia_Man_t * p, int iCtrl, int iData1, int iData0 ) static inline int Gia_ManAppendMux( Gia_Man_t * p, int iCtrl, int iData1, int iData0 )
{ {
int iTemp0 = Gia_ManAppendAnd( p, Abc_LitNot(iCtrl), iData0 ); int iTemp0 = Gia_ManAppendAnd( p, Abc_LitNot(iCtrl), iData0 );
int iTemp1 = Gia_ManAppendAnd( p, iCtrl, iData1 ); int iTemp1 = Gia_ManAppendAnd( p, iCtrl, iData1 );
return Abc_LitNotCond( Gia_ManAppendAnd( p, Abc_LitNot(iTemp0), Abc_LitNot(iTemp1) ), 1 ); return Abc_LitNotCond( Gia_ManAppendAnd( p, Abc_LitNot(iTemp0), Abc_LitNot(iTemp1) ), 1 );
} }
static inline int Gia_ManAppendXor( Gia_Man_t * p, int iLit0, int iLit1 )
{
return Gia_ManAppendMux( p, iLit0, Abc_LitNot(iLit1), iLit1 );
}
#define GIA_ZER 1 #define GIA_ZER 1
#define GIA_ONE 2 #define GIA_ONE 2
...@@ -728,6 +736,7 @@ extern void Gia_ManHashAlloc( Gia_Man_t * p ); ...@@ -728,6 +736,7 @@ extern void Gia_ManHashAlloc( Gia_Man_t * p );
extern void Gia_ManHashStart( Gia_Man_t * p ); extern void Gia_ManHashStart( Gia_Man_t * p );
extern void Gia_ManHashStop( Gia_Man_t * p ); extern void Gia_ManHashStop( Gia_Man_t * p );
extern int Gia_ManHashAnd( Gia_Man_t * p, int iLit0, int iLit1 ); extern int Gia_ManHashAnd( Gia_Man_t * p, int iLit0, int iLit1 );
extern int Gia_ManHashOr( Gia_Man_t * p, int iLit0, int iLit1 );
extern int Gia_ManHashXor( Gia_Man_t * p, int iLit0, int iLit1 ); extern int Gia_ManHashXor( Gia_Man_t * p, int iLit0, int iLit1 );
extern int Gia_ManHashMux( Gia_Man_t * p, int iCtrl, int iData1, int iData0 ); extern int Gia_ManHashMux( Gia_Man_t * p, int iCtrl, int iData1, int iData0 );
extern int Gia_ManHashAndTry( Gia_Man_t * p, int iLit0, int iLit1 ); extern int Gia_ManHashAndTry( Gia_Man_t * p, int iLit0, int iLit1 );
......
...@@ -511,6 +511,10 @@ int Gia_ManHashAnd( Gia_Man_t * p, int iLit0, int iLit1 ) ...@@ -511,6 +511,10 @@ int Gia_ManHashAnd( Gia_Man_t * p, int iLit0, int iLit1 )
} }
} }
} }
int Gia_ManHashOr( Gia_Man_t * p, int iLit0, int iLit1 )
{
return Abc_LitNot(Gia_ManHashAnd( p, Abc_LitNot(iLit0), Abc_LitNot(iLit1) ));
}
/**Function************************************************************* /**Function*************************************************************
......
...@@ -107,7 +107,9 @@ extern char * Extra_FileNameGenericAppend( char * pBase, char * pSuffix ); ...@@ -107,7 +107,9 @@ extern char * Extra_FileNameGenericAppend( char * pBase, char * pSuffix );
extern int Extra_FileCheck( char * pFileName ); extern int Extra_FileCheck( char * pFileName );
extern int Extra_FileSize( char * pFileName ); extern int Extra_FileSize( char * pFileName );
extern char * Extra_FileRead( FILE * pFile ); extern char * Extra_FileRead( FILE * pFile );
extern char * Extra_FileRead2( FILE * pFile, FILE * pFile2 );
extern char * Extra_FileReadContents( char * pFileName ); extern char * Extra_FileReadContents( char * pFileName );
extern char * Extra_FileReadContents2( char * pFileName, char * pFileName2 );
extern int Extra_FileIsType( char * pFileName, char * pS1, char * pS2, char * pS3 ); extern int Extra_FileIsType( char * pFileName, char * pS1, char * pS2, char * pS3 );
extern char * Extra_TimeStamp(); extern char * Extra_TimeStamp();
extern char * Extra_StringAppend( char * pStrGiven, char * pStrAdd ); extern char * Extra_StringAppend( char * pStrGiven, char * pStrAdd );
......
...@@ -276,6 +276,28 @@ char * Extra_FileRead( FILE * pFile ) ...@@ -276,6 +276,28 @@ char * Extra_FileRead( FILE * pFile )
pBuffer[ nFileSize + 1] = '\0'; pBuffer[ nFileSize + 1] = '\0';
return pBuffer; return pBuffer;
} }
char * Extra_FileRead2( FILE * pFile, FILE * pFile2 )
{
char * pBuffer;
int nSize, nSize2;
int RetValue;
// get the file size, in bytes
fseek( pFile, 0, SEEK_END );
nSize = ftell( pFile );
rewind( pFile );
// get the file size, in bytes
fseek( pFile2, 0, SEEK_END );
nSize2 = ftell( pFile2 );
rewind( pFile2 );
// load the contents of the file into memory
pBuffer = ABC_ALLOC( char, nSize + nSize2 + 3 );
RetValue = fread( pBuffer, nSize, 1, pFile );
RetValue = fread( pBuffer + nSize, nSize2, 1, pFile2 );
// terminate the string with '\0'
pBuffer[ nSize + nSize2 + 0] = '\n';
pBuffer[ nSize + nSize2 + 1] = '\0';
return pBuffer;
}
/**Function************************************************************* /**Function*************************************************************
...@@ -294,8 +316,18 @@ char * Extra_FileReadContents( char * pFileName ) ...@@ -294,8 +316,18 @@ char * Extra_FileReadContents( char * pFileName )
char * pBuffer; char * pBuffer;
pFile = fopen( pFileName, "rb" ); pFile = fopen( pFileName, "rb" );
pBuffer = pFile ? Extra_FileRead( pFile ) : NULL; pBuffer = pFile ? Extra_FileRead( pFile ) : NULL;
if ( pFile ) if ( pFile ) fclose( pFile );
fclose( pFile ); return pBuffer;
}
char * Extra_FileReadContents2( char * pFileName, char * pFileName2 )
{
FILE * pFile, * pFile2;
char * pBuffer;
pFile = fopen( pFileName, "rb" );
pFile2 = fopen( pFileName2, "rb" );
pBuffer = (pFile && pFile2) ? Extra_FileRead2( pFile, pFile2 ) : NULL;
if ( pFile ) fclose( pFile );
if ( pFile2 ) fclose( pFile2 );
return pBuffer; return pBuffer;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment