Commit 81af996f by Alan Mishchenko

Bug fix in 'dsat <file.cnf>' when the number of classes in listed incorrectly.

parent 5351ab4b
...@@ -1938,6 +1938,54 @@ SOURCE=.\src\sat\bmc\bmcUnroll.c ...@@ -1938,6 +1938,54 @@ SOURCE=.\src\sat\bmc\bmcUnroll.c
# PROP Default_Filter "" # PROP Default_Filter ""
# End Group # End Group
# Begin Group "xsat"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\src\sat\xsat\xsat.h
# End Source File
# Begin Source File
SOURCE=.\src\sat\xsat\xsatBQueue.h
# End Source File
# Begin Source File
SOURCE=.\src\sat\xsat\xsatClause.h
# End Source File
# Begin Source File
SOURCE=.\src\sat\xsat\xsatCnfReader.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\xsat\xsatHeap.h
# End Source File
# Begin Source File
SOURCE=.\src\sat\xsat\xsatMemory.h
# End Source File
# Begin Source File
SOURCE=.\src\sat\xsat\xsatSolver.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\xsat\xsatSolver.h
# End Source File
# Begin Source File
SOURCE=.\src\sat\xsat\xsatSolverAPI.c
# End Source File
# Begin Source File
SOURCE=.\src\sat\xsat\xsatUtils.h
# End Source File
# Begin Source File
SOURCE=.\src\sat\xsat\xsatWatchList.h
# End Source File
# End Group
# End Group # End Group
# Begin Group "opt" # Begin Group "opt"
......
...@@ -52,9 +52,9 @@ void Gia_WriteDotAigSimple( Gia_Man_t * p, char * pFileName, Vec_Int_t * vBold ) ...@@ -52,9 +52,9 @@ void Gia_WriteDotAigSimple( Gia_Man_t * p, char * pFileName, Vec_Int_t * vBold )
int LevelMax, Prev, Level, i; int LevelMax, Prev, Level, i;
int fConstIsUsed = 0; int fConstIsUsed = 0;
if ( Gia_ManAndNum(p) > 200 ) if ( Gia_ManAndNum(p) > 500 )
{ {
fprintf( stdout, "Cannot visualize AIG with more than 200 nodes.\n" ); fprintf( stdout, "Cannot visualize AIG with more than 500 nodes.\n" );
return; return;
} }
if ( (pFile = fopen( pFileName, "w" )) == NULL ) if ( (pFile = fopen( pFileName, "w" )) == NULL )
...@@ -378,7 +378,7 @@ int Gia_ShowAddOut( Vec_Int_t * vAdds, Vec_Int_t * vMapAdds, int Node ) ...@@ -378,7 +378,7 @@ int Gia_ShowAddOut( Vec_Int_t * vAdds, Vec_Int_t * vMapAdds, int Node )
{ {
int iBox = Vec_IntEntry( vMapAdds, Node ); int iBox = Vec_IntEntry( vMapAdds, Node );
if ( iBox >= 0 ) if ( iBox >= 0 )
return Vec_IntEntry( vAdds, 6*iBox+3 ); return Vec_IntEntry( vAdds, 6*iBox+4 );
return Node; return Node;
} }
void Gia_WriteDotAig( Gia_Man_t * p, char * pFileName, Vec_Int_t * vAdds, Vec_Int_t * vXors, Vec_Int_t * vMapAdds, Vec_Int_t * vMapXors, Vec_Int_t * vOrder ) void Gia_WriteDotAig( Gia_Man_t * p, char * pFileName, Vec_Int_t * vAdds, Vec_Int_t * vXors, Vec_Int_t * vMapAdds, Vec_Int_t * vMapXors, Vec_Int_t * vOrder )
...@@ -388,9 +388,9 @@ void Gia_WriteDotAig( Gia_Man_t * p, char * pFileName, Vec_Int_t * vAdds, Vec_In ...@@ -388,9 +388,9 @@ void Gia_WriteDotAig( Gia_Man_t * p, char * pFileName, Vec_Int_t * vAdds, Vec_In
int LevelMax, Prev, Level, i; int LevelMax, Prev, Level, i;
int fConstIsUsed = 0; int fConstIsUsed = 0;
if ( Gia_ManAndNum(p) > 500 ) if ( Gia_ManAndNum(p) > 1000 )
{ {
fprintf( stdout, "Cannot visualize AIG with more than 200 nodes.\n" ); fprintf( stdout, "Cannot visualize AIG with more than 1000 nodes.\n" );
return; return;
} }
if ( (pFile = fopen( pFileName, "w" )) == NULL ) if ( (pFile = fopen( pFileName, "w" )) == NULL )
...@@ -750,7 +750,7 @@ int Gia_ShowCollectObjs_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vAdds, ...@@ -750,7 +750,7 @@ int Gia_ShowCollectObjs_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vAdds,
Level = 1 + Abc_MaxInt( Abc_MaxInt(Level0, Level1), Level2 ); Level = 1 + Abc_MaxInt( Abc_MaxInt(Level0, Level1), Level2 );
Gia_ObjSetLevelId( p, Vec_IntEntry(vAdds, 6*iBox+3), Level ); Gia_ObjSetLevelId( p, Vec_IntEntry(vAdds, 6*iBox+3), Level );
Gia_ObjSetLevelId( p, Vec_IntEntry(vAdds, 6*iBox+4), Level ); Gia_ObjSetLevelId( p, Vec_IntEntry(vAdds, 6*iBox+4), Level );
pObj = Gia_ManObj( p, Vec_IntEntry(vAdds, 6*iBox+3) ); pObj = Gia_ManObj( p, Vec_IntEntry(vAdds, 6*iBox+4) );
} }
else if ( Vec_IntEntry(vMapXors, Gia_ObjId(p, pObj)) >= 0 ) else if ( Vec_IntEntry(vMapXors, Gia_ObjId(p, pObj)) >= 0 )
{ {
......
...@@ -45,6 +45,210 @@ ABC_NAMESPACE_IMPL_START ...@@ -45,6 +45,210 @@ ABC_NAMESPACE_IMPL_START
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Acec_ManDerive_rec( Gia_Man_t * pNew, Gia_Man_t * p, int Node, Vec_Int_t * vMirrors )
{
Gia_Obj_t * pObj;
int Obj = Node;
if ( Vec_IntEntry(vMirrors, Node) >= 0 )
Obj = Abc_Lit2Var( Vec_IntEntry(vMirrors, Node) );
pObj = Gia_ManObj( p, Obj );
if ( !~pObj->Value )
{
assert( Gia_ObjIsAnd(pObj) );
Acec_ManDerive_rec( pNew, p, Gia_ObjFaninId0(pObj, Obj), vMirrors );
Acec_ManDerive_rec( pNew, p, Gia_ObjFaninId1(pObj, Obj), vMirrors );
if ( Gia_ObjIsXor(pObj) )
pObj->Value = Gia_ManAppendXorReal( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
else
pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
}
// set the original node as well
if ( Obj != Node )
Gia_ManObj(p, Node)->Value = Abc_LitNotCond( pObj->Value, Abc_LitIsCompl(Vec_IntEntry(vMirrors, Node)) );
}
Gia_Man_t * Acec_ManDerive( Gia_Man_t * p, Vec_Int_t * vMirrors )
{
Gia_Man_t * pNew;
Gia_Obj_t * pObj;
int i;
assert( p->pMuxes == NULL );
Gia_ManFillValue( p );
pNew = Gia_ManStart( Gia_ManObjNum(p) );
pNew->pName = Abc_UtilStrsav( p->pName );
pNew->pSpec = Abc_UtilStrsav( p->pSpec );
Gia_ManConst0(p)->Value = 0;
Gia_ManHashAlloc( pNew );
Gia_ManForEachCi( p, pObj, i )
pObj->Value = Gia_ManAppendCi(pNew);
Gia_ManForEachCo( p, pObj, i )
Acec_ManDerive_rec( pNew, p, Gia_ObjFaninId0p(p, pObj), vMirrors );
Gia_ManForEachCo( p, pObj, i )
pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
Gia_ManHashStop( pNew );
Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
return pNew;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Int_t * Acec_CollectXorTops( Gia_Man_t * p )
{
Vec_Int_t * vRootXorSet = Vec_IntAlloc( Gia_ManCoNum(p) );
Gia_Obj_t * pObj, * pFan0, * pFan1, * pFan00, * pFan01, * pFan10, * pFan11;
int i, fXor0, fXor1, fFirstXor = 0;
Gia_ManForEachCoDriver( p, pObj, i )
{
if ( !Gia_ObjRecognizeExor(pObj, &pFan0, &pFan1) )
{
if ( fFirstXor )
{
printf( "XORs do not form a continuous sequence\n" );
Vec_IntFreeP( &vRootXorSet );
break;
}
continue;
}
fFirstXor = 1;
fXor0 = Gia_ObjRecognizeExor(Gia_Regular(pFan0), &pFan00, &pFan01);
fXor1 = Gia_ObjRecognizeExor(Gia_Regular(pFan1), &pFan10, &pFan11);
if ( fXor0 == fXor1 )
{
printf( "Both inputs of top level XOR have XOR/non-XOR\n" );
Vec_IntFreeP( &vRootXorSet );
break;
}
Vec_IntPush( vRootXorSet, Gia_ObjId(p, pObj) );
Vec_IntPush( vRootXorSet, fXor1 ? Gia_ObjId(p, Gia_Regular(pFan1)) : Gia_ObjId(p, Gia_Regular(pFan0)) );
Vec_IntPush( vRootXorSet, fXor1 ? Gia_ObjId(p, Gia_Regular(pFan10)) : Gia_ObjId(p, Gia_Regular(pFan00)) );
Vec_IntPush( vRootXorSet, fXor1 ? Gia_ObjId(p, Gia_Regular(pFan11)) : Gia_ObjId(p, Gia_Regular(pFan01)) );
}
for ( i = 0; 4*i < Vec_IntSize(vRootXorSet); i++ )
{
printf( "%2d : ", i );
printf( "%4d <- ", Vec_IntEntry(vRootXorSet, 4*i) );
printf( "%4d ", Vec_IntEntry(vRootXorSet, 4*i+1) );
printf( "%4d ", Vec_IntEntry(vRootXorSet, 4*i+2) );
printf( "%4d ", Vec_IntEntry(vRootXorSet, 4*i+3) );
printf( "\n" );
}
return vRootXorSet;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Acec_DetectLitPolarity( Gia_Man_t * p, int Node, int Leaf )
{
Gia_Obj_t * pNode;
int Lit0, Lit1;
if ( Node < Leaf )
return -1;
if ( Node == Leaf )
return Abc_Var2Lit(Node, 0);
pNode = Gia_ManObj( p, Node );
Lit0 = Acec_DetectLitPolarity( p, Gia_ObjFaninId0(pNode, Node), Leaf );
Lit1 = Acec_DetectLitPolarity( p, Gia_ObjFaninId1(pNode, Node), Leaf );
Lit0 = Lit0 == -1 ? Lit0 : Abc_LitNotCond( Lit0, Gia_ObjFaninC0(pNode) );
Lit1 = Lit1 == -1 ? Lit1 : Abc_LitNotCond( Lit1, Gia_ObjFaninC1(pNode) );
if ( Lit0 == -1 && Lit1 == -1 )
return -1;
assert( Lit0 != -1 || Lit1 != -1 );
if ( Lit0 != -1 && Lit1 != -1 )
{
assert( Lit0 == Lit1 );
return Lit0;
}
return Lit0 != -1 ? Lit0 : Lit1;
}
Gia_Man_t * Acec_DetectXorBuildNew( Gia_Man_t * p, Vec_Int_t * vRootXorSet )
{
Gia_Man_t * pNew;
int i, k, iOr1, iAnd1, iAnd2, pLits[3]; // carry, in1, in2
Vec_Int_t * vMirrors = Vec_IntStart( Gia_ManObjNum(p) );
for ( i = 0; 4*i < Vec_IntSize(vRootXorSet); i++ )
{
pLits[0] = Acec_DetectLitPolarity( p, Vec_IntEntry(vRootXorSet, 4*i), Vec_IntEntry(vRootXorSet, 4*i+1) );
// get polarity of two new ones
for ( k = 1; k < 3; k++ )
pLits[k] = Acec_DetectLitPolarity( p, Vec_IntEntry(vRootXorSet, 4*i), Vec_IntEntry(vRootXorSet, 4*i+k+1) );
// create the gate
iOr1 = Gia_ManAppendOr( p, pLits[1], pLits[2] );
iAnd1 = Gia_ManAppendAnd( p, pLits[0], iOr1 );
iAnd2 = Gia_ManAppendAnd( p, pLits[1], pLits[2] );
pLits[0] = Gia_ManAppendOr( p, iAnd1, iAnd2 );
Vec_IntWriteEntry( vMirrors, Vec_IntEntry(vRootXorSet, 4*i+1), pLits[0] );
}
// remap the AIG using map
pNew = Acec_ManDerive( p, vMirrors );
Vec_IntFree( vMirrors );
return pNew;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Gia_Man_t * Acec_DetectAdditional( Gia_Man_t * p, int fVerbose )
{
extern Vec_Int_t * Ree_ManComputeCuts( Gia_Man_t * p, Vec_Int_t ** pvXors, int fVerbose );
extern void Ree_ManRemoveTrivial( Gia_Man_t * p, Vec_Int_t * vAdds );
extern void Ree_ManRemoveContained( Gia_Man_t * p, Vec_Int_t * vAdds );
extern int Ree_ManCountFadds( Vec_Int_t * vAdds );
extern void Ree_ManPrintAdders( Vec_Int_t * vAdds, int fVerbose );
abctime clk = Abc_Clock();
Gia_Man_t * pNew;
Vec_Int_t * vRootXorSet;
// Vec_Int_t * vXors, * vAdds = Ree_ManComputeCuts( p, &vXors, 0 );
// Ree_ManRemoveTrivial( p, vAdds );
// Ree_ManRemoveContained( p, vAdds );
//Ree_ManPrintAdders( vAdds, 1 );
// printf( "Detected %d full-adders and %d half-adders. Found %d XOR-cuts. ", Ree_ManCountFadds(vAdds), Vec_IntSize(vAdds)/6-Ree_ManCountFadds(vAdds), Vec_IntSize(vXors)/4 );
// Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
clk = Abc_Clock();
vRootXorSet = Acec_CollectXorTops( p );
if ( vRootXorSet )
{
pNew = Acec_DetectXorBuildNew( p, vRootXorSet );
Vec_IntFree( vRootXorSet );
}
else
pNew = Gia_ManDup( p );
printf( "Detected %d top XORs. ", Vec_IntSize(vRootXorSet)/4 );
Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
// Vec_IntFree( vXors );
// Vec_IntFree( vAdds );
return pNew;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
......
...@@ -374,7 +374,7 @@ Cnf_Dat_t * Cnf_DataReadFromFile( char * pFileName ) ...@@ -374,7 +374,7 @@ Cnf_Dat_t * Cnf_DataReadFromFile( char * pFileName )
// create // create
pCnf = ABC_CALLOC( Cnf_Dat_t, 1 ); pCnf = ABC_CALLOC( Cnf_Dat_t, 1 );
pCnf->nVars = nVars; pCnf->nVars = nVars;
pCnf->nClauses = nClas; pCnf->nClauses = Vec_IntSize(vClas)-1;
pCnf->nLiterals = Vec_IntSize(vLits); pCnf->nLiterals = Vec_IntSize(vLits);
pCnf->pClauses = ABC_ALLOC( int *, Vec_IntSize(vClas) ); pCnf->pClauses = ABC_ALLOC( int *, Vec_IntSize(vClas) );
pCnf->pClauses[0] = Vec_IntReleaseArray(vLits); pCnf->pClauses[0] = Vec_IntReleaseArray(vLits);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// INCLUDES /// /// INCLUDES ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
#include "misc/util/abc_global.h" #include "misc/util/abc_global.h"
ABC_NAMESPACE_HEADER_START ABC_NAMESPACE_HEADER_START
...@@ -31,6 +32,7 @@ ABC_NAMESPACE_HEADER_START ...@@ -31,6 +32,7 @@ ABC_NAMESPACE_HEADER_START
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// STRUCTURE DEFINITIONS /// /// STRUCTURE DEFINITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
typedef struct xSAT_BQueue_t_ xSAT_BQueue_t; typedef struct xSAT_BQueue_t_ xSAT_BQueue_t;
struct xSAT_BQueue_t_ struct xSAT_BQueue_t_
{ {
...@@ -38,13 +40,14 @@ struct xSAT_BQueue_t_ ...@@ -38,13 +40,14 @@ struct xSAT_BQueue_t_
int nCap; int nCap;
int iFirst; int iFirst;
int iEmpty; int iEmpty;
uint64_t nSum; word nSum;
uint32_t * pData; word * pData;
}; };
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS /// /// FUNCTION DECLARATIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/**Function************************************************************* /**Function*************************************************************
Synopsis [] Synopsis []
...@@ -60,7 +63,7 @@ static inline xSAT_BQueue_t * xSAT_BQueueNew( int nCap ) ...@@ -60,7 +63,7 @@ static inline xSAT_BQueue_t * xSAT_BQueueNew( int nCap )
{ {
xSAT_BQueue_t * p = ABC_CALLOC( xSAT_BQueue_t, 1 ); xSAT_BQueue_t * p = ABC_CALLOC( xSAT_BQueue_t, 1 );
p->nCap = nCap; p->nCap = nCap;
p->pData = ABC_CALLOC( uint32_t, nCap ); p->pData = ABC_CALLOC( word, nCap );
return p; return p;
} }
...@@ -92,7 +95,7 @@ static inline void xSAT_BQueueFree( xSAT_BQueue_t * p ) ...@@ -92,7 +95,7 @@ static inline void xSAT_BQueueFree( xSAT_BQueue_t * p )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
static inline void xSAT_BQueuePush( xSAT_BQueue_t * p, uint32_t Value ) static inline void xSAT_BQueuePush( xSAT_BQueue_t * p, word Value )
{ {
if ( p->nSize == p->nCap ) if ( p->nSize == p->nCap )
{ {
...@@ -125,8 +128,8 @@ static inline void xSAT_BQueuePush( xSAT_BQueue_t * p, uint32_t Value ) ...@@ -125,8 +128,8 @@ static inline void xSAT_BQueuePush( xSAT_BQueue_t * p, uint32_t Value )
***********************************************************************/ ***********************************************************************/
static inline int xSAT_BQueuePop( xSAT_BQueue_t * p ) static inline int xSAT_BQueuePop( xSAT_BQueue_t * p )
{ {
assert( p->nSize >= 1 );
int RetValue = p->pData[p->iFirst]; int RetValue = p->pData[p->iFirst];
assert( p->nSize >= 1 );
p->nSum -= RetValue; p->nSum -= RetValue;
p->iFirst = ( p->iFirst + 1 ) % p->nCap; p->iFirst = ( p->iFirst + 1 ) % p->nCap;
p->nSize--; p->nSize--;
...@@ -144,9 +147,9 @@ static inline int xSAT_BQueuePop( xSAT_BQueue_t * p ) ...@@ -144,9 +147,9 @@ static inline int xSAT_BQueuePop( xSAT_BQueue_t * p )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
static inline uint32_t xSAT_BQueueAvg( xSAT_BQueue_t * p ) static inline word xSAT_BQueueAvg( xSAT_BQueue_t * p )
{ {
return ( uint32_t )( p->nSum / ( ( uint64_t ) p->nSize ) ); return ( word )( p->nSum / ( ( word ) p->nSize ) );
} }
/**Function************************************************************* /**Function*************************************************************
......
...@@ -96,7 +96,7 @@ static void xSAT_ClausePrint( xSAT_Clause_t * pCla ) ...@@ -96,7 +96,7 @@ static void xSAT_ClausePrint( xSAT_Clause_t * pCla )
int i; int i;
printf("{ "); printf("{ ");
for ( i = 0; i < pCla->nSize; i++ ) for ( i = 0; i < (int)pCla->nSize; i++ )
printf("%d ", pCla->pData[i].Lit ); printf("%d ", pCla->pData[i].Lit );
printf("}\n"); printf("}\n");
} }
......
...@@ -36,10 +36,10 @@ ABC_NAMESPACE_HEADER_START ...@@ -36,10 +36,10 @@ ABC_NAMESPACE_HEADER_START
typedef struct xSAT_Mem_t_ xSAT_Mem_t; typedef struct xSAT_Mem_t_ xSAT_Mem_t;
struct xSAT_Mem_t_ struct xSAT_Mem_t_
{ {
uint32_t nSize; unsigned nSize;
uint32_t nCap; unsigned nCap;
uint32_t nWasted; unsigned nWasted;
uint32_t * pData; unsigned * pData;
}; };
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -58,7 +58,7 @@ struct xSAT_Mem_t_ ...@@ -58,7 +58,7 @@ struct xSAT_Mem_t_
***********************************************************************/ ***********************************************************************/
static inline xSAT_Clause_t * xSAT_MemClauseHand( xSAT_Mem_t * p, int h ) static inline xSAT_Clause_t * xSAT_MemClauseHand( xSAT_Mem_t * p, int h )
{ {
return h != UINT32_MAX ? ( xSAT_Clause_t * )( p->pData + h ) : NULL; return h != 0xFFFFFFFF ? ( xSAT_Clause_t * )( p->pData + h ) : NULL;
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -72,21 +72,21 @@ static inline xSAT_Clause_t * xSAT_MemClauseHand( xSAT_Mem_t * p, int h ) ...@@ -72,21 +72,21 @@ static inline xSAT_Clause_t * xSAT_MemClauseHand( xSAT_Mem_t * p, int h )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
static inline void xSAT_MemGrow( xSAT_Mem_t * p, uint32_t nCap ) static inline void xSAT_MemGrow( xSAT_Mem_t * p, unsigned nCap )
{ {
unsigned nPrevCap = p->nCap;
if ( p->nCap >= nCap ) if ( p->nCap >= nCap )
return; return;
uint32_t nPrevCap = p->nCap;
while (p->nCap < nCap) while (p->nCap < nCap)
{ {
uint32_t delta = ((p->nCap >> 1) + (p->nCap >> 3) + 2) & ~1; unsigned delta = ((p->nCap >> 1) + (p->nCap >> 3) + 2) & ~1;
p->nCap += delta; p->nCap += delta;
assert(p->nCap >= nPrevCap); assert(p->nCap >= nPrevCap);
} }
assert(p->nCap > 0); assert(p->nCap > 0);
p->pData = ABC_REALLOC(uint32_t, p->pData, p->nCap); p->pData = ABC_REALLOC(unsigned, p->pData, p->nCap);
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -156,12 +156,13 @@ static inline void xSAT_MemFree( xSAT_Mem_t * p ) ...@@ -156,12 +156,13 @@ static inline void xSAT_MemFree( xSAT_Mem_t * p )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
static inline uint32_t xSAT_MemAppend( xSAT_Mem_t * p, int nSize ) static inline unsigned xSAT_MemAppend( xSAT_Mem_t * p, int nSize )
{ {
unsigned nPrevSize;
assert(nSize > 0); assert(nSize > 0);
xSAT_MemGrow(p, p->nSize + nSize); xSAT_MemGrow(p, p->nSize + nSize);
uint32_t nPrevSize = p->nSize; nPrevSize = p->nSize;
p->nSize += nSize; p->nSize += nSize;
assert(p->nSize > nPrevSize); assert(p->nSize > nPrevSize);
...@@ -179,9 +180,9 @@ static inline uint32_t xSAT_MemAppend( xSAT_Mem_t * p, int nSize ) ...@@ -179,9 +180,9 @@ static inline uint32_t xSAT_MemAppend( xSAT_Mem_t * p, int nSize )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
static inline uint32_t xSAT_MemCRef( xSAT_Mem_t * p, uint32_t * pC ) static inline unsigned xSAT_MemCRef( xSAT_Mem_t * p, unsigned * pC )
{ {
return ( uint32_t )( pC - &(p->pData[0]) ); return ( unsigned )( pC - &(p->pData[0]) );
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -195,7 +196,7 @@ static inline uint32_t xSAT_MemCRef( xSAT_Mem_t * p, uint32_t * pC ) ...@@ -195,7 +196,7 @@ static inline uint32_t xSAT_MemCRef( xSAT_Mem_t * p, uint32_t * pC )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
static inline uint32_t xSAT_MemCap( xSAT_Mem_t * p ) static inline unsigned xSAT_MemCap( xSAT_Mem_t * p )
{ {
return p->nCap; return p->nCap;
} }
...@@ -211,7 +212,7 @@ static inline uint32_t xSAT_MemCap( xSAT_Mem_t * p ) ...@@ -211,7 +212,7 @@ static inline uint32_t xSAT_MemCap( xSAT_Mem_t * p )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
static inline uint32_t xSAT_MemWastedCap( xSAT_Mem_t * p ) static inline unsigned xSAT_MemWastedCap( xSAT_Mem_t * p )
{ {
return p->nWasted; return p->nWasted;
} }
......
...@@ -70,7 +70,7 @@ enum ...@@ -70,7 +70,7 @@ enum
LitUndef = -2 LitUndef = -2
}; };
#define CRefUndef UINT32_MAX #define CRefUndef 0xFFFFFFFF
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// STRUCTURE DEFINITIONS /// /// STRUCTURE DEFINITIONS ///
...@@ -81,8 +81,8 @@ struct xSAT_SolverOptions_t_ ...@@ -81,8 +81,8 @@ struct xSAT_SolverOptions_t_
char fVerbose; char fVerbose;
// Limits // Limits
ABC_INT64_T nConfLimit; // external limit on the number of conflicts word nConfLimit; // external limit on the number of conflicts
ABC_INT64_T nInsLimit; // external limit on the number of implications word nInsLimit; // external limit on the number of implications
abctime nRuntimeLimit; // external limit on runtime abctime nRuntimeLimit; // external limit on runtime
// Constants used for restart heuristic // Constants used for restart heuristic
...@@ -105,13 +105,13 @@ struct xSAT_Stats_t_ ...@@ -105,13 +105,13 @@ struct xSAT_Stats_t_
unsigned nStarts; unsigned nStarts;
unsigned nReduceDB; unsigned nReduceDB;
ABC_INT64_T nDecisions; word nDecisions;
ABC_INT64_T nPropagations; word nPropagations;
ABC_INT64_T nInspects; word nInspects;
ABC_INT64_T nConflicts; word nConflicts;
ABC_INT64_T nClauseLits; word nClauseLits;
ABC_INT64_T nLearntLits; word nLearntLits;
}; };
struct xSAT_Solver_t_ struct xSAT_Solver_t_
...@@ -143,7 +143,7 @@ struct xSAT_Solver_t_ ...@@ -143,7 +143,7 @@ struct xSAT_Solver_t_
int nAssignSimplify; /* Number of top-level assignments since last int nAssignSimplify; /* Number of top-level assignments since last
* execution of 'simplify()'. */ * execution of 'simplify()'. */
int64_t nPropSimplify; /* Remaining number of propagations that must be word nPropSimplify; /* Remaining number of propagations that must be
* made before next execution of 'simplify()'. */ * made before next execution of 'simplify()'. */
/* Temporary data used by Search method */ /* Temporary data used by Search method */
...@@ -195,16 +195,17 @@ static inline int xSAT_SolverDecisionLevel( xSAT_Solver_t * s ) ...@@ -195,16 +195,17 @@ static inline int xSAT_SolverDecisionLevel( xSAT_Solver_t * s )
return Vec_IntSize( s->vTrailLim ); return Vec_IntSize( s->vTrailLim );
} }
static inline xSAT_Clause_t * xSAT_SolverReadClause( xSAT_Solver_t * s, uint32_t h ) static inline xSAT_Clause_t * xSAT_SolverReadClause( xSAT_Solver_t * s, unsigned h )
{ {
return xSAT_MemClauseHand( s->pMemory, h ); return xSAT_MemClauseHand( s->pMemory, h );
} }
static inline int xSAT_SolverIsClauseSatisfied( xSAT_Solver_t * s, xSAT_Clause_t * pCla ) static inline int xSAT_SolverIsClauseSatisfied( xSAT_Solver_t * s, xSAT_Clause_t * pCla )
{ {
int i;
int * lits = &( pCla->pData[0].Lit ); int * lits = &( pCla->pData[0].Lit );
for ( int i = 0; i < pCla->nSize; i++ ) for ( i = 0; i < (int)pCla->nSize; i++ )
if ( Vec_StrEntry( s->vAssigns, xSAT_Lit2Var( lits[i] ) ) == xSAT_LitSign( ( lits[i] ) ) ) if ( Vec_StrEntry( s->vAssigns, xSAT_Lit2Var( lits[i] ) ) == xSAT_LitSign( ( lits[i] ) ) )
return true; return true;
...@@ -232,14 +233,14 @@ static inline void xSAT_SolverPrintState( xSAT_Solver_t * s ) ...@@ -232,14 +233,14 @@ static inline void xSAT_SolverPrintState( xSAT_Solver_t * s )
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DECLARATIONS /// /// FUNCTION DECLARATIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
extern uint32_t xSAT_SolverClaNew( xSAT_Solver_t* s, Vec_Int_t * vLits, int fLearnt ); extern unsigned xSAT_SolverClaNew( xSAT_Solver_t* s, Vec_Int_t * vLits, int fLearnt );
extern char xSAT_SolverSearch( xSAT_Solver_t * s ); extern char xSAT_SolverSearch( xSAT_Solver_t * s );
extern void xSAT_SolverGarbageCollect( xSAT_Solver_t * s ); extern void xSAT_SolverGarbageCollect( xSAT_Solver_t * s );
extern int xSAT_SolverEnqueue( xSAT_Solver_t* s, int Lit, uint32_t From ); extern int xSAT_SolverEnqueue( xSAT_Solver_t* s, int Lit, unsigned From );
extern void xSAT_SolverCancelUntil( xSAT_Solver_t* s, int Level); extern void xSAT_SolverCancelUntil( xSAT_Solver_t* s, int Level);
extern uint32_t xSAT_SolverPropagate( xSAT_Solver_t* s ); extern unsigned xSAT_SolverPropagate( xSAT_Solver_t* s );
extern void xSAT_SolverRebuildOrderHeap( xSAT_Solver_t* s ); extern void xSAT_SolverRebuildOrderHeap( xSAT_Solver_t* s );
ABC_NAMESPACE_HEADER_END ABC_NAMESPACE_HEADER_END
......
...@@ -32,23 +32,23 @@ ABC_NAMESPACE_IMPL_START ...@@ -32,23 +32,23 @@ ABC_NAMESPACE_IMPL_START
xSAT_SolverOptions_t DefaultConfig = xSAT_SolverOptions_t DefaultConfig =
{ {
.fVerbose = 1, 1, //.fVerbose = 1,
.nConfLimit = 0, 0, //.nConfLimit = 0,
.nInsLimit = 0, 0, //.nInsLimit = 0,
.nRuntimeLimit = 0, 0, //.nRuntimeLimit = 0,
.K = 0.8, 0.8, //.K = 0.8,
.R = 1.4, 1.4, //.R = 1.4,
.nFirstBlockRestart = 10000, 10000, //.nFirstBlockRestart = 10000,
.nSizeLBDQueue = 50, 50, //.nSizeLBDQueue = 50,
.nSizeTrailQueue = 5000, 5000, //.nSizeTrailQueue = 5000,
.nConfFirstReduce = 2000, 2000, //.nConfFirstReduce = 2000,
.nIncReduce = 300, 300, //.nIncReduce = 300,
.nSpecialIncReduce = 1000, 1000, //.nSpecialIncReduce = 1000,
.nLBDFrozenClause = 30 30 //.nLBDFrozenClause = 30
}; };
/**Function************************************************************* /**Function*************************************************************
...@@ -142,6 +142,7 @@ void xSAT_SolverDestroy( xSAT_Solver_t * s ) ...@@ -142,6 +142,7 @@ void xSAT_SolverDestroy( xSAT_Solver_t * s )
Vec_StrFree( s->vAssigns ); Vec_StrFree( s->vAssigns );
Vec_IntFree( s->vLevels ); Vec_IntFree( s->vLevels );
Vec_IntFree( s->vReasons ); Vec_IntFree( s->vReasons );
Vec_IntFree( s->vStamp );
xSAT_BQueueFree(s->bqLBD); xSAT_BQueueFree(s->bqLBD);
xSAT_BQueueFree(s->bqTrail); xSAT_BQueueFree(s->bqTrail);
...@@ -163,7 +164,7 @@ void xSAT_SolverDestroy( xSAT_Solver_t * s ) ...@@ -163,7 +164,7 @@ void xSAT_SolverDestroy( xSAT_Solver_t * s )
int xSAT_SolverSimplify( xSAT_Solver_t * s ) int xSAT_SolverSimplify( xSAT_Solver_t * s )
{ {
int i, j; int i, j;
uint32_t CRef; unsigned CRef;
assert( xSAT_SolverDecisionLevel(s) == 0 ); assert( xSAT_SolverDecisionLevel(s) == 0 );
if ( xSAT_SolverPropagate(s) != CRefUndef ) if ( xSAT_SolverPropagate(s) != CRefUndef )
......
...@@ -34,7 +34,7 @@ ABC_NAMESPACE_HEADER_START ...@@ -34,7 +34,7 @@ ABC_NAMESPACE_HEADER_START
typedef struct xSAT_Watcher_t_ xSAT_Watcher_t; typedef struct xSAT_Watcher_t_ xSAT_Watcher_t;
struct xSAT_Watcher_t_ struct xSAT_Watcher_t_
{ {
uint32_t CRef; unsigned CRef;
int Blocker; int Blocker;
}; };
...@@ -162,7 +162,7 @@ static inline xSAT_Watcher_t* xSAT_WatchListArray( xSAT_WatchList_t * v ) ...@@ -162,7 +162,7 @@ static inline xSAT_Watcher_t* xSAT_WatchListArray( xSAT_WatchList_t * v )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
static inline void xSAT_WatchListRemove( xSAT_WatchList_t * v, uint32_t CRef ) static inline void xSAT_WatchListRemove( xSAT_WatchList_t * v, unsigned CRef )
{ {
xSAT_Watcher_t* ws = xSAT_WatchListArray(v); xSAT_Watcher_t* ws = xSAT_WatchListArray(v);
int j = 0; int j = 0;
...@@ -207,7 +207,8 @@ static inline xSAT_VecWatchList_t * xSAT_VecWatchListAlloc( int nCap ) ...@@ -207,7 +207,8 @@ static inline xSAT_VecWatchList_t * xSAT_VecWatchListAlloc( int nCap )
***********************************************************************/ ***********************************************************************/
static inline void xSAT_VecWatchListFree( xSAT_VecWatchList_t* v ) static inline void xSAT_VecWatchListFree( xSAT_VecWatchList_t* v )
{ {
for( int i = 0; i < v->nSize; i++ ) int i;
for( i = 0; i < v->nSize; i++ )
xSAT_WatchListFree( v->pArray + i ); xSAT_WatchListFree( v->pArray + i );
ABC_FREE( v->pArray ); ABC_FREE( v->pArray );
......
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