Commit ff1fd41a by Alan Mishchenko

Modifications to read SMTLIB file from stdin.

parent 5e0d7dad
...@@ -21448,6 +21448,7 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -21448,6 +21448,7 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv )
int fAlignPol; int fAlignPol;
int fAndOuts; int fAndOuts;
int fNewSolver; int fNewSolver;
int fSilent;
int fVerbose; int fVerbose;
int nConfLimit; int nConfLimit;
int nLearnedStart; int nLearnedStart;
...@@ -21461,6 +21462,7 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -21461,6 +21462,7 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv )
fAlignPol = 0; fAlignPol = 0;
fAndOuts = 0; fAndOuts = 0;
fNewSolver = 0; fNewSolver = 0;
fSilent = 0;
fVerbose = 0; fVerbose = 0;
nConfLimit = 0; nConfLimit = 0;
nInsLimit = 0; nInsLimit = 0;
...@@ -21468,7 +21470,7 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -21468,7 +21470,7 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv )
nLearnedDelta = 0; nLearnedDelta = 0;
nLearnedPerce = 0; nLearnedPerce = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "CILDEpanvh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "CILDEpansvh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
...@@ -21536,6 +21538,9 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -21536,6 +21538,9 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'n': case 'n':
fNewSolver ^= 1; fNewSolver ^= 1;
break; break;
case 's':
fSilent ^= 1;
break;
case 'v': case 'v':
fVerbose ^= 1; fVerbose ^= 1;
break; break;
...@@ -21596,18 +21601,20 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -21596,18 +21601,20 @@ int Abc_CommandDSat( Abc_Frame_t * pAbc, int argc, char ** argv )
pAbc->pCex = Abc_CexCreate( 0, Abc_NtkPiNum(pNtk), pNtk->pModel, 0, 0, 0 ); pAbc->pCex = Abc_CexCreate( 0, Abc_NtkPiNum(pNtk), pNtk->pModel, 0, 0, 0 );
} }
pAbc->Status = RetValue; pAbc->Status = RetValue;
if ( RetValue == -1 ) if ( !fSilent )
Abc_Print( 1, "UNDECIDED " ); {
else if ( RetValue == 0 ) if ( RetValue == -1 )
Abc_Print( 1, "SATISFIABLE " ); Abc_Print( 1, "UNDECIDED " );
else else if ( RetValue == 0 )
Abc_Print( 1, "UNSATISFIABLE " ); Abc_Print( 1, "SATISFIABLE " );
//Abc_Print( -1, "\n" ); else
Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); Abc_Print( 1, "UNSATISFIABLE " );
Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
}
return 0; return 0;
usage: usage:
Abc_Print( -2, "usage: dsat [-CILDE num] [-panvh]\n" ); Abc_Print( -2, "usage: dsat [-CILDE num] [-pansvh]\n" );
Abc_Print( -2, "\t solves the combinational miter using SAT solver MiniSat-1.14\n" ); Abc_Print( -2, "\t solves the combinational miter using SAT solver MiniSat-1.14\n" );
Abc_Print( -2, "\t derives CNF from the current network and leaves it unchanged\n" ); Abc_Print( -2, "\t derives CNF from the current network and leaves it unchanged\n" );
Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit ); Abc_Print( -2, "\t-C num : limit on the number of conflicts [default = %d]\n", nConfLimit );
...@@ -21618,6 +21625,7 @@ usage: ...@@ -21618,6 +21625,7 @@ usage:
Abc_Print( -2, "\t-p : align polarity of SAT variables [default = %s]\n", fAlignPol? "yes": "no" ); Abc_Print( -2, "\t-p : align polarity of SAT variables [default = %s]\n", fAlignPol? "yes": "no" );
Abc_Print( -2, "\t-a : toggle ANDing/ORing of miter outputs [default = %s]\n", fAndOuts? "ANDing": "ORing" ); Abc_Print( -2, "\t-a : toggle ANDing/ORing of miter outputs [default = %s]\n", fAndOuts? "ANDing": "ORing" );
Abc_Print( -2, "\t-n : toggle using new solver [default = %s]\n", fNewSolver? "yes": "no" ); Abc_Print( -2, "\t-n : toggle using new solver [default = %s]\n", fNewSolver? "yes": "no" );
Abc_Print( -2, "\t-s : enable silent computation (no reporting) [default = %s]\n", fSilent? "yes": "no" );
Abc_Print( -2, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-v : prints verbose information [default = %s]\n", fVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n"); Abc_Print( -2, "\t-h : print the command usage\n");
return 1; return 1;
...@@ -218,7 +218,11 @@ int Cba_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -218,7 +218,11 @@ int Cba_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv )
{ {
p = Cba_ManReadCba( pFileName ); p = Cba_ManReadCba( pFileName );
} }
else assert( 0 ); else
{
printf( "Unrecognized input file extension.\n" );
return 0;
}
Cba_AbcUpdateMan( pAbc, p ); Cba_AbcUpdateMan( pAbc, p );
return 0; return 0;
usage: usage:
......
...@@ -68,24 +68,25 @@ typedef enum { ...@@ -68,24 +68,25 @@ typedef enum {
WLC_OBJ_LOGIC_NOT, // 23: logic NOT WLC_OBJ_LOGIC_NOT, // 23: logic NOT
WLC_OBJ_LOGIC_AND, // 24: logic AND WLC_OBJ_LOGIC_AND, // 24: logic AND
WLC_OBJ_LOGIC_OR, // 25: logic OR WLC_OBJ_LOGIC_OR, // 25: logic OR
WLC_OBJ_COMP_EQU, // 26: compare equal WLC_OBJ_LOGIC_XOR, // 26: logic XOR
WLC_OBJ_COMP_NOTEQU, // 27: compare not equal WLC_OBJ_COMP_EQU, // 27: compare equal
WLC_OBJ_COMP_LESS, // 28: compare less WLC_OBJ_COMP_NOTEQU, // 28: compare not equal
WLC_OBJ_COMP_MORE, // 29: compare more WLC_OBJ_COMP_LESS, // 29: compare less
WLC_OBJ_COMP_LESSEQU, // 30: compare less or equal WLC_OBJ_COMP_MORE, // 30: compare more
WLC_OBJ_COMP_MOREEQU, // 31: compare more or equal WLC_OBJ_COMP_LESSEQU, // 31: compare less or equal
WLC_OBJ_REDUCT_AND, // 32: reduction AND WLC_OBJ_COMP_MOREEQU, // 32: compare more or equal
WLC_OBJ_REDUCT_OR, // 33: reduction OR WLC_OBJ_REDUCT_AND, // 33: reduction AND
WLC_OBJ_REDUCT_XOR, // 34: reduction XOR WLC_OBJ_REDUCT_OR, // 34: reduction OR
WLC_OBJ_ARI_ADD, // 35: arithmetic addition WLC_OBJ_REDUCT_XOR, // 35: reduction XOR
WLC_OBJ_ARI_SUB, // 36: arithmetic subtraction WLC_OBJ_ARI_ADD, // 36: arithmetic addition
WLC_OBJ_ARI_MULTI, // 37: arithmetic multiplier WLC_OBJ_ARI_SUB, // 37: arithmetic subtraction
WLC_OBJ_ARI_DIVIDE, // 38: arithmetic division WLC_OBJ_ARI_MULTI, // 38: arithmetic multiplier
WLC_OBJ_ARI_MODULUS, // 39: arithmetic modulus WLC_OBJ_ARI_DIVIDE, // 39: arithmetic division
WLC_OBJ_ARI_POWER, // 40: arithmetic power WLC_OBJ_ARI_MODULUS, // 40: arithmetic modulus
WLC_OBJ_ARI_MINUS, // 41: arithmetic minus WLC_OBJ_ARI_POWER, // 41: arithmetic power
WLC_OBJ_TABLE, // 42: bit table WLC_OBJ_ARI_MINUS, // 42: arithmetic minus
WLC_OBJ_NUMBER // 43: unused WLC_OBJ_TABLE, // 43: bit table
WLC_OBJ_NUMBER // 44: unused
} Wlc_ObjType_t; } Wlc_ObjType_t;
...@@ -135,6 +136,7 @@ struct Wlc_Ntk_t_ ...@@ -135,6 +136,7 @@ struct Wlc_Ntk_t_
// object names // object names
Abc_Nam_t * pManName; // object names Abc_Nam_t * pManName; // object names
Vec_Int_t vNameIds; // object name IDs Vec_Int_t vNameIds; // object name IDs
Vec_Int_t vValues; // value objects
// object attributes // object attributes
int nTravIds; // counter of traversal IDs int nTravIds; // counter of traversal IDs
Vec_Int_t vTravIds; // trav IDs of the objects Vec_Int_t vTravIds; // trav IDs of the objects
...@@ -257,6 +259,7 @@ extern void Wlc_NtkPrintNodes( Wlc_Ntk_t * p, int Type ); ...@@ -257,6 +259,7 @@ extern void Wlc_NtkPrintNodes( Wlc_Ntk_t * p, int Type );
extern void Wlc_NtkPrintStats( Wlc_Ntk_t * p, int fDistrib, int fVerbose ); extern void Wlc_NtkPrintStats( Wlc_Ntk_t * p, int fDistrib, int fVerbose );
extern Wlc_Ntk_t * Wlc_NtkDupDfs( Wlc_Ntk_t * p ); extern Wlc_Ntk_t * Wlc_NtkDupDfs( Wlc_Ntk_t * p );
extern void Wlc_NtkTransferNames( Wlc_Ntk_t * pNew, Wlc_Ntk_t * p ); extern void Wlc_NtkTransferNames( Wlc_Ntk_t * pNew, Wlc_Ntk_t * p );
extern void Wlc_NtkReport( Wlc_Ntk_t * p, Vec_Int_t * vAssign );
/*=== wlcReadSmt.c ========================================================*/ /*=== wlcReadSmt.c ========================================================*/
extern Wlc_Ntk_t * Wlc_ReadSmtBuffer( char * pFileName, char * pBuffer, char * pLimit ); extern Wlc_Ntk_t * Wlc_ReadSmtBuffer( char * pFileName, char * pBuffer, char * pLimit );
extern Wlc_Ntk_t * Wlc_ReadSmt( char * pFileName ); extern Wlc_Ntk_t * Wlc_ReadSmt( char * pFileName );
......
...@@ -658,6 +658,14 @@ Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Vec_Int_t * vBoxIds ) ...@@ -658,6 +658,14 @@ Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Vec_Int_t * vBoxIds )
for ( k = 1; k < nRange; k++ ) for ( k = 1; k < nRange; k++ )
Vec_IntPush( vRes, 0 ); Vec_IntPush( vRes, 0 );
} }
else if ( pObj->Type == WLC_OBJ_LOGIC_XOR )
{
int iLit0 = Wlc_BlastReduction( pNew, pFans0, nRange0, WLC_OBJ_REDUCT_OR );
int iLit1 = Wlc_BlastReduction( pNew, pFans1, nRange1, WLC_OBJ_REDUCT_OR );
Vec_IntFill( vRes, 1, Gia_ManHashXor(pNew, iLit0, iLit1) );
for ( k = 1; k < nRange; k++ )
Vec_IntPush( vRes, 0 );
}
else if ( pObj->Type == WLC_OBJ_COMP_EQU || pObj->Type == WLC_OBJ_COMP_NOTEQU ) else if ( pObj->Type == WLC_OBJ_COMP_EQU || pObj->Type == WLC_OBJ_COMP_NOTEQU )
{ {
int iLit = 0, nRangeMax = Abc_MaxInt( nRange0, nRange1 ); int iLit = 0, nRangeMax = Abc_MaxInt( nRange0, nRange1 );
......
...@@ -115,21 +115,34 @@ static inline int Wlc_GenerateStop( Vec_Str_t * vInput, char * pLine, int LineSi ...@@ -115,21 +115,34 @@ static inline int Wlc_GenerateStop( Vec_Str_t * vInput, char * pLine, int LineSi
} }
Vec_Str_t * Wlc_GenerateSmtStdin() Vec_Str_t * Wlc_GenerateSmtStdin()
{ {
char * pLine = "(check-sat)"; //char * pLine = "(check-sat)";
int c, LineSize = strlen(pLine); //int c, LineSize = strlen(pLine);
Vec_Str_t * vInput = Vec_StrAlloc( 1000 ); Vec_Str_t * vInput = Vec_StrAlloc( 1000 ); int c;
while ( (c = fgetc(stdin)) != EOF ) while ( (c = fgetc(stdin)) != EOF )
{
Vec_StrPush( vInput, (char)c ); Vec_StrPush( vInput, (char)c );
if ( c == ')' && Wlc_GenerateStop(vInput, pLine, LineSize) )
break;
}
Vec_StrPush( vInput, '\0' ); Vec_StrPush( vInput, '\0' );
return vInput; return vInput;
} }
void Wlc_GenerateSmtStdout( Abc_Frame_t * pAbc ) void Wlc_GenerateSmtStdout( Abc_Frame_t * pAbc )
{ {
printf( "Output produced by SMT solver will be here.\n" ); if ( Abc_FrameReadProbStatus(pAbc) == -1 )
printf( "undecided\n" );
else if ( Abc_FrameReadProbStatus(pAbc) == 1 )
printf( "unsat\n" );
else if ( Abc_FrameReadProbStatus(pAbc) == 0 )
{
Vec_Int_t * vAssign = Vec_IntAlloc( 100 );
Abc_Cex_t * pCex = Abc_FrameReadCex( pAbc ); int i;
if ( pCex == NULL )
{
printf( "CEX is not found\n" );
return;
}
for ( i = 0; i < pCex->nPis; i++ )
Vec_IntPush( vAssign, Abc_InfoHasBit(pCex->pData, i) );
Wlc_NtkReport( (Wlc_Ntk_t *)pAbc->pAbcWlc, vAssign );
Vec_IntFree( vAssign );
}
} }
/**Function******************************************************************** /**Function********************************************************************
...@@ -417,9 +430,10 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -417,9 +430,10 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0; return 0;
} }
// transform // transform
pNtk = Wlc_NtkUifNodePairs( pNtk, NULL ); //pNtk = Wlc_NtkUifNodePairs( pNtk, NULL );
pNtk = Wlc_NtkAbstractNodes( pNtk, NULL ); //pNtk = Wlc_NtkAbstractNodes( pNtk, NULL );
Wlc_AbcUpdateNtk( pAbc, pNtk ); //Wlc_AbcUpdateNtk( pAbc, pNtk );
Wlc_GenerateSmtStdout( pAbc );
return 0; return 0;
usage: usage:
Abc_Print( -2, "usage: %%test [-vh]\n" ); Abc_Print( -2, "usage: %%test [-vh]\n" );
......
...@@ -209,6 +209,7 @@ void Wlc_NtkFree( Wlc_Ntk_t * p ) ...@@ -209,6 +209,7 @@ void Wlc_NtkFree( Wlc_Ntk_t * p )
Vec_IntFreeP( &p->vInits ); Vec_IntFreeP( &p->vInits );
ABC_FREE( p->vTravIds.pArray ); ABC_FREE( p->vTravIds.pArray );
ABC_FREE( p->vNameIds.pArray ); ABC_FREE( p->vNameIds.pArray );
ABC_FREE( p->vValues.pArray );
ABC_FREE( p->vCopies.pArray ); ABC_FREE( p->vCopies.pArray );
ABC_FREE( p->pInits ); ABC_FREE( p->pInits );
ABC_FREE( p->pObjs ); ABC_FREE( p->pObjs );
...@@ -496,6 +497,52 @@ void Wlc_NtkTransferNames( Wlc_Ntk_t * pNew, Wlc_Ntk_t * p ) ...@@ -496,6 +497,52 @@ void Wlc_NtkTransferNames( Wlc_Ntk_t * pNew, Wlc_Ntk_t * p )
pNew->vTables = p->vTables; p->vTables = NULL; pNew->vTables = p->vTables; p->vTables = NULL;
} }
/**Function*************************************************************
Synopsis [Report results.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Wlc_NtkReport( Wlc_Ntk_t * p, Vec_Int_t * vAssign )
{
//sat
//((s0 #x12000000070000000000c0000085006b))
//((s1 #x0e008f00ff0000000000ff0000ed0040))
//((s2 #x96008f00ff0000000000ff0000ed0040))
int i, Name, Start, nBits, k;
Vec_Str_t * vNum = Vec_StrAlloc( 100 );
// Vec_IntForEachEntryTriple( &p->vValues, Name, Start, nBits, i )
// printf( "Variable %s : %d %d\n", Abc_NamStr(p->pManName, Name), Start, nBits );
printf( "sat\n" );
Vec_IntForEachEntryTriple( &p->vValues, Name, Start, nBits, i )
{
Vec_StrClear( vNum );
for ( k = Start; k < Start + nBits; )
{
int j, Digit = 0;
for ( j = 0; j < 4 && k < Start + nBits; j++, k++ )
Digit += (1 << j) * Vec_IntEntry(vAssign, k);
assert( Digit >= 0 && Digit < 16 );
if ( Digit >= 0 && Digit <= 9 )
Vec_StrPush( vNum, (char)('0' + Digit) );
else
Vec_StrPush( vNum, (char)('a' + Digit - 10) );
}
Vec_StrPush( vNum, 'x' );
Vec_StrPush( vNum, '#' );
Vec_StrReverseOrder( vNum );
Vec_StrPush( vNum, '\0' );
printf( "((%s %s))\n", Abc_NamStr(p->pManName, Name), Vec_StrArray(vNum) );
}
Vec_StrFree( vNum );
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
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