From 35a8768c50e73c8f4020e81f018c07b6c8dc1489 Mon Sep 17 00:00:00 2001 From: Yukio Miyasaka Date: Sun, 22 Sep 2024 14:34:18 -0700 Subject: [PATCH] ttopt bugfix --- src/aig/gia/giaMinLut.c | 10 +++++----- src/aig/gia/giaTtopt.cpp | 11 +++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/aig/gia/giaMinLut.c b/src/aig/gia/giaMinLut.c index 5304486de4..e08ebec56e 100644 --- a/src/aig/gia/giaMinLut.c +++ b/src/aig/gia/giaMinLut.c @@ -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' ) diff --git a/src/aig/gia/giaTtopt.cpp b/src/aig/gia/giaTtopt.cpp index a765633f8c..7f16b0d06a 100644 --- a/src/aig/gia/giaTtopt.cpp +++ b/src/aig/gia/giaTtopt.cpp @@ -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++ ) {