Merge pull request #335 from MyskYko/fix_ttopt

ttopt bugfix
This commit is contained in:
alanminko 2024-09-22 20:47:59 -07:00 committed by GitHub
commit 3f7a30828f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 5 deletions

View File

@ -193,7 +193,7 @@ Gia_Man_t * Vec_WrdReadTest( char * pFileName )
void Vec_WrdReadText( char * pFileName, Vec_Wrd_t ** pvSimI, Vec_Wrd_t ** pvSimO, int nIns, int nOuts )
{
int i, nSize, iLine, nLines, nWords;
char pLine[1000];
char pLine[2000];
Vec_Wrd_t * vSimI, * vSimO;
FILE * pFile = fopen( pFileName, "rb" );
if ( pFile == NULL )
@ -214,7 +214,7 @@ void Vec_WrdReadText( char * pFileName, Vec_Wrd_t ** pvSimI, Vec_Wrd_t ** pvSimO
nWords = (nLines + 63)/64;
vSimI = Vec_WrdStart( nIns *nWords );
vSimO = Vec_WrdStart( nOuts*nWords );
for ( iLine = 0; fgets( pLine, 1000, pFile ); iLine++ )
for ( iLine = 0; fgets( pLine, 2000, pFile ); iLine++ )
{
for ( i = 0; i < nIns; i++ )
if ( pLine[nIns-1-i] == '1' )
@ -233,7 +233,7 @@ void Vec_WrdReadText( char * pFileName, Vec_Wrd_t ** pvSimI, Vec_Wrd_t ** pvSimO
int Vec_WrdReadText2( char * pFileName, Vec_Wrd_t ** pvSimI )
{
int i, nSize, iLine, nLines, nWords, nIns;
char pLine[1000];
char pLine[2000];
Vec_Wrd_t * vSimI;
FILE * pFile = fopen( pFileName, "rb" );
if ( pFile == NULL )
@ -241,7 +241,7 @@ int Vec_WrdReadText2( char * pFileName, Vec_Wrd_t ** pvSimI )
printf( "Cannot open file \"%s\" for reading.\n", pFileName );
return 0;
}
if ( !fgets(pLine, 1000, pFile) || (nIns = strlen(pLine)-1) < 1 )
if ( !fgets(pLine, 2000, pFile) || (nIns = strlen(pLine)-1) < 1 )
{
printf( "Cannot find the number of inputs in file \"%s\".\n", pFileName );
fclose( pFile );
@ -259,7 +259,7 @@ int Vec_WrdReadText2( char * pFileName, Vec_Wrd_t ** pvSimI )
nLines = nSize / (nIns + 1);
nWords = (nLines + 63)/64;
vSimI = Vec_WrdStart( nIns *nWords );
for ( iLine = 0; fgets( pLine, 1000, pFile ); iLine++ )
for ( iLine = 0; fgets( pLine, 2000, pFile ); iLine++ )
{
for ( i = 0; i < nIns; i++ )
if ( pLine[nIns-1-i] == '1' )

View File

@ -1176,6 +1176,17 @@ Gia_Man_t * Gia_ManTtoptCare( Gia_Man_t * p, int nIns, int nOuts, int nRounds, c
{
vSupp = Gia_ManCollectSuppNew( p, g, nOuts );
nInputs = Vec_IntSize( vSupp );
if ( nInputs == 0 )
{
for ( k = 0; k < nOuts; k++ )
{
pObj = Gia_ManCo( p, g+k );
pTruth = Gia_ObjComputeTruthTableCut( p, Gia_ObjFanin0(pObj), vSupp );
Gia_ManAppendCo( pNew, pTruth[0] & 1 );
}
Vec_IntFree( vSupp );
continue;
}
Ttopt::TruthTableLevelTSM tt( nInputs, nOuts );
for ( k = 0; k < nOuts; k++ )
{