Commit 255f171f by Alan Mishchenko

Improving computation of choices from equivalence classes.

parent 40d9b585
......@@ -3411,6 +3411,10 @@ SOURCE=.\src\aig\gia\giaCexMin.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\gia\giaChoice.c
# End Source File
# Begin Source File
SOURCE=.\src\aig\gia\giaCof.c
# End Source File
# Begin Source File
......
......@@ -271,6 +271,7 @@ static inline Gia_Obj_t * Gia_Not( Gia_Obj_t * p ) { return (Gia_Obj
static inline Gia_Obj_t * Gia_NotCond( Gia_Obj_t * p, int c ) { return (Gia_Obj_t *)((ABC_PTRUINT_T)(p) ^ (c)); }
static inline int Gia_IsComplement( Gia_Obj_t * p ) { return (int)((ABC_PTRUINT_T)(p) & 01); }
static inline char * Gia_ManName( Gia_Man_t * p ) { return p->pName; }
static inline int Gia_ManCiNum( Gia_Man_t * p ) { return Vec_IntSize(p->vCis); }
static inline int Gia_ManCoNum( Gia_Man_t * p ) { return Vec_IntSize(p->vCos); }
static inline int Gia_ManPiNum( Gia_Man_t * p ) { return Vec_IntSize(p->vCis) - p->nRegs; }
......@@ -356,9 +357,10 @@ static inline Gia_Obj_t * Gia_ObjFromLit( Gia_Man_t * p, int iLit ) {
static inline int Gia_ObjToLit( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Abc_Var2Lit( Gia_ObjId(p, Gia_Regular(pObj)), Gia_IsComplement(pObj) ); }
static inline int Gia_ObjPhaseRealLit( Gia_Man_t * p, int iLit ) { return Gia_ObjPhaseReal( Gia_ObjFromLit(p, iLit) ); }
static inline int Gia_ObjLevel( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Vec_IntGetEntry(p->vLevels, Gia_ObjId(p,pObj)); }
static inline int Gia_ObjLevelId( Gia_Man_t * p, int Id ) { return Vec_IntGetEntry(p->vLevels, Id); }
static inline void Gia_ObjSetLevel( Gia_Man_t * p, Gia_Obj_t * pObj, int l ) { Vec_IntSetEntry(p->vLevels, Gia_ObjId(p,pObj), l); }
static inline int Gia_ObjLevel( Gia_Man_t * p, Gia_Obj_t * pObj ) { return Gia_ObjLevelId( p, Gia_ObjId(p,pObj) ); }
static inline void Gia_ObjSetLevelId( Gia_Man_t * p, int Id, int l ) { Vec_IntSetEntry(p->vLevels, Id, l); }
static inline void Gia_ObjSetLevel( Gia_Man_t * p, Gia_Obj_t * pObj, int l ) { Gia_ObjSetLevelId( p, Gia_ObjId(p,pObj), l ); }
static inline void Gia_ObjSetCoLevel( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjIsCo(pObj) ); Gia_ObjSetLevel( p, pObj, Gia_ObjLevel(p,Gia_ObjFanin0(pObj)) ); }
static inline void Gia_ObjSetAndLevel( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjIsAnd(pObj) ); Gia_ObjSetLevel( p, pObj, 1+Abc_MaxInt(Gia_ObjLevel(p,Gia_ObjFanin0(pObj)),Gia_ObjLevel(p,Gia_ObjFanin1(pObj))) ); }
......@@ -596,7 +598,6 @@ static inline int Gia_ObjNext( Gia_Man_t * p, int Id ) { r
static inline void Gia_ObjSetNext( Gia_Man_t * p, int Id, int Num ) { p->pNexts[Id] = Num; }
static inline int Gia_ObjIsConst( Gia_Man_t * p, int Id ) { return Gia_ObjRepr(p, Id) == 0; }
static inline int Gia_ObjIsUsed( Gia_Man_t * p, int Id ) { return Gia_ObjRepr(p, Id) != GIA_VOID && Gia_ObjNext(p, Id) > 0; }
static inline int Gia_ObjIsHead( Gia_Man_t * p, int Id ) { return Gia_ObjRepr(p, Id) == GIA_VOID && Gia_ObjNext(p, Id) > 0; }
static inline int Gia_ObjIsNone( Gia_Man_t * p, int Id ) { return Gia_ObjRepr(p, Id) == GIA_VOID && Gia_ObjNext(p, Id) == 0; }
static inline int Gia_ObjIsTail( Gia_Man_t * p, int Id ) { return (Gia_ObjRepr(p, Id) > 0 && Gia_ObjRepr(p, Id) != GIA_VOID) && Gia_ObjNext(p, Id) == 0; }
......@@ -699,6 +700,9 @@ extern int Gia_ManFindFailedPoCex( Gia_Man_t * pAig, Abc_Cex_t *
extern void Gia_ManCounterExampleValueStart( Gia_Man_t * pGia, Abc_Cex_t * pCex );
extern void Gia_ManCounterExampleValueStop( Gia_Man_t * pGia );
extern int Gia_ManCounterExampleValueLookup( Gia_Man_t * pGia, int Id, int iFrame );
/*=== giaChoice.c ============================================================*/
extern void Gia_ManVerifyChoices( Gia_Man_t * p );
extern void Gia_ManReverseClasses( Gia_Man_t * p, int fNowIncreasing );
/*=== giaCsatOld.c ============================================================*/
extern Vec_Int_t * Cbs_ManSolveMiter( Gia_Man_t * pGia, int nConfs, Vec_Str_t ** pvStatus, int fVerbose );
/*=== giaCsat.c ============================================================*/
......@@ -760,7 +764,6 @@ extern int Gia_ManEquivCountLitsAll( Gia_Man_t * p );
extern int Gia_ManEquivCountClasses( Gia_Man_t * p );
extern void Gia_ManEquivPrintOne( Gia_Man_t * p, int i, int Counter );
extern void Gia_ManEquivPrintClasses( Gia_Man_t * p, int fVerbose, float Mem );
extern void Gia_ManReverseClasses( Gia_Man_t * p, int fNowIncreasing );
extern Gia_Man_t * Gia_ManEquivReduce( Gia_Man_t * p, int fUseAll, int fDualOut, int fVerbose );
extern Gia_Man_t * Gia_ManEquivReduceAndRemap( Gia_Man_t * p, int fSeq, int fMiterPairs );
extern int Gia_ManEquivSetColors( Gia_Man_t * p, int fVerbose );
......@@ -912,7 +915,6 @@ extern int Gia_ObjRecognizeExor( Gia_Obj_t * pObj, Gia_Obj_t **
extern Gia_Obj_t * Gia_ObjRecognizeMux( Gia_Obj_t * pNode, Gia_Obj_t ** ppNodeT, Gia_Obj_t ** ppNodeE );
extern int Gia_NodeMffcSize( Gia_Man_t * p, Gia_Obj_t * pNode );
extern int Gia_ManHasChoices( Gia_Man_t * p );
extern void Gia_ManVerifyChoices( Gia_Man_t * p );
extern int Gia_ManHasDangling( Gia_Man_t * p );
extern int Gia_ManMarkDangling( Gia_Man_t * p );
extern Vec_Int_t * Gia_ManGetDangling( Gia_Man_t * p );
......
......@@ -419,18 +419,6 @@ void Gia_ManReprToAigRepr( Aig_Man_t * pAig, Gia_Man_t * pGia )
Aig_ObjCreateRepr( pAig, Aig_ManObj(pAig, pGiaRepr->Value), Aig_ManObj(pAig, pGiaObj->Value) );
}
}
/**Function*************************************************************
Synopsis [Transfers representatives from pGia to pAig.]
Description [Assumes that pAig was created from pGia.]
SideEffects []
SeeAlso []
***********************************************************************/
void Gia_ManReprToAigRepr2( Aig_Man_t * pAig, Gia_Man_t * pGia )
{
Gia_Obj_t * pGiaObj, * pGiaRepr;
......@@ -470,9 +458,9 @@ void Gia_ManReprFromAigRepr( Aig_Man_t * pAig, Gia_Man_t * pGia )
pGia->pReprs = ABC_CALLOC( Gia_Rpr_t, Gia_ManObjNum(pGia) );
for ( i = 0; i < Gia_ManObjNum(pGia); i++ )
Gia_ObjSetRepr( pGia, i, GIA_VOID );
// move pointers from GIA to AIG
Gia_ManForEachObj( pGia, pObjGia, i )
{
// Abc_Print( 1, "%d -> %d %d\n", i, Gia_ObjValue(pObjGia), Gia_ObjValue(pObjGia)/2 );
if ( Gia_ObjIsCo(pObjGia) )
continue;
assert( i == 0 || !Abc_LitIsCompl(Gia_ObjValue(pObjGia)) );
......@@ -490,6 +478,27 @@ void Gia_ManReprFromAigRepr( Aig_Man_t * pAig, Gia_Man_t * pGia )
}
pGia->pNexts = Gia_ManDeriveNexts( pGia );
}
void Gia_ManReprFromAigRepr2( Aig_Man_t * pAig, Gia_Man_t * pGia )
{
Aig_Obj_t * pObjAig, * pReprAig;
int i;
assert( pAig->pReprs != NULL );
assert( pGia->pReprs == NULL );
assert( Gia_ManObjNum(pGia) - Gia_ManCoNum(pGia) == Aig_ManObjNum(pAig) - Aig_ManCoNum(pAig) );
pGia->pReprs = ABC_CALLOC( Gia_Rpr_t, Gia_ManObjNum(pGia) );
for ( i = 0; i < Gia_ManObjNum(pGia); i++ )
Gia_ObjSetRepr( pGia, i, GIA_VOID );
Aig_ManForEachObj( pAig, pObjAig, i )
{
if ( Aig_ObjIsCo(pObjAig) )
continue;
if ( pAig->pReprs[i] == NULL )
continue;
pReprAig = pAig->pReprs[i];
Gia_ObjSetRepr( pGia, Abc_Lit2Var(pObjAig->iData), Abc_Lit2Var(pReprAig->iData) );
}
pGia->pNexts = Gia_ManDeriveNexts( pGia );
}
/**Function*************************************************************
......
......@@ -59,6 +59,7 @@ extern Aig_Man_t * Gia_ManToAigSimple( Gia_Man_t * p );
extern void Gia_ManReprToAigRepr( Aig_Man_t * pAig, Gia_Man_t * pGia );
extern void Gia_ManReprToAigRepr2( Aig_Man_t * pAig, Gia_Man_t * pGia );
extern void Gia_ManReprFromAigRepr( Aig_Man_t * pAig, Gia_Man_t * pGia );
extern void Gia_ManReprFromAigRepr2( Aig_Man_t * pAig, Gia_Man_t * pGia );
extern Gia_Man_t * Gia_ManCompress2( Gia_Man_t * p, int fUpdateLevel, int fVerbose );
extern Gia_Man_t * Gia_ManPerformDch( Gia_Man_t * p, void * pPars );
extern Gia_Man_t * Gia_ManAbstraction( Gia_Man_t * p, Vec_Int_t * vFlops );
......
......@@ -347,89 +347,6 @@ void Gia_ManEquivPrintClasses( Gia_Man_t * p, int fVerbose, float Mem )
/**Function*************************************************************
Synopsis [Reverse the order of nodes in equiv classes.]
Description [If the flag is 1, assumed current increasing order ]
SideEffects []
SeeAlso []
***********************************************************************/
void Gia_ManReverseClasses( Gia_Man_t * p, int fNowIncreasing )
{
Vec_Int_t * vCollected;
Vec_Int_t * vClass;
int i, k, iRepr, iNode, iPrev;
// collect classes
vCollected = Vec_IntAlloc( 100 );
Gia_ManForEachClass( p, iRepr )
{
Vec_IntPush( vCollected, iRepr );
/*
// check classes
if ( !fNowIncreasing )
{
iPrev = iRepr;
Gia_ClassForEachObj1( p, iRepr, iNode )
{
if ( iPrev < iNode )
{
printf( "Class %d : ", iRepr );
Gia_ClassForEachObj( p, iRepr, iNode )
printf( " %d", iNode );
printf( "\n" );
break;
}
iPrev = iNode;
}
}
*/
}
// correct each class
vClass = Vec_IntAlloc( 100 );
Vec_IntForEachEntry( vCollected, iRepr, i )
{
Vec_IntClear( vClass );
Vec_IntPush( vClass, iRepr );
Gia_ClassForEachObj1( p, iRepr, iNode )
{
if ( fNowIncreasing )
assert( iRepr < iNode );
// else
// assert( iRepr > iNode );
Vec_IntPush( vClass, iNode );
}
if ( !fNowIncreasing )
Vec_IntSort( vClass, 1 );
// if ( iRepr == 129720 || iRepr == 129737 )
// Vec_IntPrint( vClass );
// reverse the class
iPrev = 0;
iRepr = Vec_IntEntryLast( vClass );
Vec_IntForEachEntry( vClass, iNode, k )
{
if ( fNowIncreasing )
Gia_ObjSetReprRev( p, iNode, iNode == iRepr ? GIA_VOID : iRepr );
else
Gia_ObjSetRepr( p, iNode, iNode == iRepr ? GIA_VOID : iRepr );
Gia_ObjSetNext( p, iNode, iPrev );
iPrev = iNode;
}
}
Vec_IntFree( vCollected );
Vec_IntFree( vClass );
// verify
Gia_ManForEachClass( p, iRepr )
Gia_ClassForEachObj1( p, iRepr, iNode )
if ( fNowIncreasing )
assert( Gia_ObjRepr(p, iNode) == iRepr && iRepr > iNode );
else
assert( Gia_ObjRepr(p, iNode) == iRepr && iRepr < iNode );
}
/**Function*************************************************************
Synopsis [Returns representative node.]
Description []
......
......@@ -981,55 +981,6 @@ int Gia_ManHasChoices( Gia_Man_t * p )
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Gia_ManVerifyChoices( Gia_Man_t * p )
{
Gia_Obj_t * pObj;
int i, iRepr, iNode, fProb = 0;
assert( p->pReprs );
// mark nodes
Gia_ManCleanMark0(p);
Gia_ManForEachClass( p, iRepr )
Gia_ClassForEachObj1( p, iRepr, iNode )
{
if ( Gia_ObjIsHead(p, iNode) )
printf( "Member %d of choice class %d is a representative.\n", iNode, iRepr ), fProb = 1;
if ( Gia_ManObj( p, iNode )->fMark0 == 1 )
printf( "Node %d participates in more than one choice node.\n", iNode ), fProb = 1;
Gia_ManObj( p, iNode )->fMark0 = 1;
}
Gia_ManCleanMark0(p);
Gia_ManForEachObj( p, pObj, i )
{
if ( Gia_ObjIsAnd(pObj) )
{
if ( Gia_ObjHasRepr(p, Gia_ObjFaninId0(pObj, i)) )
printf( "Fanin 0 of AND node %d has a repr.\n", i ), fProb = 1;
if ( Gia_ObjHasRepr(p, Gia_ObjFaninId1(pObj, i)) )
printf( "Fanin 1 of AND node %d has a repr.\n", i ), fProb = 1;
}
else if ( Gia_ObjIsCo(pObj) )
{
if ( Gia_ObjHasRepr(p, Gia_ObjFaninId0(pObj, i)) )
printf( "Fanin 0 of CO node %d has a repr.\n", i ), fProb = 1;
}
}
if ( !fProb )
printf( "GIA with choices is correct.\n" );
}
/**Function*************************************************************
Synopsis [Returns 1 if AIG has dangling nodes.]
Description []
......
......@@ -5,6 +5,7 @@ SRC += src/aig/gia/gia.c \
src/aig/gia/giaCCof.c \
src/aig/gia/giaCex.c \
src/aig/gia/giaCexMin.c \
src/aig/gia/giaChoice.c \
src/aig/gia/giaCof.c \
src/aig/gia/giaCSatOld.c \
src/aig/gia/giaCSat.c \
......
......@@ -106,6 +106,12 @@ p->timeSimInit = clock() - clk;
// free memory ahead of time
p->timeTotal = clock() - clkTotal;
Dch_ManStop( p );
// try something different
{
// extern void Gia_ManNormalizeChoicesTest( Aig_Man_t * pAig );
// Gia_ManNormalizeChoicesTest( pAig );
}
// create choices
ABC_FREE( pAig->pTable );
pResult = Dch_DeriveChoiceAig( pAig, pPars->fSkipRedSupp );
......
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