38 #define MAX_CALL_NUM (1000000) // the max number of recursive calls
39 #define MAX_ITEM_NUM (1<<20) // the number of items on a page
40 #define MAX_PAGE_NUM (1<<11) // the max number of memory pages
41 #define MAX_VARS_NUM (1<<14) // the max number of state vars allowed
42 #define MAX_CUBE_NUM 63 // the max number of cubes before rebalancing
160 #define Gia_ManAreForEachCubeList( p, pList, pCube ) \
161 for ( pCube = pList; Gia_StaIsGood(p, pCube); pCube = Gia_StaNext(p, pCube) )
162 #define Gia_ManAreForEachCubeList2( p, iList, pCube, iCube ) \
163 for ( iCube = Gia_Ptr2Int(iList), pCube = Gia_ManAreSta(p, iList); \
164 Gia_StaIsGood(p, pCube); \
165 iCube = Gia_Ptr2Int(pCube->iNext), pCube = Gia_StaNext(p, pCube) )
166 #define Gia_ManAreForEachCubeStore( p, pCube, i ) \
167 for ( i = 1; i < p->nStas && (pCube = Gia_ManAreStaInt(p, i)); i++ )
168 #define Gia_ManAreForEachCubeVec( vVec, p, pCube, i ) \
169 for ( i = 0; i < Vec_IntSize(vVec) && (pCube = Gia_ManAreStaInt(p, Vec_IntEntry(vVec,i))); i++ )
188 unsigned Mint, Mask = 0;
189 int i, m, nMints, nDashes = 0, Dashes[32];
191 for ( i = 0; i < nVars; i++ )
198 Dashes[nDashes++] = i;
201 nMints = (1 << nDashes);
202 for ( m = 0; m < nMints; m++ )
205 for ( i = 0; i < nVars; i++ )
207 Mint |= (1 << Dashes[i]);
235 for ( i = 0; i < nMemSize; i++ )
340 for ( w = 0; w <
nWords; w++ )
360 for ( w = 0; w <
nWords; w++ )
380 for ( w = 0; w <
nWords; w++ )
400 for ( w = 0; w <
nWords; w++ )
422 for ( w = 0; w <
nWords; w++ )
424 Word = (~(p1->
pData[w] ^ (p1->
pData[w] >> 1))) & (p2->
pData[w] ^ (p2->
pData[w] >> 1)) & 0x55555555;
454 for ( w = 0; w <
nWords; w++ )
547 printf(
"ERA manager has run out of memory after allocating 2B internal nodes.\n" );
574 printf(
"ERA manager has run out of memory after allocating 2B state cubes.\n" );
641 if ( pObj->
Value == 0 )
643 else if ( pObj->
Value == 1 )
684 int i, Count0 = 0, Count1 = 0, Count2 = 0;
687 printf(
"%p ", pSta );
691 printf(
"0" ), Count0++;
693 printf(
"1" ), Count1++;
695 printf(
"-" ), Count2++;
697 printf(
" 0 =%3d", Count0 );
698 printf(
" 1 =%3d", Count1 );
699 printf(
" - =%3d", Count2 );
856 int Count0, Count1, Count2;
857 int iVarThis, iVarBest = -1, WeightThis, WeightBest = -1;
860 Count0 = Count1 = Count2 = 0;
874 if ( (!Count0 && !Count1) || (!Count0 && !Count2) || (!Count1 && !Count2) )
876 WeightThis = Count0 + Count1 - (Count0 > Count1 ? Count0 - Count1 : Count1 - Count0);
877 if ( WeightBest < WeightThis )
879 WeightBest = WeightThis;
883 if ( iVarBest == -1 )
886 printf(
"Error: Best variable not found!!!\n" );
913 iCube = iNext, pCube =
Gia_ManAreSta(p, iCube), iNext = pCube->iNext )
918 pCube->iNext = pNode->
F[0], pNode->
F[0] = iCube, pNode->
nStas0++;
920 pCube->iNext = pNode->
F[1], pNode->
F[1] = iCube, pNode->
nStas1++;
922 pCube->iNext = pNode->
F[2], pNode->
F[2] = iCube, pNode->
nStas2++;
950 iCube = iNext, pCube =
Gia_ManAreSta(p, iCube), iNext = pCube->iNext )
954 pCube->iNext = *pRoot;
978 printf(
"Trying cube: " );
992 printf(
"Contained in " );
1002 printf(
"Contains " );
1013 printf(
"Sharped by " );
1043 pSta->
iNext = *pRoot;
1048 printf(
"Adding cube: " );
1074 if ( RetValue == 0 )
1083 if ( RetValue == 0 )
1204 if ( iCube <= p->iStaCur )
1232 if ( RetValue == 0 )
1241 if ( RetValue == 0 )
1428 if ( pObj->
Value <= 1 )
1435 if ( pObjMax == NULL || pObjMax->
Value < pObj->
Value )
1438 return pObjMax->
Value > 1 ? pObjMax : NULL;
1478 int i, CountCur, CountMax = 0;
1634 if ( p->
pNew == NULL )
1662 printf(
"Exceeded the limit on the number of transitions from a state cube (%d).\n",
MAX_CALL_NUM );
1685 printf(
"States =%10d. Reached =%10d. R = %5.3f. Depth =%6d. Mem =%9.2f MB. ",
1719 printf(
"Currently can only handle circuit with up to %d registers.\n",
MAX_VARS_NUM );
1741 printf(
"%s after finding %d state cubes (%d not contained) with depth %d. ",
1742 p->
fStopped ?
"Stopped" :
"Completed",
1747 Abc_Print( 1,
"Output %d of miter \"%s\" was asserted in frame %d.\n",
1759 printf(
"The number of unique state minterms in computed state cubes is %d. ",
Gia_ManCountMinterms(p) );
1771 printf(
"Generated counter-example is INVALID. \n" );
1773 printf(
"Generated counter-example verified correctly. \n" );
1872 if ( iOutFailed >= 0 )
1879 (ABC_INT64_T)1000000, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
1882 printf(
"SAT problem is not satisfiable. Failure...\n" );
1930 if ( pSta != pLast )
static int Gia_WordHasOneBit(unsigned uWord)
static int * Vec_IntArray(Vec_Int_t *p)
static int Gia_ObjHasBranch1(Gia_ObjAre_t *q)
static Gia_ObjAre_t * Gia_ObjNextObj1(Gia_ManAre_t *p, Gia_ObjAre_t *q)
Vec_Vec_t * Gia_ManDeriveCiTfo(Gia_Man_t *p)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
static int Gia_StaAreDashNum(Gia_StaAre_t *p1, Gia_StaAre_t *p2, int nWords)
static unsigned Gia_Ptr2Int(Gia_PtrAre_t n)
static void Gia_ManAreRycycleSta(Gia_ManAre_t *p, Gia_StaAre_t *pSta)
int Gia_ManDeriveCiTfo_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vRes)
static void Gia_ManAreRebalance(Gia_ManAre_t *p, Gia_PtrAre_t *pRoot)
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
static int Gia_ManArePrintUsed(Gia_ManAre_t *p)
void Gia_ManStop(Gia_Man_t *p)
static int Gia_StaAreEqual(Gia_StaAre_t *p1, Gia_StaAre_t *p2, int nWords)
int Gia_ManArePerform(Gia_Man_t *pAig, int nStatesMax, int fMiter, int fVerbose)
static Gia_ObjAre_t * Gia_ManAreCreateObj(Gia_ManAre_t *p)
#define Gia_ManForEachCo(p, pObj, i)
int Gia_ManVerifyCex(Gia_Man_t *pAig, Abc_Cex_t *p, int fDualOut)
DECLARATIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
#define Gia_ManAreForEachCubeList2(p, iList, pCube, iCube)
static int Gia_ManPoNum(Gia_Man_t *p)
Cnf_Dat_t * Cnf_Derive(Aig_Man_t *pAig, int nOutputs)
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
static Gia_Obj_t * Gia_ManCi(Gia_Man_t *p, int v)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
void Aig_ManStop(Aig_Man_t *p)
static int Gia_ObjIsTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
static int Abc_InfoHasBit(unsigned *p, int i)
ABC_NAMESPACE_IMPL_START Abc_Cex_t * Abc_CexAlloc(int nRegs, int nRealPis, int nFrames)
DECLARATIONS ///.
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)
void Gia_ManAreDeriveCexSat(Gia_ManAre_t *p, Gia_StaAre_t *pCur, Gia_StaAre_t *pNext, int iOutFailed)
static int Gia_ManAppendCi(Gia_Man_t *p)
static int Gia_ManAreCubeCheckList(Gia_ManAre_t *p, Gia_PtrAre_t *pRoot, Gia_StaAre_t *pSta)
void sat_solver_delete(sat_solver *s)
void Gia_ManCleanMark0(Gia_Man_t *p)
static int Gia_ObjIsConst0(Gia_Obj_t *pObj)
static int Abc_Var2Lit(int Var, int fCompl)
static void Gia_ManAreCubeAddToList(Gia_ManAre_t *p, Gia_PtrAre_t *pRoot, Gia_StaAre_t *pSta)
static int Gia_ManAreListCountUsed(Gia_ManAre_t *p)
static int Gia_WordFindFirstBit(unsigned uWord)
static Gia_ObjAre_t * Gia_ManAreObj(Gia_ManAre_t *p, Gia_PtrAre_t n)
static int Gia_StaAreContain(Gia_StaAre_t *p1, Gia_StaAre_t *p2, int nWords)
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
static int Gia_WordCountOnes(unsigned uWord)
static int Gia_ManArePrintListUsed(Gia_ManAre_t *p, Gia_PtrAre_t Root)
static int Gia_StaIsGood(Gia_ManAre_t *p, Gia_StaAre_t *pS)
static abctime Abc_Clock()
int Gia_ManCheckPOs_rec(Gia_Man_t *p, Gia_Obj_t *pObj)
static int Abc_MaxInt(int a, int b)
static int Vec_PtrSize(Vec_Ptr_t *p)
static void Vec_VecFree(Vec_Vec_t *p)
int Gia_ManAreFindBestVar(Gia_ManAre_t *p, Gia_PtrAre_t List)
static Gia_PtrAre_t Gia_Int2Ptr(unsigned n)
static Gia_StaAre_t * Gia_ManAreCreateStaNew(Gia_ManAre_t *p)
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
static int sat_solver_var_value(sat_solver *s, int v)
static Gia_StaAre_t * Gia_ManAreStaInt(Gia_ManAre_t *p, int n)
#define ABC_PRTP(a, t, T)
#define Gia_ManAreForEachCubeStore(p, pCube, i)
void Gia_ManAreDeriveCexSatStop(Gia_ManAre_t *p)
#define Gia_ManForEachCi(p, pObj, i)
int Gia_ManAreListCountUsed_rec(Gia_ManAre_t *p, Gia_PtrAre_t Root, int fTree)
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
static Vec_Vec_t * Vec_VecDupInt(Vec_Vec_t *p)
static int Gia_StaIsUsed(Gia_StaAre_t *pS)
int Gia_ManAreCubeCheckTree_rec(Gia_ManAre_t *p, Gia_ObjAre_t *pObj, Gia_StaAre_t *pSta)
static int Abc_LitIsCompl(int Lit)
int Gia_ManAreDeriveNexts(Gia_ManAre_t *p, Gia_PtrAre_t Sta)
static void Gia_StaSetValue1(Gia_StaAre_t *p, int iReg)
static Gia_ObjAre_t * Gia_ObjNextObj2(Gia_ManAre_t *p, Gia_ObjAre_t *q)
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Abc_Cex_t * Gia_ManAreDeriveCex(Gia_ManAre_t *p, Gia_StaAre_t *pLast)
#define Gia_ManAreForEachCubeVec(vVec, p, pCube, i)
static void Gia_StaSetValue0(Gia_StaAre_t *p, int iReg)
#define MAX_CALL_NUM
DECLARATIONS ///.
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
void Gia_ManCountMintermsInCube(Gia_StaAre_t *pCube, int nVars, unsigned *pStore)
FUNCTION DEFINITIONS ///.
static int Gia_ManAreCubeCollectList(Gia_ManAre_t *p, Gia_PtrAre_t *pRoot, Gia_StaAre_t *pSta)
void Aig_ManSetRegNum(Aig_Man_t *p, int nRegs)
static int Gia_ObjFanin1Copy(Gia_Obj_t *pObj)
Gia_ManAre_t * Gia_ManAreCreate(Gia_Man_t *pAig)
struct Gia_StaAre_t_ Gia_StaAre_t
int Gia_ManAreDepth(Gia_ManAre_t *p, int iState)
static int Gia_StaAreDisjointVar(Gia_StaAre_t *p1, Gia_StaAre_t *p2, int nWords)
static int Vec_IntEntry(Vec_Int_t *p, int i)
static void Gia_ObjSetTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
int Gia_ManAreCubeCollectTree_rec(Gia_ManAre_t *p, Gia_ObjAre_t *pObj, Gia_StaAre_t *pSta)
#define ABC_NAMESPACE_IMPL_END
ABC_NAMESPACE_IMPL_END ABC_NAMESPACE_IMPL_START void Gia_ManAreDeriveCexSatStart(Gia_ManAre_t *p)
static int Gia_StaAreDisjoint(Gia_StaAre_t *p1, Gia_StaAre_t *p2, int nWords)
static Gia_Obj_t * Gia_ManAreMostUsedPi(Gia_ManAre_t *p)
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
#define Gia_ManForEachAnd(p, pObj, i)
Aig_Man_t * Gia_ManToAig(Gia_Man_t *p, int fChoices)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
static int Gia_StaHasValue0(Gia_StaAre_t *p, int iReg)
static void Abc_Print(int level, const char *format,...)
void Gia_ManAreFree(Gia_ManAre_t *p)
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
int Gia_ManAreCubeCheckTree(Gia_ManAre_t *p, Gia_StaAre_t *pSta)
static Vec_Int_t * Vec_VecEntryInt(Vec_Vec_t *p, int i)
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
#define ABC_NAMESPACE_IMPL_START
static void Abc_InfoSetBit(unsigned *p, int i)
static int Gia_StaHasValue1(Gia_StaAre_t *p, int iReg)
static int Gia_ManCiNum(Gia_Man_t *p)
static int Gia_ObjHasBranch0(Gia_ObjAre_t *q)
#define Gia_ManAreForEachCubeList(p, pList, pCube)
static Gia_StaAre_t * Gia_ManAreCreateStaInit(Gia_ManAre_t *p)
static void Gia_StaSetUnused(Gia_StaAre_t *pS)
static int Gia_ManAreCubeProcess(Gia_ManAre_t *p, Gia_StaAre_t *pSta)
static int Gia_StaIsUnused(Gia_StaAre_t *pS)
static int Vec_IntSize(Vec_Int_t *p)
void * Cnf_DataWriteIntoSolver(Cnf_Dat_t *p, int nFrames, int fInit)
int Gia_ManAreDeriveNexts_rec(Gia_ManAre_t *p, Gia_PtrAre_t Sta)
void Gia_ManAreCubeAddToTree_rec(Gia_ManAre_t *p, Gia_ObjAre_t *pObj, Gia_StaAre_t *pSta)
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Vec_Int_t * Gia_ManDeriveCiTfoOne(Gia_Man_t *p, Gia_Obj_t *pPivot)
static int Gia_ManCheckPOs(Gia_ManAre_t *p)
int Gia_ManCountMinterms(Gia_ManAre_t *p)
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
static int Abc_Lit2Var(int Lit)
#define ABC_CALLOC(type, num)
static int Gia_ManCheckPOstatus(Gia_ManAre_t *p)
void Cnf_DataFree(Cnf_Dat_t *p)
Vec_Int_t * Cnf_DataCollectCiSatNums(Cnf_Dat_t *pCnf, Aig_Man_t *p)
static int Gia_ManAreListCountListUsed(Gia_ManAre_t *p, Gia_PtrAre_t Root)
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
#define Gia_ManForEachRo(p, pObj, i)
static int Gia_ObjHasBranch2(Gia_ObjAre_t *q)
static int Abc_BitWordNum(int nBits)
void Gia_ManAreMostUsedPi_rec(Gia_Man_t *p, Gia_Obj_t *pObj)
typedefABC_NAMESPACE_HEADER_START struct Abc_Cex_t_ Abc_Cex_t
INCLUDES ///.
#define Gia_ManForEachRi(p, pObj, i)
static Gia_StaAre_t * Gia_ManAreStaLast(Gia_ManAre_t *p)
void Gia_ManHashAlloc(Gia_Man_t *p)
void Gia_ManIncrementTravId(Gia_Man_t *p)
int Gia_ManArePrintUsed_rec(Gia_ManAre_t *p, Gia_PtrAre_t Root, int fTree)
static void Vec_IntFree(Vec_Int_t *p)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
static int Gia_ManPiNum(Gia_Man_t *p)
void Gia_ManArePrintReport(Gia_ManAre_t *p, abctime Time, int fFinal)
static void Vec_IntClear(Vec_Int_t *p)
static void Gia_ManAreCompress(Gia_ManAre_t *p, Gia_PtrAre_t *pRoot)
static Gia_StaAre_t * Gia_StaPrev(Gia_ManAre_t *p, Gia_StaAre_t *pS)
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
static Gia_ObjAre_t * Gia_ObjNextObj0(Gia_ManAre_t *p, Gia_ObjAre_t *q)
#define Gia_ManForEachPo(p, pObj, i)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
static Gia_StaAre_t * Gia_StaNext(Gia_ManAre_t *p, Gia_StaAre_t *pS)
void Gia_ManArePrintCube(Gia_ManAre_t *p, Gia_StaAre_t *pSta)
static Gia_ObjAre_t * Gia_ManAreObjInt(Gia_ManAre_t *p, int n)
Vec_Int_t * Cnf_DataCollectCoSatNums(Cnf_Dat_t *pCnf, Aig_Man_t *p)
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
static Gia_StaAre_t * Gia_ManAreSta(Gia_ManAre_t *p, Gia_PtrAre_t n)
static int Gia_ObjCioId(Gia_Obj_t *pObj)
static int Gia_ManObjNum(Gia_Man_t *p)
static Gia_StaAre_t * Gia_ManAreCreateSta(Gia_ManAre_t *p)
static void Vec_PtrFree(Vec_Ptr_t *p)
static int Gia_ManCoNum(Gia_Man_t *p)
static Gia_ObjAre_t * Gia_ManAreObjLast(Gia_ManAre_t *p)
static int Gia_StaAreSharpVar(Gia_StaAre_t *p1, Gia_StaAre_t *p2, int nWords)
static int Gia_ManRegNum(Gia_Man_t *p)