53 int Abc_NtkMiterSat(
Abc_Ntk_t * pNtk, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit,
int fVerbose, ABC_INT64_T * pNumConfs, ABC_INT64_T * pNumInspects )
98 status =
sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfLimit, (ABC_INT64_T)nInsLimit, (ABC_INT64_T)0, (ABC_INT64_T)0 );
104 else if ( status ==
l_True )
223 int fComp1,
Var, Var1, i;
230 Var = (int)(ABC_PTRINT_T)pNode->
pCopy;
234 for ( i = 0; i < vSuper->nSize; i++ )
259 for ( i = 0; i < vSuper->nSize; i++ )
287 int VarF, VarI, VarT, VarE, fCompT, fCompE;
293 VarF = (int)(ABC_PTRINT_T)pNode->
pCopy;
294 VarI = (int)(ABC_PTRINT_T)pNodeC->
pCopy;
372 int RetValue1, RetValue2, i;
377 for ( i = 0; i < vSuper->nSize; i++ )
378 if ( vSuper->pArray[i] == pNode )
381 for ( i = 0; i < vSuper->nSize; i++ )
400 if ( RetValue1 == -1 || RetValue2 == -1 )
403 return RetValue1 || RetValue2;
424 assert( vNodes->nSize > 1 );
426 for ( i = 0; i < vNodes->nSize; i++ )
430 if ( RetValue == -1 )
451 return (
int)(100000000.0 * (1 + 0.01 * pObj->
Level));
468 Abc_Obj_t * pNode, * pFanin, * pNodeC, * pNodeT, * pNodeE;
471 int i, k, fUseMuxes = 1;
508 if ( pFanin->
fMarkA == 0 )
543 if ( pFanin->
fMarkA == 0 )
562 if ( pFanin->
fMarkA == 0 )
570 if ( vSuper->nSize == 0 )
694 printf(
"The CNF is trivially UNSAT.\n" );
704 pCube = pSop0 + c * (nFanins + 3);
711 if ( pCube[i] ==
'0' )
713 else if ( pCube[i] ==
'1' )
720 printf(
"The CNF is trivially UNSAT.\n" );
729 pCube = pSop1 + c * (nFanins + 3);
736 if ( pCube[i] ==
'0' )
738 else if ( pCube[i] ==
'1' )
745 printf(
"The CNF is trivially UNSAT.\n" );
777 printf(
"The CNF is trivially UNSAT.\n" );
787 printf(
"The CNF is trivially UNSAT.\n" );
799 printf(
"The CNF is trivially UNSAT.\n" );
809 printf(
"The CNF is trivially UNSAT.\n" );
819 printf(
"The CNF is trivially UNSAT.\n" );
843 char * pSop0, * pSop1;
910 Abc_Obj_t * pObj, * ppNodes[2], * ppRoots[2];
915 if ( nQueens <= 0 && nQueens >= nVars )
917 printf(
"The number of queens (Q = %d) should belong to the interval: 0 < Q < %d.\n", nQueens, nQueens);
920 assert( nQueens > 0 && nQueens < nVars );
923 sprintf( Command,
"gen -s -N %d sorter%d.blif", nVars, nVars );
926 fprintf( stdout,
"Cannot execute command \"%s\".\n", Command );
930 sprintf( Command,
"read sorter%d.blif; strash", nVars );
933 fprintf( stdout,
"Cannot execute command \"%s\".\n", Command );
940 ppNodes[0] =
Abc_NtkPo( pNtk, nVars - nQueens - 1 );
941 ppNodes[1] =
Abc_NtkPo( pNtk, nVars - nQueens );
975 pFile = fopen( pFileName,
"w" );
976 fprintf( pFile,
"c CNF for %d-bit sorter with %d bits set to 1 generated by ABC.\n", nVars, nQueens );
977 fprintf( pFile,
"p cnf %d %d\n", Counter, 3 *
Vec_PtrSize(vNodes) + 2 );
981 fprintf( pFile,
"%d %s%d %s%d 0\n", 1+(
int)(ABC_PTRINT_T)pObj->
pCopy,
985 fprintf( pFile,
"-%d %s%d 0\n", 1+(
int)(ABC_PTRINT_T)pObj->
pCopy,
987 fprintf( pFile,
"-%d %s%d 0\n", 1+(
int)(ABC_PTRINT_T)pObj->
pCopy,
997 fprintf( pFile,
"%s%d 0\n",
1000 fprintf( pFile,
"%s%d 0\n",
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
int Abc_NtkMiterSatCreateInt(sat_solver *pSat, Abc_Ntk_t *pNtk)
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
int Cmd_CommandExecute(void *pAbc, char *pCommandLine)
int sat_solver_solve(sat_solver *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
#define Cudd_Regular(node)
void sat_solver_delete(sat_solver *s)
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
int Abc_NtkNodeFactor(Abc_Obj_t *pObj, int nLevelMax)
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
void * Abc_NtkMiterSatCreate(Abc_Ntk_t *pNtk, int fAllPrimes)
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
#define Abc_NtkForEachCo(pNtk, pCo, i)
static ABC_NAMESPACE_IMPL_START sat_solver * Abc_NtkMiterSatCreateLogic(Abc_Ntk_t *pNtk, int fAllPrimes)
DECLARATIONS ///.
static Vec_Str_t * Vec_StrAlloc(int nCap)
static abctime Abc_Clock()
static int Vec_PtrSize(Vec_Ptr_t *p)
int Abc_NtkCollectSupergate_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vSuper, int fFirst, int fStopAtMux)
void Abc_NtkWriteSorterCnf(char *pFileName, int nVars, int nQueens)
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
int Abc_NodeAddClauses(sat_solver *pSat, char *pSop0, char *pSop1, Abc_Obj_t *pNode, Vec_Int_t *vVars)
void sat_solver_store_write(sat_solver *s, char *pFileName)
static lit lit_neg(lit l)
static Abc_Obj_t * Abc_ObjChild0(Abc_Obj_t *pObj)
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Mem_Flex_t * Mem_FlexStart()
typedefABC_NAMESPACE_HEADER_START struct Abc_Frame_t_ Abc_Frame_t
INCLUDES ///.
#define Cudd_IsComplement(node)
ABC_DLL int Abc_NodeIsMuxType(Abc_Obj_t *pNode)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Vec_Int_t * Abc_NtkGetCiSatVarNums(Abc_Ntk_t *pNtk)
static void Vec_StrFree(Vec_Str_t *p)
void sat_solver_store_alloc(sat_solver *s)
int Abc_NtkClauseMux(sat_solver *pSat, Abc_Obj_t *pNode, Abc_Obj_t *pNodeC, Abc_Obj_t *pNodeT, Abc_Obj_t *pNodeE, Vec_Int_t *vVars)
static lit toLitCond(int v, int c)
#define ABC_NAMESPACE_IMPL_END
void * Abc_FrameGetGlobalFrame()
static int Abc_AigNodeIsAnd(Abc_Obj_t *pNode)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
#define Abc_NtkForEachNode(pNtk, pNode, i)
void Mem_FlexStop(Mem_Flex_t *p, int fVerbose)
#define ABC_NAMESPACE_IMPL_START
int Abc_NtkClauseTriv(sat_solver *pSat, Abc_Obj_t *pNode, Vec_Int_t *vVars)
void sat_solver_store_mark_roots(sat_solver *s)
ABC_DLL Abc_Ntk_t * Abc_FrameReadNtk(Abc_Frame_t *p)
DdNode * Cudd_ReadOne(DdManager *dd)
int sat_solver_simplify(sat_solver *s)
static Abc_Obj_t * Abc_ObjRegular(Abc_Obj_t *p)
sat_solver * sat_solver_new(void)
static Abc_Obj_t * Abc_NtkPo(Abc_Ntk_t *pNtk, int i)
#define Abc_NtkForEachCi(pNtk, pCi, i)
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
#define Abc_ObjForEachFanin(pObj, pFanin, i)
int Abc_NtkClauseTop(sat_solver *pSat, Vec_Ptr_t *vNodes, Vec_Int_t *vVars)
int Abc_NtkClauseAnd(sat_solver *pSat, Abc_Obj_t *pNode, Vec_Ptr_t *vSuper, Vec_Int_t *vVars)
static int Abc_NtkIsBddLogic(Abc_Ntk_t *pNtk)
int Abc_NtkMiterSat(Abc_Ntk_t *pNtk, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, int fVerbose, ABC_INT64_T *pNumConfs, ABC_INT64_T *pNumInspects)
FUNCTION DEFINITIONS ///.
void sat_solver_store_free(sat_solver *s)
ABC_DLL int Abc_SopGetVarNum(char *pSop)
ABC_DLL void Abc_NodeBddToCnf(Abc_Obj_t *pNode, Mem_Flex_t *pMmMan, Vec_Str_t *vCube, int fAllPrimes, char **ppSop0, char **ppSop1)
static void Vec_PtrClear(Vec_Ptr_t *p)
static Abc_Obj_t * Abc_ObjNot(Abc_Obj_t *p)
ABC_DLL Vec_Ptr_t * Abc_NtkDfsNodes(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
void Sat_SolverPrintStats(FILE *pFile, sat_solver *p)
#define Abc_NtkForEachPo(pNtk, pPo, i)
static void Vec_IntFree(Vec_Int_t *p)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
static int Abc_ObjIsComplement(Abc_Obj_t *p)
void Abc_NtkCollectSupergate(Abc_Obj_t *pNode, int fStopAtMux, Vec_Ptr_t *vNodes)
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
static Abc_Obj_t * Abc_ObjChild1(Abc_Obj_t *pObj)
int * Sat_SolverGetModel(sat_solver *p, int *pVars, int nVars)
ABC_DLL Abc_Obj_t * Abc_NodeRecognizeMux(Abc_Obj_t *pNode, Abc_Obj_t **ppNodeT, Abc_Obj_t **ppNodeE)
#define Abc_NtkForEachPi(pNtk, pPi, i)
int Abc_NodeAddClausesTop(sat_solver *pSat, Abc_Obj_t *pNode, Vec_Int_t *vVars)
static void Vec_PtrFree(Vec_Ptr_t *p)