Commit 0f03f349 by Alan Mishchenko

Version abc80510

parent e94ccfd3
...@@ -3254,6 +3254,10 @@ SOURCE=.\src\aig\saig\saig.h ...@@ -3254,6 +3254,10 @@ SOURCE=.\src\aig\saig\saig.h
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\aig\saig\saigInter.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\saig\saigPhase.c SOURCE=.\src\aig\saig\saigPhase.c
# End Source File # End Source File
# Begin Source File # Begin Source File
......
...@@ -133,4 +133,6 @@ alias pjsolve "scl; dc2; fr; dc2; ic; ic -t; if -a; cs tacas/005_care.aig; mfs ...@@ -133,4 +133,6 @@ alias pjsolve "scl; dc2; fr; dc2; ic; ic -t; if -a; cs tacas/005_care.aig; mfs
alias t0 "r test/mc1.blif; st; test" alias t0 "r test/mc1.blif; st; test"
alias t1 "r s27mc2.blif; st; test" alias t1 "r s27mc2.blif; st; test"
alias t2 "r i/intel_001.aig; ps; indcut -v" alias t2 "r i/intel_001.aig; ps; indcut -v"
alias t "r c\s\0\000.aig; int"
#alias t "r test/interpol.blif; st; int"
...@@ -64,7 +64,7 @@ typedef enum { ...@@ -64,7 +64,7 @@ typedef enum {
} Aig_Type_t; } Aig_Type_t;
// the AIG node // the AIG node
struct Aig_Obj_t_ // 8 words struct Aig_Obj_t_ // 9 words
{ {
union { union {
Aig_Obj_t * pNext; // strashing table Aig_Obj_t * pNext; // strashing table
...@@ -477,6 +477,7 @@ extern Aig_Man_t * Aig_ManDupLevelized( Aig_Man_t * p ); ...@@ -477,6 +477,7 @@ extern Aig_Man_t * Aig_ManDupLevelized( Aig_Man_t * p );
extern Aig_Man_t * Aig_ManDupWithoutPos( Aig_Man_t * p ); extern Aig_Man_t * Aig_ManDupWithoutPos( Aig_Man_t * p );
extern Aig_Man_t * Aig_ManDupRepres( Aig_Man_t * p ); extern Aig_Man_t * Aig_ManDupRepres( Aig_Man_t * p );
extern Aig_Man_t * Aig_ManDupRepresDfs( Aig_Man_t * p ); extern Aig_Man_t * Aig_ManDupRepresDfs( Aig_Man_t * p );
extern Aig_Man_t * Aig_ManCreateMiter( Aig_Man_t * p1, Aig_Man_t * p2, int fImpl );
/*=== aigFanout.c ==========================================================*/ /*=== aigFanout.c ==========================================================*/
extern void Aig_ObjAddFanout( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pFanout ); extern void Aig_ObjAddFanout( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pFanout );
extern void Aig_ObjRemoveFanout( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pFanout ); extern void Aig_ObjRemoveFanout( Aig_Man_t * p, Aig_Obj_t * pObj, Aig_Obj_t * pFanout );
...@@ -524,6 +525,7 @@ extern Aig_Obj_t * Aig_Or( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 ); ...@@ -524,6 +525,7 @@ extern Aig_Obj_t * Aig_Or( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 );
extern Aig_Obj_t * Aig_Exor( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 ); extern Aig_Obj_t * Aig_Exor( Aig_Man_t * p, Aig_Obj_t * p0, Aig_Obj_t * p1 );
extern Aig_Obj_t * Aig_Mux( Aig_Man_t * p, Aig_Obj_t * pC, Aig_Obj_t * p1, Aig_Obj_t * p0 ); extern Aig_Obj_t * Aig_Mux( Aig_Man_t * p, Aig_Obj_t * pC, Aig_Obj_t * p1, Aig_Obj_t * p0 );
extern Aig_Obj_t * Aig_Maj( Aig_Man_t * p, Aig_Obj_t * pA, Aig_Obj_t * pB, Aig_Obj_t * pC ); extern Aig_Obj_t * Aig_Maj( Aig_Man_t * p, Aig_Obj_t * pA, Aig_Obj_t * pB, Aig_Obj_t * pC );
extern Aig_Obj_t * Aig_Multi( Aig_Man_t * p, Aig_Obj_t ** pArgs, int nArgs, Aig_Type_t Type );
extern Aig_Obj_t * Aig_Miter( Aig_Man_t * p, Vec_Ptr_t * vPairs ); extern Aig_Obj_t * Aig_Miter( Aig_Man_t * p, Vec_Ptr_t * vPairs );
extern Aig_Obj_t * Aig_MiterTwo( Aig_Man_t * p, Vec_Ptr_t * vNodes1, Vec_Ptr_t * vNodes2 ); extern Aig_Obj_t * Aig_MiterTwo( Aig_Man_t * p, Vec_Ptr_t * vNodes1, Vec_Ptr_t * vNodes2 );
extern Aig_Obj_t * Aig_CreateAnd( Aig_Man_t * p, int nVars ); extern Aig_Obj_t * Aig_CreateAnd( Aig_Man_t * p, int nVars );
......
...@@ -732,6 +732,61 @@ Aig_Man_t * Aig_ManDupRepresDfs( Aig_Man_t * p ) ...@@ -732,6 +732,61 @@ Aig_Man_t * Aig_ManDupRepresDfs( Aig_Man_t * p )
return pNew; return pNew;
} }
/**Function*************************************************************
Synopsis [Creates the miter of the two AIG managers.]
Description [Oper is the operation to perform on the outputs of the miter.
Oper == 0 is XOR
Oper == 1 is complemented implication (p1 => p2)
Oper == 2 is OR
Oper == 3 is AND
]
SideEffects []
SeeAlso []
***********************************************************************/
Aig_Man_t * Aig_ManCreateMiter( Aig_Man_t * p1, Aig_Man_t * p2, int Oper )
{
Aig_Man_t * pNew;
Aig_Obj_t * pObj;
int i;
assert( Aig_ManRegNum(p1) == 0 );
assert( Aig_ManRegNum(p2) == 0 );
assert( Aig_ManPoNum(p1) == 1 );
assert( Aig_ManPoNum(p2) == 1 );
assert( Aig_ManPiNum(p1) == Aig_ManPiNum(p2) );
pNew = Aig_ManStart( Aig_ManObjNumMax(p1) + Aig_ManObjNumMax(p2) );
// add first AIG
Aig_ManConst1(p1)->pData = Aig_ManConst1(pNew);
Aig_ManForEachPi( p1, pObj, i )
pObj->pData = Aig_ObjCreatePi( pNew );
Aig_ManForEachNode( p1, pObj, i )
pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
// add second AIG
Aig_ManConst1(p2)->pData = Aig_ManConst1(pNew);
Aig_ManForEachPi( p2, pObj, i )
pObj->pData = Aig_ManPi( pNew, i );
Aig_ManForEachNode( p2, pObj, i )
pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
// add the output
if ( Oper == 0 ) // XOR
pObj = Aig_Exor( pNew, Aig_ObjChild0Copy(Aig_ManPo(p1,0)), Aig_ObjChild0Copy(Aig_ManPo(p2,0)) );
else if ( Oper == 1 ) // implication is PO(p1) -> PO(p2) ... complement is PO(p1) & !PO(p2)
pObj = Aig_And( pNew, Aig_ObjChild0Copy(Aig_ManPo(p1,0)), Aig_Not(Aig_ObjChild0Copy(Aig_ManPo(p2,0))) );
else if ( Oper == 2 ) // OR
pObj = Aig_Or( pNew, Aig_ObjChild0Copy(Aig_ManPo(p1,0)), Aig_ObjChild0Copy(Aig_ManPo(p2,0)) );
else if ( Oper == 3 ) // AND
pObj = Aig_And( pNew, Aig_ObjChild0Copy(Aig_ManPo(p1,0)), Aig_ObjChild0Copy(Aig_ManPo(p2,0)) );
else
assert( 0 );
Aig_ObjCreatePo( pNew, pObj );
Aig_ManCleanup( pNew );
return pNew;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -216,7 +216,7 @@ void Aig_ManStop( Aig_Man_t * p ) ...@@ -216,7 +216,7 @@ void Aig_ManStop( Aig_Man_t * p )
FREE( p->pObjCopies ); FREE( p->pObjCopies );
FREE( p->pReprs ); FREE( p->pReprs );
FREE( p->pEquivs ); FREE( p->pEquivs );
// free( p->pTable ); free( p->pTable );
free( p ); free( p );
} }
......
...@@ -370,6 +370,11 @@ void Aig_ObjReplace( Aig_Man_t * p, Aig_Obj_t * pObjOld, Aig_Obj_t * pObjNew, in ...@@ -370,6 +370,11 @@ void Aig_ObjReplace( Aig_Man_t * p, Aig_Obj_t * pObjOld, Aig_Obj_t * pObjNew, in
// make sure object is not pointing to itself // make sure object is not pointing to itself
assert( pObjOld != Aig_ObjFanin0(pObjNewR) ); assert( pObjOld != Aig_ObjFanin0(pObjNewR) );
assert( pObjOld != Aig_ObjFanin1(pObjNewR) ); assert( pObjOld != Aig_ObjFanin1(pObjNewR) );
if ( pObjOld == Aig_ObjFanin0(pObjNewR) || pObjOld == Aig_ObjFanin1(pObjNewR) )
{
printf( "Aig_ObjReplace(): Internal error!\n" );
exit(1);
}
// recursively delete the old node - but leave the object there // recursively delete the old node - but leave the object there
pObjNewR->nRefs++; pObjNewR->nRefs++;
if ( !Aig_ObjIsPi(pObjOld) ) if ( !Aig_ObjIsPi(pObjOld) )
......
...@@ -136,8 +136,9 @@ extern Cnf_Dat_t * Cnf_DataAlloc( Aig_Man_t * pAig, int nVars, int nClauses, ...@@ -136,8 +136,9 @@ extern Cnf_Dat_t * Cnf_DataAlloc( Aig_Man_t * pAig, int nVars, int nClauses,
extern Cnf_Dat_t * Cnf_DataDup( Cnf_Dat_t * p ); extern Cnf_Dat_t * Cnf_DataDup( Cnf_Dat_t * p );
extern void Cnf_DataFree( Cnf_Dat_t * p ); extern void Cnf_DataFree( Cnf_Dat_t * p );
extern void Cnf_DataLift( Cnf_Dat_t * p, int nVarsPlus ); extern void Cnf_DataLift( Cnf_Dat_t * p, int nVarsPlus );
extern void Cnf_DataPrint( Cnf_Dat_t * p, int fReadable );
extern void Cnf_DataWriteIntoFile( Cnf_Dat_t * p, char * pFileName, int fReadable ); extern void Cnf_DataWriteIntoFile( Cnf_Dat_t * p, char * pFileName, int fReadable );
void * Cnf_DataWriteIntoSolver( Cnf_Dat_t * p, int nFrames, int fInit ); extern void * Cnf_DataWriteIntoSolver( Cnf_Dat_t * p, int nFrames, int fInit );
extern void Cnf_DataWriteOrClause( void * pSat, Cnf_Dat_t * pCnf ); extern void Cnf_DataWriteOrClause( void * pSat, Cnf_Dat_t * pCnf );
/*=== cnfMap.c ========================================================*/ /*=== cnfMap.c ========================================================*/
extern void Cnf_DeriveMapping( Cnf_Man_t * p ); extern void Cnf_DeriveMapping( Cnf_Man_t * p );
......
...@@ -212,6 +212,31 @@ void Cnf_DataLift( Cnf_Dat_t * p, int nVarsPlus ) ...@@ -212,6 +212,31 @@ void Cnf_DataLift( Cnf_Dat_t * p, int nVarsPlus )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Cnf_DataPrint( Cnf_Dat_t * p, int fReadable )
{
FILE * pFile = stdout;
int * pLit, * pStop, i;
fprintf( pFile, "p cnf %d %d\n", p->nVars, p->nClauses );
for ( i = 0; i < p->nClauses; i++ )
{
for ( pLit = p->pClauses[i], pStop = p->pClauses[i+1]; pLit < pStop; pLit++ )
fprintf( pFile, "%d ", fReadable? Cnf_Lit2Var2(*pLit) : Cnf_Lit2Var(*pLit) );
fprintf( pFile, "\n" );
}
fprintf( pFile, "\n" );
}
/**Function*************************************************************
Synopsis [Writes CNF into a file.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Cnf_DataWriteIntoFile( Cnf_Dat_t * p, char * pFileName, int fReadable ) void Cnf_DataWriteIntoFile( Cnf_Dat_t * p, char * pFileName, int fReadable )
{ {
FILE * pFile; FILE * pFile;
......
...@@ -98,6 +98,7 @@ struct Ntl_Mod_t_ ...@@ -98,6 +98,7 @@ struct Ntl_Mod_t_
float * pDelayTable; float * pDelayTable;
// other data members // other data members
void * pCopy; void * pCopy;
int nUsed, nRems;
}; };
struct Ntl_Obj_t_ struct Ntl_Obj_t_
...@@ -186,12 +187,12 @@ static inline void Ntl_ObjSetFanout( Ntl_Obj_t * p, Ntl_Net_t * pNet, int ...@@ -186,12 +187,12 @@ static inline void Ntl_ObjSetFanout( Ntl_Obj_t * p, Ntl_Net_t * pNet, int
/// ITERATORS /// /// ITERATORS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
#define Ntl_ManForEachModel( p, pNtl, i ) \ #define Ntl_ManForEachModel( p, pMod, i ) \
Vec_PtrForEachEntry( p->vModels, pNtl, i ) Vec_PtrForEachEntry( p->vModels, pMod, i )
#define Ntl_ManForEachCiNet( p, pNtl, i ) \ #define Ntl_ManForEachCiNet( p, pNet, i ) \
Vec_PtrForEachEntry( p->vCis, pNtl, i ) Vec_PtrForEachEntry( p->vCis, pNet, i )
#define Ntl_ManForEachCoNet( p, pNtl, i ) \ #define Ntl_ManForEachCoNet( p, pNet, i ) \
Vec_PtrForEachEntry( p->vCos, pNtl, i ) Vec_PtrForEachEntry( p->vCos, pNet, i )
#define Ntl_ManForEachNode( p, pObj, i ) \ #define Ntl_ManForEachNode( p, pObj, i ) \
for ( i = 0; (i < Vec_PtrSize(p->vNodes)) && (((pObj) = Vec_PtrEntry(p->vNodes, i)), 1); i++ ) \ for ( i = 0; (i < Vec_PtrSize(p->vNodes)) && (((pObj) = Vec_PtrEntry(p->vNodes, i)), 1); i++ ) \
if ( (pObj) == NULL || !Ntl_ObjIsNode(pObj) ) {} else if ( (pObj) == NULL || !Ntl_ObjIsNode(pObj) ) {} else
......
...@@ -97,11 +97,11 @@ void Ntl_ManSweepMark( Ntl_Man_t * p ) ...@@ -97,11 +97,11 @@ void Ntl_ManSweepMark( Ntl_Man_t * p )
int Ntl_ManSweep( Ntl_Man_t * p, int fVerbose ) int Ntl_ManSweep( Ntl_Man_t * p, int fVerbose )
{ {
int nObjsOld[NTL_OBJ_VOID]; int nObjsOld[NTL_OBJ_VOID];
Ntl_Mod_t * pRoot; Ntl_Mod_t * pRoot, * pMod;
Ntl_Net_t * pNet; Ntl_Net_t * pNet;
Ntl_Obj_t * pObj; Ntl_Obj_t * pObj;
int i, k, nNetsOld; int i, k, nNetsOld;
int Counter = 0; int ModelCounter = 0, Counter = 0;
// remember the number of objects // remember the number of objects
pRoot = Ntl_ManRootModel( p ); pRoot = Ntl_ManRootModel( p );
...@@ -112,6 +112,23 @@ int Ntl_ManSweep( Ntl_Man_t * p, int fVerbose ) ...@@ -112,6 +112,23 @@ int Ntl_ManSweep( Ntl_Man_t * p, int fVerbose )
// mark the nets that do not fanout into POs // mark the nets that do not fanout into POs
Ntl_ManSweepMark( p ); Ntl_ManSweepMark( p );
// count how many boxes of each type are swept away
if ( fVerbose )
{
Ntl_ManForEachModel( p, pMod, i )
pMod->nUsed = pMod->nRems = 0;
Ntl_ModelForEachObj( pRoot, pObj, i )
if ( Ntl_ObjIsBox(pObj) && pObj->pImplem )
{
pObj->pImplem->nUsed++;
if ( !pObj->fMark )
{
if ( pObj->pImplem->nRems++ == 0 )
ModelCounter++;
}
}
}
// remove the useless objects and their nets // remove the useless objects and their nets
Ntl_ModelForEachObj( pRoot, pObj, i ) Ntl_ModelForEachObj( pRoot, pObj, i )
{ {
...@@ -134,6 +151,8 @@ int Ntl_ManSweep( Ntl_Man_t * p, int fVerbose ) ...@@ -134,6 +151,8 @@ int Ntl_ManSweep( Ntl_Man_t * p, int fVerbose )
Counter++; Counter++;
} }
// print detailed statistics of sweeping // print detailed statistics of sweeping
if ( fVerbose ) if ( fVerbose )
{ {
...@@ -151,6 +170,14 @@ int Ntl_ManSweep( Ntl_Man_t * p, int fVerbose ) ...@@ -151,6 +170,14 @@ int Ntl_ManSweep( Ntl_Man_t * p, int fVerbose )
nObjsOld[NTL_OBJ_BOX] - pRoot->nObjs[NTL_OBJ_BOX], nObjsOld[NTL_OBJ_BOX] - pRoot->nObjs[NTL_OBJ_BOX],
!nObjsOld[NTL_OBJ_BOX]? 0.0: 100.0 * (nObjsOld[NTL_OBJ_BOX] - pRoot->nObjs[NTL_OBJ_BOX]) / nObjsOld[NTL_OBJ_BOX] ); !nObjsOld[NTL_OBJ_BOX]? 0.0: 100.0 * (nObjsOld[NTL_OBJ_BOX] - pRoot->nObjs[NTL_OBJ_BOX]) / nObjsOld[NTL_OBJ_BOX] );
printf( "\n" ); printf( "\n" );
if ( ModelCounter )
{
printf( "Sweep removed %d boxed of %d types (out of %d types):\n",
nObjsOld[NTL_OBJ_BOX] - pRoot->nObjs[NTL_OBJ_BOX], ModelCounter, Vec_PtrSize(p->vModels)-1 );
Ntl_ManForEachModel( p, pMod, i )
if ( i )
printf( "Model %3d : %-40s Swept = %5d. Left = %5d.\n", i, pMod->pName, pMod->nRems, pMod->nUsed-pMod->nRems );
}
} }
if ( !Ntl_ManCheck( p ) ) if ( !Ntl_ManCheck( p ) )
printf( "Ntl_ManSweep: The check has failed for design %s.\n", p->pName ); printf( "Ntl_ManSweep: The check has failed for design %s.\n", p->pName );
......
SRC += src/aig/saig/saig_.c \ SRC += src/aig/saig/saig_.c \
src/aig/saig/saigInter.c \
src/aig/saig/saigPhase.c \ src/aig/saig/saigPhase.c \
src/aig/saig/saigRetFwd.c \ src/aig/saig/saigRetFwd.c \
src/aig/saig/saigRetMin.c \ src/aig/saig/saigRetMin.c \
......
...@@ -75,6 +75,8 @@ static inline int Saig_ObjIsLi( Aig_Man_t * p, Aig_Obj_t * pObj ) { ...@@ -75,6 +75,8 @@ static inline int Saig_ObjIsLi( Aig_Man_t * p, Aig_Obj_t * pObj ) {
/// FUNCTION DECLARATIONS /// /// FUNCTION DECLARATIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/*=== saigInter.c ==========================================================*/
extern int Saig_Interpolate( Aig_Man_t * pAig, int nConfLimit, int fVerbose, int * pDepth );
/*=== saigPhase.c ==========================================================*/ /*=== saigPhase.c ==========================================================*/
extern Aig_Man_t * Saig_ManPhaseAbstract( Aig_Man_t * p, Vec_Int_t * vInits, int nFrames, int fIgnore, int fPrint, int fVerbose ); extern Aig_Man_t * Saig_ManPhaseAbstract( Aig_Man_t * p, Vec_Int_t * vInits, int nFrames, int fIgnore, int fPrint, int fVerbose );
/*=== saigRetFwd.c ==========================================================*/ /*=== saigRetFwd.c ==========================================================*/
......
...@@ -703,7 +703,7 @@ extern Abc_Ntk_t * Abc_NtkCreateFromNode( Abc_Ntk_t * pNtk, Abc_Obj_t * p ...@@ -703,7 +703,7 @@ extern Abc_Ntk_t * Abc_NtkCreateFromNode( Abc_Ntk_t * pNtk, Abc_Obj_t * p
extern Abc_Ntk_t * Abc_NtkCreateWithNode( char * pSop ); extern Abc_Ntk_t * Abc_NtkCreateWithNode( char * pSop );
extern void Abc_NtkDelete( Abc_Ntk_t * pNtk ); extern void Abc_NtkDelete( Abc_Ntk_t * pNtk );
extern void Abc_NtkFixNonDrivenNets( Abc_Ntk_t * pNtk ); extern void Abc_NtkFixNonDrivenNets( Abc_Ntk_t * pNtk );
extern void Abc_NtkMakeComb( Abc_Ntk_t * pNtk ); extern void Abc_NtkMakeComb( Abc_Ntk_t * pNtk, int fRemoveLatches );
/*=== abcObj.c ==========================================================*/ /*=== abcObj.c ==========================================================*/
extern Abc_Obj_t * Abc_ObjAlloc( Abc_Ntk_t * pNtk, Abc_ObjType_t Type ); extern Abc_Obj_t * Abc_ObjAlloc( Abc_Ntk_t * pNtk, Abc_ObjType_t Type );
extern void Abc_ObjRecycle( Abc_Obj_t * pObj ); extern void Abc_ObjRecycle( Abc_Obj_t * pObj );
......
...@@ -1104,7 +1104,7 @@ void Abc_NtkFixNonDrivenNets( Abc_Ntk_t * pNtk ) ...@@ -1104,7 +1104,7 @@ void Abc_NtkFixNonDrivenNets( Abc_Ntk_t * pNtk )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Abc_NtkMakeComb( Abc_Ntk_t * pNtk ) void Abc_NtkMakeComb( Abc_Ntk_t * pNtk, int fRemoveLatches )
{ {
Abc_Obj_t * pObj; Abc_Obj_t * pObj;
int i; int i;
...@@ -1136,17 +1136,48 @@ void Abc_NtkMakeComb( Abc_Ntk_t * pNtk ) ...@@ -1136,17 +1136,48 @@ void Abc_NtkMakeComb( Abc_Ntk_t * pNtk )
} }
assert( Abc_NtkBoNum(pNtk) == 0 ); assert( Abc_NtkBoNum(pNtk) == 0 );
// move COs to become POs if ( fRemoveLatches )
Vec_PtrClear( pNtk->vPos ); {
Abc_NtkForEachCo( pNtk, pObj, i ) // remove registers
Vec_Ptr_t * vBos;
vBos = Vec_PtrAlloc( 100 );
Vec_PtrClear( pNtk->vPos );
Abc_NtkForEachCo( pNtk, pObj, i )
if ( Abc_ObjIsBi(pObj) )
Vec_PtrPush( vBos, pObj );
else
Vec_PtrPush( pNtk->vPos, pObj );
// remove COs
Vec_PtrFree( pNtk->vCos );
pNtk->vCos = NULL;
// remove the BOs
Vec_PtrForEachEntry( vBos, pObj, i )
Abc_NtkDeleteObj( pObj );
Vec_PtrFree( vBos );
// create COs
pNtk->vCos = Vec_PtrDup( pNtk->vPos );
// cleanup
if ( Abc_NtkIsLogic(pNtk) )
Abc_NtkCleanup( pNtk, 0 );
else if ( Abc_NtkIsStrash(pNtk) )
Abc_AigCleanup( pNtk->pManFunc );
else
assert( 0 );
}
else
{ {
if ( Abc_ObjIsBi(pObj) ) // move COs to become POs
Vec_PtrClear( pNtk->vPos );
Abc_NtkForEachCo( pNtk, pObj, i )
{ {
pObj->Type = ABC_OBJ_PO; if ( Abc_ObjIsBi(pObj) )
pNtk->nObjCounts[ABC_OBJ_PO]++; {
pNtk->nObjCounts[ABC_OBJ_BI]--; pObj->Type = ABC_OBJ_PO;
pNtk->nObjCounts[ABC_OBJ_PO]++;
pNtk->nObjCounts[ABC_OBJ_BI]--;
}
Vec_PtrPush( pNtk->vPos, pObj );
} }
Vec_PtrPush( pNtk->vPos, pObj );
} }
assert( Abc_NtkBiNum(pNtk) == 0 ); assert( Abc_NtkBiNum(pNtk) == 0 );
...@@ -1157,6 +1188,60 @@ void Abc_NtkMakeComb( Abc_Ntk_t * pNtk ) ...@@ -1157,6 +1188,60 @@ void Abc_NtkMakeComb( Abc_Ntk_t * pNtk )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Removes all POs, except one.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Abc_NtkMakeOnePo( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodePo )
{
Vec_Ptr_t * vPosToRemove;
Abc_Obj_t * pObj;
int i;
assert( !Abc_NtkIsNetlist(pNtk) );
assert( Abc_NtkHasOnlyLatchBoxes(pNtk) );
if ( Abc_NtkPoNum(pNtk) == 1 )
return;
// make sure the node exists
Abc_NtkForEachPo( pNtk, pObj, i )
if ( pObj == pNodePo )
break;
assert( i < Abc_NtkPoNum(pNtk) );
// collect POs to remove
vPosToRemove = Vec_PtrAlloc( 100 );
Abc_NtkForEachPo( pNtk, pObj, i )
if ( pObj != pNodePo )
Vec_PtrPush( vPosToRemove, pObj );
// remove the POs
Vec_PtrForEachEntry( vPosToRemove, pObj, i )
Abc_NtkDeleteObj( pObj );
Vec_PtrFree( vPosToRemove );
if ( Abc_NtkIsStrash(pNtk) )
{
Abc_AigCleanup( pNtk->pManFunc );
printf( "Run sequential cleanup (\"scl\") to get rid of dangling logic.\n" );
}
else
{
printf( "Run sequential cleanup (\"st; scl\") to get rid of dangling logic.\n" );
}
if ( !Abc_NtkCheck( pNtk ) )
fprintf( stdout, "Abc_NtkMakeComb(): Network check has failed.\n" );
}
/**Function*************************************************************
Synopsis [Removes POs with suppsize less than 2 and PIs without fanout.] Synopsis [Removes POs with suppsize less than 2 and PIs without fanout.]
Description [] Description []
......
...@@ -197,6 +197,7 @@ static int Abc_CommandProve ( Abc_Frame_t * pAbc, int argc, char ** arg ...@@ -197,6 +197,7 @@ static int Abc_CommandProve ( Abc_Frame_t * pAbc, int argc, char ** arg
static int Abc_CommandIProve ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandIProve ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandDebug ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandDebug ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandBmc ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandBmc ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandBmcInter ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandIndcut ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandIndcut ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandEnlarge ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandEnlarge ( Abc_Frame_t * pAbc, int argc, char ** argv );
...@@ -447,6 +448,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) ...@@ -447,6 +448,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Verification", "iprove", Abc_CommandIProve, 1 ); Cmd_CommandAdd( pAbc, "Verification", "iprove", Abc_CommandIProve, 1 );
Cmd_CommandAdd( pAbc, "Verification", "debug", Abc_CommandDebug, 0 ); Cmd_CommandAdd( pAbc, "Verification", "debug", Abc_CommandDebug, 0 );
Cmd_CommandAdd( pAbc, "Verification", "bmc", Abc_CommandBmc, 0 ); Cmd_CommandAdd( pAbc, "Verification", "bmc", Abc_CommandBmc, 0 );
Cmd_CommandAdd( pAbc, "Verification", "int", Abc_CommandBmcInter, 0 );
Cmd_CommandAdd( pAbc, "Verification", "indcut", Abc_CommandIndcut, 0 ); Cmd_CommandAdd( pAbc, "Verification", "indcut", Abc_CommandIndcut, 0 );
Cmd_CommandAdd( pAbc, "Verification", "enlarge", Abc_CommandEnlarge, 1 ); Cmd_CommandAdd( pAbc, "Verification", "enlarge", Abc_CommandEnlarge, 1 );
...@@ -4531,17 +4533,22 @@ int Abc_CommandComb( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -4531,17 +4533,22 @@ int Abc_CommandComb( Abc_Frame_t * pAbc, int argc, char ** argv )
FILE * pOut, * pErr; FILE * pOut, * pErr;
Abc_Ntk_t * pNtk, * pNtkRes; Abc_Ntk_t * pNtk, * pNtkRes;
int c; int c;
int fRemoveLatches;
pNtk = Abc_FrameReadNtk(pAbc); pNtk = Abc_FrameReadNtk(pAbc);
pOut = Abc_FrameReadOut(pAbc); pOut = Abc_FrameReadOut(pAbc);
pErr = Abc_FrameReadErr(pAbc); pErr = Abc_FrameReadErr(pAbc);
// set defaults // set defaults
fRemoveLatches = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "lh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
case 'l':
fRemoveLatches ^= 1;
break;
case 'h': case 'h':
goto usage; goto usage;
default: default:
...@@ -4562,14 +4569,15 @@ int Abc_CommandComb( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -4562,14 +4569,15 @@ int Abc_CommandComb( Abc_Frame_t * pAbc, int argc, char ** argv )
// get the new network // get the new network
pNtkRes = Abc_NtkDup( pNtk ); pNtkRes = Abc_NtkDup( pNtk );
Abc_NtkMakeComb( pNtkRes ); Abc_NtkMakeComb( pNtkRes, fRemoveLatches );
// replace the current network // replace the current network
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
return 0; return 0;
usage: usage:
fprintf( pErr, "usage: comb [-h]\n" ); fprintf( pErr, "usage: comb [-lh]\n" );
fprintf( pErr, "\t makes the current network combinational by replacing latches by PI/PO pairs\n" ); fprintf( pErr, "\t makes the current network combinational by replacing latches by PI/PO pairs\n" );
fprintf( pErr, "\t-l : toggle removing latches [default = %s]\n", fRemoveLatches? "yes": "no" );
fprintf( pErr, "\t-h : print the command usage\n"); fprintf( pErr, "\t-h : print the command usage\n");
return 1; return 1;
} }
...@@ -5741,8 +5749,11 @@ int Abc_CommandCone( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -5741,8 +5749,11 @@ int Abc_CommandCone( Abc_Frame_t * pAbc, int argc, char ** argv )
int c; int c;
int fUseAllCis; int fUseAllCis;
int fUseMffc; int fUseMffc;
int fSeq;
int Output; int Output;
extern void Abc_NtkMakeOnePo( Abc_Ntk_t * pNtk, Abc_Obj_t * pNodePo );
pNtk = Abc_FrameReadNtk(pAbc); pNtk = Abc_FrameReadNtk(pAbc);
pOut = Abc_FrameReadOut(pAbc); pOut = Abc_FrameReadOut(pAbc);
pErr = Abc_FrameReadErr(pAbc); pErr = Abc_FrameReadErr(pAbc);
...@@ -5750,9 +5761,10 @@ int Abc_CommandCone( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -5750,9 +5761,10 @@ int Abc_CommandCone( Abc_Frame_t * pAbc, int argc, char ** argv )
// set defaults // set defaults
fUseAllCis = 0; fUseAllCis = 0;
fUseMffc = 0; fUseMffc = 0;
fSeq = 0;
Output = -1; Output = -1;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "Omah" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "Omash" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
...@@ -5769,9 +5781,13 @@ int Abc_CommandCone( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -5769,9 +5781,13 @@ int Abc_CommandCone( Abc_Frame_t * pAbc, int argc, char ** argv )
break; break;
case 'm': case 'm':
fUseMffc ^= 1; fUseMffc ^= 1;
break;
case 'a': case 'a':
fUseAllCis ^= 1; fUseAllCis ^= 1;
break; break;
case 's':
fSeq ^= 1;
break;
case 'h': case 'h':
goto usage; goto usage;
default: default:
...@@ -5824,12 +5840,18 @@ int Abc_CommandCone( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -5824,12 +5840,18 @@ int Abc_CommandCone( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1; return 1;
} }
pNodeCo = Abc_NtkCo( pNtk, Output ); pNodeCo = Abc_NtkCo( pNtk, Output );
if ( fUseMffc ) if ( fSeq )
{
pNtkRes = Abc_NtkDup( pNtk );
pNodeCo = Abc_NtkPo( pNtkRes, Output );
Abc_NtkMakeOnePo( pNtkRes, pNodeCo );
}
else if ( fUseMffc )
pNtkRes = Abc_NtkCreateMffc( pNtk, Abc_ObjFanin0(pNodeCo), Abc_ObjName(pNodeCo) ); pNtkRes = Abc_NtkCreateMffc( pNtk, Abc_ObjFanin0(pNodeCo), Abc_ObjName(pNodeCo) );
else else
pNtkRes = Abc_NtkCreateCone( pNtk, Abc_ObjFanin0(pNodeCo), Abc_ObjName(pNodeCo), fUseAllCis ); pNtkRes = Abc_NtkCreateCone( pNtk, Abc_ObjFanin0(pNodeCo), Abc_ObjName(pNodeCo), fUseAllCis );
} }
if ( pNodeCo && Abc_ObjFaninC0(pNodeCo) ) if ( pNodeCo && Abc_ObjFaninC0(pNodeCo) && !fSeq )
printf( "The extracted cone represents the complement function of the CO.\n" ); printf( "The extracted cone represents the complement function of the CO.\n" );
if ( pNtkRes == NULL ) if ( pNtkRes == NULL )
{ {
...@@ -5841,10 +5863,11 @@ int Abc_CommandCone( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -5841,10 +5863,11 @@ int Abc_CommandCone( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0; return 0;
usage: usage:
fprintf( pErr, "usage: cone [-O num] [-amh] <name>\n" ); fprintf( pErr, "usage: cone [-O num] [-amsh] <name>\n" );
fprintf( pErr, "\t replaces the current network by one logic cone\n" ); fprintf( pErr, "\t replaces the current network by one logic cone\n" );
fprintf( pErr, "\t-a : toggle writing all CIs or structral support only [default = %s]\n", fUseAllCis? "all": "structural" ); fprintf( pErr, "\t-a : toggle keeping all CIs or structral support only [default = %s]\n", fUseAllCis? "all": "structural" );
fprintf( pErr, "\t-m : toggle writing only MFFC or complete TFI cone [default = %s]\n", fUseMffc? "MFFC": "TFI cone" ); fprintf( pErr, "\t-m : toggle keeping only MFFC or complete TFI cone [default = %s]\n", fUseMffc? "MFFC": "TFI cone" );
fprintf( pErr, "\t-s : toggle comb or sequential cone (works with \"-O num\") [default = %s]\n", fSeq? "seq": "comb" );
fprintf( pErr, "\t-h : print the command usage\n"); fprintf( pErr, "\t-h : print the command usage\n");
fprintf( pErr, "\t-O num : (optional) the 0-based number of the CO to extract\n"); fprintf( pErr, "\t-O num : (optional) the 0-based number of the CO to extract\n");
fprintf( pErr, "\tname : (optional) the name of the node to extract\n"); fprintf( pErr, "\tname : (optional) the name of the node to extract\n");
...@@ -14601,6 +14624,11 @@ int Abc_CommandBmc( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -14601,6 +14624,11 @@ int Abc_CommandBmc( Abc_Frame_t * pAbc, int argc, char ** argv )
fprintf( stdout, "Currently only works for structurally hashed circuits.\n" ); fprintf( stdout, "Currently only works for structurally hashed circuits.\n" );
return 0; return 0;
} }
if ( Abc_NtkLatchNum(pNtk) == 0 )
{
fprintf( stdout, "Does not work for combinational networks.\n" );
return 0;
}
Abc_NtkDarBmc( pNtk, nFrames, nBTLimit, fRewrite, fVerbose ); Abc_NtkDarBmc( pNtk, nFrames, nBTLimit, fRewrite, fVerbose );
return 0; return 0;
...@@ -14614,7 +14642,98 @@ usage: ...@@ -14614,7 +14642,98 @@ usage:
fprintf( pErr, "\t-h : print the command usage\n"); fprintf( pErr, "\t-h : print the command usage\n");
return 1; return 1;
} }
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_CommandBmcInter( Abc_Frame_t * pAbc, int argc, char ** argv )
{
FILE * pOut, * pErr;
Abc_Ntk_t * pNtk;
int c;
int nBTLimit;
int fRewrite;
int fVerbose;
extern int Abc_NtkDarBmcInter( Abc_Ntk_t * pNtk, int nConfLimit, int fVerbose );
pNtk = Abc_FrameReadNtk(pAbc);
pOut = Abc_FrameReadOut(pAbc);
pErr = Abc_FrameReadErr(pAbc);
// set defaults
nBTLimit = 20000;
fRewrite = 0;
fVerbose = 1;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "Crvh" ) ) != EOF )
{
switch ( c )
{
case 'C':
if ( globalUtilOptind >= argc )
{
fprintf( pErr, "Command line switch \"-C\" should be followed by an integer.\n" );
goto usage;
}
nBTLimit = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nBTLimit < 0 )
goto usage;
break;
case 'r':
fRewrite ^= 1;
break;
case 'v':
fVerbose ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
if ( pNtk == NULL )
{
fprintf( pErr, "Empty network.\n" );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
fprintf( stdout, "Currently only works for structurally hashed circuits.\n" );
return 0;
}
if ( Abc_NtkLatchNum(pNtk) == 0 )
{
fprintf( stdout, "Does not work for combinational networks.\n" );
return 0;
}
if ( Abc_NtkPoNum(pNtk) != 1 )
{
fprintf( stdout, "Currently only works for single-output miters (run \"orpos\").\n" );
return 0;
}
Abc_NtkDarBmcInter( pNtk, nBTLimit, fVerbose );
return 0;
usage:
fprintf( pErr, "usage: int [-C num] [-vh]\n" );
fprintf( pErr, "\t uses interpolation to prove the property\n" );
fprintf( pErr, "\t-C num : the limit on conflicts for one SAT run [default = %d]\n", nBTLimit );
// fprintf( pErr, "\t-r : toggle the use of rewriting [default = %s]\n", fRewrite? "yes": "no" );
fprintf( pErr, "\t-v : toggle verbose output [default = %s]\n", fVerbose? "yes": "no" );
fprintf( pErr, "\t-h : print the command usage\n");
return 1;
}
/**Function************************************************************* /**Function*************************************************************
Synopsis [] Synopsis []
......
...@@ -1240,6 +1240,45 @@ PRT( "Time", clock() - clk ); ...@@ -1240,6 +1240,45 @@ PRT( "Time", clock() - clk );
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Abc_NtkDarBmcInter( Abc_Ntk_t * pNtk, int nConfLimit, int fVerbose )
{
Aig_Man_t * pMan;
int RetValue, Depth, clk = clock();
// derive the AIG manager
pMan = Abc_NtkToDar( pNtk, 0, 1 );
if ( pMan == NULL )
{
printf( "Converting miter into AIG has failed.\n" );
return -1;
}
assert( pMan->nRegs > 0 );
pMan->nTruePis = Aig_ManPiNum(pMan) - Aig_ManRegNum(pMan);
pMan->nTruePos = Aig_ManPoNum(pMan) - Aig_ManRegNum(pMan);
RetValue = Saig_Interpolate( pMan, nConfLimit, fVerbose, &Depth );
if ( RetValue == 1 )
printf( "Property proved. " );
else if ( RetValue == 0 )
printf( "Property DISPROVED with counter-example at depth %d. ", Depth );
else if ( RetValue == -1 )
printf( "Property UNDECIDED. " );
else
assert( 0 );
PRT( "Time", clock() - clk );
Aig_ManStop( pMan );
return 1;
}
/**Function*************************************************************
Synopsis [Gives the current ABC network to AIG manager for processing.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_NtkDarProve( Abc_Ntk_t * pNtk, int nFrames, int fPhaseAbstract, int fRetimeFirst, int fRetimeRegs, int fFraiging, int fVerbose, int fVeryVerbose ) int Abc_NtkDarProve( Abc_Ntk_t * pNtk, int nFrames, int fPhaseAbstract, int fRetimeFirst, int fRetimeRegs, int fFraiging, int fVerbose, int fVeryVerbose )
{ {
Aig_Man_t * pMan; Aig_Man_t * pMan;
......
...@@ -299,7 +299,7 @@ void Io_Write( Abc_Ntk_t * pNtk, char * pFileName, Io_FileType_t FileType ) ...@@ -299,7 +299,7 @@ void Io_Write( Abc_Ntk_t * pNtk, char * pFileName, Io_FileType_t FileType )
{ {
fprintf( stdout, "Latches are writen into the PLA file at PI/PO pairs.\n" ); fprintf( stdout, "Latches are writen into the PLA file at PI/PO pairs.\n" );
pNtkCopy = Abc_NtkDup( pNtk ); pNtkCopy = Abc_NtkDup( pNtk );
Abc_NtkMakeComb( pNtkCopy ); Abc_NtkMakeComb( pNtkCopy, 0 );
pNtkTemp = Abc_NtkToNetlist( pNtk ); pNtkTemp = Abc_NtkToNetlist( pNtk );
Abc_NtkDelete( pNtkCopy ); Abc_NtkDelete( pNtkCopy );
} }
......
...@@ -892,6 +892,7 @@ void Inta_ManPrepareInter( Inta_Man_t * p ) ...@@ -892,6 +892,7 @@ void Inta_ManPrepareInter( Inta_Man_t * p )
void * Inta_ManInterpolate( Inta_Man_t * p, Sto_Man_t * pCnf, void * vVarsAB, int fVerbose ) void * Inta_ManInterpolate( Inta_Man_t * p, Sto_Man_t * pCnf, void * vVarsAB, int fVerbose )
{ {
Aig_Man_t * pRes; Aig_Man_t * pRes;
Aig_Obj_t * pObj;
Sto_Cls_t * pClause; Sto_Cls_t * pClause;
int RetValue = 1; int RetValue = 1;
int clkTotal = clock(); int clkTotal = clock();
...@@ -955,7 +956,8 @@ void * Inta_ManInterpolate( Inta_Man_t * p, Sto_Man_t * pCnf, void * vVarsAB, in ...@@ -955,7 +956,8 @@ void * Inta_ManInterpolate( Inta_Man_t * p, Sto_Man_t * pCnf, void * vVarsAB, in
p->timeTotal += clock() - clkTotal; p->timeTotal += clock() - clkTotal;
} }
Aig_ObjCreatePo( pRes, *Inta_ManAigRead( p, p->pCnf->pTail ) ); pObj = *Inta_ManAigRead( p, p->pCnf->pTail );
Aig_ObjCreatePo( pRes, pObj );
Aig_ManCleanup( pRes ); Aig_ManCleanup( pRes );
p->pAig = NULL; p->pAig = NULL;
......
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