mirror of https://github.com/YosysHQ/abc.git
Merge remote-tracking branch 'upstream/master' into yosys-experimental
This commit is contained in:
commit
d2d6bbd9f8
2
Makefile
2
Makefile
|
|
@ -27,7 +27,7 @@ MODULES := \
|
|||
src/opt/cut src/opt/fxu src/opt/fxch src/opt/rwr src/opt/mfs src/opt/sim \
|
||||
src/opt/ret src/opt/fret src/opt/res src/opt/lpk src/opt/nwk src/opt/rwt \
|
||||
src/opt/cgt src/opt/csw src/opt/dar src/opt/dau src/opt/dsc src/opt/sfm src/opt/sbd \
|
||||
src/sat/bsat src/sat/xsat src/sat/satoko src/sat/csat src/sat/msat src/sat/psat src/sat/cnf src/sat/bmc src/sat/glucose \
|
||||
src/sat/bsat src/sat/xsat src/sat/satoko src/sat/csat src/sat/msat src/sat/psat src/sat/cnf src/sat/bmc src/sat/glucose src/sat/glucose2 \
|
||||
src/bool/bdc src/bool/deco src/bool/dec src/bool/kit src/bool/lucky \
|
||||
src/bool/rsb src/bool/rpo \
|
||||
src/proof/pdr src/proof/abs src/proof/live src/proof/ssc src/proof/int \
|
||||
|
|
|
|||
180
abclib.dsp
180
abclib.dsp
|
|
@ -2366,6 +2366,122 @@ SOURCE=.\src\sat\glucose\Vec.h
|
|||
SOURCE=.\src\sat\glucose\XAlloc.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "glucose2"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\AbcGlucose2.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\AbcGlucose2.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\AbcGlucoseCmd2.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\Alg.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\Alloc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\BoundedQueue.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\CGlucose.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\CGlucoseCore.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\Constants.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\Dimacs.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\Glucose2.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\Heap.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\IntTypes.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\Map.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\Options.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\Options2.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\ParseUtils.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\pstdint.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\Queue.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\SimpSolver.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\SimpSolver2.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\Solver.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\SolverTypes.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\Sort.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\System.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\System2.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\Vec.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\sat\glucose2\XAlloc.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Group
|
||||
# Begin Group "opt"
|
||||
|
||||
|
|
@ -4787,6 +4903,10 @@ SOURCE=.\src\aig\gia\giaCSat2.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaCSat3.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaCSatOld.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
@ -4799,6 +4919,10 @@ SOURCE=.\src\aig\gia\giaCut.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaDecs.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaDeep.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
@ -4943,6 +5067,14 @@ SOURCE=.\src\aig\gia\giaMini.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaMinLut.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaMinLut2.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaMuxes.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
@ -4963,6 +5095,10 @@ SOURCE=.\src\aig\gia\giaPat.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaPat2.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaPf.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
@ -4971,10 +5107,26 @@ SOURCE=.\src\aig\gia\giaQbf.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaReshape1.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaReshape2.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaResub.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaResub2.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaResub3.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaRetime.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
@ -5039,14 +5191,6 @@ SOURCE=.\src\aig\gia\giaSim2.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaSim4.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaSim5.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaSimBase.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
@ -5067,6 +5211,10 @@ SOURCE=.\src\aig\gia\giaStg.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaStoch.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaStr.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
@ -5079,6 +5227,10 @@ SOURCE=.\src\aig\gia\giaSupp.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaSupps.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\aig\gia\giaSweep.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
@ -5411,14 +5563,26 @@ SOURCE=.\src\proof\cec\cecSatG.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\proof\cec\cecSatG2.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\proof\cec\cecSeq.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\proof\cec\cecSim.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\proof\cec\cecSolve.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\proof\cec\cecSolveG.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\src\proof\cec\cecSplit.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
***********************************************************************/
|
||||
|
||||
#include "gia.h"
|
||||
#include "misc/util/utilTruth.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
|
|
@ -297,6 +298,101 @@ void Gia_ManStructExperiment( Gia_Man_t * p )
|
|||
Vec_PtrFree( vGias );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Gia_EnumFirstUnused( int * pUsed, int nVars )
|
||||
{
|
||||
int i;
|
||||
for ( i = 0; i < nVars; i++ )
|
||||
if ( pUsed[i] == 0 )
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
void Gia_EnumPerms_rec( int * pUsed, int nVars, int * pPerm, int nPerm, int * pCount, FILE * pFile, int nLogVars )
|
||||
{
|
||||
int i, k, New;
|
||||
if ( nPerm == nVars )
|
||||
{
|
||||
if ( pFile )
|
||||
{
|
||||
for ( i = 0; i < nLogVars; i++ )
|
||||
fprintf( pFile, "%c", '0' + ((*pCount) >> (nLogVars-1-i) & 1) );
|
||||
fprintf( pFile, " " );
|
||||
for ( i = 0; i < nVars; i++ )
|
||||
for ( k = 0; k < nVars; k++ )
|
||||
fprintf( pFile, "%c", '0' + (pPerm[i] == k) );
|
||||
fprintf( pFile, "\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( *pCount < 20 )
|
||||
{
|
||||
printf( "%5d : ", (*pCount) );
|
||||
for ( i = 0; i < nVars; i += 2 )
|
||||
printf( "%d %d ", pPerm[i], pPerm[i+1] );
|
||||
printf( "\n" );
|
||||
}
|
||||
}
|
||||
(*pCount)++;
|
||||
return;
|
||||
}
|
||||
New = Gia_EnumFirstUnused( pUsed, nVars );
|
||||
assert( New >= 0 );
|
||||
pPerm[nPerm] = New;
|
||||
assert( pUsed[New] == 0 );
|
||||
pUsed[New] = 1;
|
||||
// try remaining ones
|
||||
for ( i = 0; i < nVars; i++ )
|
||||
{
|
||||
if ( pUsed[i] == 1 )
|
||||
continue;
|
||||
pPerm[nPerm+1] = i;
|
||||
assert( pUsed[i] == 0 );
|
||||
pUsed[i] = 1;
|
||||
Gia_EnumPerms_rec( pUsed, nVars, pPerm, nPerm+2, pCount, pFile, nLogVars );
|
||||
assert( pUsed[i] == 1 );
|
||||
pUsed[i] = 0;
|
||||
}
|
||||
assert( pUsed[New] == 1 );
|
||||
pUsed[New] = 0;
|
||||
}
|
||||
void Gia_EnumPerms( int nVars )
|
||||
{
|
||||
int nLogVars = 0, Count = 0;
|
||||
int * pUsed = ABC_CALLOC( int, nVars );
|
||||
int * pPerm = ABC_CALLOC( int, nVars );
|
||||
FILE * pFile = fopen( "pairset.pla", "wb" );
|
||||
assert( nVars % 2 == 0 );
|
||||
|
||||
printf( "Printing sets of pairs for %d objects:\n", nVars );
|
||||
Gia_EnumPerms_rec( pUsed, nVars, pPerm, 0, &Count, NULL, -1 );
|
||||
if ( Count > 20 )
|
||||
printf( "...\n" );
|
||||
printf( "Finished enumerating %d sets of pairs.\n", Count );
|
||||
|
||||
nLogVars = Abc_Base2Log( Count );
|
||||
printf( "Need %d variables to encode %d sets.\n", nLogVars, Count );
|
||||
Count = 0;
|
||||
fprintf( pFile, ".i %d\n", nLogVars );
|
||||
fprintf( pFile, ".o %d\n", nVars*nVars );
|
||||
Gia_EnumPerms_rec( pUsed, nVars, pPerm, 0, &Count, pFile, nLogVars );
|
||||
fprintf( pFile, ".e\n" );
|
||||
fclose( pFile );
|
||||
printf( "Finished dumping file \"%s\".\n", "pairset.pla" );
|
||||
|
||||
ABC_FREE( pUsed );
|
||||
ABC_FREE( pPerm );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -171,6 +171,7 @@ struct Gia_Man_t_
|
|||
Vec_Int_t * vCoReqs; // CO required times
|
||||
Vec_Int_t * vCoArrs; // CO arrival times
|
||||
Vec_Int_t * vCoAttrs; // CO attributes
|
||||
Vec_Int_t * vWeights; // object attributes
|
||||
int And2Delay; // delay of the AND gate
|
||||
float DefInArrs; // default PI arrival times
|
||||
float DefOutReqs; // default PO required times
|
||||
|
|
@ -179,6 +180,7 @@ struct Gia_Man_t_
|
|||
int nTravIdsAlloc; // the number of trav IDs allocated
|
||||
Vec_Ptr_t * vNamesIn; // the input names
|
||||
Vec_Ptr_t * vNamesOut; // the output names
|
||||
Vec_Ptr_t * vNamesNode; // the node names
|
||||
Vec_Int_t * vUserPiIds; // numbers assigned to PIs by the user
|
||||
Vec_Int_t * vUserPoIds; // numbers assigned to POs by the user
|
||||
Vec_Int_t * vUserFfIds; // numbers assigned to FFs by the user
|
||||
|
|
@ -214,6 +216,8 @@ struct Gia_Man_t_
|
|||
Vec_Wrd_t * vSimsPo;
|
||||
Vec_Int_t * vClassOld;
|
||||
Vec_Int_t * vClassNew;
|
||||
Vec_Int_t * vPats;
|
||||
Vec_Bit_t * vPolars;
|
||||
// incremental simulation
|
||||
int fIncrSim;
|
||||
int iNextPi;
|
||||
|
|
@ -235,6 +239,7 @@ struct Gia_Man_t_
|
|||
Vec_Wrd_t * vSuppWords; // support information
|
||||
Vec_Int_t vCopiesTwo; // intermediate copies
|
||||
Vec_Int_t vSuppVars; // used variables
|
||||
Vec_Int_t vVarMap; // used variables
|
||||
Gia_Dat_t * pUData;
|
||||
};
|
||||
|
||||
|
|
@ -339,6 +344,7 @@ struct Jf_Par_t_
|
|||
int fCutMin;
|
||||
int fFuncDsd;
|
||||
int fGenCnf;
|
||||
int fGenLit;
|
||||
int fCnfObjIds;
|
||||
int fAddOrCla;
|
||||
int fCnfMapping;
|
||||
|
|
@ -477,6 +483,11 @@ static inline int Gia_ObjValue( Gia_Obj_t * pObj ) {
|
|||
static inline void Gia_ObjSetValue( Gia_Obj_t * pObj, int i ) { pObj->Value = i; }
|
||||
static inline int Gia_ObjPhase( Gia_Obj_t * pObj ) { return pObj->fPhase; }
|
||||
static inline int Gia_ObjPhaseReal( Gia_Obj_t * pObj ) { return Gia_Regular(pObj)->fPhase ^ Gia_IsComplement(pObj); }
|
||||
static inline int Gia_ObjPhaseDiff( Gia_Man_t * p, int i, int k ) { return Gia_ManObj(p, i)->fPhase ^ Gia_ManObj(p, k)->fPhase; }
|
||||
static inline char * Gia_ObjCiName( Gia_Man_t * p, int i ) { return p->vNamesIn ? (char*)Vec_PtrEntry(p->vNamesIn, i) : NULL; }
|
||||
static inline char * Gia_ObjCoName( Gia_Man_t * p, int i ) { return p->vNamesOut ? (char*)Vec_PtrEntry(p->vNamesOut, i) : NULL; }
|
||||
static inline char * Gia_ObjName( Gia_Man_t * p, int i ) { return p->vNamesNode ? (char*)Vec_PtrEntry(p->vNamesNode, i) : NULL; }
|
||||
static inline char * Gia_ObjNameObj( Gia_Man_t * p, Gia_Obj_t * pObj ) { return p->vNamesNode ? (char*)Vec_PtrEntry(p->vNamesNode, Gia_ObjId(p, pObj)) : NULL; }
|
||||
|
||||
static inline int Gia_ObjIsTerm( Gia_Obj_t * pObj ) { return pObj->fTerm; }
|
||||
static inline int Gia_ObjIsAndOrConst0( Gia_Obj_t * pObj ) { return!pObj->fTerm; }
|
||||
|
|
@ -538,6 +549,7 @@ static inline void Gia_ObjFlipFaninC0( Gia_Obj_t * pObj ) {
|
|||
static inline int Gia_ObjFaninNum( Gia_Man_t * p, Gia_Obj_t * pObj ) { if ( Gia_ObjIsMux(p, pObj) ) return 3; if ( Gia_ObjIsAnd(pObj) ) return 2; if ( Gia_ObjIsCo(pObj) ) return 1; return 0; }
|
||||
static inline int Gia_ObjWhatFanin( Gia_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pFanin ) { if ( Gia_ObjFanin0(pObj) == pFanin ) return 0; if ( Gia_ObjFanin1(pObj) == pFanin ) return 1; if ( Gia_ObjFanin2(p, pObj) == pFanin ) return 2; assert(0); return -1; }
|
||||
|
||||
static inline int Gia_ManCoDriverId( Gia_Man_t * p, int iCoIndex ) { return Gia_ObjFaninId0p(p, Gia_ManCo(p, iCoIndex)); }
|
||||
static inline int Gia_ManPoIsConst( Gia_Man_t * p, int iPoIndex ) { return Gia_ObjFaninId0p(p, Gia_ManPo(p, iPoIndex)) == 0; }
|
||||
static inline int Gia_ManPoIsConst0( Gia_Man_t * p, int iPoIndex ) { return Gia_ManIsConst0Lit( Gia_ObjFaninLit0p(p, Gia_ManPo(p, iPoIndex)) ); }
|
||||
static inline int Gia_ManPoIsConst1( Gia_Man_t * p, int iPoIndex ) { return Gia_ManIsConst1Lit( Gia_ObjFaninLit0p(p, Gia_ManPo(p, iPoIndex)) ); }
|
||||
|
|
@ -570,6 +582,7 @@ static inline int Gia_ObjPhaseRealLit( Gia_Man_t * p, int iLit ) {
|
|||
|
||||
static inline int Gia_ObjLevelId( Gia_Man_t * p, int Id ) { return Vec_IntGetEntry(p->vLevels, Id); }
|
||||
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_ObjUpdateLevelId( Gia_Man_t * p, int Id, int l ) { Vec_IntSetEntry(p->vLevels, Id, Abc_MaxInt(Vec_IntEntry(p->vLevels, Id), l)); }
|
||||
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)) ); }
|
||||
|
|
@ -610,10 +623,14 @@ static inline void Gia_ObjSetTravIdCurrent( Gia_Man_t * p, Gia_Obj_t * p
|
|||
static inline void Gia_ObjSetTravIdPrevious( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjId(p, pObj) < p->nTravIdsAlloc ); p->pTravIds[Gia_ObjId(p, pObj)] = p->nTravIds - 1; }
|
||||
static inline int Gia_ObjIsTravIdCurrent( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjId(p, pObj) < p->nTravIdsAlloc ); return (p->pTravIds[Gia_ObjId(p, pObj)] == p->nTravIds); }
|
||||
static inline int Gia_ObjIsTravIdPrevious( Gia_Man_t * p, Gia_Obj_t * pObj ) { assert( Gia_ObjId(p, pObj) < p->nTravIdsAlloc ); return (p->pTravIds[Gia_ObjId(p, pObj)] == p->nTravIds - 1); }
|
||||
static inline int Gia_ObjUpdateTravIdCurrent( Gia_Man_t * p, Gia_Obj_t * pObj ) { if ( Gia_ObjIsTravIdCurrent(p, pObj) ) return 1; Gia_ObjSetTravIdCurrent(p, pObj); return 0; }
|
||||
static inline int Gia_ObjUpdateTravIdPrevious( Gia_Man_t * p, Gia_Obj_t * pObj ) { if ( Gia_ObjIsTravIdPrevious(p, pObj) ) return 1; Gia_ObjSetTravIdPrevious(p, pObj); return 0; }
|
||||
static inline void Gia_ObjSetTravIdCurrentId( Gia_Man_t * p, int Id ) { assert( Id < p->nTravIdsAlloc ); p->pTravIds[Id] = p->nTravIds; }
|
||||
static inline void Gia_ObjSetTravIdPreviousId( Gia_Man_t * p, int Id ) { assert( Id < p->nTravIdsAlloc ); p->pTravIds[Id] = p->nTravIds - 1; }
|
||||
static inline int Gia_ObjIsTravIdCurrentId( Gia_Man_t * p, int Id ) { assert( Id < p->nTravIdsAlloc ); return (p->pTravIds[Id] == p->nTravIds); }
|
||||
static inline int Gia_ObjIsTravIdPreviousId( Gia_Man_t * p, int Id ) { assert( Id < p->nTravIdsAlloc ); return (p->pTravIds[Id] == p->nTravIds - 1); }
|
||||
static inline int Gia_ObjUpdateTravIdCurrentId( Gia_Man_t * p, int Id ) { if ( Gia_ObjIsTravIdCurrentId(p, Id) ) return 1; Gia_ObjSetTravIdCurrentId(p, Id); return 0; }
|
||||
static inline int Gia_ObjUpdateTravIdPreviousId( Gia_Man_t * p, int Id ) { if ( Gia_ObjIsTravIdPreviousId(p, Id) ) return 1; Gia_ObjSetTravIdPreviousId(p, Id); return 0; }
|
||||
|
||||
static inline void Gia_ManTimeClean( Gia_Man_t * p ) { int i; assert( p->vTiming != NULL ); Vec_FltFill(p->vTiming, 3*Gia_ManObjNum(p), 0); for ( i = 0; i < Gia_ManObjNum(p); i++ ) Vec_FltWriteEntry( p->vTiming, 3*i+1, (float)(ABC_INFINITY) ); }
|
||||
static inline void Gia_ManTimeStart( Gia_Man_t * p ) { assert( p->vTiming == NULL ); p->vTiming = Vec_FltAlloc(0); Gia_ManTimeClean( p ); }
|
||||
|
|
@ -1067,9 +1084,11 @@ static inline void Gia_ClassUndoPair( Gia_Man_t * p, int i ) { a
|
|||
#define Gia_ManForEachClassReverse( p, i ) \
|
||||
for ( i = Gia_ManObjNum(p) - 1; i > 0; i-- ) if ( !Gia_ObjIsHead(p, i) ) {} else
|
||||
#define Gia_ClassForEachObj( p, i, iObj ) \
|
||||
for ( assert(Gia_ObjIsHead(p, i)), iObj = i; iObj > 0; iObj = Gia_ObjNext(p, iObj) )
|
||||
for ( assert(Gia_ObjIsHead(p, i) && i), iObj = i; iObj > 0; iObj = Gia_ObjNext(p, iObj) )
|
||||
#define Gia_ClassForEachObj1( p, i, iObj ) \
|
||||
for ( assert(Gia_ObjIsHead(p, i)), iObj = Gia_ObjNext(p, i); iObj > 0; iObj = Gia_ObjNext(p, iObj) )
|
||||
#define Gia_ClassForEachObjStart( p, i, iObj, Start ) \
|
||||
for ( assert(Gia_ObjIsHead(p, i)), iObj = Gia_ObjNext(p, Start); iObj > 0; iObj = Gia_ObjNext(p, iObj) )
|
||||
|
||||
|
||||
static inline int Gia_ObjFoffsetId( Gia_Man_t * p, int Id ) { return Vec_IntEntry( p->vFanout, Id ); }
|
||||
|
|
@ -1149,7 +1168,13 @@ static inline int Gia_ObjCellId( Gia_Man_t * p, int iLit ) { re
|
|||
for ( i = 1; (i < p->nObjs) && ((pObj) = Gia_ManObj(p, i)); i++ )
|
||||
#define Gia_ManForEachObjVec( vVec, p, pObj, i ) \
|
||||
for ( i = 0; (i < Vec_IntSize(vVec)) && ((pObj) = Gia_ManObj(p, Vec_IntEntry(vVec,i))); i++ )
|
||||
#define Gia_ManForEachObjVecReverse( vVec, p, pObj, i ) \
|
||||
#define Gia_ManForEachObjVecStart( vVec, p, pObj, i, Start ) \
|
||||
for ( i = Start; (i < Vec_IntSize(vVec)) && ((pObj) = Gia_ManObj(p, Vec_IntEntry(vVec,i))); i++ )
|
||||
#define Gia_ManForEachObjVecStop( vVec, p, pObj, i, Stop ) \
|
||||
for ( i = 0; (i < Stop) && ((pObj) = Gia_ManObj(p, Vec_IntEntry(vVec,i))); i++ )
|
||||
#define Gia_ManForEachObjVecStartStop( vVec, p, pObj, i, Start, Stop ) \
|
||||
for ( i = Start; (i < Stop) && ((pObj) = Gia_ManObj(p, Vec_IntEntry(vVec,i))); i++ )
|
||||
#define Gia_ManForEachObjVecReverse( vVec, p, pObj, i ) \
|
||||
for ( i = Vec_IntSize(vVec) - 1; (i >= 0) && ((pObj) = Gia_ManObj(p, Vec_IntEntry(vVec,i))); i-- )
|
||||
#define Gia_ManForEachObjVecLit( vVec, p, pObj, fCompl, i ) \
|
||||
for ( i = 0; (i < Vec_IntSize(vVec)) && ((pObj) = Gia_ManObj(p, Abc_Lit2Var(Vec_IntEntry(vVec,i)))) && (((fCompl) = Abc_LitIsCompl(Vec_IntEntry(vVec,i))),1); i++ )
|
||||
|
|
@ -1245,7 +1270,7 @@ extern Cbs_Man_t * Cbs_ManAlloc( Gia_Man_t * pGia );
|
|||
extern void Cbs_ManStop( Cbs_Man_t * p );
|
||||
extern int Cbs_ManSolve( Cbs_Man_t * p, Gia_Obj_t * pObj );
|
||||
extern int Cbs_ManSolve2( Cbs_Man_t * p, Gia_Obj_t * pObj, Gia_Obj_t * pObj2 );
|
||||
extern Vec_Int_t * Cbs_ManSolveMiterNc( Gia_Man_t * pGia, int nConfs, Vec_Str_t ** pvStatus, int fVerbose );
|
||||
extern Vec_Int_t * Cbs_ManSolveMiterNc( Gia_Man_t * pGia, int nConfs, Vec_Str_t ** pvStatus, int f0Proved, int fVerbose );
|
||||
extern void Cbs_ManSetConflictNum( Cbs_Man_t * p, int Num );
|
||||
extern Vec_Int_t * Cbs_ReadModel( Cbs_Man_t * p );
|
||||
/*=== giaCTas.c ============================================================*/
|
||||
|
|
@ -1255,6 +1280,11 @@ extern void Gia_ManPrintFanio( Gia_Man_t * pGia, int nNodes );
|
|||
extern Gia_Man_t * Gia_ManDupCof( Gia_Man_t * p, int iVar );
|
||||
extern Gia_Man_t * Gia_ManDupCofAllInt( Gia_Man_t * p, Vec_Int_t * vSigs, int fVerbose );
|
||||
extern Gia_Man_t * Gia_ManDupCofAll( Gia_Man_t * p, int nFanLim, int fVerbose );
|
||||
/*=== giaDecs.c ============================================================*/
|
||||
extern int Gia_ResubVarNum( Vec_Int_t * vResub );
|
||||
extern word Gia_ResubToTruth6( Vec_Int_t * vResub );
|
||||
extern int Gia_ManEvalSolutionOne( Gia_Man_t * p, Vec_Wrd_t * vSims, Vec_Wrd_t * vIsfs, Vec_Int_t * vCands, Vec_Int_t * vSet, int nWords, int fVerbose );
|
||||
extern Vec_Int_t * Gia_ManDeriveSolutionOne( Gia_Man_t * p, Vec_Wrd_t * vSims, Vec_Wrd_t * vIsfs, Vec_Int_t * vCands, Vec_Int_t * vSet, int nWords, int Type );
|
||||
/*=== giaDfs.c ============================================================*/
|
||||
extern void Gia_ManCollectCis( Gia_Man_t * p, int * pNodes, int nNodes, Vec_Int_t * vSupp );
|
||||
extern void Gia_ManCollectAnds_rec( Gia_Man_t * p, int iObj, Vec_Int_t * vNodes );
|
||||
|
|
@ -1264,6 +1294,7 @@ extern Vec_Int_t * Gia_ManCollectNodesCis( Gia_Man_t * p, int * pNodes,
|
|||
extern int Gia_ManSuppSize( Gia_Man_t * p, int * pNodes, int nNodes );
|
||||
extern int Gia_ManConeSize( Gia_Man_t * p, int * pNodes, int nNodes );
|
||||
extern Vec_Vec_t * Gia_ManLevelize( Gia_Man_t * p );
|
||||
extern Vec_Wec_t * Gia_ManLevelizeR( Gia_Man_t * p );
|
||||
extern Vec_Int_t * Gia_ManOrderReverse( Gia_Man_t * p );
|
||||
extern void Gia_ManCollectTfi( Gia_Man_t * p, Vec_Int_t * vRoots, Vec_Int_t * vNodes );
|
||||
extern void Gia_ManCollectTfo( Gia_Man_t * p, Vec_Int_t * vRoots, Vec_Int_t * vNodes );
|
||||
|
|
@ -1272,7 +1303,7 @@ extern void Gia_ManDupRemapLiterals( Vec_Int_t * vLits, Gia_Man_t
|
|||
extern void Gia_ManDupRemapEquiv( Gia_Man_t * pNew, Gia_Man_t * p );
|
||||
extern Gia_Man_t * Gia_ManDupOrderDfs( Gia_Man_t * p );
|
||||
extern Gia_Man_t * Gia_ManDupOrderDfsChoices( Gia_Man_t * p );
|
||||
extern Gia_Man_t * Gia_ManDupOrderDfsReverse( Gia_Man_t * p );
|
||||
extern Gia_Man_t * Gia_ManDupOrderDfsReverse( Gia_Man_t * p, int fRevFans, int fRevOuts );
|
||||
extern Gia_Man_t * Gia_ManDupOutputGroup( Gia_Man_t * p, int iOutStart, int iOutStop );
|
||||
extern Gia_Man_t * Gia_ManDupOutputVec( Gia_Man_t * p, Vec_Int_t * vOutPres );
|
||||
extern Gia_Man_t * Gia_ManDupSelectedOutputs( Gia_Man_t * p, Vec_Int_t * vOutsLeft );
|
||||
|
|
@ -1298,6 +1329,7 @@ extern Gia_Man_t * Gia_ManDupMarked( Gia_Man_t * p );
|
|||
extern Gia_Man_t * Gia_ManDupTimes( Gia_Man_t * p, int nTimes );
|
||||
extern Gia_Man_t * Gia_ManDupDfs( Gia_Man_t * p );
|
||||
extern Gia_Man_t * Gia_ManDupDfsOnePo( Gia_Man_t * p, int iPo );
|
||||
extern Gia_Man_t * Gia_ManDupDfsRehash( Gia_Man_t * p );
|
||||
extern Gia_Man_t * Gia_ManDupCofactorVar( Gia_Man_t * p, int iVar, int Value );
|
||||
extern Gia_Man_t * Gia_ManDupCofactorObj( Gia_Man_t * p, int iObj, int Value );
|
||||
extern Gia_Man_t * Gia_ManDupMux( int iVar, Gia_Man_t * pCof1, Gia_Man_t * pCof0 );
|
||||
|
|
@ -1397,6 +1429,7 @@ extern void Gia_ManFanoutStart( Gia_Man_t * p );
|
|||
extern void Gia_ManFanoutStop( Gia_Man_t * p );
|
||||
extern void Gia_ManStaticFanoutStart( Gia_Man_t * p );
|
||||
extern void Gia_ManStaticFanoutStop( Gia_Man_t * p );
|
||||
extern void Gia_ManStaticMappingFanoutStart( Gia_Man_t * p );
|
||||
/*=== giaForce.c =========================================================*/
|
||||
extern void For_ManExperiment( Gia_Man_t * pGia, int nIters, int fClustered, int fVerbose );
|
||||
/*=== giaFrames.c =========================================================*/
|
||||
|
|
@ -1480,7 +1513,7 @@ extern void Gia_ManPrintStatsMiter( Gia_Man_t * p, int fVerbose )
|
|||
extern void Gia_ManSetRegNum( Gia_Man_t * p, int nRegs );
|
||||
extern void Gia_ManReportImprovement( Gia_Man_t * p, Gia_Man_t * pNew );
|
||||
extern void Gia_ManPrintNpnClasses( Gia_Man_t * p );
|
||||
extern void Gia_ManDumpVerilog( Gia_Man_t * p, char * pFileName, Vec_Int_t * vObjs );
|
||||
extern void Gia_ManDumpVerilog( Gia_Man_t * p, char * pFileName, Vec_Int_t * vObjs, int fVerBufs );
|
||||
/*=== giaMem.c ===========================================================*/
|
||||
extern Gia_MmFixed_t * Gia_MmFixedStart( int nEntrySize, int nEntriesMax );
|
||||
extern void Gia_MmFixedStop( Gia_MmFixed_t * p, int fVerbose );
|
||||
|
|
@ -1504,7 +1537,7 @@ extern void Mf_ManSetDefaultPars( Jf_Par_t * pPars );
|
|||
extern Gia_Man_t * Mf_ManPerformMapping( Gia_Man_t * pGia, Jf_Par_t * pPars );
|
||||
extern void * Mf_ManGenerateCnf( Gia_Man_t * pGia, int nLutSize, int fCnfObjIds, int fAddOrCla, int fMapping, int fVerbose );
|
||||
/*=== giaMini.c ===========================================================*/
|
||||
extern Gia_Man_t * Gia_ManReadMiniAig( char * pFileName );
|
||||
extern Gia_Man_t * Gia_ManReadMiniAig( char * pFileName, int fGiaSimple );
|
||||
extern void Gia_ManWriteMiniAig( Gia_Man_t * pGia, char * pFileName );
|
||||
extern Gia_Man_t * Gia_ManReadMiniLut( char * pFileName );
|
||||
extern void Gia_ManWriteMiniLut( Gia_Man_t * pGia, char * pFileName );
|
||||
|
|
@ -1557,6 +1590,15 @@ extern void Gia_ManIncrSimStart( Gia_Man_t * p, int nWords, int n
|
|||
extern void Gia_ManIncrSimSet( Gia_Man_t * p, Vec_Int_t * vObjLits );
|
||||
extern int Gia_ManIncrSimCheckOver( Gia_Man_t * p, int iLit0, int iLit1 );
|
||||
extern int Gia_ManIncrSimCheckEqual( Gia_Man_t * p, int iLit0, int iLit1 );
|
||||
/*=== giaSimBase.c ============================================================*/
|
||||
extern Vec_Wrd_t * Gia_ManSimPatSim( Gia_Man_t * p );
|
||||
extern Vec_Wrd_t * Gia_ManSimPatSimOut( Gia_Man_t * pGia, Vec_Wrd_t * vSimsPi, int fOuts );
|
||||
extern void Gia_ManSim2ArrayOne( Vec_Wrd_t * vSimsPi, Vec_Int_t * vRes );
|
||||
extern Vec_Wec_t * Gia_ManSim2Array( Vec_Ptr_t * vSims );
|
||||
extern Vec_Wrd_t * Gia_ManArray2SimOne( Vec_Int_t * vRes );
|
||||
extern Vec_Ptr_t * Gia_ManArray2Sim( Vec_Wec_t * vRes );
|
||||
extern void Gia_ManPtrWrdDumpBin( char * pFileName, Vec_Ptr_t * p, int fVerbose );
|
||||
extern Vec_Ptr_t * Gia_ManPtrWrdReadBin( char * pFileName, int fVerbose );
|
||||
/*=== giaSpeedup.c ============================================================*/
|
||||
extern float Gia_ManDelayTraceLut( Gia_Man_t * p );
|
||||
extern float Gia_ManDelayTraceLutPrint( Gia_Man_t * p, int fVerbose );
|
||||
|
|
@ -1668,6 +1710,7 @@ extern void Gia_ManSetPhase1( Gia_Man_t * p );
|
|||
extern void Gia_ManCleanPhase( Gia_Man_t * p );
|
||||
extern int Gia_ManCheckCoPhase( Gia_Man_t * p );
|
||||
extern int Gia_ManLevelNum( Gia_Man_t * p );
|
||||
extern int Gia_ManLevelRNum( Gia_Man_t * p );
|
||||
extern Vec_Int_t * Gia_ManGetCiLevels( Gia_Man_t * p );
|
||||
extern int Gia_ManSetLevels( Gia_Man_t * p, Vec_Int_t * vCiLevels );
|
||||
extern Vec_Int_t * Gia_ManReverseLevel( Gia_Man_t * p );
|
||||
|
|
@ -1682,7 +1725,9 @@ 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_ObjRecognizeMuxLits( Gia_Man_t * p, Gia_Obj_t * pNode, int * iLitT, int * iLitE );
|
||||
extern int Gia_NodeMffcSize( Gia_Man_t * p, Gia_Obj_t * pNode );
|
||||
extern int Gia_NodeMffcSizeMark( Gia_Man_t * p, Gia_Obj_t * pNode );
|
||||
extern int Gia_NodeMffcSizeSupp( Gia_Man_t * p, Gia_Obj_t * pNode, Vec_Int_t * vSupp );
|
||||
extern int Gia_NodeMffcMapping( 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 );
|
||||
|
|
@ -1704,6 +1749,7 @@ extern int Gia_ManCheckSuppOverlap( Gia_Man_t * p, int iNode1, i
|
|||
extern int Gia_ManCountPisWithFanout( Gia_Man_t * p );
|
||||
extern int Gia_ManCountPosWithNonZeroDrivers( Gia_Man_t * p );
|
||||
extern void Gia_ManUpdateCopy( Vec_Int_t * vCopy, Gia_Man_t * p );
|
||||
extern Vec_Int_t * Gia_ManComputeDistance( Gia_Man_t * p, int iObj, Vec_Int_t * vObjs, int fVerbose );
|
||||
|
||||
/*=== giaCTas.c ===========================================================*/
|
||||
typedef struct Tas_Man_t_ Tas_Man_t;
|
||||
|
|
|
|||
|
|
@ -100,6 +100,41 @@ Gia_Man_t * Gia_ManFromAig( Aig_Man_t * p )
|
|||
return pNew;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Checks integrity of choice nodes.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_ManCheckChoices_rec( Gia_Man_t * p, Gia_Obj_t * pObj )
|
||||
{
|
||||
if ( !pObj || !Gia_ObjIsAnd(pObj) || pObj->fPhase )
|
||||
return;
|
||||
pObj->fPhase = 1;
|
||||
Gia_ManCheckChoices_rec( p, Gia_ObjFanin0(pObj) );
|
||||
Gia_ManCheckChoices_rec( p, Gia_ObjFanin1(pObj) );
|
||||
Gia_ManCheckChoices_rec( p, Gia_ObjSiblObj(p, Gia_ObjId(p, pObj)) );
|
||||
}
|
||||
void Gia_ManCheckChoices( Gia_Man_t * p )
|
||||
{
|
||||
Gia_Obj_t * pObj;
|
||||
int i, fFound = 0;
|
||||
Gia_ManCleanPhase( p );
|
||||
Gia_ManForEachCo( p, pObj, i )
|
||||
Gia_ManCheckChoices_rec( p, Gia_ObjFanin0(pObj) );
|
||||
Gia_ManForEachAnd( p, pObj, i )
|
||||
if ( !pObj->fPhase )
|
||||
printf( "Object %d is dangling.\n", i ), fFound = 1;
|
||||
if ( !fFound )
|
||||
printf( "There are no dangling objects.\n" );
|
||||
Gia_ManCleanPhase( p );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Duplicates AIG in the DFS order.]
|
||||
|
|
@ -155,6 +190,7 @@ Gia_Man_t * Gia_ManFromAigChoices( Aig_Man_t * p )
|
|||
Gia_ManAppendCo( pNew, Gia_ObjChild0Copy(pObj) );
|
||||
Gia_ManSetRegNum( pNew, Aig_ManRegNum(p) );
|
||||
//assert( Gia_ManObjNum(pNew) == Aig_ManObjNum(p) );
|
||||
//Gia_ManCheckChoices( pNew );
|
||||
return pNew;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -176,6 +176,7 @@ Vec_Str_t * Gia_AigerWriteLiterals( Vec_Int_t * vLits )
|
|||
Gia_Man_t * Gia_AigerReadFromMemory( char * pContents, int nFileSize, int fGiaSimple, int fSkipStrash, int fCheck )
|
||||
{
|
||||
Gia_Man_t * pNew, * pTemp;
|
||||
Vec_Ptr_t * vNamesIn = NULL, * vNamesOut = NULL, * vNamesRegIn = NULL, * vNamesRegOut = NULL, * vNamesNode = NULL;
|
||||
Vec_Int_t * vLits = NULL, * vPoTypes = NULL;
|
||||
Vec_Int_t * vNodes, * vDrivers, * vInits = NULL;
|
||||
int iObj, iNode0, iNode1, fHieOnly = 0;
|
||||
|
|
@ -377,6 +378,101 @@ Gia_Man_t * Gia_AigerReadFromMemory( char * pContents, int nFileSize, int fGiaSi
|
|||
pCur = pSymbols;
|
||||
if ( pCur < (unsigned char *)pContents + nFileSize && *pCur != 'c' )
|
||||
{
|
||||
int fReadNames = 1;
|
||||
if ( fReadNames )
|
||||
{
|
||||
int fError = 0;
|
||||
while ( !fError && pCur < (unsigned char *)pContents + nFileSize && *pCur != 'c' )
|
||||
{
|
||||
int iTerm;
|
||||
char * pType = (char *)pCur;
|
||||
char * pName = NULL;
|
||||
// check terminal type
|
||||
if ( *pCur != 'i' && *pCur != 'o' && *pCur != 'l' && *pCur != 'n' )
|
||||
{
|
||||
fError = 1;
|
||||
break;
|
||||
}
|
||||
// get terminal number
|
||||
iTerm = atoi( (char *)++pCur ); while ( *pCur++ != ' ' );
|
||||
// skip spaces
|
||||
while ( *pCur == ' ' )
|
||||
pCur++;
|
||||
// skip till the end of line
|
||||
for ( pName = (char *)pCur; *pCur && *pCur != '\n'; pCur++ );
|
||||
if ( *pCur == '\n' )
|
||||
*pCur = 0;
|
||||
// save the name
|
||||
if ( *pType == 'i' )
|
||||
{
|
||||
if ( vNamesIn == NULL )
|
||||
vNamesIn = Vec_PtrAlloc( nInputs + nLatches );
|
||||
if ( Vec_PtrSize(vNamesIn) != iTerm )
|
||||
{
|
||||
fError = 1;
|
||||
break;
|
||||
}
|
||||
Vec_PtrPush( vNamesIn, Abc_UtilStrsav(pName) );
|
||||
}
|
||||
else if ( *pType == 'o' )
|
||||
{
|
||||
if ( vNamesOut == NULL )
|
||||
vNamesOut = Vec_PtrAlloc( nOutputs + nLatches );
|
||||
if ( Vec_PtrSize(vNamesOut) != iTerm )
|
||||
{
|
||||
fError = 1;
|
||||
break;
|
||||
}
|
||||
Vec_PtrPush( vNamesOut, Abc_UtilStrsav(pName) );
|
||||
}
|
||||
else if ( *pType == 'l' )
|
||||
{
|
||||
char Buffer[1000];
|
||||
assert( strlen(pName) < 995 );
|
||||
sprintf( Buffer, "%s_in", pName );
|
||||
if ( vNamesRegIn == NULL )
|
||||
vNamesRegIn = Vec_PtrAlloc( nLatches );
|
||||
if ( vNamesRegOut == NULL )
|
||||
vNamesRegOut = Vec_PtrAlloc( nLatches );
|
||||
if ( Vec_PtrSize(vNamesRegIn) != iTerm )
|
||||
{
|
||||
fError = 1;
|
||||
break;
|
||||
}
|
||||
Vec_PtrPush( vNamesRegIn, Abc_UtilStrsav(Buffer) );
|
||||
Vec_PtrPush( vNamesRegOut, Abc_UtilStrsav(pName) );
|
||||
}
|
||||
else if ( *pType == 'n' )
|
||||
{
|
||||
if ( Vec_IntSize(&pNew->vHTable) != 0 )
|
||||
{
|
||||
printf( "Structural hashing should be disabled to read internal nodes names.\n" );
|
||||
fError = 1;
|
||||
break;
|
||||
}
|
||||
if ( vNamesNode == NULL )
|
||||
vNamesNode = Vec_PtrStart( Gia_ManObjNum(pNew) );
|
||||
Vec_PtrWriteEntry( vNamesNode, iTerm, Abc_UtilStrsav(pName) );
|
||||
}
|
||||
else
|
||||
{
|
||||
fError = 1;
|
||||
break;
|
||||
}
|
||||
pCur++;
|
||||
}
|
||||
if ( fError )
|
||||
{
|
||||
printf( "Error occurred when reading signal names. Signal names ignored.\n" );
|
||||
if ( vNamesIn ) Vec_PtrFreeFree( vNamesIn ), vNamesIn = NULL;
|
||||
if ( vNamesOut ) Vec_PtrFreeFree( vNamesOut ), vNamesOut = NULL;
|
||||
if ( vNamesRegIn ) Vec_PtrFreeFree( vNamesRegIn ), vNamesRegIn = NULL;
|
||||
if ( vNamesRegOut ) Vec_PtrFreeFree( vNamesRegOut ), vNamesRegOut = NULL;
|
||||
if ( vNamesNode ) Vec_PtrFreeFree( vNamesNode ), vNamesNode = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int fBreakUsed = 0;
|
||||
unsigned char * pCurOld = pCur;
|
||||
pNew->vUserPiIds = Vec_IntStartFull( nInputs );
|
||||
|
|
@ -505,6 +601,7 @@ Gia_Man_t * Gia_AigerReadFromMemory( char * pContents, int nFileSize, int fGiaSi
|
|||
}
|
||||
Vec_IntFree( vPoNames );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -636,6 +733,7 @@ Gia_Man_t * Gia_AigerReadFromMemory( char * pContents, int nFileSize, int fGiaSi
|
|||
pCur++;
|
||||
if ( (*pCur >= 'a' && *pCur <= 'z') || (*pCur >= 'A' && *pCur <= 'Z') || (*pCur >= '0' && *pCur <= '9') )
|
||||
{
|
||||
ABC_FREE( pNew->pName );
|
||||
pNew->pName = Abc_UtilStrsav( (char *)pCur ); pCur += strlen(pNew->pName) + 1;
|
||||
}
|
||||
else
|
||||
|
|
@ -866,6 +964,39 @@ Gia_Man_t * Gia_AigerReadFromMemory( char * pContents, int nFileSize, int fGiaSi
|
|||
Abc_Print( 0, "Structural hashing enabled while reading AIGER invalidated the mapping. Consider using \"&r -s\".\n" );
|
||||
Vec_IntFreeP( &pNew->vMapping );
|
||||
}
|
||||
if ( vNamesIn && Gia_ManPiNum(pNew) != Vec_PtrSize(vNamesIn) )
|
||||
Abc_Print( 0, "The number of inputs does not match the number of input names.\n" );
|
||||
else if ( vNamesOut && Gia_ManPoNum(pNew) != Vec_PtrSize(vNamesOut) )
|
||||
Abc_Print( 0, "The number of output does not match the number of output names.\n" );
|
||||
else if ( vNamesRegOut && Gia_ManRegNum(pNew) != Vec_PtrSize(vNamesRegOut) )
|
||||
Abc_Print( 0, "The number of inputs does not match the number of flop names.\n" );
|
||||
else if ( vNamesIn && vNamesOut )
|
||||
{
|
||||
pNew->vNamesIn = vNamesIn; vNamesIn = NULL;
|
||||
pNew->vNamesOut = vNamesOut; vNamesOut = NULL;
|
||||
if ( vNamesRegOut )
|
||||
{
|
||||
Vec_PtrAppend( pNew->vNamesIn, vNamesRegOut );
|
||||
Vec_PtrClear( vNamesRegOut );
|
||||
Vec_PtrFree( vNamesRegOut );
|
||||
vNamesRegOut = NULL;
|
||||
}
|
||||
if ( vNamesRegIn )
|
||||
{
|
||||
Vec_PtrAppend( pNew->vNamesOut, vNamesRegIn );
|
||||
Vec_PtrClear( vNamesRegIn );
|
||||
Vec_PtrFree( vNamesRegIn );
|
||||
vNamesRegIn = NULL;
|
||||
}
|
||||
}
|
||||
if ( vNamesNode && Gia_ManObjNum(pNew) != Vec_PtrSize(vNamesNode) )
|
||||
Abc_Print( 0, "The size of the node name array does not match the number of objects. Names are not entered.\n" );
|
||||
else if ( vNamesNode )
|
||||
pNew->vNamesNode = vNamesNode, vNamesNode = NULL;
|
||||
if ( vNamesIn ) Vec_PtrFreeFree( vNamesIn );
|
||||
if ( vNamesOut ) Vec_PtrFreeFree( vNamesOut );
|
||||
if ( vNamesRegIn ) Vec_PtrFreeFree( vNamesRegIn );
|
||||
if ( vNamesRegOut ) Vec_PtrFreeFree( vNamesRegOut );
|
||||
return pNew;
|
||||
}
|
||||
|
||||
|
|
@ -1197,6 +1328,14 @@ void Gia_AigerWrite( Gia_Man_t * pInit, char * pFileName, int fWriteSymbols, int
|
|||
Gia_ManForEachPo( p, pObj, i )
|
||||
fprintf( pFile, "o%d %s\n", i, (char *)Vec_PtrEntry(p->vNamesOut, i) );
|
||||
}
|
||||
if ( p->vNamesNode && Vec_PtrSize(p->vNamesNode) != Gia_ManObjNum(p) )
|
||||
Abc_Print( 0, "The size of the node name array does not match the number of objects. Names are not written.\n" );
|
||||
else if ( p->vNamesNode )
|
||||
{
|
||||
Gia_ManForEachAnd( p, pObj, i )
|
||||
if ( Vec_PtrEntry(p->vNamesNode, i) )
|
||||
fprintf( pFile, "n%d %s\n", i, (char *)Vec_PtrEntry(p->vNamesNode, i) );
|
||||
}
|
||||
|
||||
// write the comment
|
||||
if ( fWriteNewLine )
|
||||
|
|
@ -1477,6 +1616,148 @@ void Gia_AigerWriteSimple( Gia_Man_t * pInit, char * pFileName )
|
|||
fclose( pFile );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Simple AIGER reader/writer.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static inline unsigned Aiger_ReadUnsigned( FILE * pFile )
|
||||
{
|
||||
unsigned x = 0, i = 0;
|
||||
unsigned char ch;
|
||||
while ((ch = fgetc(pFile)) & 0x80)
|
||||
x |= (ch & 0x7f) << (7 * i++);
|
||||
return x | (ch << (7 * i));
|
||||
}
|
||||
static inline void Aiger_WriteUnsigned( FILE * pFile, unsigned x )
|
||||
{
|
||||
unsigned char ch;
|
||||
while (x & ~0x7f)
|
||||
{
|
||||
ch = (x & 0x7f) | 0x80;
|
||||
fputc( ch, pFile );
|
||||
x >>= 7;
|
||||
}
|
||||
ch = x;
|
||||
fputc( ch, pFile );
|
||||
}
|
||||
int * Aiger_Read( char * pFileName, int * pnObjs, int * pnIns, int * pnLats, int * pnOuts, int * pnAnds )
|
||||
{
|
||||
int i, Temp, Value = 0, nTotal, nObjs, nIns, nLats, nOuts, nAnds, * pObjs;
|
||||
FILE * pFile = fopen( pFileName, "rb" );
|
||||
if ( pFile == NULL )
|
||||
{
|
||||
fprintf( stdout, "Aiger_Read(): Cannot open the output file \"%s\".\n", pFileName );
|
||||
return NULL;
|
||||
}
|
||||
if ( fgetc(pFile) != 'a' || fgetc(pFile) != 'i' || fgetc(pFile) != 'g' )
|
||||
{
|
||||
fprintf( stdout, "Aiger_Read(): Can only read binary AIGER.\n" );
|
||||
fclose( pFile );
|
||||
return NULL;
|
||||
}
|
||||
if ( fscanf(pFile, "%d %d %d %d %d", &nTotal, &nIns, &nLats, &nOuts, &nAnds) != 5 )
|
||||
{
|
||||
fprintf( stdout, "Aiger_Read(): Cannot read the header line.\n" );
|
||||
fclose( pFile );
|
||||
return NULL;
|
||||
}
|
||||
if ( nTotal != nIns + nLats + nAnds )
|
||||
{
|
||||
fprintf( stdout, "The number of objects does not match.\n" );
|
||||
fclose( pFile );
|
||||
return NULL;
|
||||
}
|
||||
nObjs = 1 + nIns + 2*nLats + nOuts + nAnds;
|
||||
pObjs = ABC_CALLOC( int, nObjs * 2 );
|
||||
// read flop input literals
|
||||
for ( i = 0; i < nLats; i++ )
|
||||
{
|
||||
while ( fgetc(pFile) != '\n' );
|
||||
Value += fscanf( pFile, "%d", &Temp );
|
||||
pObjs[2*(nObjs-nLats+i)+0] = Temp;
|
||||
pObjs[2*(nObjs-nLats+i)+1] = Temp;
|
||||
}
|
||||
// read output literals
|
||||
for ( i = 0; i < nOuts; i++ )
|
||||
{
|
||||
while ( fgetc(pFile) != '\n' );
|
||||
Value += fscanf( pFile, "%d", &Temp );
|
||||
pObjs[2*(nObjs-nOuts-nLats+i)+0] = Temp;
|
||||
pObjs[2*(nObjs-nOuts-nLats+i)+1] = Temp;
|
||||
}
|
||||
assert( Value == nLats + nOuts );
|
||||
// read the binary part
|
||||
while ( fgetc(pFile) != '\n' );
|
||||
for ( i = 0; i < nAnds; i++ )
|
||||
{
|
||||
int uLit = 2*(1 + nIns + nLats + i);
|
||||
int uLit1 = uLit - Aiger_ReadUnsigned( pFile );
|
||||
int uLit0 = uLit1 - Aiger_ReadUnsigned( pFile );
|
||||
pObjs[2*(1+nIns+nLats+i)+0] = uLit0;
|
||||
pObjs[2*(1+nIns+nLats+i)+1] = uLit1;
|
||||
}
|
||||
fclose( pFile );
|
||||
if ( pnObjs ) *pnObjs = nObjs;
|
||||
if ( pnIns ) *pnIns = nIns;
|
||||
if ( pnLats ) *pnLats = nLats;
|
||||
if ( pnOuts ) *pnOuts = nOuts;
|
||||
if ( pnAnds ) *pnAnds = nAnds;
|
||||
return pObjs;
|
||||
}
|
||||
void Aiger_Write( char * pFileName, int * pObjs, int nObjs, int nIns, int nLats, int nOuts, int nAnds )
|
||||
{
|
||||
FILE * pFile = fopen( pFileName, "wb" ); int i;
|
||||
if ( pFile == NULL )
|
||||
{
|
||||
fprintf( stdout, "Aiger_Write(): Cannot open the output file \"%s\".\n", pFileName );
|
||||
return;
|
||||
}
|
||||
fprintf( pFile, "aig %d %d %d %d %d\n", nIns + nLats + nAnds, nIns, nLats, nOuts, nAnds );
|
||||
for ( i = 0; i < nLats; i++ )
|
||||
fprintf( pFile, "%d\n", pObjs[2*(nObjs-nLats+i)+0] );
|
||||
for ( i = 0; i < nOuts; i++ )
|
||||
fprintf( pFile, "%d\n", pObjs[2*(nObjs-nOuts-nLats+i)+0] );
|
||||
for ( i = 0; i < nAnds; i++ )
|
||||
{
|
||||
int uLit = 2*(1 + nIns + nLats + i);
|
||||
int uLit0 = pObjs[2*(1+nIns+nLats+i)+0];
|
||||
int uLit1 = pObjs[2*(1+nIns+nLats+i)+1];
|
||||
Aiger_WriteUnsigned( pFile, uLit - uLit1 );
|
||||
Aiger_WriteUnsigned( pFile, uLit1 - uLit0 );
|
||||
}
|
||||
fprintf( pFile, "c\n" );
|
||||
fclose( pFile );
|
||||
}
|
||||
void Aiger_Test( char * pFileNameIn, char * pFileNameOut )
|
||||
{
|
||||
int nObjs, nIns, nLats, nOuts, nAnds, * pObjs = Aiger_Read( pFileNameIn, &nObjs, &nIns, &nLats, &nOuts, &nAnds );
|
||||
if ( pObjs == NULL )
|
||||
return;
|
||||
printf( "Read input file \"%s\".\n", pFileNameIn );
|
||||
Aiger_Write( pFileNameOut, pObjs, nObjs, nIns, nLats, nOuts, nAnds );
|
||||
printf( "Written output file \"%s\".\n", pFileNameOut );
|
||||
ABC_FREE( pObjs );
|
||||
}
|
||||
|
||||
/*
|
||||
int main( int argc, char ** argv )
|
||||
{
|
||||
if ( argc != 3 )
|
||||
return 0;
|
||||
Aiger_Test( argv[1], argv[2] );
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -1034,7 +1034,7 @@ void Cbs_ManSatPrintStats( Cbs_Man_t * p )
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Vec_Int_t * Cbs_ManSolveMiterNc( Gia_Man_t * pAig, int nConfs, Vec_Str_t ** pvStatus, int fVerbose )
|
||||
Vec_Int_t * Cbs_ManSolveMiterNc( Gia_Man_t * pAig, int nConfs, Vec_Str_t ** pvStatus, int f0Proved, int fVerbose )
|
||||
{
|
||||
extern void Gia_ManCollectTest( Gia_Man_t * pAig );
|
||||
extern void Cec_ManSatAddToStore( Vec_Int_t * vCexStore, Vec_Int_t * vCex, int Out );
|
||||
|
|
@ -1105,6 +1105,8 @@ Vec_Int_t * Cbs_ManSolveMiterNc( Gia_Man_t * pAig, int nConfs, Vec_Str_t ** pvSt
|
|||
}
|
||||
if ( status == 1 )
|
||||
{
|
||||
if ( f0Proved )
|
||||
Gia_ManPatchCoDriver( pAig, i, 0 );
|
||||
p->nSatUnsat++;
|
||||
p->nConfUnsat += p->Pars.nBTThis;
|
||||
p->timeSatUnsat += Abc_Clock() - clk;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -602,10 +602,10 @@ void Gia_StoRefObj( Gia_Sto_t * p, int iObj )
|
|||
}
|
||||
void Gia_StoComputeCuts( Gia_Man_t * pGia )
|
||||
{
|
||||
int nCutSize = 6;
|
||||
int nCutNum = 25;
|
||||
int fCutMin = 1;
|
||||
int fTruthMin = 1;
|
||||
int nCutSize = 8;
|
||||
int nCutNum = 6;
|
||||
int fCutMin = 0;
|
||||
int fTruthMin = 0;
|
||||
int fVerbose = 1;
|
||||
Gia_Sto_t * p = Gia_StoAlloc( pGia, nCutSize, nCutNum, fCutMin, fTruthMin, fVerbose );
|
||||
Gia_Obj_t * pObj; int i, iObj;
|
||||
|
|
@ -637,6 +637,147 @@ void Gia_StoComputeCuts( Gia_Man_t * pGia )
|
|||
Gia_StoFree( p );
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Extract a given number of cuts.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Gia_StoSelectOneCut( Vec_Wec_t * vCuts, int iObj, Vec_Int_t * vCut, int nCutSizeMin )
|
||||
{
|
||||
Vec_Int_t * vThis = Vec_WecEntry( vCuts, iObj );
|
||||
int i, v, * pCut, * pList = Vec_IntArray( vThis );
|
||||
if ( pList == NULL )
|
||||
return 0;
|
||||
Vec_IntClear( vCut );
|
||||
Sdb_ForEachCut( pList, pCut, i )
|
||||
{
|
||||
if ( pCut[0] < nCutSizeMin )
|
||||
continue;
|
||||
for ( v = 0; v <= pCut[0]; v++ )
|
||||
Vec_IntPush( vCut, pCut[v] );
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Vec_Wec_t * Gia_ManSelectCuts( Vec_Wec_t * vCuts, int nCuts, int nCutSizeMin )
|
||||
{
|
||||
Vec_Wec_t * vCutsSel = Vec_WecStart( nCuts );
|
||||
int i; srand( time(NULL) );
|
||||
for ( i = 0; i < nCuts; i++ )
|
||||
while ( !Gia_StoSelectOneCut(vCuts, (rand() | (rand() << 15)) % Vec_WecSize(vCuts), Vec_WecEntry(vCutsSel, i), nCutSizeMin) );
|
||||
return vCutsSel;
|
||||
}
|
||||
Vec_Wec_t * Gia_ManExtractCuts( Gia_Man_t * pGia, int nCutSize0, int nCuts0, int fVerbose0 )
|
||||
{
|
||||
int nCutSize = nCutSize0;
|
||||
int nCutNum = 6;
|
||||
int fCutMin = 0;
|
||||
int fTruthMin = 0;
|
||||
int fVerbose = fVerbose0;
|
||||
Vec_Wec_t * vCutsSel;
|
||||
Gia_Sto_t * p = Gia_StoAlloc( pGia, nCutSize, nCutNum, fCutMin, fTruthMin, fVerbose );
|
||||
Gia_Obj_t * pObj; int i, iObj;
|
||||
assert( nCutSize <= GIA_MAX_CUTSIZE );
|
||||
assert( nCutNum < GIA_MAX_CUTNUM );
|
||||
// prepare references
|
||||
Gia_ManForEachObj( p->pGia, pObj, iObj )
|
||||
Gia_StoRefObj( p, iObj );
|
||||
// compute cuts
|
||||
Gia_StoComputeCutsConst0( p, 0 );
|
||||
Gia_ManForEachCiId( p->pGia, iObj, i )
|
||||
Gia_StoComputeCutsCi( p, iObj );
|
||||
Gia_ManForEachAnd( p->pGia, pObj, iObj )
|
||||
Gia_StoComputeCutsNode( p, iObj );
|
||||
if ( p->fVerbose )
|
||||
{
|
||||
printf( "Running cut computation with CutSize = %d CutNum = %d CutMin = %s TruthMin = %s\n",
|
||||
p->nCutSize, p->nCutNum, p->fCutMin ? "yes":"no", p->fTruthMin ? "yes":"no" );
|
||||
printf( "CutPair = %.0f ", p->CutCount[0] );
|
||||
printf( "Merge = %.0f (%.2f %%) ", p->CutCount[1], 100.0*p->CutCount[1]/p->CutCount[0] );
|
||||
printf( "Eval = %.0f (%.2f %%) ", p->CutCount[2], 100.0*p->CutCount[2]/p->CutCount[0] );
|
||||
printf( "Cut = %.0f (%.2f %%) ", p->CutCount[3], 100.0*p->CutCount[3]/p->CutCount[0] );
|
||||
printf( "Cut/Node = %.2f ", p->CutCount[3] / Gia_ManAndNum(p->pGia) );
|
||||
printf( "\n" );
|
||||
printf( "The number of nodes with cut count over the limit (%d cuts) = %d nodes (out of %d). ",
|
||||
p->nCutNum, p->nCutsOver, Gia_ManAndNum(pGia) );
|
||||
Abc_PrintTime( 0, "Time", Abc_Clock() - p->clkStart );
|
||||
}
|
||||
vCutsSel = Gia_ManSelectCuts( p->vCuts, nCuts0, nCutSize0-1 );
|
||||
Gia_StoFree( p );
|
||||
return vCutsSel;
|
||||
}
|
||||
void Gia_ManCreateWins( Gia_Man_t * pGia, Vec_Wec_t * vCuts )
|
||||
{
|
||||
Gia_Obj_t * pObj;
|
||||
Vec_Wec_t * vWins = Vec_WecStart( Gia_ManObjNum(pGia) );
|
||||
Vec_Int_t * vTemp = Vec_IntAlloc( 100 );
|
||||
Vec_Int_t * vCut; int i, k, Obj, Cut;
|
||||
Vec_WecForEachLevel( vCuts, vCut, i )
|
||||
Vec_IntForEachEntryStart( vCut, Obj, k, 1 )
|
||||
Vec_IntPush( Vec_WecEntry(vWins, Obj), i );
|
||||
Gia_ManForEachAnd( pGia, pObj, Obj )
|
||||
{
|
||||
Vec_Int_t * vWin = Vec_WecEntry(vWins, Obj);
|
||||
Vec_Int_t * vWin0 = Vec_WecEntry(vWins, Gia_ObjFaninId0(pObj, Obj));
|
||||
Vec_Int_t * vWin1 = Vec_WecEntry(vWins, Gia_ObjFaninId1(pObj, Obj));
|
||||
Vec_IntTwoFindCommon( vWin0, vWin1, vTemp );
|
||||
Vec_IntForEachEntry( vTemp, Cut, k )
|
||||
{
|
||||
Vec_IntPushUniqueOrder( vWin, Cut );
|
||||
Vec_IntPush( Vec_WecEntry(vCuts, Cut), Obj );
|
||||
}
|
||||
}
|
||||
Vec_WecFree( vWins );
|
||||
Vec_IntFree( vTemp );
|
||||
}
|
||||
void Gia_ManPrintWins( Vec_Wec_t * vCuts )
|
||||
{
|
||||
Vec_Int_t * vCut; int i, k, Obj;
|
||||
Vec_WecForEachLevel( vCuts, vCut, i )
|
||||
{
|
||||
int nInputs = Vec_IntEntry(vCut, 0);
|
||||
printf( "Cut %5d : ", i );
|
||||
printf( "Supp = %d ", nInputs );
|
||||
printf( "Nodes = %d ", Vec_IntSize(vCut) - 1 - nInputs );
|
||||
Vec_IntForEachEntryStartStop( vCut, Obj, k, 1, nInputs+1 )
|
||||
printf( "%d ", Obj );
|
||||
printf( " " );
|
||||
Vec_IntForEachEntryStart( vCut, Obj, k, nInputs+1 )
|
||||
printf( "%d ", Obj );
|
||||
printf( "\n" );
|
||||
}
|
||||
}
|
||||
void Gia_ManPrintWinStats( Vec_Wec_t * vCuts )
|
||||
{
|
||||
Vec_Int_t * vCut; int i, nInputs = 0, nNodes = 0;
|
||||
Vec_WecForEachLevel( vCuts, vCut, i )
|
||||
{
|
||||
nInputs += Vec_IntEntry(vCut, 0);
|
||||
nNodes += Vec_IntSize(vCut) - 1 - Vec_IntEntry(vCut, 0);
|
||||
}
|
||||
printf( "Computed %d windows with average support %.3f and average volume %.3f.\n",
|
||||
Vec_WecSize(vCuts), 1.0*nInputs/Vec_WecSize(vCuts), 1.0*nNodes/Vec_WecSize(vCuts) );
|
||||
}
|
||||
void Gia_ManExtractTest( Gia_Man_t * pGia )
|
||||
{
|
||||
extern Vec_Wec_t * Gia_ManExtractCuts2( Gia_Man_t * p, int nCutSize, int nCuts, int fVerbose );
|
||||
Vec_Wec_t * vCutsSel = Gia_ManExtractCuts2( pGia, 8, 10000, 1 );
|
||||
//Vec_Wec_t * vCutsSel = Gia_ManExtractCuts( pGia, 8, 10000, 1 );
|
||||
abctime clk = Abc_Clock();
|
||||
Gia_ManCreateWins( pGia, vCutsSel );
|
||||
//Gia_ManPrintWins( vCutsSel );
|
||||
Gia_ManPrintWinStats( vCutsSel );
|
||||
Vec_WecFree( vCutsSel );
|
||||
Abc_PrintTime( 0, "Creating windows", Abc_Clock() - clk );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -0,0 +1,350 @@
|
|||
/**CFile****************************************************************
|
||||
|
||||
FileName [giaDecs.c]
|
||||
|
||||
SystemName [ABC: Logic synthesis and verification system.]
|
||||
|
||||
PackageName [Scalable AIG package.]
|
||||
|
||||
Synopsis [Calling various decomposition engines.]
|
||||
|
||||
Author [Alan Mishchenko]
|
||||
|
||||
Affiliation [UC Berkeley]
|
||||
|
||||
Date [Ver. 1.0. Started - June 20, 2005.]
|
||||
|
||||
Revision [$Id: giaDecs.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
|
||||
|
||||
***********************************************************************/
|
||||
|
||||
#include "aig/gia/gia.h"
|
||||
#include "misc/util/utilTruth.h"
|
||||
#include "misc/extra/extra.h"
|
||||
#include "bool/bdc/bdc.h"
|
||||
#include "bool/kit/kit.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// DECLARATIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern void Extra_BitMatrixTransposeP( Vec_Wrd_t * vSimsIn, int nWordsIn, Vec_Wrd_t * vSimsOut, int nWordsOut );
|
||||
extern Vec_Int_t * Gia_ManResubOne( Vec_Ptr_t * vDivs, int nWords, int nLimit, int nDivsMax, int iChoice, int fUseXor, int fDebug, int fVerbose, word * pFunc, int Depth );
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// FUNCTION DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Gia_ResubVarNum( Vec_Int_t * vResub )
|
||||
{
|
||||
if ( Vec_IntSize(vResub) == 1 )
|
||||
return Vec_IntEntryLast(vResub) >= 2;
|
||||
return Vec_IntEntryLast(vResub)/2 - Vec_IntSize(vResub)/2 - 1;
|
||||
}
|
||||
word Gia_ResubToTruth6_rec( Vec_Int_t * vResub, int iNode, int nVars )
|
||||
{
|
||||
assert( iNode >= 0 && nVars <= 6 );
|
||||
if ( iNode < nVars )
|
||||
return s_Truths6[iNode];
|
||||
else
|
||||
{
|
||||
int iLit0 = Vec_IntEntry( vResub, Abc_Var2Lit(iNode-nVars, 0) );
|
||||
int iLit1 = Vec_IntEntry( vResub, Abc_Var2Lit(iNode-nVars, 1) );
|
||||
word Res0 = Gia_ResubToTruth6_rec( vResub, Abc_Lit2Var(iLit0)-2, nVars );
|
||||
word Res1 = Gia_ResubToTruth6_rec( vResub, Abc_Lit2Var(iLit1)-2, nVars );
|
||||
Res0 = Abc_LitIsCompl(iLit0) ? ~Res0 : Res0;
|
||||
Res1 = Abc_LitIsCompl(iLit1) ? ~Res1 : Res1;
|
||||
return iLit0 > iLit1 ? Res0 ^ Res1 : Res0 & Res1;
|
||||
}
|
||||
}
|
||||
word Gia_ResubToTruth6( Vec_Int_t * vResub )
|
||||
{
|
||||
word Res;
|
||||
int iRoot = Vec_IntEntryLast(vResub);
|
||||
if ( iRoot < 2 )
|
||||
return iRoot ? ~(word)0 : 0;
|
||||
assert( iRoot != 2 && iRoot != 3 );
|
||||
Res = Gia_ResubToTruth6_rec( vResub, Abc_Lit2Var(iRoot)-2, Gia_ResubVarNum(vResub) );
|
||||
return Abc_LitIsCompl(iRoot) ? ~Res : Res;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Vec_Wrd_t * Gia_ManDeriveTruths( Gia_Man_t * p, Vec_Wrd_t * vSims, Vec_Wrd_t * vIsfs, Vec_Int_t * vCands, Vec_Int_t * vSet, int nWords )
|
||||
{
|
||||
int nTtWords = Abc_Truth6WordNum(Vec_IntSize(vSet));
|
||||
int nFuncs = Vec_WrdSize(vIsfs) / 2 / nWords;
|
||||
Vec_Wrd_t * vRes = Vec_WrdStart( 2 * nFuncs * nTtWords );
|
||||
Vec_Wrd_t * vIn = Vec_WrdStart( 64*nWords ), * vOut;
|
||||
int i, f, m, iObj; word Func;
|
||||
assert( Vec_IntSize(vSet) <= 64 );
|
||||
Vec_IntForEachEntry( vSet, iObj, i )
|
||||
Abc_TtCopy( Vec_WrdEntryP(vIn, i*nWords), Vec_WrdEntryP(vSims, Vec_IntEntry(vCands, iObj)*nWords), nWords, 0 );
|
||||
vOut = Vec_WrdStart( Vec_WrdSize(vIn) );
|
||||
Extra_BitMatrixTransposeP( vIn, nWords, vOut, 1 );
|
||||
for ( f = 0; f < nFuncs; f++ )
|
||||
{
|
||||
word * pIsf[2] = { Vec_WrdEntryP(vIsfs, (2*f+0)*nWords),
|
||||
Vec_WrdEntryP(vIsfs, (2*f+1)*nWords) };
|
||||
word * pTruth[2] = { Vec_WrdEntryP(vRes, (2*f+0)*nTtWords),
|
||||
Vec_WrdEntryP(vRes, (2*f+1)*nTtWords) };
|
||||
for ( m = 0; m < 64*nWords; m++ )
|
||||
{
|
||||
int iMint = (int)Vec_WrdEntry(vOut, m);
|
||||
int Value0 = Abc_TtGetBit( pIsf[0], m );
|
||||
int Value1 = Abc_TtGetBit( pIsf[1], m );
|
||||
if ( !Value0 && !Value1 )
|
||||
continue;
|
||||
if ( Value0 && Value1 )
|
||||
printf( "Internal error: Onset and Offset overlap.\n" );
|
||||
assert( !Value0 || !Value1 );
|
||||
Abc_TtSetBit( pTruth[Value1], iMint );
|
||||
}
|
||||
if ( Abc_TtCountOnesVecMask(pTruth[0], pTruth[1], nTtWords, 0) )
|
||||
printf( "Verification for function %d failed for %d minterm pairs.\n", f,
|
||||
Abc_TtCountOnesVecMask(pTruth[0], pTruth[1], nTtWords, 0) );
|
||||
}
|
||||
if ( Vec_IntSize(vSet) < 6 )
|
||||
Vec_WrdForEachEntry( vRes, Func, i )
|
||||
Vec_WrdWriteEntry( vRes, i, Abc_Tt6Stretch(Func, Vec_IntSize(vSet)) );
|
||||
Vec_WrdFree( vIn );
|
||||
Vec_WrdFree( vOut );
|
||||
return vRes;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Gia_ManCountResub( Vec_Wrd_t * vTruths, int nVars, int fVerbose )
|
||||
{
|
||||
Vec_Int_t * vResub; int nNodes;
|
||||
int nTtWords = Abc_Truth6WordNum(nVars);
|
||||
int v, nFuncs = Vec_WrdSize(vTruths) / 2 / nTtWords;
|
||||
Vec_Wrd_t * vElems = Vec_WrdStartTruthTables( nVars );
|
||||
Vec_Ptr_t * vDivs = Vec_PtrAlloc( 2 + nVars );
|
||||
assert( Vec_WrdSize(vElems) == nTtWords * nVars );
|
||||
assert( nFuncs == 1 );
|
||||
Vec_PtrPush( vDivs, Vec_WrdEntryP(vTruths, (2*0+0)*nTtWords) );
|
||||
Vec_PtrPush( vDivs, Vec_WrdEntryP(vTruths, (2*0+1)*nTtWords) );
|
||||
for ( v = 0; v < nVars; v++ )
|
||||
Vec_PtrPush( vDivs, Vec_WrdEntryP(vElems, v*nTtWords) );
|
||||
vResub = Gia_ManResubOne( vDivs, nTtWords, 30, 100, 0, 0, 0, fVerbose, NULL, 0 );
|
||||
Vec_PtrFree( vDivs );
|
||||
Vec_WrdFree( vElems );
|
||||
nNodes = Vec_IntSize(vResub) ? Vec_IntSize(vResub)/2 : 999;
|
||||
Vec_IntFree( vResub );
|
||||
return nNodes;
|
||||
}
|
||||
Vec_Int_t * Gia_ManDeriveResub( Vec_Wrd_t * vTruths, int nVars )
|
||||
{
|
||||
Vec_Int_t * vResub;
|
||||
int nTtWords = Abc_Truth6WordNum(nVars);
|
||||
int v, nFuncs = Vec_WrdSize(vTruths) / 2 / nTtWords;
|
||||
Vec_Wrd_t * vElems = Vec_WrdStartTruthTables( nVars );
|
||||
Vec_Ptr_t * vDivs = Vec_PtrAlloc( 2 + nVars );
|
||||
assert( Vec_WrdSize(vElems) == nTtWords * nVars );
|
||||
assert( nFuncs == 1 );
|
||||
Vec_PtrPush( vDivs, Vec_WrdEntryP(vTruths, (2*0+0)*nTtWords) );
|
||||
Vec_PtrPush( vDivs, Vec_WrdEntryP(vTruths, (2*0+1)*nTtWords) );
|
||||
for ( v = 0; v < nVars; v++ )
|
||||
Vec_PtrPush( vDivs, Vec_WrdEntryP(vElems, v*nTtWords) );
|
||||
vResub = Gia_ManResubOne( vDivs, nTtWords, 30, 100, 0, 0, 0, 0, NULL, 0 );
|
||||
Vec_PtrFree( vDivs );
|
||||
Vec_WrdFree( vElems );
|
||||
return vResub;
|
||||
}
|
||||
|
||||
int Gia_ManCountBidec( Vec_Wrd_t * vTruths, int nVars, int fVerbose )
|
||||
{
|
||||
int nNodes, nTtWords = Abc_Truth6WordNum(nVars);
|
||||
word * pTruth[2] = { Vec_WrdEntryP(vTruths, 0*nTtWords),
|
||||
Vec_WrdEntryP(vTruths, 1*nTtWords) };
|
||||
Abc_TtOr( pTruth[0], pTruth[0], pTruth[1], nTtWords );
|
||||
nNodes = Bdc_ManBidecNodeNum( pTruth[1], pTruth[0], nVars, fVerbose );
|
||||
Abc_TtSharp( pTruth[0], pTruth[0], pTruth[1], nTtWords );
|
||||
return nNodes;
|
||||
}
|
||||
Vec_Int_t * Gia_ManDeriveBidec( Vec_Wrd_t * vTruths, int nVars )
|
||||
{
|
||||
Vec_Int_t * vRes = NULL;
|
||||
int nTtWords = Abc_Truth6WordNum(nVars);
|
||||
word * pTruth[2] = { Vec_WrdEntryP(vTruths, 0*nTtWords),
|
||||
Vec_WrdEntryP(vTruths, 1*nTtWords) };
|
||||
Abc_TtOr( pTruth[0], pTruth[0], pTruth[1], nTtWords );
|
||||
vRes = Bdc_ManBidecResub( pTruth[1], pTruth[0], nVars );
|
||||
Abc_TtSharp( pTruth[0], pTruth[0], pTruth[1], nTtWords );
|
||||
return vRes;
|
||||
}
|
||||
|
||||
int Gia_ManCountIsop( Vec_Wrd_t * vTruths, int nVars, int fVerbose )
|
||||
{
|
||||
int nTtWords = Abc_Truth6WordNum(nVars);
|
||||
word * pTruth[2] = { Vec_WrdEntryP(vTruths, 0*nTtWords),
|
||||
Vec_WrdEntryP(vTruths, 1*nTtWords) };
|
||||
int nNodes = Kit_IsopNodeNum( (unsigned *)pTruth[0], (unsigned *)pTruth[1], nVars, NULL );
|
||||
return nNodes;
|
||||
}
|
||||
Vec_Int_t * Gia_ManDeriveIsop( Vec_Wrd_t * vTruths, int nVars )
|
||||
{
|
||||
Vec_Int_t * vRes = NULL;
|
||||
int nTtWords = Abc_Truth6WordNum(nVars);
|
||||
word * pTruth[2] = { Vec_WrdEntryP(vTruths, 0*nTtWords),
|
||||
Vec_WrdEntryP(vTruths, 1*nTtWords) };
|
||||
vRes = Kit_IsopResub( (unsigned *)pTruth[0], (unsigned *)pTruth[1], nVars, NULL );
|
||||
return vRes;
|
||||
}
|
||||
|
||||
int Gia_ManCountBdd( Vec_Wrd_t * vTruths, int nVars, int fVerbose )
|
||||
{
|
||||
extern Gia_Man_t * Gia_TryPermOptNew( word * pTruths, int nIns, int nOuts, int nWords, int nRounds, int fVerbose );
|
||||
int nTtWords = Abc_Truth6WordNum(nVars);
|
||||
word * pTruth[2] = { Vec_WrdEntryP(vTruths, 0*nTtWords),
|
||||
Vec_WrdEntryP(vTruths, 1*nTtWords) };
|
||||
Gia_Man_t * pGia; int nNodes;
|
||||
|
||||
Abc_TtOr( pTruth[1], pTruth[1], pTruth[0], nTtWords );
|
||||
Abc_TtNot( pTruth[0], nTtWords );
|
||||
pGia = Gia_TryPermOptNew( pTruth[0], nVars, 1, nTtWords, 50, 0 );
|
||||
Abc_TtNot( pTruth[0], nTtWords );
|
||||
Abc_TtSharp( pTruth[1], pTruth[1], pTruth[0], nTtWords );
|
||||
|
||||
nNodes = Gia_ManAndNum(pGia);
|
||||
Gia_ManStop( pGia );
|
||||
return nNodes;
|
||||
}
|
||||
Vec_Int_t * Gia_ManDeriveBdd( Vec_Wrd_t * vTruths, int nVars )
|
||||
{
|
||||
extern Vec_Int_t * Gia_ManToGates( Gia_Man_t * p );
|
||||
Vec_Int_t * vRes = NULL;
|
||||
extern Gia_Man_t * Gia_TryPermOptNew( word * pTruths, int nIns, int nOuts, int nWords, int nRounds, int fVerbose );
|
||||
int nTtWords = Abc_Truth6WordNum(nVars);
|
||||
word * pTruth[2] = { Vec_WrdEntryP(vTruths, 0*nTtWords),
|
||||
Vec_WrdEntryP(vTruths, 1*nTtWords) };
|
||||
Gia_Man_t * pGia;
|
||||
|
||||
Abc_TtOr( pTruth[1], pTruth[1], pTruth[0], nTtWords );
|
||||
Abc_TtNot( pTruth[0], nTtWords );
|
||||
pGia = Gia_TryPermOptNew( pTruth[0], nVars, 1, nTtWords, 50, 0 );
|
||||
Abc_TtNot( pTruth[0], nTtWords );
|
||||
Abc_TtSharp( pTruth[1], pTruth[1], pTruth[0], nTtWords );
|
||||
|
||||
vRes = Gia_ManToGates( pGia );
|
||||
Gia_ManStop( pGia );
|
||||
return vRes;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Gia_ManEvalSolutionOne( Gia_Man_t * p, Vec_Wrd_t * vSims, Vec_Wrd_t * vIsfs, Vec_Int_t * vCands, Vec_Int_t * vSet, int nWords, int fVerbose )
|
||||
{
|
||||
Vec_Wrd_t * vTruths = Gia_ManDeriveTruths( p, vSims, vIsfs, vCands, vSet, nWords );
|
||||
int nTtWords = Vec_WrdSize(vTruths)/2, nVars = Vec_IntSize(vSet);
|
||||
word * pTruth[2] = { Vec_WrdEntryP(vTruths, 0*nTtWords),
|
||||
Vec_WrdEntryP(vTruths, 1*nTtWords) };
|
||||
int nNodesResub = Gia_ManCountResub( vTruths, nVars, 0 );
|
||||
int nNodesBidec = nVars > 2 ? Gia_ManCountBidec( vTruths, nVars, 0 ) : 999;
|
||||
int nNodesIsop = nVars > 2 ? Gia_ManCountIsop( vTruths, nVars, 0 ) : 999;
|
||||
int nNodesBdd = nVars > 2 ? Gia_ManCountBdd( vTruths, nVars, 0 ) : 999;
|
||||
int nNodesMin = Abc_MinInt( Abc_MinInt(nNodesResub, nNodesBidec), Abc_MinInt(nNodesIsop, nNodesBdd) );
|
||||
if ( fVerbose )
|
||||
{
|
||||
printf( "Size = %2d ", nVars );
|
||||
printf( "Resub =%3d ", nNodesResub );
|
||||
printf( "Bidec =%3d ", nNodesBidec );
|
||||
printf( "Isop =%3d ", nNodesIsop );
|
||||
printf( "Bdd =%3d ", nNodesBdd );
|
||||
Abc_TtIsfPrint( pTruth[0], pTruth[1], nTtWords );
|
||||
if ( nVars <= 6 )
|
||||
{
|
||||
printf( " " );
|
||||
Extra_PrintHex( stdout, (unsigned*)pTruth[0], nVars );
|
||||
printf( " " );
|
||||
Extra_PrintHex( stdout, (unsigned*)pTruth[1], nVars );
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
Vec_WrdFree( vTruths );
|
||||
if ( nNodesMin > 500 )
|
||||
return -1;
|
||||
if ( nNodesMin == nNodesResub )
|
||||
return (nNodesMin << 2) | 0;
|
||||
if ( nNodesMin == nNodesBidec )
|
||||
return (nNodesMin << 2) | 1;
|
||||
if ( nNodesMin == nNodesIsop )
|
||||
return (nNodesMin << 2) | 2;
|
||||
if ( nNodesMin == nNodesBdd )
|
||||
return (nNodesMin << 2) | 3;
|
||||
return -1;
|
||||
}
|
||||
Vec_Int_t * Gia_ManDeriveSolutionOne( Gia_Man_t * p, Vec_Wrd_t * vSims, Vec_Wrd_t * vIsfs, Vec_Int_t * vCands, Vec_Int_t * vSet, int nWords, int Type )
|
||||
{
|
||||
Vec_Int_t * vRes = NULL;
|
||||
Vec_Wrd_t * vTruths = Gia_ManDeriveTruths( p, vSims, vIsfs, vCands, vSet, nWords );
|
||||
int nTtWords = Vec_WrdSize(vTruths)/2, nVars = Vec_IntSize(vSet);
|
||||
word * pTruth[2] = { Vec_WrdEntryP(vTruths, 0*nTtWords),
|
||||
Vec_WrdEntryP(vTruths, 1*nTtWords) };
|
||||
if ( Type == 0 )
|
||||
vRes = Gia_ManDeriveResub( vTruths, nVars );
|
||||
else if ( Type == 1 )
|
||||
vRes = Gia_ManDeriveBidec( vTruths, nVars );
|
||||
else if ( Type == 2 )
|
||||
vRes = Gia_ManDeriveIsop( vTruths, nVars );
|
||||
else if ( Type == 3 )
|
||||
vRes = Gia_ManDeriveBdd( vTruths, nVars );
|
||||
if ( vRes && Gia_ResubVarNum(vRes) <= 6 )
|
||||
{
|
||||
word Func = Gia_ResubToTruth6( vRes );
|
||||
assert( !(Func & pTruth[0][0]) );
|
||||
assert( !(pTruth[1][0] & ~Func) );
|
||||
}
|
||||
Vec_WrdFree( vTruths );
|
||||
return vRes;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
||||
|
|
@ -19,14 +19,14 @@
|
|||
***********************************************************************/
|
||||
|
||||
#include "gia.h"
|
||||
#include "base/main/main.h"
|
||||
#include "base/cmd/cmd.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// DECLARATIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// FUNCTION DEFINITIONS ///
|
||||
|
|
@ -43,9 +43,121 @@ ABC_NAMESPACE_IMPL_START
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Gia_Man_t * Gia_ManDeepSyn( Gia_Man_t * pGia, int TimeOut, int nAnds, int Seed, int fVerbose )
|
||||
Gia_Man_t * Gia_ManDeepSynOne( int nNoImpr, int TimeOut, int nAnds, int Seed, int fUseTwo, int fVerbose )
|
||||
{
|
||||
return NULL;
|
||||
abctime nTimeToStop = TimeOut ? Abc_Clock() + TimeOut * CLOCKS_PER_SEC : 0;
|
||||
abctime clkStart = Abc_Clock();
|
||||
int s, i, IterMax = 100000, nAndsMin = -1, iIterLast = -1;
|
||||
Gia_Man_t * pTemp = Abc_FrameReadGia(Abc_FrameGetGlobalFrame());
|
||||
Gia_Man_t * pNew = Gia_ManDup( pTemp );
|
||||
Abc_Random(1);
|
||||
for ( s = 0; s < 10+Seed; s++ )
|
||||
Abc_Random(0);
|
||||
for ( i = 0; i < IterMax; i++ )
|
||||
{
|
||||
unsigned Rand = Abc_Random(0);
|
||||
int fDch = Rand & 1;
|
||||
//int fCom = (Rand >> 1) & 3;
|
||||
int fCom = (Rand >> 1) & 1;
|
||||
int fFx = (Rand >> 2) & 1;
|
||||
int KLut = fUseTwo ? 2 + (i % 5) : 3 + (i % 4);
|
||||
int fChange = 0;
|
||||
char Command[1000];
|
||||
char * pComp = NULL;
|
||||
if ( fCom == 3 )
|
||||
pComp = "; &put; compress2rs; compress2rs; compress2rs; &get";
|
||||
else if ( fCom == 2 )
|
||||
pComp = "; &put; compress2rs; compress2rs; &get";
|
||||
else if ( fCom == 1 )
|
||||
pComp = "; &put; compress2rs; &get";
|
||||
else if ( fCom == 0 )
|
||||
pComp = "; &dc2";
|
||||
sprintf( Command, "&dch%s; &if -a -K %d; &mfs -e -W 20 -L 20%s%s",
|
||||
fDch ? " -f" : "", KLut, fFx ? "; &fx; &st" : "", pComp );
|
||||
if ( Abc_FrameIsBatchMode() )
|
||||
{
|
||||
if ( Cmd_CommandExecute(Abc_FrameGetGlobalFrame(), Command) )
|
||||
{
|
||||
Abc_Print( 1, "Something did not work out with the command \"%s\".\n", Command );
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Abc_FrameSetBatchMode( 1 );
|
||||
if ( Cmd_CommandExecute(Abc_FrameGetGlobalFrame(), Command) )
|
||||
{
|
||||
Abc_Print( 1, "Something did not work out with the command \"%s\".\n", Command );
|
||||
return NULL;
|
||||
}
|
||||
Abc_FrameSetBatchMode( 0 );
|
||||
}
|
||||
pTemp = Abc_FrameReadGia(Abc_FrameGetGlobalFrame());
|
||||
if ( Gia_ManAndNum(pNew) > Gia_ManAndNum(pTemp) )
|
||||
{
|
||||
Gia_ManStop( pNew );
|
||||
pNew = Gia_ManDup( pTemp );
|
||||
fChange = 1;
|
||||
iIterLast = i;
|
||||
}
|
||||
else if ( Gia_ManAndNum(pNew) + Gia_ManAndNum(pNew)/10 < Gia_ManAndNum(pTemp) )
|
||||
{
|
||||
//printf( "Updating\n" );
|
||||
//Abc_FrameUpdateGia( Abc_FrameGetGlobalFrame(), Gia_ManDup(pNew) );
|
||||
}
|
||||
if ( fChange && fVerbose )
|
||||
{
|
||||
printf( "Iter %6d : ", i );
|
||||
printf( "Time %8.2f sec : ", (float)1.0*(Abc_Clock() - clkStart)/CLOCKS_PER_SEC );
|
||||
printf( "And = %6d ", Gia_ManAndNum(pNew) );
|
||||
printf( "Lev = %3d ", Gia_ManLevelNum(pNew) );
|
||||
if ( fChange )
|
||||
printf( "<== best : " );
|
||||
else if ( fVerbose )
|
||||
printf( " " );
|
||||
printf( "%s", Command );
|
||||
printf( "\n" );
|
||||
}
|
||||
if ( nTimeToStop && Abc_Clock() > nTimeToStop )
|
||||
{
|
||||
printf( "Runtime limit (%d sec) is reached after %d iterations.\n", TimeOut, i );
|
||||
break;
|
||||
}
|
||||
if ( i - iIterLast > nNoImpr )
|
||||
{
|
||||
printf( "Completed %d iterations without improvement in %.2f seconds.\n",
|
||||
nNoImpr, (float)1.0*(Abc_Clock() - clkStart)/CLOCKS_PER_SEC );
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( i == IterMax )
|
||||
printf( "Iteration limit (%d iters) is reached after %.2f seconds.\n", IterMax, (float)1.0*(Abc_Clock() - clkStart)/CLOCKS_PER_SEC );
|
||||
else if ( nAnds && nAndsMin <= nAnds )
|
||||
printf( "Quality goal (%d nodes <= %d nodes) is achieved after %d iterations and %.2f seconds.\n",
|
||||
nAndsMin, nAnds, i, (float)1.0*(Abc_Clock() - clkStart)/CLOCKS_PER_SEC );
|
||||
return pNew;
|
||||
}
|
||||
Gia_Man_t * Gia_ManDeepSyn( Gia_Man_t * pGia, int nIters, int nNoImpr, int TimeOut, int nAnds, int Seed, int fUseTwo, int fVerbose )
|
||||
{
|
||||
Gia_Man_t * pInit = Gia_ManDup(pGia);
|
||||
Gia_Man_t * pBest = Gia_ManDup(pGia);
|
||||
Gia_Man_t * pThis;
|
||||
int i;
|
||||
for ( i = 0; i < nIters; i++ )
|
||||
{
|
||||
Abc_FrameUpdateGia( Abc_FrameGetGlobalFrame(), Gia_ManDup(pInit) );
|
||||
pThis = Gia_ManDeepSynOne( nNoImpr, TimeOut, nAnds, Seed+i, fUseTwo, fVerbose );
|
||||
if ( Gia_ManAndNum(pBest) > Gia_ManAndNum(pThis) )
|
||||
{
|
||||
Gia_ManStop( pBest );
|
||||
pBest = pThis;
|
||||
}
|
||||
else
|
||||
Gia_ManStop( pThis );
|
||||
|
||||
}
|
||||
Gia_ManStop( pInit );
|
||||
return pBest;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -416,6 +416,34 @@ Vec_Vec_t * Gia_ManLevelize( Gia_Man_t * p )
|
|||
return vLevels;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Levelizes the nodes.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Vec_Wec_t * Gia_ManLevelizeR( Gia_Man_t * p )
|
||||
{
|
||||
Gia_Obj_t * pObj;
|
||||
Vec_Wec_t * vLevels;
|
||||
int nLevels, Level, i;
|
||||
nLevels = Gia_ManLevelRNum( p );
|
||||
vLevels = Vec_WecStart( nLevels + 1 );
|
||||
Gia_ManForEachObj( p, pObj, i )
|
||||
{
|
||||
if ( i == 0 || (!Gia_ObjIsCo(pObj) && !Gia_ObjLevel(p, pObj)) )
|
||||
continue;
|
||||
Level = Gia_ObjLevel( p, pObj );
|
||||
assert( Level <= nLevels );
|
||||
Vec_WecPush( vLevels, Level, i );
|
||||
}
|
||||
return vLevels;
|
||||
}
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Computes reverse topological order.]
|
||||
|
|
|
|||
|
|
@ -466,7 +466,16 @@ Gia_Man_t * Gia_ManDupOrderDfsChoices( Gia_Man_t * p )
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Gia_Man_t * Gia_ManDupOrderDfsReverse( Gia_Man_t * p )
|
||||
int Gia_ManDupOrderDfs2_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pObj )
|
||||
{
|
||||
if ( ~pObj->Value )
|
||||
return pObj->Value;
|
||||
assert( Gia_ObjIsAnd(pObj) );
|
||||
Gia_ManDupOrderDfs2_rec( pNew, p, Gia_ObjFanin1(pObj) );
|
||||
Gia_ManDupOrderDfs2_rec( pNew, p, Gia_ObjFanin0(pObj) );
|
||||
return pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
|
||||
}
|
||||
Gia_Man_t * Gia_ManDupOrderDfsReverse( Gia_Man_t * p, int fRevFans, int fRevOuts )
|
||||
{
|
||||
Gia_Man_t * pNew;
|
||||
Gia_Obj_t * pObj;
|
||||
|
|
@ -476,12 +485,28 @@ Gia_Man_t * Gia_ManDupOrderDfsReverse( Gia_Man_t * p )
|
|||
pNew->pName = Abc_UtilStrsav( p->pName );
|
||||
pNew->pSpec = Abc_UtilStrsav( p->pSpec );
|
||||
Gia_ManConst0(p)->Value = 0;
|
||||
Gia_ManForEachCoReverse( p, pObj, i )
|
||||
Gia_ManDupOrderDfs_rec( pNew, p, pObj );
|
||||
Gia_ManForEachCi( p, pObj, i )
|
||||
if ( !~pObj->Value )
|
||||
pObj->Value = Gia_ManAppendCi(pNew);
|
||||
assert( Gia_ManCiNum(pNew) == Gia_ManCiNum(p) );
|
||||
pObj->Value = Gia_ManAppendCi(pNew);
|
||||
if ( fRevOuts )
|
||||
{
|
||||
if ( fRevFans )
|
||||
Gia_ManForEachCoReverse( p, pObj, i )
|
||||
Gia_ManDupOrderDfs2_rec( pNew, p, Gia_ObjFanin0(pObj) );
|
||||
else
|
||||
Gia_ManForEachCoReverse( p, pObj, i )
|
||||
Gia_ManDupOrderDfs_rec( pNew, p, Gia_ObjFanin0(pObj) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( fRevFans )
|
||||
Gia_ManForEachCo( p, pObj, i )
|
||||
Gia_ManDupOrderDfs2_rec( pNew, p, Gia_ObjFanin0(pObj) );
|
||||
else
|
||||
Gia_ManForEachCo( p, pObj, i )
|
||||
Gia_ManDupOrderDfs_rec( pNew, p, Gia_ObjFanin0(pObj) );
|
||||
}
|
||||
Gia_ManForEachCo( p, pObj, i )
|
||||
pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
|
||||
Gia_ManDupRemapCis( pNew, p );
|
||||
Gia_ManDupRemapCos( pNew, p );
|
||||
Gia_ManDupRemapEquiv( pNew, p );
|
||||
|
|
@ -1327,7 +1352,7 @@ Gia_Man_t * Gia_ManDupMarked( Gia_Man_t * p )
|
|||
{
|
||||
Gia_Obj_t * pRepr;
|
||||
pNew->pReprs = ABC_CALLOC( Gia_Rpr_t, Gia_ManObjNum(pNew) );
|
||||
for ( i = 0; i < Gia_ManObjNum(p); i++ )
|
||||
for ( i = 0; i < Gia_ManObjNum(pNew); i++ )
|
||||
Gia_ObjSetRepr( pNew, i, GIA_VOID );
|
||||
Gia_ManForEachObj1( p, pObj, i )
|
||||
{
|
||||
|
|
@ -1583,6 +1608,52 @@ Gia_Man_t * Gia_ManDupDfsOnePo( Gia_Man_t * p, int iPo )
|
|||
return pNew;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Duplicates the AIG in the DFS order.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_ManDupDfsRehash_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pObj )
|
||||
{
|
||||
if ( ~pObj->Value )
|
||||
return;
|
||||
assert( Gia_ObjIsAnd(pObj) );
|
||||
Gia_ManDupDfsRehash_rec( pNew, p, Gia_ObjFanin0(pObj) );
|
||||
Gia_ManDupDfsRehash_rec( pNew, p, Gia_ObjFanin1(pObj) );
|
||||
pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
|
||||
}
|
||||
Gia_Man_t * Gia_ManDupDfsRehash( Gia_Man_t * p )
|
||||
{
|
||||
Gia_Man_t * pNew, * pTemp;
|
||||
Gia_Obj_t * pObj;
|
||||
int i;
|
||||
pNew = Gia_ManStart( Gia_ManObjNum(p) );
|
||||
pNew->pName = Abc_UtilStrsav( p->pName );
|
||||
pNew->pSpec = Abc_UtilStrsav( p->pSpec );
|
||||
Gia_ManFillValue( p );
|
||||
Gia_ManConst0(p)->Value = 0;
|
||||
Gia_ManForEachCi( p, pObj, i )
|
||||
pObj->Value = Gia_ManAppendCi(pNew);
|
||||
Gia_ManHashAlloc( pNew );
|
||||
Gia_ManForEachCo( p, pObj, i )
|
||||
Gia_ManDupDfsRehash_rec( pNew, p, Gia_ObjFanin0(pObj) );
|
||||
Gia_ManForEachCo( p, pObj, i )
|
||||
pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
|
||||
pNew = Gia_ManCleanup( pTemp = pNew );
|
||||
Gia_ManStop( pTemp );
|
||||
Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
|
||||
pNew->nConstrs = p->nConstrs;
|
||||
if ( p->pCexSeq )
|
||||
pNew->pCexSeq = Abc_CexDup( p->pCexSeq, Gia_ManRegNum(p) );
|
||||
return pNew;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Cofactors w.r.t. a primary input variable.]
|
||||
|
|
@ -2295,6 +2366,31 @@ Gia_Man_t * Gia_ManDupTrimmed2( Gia_Man_t * p )
|
|||
assert( !Gia_ManHasDangling( pNew ) );
|
||||
return pNew;
|
||||
}
|
||||
Gia_Man_t * Gia_ManDupTrimmed3( Gia_Man_t * p )
|
||||
{
|
||||
Vec_Int_t * vMap = Vec_IntStartFull( Gia_ManObjNum(p) );
|
||||
Gia_Man_t * pNew;
|
||||
Gia_Obj_t * pObj;
|
||||
int i;
|
||||
pNew = Gia_ManStart( Gia_ManObjNum(p) );
|
||||
pNew->pName = Abc_UtilStrsav( p->pName );
|
||||
pNew->pSpec = Abc_UtilStrsav( p->pSpec );
|
||||
Gia_ManFillValue( p );
|
||||
Gia_ManConst0(p)->Value = 0;
|
||||
Gia_ManForEachCi( p, pObj, i )
|
||||
pObj->Value = Gia_ManAppendCi(pNew);
|
||||
Gia_ManForEachAnd( p, pObj, i )
|
||||
pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
|
||||
// mark duplicated POs
|
||||
Gia_ManForEachPo( p, pObj, i )
|
||||
Vec_IntWriteEntry( vMap, Gia_ObjFaninId0p(p, pObj), i );
|
||||
Gia_ManForEachPo( p, pObj, i )
|
||||
if ( Vec_IntEntry(vMap, Gia_ObjFaninId0p(p, pObj)) == i )
|
||||
Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
|
||||
Vec_IntFree( vMap );
|
||||
Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
|
||||
return pNew;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
|
|
@ -2914,6 +3010,44 @@ Vec_Ptr_t * Gia_ManMiterNames( Vec_Ptr_t * p, int nOuts )
|
|||
return pNew;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Pair-wise miter.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Gia_Man_t * Gia_ManPairWiseMiter( Gia_Man_t * p )
|
||||
{
|
||||
Gia_Man_t * pNew, * pTemp;
|
||||
Gia_Obj_t * pObj, * pObj2;
|
||||
int i, k, iLit;
|
||||
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_ManForEachAnd( p, pObj, i )
|
||||
pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
|
||||
Gia_ManForEachPo( p, pObj, i )
|
||||
Gia_ManForEachPo( p, pObj2, k )
|
||||
{
|
||||
if ( i >= k )
|
||||
continue;
|
||||
iLit = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin0Copy(pObj2) );
|
||||
Gia_ManAppendCo( pNew, iLit );
|
||||
}
|
||||
pNew = Gia_ManCleanup( pTemp = pNew );
|
||||
Gia_ManStop( pTemp );
|
||||
return pNew;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Transforms the circuit into a regular miter.]
|
||||
|
|
@ -3448,7 +3582,7 @@ Gia_Man_t * Gia_ManDupCones( Gia_Man_t * p, int * pPos, int nPos, int fTrimPis )
|
|||
Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) );
|
||||
Vec_PtrForEachEntry( Gia_Obj_t *, vRoots, pObj, i )
|
||||
Gia_ManDupCones_rec( p, pObj, vLeaves, vNodes, vRoots );
|
||||
Vec_PtrSort( vLeaves, (int (*)(void))Gia_ObjCompareByCioId );
|
||||
Vec_PtrSort( vLeaves, (int (*)(const void *, const void *))Gia_ObjCompareByCioId );
|
||||
|
||||
// start the new manager
|
||||
// Gia_ManFillValue( p );
|
||||
|
|
@ -3460,6 +3594,8 @@ Gia_Man_t * Gia_ManDupCones( Gia_Man_t * p, int * pPos, int nPos, int fTrimPis )
|
|||
// create PIs
|
||||
if ( fTrimPis )
|
||||
{
|
||||
Gia_ManForEachPi( p, pObj, i )
|
||||
pObj->Value = ~0;
|
||||
Vec_PtrForEachEntry( Gia_Obj_t *, vLeaves, pObj, i )
|
||||
pObj->Value = Gia_ManAppendCi( pNew );
|
||||
}
|
||||
|
|
@ -3508,7 +3644,7 @@ Gia_Man_t * Gia_ManDupAndCones( Gia_Man_t * p, int * pAnds, int nAnds, int fTrim
|
|||
Gia_ObjSetTravIdCurrent( p, Gia_ManConst0(p) );
|
||||
Vec_PtrForEachEntry( Gia_Obj_t *, vRoots, pObj, i )
|
||||
Gia_ManDupCones_rec( p, pObj, vLeaves, vNodes, vRoots );
|
||||
Vec_PtrSort( vLeaves, (int (*)(void))Gia_ObjCompareByCioId );
|
||||
Vec_PtrSort( vLeaves, (int (*)(const void *, const void *))Gia_ObjCompareByCioId );
|
||||
|
||||
// start the new manager
|
||||
// Gia_ManFillValue( p );
|
||||
|
|
@ -4245,7 +4381,7 @@ Gia_Man_t * Gia_ManDupDemiter( Gia_Man_t * p, int fVerbose )
|
|||
vSuperPtr = Vec_PtrAlloc( Vec_IntSize(vSuper) );
|
||||
Vec_IntForEachEntry( vSuper, iLit, i )
|
||||
Vec_PtrPush( vSuperPtr, Gia_Lit2Obj(p, iLit) );
|
||||
Vec_PtrSort( vSuperPtr, (int (*)(void))Gia_ManSortByValue );
|
||||
Vec_PtrSort( vSuperPtr, (int (*)(const void *, const void *))Gia_ManSortByValue );
|
||||
// create new manager
|
||||
pNew = Gia_ManStart( Gia_ManObjNum(p) );
|
||||
pNew->pName = Abc_UtilStrsav( p->pName );
|
||||
|
|
@ -4899,6 +5035,38 @@ Gia_Man_t * Gia_ManDupReplaceCut( Gia_Man_t * p )
|
|||
return pNew;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Duplicate AIG by creating a cut between logic fed by PIs]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Gia_Man_t * Gia_ManDupAddPis( Gia_Man_t * p, int nMulti )
|
||||
{
|
||||
Gia_Man_t * pNew; int i, k;
|
||||
Gia_Obj_t * pObj;
|
||||
pNew = Gia_ManStart( Gia_ManObjNum(p) + Gia_ManCiNum(p) * nMulti );
|
||||
pNew->pName = Abc_UtilStrsav( p->pName );
|
||||
Gia_ManConst0(p)->Value = 0;
|
||||
Gia_ManForEachCi( p, pObj, i )
|
||||
{
|
||||
pObj->Value = Gia_ManAppendCi(pNew);
|
||||
for ( k = 1; k < nMulti; k++ )
|
||||
Gia_ManAppendCi(pNew);
|
||||
}
|
||||
Gia_ManForEachAnd( p, pObj, i )
|
||||
pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
|
||||
Gia_ManForEachCo( p, pObj, i )
|
||||
pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
|
||||
assert( Gia_ManCiNum(pNew) == nMulti * Gia_ManCiNum(p) );
|
||||
return pNew;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ ABC_NAMESPACE_IMPL_START
|
|||
http://www.emis.de/journals/JGAA/accepted/2004/HarelKoren2004.8.2.pdf
|
||||
|
||||
Iterative refinement is described in the paper: F. A. Aloul, I. L. Markov, and K. A. Sakallah.
|
||||
"FORCE: A Fast and Easy-To-Implement Variable-Ordering Heuristic", Proc. GLSVLSI’03.
|
||||
"FORCE: A Fast and Easy-To-Implement Variable-Ordering Heuristic", Proc. GLSVLSI 03.
|
||||
http://www.eecs.umich.edu/~imarkov/pubs/conf/glsvlsi03-force.pdf
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -269,6 +269,7 @@ int * Gia_ManDeriveNexts( Gia_Man_t * p )
|
|||
pTails[i] = i;
|
||||
for ( i = 0; i < Gia_ManObjNum(p); i++ )
|
||||
{
|
||||
//if ( p->pReprs[i].iRepr == GIA_VOID )
|
||||
if ( !p->pReprs[i].iRepr || p->pReprs[i].iRepr == GIA_VOID )
|
||||
continue;
|
||||
pNexts[ pTails[p->pReprs[i].iRepr] ] = i;
|
||||
|
|
@ -480,8 +481,10 @@ void Gia_ManEquivPrintClasses( Gia_Man_t * p, int fVerbose, float Mem )
|
|||
}
|
||||
CounterX -= Gia_ManCoNum(p);
|
||||
nLits = Gia_ManCiNum(p) + Gia_ManAndNum(p) - Counter - CounterX;
|
||||
Abc_Print( 1, "cst =%8d cls =%7d lit =%8d unused =%8d proof =%6d mem =%5.2f MB\n",
|
||||
Counter0, Counter, nLits, CounterX, Proved, (Mem == 0.0) ? 8.0*Gia_ManObjNum(p)/(1<<20) : Mem );
|
||||
// Abc_Print( 1, "cst =%8d cls =%7d lit =%8d unused =%8d proof =%6d mem =%5.2f MB\n",
|
||||
// Counter0, Counter, nLits, CounterX, Proved, (Mem == 0.0) ? 8.0*Gia_ManObjNum(p)/(1<<20) : Mem );
|
||||
Abc_Print( 1, "cst =%8d cls =%7d lit =%8d unused =%8d proof =%6d\n",
|
||||
Counter0, Counter, nLits, CounterX, Proved );
|
||||
assert( Gia_ManEquivCheckLits( p, nLits ) );
|
||||
if ( fVerbose )
|
||||
{
|
||||
|
|
@ -1985,7 +1988,7 @@ Gia_Man_t * Gia_ManEquivToChoices( Gia_Man_t * p, int nSnapshots )
|
|||
pNew->pReprs = ABC_CALLOC( Gia_Rpr_t, Gia_ManObjNum(p) );
|
||||
pNew->pNexts = ABC_CALLOC( int, Gia_ManObjNum(p) );
|
||||
for ( i = 0; i < Gia_ManObjNum(p); i++ )
|
||||
Gia_ObjSetRepr( pNew, i, GIA_VOID );
|
||||
pNew->pReprs[i].iRepr = GIA_VOID;
|
||||
Gia_ManFillValue( p );
|
||||
Gia_ManConst0(p)->Value = 0;
|
||||
Gia_ManForEachCi( p, pObj, i )
|
||||
|
|
@ -2587,6 +2590,294 @@ void Gia_ManFilterEquivsUsingLatches( Gia_Man_t * pGia, int fFlopsOnly, int fFlo
|
|||
Abc_Print( 1, "The number of literals: Before = %d. After = %d.\n", iLitsOld, iLitsNew );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Changing node order.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Gia_ManChangeOrder_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pObj )
|
||||
{
|
||||
if ( ~pObj->Value )
|
||||
return pObj->Value;
|
||||
if ( Gia_ObjIsCi(pObj) )
|
||||
return pObj->Value = Gia_ManAppendCi(pNew);
|
||||
Gia_ManChangeOrder_rec( pNew, p, Gia_ObjFanin0(pObj) );
|
||||
if ( Gia_ObjIsCo(pObj) )
|
||||
return pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
|
||||
Gia_ManChangeOrder_rec( pNew, p, Gia_ObjFanin1(pObj) );
|
||||
return pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
|
||||
}
|
||||
Gia_Man_t * Gia_ManChangeOrder( Gia_Man_t * p )
|
||||
{
|
||||
Gia_Man_t * pNew;
|
||||
Gia_Obj_t * pObj;
|
||||
int i, k;
|
||||
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_ManForEachCi( p, pObj, i )
|
||||
pObj->Value = Gia_ManAppendCi(pNew);
|
||||
Gia_ManForEachClass( p, i )
|
||||
Gia_ClassForEachObj( p, i, k )
|
||||
Gia_ManChangeOrder_rec( pNew, p, Gia_ManObj(p, k) );
|
||||
Gia_ManForEachConst( p, k )
|
||||
Gia_ManChangeOrder_rec( pNew, p, Gia_ManObj(p, k) );
|
||||
Gia_ManForEachCo( p, pObj, i )
|
||||
Gia_ManChangeOrder_rec( pNew, p, Gia_ObjFanin0(pObj) );
|
||||
Gia_ManForEachCo( p, pObj, i )
|
||||
pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
|
||||
Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
|
||||
assert( Gia_ManObjNum(pNew) == Gia_ManObjNum(p) );
|
||||
return pNew;
|
||||
}
|
||||
void Gia_ManTransferEquivs( Gia_Man_t * p, Gia_Man_t * pNew )
|
||||
{
|
||||
Vec_Int_t * vClass;
|
||||
int i, k, iNode, iRepr;
|
||||
assert( Gia_ManObjNum(p) == Gia_ManObjNum(pNew) );
|
||||
assert( p->pReprs != NULL );
|
||||
assert( p->pNexts != NULL );
|
||||
assert( pNew->pReprs == NULL );
|
||||
assert( pNew->pNexts == NULL );
|
||||
// start representatives
|
||||
pNew->pReprs = ABC_CALLOC( Gia_Rpr_t, Gia_ManObjNum(pNew) );
|
||||
for ( i = 0; i < Gia_ManObjNum(pNew); i++ )
|
||||
Gia_ObjSetRepr( pNew, i, GIA_VOID );
|
||||
// iterate over constant candidates
|
||||
Gia_ManForEachConst( p, i )
|
||||
Gia_ObjSetRepr( pNew, Abc_Lit2Var(Gia_ManObj(p, i)->Value), 0 );
|
||||
// iterate over class candidates
|
||||
vClass = Vec_IntAlloc( 100 );
|
||||
Gia_ManForEachClass( p, i )
|
||||
{
|
||||
Vec_IntClear( vClass );
|
||||
Gia_ClassForEachObj( p, i, k )
|
||||
Vec_IntPushUnique( vClass, Abc_Lit2Var(Gia_ManObj(p, k)->Value) );
|
||||
assert( Vec_IntSize( vClass ) > 1 );
|
||||
Vec_IntSort( vClass, 0 );
|
||||
iRepr = Vec_IntEntry( vClass, 0 );
|
||||
Vec_IntForEachEntryStart( vClass, iNode, k, 1 )
|
||||
Gia_ObjSetRepr( pNew, iNode, iRepr );
|
||||
}
|
||||
Vec_IntFree( vClass );
|
||||
pNew->pNexts = Gia_ManDeriveNexts( pNew );
|
||||
}
|
||||
void Gia_ManTransferTest( Gia_Man_t * p )
|
||||
{
|
||||
Gia_Obj_t * pObj; int i;
|
||||
Gia_Rpr_t * pReprs = p->pReprs; // representatives (for CIs and ANDs)
|
||||
int * pNexts = p->pNexts; // next nodes in the equivalence classes
|
||||
Gia_Man_t * pNew = Gia_ManChangeOrder(p);
|
||||
//Gia_ManEquivPrintClasses( p, 1, 0 );
|
||||
assert( Gia_ManObjNum(p) == Gia_ManObjNum(pNew) );
|
||||
Gia_ManTransferEquivs( p, pNew );
|
||||
p->pReprs = NULL;
|
||||
p->pNexts = NULL;
|
||||
// make new point to old
|
||||
Gia_ManForEachObj( p, pObj, i )
|
||||
{
|
||||
assert( !Abc_LitIsCompl(pObj->Value) );
|
||||
Gia_ManObj(pNew, Abc_Lit2Var(pObj->Value))->Value = Abc_Var2Lit(i, 0);
|
||||
}
|
||||
Gia_ManTransferEquivs( pNew, p );
|
||||
//Gia_ManEquivPrintClasses( p, 1, 0 );
|
||||
for ( i = 0; i < Gia_ManObjNum(p); i++ )
|
||||
pReprs[i].fProved = 0;
|
||||
//printf( "%5d : %5d %5d %5d %5d\n", i, *(int*)&p->pReprs[i], *(int*)&pReprs[i], (int)p->pNexts[i], (int)pNexts[i] );
|
||||
if ( memcmp(p->pReprs, pReprs, sizeof(int)*Gia_ManObjNum(p)) )
|
||||
printf( "Verification of reprs failed.\n" );
|
||||
else
|
||||
printf( "Verification of reprs succeeded.\n" );
|
||||
if ( memcmp(p->pNexts, pNexts, sizeof(int)*Gia_ManObjNum(p)) )
|
||||
printf( "Verification of nexts failed.\n" );
|
||||
else
|
||||
printf( "Verification of nexts succeeded.\n" );
|
||||
ABC_FREE( pNew->pReprs );
|
||||
ABC_FREE( pNew->pNexts );
|
||||
ABC_FREE( pReprs );
|
||||
ABC_FREE( pNexts );
|
||||
Gia_ManStop( pNew );
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Converting AIG after SAT sweeping into AIG with choices.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Cec4_ManMarkIndependentClasses_rec( Gia_Man_t * p, int iObj )
|
||||
{
|
||||
Gia_Obj_t * pObj;
|
||||
assert( iObj > 0 );
|
||||
if ( Gia_ObjIsTravIdPreviousId(p, iObj) ) // failed
|
||||
return 0;
|
||||
if ( Gia_ObjIsTravIdCurrentId(p, iObj) ) // passed
|
||||
return 1;
|
||||
Gia_ObjSetTravIdCurrentId(p, iObj);
|
||||
pObj = Gia_ManObj( p, iObj );
|
||||
if ( Gia_ObjIsCi(pObj) )
|
||||
return 1;
|
||||
assert( Gia_ObjIsAnd(pObj) );
|
||||
if ( Cec4_ManMarkIndependentClasses_rec( p, Gia_ObjFaninId0(pObj, iObj) ) &&
|
||||
Cec4_ManMarkIndependentClasses_rec( p, Gia_ObjFaninId1(pObj, iObj) ) )
|
||||
return 1;
|
||||
Gia_ObjSetTravIdPreviousId(p, iObj);
|
||||
return 0;
|
||||
}
|
||||
int Cec4_ManMarkIndependentClasses( Gia_Man_t * p, Gia_Man_t * pNew )
|
||||
{
|
||||
int iObjNew, iRepr, iObj, Res, fHaveChoices = 0;
|
||||
Gia_ManCleanMark01(p);
|
||||
Gia_ManForEachClass( p, iRepr )
|
||||
{
|
||||
Gia_ManIncrementTravId( pNew );
|
||||
Gia_ManIncrementTravId( pNew );
|
||||
iObjNew = Abc_Lit2Var( Gia_ManObj(p, iRepr)->Value );
|
||||
Res = Cec4_ManMarkIndependentClasses_rec( pNew, iObjNew );
|
||||
assert( Res == 1 );
|
||||
Gia_ObjSetTravIdPreviousId( pNew, iObjNew );
|
||||
p->pReprs[iRepr].fColorA = 1;
|
||||
Gia_ClassForEachObj1( p, iRepr, iObj )
|
||||
{
|
||||
assert( p->pReprs[iObj].iRepr == (unsigned)iRepr );
|
||||
iObjNew = Abc_Lit2Var( Gia_ManObj(p, iObj)->Value );
|
||||
if ( Cec4_ManMarkIndependentClasses_rec( pNew, iObjNew ) )
|
||||
{
|
||||
p->pReprs[iObj].fColorA = 1;
|
||||
fHaveChoices = 1;
|
||||
}
|
||||
Gia_ObjSetTravIdPreviousId( pNew, iObjNew );
|
||||
}
|
||||
}
|
||||
return fHaveChoices;
|
||||
}
|
||||
int Cec4_ManSatSolverAnd_rec( Gia_Man_t * pCho, Gia_Man_t * p, Gia_Man_t * pNew, int iObj )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int Cec4_ManSatSolverChoices_rec( Gia_Man_t * pCho, Gia_Man_t * p, Gia_Man_t * pNew, int iObj )
|
||||
{
|
||||
if ( !Gia_ObjIsClass(p, iObj) )
|
||||
return Cec4_ManSatSolverAnd_rec( pCho, p, pNew, iObj );
|
||||
else
|
||||
{
|
||||
Vec_Int_t * vLits = Vec_IntAlloc( 100 );
|
||||
int i, iHead, iNext, iRepr = Gia_ObjIsHead(p, iObj) ? iObj : Gia_ObjRepr(p, iObj);
|
||||
Gia_ClassForEachObj( p, iRepr, iObj )
|
||||
if ( p->pReprs[iObj].fColorA )
|
||||
Vec_IntPush( vLits, Cec4_ManSatSolverAnd_rec( pCho, p, pNew, iObj ) );
|
||||
Vec_IntSort( vLits, 1 );
|
||||
iHead = Abc_Lit2Var( Vec_IntEntry(vLits, 0) );
|
||||
if ( Vec_IntSize(vLits) > 1 )
|
||||
{
|
||||
Vec_IntForEachEntryStart( vLits, iNext, i, 1 )
|
||||
{
|
||||
pCho->pSibls[iHead] = Abc_Lit2Var(iNext);
|
||||
iHead = Abc_Lit2Var(iNext);
|
||||
}
|
||||
}
|
||||
return Abc_LitNotCond( Vec_IntEntry(vLits, 0), Gia_ManObj(p, iHead)->fPhase );
|
||||
}
|
||||
}
|
||||
Gia_Man_t * Cec4_ManSatSolverChoices( Gia_Man_t * p, Gia_Man_t * pNew )
|
||||
{
|
||||
Gia_Man_t * pCho;
|
||||
Gia_Obj_t * pObj;
|
||||
int i, DriverId;
|
||||
// mark topologically dependent equivalent nodes
|
||||
if ( !Cec4_ManMarkIndependentClasses( p, pNew ) )
|
||||
return Gia_ManDup( pNew );
|
||||
// rebuild AIG in a different order with choices
|
||||
pCho = Gia_ManStart( Gia_ManObjNum(pNew) );
|
||||
pCho->pName = Abc_UtilStrsav( p->pName );
|
||||
pCho->pSpec = Abc_UtilStrsav( p->pSpec );
|
||||
pCho->pSibls = ABC_CALLOC( int, Gia_ManObjNum(pNew) );
|
||||
Gia_ManFillValue(pNew);
|
||||
Gia_ManConst0(pNew)->Value = 0;
|
||||
for ( i = 0; i < Gia_ManCiNum(pNew); i++ )
|
||||
Gia_ManCi(pNew, i)->Value = Gia_ManAppendCi( pCho );
|
||||
Gia_ManForEachCoDriverId( p, DriverId, i )
|
||||
Cec4_ManSatSolverChoices_rec( pCho, p, pNew, DriverId );
|
||||
Gia_ManForEachCo( pNew, pObj, i )
|
||||
pObj->Value = Gia_ManAppendCo( pCho, Gia_ObjFanin0Copy(pObj) );
|
||||
Gia_ManSetRegNum( pCho, Gia_ManRegNum(p) );
|
||||
return pCho;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Converting AIG after SAT sweeping into AIG with choices.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Gia_Man_t * Gia_ManCombSpecReduce( Gia_Man_t * p )
|
||||
{
|
||||
Gia_Obj_t * pObj, * pRepr; int i, iLit;
|
||||
Vec_Int_t * vXors = Vec_IntAlloc( 100 );
|
||||
Gia_Man_t * pTemp, * pNew = Gia_ManStart( Gia_ManObjNum(p) );
|
||||
assert( p->pReprs && p->pNexts );
|
||||
pNew->pName = Abc_UtilStrsav( p->pName );
|
||||
pNew->pSpec = Abc_UtilStrsav( p->pSpec );
|
||||
Gia_ManLevelNum(p);
|
||||
Gia_ManSetPhase(p);
|
||||
Gia_ManFillValue(p);
|
||||
Gia_ManConst0(p)->Value = 0;
|
||||
Gia_ManForEachCi( p, pObj, i )
|
||||
pObj->Value = Gia_ManAppendCi( pNew );
|
||||
Gia_ManHashAlloc( pNew );
|
||||
Gia_ManForEachAnd( p, pObj, i )
|
||||
{
|
||||
pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
|
||||
pRepr = Gia_ObjReprObj( p, i );
|
||||
if ( pRepr && Abc_Lit2Var(pObj->Value) != Abc_Lit2Var(pRepr->Value) )
|
||||
{
|
||||
//if ( Gia_ObjLevel(p, pRepr) > Gia_ObjLevel(p, pObj) + 50 )
|
||||
//printf( "%d %d ", Gia_ObjLevel(p, pRepr), Gia_ObjLevel(p, pObj) );
|
||||
iLit = Abc_LitNotCond( pRepr->Value, pObj->fPhase ^ pRepr->fPhase );
|
||||
Vec_IntPush( vXors, Gia_ManHashXor( pNew, pObj->Value, iLit ) );
|
||||
pObj->Value = iLit;
|
||||
}
|
||||
}
|
||||
Gia_ManHashStop( pNew );
|
||||
if ( Vec_IntSize(vXors) == 0 )
|
||||
Vec_IntPush( vXors, 0 );
|
||||
Vec_IntForEachEntry( vXors, iLit, i )
|
||||
Gia_ManAppendCo( pNew, iLit );
|
||||
Vec_IntFree( vXors );
|
||||
Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
|
||||
pNew = Gia_ManCleanup( pTemp = pNew );
|
||||
Gia_ManStop( pTemp );
|
||||
return pNew;
|
||||
}
|
||||
void Gia_ManCombSpecReduceTest( Gia_Man_t * p, char * pFileName )
|
||||
{
|
||||
Gia_Man_t * pSrm = Gia_ManCombSpecReduce( p );
|
||||
if ( pFileName == NULL )
|
||||
pFileName = "test.aig";
|
||||
Gia_AigerWrite( pSrm, pFileName, 0, 0, 0 );
|
||||
Abc_Print( 1, "Speculatively reduced model was written into file \"%s\".\n", pFileName );
|
||||
Gia_ManStop( pSrm );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -283,6 +283,89 @@ void Gia_ManStaticFanoutStart( Gia_Man_t * p )
|
|||
Vec_IntFree( vCounts );
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Compute the map of all edges.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Vec_Int_t * Gia_ManStartMappingFanoutMap( Gia_Man_t * p, Vec_Int_t * vFanoutNums )
|
||||
{
|
||||
Gia_Obj_t * pObj;
|
||||
int i, iOffset = Gia_ManObjNum(p);
|
||||
Vec_Int_t * vEdgeMap = Vec_IntAlloc( 2 * iOffset );
|
||||
Vec_IntFill( vEdgeMap, iOffset, 0 );
|
||||
Gia_ManForEachObj( p, pObj, i )
|
||||
{
|
||||
if ( Vec_IntEntry(vFanoutNums, i) == 0 )
|
||||
continue;
|
||||
Vec_IntWriteEntry( vEdgeMap, i, iOffset );
|
||||
iOffset += Vec_IntEntry( vFanoutNums, i );
|
||||
Vec_IntFillExtra( vEdgeMap, iOffset, 0 );
|
||||
}
|
||||
//printf( "Fanout map is %.2fx larger than AIG manager.\n", 1.0*Vec_IntSize(vEdgeMap)/Gia_ManObjNum(p) );
|
||||
return vEdgeMap;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Allocates static fanout.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_ManStaticMappingFanoutStart( Gia_Man_t * p )
|
||||
{
|
||||
Vec_Int_t * vCounts;
|
||||
int * pRefsOld;
|
||||
Gia_Obj_t * pObj, * pFanin;
|
||||
int i, k, iFan, iFanout;
|
||||
assert( p->vFanoutNums == NULL );
|
||||
assert( p->vFanout == NULL );
|
||||
// recompute reference counters
|
||||
pRefsOld = p->pLutRefs; p->pLutRefs = NULL;
|
||||
Gia_ManSetLutRefs(p);
|
||||
p->vFanoutNums = Vec_IntAllocArray( p->pLutRefs, Gia_ManObjNum(p) );
|
||||
p->pLutRefs = pRefsOld;
|
||||
// start the fanout maps
|
||||
p->vFanout = Gia_ManStartMappingFanoutMap( p, p->vFanoutNums );
|
||||
// incrementally add fanouts
|
||||
vCounts = Vec_IntStart( Gia_ManObjNum(p) );
|
||||
Gia_ManForEachLut( p, i )
|
||||
{
|
||||
pObj = Gia_ManObj( p, i );
|
||||
Gia_LutForEachFanin( p, i, iFan, k )
|
||||
{
|
||||
pFanin = Gia_ManObj( p, iFan );
|
||||
iFanout = Vec_IntEntry( vCounts, iFan );
|
||||
Gia_ObjSetFanout( p, pFanin, iFanout, pObj );
|
||||
Vec_IntAddToEntry( vCounts, iFan, 1 );
|
||||
}
|
||||
}
|
||||
Gia_ManForEachCo( p, pObj, i )
|
||||
{
|
||||
iFan = Gia_ObjFaninId0p(p, pObj);
|
||||
pFanin = Gia_ManObj( p, iFan );
|
||||
iFanout = Vec_IntEntry( vCounts, iFan );
|
||||
Gia_ObjSetFanout( p, pFanin, iFanout, pObj );
|
||||
Vec_IntAddToEntry( vCounts, iFan, 1 );
|
||||
}
|
||||
// double-check the current number of fanouts added
|
||||
Gia_ManForEachObj( p, pObj, i )
|
||||
assert( Vec_IntEntry(vCounts, i) == Gia_ObjFanoutNum(p, pObj) );
|
||||
Vec_IntFree( vCounts );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Deallocates static fanout.]
|
||||
|
|
|
|||
|
|
@ -460,7 +460,11 @@ Gia_Man_t * Gia_ManPerformFx( Gia_Man_t * p, int nNewNodesMax, int LitCountMax,
|
|||
Vec_Wec_t * vCubes;
|
||||
Vec_Str_t * vCompl;
|
||||
if ( Gia_ManAndNum(p) == 0 )
|
||||
return Gia_ManDup(p);
|
||||
{
|
||||
pNew = Gia_ManDup(p);
|
||||
Gia_ManTransferTiming( pNew, p );
|
||||
return pNew;
|
||||
}
|
||||
// abctime clk;
|
||||
assert( Gia_ManHasMapping(p) );
|
||||
// collect information
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "gia.h"
|
||||
#include "misc/util/utilTruth.h"
|
||||
#include "misc/extra/extra.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
|
|
@ -33,6 +34,64 @@ ABC_NAMESPACE_IMPL_START
|
|||
/// FUNCTION DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Gia_Man_t * Gia_DeriveAig( Vec_Wrd_t * vSims, Vec_Str_t * vSimsOut )
|
||||
{
|
||||
int nInputs = 32*32*24;
|
||||
int nWords = nInputs/64;
|
||||
int nExamps = 64;
|
||||
int i, e, iLitOut[10] = {0};
|
||||
Gia_Man_t * pNew;
|
||||
assert( Vec_WrdSize(vSims) % nInputs == 0 );
|
||||
pNew = Gia_ManStart( nInputs * nExamps + 10000 );
|
||||
for ( i = 0; i < nInputs; i++ )
|
||||
Gia_ManAppendCi( pNew );
|
||||
Gia_ManHashStart( pNew );
|
||||
for ( e = 0; e < nExamps; e++ )
|
||||
{
|
||||
int Class = Vec_StrEntry( vSimsOut, e );
|
||||
int This = 1;
|
||||
word * pSim = Vec_WrdEntryP( vSims, e*nWords );
|
||||
for ( i = 0; i < nInputs; i++ )
|
||||
This = Gia_ManHashAnd( pNew, This, Abc_Var2Lit(i+1, !Abc_TtGetBit(pSim, i)) );
|
||||
assert( Class >= 0 && Class <= 9 );
|
||||
iLitOut[Class] = Gia_ManHashOr( pNew, iLitOut[Class], This );
|
||||
//printf( "Finished example %d\n", e );
|
||||
}
|
||||
for ( i = 0; i < 10; i++ )
|
||||
Gia_ManAppendCo( pNew, iLitOut[i] );
|
||||
//pNew = Gia_ManCleanup( pTemp = pNew );
|
||||
//Gia_ManStop( pTemp );
|
||||
return pNew;
|
||||
}
|
||||
void Gia_DeriveAigTest()
|
||||
{
|
||||
extern int Gia_ManReadCifar10File( char * pFileName, Vec_Wrd_t ** pvSimsIn, Vec_Str_t ** pvSimsOut, int * pnExamples );
|
||||
char pFileName[100] = "test";
|
||||
Vec_Wrd_t * vSimsIn;
|
||||
Vec_Str_t * vSimsOut;
|
||||
int nExamples = 0;
|
||||
int nInputs = Gia_ManReadCifar10File( pFileName, &vSimsIn, &vSimsOut, &nExamples );
|
||||
Gia_Man_t * pThis = Gia_DeriveAig( vSimsIn, vSimsOut );
|
||||
Gia_AigerWrite( pThis, "examples64.aig", 0, 0, 0 );
|
||||
printf( "Dumped file \"%s\".\n", "examples64.aig" );
|
||||
Gia_ManStop( pThis );
|
||||
Vec_WrdFree( vSimsIn );
|
||||
Vec_StrFree( vSimsOut );
|
||||
nInputs = 0;
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Populate internal simulation info.]
|
||||
|
|
@ -136,6 +195,38 @@ int Gia_ManSimulateWordsInit( Gia_Man_t * p, Vec_Wrd_t * vSimsIn )
|
|||
return 1;
|
||||
}
|
||||
|
||||
Vec_Wrd_t * Gia_ManSimulateWordsOut( Gia_Man_t * p, Vec_Wrd_t * vSimsIn )
|
||||
{
|
||||
Gia_Obj_t * pObj; int i, Id;
|
||||
int nWords = Vec_WrdSize(vSimsIn) / Gia_ManCiNum(p);
|
||||
Vec_Wrd_t * vSimsOut = Vec_WrdStart( nWords * Gia_ManCoNum(p) );
|
||||
assert( Vec_WrdSize(vSimsIn) == nWords * Gia_ManCiNum(p) );
|
||||
// allocate simulation info for one timeframe
|
||||
Vec_WrdFreeP( &p->vSims );
|
||||
p->vSims = Vec_WrdStart( Gia_ManObjNum(p) * nWords );
|
||||
p->nSimWords = nWords;
|
||||
// set input sim info
|
||||
Gia_ManForEachCiId( p, Id, i )
|
||||
memcpy( Vec_WrdEntryP(p->vSims, Id*nWords), Vec_WrdEntryP(vSimsIn, i*nWords), sizeof(word)*nWords );
|
||||
// perform simulation
|
||||
Gia_ManForEachObj1( p, pObj, i )
|
||||
{
|
||||
if ( Gia_ObjIsAnd(pObj) )
|
||||
Gia_ManObjSimAnd( p, i );
|
||||
else if ( Gia_ObjIsCi(pObj) )
|
||||
continue;
|
||||
else if ( Gia_ObjIsCo(pObj) )
|
||||
Gia_ManObjSimPo( p, i );
|
||||
else assert( 0 );
|
||||
}
|
||||
// set output sim info
|
||||
Gia_ManForEachCoId( p, Id, i )
|
||||
memcpy( Vec_WrdEntryP(vSimsOut, i*nWords), Vec_WrdEntryP(p->vSims, Id*nWords), sizeof(word)*nWords );
|
||||
Vec_WrdFreeP( &p->vSims );
|
||||
p->nSimWords = -1;
|
||||
return vSimsOut;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Dump data files.]
|
||||
|
|
@ -432,6 +523,224 @@ void Gia_ManCompareValues( Gia_Man_t * p, Vec_Wrd_t * vSimsIn, Vec_Int_t * vValu
|
|||
printf( "Finished dumping statistics into file \"%s\".\n", pDumpFile );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_ManReadSimFile( char * pFileName, int * pnIns, int * pnOuts, int * pnPats, Vec_Wrd_t ** pvSimsIn, Vec_Wrd_t ** pvSimsOut )
|
||||
{
|
||||
char * pTemp, pBuffer[1000];
|
||||
Vec_Wrd_t * vSimsIn = NULL, * vSimsOut = NULL;
|
||||
int i, iPat = 0, nWordsI, nWordsO, nIns = -1, nOuts = -1, nPats = -1;
|
||||
FILE * pFile = fopen( pFileName, "rb" );
|
||||
if ( pFile == NULL )
|
||||
{
|
||||
printf( "Cannot open file \"%s\" for reading.\n", pFileName );
|
||||
return;
|
||||
}
|
||||
while ( fgets( pBuffer, 1000, pFile ) != NULL )
|
||||
{
|
||||
pTemp = pBuffer;
|
||||
if ( pTemp[0] == '\0' || pTemp[0] == '#' || pTemp[0] == ' ' )
|
||||
continue;
|
||||
if ( pTemp[0] != '.' )
|
||||
break;
|
||||
if ( pTemp[1] == 'i' )
|
||||
nIns = atoi(pTemp+2);
|
||||
else if ( pTemp[1] == 'o' )
|
||||
nOuts = atoi(pTemp+2);
|
||||
else if ( pTemp[1] == 'p' )
|
||||
{
|
||||
if ( atoi(pTemp+2) % 64 == 0 )
|
||||
printf( "Expecting the number of patterns divisible by 64.\n" );
|
||||
nPats = atoi(pTemp+2) / 64;
|
||||
}
|
||||
}
|
||||
if ( nIns == -1 || nOuts == -1 || nPats == -1 )
|
||||
{
|
||||
printf( "Some of the parameters (inputs, outputs, patterns) is not specified.\n" );
|
||||
fclose( pFile );
|
||||
return;
|
||||
}
|
||||
nWordsI = (nIns + 63) / 64;
|
||||
nWordsO = (nOuts + 63) / 64;
|
||||
|
||||
vSimsIn = Vec_WrdStart( nPats * nWordsI );
|
||||
vSimsOut = Vec_WrdStart( nPats * nWordsO );
|
||||
rewind(pFile);
|
||||
while ( fgets( pBuffer, 1000, pFile ) != NULL )
|
||||
{
|
||||
if ( pTemp[0] == '\0' || pTemp[0] == '.' )
|
||||
continue;
|
||||
for ( i = 0, pTemp = pBuffer; *pTemp != '\n'; pTemp++ )
|
||||
if ( *pTemp == '0' || *pTemp == '1' )
|
||||
{
|
||||
if ( *pTemp == '1' )
|
||||
{
|
||||
if ( i < nIns )
|
||||
Abc_TtSetBit( Vec_WrdEntryP(vSimsIn, nWordsI*iPat), i );
|
||||
else
|
||||
Abc_TtSetBit( Vec_WrdEntryP(vSimsOut, nWordsO*iPat), i-nIns );
|
||||
}
|
||||
i++;
|
||||
}
|
||||
iPat++;
|
||||
}
|
||||
if ( iPat != nPats )
|
||||
printf( "The number of patterns does not match.\n" );
|
||||
fclose( pFile );
|
||||
*pnIns = nIns;
|
||||
*pnOuts = nOuts;
|
||||
*pnPats = nPats;
|
||||
*pvSimsIn = vSimsIn;
|
||||
*pvSimsOut = vSimsOut;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Gia_ManReadBinaryFile( char * pFileName, Vec_Wrd_t ** pvSimsIn, Vec_Str_t ** pvSimsOut )
|
||||
{
|
||||
extern void Extra_BitMatrixTransposeP( Vec_Wrd_t * vSimsIn, int nWordsIn, Vec_Wrd_t * vSimsOut, int nWordsOut );
|
||||
int nFileSize = Extra_FileSize( pFileName );
|
||||
int nExamples = 1 << 16;
|
||||
int nInputs = nFileSize / nExamples - 1;
|
||||
int nWords = (8*nInputs + 63)/64, i;
|
||||
char * pContents = Extra_FileReadContents( pFileName );
|
||||
Vec_Wrd_t * vSimsIn = Vec_WrdStart( nExamples * nWords );
|
||||
Vec_Wrd_t * vSimsIn2 = Vec_WrdStart( nExamples * nWords );
|
||||
Vec_Str_t * vSimsOut = Vec_StrAlloc( nExamples );
|
||||
assert( nFileSize % nExamples == 0 );
|
||||
for ( i = 0; i < nExamples; i++ )
|
||||
{
|
||||
memcpy( (void *)Vec_WrdEntryP(vSimsIn, i*nWords), (void *)(pContents + i*(nInputs+1)), nInputs );
|
||||
Vec_StrPush( vSimsOut, pContents[i*(nInputs+1) + nInputs] );
|
||||
}
|
||||
Extra_BitMatrixTransposeP( vSimsIn, nWords, vSimsIn2, nExamples/64 );
|
||||
Vec_WrdShrink( vSimsIn2, 8*nInputs * nExamples/64 );
|
||||
Vec_WrdFree( vSimsIn );
|
||||
*pvSimsIn = vSimsIn2;
|
||||
*pvSimsOut = vSimsOut;
|
||||
ABC_FREE( pContents );
|
||||
return nInputs;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_ManSimLogStats2( Gia_Man_t * p, char * pDumpFile, int Total, int nPositives, float ErrorTotal, float GuessTotal )
|
||||
{
|
||||
FILE * pTable = fopen( pDumpFile, "wb" );
|
||||
fprintf( pTable, "{\n" );
|
||||
fprintf( pTable, " \"name\" : \"%s\",\n", p->pName );
|
||||
fprintf( pTable, " \"input\" : %d,\n", Gia_ManCiNum(p) );
|
||||
fprintf( pTable, " \"output\" : %d,\n", Gia_ManCoNum(p) );
|
||||
fprintf( pTable, " \"and\" : %d,\n", Gia_ManAndNum(p) );
|
||||
fprintf( pTable, " \"level\" : %d,\n", Gia_ManLevelNum(p) );
|
||||
fprintf( pTable, " \"total\" : %d,\n", Total );
|
||||
fprintf( pTable, " \"positive\" : %d,\n", nPositives );
|
||||
fprintf( pTable, " \"error\" : %e,\n", ErrorTotal );
|
||||
fprintf( pTable, " \"guess\" : %e\n", GuessTotal );
|
||||
fprintf( pTable, "}\n" );
|
||||
fclose( pTable );
|
||||
}
|
||||
int Gia_ManGetExampleValue( word ** ppSims, int nSims, int iExample )
|
||||
{
|
||||
int o, Sign = 0, ValueSim = 0;
|
||||
for ( o = 0; o < nSims; o++ )
|
||||
if ( (Sign = Abc_TtGetBit(ppSims[o], iExample)) )
|
||||
ValueSim |= (1 << o);
|
||||
if ( Sign )
|
||||
ValueSim |= ~0 << nSims;
|
||||
return ValueSim;
|
||||
}
|
||||
void Gia_ManCompareValues2( int nInputs, Gia_Man_t * p, Vec_Wrd_t * vSimsIn, Vec_Str_t * vValues, char * pDumpFile )
|
||||
{
|
||||
float Error1, ErrorTotal = 0, Guess1, GuessTotal = 0;
|
||||
int i, o, nPositives = 0, nWords = Vec_WrdSize(vSimsIn) / Gia_ManCiNum(p);
|
||||
word ** ppSims = ABC_CALLOC( word *, Gia_ManCoNum(p) );
|
||||
Gia_Obj_t * pObj;
|
||||
assert( nWords == (1<<10) );
|
||||
assert( Vec_WrdSize(vSimsIn) % Gia_ManCiNum(p) == 0 );
|
||||
assert( Vec_StrSize(vValues) == (1 << 16) );
|
||||
assert( nWords*64 == (1 << 16) );
|
||||
// simulate examples given in vSimsIn
|
||||
Gia_ManSimulateWordsInit( p, vSimsIn );
|
||||
// collect simulation info for the outputs
|
||||
assert( p->nSimWords == nWords );
|
||||
Gia_ManForEachCo( p, pObj, o )
|
||||
ppSims[o] = Gia_ManObjSim( p, Gia_ObjId(p, pObj) );
|
||||
// compare the output for each example
|
||||
for ( i = 0; i < nWords*64; i++ )
|
||||
{
|
||||
int ValueGold = (int)Vec_StrEntry( vValues, i );
|
||||
int ValueImpl = Gia_ManGetExampleValue( ppSims, Gia_ManCoNum(p), i );
|
||||
// compute error for this example
|
||||
Error1 = (float)(ValueGold - ValueImpl)/256;
|
||||
ErrorTotal += Error1 * Error1;
|
||||
// compute error of zero-output
|
||||
Guess1 = ValueGold > 0 ? Abc_AbsInt(ValueImpl) : 0;
|
||||
GuessTotal += Guess1 * Guess1;
|
||||
// count positive values (disregard negative values due to Leaky ReLU)
|
||||
nPositives += (int)(ValueGold > 0);
|
||||
}
|
||||
ABC_FREE( ppSims );
|
||||
printf( "Total = %6d. Positive = %6d. (%6.2f %%) Errors = %e. Guess = %e. (%6.2f %%)\n",
|
||||
Vec_StrSize(vValues), nPositives, 100.0*nPositives/Vec_StrSize(vValues),
|
||||
ErrorTotal, GuessTotal, 100.0*ErrorTotal/GuessTotal );
|
||||
if ( pDumpFile == NULL )
|
||||
return;
|
||||
Gia_ManSimLogStats2( p, pDumpFile, Vec_StrSize(vValues), nPositives, ErrorTotal, GuessTotal );
|
||||
printf( "Finished dumping statistics into file \"%s\".\n", pDumpFile );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_ManTestWordFileUnused( Gia_Man_t * p, char * pFileName, char * pDumpFile )
|
||||
{
|
||||
Vec_Wrd_t * vSimsIn;
|
||||
Vec_Str_t * vSimsOut;
|
||||
int nInputs = Gia_ManReadBinaryFile( pFileName, &vSimsIn, &vSimsOut );
|
||||
if ( Gia_ManCiNum(p) == 8*nInputs )
|
||||
Gia_ManCompareValues2( nInputs, p, vSimsIn, vSimsOut, pDumpFile );
|
||||
else
|
||||
printf( "The number of inputs in the AIG (%d) and in the file (%d) does not match.\n", Gia_ManCiNum(p), 8*nInputs );
|
||||
Vec_WrdFree( vSimsIn );
|
||||
Vec_StrFree( vSimsOut );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
|
@ -463,6 +772,158 @@ void Gia_ManTestOneFile( Gia_Man_t * p, char * pFileName, char * pDumpFile )
|
|||
Vec_IntFree( vValues );
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Gia_ManReadCifar10File( char * pFileName, Vec_Wrd_t ** pvSimsIn, Vec_Str_t ** pvSimsOut, int * pnExamples )
|
||||
{
|
||||
int nPixels = 32*32*3;
|
||||
int nFileSize = Extra_FileSize( pFileName );
|
||||
int nExamples = nFileSize / (nPixels + 1);
|
||||
int nWordsIn = nPixels / 8;
|
||||
int nWordsOut = (nExamples + 63) / 64; int e;
|
||||
if ( nFileSize % (nPixels + 1) )
|
||||
{
|
||||
printf( "The input file \"%s\" with image data does not appear to be in CIFAR10 format.\n", pFileName );
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vec_Wrd_t * vSimsIn = Vec_WrdStart( 64 * nWordsOut * nWordsIn );
|
||||
Vec_Str_t * vSimsOut = Vec_StrAlloc( 64 * nWordsOut );
|
||||
unsigned char * pBuffer = ABC_ALLOC( unsigned char, nFileSize );
|
||||
FILE * pFile = fopen( pFileName, "rb" );
|
||||
int Value = fread( pBuffer, 1, nFileSize, pFile );
|
||||
fclose( pFile );
|
||||
assert( Value == nFileSize );
|
||||
printf( "Successfully read %5.2f MB (%d images) from file \"%s\".\n", (float)nFileSize/(1<<20), nExamples, pFileName );
|
||||
for ( e = 0; e < nExamples; e++ )
|
||||
{
|
||||
Vec_StrPush( vSimsOut, (char)pBuffer[e*(nPixels + 1)] );
|
||||
memcpy( Vec_WrdEntryP(vSimsIn, e*nWordsIn), pBuffer + e*(nPixels + 1) + 1, nPixels );
|
||||
}
|
||||
ABC_FREE( pBuffer );
|
||||
for ( ; e < 64 * nWordsOut; e++ )
|
||||
Vec_StrPush( vSimsOut, (char)0 );
|
||||
memset( Vec_WrdEntryP(vSimsIn, nExamples*nWordsIn), 0, (64*nWordsOut - nExamples)*nWordsIn );
|
||||
*pvSimsIn = vSimsIn;
|
||||
*pvSimsOut = vSimsOut;
|
||||
*pnExamples = nExamples;
|
||||
return 8*nPixels;
|
||||
}
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Gia_ManSimulateBatch( Gia_Man_t * p, Vec_Wrd_t * vSimsIn, Vec_Str_t * vSimsOut, Vec_Str_t * vSimsOut2, int b, int Limit )
|
||||
{
|
||||
Gia_Obj_t * pObj;
|
||||
word * ppSims[10];
|
||||
int i, o, Count = 0;
|
||||
assert( Gia_ManCiNum(p) == Vec_WrdSize(vSimsIn) );
|
||||
assert( Gia_ManCoNum(p) == 10 );
|
||||
Gia_ManSimulateWordsInit( p, vSimsIn );
|
||||
Gia_ManForEachCo( p, pObj, o )
|
||||
ppSims[o] = Gia_ManObjSim( p, Gia_ObjId(p, pObj) );
|
||||
for ( i = 0; i < Limit; i++ )
|
||||
{
|
||||
int Value = 0;
|
||||
for ( o = 0; o < 10; o++ )
|
||||
if ( Abc_TtGetBit(ppSims[o], i) )
|
||||
{
|
||||
Value = o;
|
||||
break;
|
||||
}
|
||||
Vec_StrPush( vSimsOut, (char)Value );
|
||||
Count += Value == (int)Vec_StrEntry( vSimsOut2, 64*b+i );
|
||||
}
|
||||
return Count;
|
||||
}
|
||||
Vec_Str_t * Gia_ManSimulateAll( Gia_Man_t * p, Vec_Wrd_t * vSimsIn, Vec_Str_t * vSimsOut, int nExamples, int fVerbose )
|
||||
{
|
||||
extern void Extra_BitMatrixTransposeP( Vec_Wrd_t * vSimsIn, int nWordsIn, Vec_Wrd_t * vSimsOut, int nWordsOut );
|
||||
Vec_Str_t * vRes = Vec_StrAlloc( 100 ); int b, Count;
|
||||
int nWordsIn = 32*32*24/64; // one image
|
||||
int nWordsOut = Vec_WrdSize(vSimsIn)/(nWordsIn*64);
|
||||
assert( Vec_WrdSize(vSimsIn) % nWordsIn == 0 );
|
||||
for ( b = 0; b < nWordsOut; b++ )
|
||||
{
|
||||
int Limit = b == nWordsOut-1 ? nExamples-b*64 : 64;
|
||||
Vec_Wrd_t * vSimsIn1 = Vec_WrdStart( nWordsIn*64 );
|
||||
Vec_Wrd_t * vSimsIn2 = Vec_WrdStart( nWordsIn*64 );
|
||||
memcpy( Vec_WrdArray(vSimsIn1), Vec_WrdEntryP(vSimsIn, b*nWordsIn*64), sizeof(word)*nWordsIn*64 );
|
||||
Extra_BitMatrixTransposeP( vSimsIn1, nWordsIn, vSimsIn2, 1 );
|
||||
Vec_WrdFree( vSimsIn1 );
|
||||
Count = Gia_ManSimulateBatch( p, vSimsIn2, vRes, vSimsOut, b, Limit );
|
||||
Vec_WrdFree( vSimsIn2 );
|
||||
if ( fVerbose )
|
||||
printf( "Finished simulating word %4d (out of %4d). Correct = %2d. (Limit = %2d.)\n", b, nWordsOut, Count, Limit );
|
||||
}
|
||||
assert( Vec_StrSize(vRes) == nExamples );
|
||||
return vRes;
|
||||
}
|
||||
void Gia_ManCompareCifar10Values( Gia_Man_t * p, Vec_Str_t * vRes, Vec_Str_t * vSimsOut, char * pDumpFile, int nExamples )
|
||||
{
|
||||
int i, Guess = (nExamples+9)/10, Count = 0;
|
||||
for ( i = 0; i < nExamples; i++ )
|
||||
{
|
||||
char ValueReal = Vec_StrEntry(vRes, i);
|
||||
char ValueGold = Vec_StrEntry(vSimsOut, i);
|
||||
if ( ValueReal == ValueGold )
|
||||
Count++;
|
||||
}
|
||||
printf( "Summary: Total = %6d. Errors = %6d. Correct = %6d. (%6.2f %%) Naive guess = %6d. (%6.2f %%)\n",
|
||||
nExamples, nExamples - Count,
|
||||
Count, 100.0*Count/nExamples,
|
||||
Guess, 100.0*Guess/nExamples);
|
||||
if ( pDumpFile == NULL )
|
||||
return;
|
||||
Gia_ManSimLogStats( p, pDumpFile, nExamples, Count, Guess );
|
||||
printf( "Finished dumping statistics into file \"%s\".\n", pDumpFile );
|
||||
}
|
||||
void Gia_ManTestWordFile( Gia_Man_t * p, char * pFileName, char * pDumpFile, int fVerbose )
|
||||
{
|
||||
abctime clk = Abc_Clock();
|
||||
Vec_Wrd_t * vSimsIn;
|
||||
Vec_Str_t * vSimsOut;
|
||||
int i, nExamples = 0;
|
||||
int nInputs = Gia_ManReadCifar10File( pFileName, &vSimsIn, &vSimsOut, &nExamples );
|
||||
char * pKnownFileNames[3] = {"small.aig", "medium.aig", "large.aig"};
|
||||
int pLimitFileSizes[3] = {10000, 100000, 1000000};
|
||||
for ( i = 0; i < 3; i++ )
|
||||
if ( p->pSpec && !strncmp(p->pSpec, pKnownFileNames[i], 5) && Gia_ManAndNum(p) > pLimitFileSizes[i] )
|
||||
printf( "Warning: The input file \"%s\" contains more than %d internal and-nodes.\n", pKnownFileNames[i], pLimitFileSizes[i] );
|
||||
if ( nInputs == Gia_ManCiNum(p) )
|
||||
{
|
||||
Vec_Str_t * vRes = Gia_ManSimulateAll( p, vSimsIn, vSimsOut, nExamples, fVerbose );
|
||||
Gia_ManCompareCifar10Values( p, vRes, vSimsOut, pDumpFile, nExamples );
|
||||
Vec_StrFree( vRes );
|
||||
}
|
||||
else
|
||||
printf( "The primary input counts in the AIG (%d) and in the image data (%d) do not match.\n", Gia_ManCiNum(p), nInputs );
|
||||
Vec_WrdFree( vSimsIn );
|
||||
Vec_StrFree( vSimsOut );
|
||||
Abc_PrintTime( 1, "Total checking time", Abc_Clock() - clk );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -814,6 +814,328 @@ int Gia_ManHashDualMiter( Gia_Man_t * p, Vec_Int_t * vOuts )
|
|||
return iRes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Create multi-input tree.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int * Gia_ManCollectLiterals( int nVars )
|
||||
{
|
||||
int i, * pRes = ABC_CALLOC( int, nVars );
|
||||
for ( i = 0; i < nVars; i++ )
|
||||
pRes[i] = Abc_Var2Lit( i+1, 0 );
|
||||
return pRes;
|
||||
}
|
||||
int * Gia_ManGenZero( int nBits )
|
||||
{
|
||||
return ABC_CALLOC( int, nBits );
|
||||
}
|
||||
int * Gia_ManGenPerm( int nBits )
|
||||
{
|
||||
int i, * pRes = ABC_CALLOC( int, nBits );
|
||||
srand( time(NULL) );
|
||||
for ( i = 0; i < nBits; i++ )
|
||||
pRes[i] = i;
|
||||
for ( i = 0; i < nBits; i++ )
|
||||
{
|
||||
int iPerm = rand() % nBits;
|
||||
ABC_SWAP( int, pRes[i], pRes[iPerm] );
|
||||
}
|
||||
return pRes;
|
||||
}
|
||||
int * Gia_ManGenPerm2( int nBits )
|
||||
{
|
||||
int i, * pRes = ABC_CALLOC( int, nBits );
|
||||
srand( time(NULL) );
|
||||
for ( i = 0; i < nBits; i++ )
|
||||
pRes[i] = rand() % nBits;
|
||||
return pRes;
|
||||
}
|
||||
int Gia_ManMultiCheck( int * pPerm, int nPerm )
|
||||
{
|
||||
int i;
|
||||
for ( i = 1; i < nPerm; i++ )
|
||||
if ( pPerm[i-1] <= pPerm[i] )
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
int Gia_ManMultiInputPerm( Gia_Man_t * pNew, int * pVars, int nVars, int * pPerm, int fOr, int fXor )
|
||||
{
|
||||
int fPrint = 1;
|
||||
int i, iLit;
|
||||
if ( fPrint )
|
||||
{
|
||||
for ( i = 0; i < nVars; i++ )
|
||||
printf( "%d ", pPerm[i] );
|
||||
printf( "\n" );
|
||||
}
|
||||
while ( 1 )
|
||||
{
|
||||
for ( i = 1; i < nVars; i++ )
|
||||
if ( pPerm[i-1] >= pPerm[i] )
|
||||
break;
|
||||
if ( i == nVars )
|
||||
break;
|
||||
assert( pPerm[i-1] >= pPerm[i] );
|
||||
if ( pPerm[i-1] > pPerm[i] )
|
||||
{
|
||||
ABC_SWAP( int, pPerm[i-1], pPerm[i] );
|
||||
ABC_SWAP( int, pVars[i-1], pVars[i] );
|
||||
}
|
||||
else
|
||||
{
|
||||
assert( pPerm[i-1] == pPerm[i] );
|
||||
pPerm[i-1]++;
|
||||
if ( fXor )
|
||||
pVars[i-1] = Gia_ManHashXor( pNew, pVars[i-1], pVars[i] );
|
||||
else if ( fOr )
|
||||
pVars[i-1] = Gia_ManHashOr( pNew, pVars[i-1], pVars[i] );
|
||||
else
|
||||
pVars[i-1] = Gia_ManHashAnd( pNew, pVars[i-1], pVars[i] );
|
||||
for ( i = i+1; i < nVars; i++ )
|
||||
{
|
||||
pPerm[i-1] = pPerm[i];
|
||||
pVars[i-1] = pVars[i];
|
||||
}
|
||||
nVars--;
|
||||
}
|
||||
if ( fPrint )
|
||||
{
|
||||
for ( i = 0; i < nVars; i++ )
|
||||
printf( "%d ", pPerm[i] );
|
||||
printf( "\n" );
|
||||
}
|
||||
}
|
||||
iLit = pVars[0];
|
||||
for ( i = 1; i < nVars; i++ )
|
||||
if ( fXor )
|
||||
iLit = Gia_ManHashXor( pNew, iLit, pVars[i] );
|
||||
else if ( fOr )
|
||||
iLit = Gia_ManHashOr( pNew, iLit, pVars[i] );
|
||||
else
|
||||
iLit = Gia_ManHashAnd( pNew, iLit, pVars[i] );
|
||||
return iLit;
|
||||
}
|
||||
Gia_Man_t * Gia_ManMultiInputTest( int nBits )
|
||||
{
|
||||
Gia_Man_t * pNew;
|
||||
int i, iRes, * pPerm;
|
||||
int * pMulti = Gia_ManCollectLiterals( nBits );
|
||||
pNew = Gia_ManStart( 1000 );
|
||||
pNew->pName = Abc_UtilStrsav( "multi" );
|
||||
for ( i = 0; i < nBits; i++ )
|
||||
Gia_ManAppendCi( pNew );
|
||||
Gia_ManHashAlloc( pNew );
|
||||
pPerm = Gia_ManGenPerm2( nBits );
|
||||
//pPerm = Gia_ManGenZero( nBits );
|
||||
iRes = Gia_ManMultiInputPerm( pNew, pMulti, nBits, pPerm, 0, 0 );
|
||||
Gia_ManAppendCo( pNew, iRes );
|
||||
ABC_FREE( pPerm );
|
||||
ABC_FREE( pMulti );
|
||||
return pNew;
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Create MUX tree.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Gia_ManCube( Gia_Man_t * pNew, int Vars, int nVars, int * pLits )
|
||||
{
|
||||
int i, iLit = 1;
|
||||
for ( i = 0; i < nVars; i++ )
|
||||
iLit = Gia_ManHashAnd( pNew, iLit, Abc_LitNotCond(pLits[i], !((Vars >> i) & 1)) );
|
||||
return iLit;
|
||||
}
|
||||
int Gia_ManMuxTree_rec( Gia_Man_t * pNew, int * pCtrl, int nCtrl, int * pData )
|
||||
{
|
||||
int iLit0, iLit1;
|
||||
if ( nCtrl == 0 )
|
||||
return pData[0];
|
||||
iLit0 = Gia_ManMuxTree_rec( pNew, pCtrl, nCtrl-1, pData );
|
||||
iLit1 = Gia_ManMuxTree_rec( pNew, pCtrl, nCtrl-1, pData + (1<<(nCtrl-1)) );
|
||||
return Gia_ManHashMux( pNew, pCtrl[nCtrl-1], iLit1, iLit0 );
|
||||
}
|
||||
void Gia_ManUsePerm( int * pTree, int nBits, int * pPerm )
|
||||
{
|
||||
int fPrint = 0;
|
||||
int i, k, m, nVars = nBits + (1 << nBits);
|
||||
if ( fPrint )
|
||||
{
|
||||
for ( i = 0; i < nVars; i++ )
|
||||
printf( "%d ", pPerm[i] );
|
||||
printf( "\n" );
|
||||
}
|
||||
for ( i = 0; i < nBits; i++ )
|
||||
{
|
||||
for ( k = i+1; k < nBits; k++ )
|
||||
if ( pPerm[i] > pPerm[k] )
|
||||
break;
|
||||
if ( k == nBits )
|
||||
break;
|
||||
assert( pPerm[i] > pPerm[k] );
|
||||
ABC_SWAP( int, pPerm[i], pPerm[k] );
|
||||
ABC_SWAP( int, pTree[i], pTree[k] );
|
||||
for ( m = 0; m < (1 << nBits); m++ )
|
||||
if ( ((m >> i) & 1) && !((m >> k) & 1) )
|
||||
{
|
||||
ABC_SWAP( int, pTree[nBits+m], pTree[nBits+(m^(1<<i)^(1<<k))] );
|
||||
ABC_SWAP( int, pPerm[nBits+m], pPerm[nBits+(m^(1<<i)^(1<<k))] );
|
||||
}
|
||||
}
|
||||
if ( fPrint )
|
||||
{
|
||||
for ( i = 0; i < nVars; i++ )
|
||||
printf( "%d ", pPerm[i] );
|
||||
printf( "\n" );
|
||||
}
|
||||
}
|
||||
int Gia_ManFindCond( int * pLits, int nBits, int iLate1, int iLate2 )
|
||||
{
|
||||
int i;
|
||||
assert( iLate1 != iLate2 );
|
||||
for ( i = 0; i < nBits; i++ )
|
||||
if ( (((iLate1 ^ iLate2) >> i) & 1) )
|
||||
return Abc_LitNotCond( pLits[i], (iLate1 >> i) & 1 );
|
||||
return -1;
|
||||
}
|
||||
int Gia_ManLatest( int * pPerm, int nVars, int iPrev1, int iPrev2, int iPrev3 )
|
||||
{
|
||||
int i, Value = -1, iLate = -1;
|
||||
for ( i = 0; i < nVars; i++ )
|
||||
if ( Value < pPerm[i] && i != iPrev1 && i != iPrev2 && i != iPrev3 )
|
||||
{
|
||||
Value = pPerm[i];
|
||||
iLate = i;
|
||||
}
|
||||
return iLate;
|
||||
}
|
||||
int Gia_ManEarliest( int * pPerm, int nVars )
|
||||
{
|
||||
int i, Value = ABC_INFINITY, iLate = -1;
|
||||
for ( i = 0; i < nVars; i++ )
|
||||
if ( Value > pPerm[i] )
|
||||
{
|
||||
Value = pPerm[i];
|
||||
iLate = i;
|
||||
}
|
||||
return iLate;
|
||||
}
|
||||
int Gia_ManDecompOne( Gia_Man_t * pNew, int * pTree, int nBits, int * pPerm, int iLate )
|
||||
{
|
||||
int iRes, iData;
|
||||
assert( iLate >= 0 && iLate < (1<<nBits) );
|
||||
iData = pTree[nBits+iLate];
|
||||
pTree[nBits+iLate] = pTree[nBits+(iLate^1)];
|
||||
iRes = Gia_ManMuxTree_rec( pNew, pTree, nBits, pTree+nBits );
|
||||
return Gia_ManHashMux( pNew, Gia_ManCube(pNew, iLate, nBits, pTree), iData, iRes );
|
||||
}
|
||||
int Gia_ManDecompTwo( Gia_Man_t * pNew, int * pTree, int nBits, int * pPerm, int iLate1, int iLate2 )
|
||||
{
|
||||
int iRes, iData1, iData2, iData, iCond, iCond2;
|
||||
assert( iLate1 != iLate2 );
|
||||
assert( iLate1 >= 0 && iLate1 < (1<<nBits) );
|
||||
assert( iLate2 >= 0 && iLate2 < (1<<nBits) );
|
||||
iData1 = pTree[nBits+iLate1];
|
||||
iData2 = pTree[nBits+iLate2];
|
||||
pTree[nBits+iLate1] = pTree[nBits+(iLate1^1)];
|
||||
pTree[nBits+iLate2] = pTree[nBits+(iLate2^1)];
|
||||
iRes = Gia_ManMuxTree_rec( pNew, pTree, nBits, pTree+nBits );
|
||||
iCond = Gia_ManHashOr( pNew, Gia_ManCube(pNew, iLate1, nBits, pTree), Gia_ManCube(pNew, iLate2, nBits, pTree) );
|
||||
iCond2 = Gia_ManFindCond( pTree, nBits, iLate1, iLate2 );
|
||||
iData = Gia_ManHashMux( pNew, iCond2, iData2, iData1 );
|
||||
return Gia_ManHashMux( pNew, iCond, iData, iRes );
|
||||
}
|
||||
int Gia_ManDecompThree( Gia_Man_t * pNew, int * pTree, int nBits, int * pPerm, int iLate1, int iLate2, int iLate3 )
|
||||
{
|
||||
int iRes, iData1, iData2, iData3, iCube1, iCube2, iCube3, iCtrl0, iCtrl1, iMux10, iMux11;
|
||||
assert( iLate1 != iLate2 );
|
||||
assert( iLate1 != iLate3 );
|
||||
assert( iLate2 != iLate3 );
|
||||
assert( iLate1 >= 0 && iLate1 < (1<<nBits) );
|
||||
assert( iLate2 >= 0 && iLate2 < (1<<nBits) );
|
||||
assert( iLate3 >= 0 && iLate3 < (1<<nBits) );
|
||||
iData1 = pTree[nBits+iLate1];
|
||||
iData2 = pTree[nBits+iLate2];
|
||||
iData3 = pTree[nBits+iLate3];
|
||||
pTree[nBits+iLate1] = pTree[nBits+(iLate1^1)];
|
||||
pTree[nBits+iLate2] = pTree[nBits+(iLate2^1)];
|
||||
pTree[nBits+iLate3] = pTree[nBits+(iLate3^1)];
|
||||
iRes = Gia_ManMuxTree_rec( pNew, pTree, nBits, pTree+nBits );
|
||||
iCube1 = Gia_ManCube( pNew, iLate1, nBits, pTree );
|
||||
iCube2 = Gia_ManCube( pNew, iLate2, nBits, pTree );
|
||||
iCube3 = Gia_ManCube( pNew, iLate3, nBits, pTree );
|
||||
iCtrl0 = Gia_ManHashOr( pNew, iCube1, iCube3 );
|
||||
iCtrl1 = Gia_ManHashOr( pNew, iCube2, iCube3 );
|
||||
iMux10 = Gia_ManHashMux( pNew, iCtrl0, iData1, iRes );
|
||||
iMux11 = Gia_ManHashMux( pNew, iCtrl0, iData3, iData2 );
|
||||
return Gia_ManHashMux( pNew, iCtrl1, iMux11, iMux10 );
|
||||
}
|
||||
int Gia_ManDecomp( Gia_Man_t * pNew, int * pTree, int nBits, int * pPerm )
|
||||
{
|
||||
if ( nBits == 2 )
|
||||
return Gia_ManMuxTree_rec( pNew, pTree, nBits, pTree+nBits );
|
||||
else
|
||||
{
|
||||
int iBase = Gia_ManEarliest( pPerm+nBits, 1<<nBits ), BaseValue = pPerm[nBits+iBase];
|
||||
int iLate1 = Gia_ManLatest( pPerm+nBits, 1<<nBits, -1, -1, -1 );
|
||||
int iLate2 = Gia_ManLatest( pPerm+nBits, 1<<nBits, iLate1, -1, -1 );
|
||||
int iLate3 = Gia_ManLatest( pPerm+nBits, 1<<nBits, iLate1, iLate2, -1 );
|
||||
int iLate4 = Gia_ManLatest( pPerm+nBits, 1<<nBits, iLate1, iLate2, iLate3 );
|
||||
if ( 0 )
|
||||
{
|
||||
int i;
|
||||
for ( i = 0; i < (1<<nBits); i++ )
|
||||
printf( "%d ", pPerm[nBits+i] );
|
||||
printf( "\n" );
|
||||
}
|
||||
if ( pPerm[nBits+iLate1] > BaseValue && pPerm[nBits+iLate2] > BaseValue && pPerm[nBits+iLate3] > BaseValue && pPerm[nBits+iLate4] == BaseValue )
|
||||
return Gia_ManDecompThree( pNew, pTree, nBits, pPerm, iLate1, iLate2, iLate3 );
|
||||
if ( pPerm[nBits+iLate1] > BaseValue && pPerm[nBits+iLate2] > BaseValue && pPerm[nBits+iLate3] == BaseValue )
|
||||
return Gia_ManDecompTwo( pNew, pTree, nBits, pPerm, iLate1, iLate2 );
|
||||
if ( pPerm[nBits+iLate1] > BaseValue && pPerm[nBits+iLate2] == BaseValue )
|
||||
return Gia_ManDecompOne( pNew, pTree, nBits, pPerm, iLate1 );
|
||||
return Gia_ManMuxTree_rec( pNew, pTree, nBits, pTree+nBits );
|
||||
}
|
||||
}
|
||||
Gia_Man_t * Gia_ManMuxTreeTest( int nBits )
|
||||
{
|
||||
Gia_Man_t * pNew;
|
||||
int i, iLit, nVars = nBits + (1 << nBits);
|
||||
int * pPerm, * pTree = Gia_ManCollectLiterals( nVars );
|
||||
pNew = Gia_ManStart( 1000 );
|
||||
pNew->pName = Abc_UtilStrsav( "mux_tree" );
|
||||
for ( i = 0; i < nVars; i++ )
|
||||
Gia_ManAppendCi( pNew );
|
||||
Gia_ManHashAlloc( pNew );
|
||||
pPerm = Gia_ManGenPerm( nVars );
|
||||
//pPerm = Gia_ManGenZero( nVars );
|
||||
pPerm[nBits+1] = 100;
|
||||
pPerm[nBits+5] = 100;
|
||||
pPerm[nBits+4] = 100;
|
||||
Gia_ManUsePerm( pTree, nBits, pPerm );
|
||||
iLit = Gia_ManDecomp( pNew, pTree, nBits, pPerm );
|
||||
Gia_ManAppendCo( pNew, iLit );
|
||||
ABC_FREE( pPerm );
|
||||
ABC_FREE( pTree );
|
||||
return pNew;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ ABC_NAMESPACE_IMPL_START
|
|||
extern int Kit_TruthToGia( Gia_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory, Vec_Int_t * vLeaves, int fHash );
|
||||
extern int Abc_RecToGia3( Gia_Man_t * pMan, If_Man_t * pIfMan, If_Cut_t * pCut, Vec_Int_t * vLeaves, int fHash );
|
||||
|
||||
extern void Gia_ManPrintGetMuxFanins( Gia_Man_t * p, Gia_Obj_t * pObj, int * pFanins );
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// FUNCTION DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -200,6 +202,7 @@ int Gia_ManLutLevel( Gia_Man_t * p, int ** ppLevels )
|
|||
***********************************************************************/
|
||||
void Gia_ManLutParams( Gia_Man_t * p, int * pnCurLuts, int * pnCurEdges, int * pnCurLevels )
|
||||
{
|
||||
int fDisable2Lut = 1;
|
||||
if ( p->pManTime && Tim_ManBoxNum((Tim_Man_t *)p->pManTime) )
|
||||
{
|
||||
int i;
|
||||
|
|
@ -219,20 +222,37 @@ void Gia_ManLutParams( Gia_Man_t * p, int * pnCurLuts, int * pnCurEdges, int * p
|
|||
int * pLevels = ABC_CALLOC( int, Gia_ManObjNum(p) );
|
||||
*pnCurLuts = 0;
|
||||
*pnCurEdges = 0;
|
||||
*pnCurLevels = 0;
|
||||
Gia_ManForEachLut( p, i )
|
||||
{
|
||||
int Level = 0;
|
||||
if ( Gia_ObjLutIsMux(p, i) && !(fDisable2Lut && Gia_ObjLutSize(p, i) == 2) )
|
||||
{
|
||||
int pFanins[3];
|
||||
if ( Gia_ObjLutSize(p, i) == 3 )
|
||||
{
|
||||
Gia_ManPrintGetMuxFanins( p, Gia_ManObj(p, i), pFanins );
|
||||
pLevels[i] = Abc_MaxInt( pLevels[i], pLevels[pFanins[0]]+1 );
|
||||
pLevels[i] = Abc_MaxInt( pLevels[i], pLevels[pFanins[1]] );
|
||||
pLevels[i] = Abc_MaxInt( pLevels[i], pLevels[pFanins[2]] );
|
||||
}
|
||||
else if ( Gia_ObjLutSize(p, i) == 2 )
|
||||
{
|
||||
pObj = Gia_ManObj( p, i );
|
||||
pLevels[i] = Abc_MaxInt( pLevels[i], pLevels[Gia_ObjFaninId0(pObj, i)] );
|
||||
pLevels[i] = Abc_MaxInt( pLevels[i], pLevels[Gia_ObjFaninId1(pObj, i)] );
|
||||
}
|
||||
*pnCurLevels = Abc_MaxInt( *pnCurLevels, pLevels[i] );
|
||||
(*pnCurEdges)++;
|
||||
//nMuxF++;
|
||||
continue;
|
||||
}
|
||||
(*pnCurLuts)++;
|
||||
(*pnCurEdges) += Gia_ObjLutSize(p, i);
|
||||
Gia_LutForEachFanin( p, i, iFan, k )
|
||||
if ( Level < pLevels[iFan] )
|
||||
Level = pLevels[iFan];
|
||||
pLevels[i] = Level + 1;
|
||||
pLevels[i] = Abc_MaxInt( pLevels[i], pLevels[iFan] );
|
||||
pLevels[i]++;
|
||||
*pnCurLevels = Abc_MaxInt( *pnCurLevels, pLevels[i] );
|
||||
}
|
||||
*pnCurLevels = 0;
|
||||
Gia_ManForEachCo( p, pObj, k )
|
||||
if ( *pnCurLevels < pLevels[Gia_ObjFaninId0p(p, pObj)] )
|
||||
*pnCurLevels = pLevels[Gia_ObjFaninId0p(p, pObj)];
|
||||
ABC_FREE( pLevels );
|
||||
}
|
||||
}
|
||||
|
|
@ -452,6 +472,7 @@ int Gia_ManCountDupLut( Gia_Man_t * p )
|
|||
|
||||
void Gia_ManPrintMappingStats( Gia_Man_t * p, char * pDumpFile )
|
||||
{
|
||||
int fDisable2Lut = 1;
|
||||
Gia_Obj_t * pObj;
|
||||
int * pLevels;
|
||||
int i, k, iFan, nLutSize = 0, nLuts = 0, nFanins = 0, LevelMax = 0, Ave = 0, nMuxF = 0;
|
||||
|
|
@ -460,7 +481,7 @@ void Gia_ManPrintMappingStats( Gia_Man_t * p, char * pDumpFile )
|
|||
pLevels = ABC_CALLOC( int, Gia_ManObjNum(p) );
|
||||
Gia_ManForEachLut( p, i )
|
||||
{
|
||||
if ( Gia_ObjLutIsMux(p, i) )
|
||||
if ( Gia_ObjLutIsMux(p, i) && !(fDisable2Lut && Gia_ObjLutSize(p, i) == 2) )
|
||||
{
|
||||
int pFanins[3];
|
||||
if ( Gia_ObjLutSize(p, i) == 3 )
|
||||
|
|
@ -756,6 +777,43 @@ int Gia_ManChoiceLevel( Gia_Man_t * p )
|
|||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Checks integrity of choice nodes.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void If_ManCheckChoices_rec( If_Man_t * pIfMan, If_Obj_t * pIfObj )
|
||||
{
|
||||
if ( !pIfObj || pIfObj->Type != IF_AND || pIfObj->fDriver )
|
||||
return;
|
||||
pIfObj->fDriver = 1;
|
||||
If_ManCheckChoices_rec( pIfMan, If_ObjFanin0(pIfObj) );
|
||||
If_ManCheckChoices_rec( pIfMan, If_ObjFanin1(pIfObj) );
|
||||
If_ManCheckChoices_rec( pIfMan, pIfObj->pEquiv );
|
||||
}
|
||||
void If_ManCheckChoices( If_Man_t * pIfMan )
|
||||
{
|
||||
If_Obj_t * pIfObj;
|
||||
int i, fFound = 0;
|
||||
If_ManForEachObj( pIfMan, pIfObj, i )
|
||||
pIfObj->fDriver = 0;
|
||||
If_ManForEachCo( pIfMan, pIfObj, i )
|
||||
If_ManCheckChoices_rec( pIfMan, If_ObjFanin0(pIfObj) );
|
||||
If_ManForEachNode( pIfMan, pIfObj, i )
|
||||
if ( !pIfObj->fDriver )
|
||||
printf( "Object %d is dangling.\n", i ), fFound = 1;
|
||||
if ( !fFound )
|
||||
printf( "There are no dangling objects.\n" );
|
||||
If_ManForEachObj( pIfMan, pIfObj, i )
|
||||
pIfObj->fDriver = 0;
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
|
|
@ -824,6 +882,7 @@ If_Man_t * Gia_ManToIf( Gia_Man_t * p, If_Par_t * pPars )
|
|||
}
|
||||
if ( Gia_ManHasChoices(p) )
|
||||
Gia_ManCleanMark0( p );
|
||||
//If_ManCheckChoices( pIfMan );
|
||||
return pIfMan;
|
||||
}
|
||||
|
||||
|
|
@ -1987,6 +2046,7 @@ Gia_Man_t * Gia_ManFromIfLogic( If_Man_t * pIfMan )
|
|||
pFile = fopen( Buffer, "wb" );
|
||||
if ( pFile == NULL )
|
||||
{
|
||||
Vec_StrFree( vConfigsStr );
|
||||
printf( "Cannot open file \"%s\".\n", Buffer );
|
||||
return pNew;
|
||||
}
|
||||
|
|
@ -2162,10 +2222,11 @@ void Gia_ManTransferTiming( Gia_Man_t * p, Gia_Man_t * pGia )
|
|||
p->DefOutReqs = pGia->DefOutReqs;
|
||||
p->And2Delay = pGia->And2Delay;
|
||||
}
|
||||
if ( pGia->vNamesIn || pGia->vNamesOut )
|
||||
if ( pGia->vNamesIn || pGia->vNamesOut || pGia->vNamesNode )
|
||||
{
|
||||
p->vNamesIn = pGia->vNamesIn; pGia->vNamesIn = NULL;
|
||||
p->vNamesOut = pGia->vNamesOut; pGia->vNamesOut = NULL;
|
||||
p->vNamesNode = pGia->vNamesNode; pGia->vNamesNode = NULL;
|
||||
}
|
||||
if ( pGia->vConfigs || pGia->pCellStr )
|
||||
{
|
||||
|
|
@ -2357,6 +2418,7 @@ Gia_Man_t * Gia_ManPerformMappingInt( Gia_Man_t * p, If_Par_t * pPars )
|
|||
// transfer name
|
||||
assert( pNew->pName == NULL );
|
||||
pNew->pName = Abc_UtilStrsav( p->pName );
|
||||
ABC_FREE( pNew->pSpec );
|
||||
pNew->pSpec = Abc_UtilStrsav( p->pSpec );
|
||||
Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
|
||||
// print delay trace
|
||||
|
|
|
|||
|
|
@ -894,7 +894,7 @@ void Gia_ManFindCaninicalOrder( Gia_Man_t * p, Vec_Int_t * vCis, Vec_Int_t * vAn
|
|||
Vec_PtrClear( vTemp );
|
||||
Gia_ManForEachPi( p, pObj, i )
|
||||
Vec_PtrPush( vTemp, pObj );
|
||||
Vec_PtrSort( vTemp, (int (*)(void))Gia_ObjCompareByValue );
|
||||
Vec_PtrSort( vTemp, (int (*)(const void *, const void *))Gia_ObjCompareByValue );
|
||||
// create the result
|
||||
Vec_PtrForEachEntry( Gia_Obj_t *, vTemp, pObj, i )
|
||||
Vec_IntPush( vCis, Gia_ObjId(p, pObj) );
|
||||
|
|
@ -917,7 +917,7 @@ void Gia_ManFindCaninicalOrder( Gia_Man_t * p, Vec_Int_t * vCis, Vec_Int_t * vAn
|
|||
pObj->Value = Abc_Var2Lit( Gia_ObjFanin0(pObj)->Value, Gia_ObjFaninC0(pObj) );
|
||||
Vec_PtrPush( vTemp, pObj );
|
||||
}
|
||||
Vec_PtrSort( vTemp, (int (*)(void))Gia_ObjCompareByValue );
|
||||
Vec_PtrSort( vTemp, (int (*)(const void *, const void *))Gia_ObjCompareByValue );
|
||||
Vec_PtrForEachEntry( Gia_Obj_t *, vTemp, pObj, i )
|
||||
Vec_IntPush( vCos, Gia_ObjId(p, pObj) );
|
||||
}
|
||||
|
|
@ -926,7 +926,7 @@ void Gia_ManFindCaninicalOrder( Gia_Man_t * p, Vec_Int_t * vCis, Vec_Int_t * vAn
|
|||
Vec_PtrClear( vTemp );
|
||||
Gia_ManForEachRo( p, pObj, i )
|
||||
Vec_PtrPush( vTemp, pObj );
|
||||
Vec_PtrSort( vTemp, (int (*)(void))Gia_ObjCompareByValue );
|
||||
Vec_PtrSort( vTemp, (int (*)(const void *, const void *))Gia_ObjCompareByValue );
|
||||
// create the result
|
||||
Vec_PtrForEachEntry( Gia_Obj_t *, vTemp, pObj, i )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -328,7 +328,7 @@ int Gia_Iso2ManUniqify( Gia_Iso2Man_t * p )
|
|||
}
|
||||
Vec_IntShrink( p->vTied, k );
|
||||
// sort singletons
|
||||
Vec_PtrSort( p->vSingles, (int (*)(void))Gia_ObjCompareByValue2 );
|
||||
Vec_PtrSort( p->vSingles, (int (*)(const void *, const void *))Gia_ObjCompareByValue2 );
|
||||
// add them to unique and increment signature
|
||||
Vec_PtrForEachEntry( Gia_Obj_t *, p->vSingles, pObj, i )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -158,6 +158,97 @@ void Gia_Iso3Test( Gia_Man_t * p )
|
|||
Vec_IntFreeP( &vSign );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Vec_Wec_t * Gia_Iso4Gia( Gia_Man_t * p )
|
||||
{
|
||||
Vec_Wec_t * vLevs = Gia_ManLevelizeR( p );
|
||||
Vec_Int_t * vLevel; int l;
|
||||
Abc_Random( 1 );
|
||||
Vec_WecForEachLevel( vLevs, vLevel, l )
|
||||
{
|
||||
Gia_Obj_t * pObj; int i;
|
||||
int RandC[2] = { Abc_Random(0), Abc_Random(0) };
|
||||
if ( l == 0 )
|
||||
{
|
||||
Gia_ManForEachObjVec( vLevel, p, pObj, i )
|
||||
{
|
||||
assert( Gia_ObjIsCo(pObj) );
|
||||
pObj->Value = Abc_Random(0);
|
||||
Gia_ObjFanin0(pObj)->Value += pObj->Value + RandC[Gia_ObjFaninC0(pObj)];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Gia_ManForEachObjVec( vLevel, p, pObj, i ) if ( Gia_ObjIsAnd(pObj) )
|
||||
{
|
||||
Gia_ObjFanin0(pObj)->Value += pObj->Value + RandC[Gia_ObjFaninC0(pObj)];
|
||||
Gia_ObjFanin1(pObj)->Value += pObj->Value + RandC[Gia_ObjFaninC1(pObj)];
|
||||
}
|
||||
}
|
||||
}
|
||||
return vLevs;
|
||||
}
|
||||
void Gia_Iso4Test( Gia_Man_t * p )
|
||||
{
|
||||
Vec_Wec_t * vLevs = Gia_Iso4Gia( p );
|
||||
Vec_Int_t * vLevel; int l;
|
||||
Vec_WecForEachLevel( vLevs, vLevel, l )
|
||||
{
|
||||
Gia_Obj_t * pObj; int i;
|
||||
printf( "Level %d\n", l );
|
||||
Gia_ManForEachObjVec( vLevel, p, pObj, i )
|
||||
printf( "Obj = %5d. Value = %08x.\n", Gia_ObjId(p, pObj), pObj->Value );
|
||||
}
|
||||
Vec_WecFree( vLevs );
|
||||
}
|
||||
Vec_Int_t * Gia_IsoCollectData( Gia_Man_t * p, Vec_Int_t * vObjs )
|
||||
{
|
||||
Gia_Obj_t * pObj; int i;
|
||||
Vec_Int_t * vData = Vec_IntAlloc( Vec_IntSize(vObjs) );
|
||||
Gia_ManForEachObjVec( vObjs, p, pObj, i )
|
||||
Vec_IntPush( vData, pObj->Value );
|
||||
return vData;
|
||||
}
|
||||
void Gia_IsoCompareVecs( Gia_Man_t * pGia0, Vec_Wec_t * vLevs0, Gia_Man_t * pGia1, Vec_Wec_t * vLevs1 )
|
||||
{
|
||||
int i, Common, nLevels = Abc_MinInt( Vec_WecSize(vLevs0), Vec_WecSize(vLevs1) );
|
||||
Gia_ManPrintStats( pGia0, NULL );
|
||||
Gia_ManPrintStats( pGia1, NULL );
|
||||
printf( "Printing %d shared levels:\n", nLevels );
|
||||
for ( i = 0; i < nLevels; i++ )
|
||||
{
|
||||
Vec_Int_t * vLev0 = Vec_WecEntry(vLevs0, i);
|
||||
Vec_Int_t * vLev1 = Vec_WecEntry(vLevs1, i);
|
||||
Vec_Int_t * vData0 = Gia_IsoCollectData( pGia0, vLev0 );
|
||||
Vec_Int_t * vData1 = Gia_IsoCollectData( pGia1, vLev1 );
|
||||
Vec_IntSort( vData0, 0 );
|
||||
Vec_IntSort( vData1, 0 );
|
||||
Common = Vec_IntTwoCountCommon( vData0, vData1 );
|
||||
printf( "Level = %3d. One = %6d. Two = %6d. Common = %6d.\n",
|
||||
i, Vec_IntSize(vData0)-Common, Vec_IntSize(vData1)-Common, Common );
|
||||
Vec_IntFree( vData0 );
|
||||
Vec_IntFree( vData1 );
|
||||
}
|
||||
}
|
||||
void Gia_Iso4TestTwo( Gia_Man_t * pGia0, Gia_Man_t * pGia1 )
|
||||
{
|
||||
Vec_Wec_t * vLevs0 = Gia_Iso4Gia( pGia0 );
|
||||
Vec_Wec_t * vLevs1 = Gia_Iso4Gia( pGia1 );
|
||||
Gia_IsoCompareVecs( pGia0, vLevs0, pGia1, vLevs1 );
|
||||
Vec_WecFree( vLevs0 );
|
||||
Vec_WecFree( vLevs1 );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -81,8 +81,6 @@ Gia_Man_t * Gia_ManStart( int nObjsMax )
|
|||
***********************************************************************/
|
||||
void Gia_ManStop( Gia_Man_t * p )
|
||||
{
|
||||
extern void Gia_DatFree( Gia_Dat_t * p );
|
||||
Gia_DatFree( p->pUData );
|
||||
if ( p->vSeqModelVec )
|
||||
Vec_PtrFreeFree( p->vSeqModelVec );
|
||||
Gia_ManStaticFanoutStop( p );
|
||||
|
|
@ -90,11 +88,14 @@ void Gia_ManStop( Gia_Man_t * p )
|
|||
assert( p->pManTime == NULL );
|
||||
Vec_PtrFreeFree( p->vNamesIn );
|
||||
Vec_PtrFreeFree( p->vNamesOut );
|
||||
Vec_PtrFreeFree( p->vNamesNode );
|
||||
Vec_IntFreeP( &p->vSwitching );
|
||||
Vec_IntFreeP( &p->vSuper );
|
||||
Vec_IntFreeP( &p->vStore );
|
||||
Vec_IntFreeP( &p->vClassNew );
|
||||
Vec_IntFreeP( &p->vClassOld );
|
||||
Vec_IntFreeP( &p->vPats );
|
||||
Vec_BitFreeP( &p->vPolars );
|
||||
Vec_WrdFreeP( &p->vSims );
|
||||
Vec_WrdFreeP( &p->vSimsT );
|
||||
Vec_WrdFreeP( &p->vSimsPi );
|
||||
|
|
@ -129,6 +130,7 @@ void Gia_ManStop( Gia_Man_t * p )
|
|||
Vec_IntFreeP( &p->vVar2Obj );
|
||||
Vec_IntErase( &p->vCopiesTwo );
|
||||
Vec_IntErase( &p->vSuppVars );
|
||||
Vec_IntErase( &p->vVarMap );
|
||||
Vec_WrdFreeP( &p->vSuppWords );
|
||||
Vec_IntFreeP( &p->vTtNums );
|
||||
Vec_IntFreeP( &p->vTtNodes );
|
||||
|
|
@ -147,6 +149,7 @@ void Gia_ManStop( Gia_Man_t * p )
|
|||
Vec_IntFreeP( &p->vCoReqs );
|
||||
Vec_IntFreeP( &p->vCoArrs );
|
||||
Vec_IntFreeP( &p->vCoAttrs );
|
||||
Vec_IntFreeP( &p->vWeights );
|
||||
Gia_ManStopP( &p->pAigExtra );
|
||||
Vec_IntFree( p->vCis );
|
||||
Vec_IntFree( p->vCos );
|
||||
|
|
@ -201,6 +204,7 @@ double Gia_ManMemory( Gia_Man_t * p )
|
|||
Memory += Vec_FltMemory( p->vOutReqs );
|
||||
Memory += Vec_PtrMemory( p->vNamesIn );
|
||||
Memory += Vec_PtrMemory( p->vNamesOut );
|
||||
Memory += Vec_PtrMemory( p->vNamesNode );
|
||||
return Memory;
|
||||
}
|
||||
|
||||
|
|
@ -582,7 +586,7 @@ void Gia_ManPrintStats( Gia_Man_t * p, Gps_Par_t * pPars )
|
|||
Gia_ManPrintMappingStats( p, pPars ? pPars->pDumpFile : NULL );
|
||||
else if ( pPars && pPars->pDumpFile )
|
||||
Gia_ManLogAigStats( p, pPars->pDumpFile );
|
||||
if ( pPars && pPars->fNpn && Gia_ManHasMapping(p) && Gia_ManLutSizeMax(p) <= 4 )
|
||||
if ( pPars && pPars->fNpn && Gia_ManHasMapping(p) )
|
||||
Gia_ManPrintNpnClasses( p );
|
||||
if ( p->vPacking )
|
||||
Gia_ManPrintPackingStats( p );
|
||||
|
|
@ -1269,13 +1273,14 @@ void Gia_ManWriteNames( FILE * pFile, char c, int n, Vec_Ptr_t * vNames, int Sta
|
|||
fFirst = 0;
|
||||
}
|
||||
}
|
||||
void Gia_ManDumpVerilog( Gia_Man_t * p, char * pFileName, Vec_Int_t * vObjs )
|
||||
void Gia_ManDumpVerilog( Gia_Man_t * p, char * pFileName, Vec_Int_t * vObjs, int fVerBufs )
|
||||
{
|
||||
FILE * pFile;
|
||||
Gia_Obj_t * pObj;
|
||||
Vec_Bit_t * vInvs, * vUsed;
|
||||
int nDigits = Abc_Base10Log( Gia_ManObjNum(p) );
|
||||
int nDigits2 = Abc_Base10Log( Gia_ManPiNum(p) );
|
||||
int nDigits = Abc_Base10Log( Gia_ManObjNum(p) );
|
||||
int nDigitsI = Abc_Base10Log( Gia_ManPiNum(p) );
|
||||
int nDigitsO = Abc_Base10Log( Gia_ManPoNum(p) );
|
||||
int i, k, iObj;
|
||||
if ( Gia_ManRegNum(p) )
|
||||
{
|
||||
|
|
@ -1300,20 +1305,63 @@ void Gia_ManDumpVerilog( Gia_Man_t * p, char * pFileName, Vec_Int_t * vObjs )
|
|||
fprintf( pFile, "%c", p->pName[i] );
|
||||
else
|
||||
fprintf( pFile, "_" );
|
||||
fprintf( pFile, " (\n " );
|
||||
Gia_ManWriteNames( pFile, 'x', Gia_ManPiNum(p), p->vNamesIn, 4, 4, NULL );
|
||||
fprintf( pFile, ",\n " );
|
||||
|
||||
Gia_ManWriteNames( pFile, 'z', Gia_ManPoNum(p), p->vNamesOut, 4, 4, NULL );
|
||||
fprintf( pFile, "\n );\n\n" );
|
||||
if ( fVerBufs )
|
||||
{
|
||||
fprintf( pFile, " (\n " );
|
||||
Gia_ManWriteNames( pFile, 'a', Gia_ManPiNum(p), NULL, 4, 4, NULL );
|
||||
fprintf( pFile, ",\n " );
|
||||
|
||||
fprintf( pFile, " input " );
|
||||
Gia_ManWriteNames( pFile, 'x', Gia_ManPiNum(p), p->vNamesIn, 8, 4, NULL );
|
||||
fprintf( pFile, ";\n\n" );
|
||||
Gia_ManWriteNames( pFile, 'y', Gia_ManPoNum(p), NULL, 4, 4, NULL );
|
||||
fprintf( pFile, "\n );\n\n" );
|
||||
|
||||
fprintf( pFile, " output " );
|
||||
Gia_ManWriteNames( pFile, 'z', Gia_ManPoNum(p), p->vNamesOut, 9, 4, NULL );
|
||||
fprintf( pFile, ";\n\n" );
|
||||
fprintf( pFile, " input " );
|
||||
Gia_ManWriteNames( pFile, 'a', Gia_ManPiNum(p), NULL, 8, 4, NULL );
|
||||
fprintf( pFile, ";\n\n" );
|
||||
|
||||
fprintf( pFile, " output " );
|
||||
Gia_ManWriteNames( pFile, 'y', Gia_ManPoNum(p), NULL, 9, 4, NULL );
|
||||
fprintf( pFile, ";\n\n" );
|
||||
|
||||
fprintf( pFile, " wire " );
|
||||
Gia_ManWriteNames( pFile, 'x', Gia_ManPiNum(p), p->vNamesIn, 8, 4, NULL );
|
||||
fprintf( pFile, ";\n\n" );
|
||||
|
||||
fprintf( pFile, " wire " );
|
||||
Gia_ManWriteNames( pFile, 'z', Gia_ManPoNum(p), p->vNamesOut, 9, 4, NULL );
|
||||
fprintf( pFile, ";\n\n" );
|
||||
|
||||
Gia_ManForEachPi( p, pObj, i )
|
||||
{
|
||||
fprintf( pFile, " buf ( %s,", Gia_ObjGetDumpName(p->vNamesIn, 'x', i, nDigitsI) );
|
||||
fprintf( pFile, " %s );\n", Gia_ObjGetDumpName(NULL, 'a', i, nDigitsI) );
|
||||
}
|
||||
fprintf( pFile, "\n" );
|
||||
|
||||
Gia_ManForEachPo( p, pObj, i )
|
||||
{
|
||||
fprintf( pFile, " buf ( %s,", Gia_ObjGetDumpName(NULL, 'y', i, nDigitsO) );
|
||||
fprintf( pFile, " %s );\n", Gia_ObjGetDumpName(p->vNamesOut, 'z', i, nDigitsO) );
|
||||
}
|
||||
fprintf( pFile, "\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( pFile, " (\n " );
|
||||
Gia_ManWriteNames( pFile, 'x', Gia_ManPiNum(p), p->vNamesIn, 4, 4, NULL );
|
||||
fprintf( pFile, ",\n " );
|
||||
|
||||
Gia_ManWriteNames( pFile, 'z', Gia_ManPoNum(p), p->vNamesOut, 4, 4, NULL );
|
||||
fprintf( pFile, "\n );\n\n" );
|
||||
|
||||
fprintf( pFile, " input " );
|
||||
Gia_ManWriteNames( pFile, 'x', Gia_ManPiNum(p), p->vNamesIn, 8, 4, NULL );
|
||||
fprintf( pFile, ";\n\n" );
|
||||
|
||||
fprintf( pFile, " output " );
|
||||
Gia_ManWriteNames( pFile, 'z', Gia_ManPoNum(p), p->vNamesOut, 9, 4, NULL );
|
||||
fprintf( pFile, ";\n\n" );
|
||||
}
|
||||
|
||||
if ( Vec_BitCount(vUsed) )
|
||||
{
|
||||
|
|
@ -1337,7 +1385,7 @@ void Gia_ManDumpVerilog( Gia_Man_t * p, char * pFileName, Vec_Int_t * vObjs )
|
|||
fprintf( pFile, ";\n\n" );
|
||||
Vec_IntForEachEntry( vObjs, iObj, i )
|
||||
{
|
||||
fprintf( pFile, " buf( %s,", Gia_ObjGetDumpName(NULL, 'n', iObj, nDigits) );
|
||||
fprintf( pFile, " buf ( %s,", Gia_ObjGetDumpName(NULL, 'n', iObj, nDigits) );
|
||||
fprintf( pFile, " t_%d );\n", i );
|
||||
}
|
||||
fprintf( pFile, "\n" );
|
||||
|
|
@ -1348,13 +1396,13 @@ void Gia_ManDumpVerilog( Gia_Man_t * p, char * pFileName, Vec_Int_t * vObjs )
|
|||
{
|
||||
if ( Vec_BitEntry(vUsed, Gia_ObjId(p, pObj)) )
|
||||
{
|
||||
fprintf( pFile, " buf( %s,", Gia_ObjGetDumpName(NULL, 'n', Gia_ObjId(p, pObj), nDigits) );
|
||||
fprintf( pFile, " %s );\n", Gia_ObjGetDumpName(p->vNamesIn, 'x', i, nDigits2) );
|
||||
fprintf( pFile, " buf ( %s,", Gia_ObjGetDumpName(NULL, 'n', Gia_ObjId(p, pObj), nDigits) );
|
||||
fprintf( pFile, " %s );\n", Gia_ObjGetDumpName(p->vNamesIn, 'x', i, nDigitsI) );
|
||||
}
|
||||
if ( Vec_BitEntry(vInvs, Gia_ObjId(p, pObj)) )
|
||||
{
|
||||
fprintf( pFile, " not( %s,", Gia_ObjGetDumpName(NULL, 'i', Gia_ObjId(p, pObj), nDigits) );
|
||||
fprintf( pFile, " %s );\n", Gia_ObjGetDumpName(p->vNamesIn, 'x', i, nDigits2) );
|
||||
fprintf( pFile, " not ( %s,", Gia_ObjGetDumpName(NULL, 'i', Gia_ObjId(p, pObj), nDigits) );
|
||||
fprintf( pFile, " %s );\n", Gia_ObjGetDumpName(p->vNamesIn, 'x', i, nDigitsI) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1373,20 +1421,19 @@ void Gia_ManDumpVerilog( Gia_Man_t * p, char * pFileName, Vec_Int_t * vObjs )
|
|||
}
|
||||
if ( !fSkip )
|
||||
{
|
||||
fprintf( pFile, " and( %s,", Gia_ObjGetDumpName(NULL, 'n', i, nDigits) );
|
||||
fprintf( pFile, " and ( %s,", Gia_ObjGetDumpName(NULL, 'n', i, nDigits) );
|
||||
fprintf( pFile, " %s,", Gia_ObjGetDumpName(NULL, (char)(Gia_ObjFaninC0(pObj)? 'i':'n'), Gia_ObjFaninId0(pObj, i), nDigits) );
|
||||
fprintf( pFile, " %s );\n", Gia_ObjGetDumpName(NULL, (char)(Gia_ObjFaninC1(pObj)? 'i':'n'), Gia_ObjFaninId1(pObj, i), nDigits) );
|
||||
}
|
||||
if ( Vec_BitEntry(vInvs, i) )
|
||||
{
|
||||
fprintf( pFile, " not( %s,", Gia_ObjGetDumpName(NULL, 'i', i, nDigits) );
|
||||
fprintf( pFile, " not ( %s,", Gia_ObjGetDumpName(NULL, 'i', i, nDigits) );
|
||||
fprintf( pFile, " %s );\n", Gia_ObjGetDumpName(NULL, 'n', i, nDigits) );
|
||||
}
|
||||
}
|
||||
|
||||
// output drivers
|
||||
fprintf( pFile, "\n" );
|
||||
nDigits2 = Abc_Base10Log( Gia_ManPoNum(p) );
|
||||
Gia_ManForEachPo( p, pObj, i )
|
||||
{
|
||||
/*
|
||||
|
|
@ -1396,7 +1443,7 @@ void Gia_ManDumpVerilog( Gia_Man_t * p, char * pFileName, Vec_Int_t * vObjs )
|
|||
else
|
||||
fprintf( pFile, "%s;\n", Gia_ObjGetDumpName(NULL, (char)(Gia_ObjFaninC0(pObj)? 'i':'n'), Gia_ObjFaninId0p(p, pObj), nDigits) );
|
||||
*/
|
||||
fprintf( pFile, " buf( %s, ", Gia_ObjGetDumpName(p->vNamesOut, 'z', i, nDigits2) );
|
||||
fprintf( pFile, " buf ( %s, ", Gia_ObjGetDumpName(p->vNamesOut, 'z', i, nDigitsO) );
|
||||
if ( Gia_ObjIsConst0(Gia_ObjFanin0(pObj)) )
|
||||
fprintf( pFile, "1\'b%d );\n", Gia_ObjFaninC0(pObj) );
|
||||
else
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include "misc/extra/extra.h"
|
||||
#include "sat/cnf/cnf.h"
|
||||
#include "opt/dau/dau.h"
|
||||
#include "bool/kit/kit.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
|
|
@ -557,8 +558,8 @@ static inline int Mf_CutComputeTruth6( Mf_Man_t * p, Mf_Cut_t * pCut0, Mf_Cut_t
|
|||
assert( (int)(t & 1) == 0 );
|
||||
truthId = Vec_MemHashInsert(p->vTtMem, &t);
|
||||
pCutR->iFunc = Abc_Var2Lit( truthId, fCompl );
|
||||
if ( p->pPars->fGenCnf && truthId == Vec_IntSize(&p->vCnfSizes) )
|
||||
Vec_IntPush( &p->vCnfSizes, Abc_Tt6CnfSize(t, pCutR->nLeaves) );
|
||||
if ( (p->pPars->fGenCnf || p->pPars->fGenLit) && truthId == Vec_IntSize(&p->vCnfSizes) )
|
||||
Vec_IntPush( &p->vCnfSizes, p->pPars->fGenCnf ? Abc_Tt6CnfSize(t, pCutR->nLeaves) : Kit_TruthLitNum((unsigned *)&t, pCutR->nLeaves, &p->vCnfMem) );
|
||||
// p->nCutMux += Mf_ManTtIsMux( t );
|
||||
assert( (int)pCutR->nLeaves <= nOldSupp );
|
||||
// Mf_ManTruthCanonicize( &t, pCutR->nLeaves );
|
||||
|
|
@ -588,8 +589,8 @@ static inline int Mf_CutComputeTruth( Mf_Man_t * p, Mf_Cut_t * pCut0, Mf_Cut_t *
|
|||
//Kit_DsdPrintFromTruth( uTruth, pCutR->nLeaves ), printf("\n" ), printf("\n" );
|
||||
truthId = Vec_MemHashInsert(p->vTtMem, uTruth);
|
||||
pCutR->iFunc = Abc_Var2Lit( truthId, fCompl );
|
||||
if ( p->pPars->fGenCnf && truthId == Vec_IntSize(&p->vCnfSizes) && LutSize <= 8 )
|
||||
Vec_IntPush( &p->vCnfSizes, Abc_Tt8CnfSize(uTruth, pCutR->nLeaves) );
|
||||
if ( (p->pPars->fGenCnf || p->pPars->fGenLit) && truthId == Vec_IntSize(&p->vCnfSizes) && LutSize <= 8 )
|
||||
Vec_IntPush( &p->vCnfSizes, p->pPars->fGenCnf ? Abc_Tt8CnfSize(uTruth, pCutR->nLeaves) : Kit_TruthLitNum((unsigned *)uTruth, pCutR->nLeaves, &p->vCnfMem) );
|
||||
assert( (int)pCutR->nLeaves <= nOldSupp );
|
||||
return (int)pCutR->nLeaves < nOldSupp;
|
||||
}
|
||||
|
|
@ -612,8 +613,8 @@ static inline int Mf_CutComputeTruthMux6( Mf_Man_t * p, Mf_Cut_t * pCut0, Mf_Cut
|
|||
assert( (int)(t & 1) == 0 );
|
||||
truthId = Vec_MemHashInsert(p->vTtMem, &t);
|
||||
pCutR->iFunc = Abc_Var2Lit( truthId, fCompl );
|
||||
if ( p->pPars->fGenCnf && truthId == Vec_IntSize(&p->vCnfSizes) )
|
||||
Vec_IntPush( &p->vCnfSizes, Abc_Tt6CnfSize(t, pCutR->nLeaves) );
|
||||
if ( (p->pPars->fGenCnf || p->pPars->fGenLit) && truthId == Vec_IntSize(&p->vCnfSizes) )
|
||||
Vec_IntPush( &p->vCnfSizes, p->pPars->fGenCnf ? Abc_Tt6CnfSize(t, pCutR->nLeaves) : Kit_TruthLitNum((unsigned *)&t, pCutR->nLeaves, &p->vCnfMem) );
|
||||
assert( (int)pCutR->nLeaves <= nOldSupp );
|
||||
return (int)pCutR->nLeaves < nOldSupp;
|
||||
}
|
||||
|
|
@ -642,8 +643,8 @@ static inline int Mf_CutComputeTruthMux( Mf_Man_t * p, Mf_Cut_t * pCut0, Mf_Cut_
|
|||
assert( (uTruth[0] & 1) == 0 );
|
||||
truthId = Vec_MemHashInsert(p->vTtMem, uTruth);
|
||||
pCutR->iFunc = Abc_Var2Lit( truthId, fCompl );
|
||||
if ( p->pPars->fGenCnf && truthId == Vec_IntSize(&p->vCnfSizes) && LutSize <= 8 )
|
||||
Vec_IntPush( &p->vCnfSizes, Abc_Tt8CnfSize(uTruth, pCutR->nLeaves) );
|
||||
if ( (p->pPars->fGenCnf || p->pPars->fGenLit) && truthId == Vec_IntSize(&p->vCnfSizes) && LutSize <= 8 )
|
||||
Vec_IntPush( &p->vCnfSizes, p->pPars->fGenCnf ? Abc_Tt8CnfSize(uTruth, pCutR->nLeaves) : Kit_TruthLitNum((unsigned *)uTruth, pCutR->nLeaves, &p->vCnfMem) );
|
||||
assert( (int)pCutR->nLeaves <= nOldSupp );
|
||||
return (int)pCutR->nLeaves < nOldSupp;
|
||||
}
|
||||
|
|
@ -699,6 +700,8 @@ static inline void Mf_CutPrint( Mf_Man_t * p, Mf_Cut_t * pCut )
|
|||
{
|
||||
if ( p->pPars->fGenCnf )
|
||||
printf( "CNF = %2d ", Vec_IntEntry(&p->vCnfSizes, Abc_Lit2Var(pCut->iFunc)) );
|
||||
if ( p->pPars->fGenLit )
|
||||
printf( "Lit = %2d ", Vec_IntEntry(&p->vCnfSizes, Abc_Lit2Var(pCut->iFunc)) );
|
||||
Dau_DsdPrintFromTruth( Vec_MemReadEntry(p->vTtMem, Abc_Lit2Var(pCut->iFunc)), pCut->nLeaves );
|
||||
}
|
||||
else
|
||||
|
|
@ -998,7 +1001,7 @@ static inline int Mf_CutArea( Mf_Man_t * p, int nLeaves, int iFunc )
|
|||
{
|
||||
if ( nLeaves < 2 )
|
||||
return 0;
|
||||
if ( p->pPars->fGenCnf )
|
||||
if ( p->pPars->fGenCnf || p->pPars->fGenLit )
|
||||
return Vec_IntEntry(&p->vCnfSizes, Abc_Lit2Var(iFunc));
|
||||
if ( p->pPars->fOptEdge )
|
||||
return nLeaves + p->pPars->nAreaTuner;
|
||||
|
|
@ -1202,7 +1205,7 @@ int Mf_ManSetMapRefs( Mf_Man_t * p )
|
|||
Mf_ObjMapRefInc( p, pCut[k] );
|
||||
p->pPars->Edge += Mf_CutSize(pCut);
|
||||
p->pPars->Area++;
|
||||
if ( p->pPars->fGenCnf )
|
||||
if ( p->pPars->fGenCnf || p->pPars->fGenLit )
|
||||
p->pPars->Clause += Mf_CutArea(p, Mf_CutSize(pCut), Mf_CutFunc(pCut));
|
||||
}
|
||||
// blend references
|
||||
|
|
@ -1394,7 +1397,7 @@ Mf_Man_t * Mf_ManAlloc( Gia_Man_t * pGia, Jf_Par_t * pPars )
|
|||
p->pLfObjs = ABC_CALLOC( Mf_Obj_t, Gia_ManObjNum(pGia) );
|
||||
p->iCur = 2;
|
||||
Vec_PtrGrow( &p->vPages, 256 );
|
||||
if ( pPars->fGenCnf )
|
||||
if ( pPars->fGenCnf || pPars->fGenLit )
|
||||
{
|
||||
Vec_IntGrow( &p->vCnfSizes, 10000 );
|
||||
Vec_IntPush( &p->vCnfSizes, 1 );
|
||||
|
|
@ -1410,7 +1413,7 @@ Mf_Man_t * Mf_ManAlloc( Gia_Man_t * pGia, Jf_Par_t * pPars )
|
|||
}
|
||||
void Mf_ManFree( Mf_Man_t * p )
|
||||
{
|
||||
assert( !p->pPars->fGenCnf || Vec_IntSize(&p->vCnfSizes) == Vec_MemEntryNum(p->vTtMem) );
|
||||
assert( !p->pPars->fGenCnf || !p->pPars->fGenLit || Vec_IntSize(&p->vCnfSizes) == Vec_MemEntryNum(p->vTtMem) );
|
||||
if ( p->pPars->fCutMin )
|
||||
Vec_MemHashFree( p->vTtMem );
|
||||
if ( p->pPars->fCutMin )
|
||||
|
|
@ -1453,6 +1456,7 @@ void Mf_ManSetDefaultPars( Jf_Par_t * pPars )
|
|||
pPars->fCoarsen = 1;
|
||||
pPars->fCutMin = 0;
|
||||
pPars->fGenCnf = 0;
|
||||
pPars->fGenLit = 0;
|
||||
pPars->fPureAig = 0;
|
||||
pPars->fVerbose = 0;
|
||||
pPars->fVeryVerbose = 0;
|
||||
|
|
@ -1469,6 +1473,8 @@ void Mf_ManPrintStats( Mf_Man_t * p, char * pTitle )
|
|||
printf( "Edge =%9lu ", (long)p->pPars->Edge );
|
||||
if ( p->pPars->fGenCnf )
|
||||
printf( "CNF =%9lu ", (long)p->pPars->Clause );
|
||||
if ( p->pPars->fGenLit )
|
||||
printf( "FFL =%9lu ", (long)p->pPars->Clause );
|
||||
Abc_PrintTime( 1, "Time", Abc_Clock() - p->clkStart );
|
||||
fflush( stdout );
|
||||
}
|
||||
|
|
@ -1483,6 +1489,7 @@ void Mf_ManPrintInit( Mf_Man_t * p )
|
|||
printf( "CutMin = %d ", p->pPars->fCutMin );
|
||||
printf( "Coarse = %d ", p->pPars->fCoarsen );
|
||||
printf( "CNF = %d ", p->pPars->fGenCnf );
|
||||
printf( "FFL = %d ", p->pPars->fGenLit );
|
||||
printf( "\n" );
|
||||
printf( "Computing cuts...\r" );
|
||||
fflush( stdout );
|
||||
|
|
@ -1541,28 +1548,6 @@ void Mf_ManComputeCuts( Mf_Man_t * p )
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Mf_CutRef2_rec( Mf_Man_t * p, int * pCut, Vec_Int_t * vTemp, int Limit )
|
||||
{
|
||||
int i, Count = Mf_CutArea(p, Mf_CutSize(pCut), Mf_CutFunc(pCut));
|
||||
if ( Limit == 0 ) return Count;
|
||||
for ( i = 1; i <= Mf_CutSize(pCut); i++ )
|
||||
{
|
||||
Vec_IntPush( vTemp, pCut[i] );
|
||||
if ( !Mf_ObjMapRefInc(p, pCut[i]) && Mf_ManObj(p, pCut[i])->iCutSet )
|
||||
Count += Mf_CutRef2_rec( p, Mf_ObjCutBest(p, pCut[i]), vTemp, Limit-1 );
|
||||
}
|
||||
return Count;
|
||||
}
|
||||
static inline int Mf_CutAreaDerefed2( Mf_Man_t * p, int * pCut )
|
||||
{
|
||||
int Ela1, iObj, i;
|
||||
Vec_IntClear( &p->vTemp );
|
||||
Ela1 = Mf_CutRef2_rec( p, pCut, &p->vTemp, 8 );
|
||||
Vec_IntForEachEntry( &p->vTemp, iObj, i )
|
||||
Mf_ObjMapRefDec( p, iObj );
|
||||
return Ela1;
|
||||
}
|
||||
|
||||
int Mf_CutRef_rec( Mf_Man_t * p, int * pCut )
|
||||
{
|
||||
int i, Count = Mf_CutArea(p, Mf_CutSize(pCut), Mf_CutFunc(pCut));
|
||||
|
|
@ -1579,6 +1564,13 @@ int Mf_CutDeref_rec( Mf_Man_t * p, int * pCut )
|
|||
Count += Mf_CutDeref_rec( p, Mf_ObjCutBest(p, pCut[i]) );
|
||||
return Count;
|
||||
}
|
||||
static inline int Mf_CutAreaRefed( Mf_Man_t * p, int * pCut )
|
||||
{
|
||||
int Ela1 = Mf_CutDeref_rec( p, pCut );
|
||||
int Ela2 = Mf_CutRef_rec( p, pCut );
|
||||
assert( Ela1 == Ela2 );
|
||||
return Ela1;
|
||||
}
|
||||
static inline int Mf_CutAreaDerefed( Mf_Man_t * p, int * pCut )
|
||||
{
|
||||
int Ela1 = Mf_CutRef_rec( p, pCut );
|
||||
|
|
@ -1586,6 +1578,67 @@ static inline int Mf_CutAreaDerefed( Mf_Man_t * p, int * pCut )
|
|||
assert( Ela1 == Ela2 );
|
||||
return Ela1;
|
||||
}
|
||||
static inline int Mf_CutAreaMffc( Mf_Man_t * p, int iObj )
|
||||
{
|
||||
return Mf_ObjMapRefNum(p, iObj) ?
|
||||
Mf_CutAreaRefed (p, Mf_ObjCutBest(p, iObj)) :
|
||||
Mf_CutAreaDerefed(p, Mf_ObjCutBest(p, iObj));
|
||||
}
|
||||
|
||||
int Mf_CutRef2_rec( Mf_Man_t * p, int * pCut, Vec_Int_t * vTemp, int Limit )
|
||||
{
|
||||
int i, Count = Mf_CutArea(p, Mf_CutSize(pCut), Mf_CutFunc(pCut));
|
||||
if ( Limit == 0 ) return Count;
|
||||
for ( i = 1; i <= Mf_CutSize(pCut); i++ )
|
||||
{
|
||||
Vec_IntPush( vTemp, pCut[i] );
|
||||
if ( !Mf_ObjMapRefInc(p, pCut[i]) && Mf_ManObj(p, pCut[i])->iCutSet )
|
||||
Count += Mf_CutRef2_rec( p, Mf_ObjCutBest(p, pCut[i]), vTemp, Limit-1 );
|
||||
}
|
||||
return Count;
|
||||
}
|
||||
int Mf_CutDeref2_rec( Mf_Man_t * p, int * pCut, Vec_Int_t * vTemp, int Limit )
|
||||
{
|
||||
int i, Count = Mf_CutArea(p, Mf_CutSize(pCut), Mf_CutFunc(pCut));
|
||||
if ( Limit == 0 ) return Count;
|
||||
for ( i = 1; i <= Mf_CutSize(pCut); i++ )
|
||||
{
|
||||
Vec_IntPush( vTemp, pCut[i] );
|
||||
if ( !Mf_ObjMapRefDec(p, pCut[i]) && Mf_ManObj(p, pCut[i])->iCutSet )
|
||||
Count += Mf_CutDeref2_rec( p, Mf_ObjCutBest(p, pCut[i]), vTemp, Limit-1 );
|
||||
}
|
||||
return Count;
|
||||
}
|
||||
static inline int Mf_CutAreaRefed2( Mf_Man_t * p, int * pCut )
|
||||
{
|
||||
int Ela1, iObj, i;
|
||||
Vec_IntClear( &p->vTemp );
|
||||
Ela1 = Mf_CutDeref2_rec( p, pCut, &p->vTemp, 8 );
|
||||
Vec_IntForEachEntry( &p->vTemp, iObj, i )
|
||||
Mf_ObjMapRefInc( p, iObj );
|
||||
return Ela1;
|
||||
}
|
||||
static inline int Mf_CutAreaDerefed2( Mf_Man_t * p, int * pCut )
|
||||
{
|
||||
int Ela1, iObj, i;
|
||||
Vec_IntClear( &p->vTemp );
|
||||
Ela1 = Mf_CutRef2_rec( p, pCut, &p->vTemp, 8 );
|
||||
Vec_IntForEachEntry( &p->vTemp, iObj, i )
|
||||
Mf_ObjMapRefDec( p, iObj );
|
||||
return Ela1;
|
||||
}
|
||||
static inline int Mf_CutAreaRefed2Multi( Mf_Man_t * p, int iObj, int ** ppCuts, int nCuts )
|
||||
{
|
||||
int Ela1 = 0, iTemp, i;
|
||||
Vec_IntClear( &p->vTemp );
|
||||
for ( i = 0; i < nCuts; i++ )
|
||||
Ela1 += Mf_CutDeref2_rec( p, ppCuts[i], &p->vTemp, ABC_INFINITY );
|
||||
assert( Mf_ObjMapRefNum(p, iObj) == 0 );
|
||||
Vec_IntForEachEntry( &p->vTemp, iTemp, i )
|
||||
Mf_ObjMapRefInc( p, iTemp );
|
||||
return Ela1;
|
||||
}
|
||||
|
||||
static inline float Mf_CutFlow( Mf_Man_t * p, int * pCut, int * pTime )
|
||||
{
|
||||
Mf_Obj_t * pObj;
|
||||
|
|
@ -1633,6 +1686,120 @@ static inline void Mf_ObjComputeBestCut( Mf_Man_t * p, int iObj )
|
|||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Mf_ManMappingFromMapping( Mf_Man_t * p )
|
||||
{
|
||||
Gia_Man_t * pGia = p->pGia0;
|
||||
Gia_Obj_t * pObj;
|
||||
int i, iObj, Count = 0;
|
||||
Vec_Int_t * vMapping = Vec_IntAlloc( 3 * Gia_ManObjNum(pGia) );
|
||||
Vec_IntFill( vMapping, Gia_ManObjNum(pGia), 0 );
|
||||
Gia_ManForEachAnd( pGia, pObj, iObj )
|
||||
if ( Mf_ObjMapRefNum(p, iObj) )
|
||||
{
|
||||
int * pCut = Mf_ObjCutBest(p, iObj);
|
||||
Vec_IntWriteEntry( vMapping, iObj, Vec_IntSize(vMapping) );
|
||||
Vec_IntPush( vMapping, Mf_CutSize(pCut) );
|
||||
for ( i = 1; i <= Mf_CutSize(pCut); i++ )
|
||||
Vec_IntPush( vMapping, pCut[i] );
|
||||
Vec_IntPush( vMapping, iObj );
|
||||
Count++;
|
||||
}
|
||||
assert( pGia->vMapping == NULL );
|
||||
pGia->vMapping = vMapping;
|
||||
printf( "Mapping is %.2fx larger than AIG manager.\n", 1.0*Vec_IntSize(vMapping)/Gia_ManObjNum(pGia) );
|
||||
return Count;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Mf_ManPrintFanoutProfile( Mf_Man_t * p, Vec_Int_t * vFanCounts )
|
||||
{
|
||||
Gia_Man_t * pGia = p->pGia0;
|
||||
int i, Count, nMax = Vec_IntFindMax( vFanCounts );
|
||||
Vec_Int_t * vCounts = Vec_IntStart( nMax + 1 );
|
||||
Vec_IntForEachEntry( vFanCounts, Count, i )
|
||||
if ( Count && Gia_ObjIsAnd(Gia_ManObj(pGia, i)) )
|
||||
Vec_IntAddToEntry( vCounts, Count, 1 );
|
||||
printf( "\nFanout distribution for internal nodes:\n" );
|
||||
Vec_IntForEachEntry( vCounts, Count, i )
|
||||
if ( Count ) printf( "Fanout = %5d : Nodes = %5d.\n", i, Count );
|
||||
printf( "Total nodes with fanout = %d. Max fanout = %d.\n\n", Vec_IntCountPositive(vCounts), nMax );
|
||||
Vec_IntFree( vCounts );
|
||||
}
|
||||
int Mf_ManPrintMfccStats( Mf_Man_t * p, int iObj )
|
||||
{
|
||||
Gia_Man_t * pGia = p->pGia0;
|
||||
int Area;
|
||||
printf( "%5d : Level = %5d Refs = %5d Mffc = %5d\n",
|
||||
iObj, Gia_ObjLevelId(pGia, iObj), Mf_ObjMapRefNum(p, iObj), (Area = Mf_CutAreaMffc(p, iObj)) );
|
||||
return Area;
|
||||
}
|
||||
void Mf_ManOptimizationOne( Mf_Man_t * p, int iObj )
|
||||
{
|
||||
Gia_Man_t * pGia = p->pGia0;
|
||||
int * ppCuts[32], nCuts = 0;
|
||||
int iFanout, i, nAreaSum = 0, nAreaBest = 0;
|
||||
// skip pivots whose MFFC fanouts are pointed to by COs
|
||||
Gia_ObjForEachFanoutStaticId( pGia, iObj, iFanout, i )
|
||||
if ( Gia_ObjIsCo(Gia_ManObj(pGia, iFanout)) )
|
||||
return;
|
||||
// the pivot is used in the mapping as well as all of its fanouts
|
||||
assert( Mf_ObjMapRefNum(p, iObj) > 1 );
|
||||
Gia_ObjForEachFanoutStaticId( pGia, iObj, iFanout, i )
|
||||
assert( Mf_ObjMapRefNum(p, iFanout) > 0 );
|
||||
// print this pivot and its fanouts
|
||||
printf( "\nPivot node = %d\n", iObj );
|
||||
printf( "Pivot " ), Mf_ManPrintMfccStats( p, iObj );
|
||||
Gia_ObjForEachFanoutStaticId( pGia, iObj, iFanout, i )
|
||||
printf( "Node " ), nAreaSum += Mf_ManPrintMfccStats( p, iFanout );
|
||||
// calculate the shared MFFC
|
||||
Gia_ObjForEachFanoutStaticId( pGia, iObj, iFanout, i )
|
||||
Mf_ObjMapRefInc( p, iFanout );
|
||||
Gia_ObjForEachFanoutStaticId( pGia, iObj, iFanout, i )
|
||||
ppCuts[nCuts++] = Mf_ObjCutBest( p, iFanout );
|
||||
nAreaBest = Mf_CutAreaRefed2Multi( p, iObj, ppCuts, nCuts );
|
||||
Gia_ObjForEachFanoutStaticId( pGia, iObj, iFanout, i )
|
||||
Mf_ObjMapRefDec( p, iFanout );
|
||||
printf( "Sum of MFFC sizes = %d\n", nAreaSum );
|
||||
printf( "Shared MFFC size = %d\n", nAreaBest );
|
||||
}
|
||||
void Mf_ManOptimization( Mf_Man_t * p )
|
||||
{
|
||||
int nOutMax = 3;
|
||||
Gia_Man_t * pGia = p->pGia0;
|
||||
int i, Count, nNodes = Mf_ManMappingFromMapping( p );
|
||||
Gia_ManLevelNum( pGia );
|
||||
Gia_ManStaticMappingFanoutStart( pGia );
|
||||
Mf_ManPrintFanoutProfile( p, pGia->vFanoutNums );
|
||||
printf( "\nIndividual logic cones for mapping with %d nodes:\n", nNodes );
|
||||
Vec_IntForEachEntry( pGia->vFanoutNums, Count, i )
|
||||
if ( Count >= 2 && Count <= nOutMax && Gia_ObjIsAnd(Gia_ManObj(pGia, i)) )
|
||||
Mf_ManOptimizationOne( p, i );
|
||||
printf( "\nFinished printing individual logic cones.\n" );
|
||||
Gia_ManStaticFanoutStop( pGia );
|
||||
Vec_IntFreeP( &pGia->vMapping );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Technology mappping.]
|
||||
|
|
@ -1656,7 +1823,7 @@ Gia_Man_t * Mf_ManPerformMapping( Gia_Man_t * pGia, Jf_Par_t * pPars )
|
|||
{
|
||||
Mf_Man_t * p;
|
||||
Gia_Man_t * pNew, * pCls;
|
||||
if ( pPars->fGenCnf )
|
||||
if ( pPars->fGenCnf || pPars->fGenLit )
|
||||
pPars->fCutMin = 1;
|
||||
if ( Gia_ManHasChoices(pGia) )
|
||||
pPars->fCutMin = 1, pPars->fCoarsen = 0;
|
||||
|
|
@ -1675,6 +1842,7 @@ Gia_Man_t * Mf_ManPerformMapping( Gia_Man_t * pGia, Jf_Par_t * pPars )
|
|||
p->fUseEla = 1;
|
||||
for ( ; p->Iter < p->pPars->nRounds + pPars->nRoundsEla; p->Iter++ )
|
||||
Mf_ManComputeMapping( p );
|
||||
//Mf_ManOptimization( p );
|
||||
if ( pPars->fVeryVerbose && pPars->fCutMin )
|
||||
Vec_MemDumpTruthTables( p->vTtMem, Gia_ManName(p->pGia), pPars->nLutSize );
|
||||
if ( pPars->fCutMin )
|
||||
|
|
@ -1685,8 +1853,8 @@ Gia_Man_t * Mf_ManPerformMapping( Gia_Man_t * pGia, Jf_Par_t * pPars )
|
|||
pNew = Mf_ManDeriveMapping( p );
|
||||
if ( p->pPars->fGenCnf )
|
||||
pGia->pData = Mf_ManDeriveCnf( p, p->pPars->fCnfObjIds, p->pPars->fAddOrCla );
|
||||
// if ( p->pPars->fGenCnf )
|
||||
// Mf_ManProfileTruths( p );
|
||||
//if ( p->pPars->fGenCnf || p->pPars->fGenLit )
|
||||
// Mf_ManProfileTruths( p );
|
||||
Gia_ManMappingVerify( pNew );
|
||||
Mf_ManPrintQuit( p, pNew );
|
||||
Mf_ManFree( p );
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -32,6 +32,8 @@ ABC_NAMESPACE_IMPL_START
|
|||
/// DECLARATIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
extern int Kit_TruthToGia( Gia_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory, Vec_Int_t * vLeaves, int fHash );
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// FUNCTION DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -57,7 +59,7 @@ int Gia_ObjFromMiniFanin1Copy( Gia_Man_t * pGia, Vec_Int_t * vCopies, Mini_Aig_t
|
|||
int Lit = Mini_AigNodeFanin1( p, Id );
|
||||
return Abc_LitNotCond( Vec_IntEntry(vCopies, Abc_Lit2Var(Lit)), Abc_LitIsCompl(Lit) );
|
||||
}
|
||||
Gia_Man_t * Gia_ManFromMiniAig( Mini_Aig_t * p, Vec_Int_t ** pvCopies )
|
||||
Gia_Man_t * Gia_ManFromMiniAig( Mini_Aig_t * p, Vec_Int_t ** pvCopies, int fGiaSimple )
|
||||
{
|
||||
Gia_Man_t * pGia, * pTemp;
|
||||
Vec_Int_t * vCopies;
|
||||
|
|
@ -71,7 +73,10 @@ Gia_Man_t * Gia_ManFromMiniAig( Mini_Aig_t * p, Vec_Int_t ** pvCopies )
|
|||
vCopies = Vec_IntAlloc( nNodes );
|
||||
Vec_IntPush( vCopies, 0 );
|
||||
// iterate through the objects
|
||||
Gia_ManHashAlloc( pGia );
|
||||
if ( fGiaSimple )
|
||||
pGia->fGiaSimple = fGiaSimple;
|
||||
else
|
||||
Gia_ManHashAlloc( pGia );
|
||||
for ( i = 1; i < nNodes; i++ )
|
||||
{
|
||||
if ( Mini_AigNodeIsPi( p, i ) )
|
||||
|
|
@ -83,17 +88,19 @@ Gia_Man_t * Gia_ManFromMiniAig( Mini_Aig_t * p, Vec_Int_t ** pvCopies )
|
|||
else assert( 0 );
|
||||
Vec_IntPush( vCopies, iGiaLit );
|
||||
}
|
||||
Gia_ManHashStop( pGia );
|
||||
assert( Vec_IntSize(vCopies) == nNodes );
|
||||
if ( pvCopies )
|
||||
*pvCopies = vCopies;
|
||||
else
|
||||
Vec_IntFree( vCopies );
|
||||
Gia_ManSetRegNum( pGia, Mini_AigRegNum(p) );
|
||||
pGia = Gia_ManCleanup( pTemp = pGia );
|
||||
if ( pvCopies )
|
||||
Gia_ManDupRemapLiterals( *pvCopies, pTemp );
|
||||
Gia_ManStop( pTemp );
|
||||
if ( !fGiaSimple )
|
||||
{
|
||||
pGia = Gia_ManCleanup( pTemp = pGia );
|
||||
if ( pvCopies )
|
||||
Gia_ManDupRemapLiterals( *pvCopies, pTemp );
|
||||
Gia_ManStop( pTemp );
|
||||
}
|
||||
return pGia;
|
||||
}
|
||||
|
||||
|
|
@ -148,7 +155,7 @@ void Abc_FrameGiaInputMiniAig( Abc_Frame_t * pAbc, void * p )
|
|||
printf( "ABC framework is not initialized by calling Abc_Start()\n" );
|
||||
Gia_ManStopP( &pAbc->pGiaMiniAig );
|
||||
Vec_IntFreeP( &pAbc->vCopyMiniAig );
|
||||
pGia = Gia_ManFromMiniAig( (Mini_Aig_t *)p, &pAbc->vCopyMiniAig );
|
||||
pGia = Gia_ManFromMiniAig( (Mini_Aig_t *)p, &pAbc->vCopyMiniAig, 0 );
|
||||
Abc_FrameUpdateGia( pAbc, pGia );
|
||||
pAbc->pGiaMiniAig = Gia_ManDup( pGia );
|
||||
// Gia_ManDelete( pGia );
|
||||
|
|
@ -175,10 +182,10 @@ void * Abc_FrameGiaOutputMiniAig( Abc_Frame_t * pAbc )
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Gia_Man_t * Gia_ManReadMiniAig( char * pFileName )
|
||||
Gia_Man_t * Gia_ManReadMiniAig( char * pFileName, int fGiaSimple )
|
||||
{
|
||||
Mini_Aig_t * p = Mini_AigLoad( pFileName );
|
||||
Gia_Man_t * pGia = Gia_ManFromMiniAig( p, NULL );
|
||||
Gia_Man_t * pGia = Gia_ManFromMiniAig( p, NULL, fGiaSimple );
|
||||
ABC_FREE( pGia->pName );
|
||||
pGia->pName = Extra_FileNameGeneric( pFileName );
|
||||
Mini_AigStop( p );
|
||||
|
|
@ -260,6 +267,65 @@ Gia_Man_t * Gia_ManFromMiniLut( Mini_Lut_t * p, Vec_Int_t ** pvCopies )
|
|||
return pGia;
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Converts MiniLUT into GIA.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Gia_Man_t * Gia_ManFromMiniLut2( Mini_Lut_t * p, Vec_Int_t ** pvCopies )
|
||||
{
|
||||
Gia_Man_t * pGia;
|
||||
Vec_Int_t * vCopies;
|
||||
Vec_Int_t * vCover = Vec_IntAlloc( 1000 );
|
||||
Vec_Int_t * vLits = Vec_IntAlloc( 100 );
|
||||
int i, k, Fan, iGiaLit, nNodes;
|
||||
// get the number of nodes
|
||||
nNodes = Mini_LutNodeNum(p);
|
||||
// create ABC network
|
||||
pGia = Gia_ManStart( 3 * nNodes );
|
||||
pGia->pName = Abc_UtilStrsav( "MiniLut" );
|
||||
// create mapping from MiniLUT objects into ABC objects
|
||||
vCopies = Vec_IntAlloc( nNodes );
|
||||
Vec_IntPush( vCopies, 0 );
|
||||
Vec_IntPush( vCopies, 1 );
|
||||
// iterate through the objects
|
||||
pGia->fGiaSimple = 1;
|
||||
for ( i = 2; i < nNodes; i++ )
|
||||
{
|
||||
if ( Mini_LutNodeIsPi( p, i ) )
|
||||
iGiaLit = Gia_ManAppendCi(pGia);
|
||||
else if ( Mini_LutNodeIsPo( p, i ) )
|
||||
iGiaLit = Gia_ManAppendCo(pGia, Vec_IntEntry(vCopies, Mini_LutNodeFanin(p, i, 0)));
|
||||
else if ( Mini_LutNodeIsNode( p, i ) )
|
||||
{
|
||||
unsigned * puTruth = Mini_LutNodeTruth( p, i );
|
||||
Vec_IntClear( vLits );
|
||||
Mini_LutForEachFanin( p, i, Fan, k )
|
||||
Vec_IntPush( vLits, Vec_IntEntry(vCopies, Fan) );
|
||||
iGiaLit = Kit_TruthToGia( pGia, puTruth, Vec_IntSize(vLits), vCover, vLits, 0 );
|
||||
}
|
||||
else assert( 0 );
|
||||
Vec_IntPush( vCopies, iGiaLit );
|
||||
}
|
||||
Vec_IntFree( vCover );
|
||||
Vec_IntFree( vLits );
|
||||
assert( Vec_IntSize(vCopies) == nNodes );
|
||||
if ( pvCopies )
|
||||
*pvCopies = vCopies;
|
||||
else
|
||||
Vec_IntFree( vCopies );
|
||||
Gia_ManSetRegNum( pGia, Mini_LutRegNum(p) );
|
||||
return pGia;
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Marks LUTs that should be complemented.]
|
||||
|
|
@ -412,6 +478,15 @@ void Abc_FrameGiaInputMiniLut( Abc_Frame_t * pAbc, void * p )
|
|||
Abc_FrameUpdateGia( pAbc, pGia );
|
||||
// Gia_ManDelete( pGia );
|
||||
}
|
||||
void Abc_FrameGiaInputMiniLut2( Abc_Frame_t * pAbc, void * p )
|
||||
{
|
||||
if ( pAbc == NULL )
|
||||
printf( "ABC framework is not initialized by calling Abc_Start()\n" );
|
||||
Vec_IntFreeP( &pAbc->vCopyMiniLut );
|
||||
Gia_ManStopP( &pAbc->pGiaMiniLut );
|
||||
pAbc->pGiaMiniLut = Gia_ManFromMiniLut2( (Mini_Lut_t *)p, &pAbc->vCopyMiniLut );
|
||||
// Abc_FrameUpdateGia( pAbc, pGia );
|
||||
}
|
||||
void * Abc_FrameGiaOutputMiniLut( Abc_Frame_t * pAbc )
|
||||
{
|
||||
Mini_Lut_t * pRes = NULL;
|
||||
|
|
@ -589,6 +664,39 @@ int * Abc_FrameReadMiniLutNameMapping( Abc_Frame_t * pAbc )
|
|||
Gia_ManStop( pGia );
|
||||
return pRes;
|
||||
}
|
||||
int * Abc_FrameReadMiniLutSwitching( Abc_Frame_t * pAbc )
|
||||
{
|
||||
Vec_Int_t * vSwitching;
|
||||
int i, iObj, * pRes = NULL;
|
||||
if ( pAbc->pGiaMiniLut == NULL )
|
||||
{
|
||||
printf( "GIA derived from MiniLut is not available.\n" );
|
||||
return NULL;
|
||||
}
|
||||
vSwitching = Gia_ManComputeSwitchProbs( pAbc->pGiaMiniLut, 48, 16, 0 );
|
||||
pRes = ABC_CALLOC( int, Vec_IntSize(pAbc->vCopyMiniLut) );
|
||||
Vec_IntForEachEntry( pAbc->vCopyMiniLut, iObj, i )
|
||||
if ( iObj >= 0 )
|
||||
pRes[i] = (int)(10000*Vec_FltEntry( (Vec_Flt_t *)vSwitching, Abc_Lit2Var(iObj) ));
|
||||
Vec_IntFree( vSwitching );
|
||||
return pRes;
|
||||
}
|
||||
int * Abc_FrameReadMiniLutSwitchingPo( Abc_Frame_t * pAbc )
|
||||
{
|
||||
Vec_Int_t * vSwitching;
|
||||
int i, iObj, * pRes = NULL;
|
||||
if ( pAbc->pGiaMiniAig == NULL )
|
||||
{
|
||||
printf( "GIA derived from MiniAIG is not available.\n" );
|
||||
return NULL;
|
||||
}
|
||||
vSwitching = Gia_ManComputeSwitchProbs( pAbc->pGiaMiniAig, 48, 16, 0 );
|
||||
pRes = ABC_CALLOC( int, Gia_ManCoNum(pAbc->pGiaMiniAig) );
|
||||
Gia_ManForEachCoDriverId( pAbc->pGiaMiniAig, iObj, i )
|
||||
pRes[i] = (int)(10000*Vec_FltEntry( (Vec_Flt_t *)vSwitching, iObj ));
|
||||
Vec_IntFree( vSwitching );
|
||||
return pRes;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
|
|
@ -797,6 +905,274 @@ void Gia_MiniAigVerify( Abc_Frame_t * pAbc, char * pFileName )
|
|||
Mini_AigStop( p );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Collects supergate for the outputs.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_MiniAigSuperGates_rec( Mini_Aig_t * p, int iObj, Vec_Int_t * vRes, Vec_Int_t * vMap )
|
||||
{
|
||||
int iFan0, iFan1;
|
||||
if ( Mini_AigNodeIsPi(p, iObj) )
|
||||
{
|
||||
assert( Vec_IntEntry(vMap, iObj) >= 0 );
|
||||
Vec_IntPush( vRes, Vec_IntEntry(vMap, iObj) );
|
||||
return;
|
||||
}
|
||||
iFan0 = Mini_AigNodeFanin0( p, iObj );
|
||||
iFan1 = Mini_AigNodeFanin1( p, iObj );
|
||||
assert( !Abc_LitIsCompl(iFan0) );
|
||||
assert( !Abc_LitIsCompl(iFan1) );
|
||||
Gia_MiniAigSuperGates_rec( p, Abc_Lit2Var(iFan0), vRes, vMap );
|
||||
Gia_MiniAigSuperGates_rec( p, Abc_Lit2Var(iFan1), vRes, vMap );
|
||||
}
|
||||
Vec_Wec_t * Gia_MiniAigSuperGates( Mini_Aig_t * p )
|
||||
{
|
||||
Vec_Wec_t * vRes = Vec_WecStart( Mini_AigPoNum(p) );
|
||||
Vec_Int_t * vMap = Vec_IntStartFull( Mini_AigNodeNum(p) );
|
||||
int i, Index = 0;
|
||||
Mini_AigForEachPi( p, i )
|
||||
Vec_IntWriteEntry( vMap, i, Index++ );
|
||||
assert( Index == Mini_AigPiNum(p) );
|
||||
Index = 0;
|
||||
Mini_AigForEachPo( p, i )
|
||||
{
|
||||
int iFan0 = Mini_AigNodeFanin0( p, i );
|
||||
assert( !Abc_LitIsCompl(iFan0) );
|
||||
Gia_MiniAigSuperGates_rec( p, Abc_Lit2Var(iFan0), Vec_WecEntry(vRes, Index++), vMap );
|
||||
}
|
||||
assert( Index == Mini_AigPoNum(p) );
|
||||
Vec_IntFree( vMap );
|
||||
return vRes;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Transform.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_MiniAigSuperPrintDouble( Vec_Int_t * p, int nPis )
|
||||
{
|
||||
int i, Entry;
|
||||
printf( "\n" );
|
||||
Vec_IntForEachEntry( p, Entry, i )
|
||||
printf( "%d(%d) ", Entry%nPis, Entry/nPis );
|
||||
printf( " Total = %d\n", Vec_IntSize(p) );
|
||||
}
|
||||
int Gia_MiniAigSuperMerge( Vec_Int_t * p, int nPis )
|
||||
{
|
||||
int i, k = 0, This, Prev = -1, fChange = 0;
|
||||
Vec_IntForEachEntry( p, This, i )
|
||||
{
|
||||
if ( Prev == This )
|
||||
{
|
||||
Vec_IntWriteEntry( p, k++, (This/nPis+1)*nPis + This%nPis );
|
||||
Prev = -1;
|
||||
fChange = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( Prev != -1 )
|
||||
Vec_IntWriteEntry( p, k++, Prev );
|
||||
Prev = This;
|
||||
}
|
||||
}
|
||||
if ( Prev != -1 )
|
||||
Vec_IntWriteEntry( p, k++, Prev );
|
||||
Vec_IntShrink( p, k );
|
||||
return fChange;
|
||||
}
|
||||
int Gia_MiniAigSuperPreprocess( Mini_Aig_t * p, Vec_Wec_t * vSuper, int nPis, int fVerbose )
|
||||
{
|
||||
Vec_Int_t * vRes;
|
||||
int i, nIters, Multi = 1;
|
||||
Vec_WecForEachLevel( vSuper, vRes, i )
|
||||
{
|
||||
Vec_IntSort( vRes, 0 );
|
||||
if ( fVerbose )
|
||||
printf( "\nOutput %d\n", i );
|
||||
if ( fVerbose )
|
||||
Gia_MiniAigSuperPrintDouble( vRes, nPis );
|
||||
for ( nIters = 1; Gia_MiniAigSuperMerge(vRes, nPis); nIters++ )
|
||||
{
|
||||
if ( fVerbose )
|
||||
Gia_MiniAigSuperPrintDouble( vRes, nPis );
|
||||
}
|
||||
Multi = Abc_MaxInt( Multi, nIters );
|
||||
}
|
||||
if ( fVerbose )
|
||||
printf( "Multi = %d.\n", Multi );
|
||||
return Multi;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Derive AIG.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Gia_Man_t * Gia_MiniAigSuperDeriveGia( Vec_Wec_t * p, int nPis, int Multi )
|
||||
{
|
||||
Gia_Man_t * pNew;
|
||||
Vec_Int_t * vTemp, * vLits = Vec_IntAlloc( 100 );
|
||||
Vec_Int_t * vDrivers = Vec_IntAlloc(100);
|
||||
int i, k, iObj, iLit, nInputs = nPis*Multi;
|
||||
pNew = Gia_ManStart( 1000 );
|
||||
pNew->pName = Abc_UtilStrsav( "tree" );
|
||||
for ( i = 0; i < nInputs; i++ )
|
||||
Gia_ManAppendCi( pNew );
|
||||
Gia_ManHashAlloc( pNew );
|
||||
Vec_WecForEachLevel( p, vTemp, i )
|
||||
{
|
||||
Vec_IntClear( vLits );
|
||||
Vec_IntForEachEntry( vTemp, iObj, k )
|
||||
{
|
||||
assert( iObj < nInputs );
|
||||
Vec_IntPush( vLits, 2+2*((iObj%nPis)*Multi+iObj/nPis) );
|
||||
}
|
||||
Vec_IntPush( vDrivers, Gia_ManHashAndMulti2(pNew, vLits) );
|
||||
}
|
||||
Gia_ManHashStop( pNew );
|
||||
Vec_IntFree( vLits );
|
||||
Vec_IntForEachEntry( vDrivers, iLit, i )
|
||||
Gia_ManAppendCo( pNew, iLit );
|
||||
Vec_IntFree( vDrivers );
|
||||
return pNew;
|
||||
}
|
||||
Gia_Man_t * Gia_MiniAigSuperDerive( char * pFileName, int fVerbose )
|
||||
{
|
||||
Mini_Aig_t * p = Mini_AigLoad( pFileName );
|
||||
Vec_Wec_t * vSuper = Gia_MiniAigSuperGates( p );
|
||||
int Multi = Gia_MiniAigSuperPreprocess( p, vSuper, Mini_AigPiNum(p), fVerbose );
|
||||
Gia_Man_t * pNew = Gia_MiniAigSuperDeriveGia( vSuper, Mini_AigPiNum(p), Multi );
|
||||
Vec_WecFree( vSuper );
|
||||
Mini_AigStop( p );
|
||||
return pNew;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Process file.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Vec_Int_t * Gia_MiniAigProcessFile()
|
||||
{
|
||||
Vec_Int_t * vTriples = Vec_IntAlloc( 100 );
|
||||
char * pFileName = "test.txt";
|
||||
FILE * pFile = fopen( pFileName, "rb" );
|
||||
if ( pFile == NULL )
|
||||
printf( "Cannot open the file.\n" );
|
||||
else
|
||||
{
|
||||
int nLines = 0, nLinesAll = 0;
|
||||
char * pToken;
|
||||
char Buffer[1000];
|
||||
while ( fgets( Buffer, 1000, pFile ) != NULL )
|
||||
{
|
||||
nLinesAll++;
|
||||
if ( Buffer[0] != '#' )
|
||||
continue;
|
||||
//printf( "%s", Buffer );
|
||||
nLines++;
|
||||
pToken = strtok( Buffer+3, " \r\n\r+=" );
|
||||
while ( pToken )
|
||||
{
|
||||
Vec_IntPush( vTriples, atoi(pToken) );
|
||||
pToken = strtok( NULL, " \r\n\r+=" );
|
||||
}
|
||||
}
|
||||
fclose( pFile );
|
||||
printf( "Collected %d (out of %d) lines.\n", nLines, nLinesAll );
|
||||
printf( "Entries = %d\n", Vec_IntSize(vTriples) );
|
||||
}
|
||||
return vTriples;
|
||||
}
|
||||
void Gia_MiniAigGenerate_rec( Mini_Aig_t * p, Vec_Int_t * vTriples, int iObj, Vec_Int_t * vDefs, Vec_Int_t * vMap )
|
||||
{
|
||||
int Index, Entry0, Entry1, Entry2, Value;
|
||||
if ( Vec_IntEntry(vMap, iObj) >= 0 )
|
||||
return;
|
||||
Index = Vec_IntEntry( vDefs, iObj );
|
||||
Entry0 = Vec_IntEntry( vTriples, 3*Index+0 );
|
||||
Entry1 = Vec_IntEntry( vTriples, 3*Index+1 );
|
||||
Entry2 = Vec_IntEntry( vTriples, 3*Index+2 );
|
||||
Gia_MiniAigGenerate_rec( p, vTriples, Entry1, vDefs, vMap );
|
||||
Gia_MiniAigGenerate_rec( p, vTriples, Entry2, vDefs, vMap );
|
||||
assert( Vec_IntEntry(vMap, Entry1) >= 0 );
|
||||
assert( Vec_IntEntry(vMap, Entry2) >= 0 );
|
||||
Value = Mini_AigAnd( p, Vec_IntEntry(vMap, Entry1), Vec_IntEntry(vMap, Entry2) );
|
||||
Vec_IntWriteEntry( vMap, Entry0, Value );
|
||||
}
|
||||
void Gia_MiniAigGenerateFromFile()
|
||||
{
|
||||
Mini_Aig_t * p = Mini_AigStart();
|
||||
Vec_Int_t * vTriples = Gia_MiniAigProcessFile();
|
||||
Vec_Int_t * vDefs = Vec_IntStartFull( Vec_IntSize(vTriples) );
|
||||
Vec_Int_t * vMap = Vec_IntStartFull( Vec_IntSize(vTriples) );
|
||||
Vec_Int_t * vMapIn = Vec_IntStart( Vec_IntSize(vTriples) );
|
||||
Vec_Int_t * vMapOut = Vec_IntStart( Vec_IntSize(vTriples) );
|
||||
Vec_Int_t * vPis = Vec_IntAlloc( 100 );
|
||||
Vec_Int_t * vPos = Vec_IntAlloc( 100 );
|
||||
int i, ObjOut, ObjIn;
|
||||
assert( Vec_IntSize(vTriples) % 3 == 0 );
|
||||
for ( i = 0; i < Vec_IntSize(vTriples)/3; i++ )
|
||||
{
|
||||
int Entry0 = Vec_IntEntry(vTriples, 3*i+0);
|
||||
int Entry1 = Vec_IntEntry(vTriples, 3*i+1);
|
||||
int Entry2 = Vec_IntEntry(vTriples, 3*i+2);
|
||||
Vec_IntWriteEntry( vDefs, Entry0, i );
|
||||
Vec_IntAddToEntry( vMapOut, Entry0, 1 );
|
||||
Vec_IntAddToEntry( vMapIn, Entry1, 1 );
|
||||
Vec_IntAddToEntry( vMapIn, Entry2, 1 );
|
||||
}
|
||||
Vec_IntForEachEntryTwo( vMapOut, vMapIn, ObjOut, ObjIn, i )
|
||||
if ( !ObjOut && ObjIn )
|
||||
Vec_IntPush( vPis, i );
|
||||
else if ( ObjOut && !ObjIn )
|
||||
Vec_IntPush( vPos, i );
|
||||
Vec_IntForEachEntry( vPis, ObjIn, i )
|
||||
Vec_IntWriteEntry( vMap, ObjIn, Mini_AigCreatePi(p) );
|
||||
Vec_IntForEachEntry( vPos, ObjOut, i )
|
||||
Gia_MiniAigGenerate_rec( p, vTriples, ObjOut, vDefs, vMap );
|
||||
Vec_IntForEachEntry( vPos, ObjOut, i )
|
||||
{
|
||||
assert( Vec_IntEntry(vMap, ObjOut) >= 0 );
|
||||
Mini_AigCreatePo( p, Vec_IntEntry(vMap, ObjOut) );
|
||||
}
|
||||
Vec_IntFree( vTriples );
|
||||
Vec_IntFree( vDefs );
|
||||
Vec_IntFree( vMap );
|
||||
Vec_IntFree( vMapIn );
|
||||
Vec_IntFree( vMapOut );
|
||||
Vec_IntFree( vPis );
|
||||
Vec_IntFree( vPos );
|
||||
Mini_AigDump( p, "test.miniaig" );
|
||||
Mini_AigStop( p );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,12 +1,12 @@
|
|||
/**CFile****************************************************************
|
||||
|
||||
FileName [giaSim5.c]
|
||||
FileName [giaReshape.c]
|
||||
|
||||
SystemName [ABC: Logic synthesis and verification system.]
|
||||
|
||||
PackageName [Scalable AIG package.]
|
||||
|
||||
Synopsis [Simulation engine.]
|
||||
Synopsis []
|
||||
|
||||
Author [Alan Mishchenko]
|
||||
|
||||
|
|
@ -14,23 +14,19 @@
|
|||
|
||||
Date [Ver. 1.0. Started - June 20, 2005.]
|
||||
|
||||
Revision [$Id: giaSim5.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
|
||||
Revision [$Id: gia.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
|
||||
|
||||
***********************************************************************/
|
||||
|
||||
#include "gia.h"
|
||||
#include "base/main/main.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// DECLARATIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Sim_Init( Abc_Frame_t * pAbc ) {}
|
||||
void Sim_End( Abc_Frame_t * pAbc ) {}
|
||||
void Gia_DatFree( Gia_Dat_t * p ) {}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// FUNCTION DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -40,12 +36,16 @@ void Gia_DatFree( Gia_Dat_t * p ) {}
|
|||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Gia_Man_t * Gia_ManReshape1( Gia_Man_t * p, int fUseSimple, int fVerbose, int fVeryVerbose )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
/**CFile****************************************************************
|
||||
|
||||
FileName [giaSim4.c]
|
||||
FileName [giaReshape.c]
|
||||
|
||||
SystemName [ABC: Logic synthesis and verification system.]
|
||||
|
||||
PackageName [Scalable AIG package.]
|
||||
|
||||
Synopsis [Simulation engine.]
|
||||
Synopsis []
|
||||
|
||||
Author [Alan Mishchenko]
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
Date [Ver. 1.0. Started - June 20, 2005.]
|
||||
|
||||
Revision [$Id: giaSim4.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
|
||||
Revision [$Id: gia.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
|
||||
|
||||
***********************************************************************/
|
||||
|
||||
|
|
@ -35,15 +35,15 @@ ABC_NAMESPACE_IMPL_START
|
|||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Gia_Sim4Try( char * pFileName0, char * pFileName1, char * pFileName2, int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fVerbose )
|
||||
Gia_Man_t * Gia_ManReshape2( Gia_Man_t * p, int fUseSimple, int fVerbose, int fVeryVerbose )
|
||||
{
|
||||
return 0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,54 @@
|
|||
/**CFile****************************************************************
|
||||
|
||||
FileName [giaResub3.c]
|
||||
|
||||
SystemName [ABC: Logic synthesis and verification system.]
|
||||
|
||||
PackageName [Scalable AIG package.]
|
||||
|
||||
Synopsis [Resubstitution computation.]
|
||||
|
||||
Author [Alan Mishchenko]
|
||||
|
||||
Affiliation [UC Berkeley]
|
||||
|
||||
Date [Ver. 1.0. Started - June 20, 2005.]
|
||||
|
||||
Revision [$Id: giaResub3.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
|
||||
|
||||
***********************************************************************/
|
||||
|
||||
#include "gia.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// DECLARATIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// FUNCTION DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Gia_Man_t * Gia_ManPerformNewResub( Gia_Man_t * p, int nWinCount, int nCutSize, int nProcs, int fVerbose )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
||||
|
|
@ -88,7 +88,12 @@ Gia_Man_t * Gia_ManAigSyn2( Gia_Man_t * pInit, int fOldAlgo, int fCoarsen, int f
|
|||
p = Gia_ManDup( pInit );
|
||||
Gia_ManTransferTiming( p, pInit );
|
||||
if ( Gia_ManAndNum(p) == 0 )
|
||||
return p;
|
||||
{
|
||||
pNew = Gia_ManDup(p);
|
||||
Gia_ManTransferTiming( pNew, p );
|
||||
Gia_ManStop( p );
|
||||
return pNew;
|
||||
}
|
||||
// delay optimization
|
||||
if ( fDelayMin && p->pManTime == NULL )
|
||||
{
|
||||
|
|
@ -157,7 +162,12 @@ Gia_Man_t * Gia_ManAigSyn3( Gia_Man_t * p, int fVerbose, int fVeryVerbose )
|
|||
pPars->nRelaxRatio = 40;
|
||||
if ( fVerbose ) Gia_ManPrintStats( p, NULL );
|
||||
if ( Gia_ManAndNum(p) == 0 )
|
||||
return Gia_ManDup(p);
|
||||
{
|
||||
pNew = Gia_ManDup(p);
|
||||
Gia_ManTransferTiming( pNew, p );
|
||||
//Gia_ManStop( p );
|
||||
return pNew;
|
||||
}
|
||||
// perform balancing
|
||||
pNew = Gia_ManAreaBalance( p, 0, ABC_INFINITY, fVeryVerbose, 0 );
|
||||
if ( fVerbose ) Gia_ManPrintStats( pNew, NULL );
|
||||
|
|
@ -189,7 +199,12 @@ Gia_Man_t * Gia_ManAigSyn4( Gia_Man_t * p, int fVerbose, int fVeryVerbose )
|
|||
pPars->nRelaxRatio = 40;
|
||||
if ( fVerbose ) Gia_ManPrintStats( p, NULL );
|
||||
if ( Gia_ManAndNum(p) == 0 )
|
||||
return Gia_ManDup(p);
|
||||
{
|
||||
pNew = Gia_ManDup(p);
|
||||
Gia_ManTransferTiming( pNew, p );
|
||||
//Gia_ManStop( p );
|
||||
return pNew;
|
||||
}
|
||||
//Gia_ManAigPrintPiLevels( p );
|
||||
// perform balancing
|
||||
pNew = Gia_ManAreaBalance( p, 0, ABC_INFINITY, fVeryVerbose, 0 );
|
||||
|
|
|
|||
|
|
@ -1222,6 +1222,172 @@ int Gia_ManIncrSimCheckEqual( Gia_Man_t * p, int iLit0, int iLit1 )
|
|||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_ManSimOneBit( Gia_Man_t * p, Vec_Int_t * vValues )
|
||||
{
|
||||
Gia_Obj_t * pObj; int k;
|
||||
assert( Vec_IntSize(vValues) == Gia_ManCiNum(p) );
|
||||
|
||||
Gia_ManConst0(p)->fMark0 = 0;
|
||||
Gia_ManForEachCi( p, pObj, k )
|
||||
pObj->fMark0 = Vec_IntEntry(vValues, k);
|
||||
Gia_ManForEachAnd( p, pObj, k )
|
||||
pObj->fMark0 = (Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj)) & (Gia_ObjFanin1(pObj)->fMark0 ^ Gia_ObjFaninC1(pObj));
|
||||
Gia_ManForEachCo( p, pObj, k )
|
||||
pObj->fMark0 = Gia_ObjFanin0(pObj)->fMark0 ^ Gia_ObjFaninC0(pObj);
|
||||
|
||||
Gia_ManForEachCi( p, pObj, k )
|
||||
printf( "%d", k % 10 );
|
||||
printf( "\n" );
|
||||
Gia_ManForEachCi( p, pObj, k )
|
||||
printf( "%d", Vec_IntEntry(vValues, k) );
|
||||
printf( "\n" );
|
||||
|
||||
Gia_ManForEachCo( p, pObj, k )
|
||||
printf( "%d", k % 10 );
|
||||
printf( "\n" );
|
||||
Gia_ManForEachCo( p, pObj, k )
|
||||
printf( "%d", pObj->fMark0 );
|
||||
printf( "\n" );
|
||||
printf( "\n" );
|
||||
}
|
||||
void Gia_ManSimOneBitTest2( Gia_Man_t * p )
|
||||
{
|
||||
Vec_Int_t * vValues = Vec_IntStart( Gia_ManCiNum(p) );
|
||||
|
||||
Vec_IntWriteEntry( vValues, 0, 1 );
|
||||
Gia_ManSimOneBit( p, vValues );
|
||||
Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
|
||||
|
||||
Vec_IntWriteEntry( vValues, 0, 1 );
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2, 1 );
|
||||
Gia_ManSimOneBit( p, vValues );
|
||||
Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
|
||||
|
||||
Vec_IntWriteEntry( vValues, 0, 1 );
|
||||
Vec_IntWriteEntry( vValues, 1, 1 );
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2+2, 1 );
|
||||
Gia_ManSimOneBit( p, vValues );
|
||||
Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
|
||||
|
||||
Vec_IntWriteEntry( vValues, 0, 1 );
|
||||
Vec_IntWriteEntry( vValues, 1, 1 );
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2, 1 );
|
||||
Gia_ManSimOneBit( p, vValues );
|
||||
Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
|
||||
|
||||
Vec_IntFill( vValues, Vec_IntSize(vValues)/2, 1 );
|
||||
Vec_IntFillExtra( vValues, Gia_ManCiNum(p), 0 );
|
||||
Gia_ManSimOneBit( p, vValues );
|
||||
Vec_IntFill( vValues, Gia_ManCiNum(p), 0 );
|
||||
|
||||
Vec_IntFill( vValues, Gia_ManCiNum(p), 1 );
|
||||
Gia_ManSimOneBit( p, vValues );
|
||||
Vec_IntFill( vValues, Gia_ManCiNum(p), 0 );
|
||||
|
||||
Vec_IntFill( vValues, Gia_ManCiNum(p), 1 );
|
||||
Vec_IntWriteEntry( vValues, 127, 1 );
|
||||
Vec_IntWriteEntry( vValues, 255, 0 );
|
||||
Gia_ManSimOneBit( p, vValues );
|
||||
Vec_IntFill( vValues, Gia_ManCiNum(p), 0 );
|
||||
|
||||
Vec_IntFill( vValues, Gia_ManCiNum(p), 1 );
|
||||
Vec_IntWriteEntry( vValues, 127, 0 );
|
||||
Vec_IntWriteEntry( vValues, 255, 1 );
|
||||
Gia_ManSimOneBit( p, vValues );
|
||||
Vec_IntFill( vValues, Gia_ManCiNum(p), 0 );
|
||||
|
||||
Vec_IntFill( vValues, Gia_ManCiNum(p), 1 );
|
||||
Vec_IntWriteEntry( vValues, 127, 0 );
|
||||
Vec_IntWriteEntry( vValues, 255, 0 );
|
||||
Gia_ManSimOneBit( p, vValues );
|
||||
Vec_IntFill( vValues, Gia_ManCiNum(p), 0 );
|
||||
|
||||
Vec_IntFree( vValues );
|
||||
}
|
||||
void Gia_ManSimOneBitTest3( Gia_Man_t * p )
|
||||
{
|
||||
Vec_Int_t * vValues = Vec_IntStart( Gia_ManCiNum(p) );
|
||||
|
||||
Vec_IntWriteEntry( vValues, 0, 1 );
|
||||
Gia_ManSimOneBit( p, vValues );
|
||||
Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
|
||||
|
||||
Vec_IntWriteEntry( vValues, 0, 1 );
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2, 1 );
|
||||
Gia_ManSimOneBit( p, vValues );
|
||||
Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
|
||||
|
||||
Vec_IntWriteEntry( vValues, 0, 1 );
|
||||
Vec_IntWriteEntry( vValues, 1, 1 );
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2+2, 1 );
|
||||
Gia_ManSimOneBit( p, vValues );
|
||||
Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
|
||||
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2-1, 1 );
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p) -1, 1 );
|
||||
Gia_ManSimOneBit( p, vValues );
|
||||
Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
|
||||
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2-1, 1 );
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2-2, 1 );
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p) -1, 1 );
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p) -2, 1 );
|
||||
Gia_ManSimOneBit( p, vValues );
|
||||
Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
|
||||
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2-2, 1 );
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p) -2, 1 );
|
||||
Gia_ManSimOneBit( p, vValues );
|
||||
Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
|
||||
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2-1, 1 );
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2-2, 1 );
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2-3, 1 );
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p) -1, 1 );
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p) -2, 1 );
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p) -3, 1 );
|
||||
Gia_ManSimOneBit( p, vValues );
|
||||
Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
|
||||
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2-2, 1 );
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p)/2-3, 1 );
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p) -2, 1 );
|
||||
Vec_IntWriteEntry( vValues, Gia_ManCiNum(p) -3, 1 );
|
||||
Gia_ManSimOneBit( p, vValues );
|
||||
Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
|
||||
|
||||
Vec_IntFill( vValues, Vec_IntSize(vValues), 1 );
|
||||
Gia_ManSimOneBit( p, vValues );
|
||||
Vec_IntFill( vValues, Vec_IntSize(vValues), 0 );
|
||||
|
||||
Vec_IntFree( vValues );
|
||||
}
|
||||
|
||||
|
||||
void Gia_ManSimOneBitTest( Gia_Man_t * p )
|
||||
{
|
||||
Vec_Int_t * vValues = Vec_IntStart( Gia_ManCiNum(p) );
|
||||
int i, k;
|
||||
for ( i = 0; i < 10; i++ )
|
||||
{
|
||||
for ( k = 0; k < Vec_IntSize(vValues); k++ )
|
||||
Vec_IntWriteEntry( vValues, k, Vec_IntEntry(vValues, k) ^ (rand()&1) );
|
||||
|
||||
printf( "Values = %d ", Vec_IntSum(vValues) );
|
||||
Gia_ManSimOneBit( p, vValues );
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include "gia.h"
|
||||
#include "misc/util/utilTruth.h"
|
||||
#include "misc/extra/extra.h"
|
||||
//#include <immintrin.h>
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
|
|
@ -112,7 +113,13 @@ static inline void Gia_ManSimPatSimPo( Gia_Man_t * p, int i, Gia_Obj_t * pObj, i
|
|||
word * pSims0 = pSims + nWords*Gia_ObjFaninId0(pObj, i);
|
||||
word * pSims2 = pSims + nWords*i; int w;
|
||||
for ( w = 0; w < nWords; w++ )
|
||||
pSims2[w] = (pSims0[w] ^ Diff0);
|
||||
pSims2[w] = (pSims0[w] ^ Diff0);
|
||||
}
|
||||
static inline void Gia_ManSimPatSimNot( Gia_Man_t * p, int i, Gia_Obj_t * pObj, int nWords, Vec_Wrd_t * vSims )
|
||||
{
|
||||
word * pSims = Vec_WrdArray(vSims) + nWords*i; int w;
|
||||
for ( w = 0; w < nWords; w++ )
|
||||
pSims[w] = ~pSims[w];
|
||||
}
|
||||
Vec_Wrd_t * Gia_ManSimPatSim( Gia_Man_t * pGia )
|
||||
{
|
||||
|
|
@ -127,6 +134,427 @@ Vec_Wrd_t * Gia_ManSimPatSim( Gia_Man_t * pGia )
|
|||
Gia_ManSimPatSimPo( pGia, Gia_ObjId(pGia, pObj), pObj, nWords, vSims );
|
||||
return vSims;
|
||||
}
|
||||
Vec_Wrd_t * Gia_ManSimPatSimOut( Gia_Man_t * pGia, Vec_Wrd_t * vSimsPi, int fOuts )
|
||||
{
|
||||
Gia_Obj_t * pObj;
|
||||
int i, nWords = Vec_WrdSize(vSimsPi) / Gia_ManCiNum(pGia);
|
||||
Vec_Wrd_t * vSimsCo = fOuts ? Vec_WrdStart( Gia_ManCoNum(pGia) * nWords ) : NULL;
|
||||
Vec_Wrd_t * vSims = Vec_WrdStart( Gia_ManObjNum(pGia) * nWords );
|
||||
assert( Vec_WrdSize(vSimsPi) % Gia_ManCiNum(pGia) == 0 );
|
||||
Gia_ManSimPatAssignInputs( pGia, nWords, vSims, vSimsPi );
|
||||
Gia_ManForEachAnd( pGia, pObj, i )
|
||||
Gia_ManSimPatSimAnd( pGia, i, pObj, nWords, vSims );
|
||||
Gia_ManForEachCo( pGia, pObj, i )
|
||||
Gia_ManSimPatSimPo( pGia, Gia_ObjId(pGia, pObj), pObj, nWords, vSims );
|
||||
if ( !fOuts )
|
||||
return vSims;
|
||||
Gia_ManForEachCo( pGia, pObj, i )
|
||||
memcpy( Vec_WrdEntryP(vSimsCo, i*nWords), Vec_WrdEntryP(vSims, Gia_ObjId(pGia, pObj)*nWords), sizeof(word)*nWords );
|
||||
Vec_WrdFree( vSims );
|
||||
return vSimsCo;
|
||||
}
|
||||
static inline void Gia_ManSimPatSimAnd3( Gia_Man_t * p, int i, Gia_Obj_t * pObj, int nWords, Vec_Wrd_t * vSims, Vec_Wrd_t * vSimsC )
|
||||
{
|
||||
word pComps[2] = { ~(word)0, 0 };
|
||||
word Diff0 = pComps[Gia_ObjFaninC0(pObj)];
|
||||
word Diff1 = pComps[Gia_ObjFaninC1(pObj)];
|
||||
word * pSims0 = Vec_WrdArray(vSims) + nWords*Gia_ObjFaninId0(pObj, i);
|
||||
word * pSims1 = Vec_WrdArray(vSims) + nWords*Gia_ObjFaninId1(pObj, i);
|
||||
word * pSims2 = Vec_WrdArray(vSims) + nWords*i;
|
||||
word * pSimsC0 = Vec_WrdArray(vSimsC) + nWords*Gia_ObjFaninId0(pObj, i);
|
||||
word * pSimsC1 = Vec_WrdArray(vSimsC) + nWords*Gia_ObjFaninId1(pObj, i);
|
||||
word * pSimsC2 = Vec_WrdArray(vSimsC) + nWords*i; int w;
|
||||
if ( Gia_ObjIsXor(pObj) )
|
||||
for ( w = 0; w < nWords; w++ )
|
||||
{
|
||||
pSimsC0[w] |= pSimsC2[w];
|
||||
pSimsC1[w] |= pSimsC2[w];
|
||||
}
|
||||
else
|
||||
for ( w = 0; w < nWords; w++ )
|
||||
{
|
||||
pSimsC0[w] |= (pSims2[w] | (pSims0[w] ^ Diff0)) & pSimsC2[w];
|
||||
pSimsC1[w] |= (pSims2[w] | (pSims1[w] ^ Diff1)) & pSimsC2[w];
|
||||
}
|
||||
}
|
||||
Vec_Wrd_t * Gia_ManSimPatSimIn( Gia_Man_t * pGia, Vec_Wrd_t * vSims, int fIns, Vec_Int_t * vAnds )
|
||||
{
|
||||
Gia_Obj_t * pObj;
|
||||
int i, Id, nWords = Vec_WrdSize(vSims) / Gia_ManObjNum(pGia);
|
||||
Vec_Wrd_t * vSimsCi = fIns ? Vec_WrdStart( Gia_ManCiNum(pGia) * nWords ) : NULL;
|
||||
Vec_Wrd_t * vSimsC = Vec_WrdStart( Vec_WrdSize(vSims) );
|
||||
assert( Vec_WrdSize(vSims) % Gia_ManObjNum(pGia) == 0 );
|
||||
if ( vAnds )
|
||||
Vec_IntForEachEntry( vAnds, Id, i )
|
||||
memset( Vec_WrdEntryP(vSimsC, Id*nWords), 0xFF, sizeof(word)*nWords );
|
||||
else
|
||||
Gia_ManForEachCoDriverId( pGia, Id, i )
|
||||
memset( Vec_WrdEntryP(vSimsC, Id*nWords), 0xFF, sizeof(word)*nWords );
|
||||
Gia_ManForEachAndReverse( pGia, pObj, i )
|
||||
Gia_ManSimPatSimAnd3( pGia, i, pObj, nWords, vSims, vSimsC );
|
||||
if ( !fIns )
|
||||
return vSimsC;
|
||||
Gia_ManForEachCi( pGia, pObj, i )
|
||||
memcpy( Vec_WrdEntryP(vSimsCi, i*nWords), Vec_WrdEntryP(vSimsC, Gia_ObjId(pGia, pObj)*nWords), sizeof(word)*nWords );
|
||||
Vec_WrdFree( vSimsC );
|
||||
return vSimsCi;
|
||||
}
|
||||
void Gia_ManSimPatSimInTest( Gia_Man_t * pGia )
|
||||
{
|
||||
int nWords = 10;
|
||||
Vec_Wrd_t * vSimsCi = Vec_WrdStartRandom( Gia_ManCiNum(pGia) * nWords );
|
||||
Vec_Wrd_t * vSims = Gia_ManSimPatSimOut( pGia, vSimsCi, 0 );
|
||||
Vec_Wrd_t * vSims2 = Gia_ManSimPatSimIn( pGia, vSims, 0, NULL );
|
||||
int nOnes = Abc_TtCountOnesVec( Vec_WrdArray(vSims2), Vec_WrdSize(vSims2) );
|
||||
int nTotal = 64*nWords*Gia_ManCandNum(pGia);
|
||||
printf( "Ratio = %6.2f %%\n", 100.0*nOnes/nTotal );
|
||||
Vec_WrdFree( vSims );
|
||||
Vec_WrdFree( vSims2 );
|
||||
Vec_WrdFree( vSimsCi );
|
||||
}
|
||||
static inline void Gia_ManSimPatSimAnd4( Gia_Man_t * p, int i, Gia_Obj_t * pObj, int nWords, Vec_Wrd_t * vSims, Vec_Wrd_t * vSimsC )
|
||||
{
|
||||
word pComps[2] = { ~(word)0, 0 };
|
||||
word Diff0 = pComps[Gia_ObjFaninC0(pObj)];
|
||||
word Diff1 = pComps[Gia_ObjFaninC1(pObj)];
|
||||
word * pSims0 = Vec_WrdArray(vSims) + nWords*Gia_ObjFaninId0(pObj, i);
|
||||
word * pSims1 = Vec_WrdArray(vSims) + nWords*Gia_ObjFaninId1(pObj, i);
|
||||
word * pSimsC0 = Vec_WrdArray(vSimsC) + nWords*Gia_ObjFaninId0(pObj, i);
|
||||
word * pSimsC1 = Vec_WrdArray(vSimsC) + nWords*Gia_ObjFaninId1(pObj, i);
|
||||
word * pSimsC2 = Vec_WrdArray(vSimsC) + nWords*i; int w;
|
||||
if ( Gia_ObjIsXor(pObj) )
|
||||
for ( w = 0; w < nWords; w++ )
|
||||
pSimsC2[w] = pSimsC0[w] & pSimsC1[w];
|
||||
else
|
||||
for ( w = 0; w < nWords; w++ )
|
||||
pSimsC2[w] = (pSimsC0[w] & pSimsC1[w]) | ((pSims0[w] ^ Diff0) & pSimsC0[w]) | ((pSims1[w] ^ Diff1) & pSimsC1[w]);
|
||||
}
|
||||
Vec_Wrd_t * Gia_ManSimPatSimC( Gia_Man_t * pGia, Vec_Wrd_t * vSims, Vec_Wrd_t * vSimsCiC )
|
||||
{
|
||||
Gia_Obj_t * pObj;
|
||||
int i, Id, nWords = Vec_WrdSize(vSims) / Gia_ManObjNum(pGia);
|
||||
Vec_Wrd_t * vSimsC = Vec_WrdStart( Vec_WrdSize(vSims) );
|
||||
assert( Vec_WrdSize(vSims) % Gia_ManObjNum(pGia) == 0 );
|
||||
memset( Vec_WrdEntryP(vSimsC, 0), 0xFF, sizeof(word)*nWords );
|
||||
Gia_ManForEachCiId( pGia, Id, i )
|
||||
memmove( Vec_WrdEntryP(vSimsC, Id*nWords), Vec_WrdEntryP(vSimsCiC, i*nWords), sizeof(word)*nWords );
|
||||
Gia_ManForEachAnd( pGia, pObj, i )
|
||||
Gia_ManSimPatSimAnd4( pGia, i, pObj, nWords, vSims, vSimsC );
|
||||
return vSimsC;
|
||||
}
|
||||
void Gia_ManSimPatSimCTest( Gia_Man_t * pGia )
|
||||
{
|
||||
int nWords = 10;
|
||||
Vec_Wrd_t * vSimsCi = Vec_WrdStartRandom( Gia_ManCiNum(pGia) * nWords );
|
||||
Vec_Wrd_t * vSims = Gia_ManSimPatSimOut( pGia, vSimsCi, 0 );
|
||||
Vec_Wrd_t * vSims2 = Gia_ManSimPatSimIn( pGia, vSims, 0, NULL );
|
||||
Vec_Wrd_t * vSimsCi2 = Gia_ManSimPatSimIn( pGia, vSims, 1, NULL );
|
||||
Vec_Wrd_t * vSims3 = Gia_ManSimPatSimC( pGia, vSims, vSimsCi2 );
|
||||
int nOnes2 = Abc_TtCountOnesVec( Vec_WrdArray(vSims2), Vec_WrdSize(vSims2) );
|
||||
int nOnes3 = Abc_TtCountOnesVec( Vec_WrdArray(vSims3), Vec_WrdSize(vSims3) );
|
||||
int nTotal = 64*nWords*Gia_ManCandNum(pGia);
|
||||
printf( "Ratio = %6.2f %% Ratio = %6.2f %%\n", 100.0*nOnes2/nTotal, 100.0*nOnes3/nTotal );
|
||||
Vec_WrdFree( vSims );
|
||||
Vec_WrdFree( vSims2 );
|
||||
Vec_WrdFree( vSims3 );
|
||||
Vec_WrdFree( vSimsCi );
|
||||
Vec_WrdFree( vSimsCi2 );
|
||||
}
|
||||
void Gia_ManSimPatResim( Gia_Man_t * pGia, Vec_Int_t * vObjs, int nWords, Vec_Wrd_t * vSims )
|
||||
{
|
||||
Gia_Obj_t * pObj; int i;
|
||||
Gia_ManForEachObjVec( vObjs, pGia, pObj, i )
|
||||
if ( i == 0 )
|
||||
Gia_ManSimPatSimNot( pGia, Gia_ObjId(pGia, pObj), pObj, nWords, vSims );
|
||||
else if ( Gia_ObjIsAnd(pObj) )
|
||||
Gia_ManSimPatSimAnd( pGia, Gia_ObjId(pGia, pObj), pObj, nWords, vSims );
|
||||
else if ( !Gia_ObjIsCo(pObj) ) assert(0);
|
||||
}
|
||||
void Gia_ManSimPatWrite( char * pFileName, Vec_Wrd_t * vSimsIn, int nWords )
|
||||
{
|
||||
Vec_WrdDumpHex( pFileName, vSimsIn, nWords, 0 );
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
word * Gia_ManDeriveFuncs( Gia_Man_t * p )
|
||||
{
|
||||
int nVars2 = (Gia_ManCiNum(p) + 6)/2;
|
||||
int nVars3 = Gia_ManCiNum(p) - nVars2;
|
||||
int nWords = Abc_Truth6WordNum( Gia_ManCiNum(p) );
|
||||
int nWords2 = Abc_Truth6WordNum( nVars2 );
|
||||
word * pRes = ABC_ALLOC( word, Gia_ManCoNum(p) * nWords );
|
||||
Vec_Wrd_t * vSims = Vec_WrdStart( nWords2 * Gia_ManObjNum(p) );
|
||||
Vec_Ptr_t * vTruths = Vec_PtrAllocTruthTables( nVars2 );
|
||||
Gia_Obj_t * pObj; int i, v, m;
|
||||
Gia_ManForEachCi( p, pObj, i )
|
||||
assert( Gia_ObjId(p, pObj) == i+1 );
|
||||
for ( i = 0; i < nVars2; i++ )
|
||||
Abc_TtCopy( Vec_WrdEntryP(vSims, nWords2*(i+1)), (word *)Vec_PtrEntry(vTruths, i), nWords2, 0 );
|
||||
Vec_PtrFree( vTruths );
|
||||
for ( m = 0; m < (1 << nVars3); m++ )
|
||||
{
|
||||
for ( v = 0; v < nVars3; v++ )
|
||||
Abc_TtConst( Vec_WrdEntryP(vSims, nWords2*(nVars2+v+1)), nWords2, (m >> v) & 1 );
|
||||
Gia_ManForEachAnd( p, pObj, i )
|
||||
Gia_ManSimPatSimAnd( p, i, pObj, nWords2, vSims );
|
||||
Gia_ManForEachCo( p, pObj, i )
|
||||
Gia_ManSimPatSimPo( p, Gia_ObjId(p, pObj), pObj, nWords2, vSims );
|
||||
Gia_ManForEachCo( p, pObj, i )
|
||||
Abc_TtCopy( pRes + i*nWords + m*nWords2, Vec_WrdEntryP(vSims, nWords2*Gia_ObjId(p, pObj)), nWords2, 0 );
|
||||
}
|
||||
Vec_WrdFree( vSims );
|
||||
return pRes;
|
||||
}
|
||||
Gia_Man_t * Gia_ManPerformMuxDec( Gia_Man_t * p )
|
||||
{
|
||||
extern int Gia_ManFindMuxTree_rec( Gia_Man_t * pNew, int * pCtrl, int nCtrl, Vec_Int_t * vData, int Shift );
|
||||
extern int Kit_TruthToGia( Gia_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory, Vec_Int_t * vLeaves, int fHash );
|
||||
int nWords = Abc_Truth6WordNum( Gia_ManCiNum(p) );
|
||||
int nCofs = 1 << (Gia_ManCiNum(p) - 6);
|
||||
word * pRes = Gia_ManDeriveFuncs( p );
|
||||
Vec_Int_t * vMemory = Vec_IntAlloc( 1 << 16 );
|
||||
Vec_Int_t * vLeaves = Vec_IntAlloc( 6 );
|
||||
Vec_Int_t * vCtrls = Vec_IntAlloc( nCofs );
|
||||
Vec_Int_t * vDatas = Vec_IntAlloc( Gia_ManCoNum(p) );
|
||||
Gia_Man_t * pNew, * pTemp; int i, o;
|
||||
pNew = Gia_ManStart( Gia_ManObjNum(p) );
|
||||
pNew->pName = Abc_UtilStrsav( p->pName );
|
||||
pNew->pSpec = Abc_UtilStrsav( p->pSpec );
|
||||
Gia_ManConst0(p)->Value = 0;
|
||||
for ( i = 0; i < Gia_ManCiNum(p); i++ )
|
||||
Vec_IntPush( i < 6 ? vLeaves : vCtrls, Gia_ManAppendCi(pNew) );
|
||||
Gia_ManHashAlloc( pNew );
|
||||
for ( o = 0; o < Gia_ManCoNum(p); o++ )
|
||||
{
|
||||
Vec_IntClear( vDatas );
|
||||
for ( i = 0; i < nWords; i++ )
|
||||
Vec_IntPush( vDatas, Kit_TruthToGia(pNew, (unsigned *)(pRes+o*nWords+i), 6, vMemory, vLeaves, 1) );
|
||||
Gia_ManAppendCo( pNew, Gia_ManFindMuxTree_rec(pNew, Vec_IntArray(vCtrls), Vec_IntSize(vCtrls), vDatas, 0) );
|
||||
}
|
||||
Gia_ManHashStop( pNew );
|
||||
ABC_FREE( pRes );
|
||||
Vec_IntFree( vMemory );
|
||||
Vec_IntFree( vLeaves );
|
||||
Vec_IntFree( vCtrls );
|
||||
Vec_IntFree( vDatas );
|
||||
Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
|
||||
pNew = Gia_ManCleanup( pTemp = pNew );
|
||||
Gia_ManStop( pTemp );
|
||||
Gia_ManTransferTiming( pNew, p );
|
||||
return pNew;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Gia_ManComputeTfos_rec( Gia_Man_t * p, int iObj, int iRoot, Vec_Int_t * vNode )
|
||||
{
|
||||
Gia_Obj_t * pObj;
|
||||
if ( Gia_ObjIsTravIdPreviousId(p, iObj) )
|
||||
return 1;
|
||||
if ( Gia_ObjIsTravIdCurrentId(p, iObj) )
|
||||
return 0;
|
||||
pObj = Gia_ManObj( p, iObj );
|
||||
if ( !Gia_ObjIsAnd(pObj) )
|
||||
return 0;
|
||||
if ( Gia_ManComputeTfos_rec( p, Gia_ObjFaninId0(pObj, iObj), iRoot, vNode ) |
|
||||
Gia_ManComputeTfos_rec( p, Gia_ObjFaninId1(pObj, iObj), iRoot, vNode ) )
|
||||
{
|
||||
Gia_ObjSetTravIdPreviousId(p, iObj);
|
||||
Vec_IntPush( vNode, iObj );
|
||||
return 1;
|
||||
}
|
||||
Gia_ObjSetTravIdCurrentId(p, iObj);
|
||||
return 0;
|
||||
}
|
||||
Vec_Wec_t * Gia_ManComputeTfos( Gia_Man_t * p )
|
||||
{
|
||||
Vec_Wec_t * vNodes = Vec_WecStart( Gia_ManCiNum(p) );
|
||||
Vec_Int_t * vTemp = Vec_IntAlloc( 100 );
|
||||
int i, o, IdCi, IdCo;
|
||||
Gia_ManForEachCiId( p, IdCi, i )
|
||||
{
|
||||
Vec_Int_t * vNode = Vec_WecEntry( vNodes, i );
|
||||
Gia_ManIncrementTravId( p );
|
||||
Gia_ManIncrementTravId( p );
|
||||
Gia_ObjSetTravIdPreviousId(p, IdCi);
|
||||
Vec_IntPush( vNode, IdCi );
|
||||
Vec_IntClear( vTemp );
|
||||
Gia_ManForEachCoId( p, IdCo, o )
|
||||
if ( Gia_ManComputeTfos_rec( p, Gia_ObjFaninId0(Gia_ManObj(p, IdCo), IdCo), IdCi, vNode ) )
|
||||
Vec_IntPush( vTemp, Gia_ManObjNum(p) + (o >> 1) );
|
||||
Vec_IntUniqify( vTemp );
|
||||
Vec_IntAppend( vNode, vTemp );
|
||||
}
|
||||
Vec_IntFree( vTemp );
|
||||
Vec_WecSort( vNodes, 1 );
|
||||
//Vec_WecPrint( vNodes, 0 );
|
||||
//Gia_AigerWrite( p, "dump.aig", 0, 0, 0 );
|
||||
return vNodes;
|
||||
}
|
||||
int Gia_ManFindDividerVar( Gia_Man_t * p, int fVerbose )
|
||||
{
|
||||
int iVar, Target = 1 << 28;
|
||||
for ( iVar = 6; iVar < Gia_ManCiNum(p); iVar++ )
|
||||
if ( (1 << (iVar-3)) * Gia_ManObjNum(p) > Target )
|
||||
break;
|
||||
if ( iVar == Gia_ManCiNum(p) )
|
||||
iVar = Gia_ManCiNum(p) - 1;
|
||||
if ( fVerbose )
|
||||
printf( "Split var = %d. Rounds = %d. Bytes per node = %d. Total = %.2f MB.\n", iVar, 1 << (Gia_ManCiNum(p) - iVar), 1 << (iVar-3), 1.0*(1 << (iVar-3)) * Gia_ManObjNum(p)/(1<<20) );
|
||||
return iVar;
|
||||
}
|
||||
int Gia_ManComparePair( Gia_Man_t * p, Vec_Wrd_t * vSims, int iOut, int nWords2 )
|
||||
{
|
||||
Gia_Obj_t * pObj0 = Gia_ManCo( p, 2*iOut+0 );
|
||||
Gia_Obj_t * pObj1 = Gia_ManCo( p, 2*iOut+1 );
|
||||
word * pSim0 = Vec_WrdEntryP( vSims, nWords2*Gia_ObjId(p, pObj0) );
|
||||
word * pSim1 = Vec_WrdEntryP( vSims, nWords2*Gia_ObjId(p, pObj1) );
|
||||
Gia_ManSimPatSimPo( p, Gia_ObjId(p, pObj0), pObj0, nWords2, vSims );
|
||||
Gia_ManSimPatSimPo( p, Gia_ObjId(p, pObj1), pObj1, nWords2, vSims );
|
||||
return Abc_TtEqual( pSim0, pSim1, nWords2 );
|
||||
}
|
||||
int Gia_ManCheckSimEquiv( Gia_Man_t * p, int fVerbose )
|
||||
{
|
||||
abctime clk = Abc_Clock(); int fWarning = 0;
|
||||
//int nVars2 = (Gia_ManCiNum(p) + 6)/2;
|
||||
int nVars2 = Gia_ManFindDividerVar( p, fVerbose );
|
||||
int nVars3 = Gia_ManCiNum(p) - nVars2;
|
||||
int nWords2 = Abc_Truth6WordNum( nVars2 );
|
||||
Vec_Wrd_t * vSims = Vec_WrdStart( nWords2 * Gia_ManObjNum(p) );
|
||||
Vec_Wec_t * vNodes = Gia_ManComputeTfos( p );
|
||||
Vec_Ptr_t * vTruths = Vec_PtrAllocTruthTables( nVars2 );
|
||||
Gia_Obj_t * pObj; Vec_Int_t * vNode; int i, m, iObj;
|
||||
Vec_WecForEachLevelStop( vNodes, vNode, i, nVars2 )
|
||||
Abc_TtCopy( Vec_WrdEntryP(vSims, nWords2*Vec_IntEntry(vNode,0)), (word *)Vec_PtrEntry(vTruths, i), nWords2, 0 );
|
||||
Vec_PtrFree( vTruths );
|
||||
Gia_ManForEachAnd( p, pObj, i )
|
||||
Gia_ManSimPatSimAnd( p, i, pObj, nWords2, vSims );
|
||||
for ( i = 0; i < Gia_ManCoNum(p)/2; i++ )
|
||||
{
|
||||
if ( !Gia_ManComparePair( p, vSims, i, nWords2 ) )
|
||||
{
|
||||
printf( "Miter is asserted for output %d.\n", i );
|
||||
Vec_WecFree( vNodes );
|
||||
Vec_WrdFree( vSims );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
for ( m = 0; m < (1 << nVars3); m++ )
|
||||
{
|
||||
int iVar = m ? Abc_TtSuppFindFirst( m ^ (m >> 1) ^ (m-1) ^ ((m-1) >> 1) ) : 0;
|
||||
vNode = Vec_WecEntry( vNodes, nVars2+iVar );
|
||||
Abc_TtNot( Vec_WrdEntryP(vSims, nWords2*Vec_IntEntry(vNode,0)), nWords2 );
|
||||
Vec_IntForEachEntryStart( vNode, iObj, i, 1 )
|
||||
{
|
||||
if ( iObj < Gia_ManObjNum(p) )
|
||||
{
|
||||
pObj = Gia_ManObj( p, iObj );
|
||||
assert( Gia_ObjIsAnd(pObj) );
|
||||
Gia_ManSimPatSimAnd( p, iObj, pObj, nWords2, vSims );
|
||||
}
|
||||
else if ( !Gia_ManComparePair( p, vSims, iObj - Gia_ManObjNum(p), nWords2 ) )
|
||||
{
|
||||
printf( "Miter is asserted for output %d.\n", iObj - Gia_ManObjNum(p) );
|
||||
Vec_WecFree( vNodes );
|
||||
Vec_WrdFree( vSims );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//for ( i = 0; i < Gia_ManObjNum(p); i++ )
|
||||
// printf( "%3d : ", i), Extra_PrintHex2( stdout, (unsigned *)Vec_WrdEntryP(vSims, i), 6 ), printf( "\n" );
|
||||
if ( !fWarning && Abc_Clock() > clk + 5*CLOCKS_PER_SEC )
|
||||
printf( "The computation is expected to take about %.2f sec.\n", 5.0*(1 << nVars3)/m ), fWarning = 1;
|
||||
//if ( (m & 0x3F) == 0x3F )
|
||||
if ( fVerbose && (m & 0xFF) == 0xFF )
|
||||
printf( "Finished %6d (out of %6d)...\n", m, 1 << nVars3 );
|
||||
}
|
||||
Vec_WecFree( vNodes );
|
||||
Vec_WrdFree( vSims );
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_ManSimPatAssignInputs2( Gia_Man_t * p, int nWords, Vec_Wrd_t * vSims, Vec_Wrd_t * vSimsIn )
|
||||
{
|
||||
int i, Id;
|
||||
assert( Vec_WrdSize(vSims) == 2 * nWords * Gia_ManObjNum(p) );
|
||||
assert( Vec_WrdSize(vSimsIn) == nWords * Gia_ManCiNum(p) );
|
||||
Gia_ManForEachCiId( p, Id, i )
|
||||
{
|
||||
Abc_TtCopy( Vec_WrdEntryP(vSims, 2*Id*nWords+0), Vec_WrdEntryP(vSimsIn, i*nWords), nWords, 0 );
|
||||
Abc_TtCopy( Vec_WrdEntryP(vSims, 2*Id*nWords+1), Vec_WrdEntryP(vSimsIn, i*nWords), nWords, 1 );
|
||||
}
|
||||
}
|
||||
static inline void Gia_ManSimPatSimAnd2( Gia_Man_t * p, int i, Gia_Obj_t * pObj, int nWords, Vec_Wrd_t * vSims )
|
||||
{
|
||||
word * pSims = Vec_WrdArray(vSims);
|
||||
word * pSims0 = pSims + nWords*Gia_ObjFaninLit0(pObj, i);
|
||||
word * pSims1 = pSims + nWords*Gia_ObjFaninLit1(pObj, i);
|
||||
word * pSims2 = pSims + nWords*(2*i+0);
|
||||
word * pSims3 = pSims + nWords*(2*i+1); int w;
|
||||
assert( !Gia_ObjIsXor(pObj) );
|
||||
// if ( Gia_ObjIsXor(pObj) )
|
||||
// for ( w = 0; w < nWords; w++ )
|
||||
// pSims2[w] = pSims0[w] ^ pSims1[w];
|
||||
// else
|
||||
for ( w = 0; w < nWords; w++ )
|
||||
{
|
||||
pSims2[w] = pSims0[w] & pSims1[w];
|
||||
pSims3[w] = ~pSims2[w];
|
||||
}
|
||||
//_mm256_storeu_ps( (float *)pSims2, _mm256_and_ps(_mm256_loadu_ps((float *)pSims0), _mm256_loadu_ps((float *)pSims1)) );
|
||||
}
|
||||
static inline void Gia_ManSimPatSimPo2( Gia_Man_t * p, int i, Gia_Obj_t * pObj, int nWords, Vec_Wrd_t * vSims )
|
||||
{
|
||||
word * pSims = Vec_WrdArray(vSims);
|
||||
word * pSims0 = pSims + nWords*Gia_ObjFaninLit0(pObj, i);
|
||||
word * pSims2 = pSims + nWords*i; int w;
|
||||
for ( w = 0; w < nWords; w++ )
|
||||
pSims2[w] = pSims0[w];
|
||||
}
|
||||
Vec_Wrd_t * Gia_ManSimPatSim2( Gia_Man_t * pGia )
|
||||
{
|
||||
Gia_Obj_t * pObj;
|
||||
int i, nWords = Vec_WrdSize(pGia->vSimsPi) / Gia_ManCiNum(pGia);
|
||||
Vec_Wrd_t * vSims = Vec_WrdStart( Gia_ManObjNum(pGia) * nWords * 2 );
|
||||
assert( Vec_WrdSize(pGia->vSimsPi) % Gia_ManCiNum(pGia) == 0 );
|
||||
Gia_ManSimPatAssignInputs2( pGia, nWords, vSims, pGia->vSimsPi );
|
||||
Gia_ManForEachAnd( pGia, pObj, i )
|
||||
Gia_ManSimPatSimAnd2( pGia, i, pObj, nWords, vSims );
|
||||
Gia_ManForEachCo( pGia, pObj, i )
|
||||
Gia_ManSimPatSimPo2( pGia, Gia_ObjId(pGia, pObj), pObj, nWords, vSims );
|
||||
return vSims;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
|
|
@ -248,7 +676,6 @@ Vec_Wrd_t * Gia_ManSimBitPacking( Gia_Man_t * p, Vec_Int_t * vCexStore, int nCex
|
|||
return vSimsRes;
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
|
@ -306,87 +733,6 @@ Gia_Man_t * Gia_ManSimPatGenMiter( Gia_Man_t * p, Vec_Wrd_t * vSims )
|
|||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_ManSimPatWriteOne( FILE * pFile, word * pSim, int nWords )
|
||||
{
|
||||
int k, Digit, nDigits = nWords*16;
|
||||
for ( k = 0; k < nDigits; k++ )
|
||||
{
|
||||
Digit = (int)((pSim[k/16] >> ((k%16) * 4)) & 15);
|
||||
if ( Digit < 10 )
|
||||
fprintf( pFile, "%d", Digit );
|
||||
else
|
||||
fprintf( pFile, "%c", 'A' + Digit-10 );
|
||||
}
|
||||
fprintf( pFile, "\n" );
|
||||
}
|
||||
void Gia_ManSimPatWrite( char * pFileName, Vec_Wrd_t * vSimsIn, int nWords )
|
||||
{
|
||||
int i, nNodes = Vec_WrdSize(vSimsIn) / nWords;
|
||||
FILE * pFile = fopen( pFileName, "wb" );
|
||||
if ( pFile == NULL )
|
||||
{
|
||||
printf( "Cannot open file \"%s\" for writing.\n", pFileName );
|
||||
return;
|
||||
}
|
||||
assert( Vec_WrdSize(vSimsIn) % nWords == 0 );
|
||||
for ( i = 0; i < nNodes; i++ )
|
||||
Gia_ManSimPatWriteOne( pFile, Vec_WrdEntryP(vSimsIn, i*nWords), nWords );
|
||||
fclose( pFile );
|
||||
printf( "Written %d words of simulation data into file \"%s\".\n", nWords, pFileName );
|
||||
}
|
||||
int Gia_ManSimPatReadOne( char c )
|
||||
{
|
||||
int Digit = 0;
|
||||
if ( c >= '0' && c <= '9' )
|
||||
Digit = c - '0';
|
||||
else if ( c >= 'A' && c <= 'F' )
|
||||
Digit = c - 'A' + 10;
|
||||
else if ( c >= 'a' && c <= 'f' )
|
||||
Digit = c - 'a' + 10;
|
||||
else assert( 0 );
|
||||
assert( Digit >= 0 && Digit < 16 );
|
||||
return Digit;
|
||||
}
|
||||
Vec_Wrd_t * Gia_ManSimPatRead( char * pFileName )
|
||||
{
|
||||
Vec_Wrd_t * vSimsIn = NULL;
|
||||
int c, nWords = -1, nChars = 0; word Num = 0;
|
||||
FILE * pFile = fopen( pFileName, "rb" );
|
||||
if ( pFile == NULL )
|
||||
{
|
||||
printf( "Cannot open file \"%s\" for reading.\n", pFileName );
|
||||
return NULL;
|
||||
}
|
||||
vSimsIn = Vec_WrdAlloc( 1000 );
|
||||
while ( (c = fgetc(pFile)) != EOF )
|
||||
{
|
||||
if ( c == '\n' && nWords == -1 )
|
||||
nWords = Vec_WrdSize(vSimsIn);
|
||||
if ( c == '\n' || c == '\r' || c == '\t' || c == ' ' )
|
||||
continue;
|
||||
Num |= (word)Gia_ManSimPatReadOne((char)c) << (nChars * 4);
|
||||
if ( ++nChars < 16 )
|
||||
continue;
|
||||
Vec_WrdPush( vSimsIn, Num );
|
||||
nChars = 0;
|
||||
Num = 0;
|
||||
}
|
||||
assert( Vec_WrdSize(vSimsIn) % nWords == 0 );
|
||||
fclose( pFile );
|
||||
printf( "Read %d words of simulation data.\n", nWords );
|
||||
return vSimsIn;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
|
|
@ -2029,6 +2375,331 @@ void Gia_ManPatRareImprove( Gia_Man_t * p, int RareLimit, int fVerbose )
|
|||
Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Trying vectorized simulation.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_ManSimTest( Gia_Man_t * pGia )
|
||||
{
|
||||
int n, nWords = 4;
|
||||
Vec_Wrd_t * vSim1, * vSim2;
|
||||
Vec_Wrd_t * vSim0 = Vec_WrdStartRandom( Gia_ManCiNum(pGia) * nWords );
|
||||
abctime clk = Abc_Clock();
|
||||
|
||||
pGia->vSimsPi = vSim0;
|
||||
for ( n = 0; n < 20; n++ )
|
||||
{
|
||||
vSim1 = Gia_ManSimPatSim( pGia );
|
||||
Vec_WrdFree( vSim1 );
|
||||
}
|
||||
Abc_PrintTime( 1, "Time1", Abc_Clock() - clk );
|
||||
|
||||
clk = Abc_Clock();
|
||||
for ( n = 0; n < 20; n++ )
|
||||
{
|
||||
vSim2 = Gia_ManSimPatSim2( pGia );
|
||||
Vec_WrdFree( vSim2 );
|
||||
}
|
||||
Abc_PrintTime( 1, "Time2", Abc_Clock() - clk );
|
||||
|
||||
pGia->vSimsPi = NULL;
|
||||
Vec_WrdFree( vSim0 );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Trying compiled simulation.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_ManSimGen( Gia_Man_t * pGia )
|
||||
{
|
||||
int nWords = 4;
|
||||
Gia_Obj_t * pObj;
|
||||
Vec_Wrd_t * vSim0 = Vec_WrdStartRandom( Gia_ManCiNum(pGia) * nWords );
|
||||
FILE * pFile = fopen( "comp_sim.c", "wb" );
|
||||
int i, k, Id;
|
||||
fprintf( pFile, "#include <stdio.h>\n" );
|
||||
fprintf( pFile, "#include <stdlib.h>\n" );
|
||||
fprintf( pFile, "#include <time.h>\n" );
|
||||
fprintf( pFile, "int main()\n" );
|
||||
fprintf( pFile, "{\n" );
|
||||
fprintf( pFile, " clock_t clkThis = clock();\n" );
|
||||
fprintf( pFile, " unsigned long Res = 0;\n" );
|
||||
fprintf( pFile, " int i;\n" );
|
||||
fprintf( pFile, " srand(time(NULL));\n" );
|
||||
fprintf( pFile, " for ( i = 0; i < 2000; i++ )\n" );
|
||||
fprintf( pFile, " {\n" );
|
||||
for ( k = 0; k < nWords; k++ )
|
||||
fprintf( pFile, " unsigned long s%07d_%d = 0x%08x%08x;\n", 0, k, 0, 0 );
|
||||
Gia_ManForEachCiId( pGia, Id, i )
|
||||
{
|
||||
//word * pSim = Vec_WrdEntryP(vSim0, i*nWords);
|
||||
//unsigned * pSimU = (unsigned *)pSim;
|
||||
for ( k = 0; k < nWords; k++ )
|
||||
fprintf( pFile, " unsigned long s%07d_%d = ((unsigned long)rand() << 48) | ((unsigned long)rand() << 32) | ((unsigned long)rand() << 16) | (unsigned long)rand();\n", Id, k );
|
||||
}
|
||||
Gia_ManForEachAnd( pGia, pObj, Id )
|
||||
{
|
||||
for ( k = 0; k < nWords; k++ )
|
||||
fprintf( pFile, " unsigned long s%07d_%d = %cs%07d_%d & %cs%07d_%d;\n", Id, k,
|
||||
Gia_ObjFaninC0(pObj) ? '~' : ' ', Gia_ObjFaninId0(pObj, Id), k,
|
||||
Gia_ObjFaninC1(pObj) ? ' ' : '~', Gia_ObjFaninId1(pObj, Id), k );
|
||||
}
|
||||
Gia_ManForEachCoId( pGia, Id, i )
|
||||
{
|
||||
pObj = Gia_ManObj(pGia, Id);
|
||||
for ( k = 0; k < nWords; k++ )
|
||||
fprintf( pFile, " Res ^= %cs%07d_%d;\n", Gia_ObjFaninC0(pObj) ? '~' : ' ', Gia_ObjFaninId0(pObj, Id), k );
|
||||
}
|
||||
Vec_WrdFree( vSim0 );
|
||||
fprintf( pFile, " }\n" );
|
||||
fprintf( pFile, " printf( \"Res = 0x%%08x \", (unsigned)Res );\n" );
|
||||
fprintf( pFile, " printf( \"Time = %%6.2f sec\\n\", (float)(clock() - clkThis)/CLOCKS_PER_SEC );\n" );
|
||||
fprintf( pFile, " return 1;\n" );
|
||||
fprintf( pFile, "}\n" );
|
||||
fclose( pFile );
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Trying vectorized simulation.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Gia_ManSimTwo( Gia_Man_t * p0, Gia_Man_t * p1, int nWords, int nRounds, int fVerbose )
|
||||
{
|
||||
Vec_Wrd_t * vSim0, * vSim1, * vSim2;
|
||||
abctime clk = Abc_Clock();
|
||||
int n, i, RetValue = 1;
|
||||
printf( "Simulating %d round with %d machine words.\n", nRounds, nWords );
|
||||
Abc_RandomW(0);
|
||||
for ( n = 0; RetValue && n < nRounds; n++ )
|
||||
{
|
||||
vSim0 = Vec_WrdStartRandom( Gia_ManCiNum(p0) * nWords );
|
||||
p0->vSimsPi = vSim0;
|
||||
p1->vSimsPi = vSim0;
|
||||
vSim1 = Gia_ManSimPatSim( p0 );
|
||||
vSim2 = Gia_ManSimPatSim( p1 );
|
||||
for ( i = 0; i < Gia_ManCoNum(p0); i++ )
|
||||
{
|
||||
word * pSim1 = Vec_WrdEntryP(vSim1, Gia_ObjId(p0, Gia_ManCo(p0, i))*nWords);
|
||||
word * pSim2 = Vec_WrdEntryP(vSim2, Gia_ObjId(p1, Gia_ManCo(p1, i))*nWords);
|
||||
if ( memcmp(pSim1, pSim2, sizeof(word)*nWords) )
|
||||
{
|
||||
printf( "Output %d failed simulation at round %d. ", i, n );
|
||||
RetValue = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Vec_WrdFree( vSim1 );
|
||||
Vec_WrdFree( vSim2 );
|
||||
Vec_WrdFree( vSim0 );
|
||||
p0->vSimsPi = NULL;
|
||||
p1->vSimsPi = NULL;
|
||||
}
|
||||
if ( RetValue == 1 )
|
||||
printf( "Simulation did not detect a bug. " );
|
||||
Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
|
||||
return RetValue;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Serialization.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_ManSim2ArrayOne( Vec_Wrd_t * vSimsPi, Vec_Int_t * vRes )
|
||||
{
|
||||
word * pInfo = Vec_WrdArray(vSimsPi); int w, i;
|
||||
word * pCare = pInfo + Vec_WrdSize(vSimsPi);
|
||||
Vec_IntClear( vRes );
|
||||
for ( w = 0; w < Vec_WrdSize(vSimsPi); w++ )
|
||||
if ( pCare[w] )
|
||||
for ( i = 0; i < 64; i++ )
|
||||
if ( Abc_TtGetBit(pCare, w*64+i) )
|
||||
Vec_IntPush( vRes, Abc_Var2Lit(w*64+i, Abc_TtGetBit(pInfo, w*64+i)) );
|
||||
Vec_IntPush( vRes, Vec_WrdSize(vSimsPi) );
|
||||
}
|
||||
Vec_Wec_t * Gia_ManSim2Array( Vec_Ptr_t * vSims )
|
||||
{
|
||||
Vec_Wec_t * vRes = Vec_WecStart( Vec_PtrSize(vSims) );
|
||||
Vec_Int_t * vLevel; int i;
|
||||
Vec_WecForEachLevel( vRes, vLevel, i )
|
||||
Gia_ManSim2ArrayOne( (Vec_Wrd_t *)Vec_PtrEntry(vSims, i), vLevel );
|
||||
return vRes;
|
||||
}
|
||||
|
||||
Vec_Wrd_t * Gia_ManArray2SimOne( Vec_Int_t * vRes )
|
||||
{
|
||||
int i, iLit, nWords = Vec_IntEntryLast(vRes);
|
||||
Vec_Wrd_t * vSimsPi = Vec_WrdStart( 2*nWords );
|
||||
word * pInfo = Vec_WrdArray(vSimsPi);
|
||||
word * pCare = pInfo + nWords;
|
||||
Vec_IntPop( vRes );
|
||||
Vec_IntForEachEntry( vRes, iLit, i )
|
||||
{
|
||||
Abc_TtXorBit( pCare, Abc_Lit2Var(iLit) );
|
||||
if ( Abc_LitIsCompl(iLit) )
|
||||
Abc_TtXorBit( pInfo, Abc_Lit2Var(iLit) );
|
||||
}
|
||||
Vec_IntPush( vRes, nWords );
|
||||
Vec_WrdShrink( vSimsPi, Vec_WrdSize(vSimsPi)/2 );
|
||||
return vSimsPi;
|
||||
}
|
||||
Vec_Ptr_t * Gia_ManArray2Sim( Vec_Wec_t * vRes )
|
||||
{
|
||||
Vec_Ptr_t * vSims = Vec_PtrAlloc( Vec_WecSize(vRes) );
|
||||
Vec_Int_t * vLevel; int i;
|
||||
Vec_WecForEachLevel( vRes, vLevel, i )
|
||||
Vec_PtrPush( vSims, Gia_ManArray2SimOne(vLevel) );
|
||||
return vSims;
|
||||
}
|
||||
|
||||
void Gia_ManSimArrayTest( Vec_Wrd_t * vSimsPi )
|
||||
{
|
||||
Vec_Ptr_t * vTemp = Vec_PtrAlloc( 2 );
|
||||
Vec_PtrPushTwo( vTemp, vSimsPi, vSimsPi );
|
||||
{
|
||||
Vec_Wec_t * vRes = Gia_ManSim2Array( vTemp );
|
||||
Vec_WecDumpBin( "temp.sims", vRes, 1 );
|
||||
{
|
||||
Vec_Wec_t * vRes = Vec_WecReadBin( "temp.sims", 1 );
|
||||
Vec_Ptr_t * vTemp2 = Gia_ManArray2Sim( vRes );
|
||||
Vec_Wrd_t * vSimsPi2 = (Vec_Wrd_t *)Vec_PtrEntry( vTemp2, 0 );
|
||||
Vec_Wrd_t * vSimsPi3 = (Vec_Wrd_t *)Vec_PtrEntry( vTemp2, 1 );
|
||||
|
||||
Abc_TtAnd( Vec_WrdArray(vSimsPi), Vec_WrdArray(vSimsPi), Vec_WrdArray(vSimsPi)+Vec_WrdSize(vSimsPi), Vec_WrdSize(vSimsPi), 0 );
|
||||
|
||||
vSimsPi->nSize *= 2;
|
||||
vSimsPi2->nSize *= 2;
|
||||
vSimsPi3->nSize *= 2;
|
||||
Vec_WrdDumpHex( "test1.hex", vSimsPi, 1, 1 );
|
||||
Vec_WrdDumpHex( "test2.hex", vSimsPi2, 1, 1 );
|
||||
Vec_WrdDumpHex( "test3.hex", vSimsPi3, 1, 1 );
|
||||
vSimsPi->nSize /= 2;
|
||||
vSimsPi2->nSize /= 2;
|
||||
vSimsPi3->nSize /= 2;
|
||||
|
||||
if ( Vec_WrdEqual( vSimsPi, vSimsPi2 ) )
|
||||
printf( "Success.\n" );
|
||||
else
|
||||
printf( "Failure.\n" );
|
||||
if ( Vec_WrdEqual( vSimsPi, vSimsPi3 ) )
|
||||
printf( "Success.\n" );
|
||||
else
|
||||
printf( "Failure.\n" );
|
||||
Vec_WrdFree( vSimsPi2 );
|
||||
Vec_WrdFree( vSimsPi3 );
|
||||
Vec_PtrFree( vTemp2 );
|
||||
Vec_WecFree( vRes );
|
||||
}
|
||||
Vec_WecFree( vRes );
|
||||
}
|
||||
Vec_PtrFree( vTemp );
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Serialization.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_ManPtrWrdDumpBin( char * pFileName, Vec_Ptr_t * p, int fVerbose )
|
||||
{
|
||||
Vec_Wrd_t * vLevel;
|
||||
int i, nSize, RetValue;
|
||||
FILE * pFile = fopen( pFileName, "wb" );
|
||||
if ( pFile == NULL )
|
||||
{
|
||||
printf( "Cannot open file \"%s\" for writing.\n", pFileName );
|
||||
return;
|
||||
}
|
||||
nSize = Vec_PtrSize(p);
|
||||
RetValue = fwrite( &nSize, 1, sizeof(int), pFile );
|
||||
Vec_PtrForEachEntry( Vec_Wrd_t *, p, vLevel, i )
|
||||
{
|
||||
nSize = Vec_WrdSize(vLevel);
|
||||
RetValue += fwrite( &nSize, 1, sizeof(int), pFile );
|
||||
RetValue += fwrite( Vec_WrdArray(vLevel), 1, sizeof(word)*nSize, pFile );
|
||||
}
|
||||
fclose( pFile );
|
||||
if ( fVerbose )
|
||||
printf( "Written %d arrays into file \"%s\".\n", Vec_PtrSize(p), pFileName );
|
||||
}
|
||||
Vec_Ptr_t * Gia_ManPtrWrdReadBin( char * pFileName, int fVerbose )
|
||||
{
|
||||
Vec_Ptr_t * p = NULL; Vec_Wrd_t * vLevel; int i, nSize, RetValue;
|
||||
FILE * pFile = fopen( pFileName, "rb" );
|
||||
if ( pFile == NULL )
|
||||
{
|
||||
printf( "Cannot open file \"%s\" for reading.\n", pFileName );
|
||||
return NULL;
|
||||
}
|
||||
fseek( pFile, 0, SEEK_END );
|
||||
nSize = ftell( pFile );
|
||||
if ( nSize == 0 )
|
||||
{
|
||||
printf( "The input file is empty.\n" );
|
||||
fclose( pFile );
|
||||
return NULL;
|
||||
}
|
||||
if ( nSize % (int)sizeof(int) > 0 )
|
||||
{
|
||||
printf( "Cannot read file with integers because it is not aligned at 4 bytes (remainder = %d).\n", nSize % (int)sizeof(int) );
|
||||
fclose( pFile );
|
||||
return NULL;
|
||||
}
|
||||
rewind( pFile );
|
||||
RetValue = fread( &nSize, 1, sizeof(int), pFile );
|
||||
assert( RetValue == 4 );
|
||||
p = Vec_PtrAlloc( nSize );
|
||||
for ( i = 0; i < nSize; i++ )
|
||||
Vec_PtrPush( p, Vec_WrdAlloc(100) );
|
||||
Vec_PtrForEachEntry( Vec_Wrd_t *, p, vLevel, i )
|
||||
{
|
||||
RetValue = fread( &nSize, 1, sizeof(int), pFile );
|
||||
assert( RetValue == 4 );
|
||||
Vec_WrdFill( vLevel, nSize, 0 );
|
||||
RetValue = fread( Vec_WrdArray(vLevel), 1, sizeof(word)*nSize, pFile );
|
||||
assert( RetValue == 8*nSize );
|
||||
}
|
||||
fclose( pFile );
|
||||
if ( fVerbose )
|
||||
printf( "Read %d arrays from file \"%s\".\n", Vec_PtrSize(p), pFileName );
|
||||
return p;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -0,0 +1,448 @@
|
|||
/**CFile****************************************************************
|
||||
|
||||
FileName [giaDeep.c]
|
||||
|
||||
SystemName [ABC: Logic synthesis and verification system.]
|
||||
|
||||
PackageName [Scalable AIG package.]
|
||||
|
||||
Synopsis [Experiments with synthesis.]
|
||||
|
||||
Author [Alan Mishchenko]
|
||||
|
||||
Affiliation [UC Berkeley]
|
||||
|
||||
Date [Ver. 1.0. Started - June 20, 2005.]
|
||||
|
||||
Revision [$Id: giaDeep.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
|
||||
|
||||
***********************************************************************/
|
||||
|
||||
#include "gia.h"
|
||||
#include "base/main/main.h"
|
||||
#include "base/cmd/cmd.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// DECLARATIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// FUNCTION DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_ManDupMapping( Gia_Man_t * pNew, Gia_Man_t * p )
|
||||
{
|
||||
Gia_Obj_t * pObj, * pFanin; int i, k;
|
||||
Vec_Int_t * vMapping = p->vMapping ? Vec_IntAlloc( Vec_IntSize(p->vMapping) ) : NULL;
|
||||
if ( p->vMapping == NULL )
|
||||
return;
|
||||
Vec_IntFill( vMapping, Gia_ManObjNum(p), 0 );
|
||||
Gia_ManForEachLut( p, i )
|
||||
{
|
||||
pObj = Gia_ManObj( p, i );
|
||||
Vec_IntWriteEntry( vMapping, Abc_Lit2Var(pObj->Value), Vec_IntSize(vMapping) );
|
||||
Vec_IntPush( vMapping, Gia_ObjLutSize(p, i) );
|
||||
Gia_LutForEachFaninObj( p, i, pFanin, k )
|
||||
Vec_IntPush( vMapping, Abc_Lit2Var(pFanin->Value) );
|
||||
Vec_IntPush( vMapping, Abc_Lit2Var(pObj->Value) );
|
||||
}
|
||||
pNew->vMapping = vMapping;
|
||||
}
|
||||
Gia_Man_t * Gia_ManDupWithMapping( Gia_Man_t * pGia )
|
||||
{
|
||||
Gia_Man_t * pCopy = Gia_ManDup(pGia);
|
||||
Gia_ManDupMapping( pCopy, pGia );
|
||||
return pCopy;
|
||||
}
|
||||
void Gia_ManStochSynthesis( Vec_Ptr_t * vAigs, char * pScript )
|
||||
{
|
||||
Gia_Man_t * pGia, * pNew; int i;
|
||||
Vec_PtrForEachEntry( Gia_Man_t *, vAigs, pGia, i )
|
||||
{
|
||||
Gia_Man_t * pCopy = Gia_ManDupWithMapping(pGia);
|
||||
Abc_FrameUpdateGia( Abc_FrameGetGlobalFrame(), pGia );
|
||||
if ( Abc_FrameIsBatchMode() )
|
||||
{
|
||||
if ( Cmd_CommandExecute(Abc_FrameGetGlobalFrame(), pScript) )
|
||||
{
|
||||
Abc_Print( 1, "Something did not work out with the command \"%s\".\n", pScript );
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Abc_FrameSetBatchMode( 1 );
|
||||
if ( Cmd_CommandExecute(Abc_FrameGetGlobalFrame(), pScript) )
|
||||
{
|
||||
Abc_Print( 1, "Something did not work out with the command \"%s\".\n", pScript );
|
||||
Abc_FrameSetBatchMode( 0 );
|
||||
return;
|
||||
}
|
||||
Abc_FrameSetBatchMode( 0 );
|
||||
}
|
||||
pNew = Abc_FrameReadGia(Abc_FrameGetGlobalFrame());
|
||||
if ( Gia_ManHasMapping(pNew) && Gia_ManHasMapping(pCopy) )
|
||||
{
|
||||
if ( Gia_ManLutNum(pNew) < Gia_ManLutNum(pCopy) )
|
||||
{
|
||||
Gia_ManStop( pCopy );
|
||||
pCopy = Gia_ManDupWithMapping( pNew );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( Gia_ManAndNum(pNew) < Gia_ManAndNum(pCopy) )
|
||||
{
|
||||
Gia_ManStop( pCopy );
|
||||
pCopy = Gia_ManDup( pNew );
|
||||
}
|
||||
}
|
||||
Vec_PtrWriteEntry( vAigs, i, pCopy );
|
||||
}
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_ManCollectNodes_rec( Gia_Man_t * p, int iObj, Vec_Int_t * vAnds )
|
||||
{
|
||||
Gia_Obj_t * pObj;
|
||||
if ( Gia_ObjUpdateTravIdCurrentId( p, iObj ) )
|
||||
return;
|
||||
pObj = Gia_ManObj( p, iObj );
|
||||
if ( Gia_ObjIsCi(pObj) || iObj == 0 )
|
||||
return;
|
||||
assert( Gia_ObjIsAnd(pObj) );
|
||||
Gia_ManCollectNodes_rec( p, Gia_ObjFaninId0(pObj, iObj), vAnds );
|
||||
Gia_ManCollectNodes_rec( p, Gia_ObjFaninId1(pObj, iObj), vAnds );
|
||||
Vec_IntPush( vAnds, iObj );
|
||||
}
|
||||
void Gia_ManCollectNodes( Gia_Man_t * p, Vec_Int_t * vCis, Vec_Int_t * vAnds, Vec_Int_t * vCos )
|
||||
{
|
||||
int i, iObj;
|
||||
if ( !Gia_ManHasMapping(p) )
|
||||
return;
|
||||
Vec_IntClear( vAnds );
|
||||
Gia_ManIncrementTravId( p );
|
||||
Vec_IntForEachEntry( vCis, iObj, i )
|
||||
Gia_ObjSetTravIdCurrentId( p, iObj );
|
||||
Vec_IntForEachEntry( vCos, iObj, i )
|
||||
Gia_ManCollectNodes_rec( p, iObj, vAnds );
|
||||
}
|
||||
Gia_Man_t * Gia_ManDupDivideOne( Gia_Man_t * p, Vec_Int_t * vCis, Vec_Int_t * vAnds, Vec_Int_t * vCos )
|
||||
{
|
||||
Vec_Int_t * vMapping; int i;
|
||||
Gia_Man_t * pNew; Gia_Obj_t * pObj;
|
||||
pNew = Gia_ManStart( 1+Vec_IntSize(vCis)+Vec_IntSize(vAnds)+Vec_IntSize(vCos) );
|
||||
pNew->pName = Abc_UtilStrsav( p->pName );
|
||||
Gia_ManFillValue(p);
|
||||
Gia_ManConst0(p)->Value = 0;
|
||||
Gia_ManForEachObjVec( vCis, p, pObj, i )
|
||||
pObj->Value = Gia_ManAppendCi( pNew );
|
||||
Gia_ManForEachObjVec( vAnds, p, pObj, i )
|
||||
pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
|
||||
Gia_ManForEachObjVec( vCos, p, pObj, i )
|
||||
Gia_ManAppendCo( pNew, pObj->Value );
|
||||
assert( Gia_ManCiNum(pNew) > 0 && Gia_ManCoNum(pNew) > 0 );
|
||||
if ( !Gia_ManHasMapping(p) )
|
||||
return pNew;
|
||||
vMapping = Vec_IntAlloc( 4*Gia_ManObjNum(pNew) );
|
||||
Vec_IntFill( vMapping, Gia_ManObjNum(pNew), 0 );
|
||||
Gia_ManForEachObjVec( vAnds, p, pObj, i )
|
||||
{
|
||||
Gia_Obj_t * pFanin; int k;
|
||||
int iObj = Gia_ObjId(p, pObj);
|
||||
if ( !Gia_ObjIsLut(p, iObj) )
|
||||
continue;
|
||||
Vec_IntWriteEntry( vMapping, Abc_Lit2Var(pObj->Value), Vec_IntSize(vMapping) );
|
||||
Vec_IntPush( vMapping, Gia_ObjLutSize(p, iObj) );
|
||||
Gia_LutForEachFaninObj( p, iObj, pFanin, k )
|
||||
Vec_IntPush( vMapping, Abc_Lit2Var(pFanin->Value) );
|
||||
Vec_IntPush( vMapping, Abc_Lit2Var(pObj->Value) );
|
||||
}
|
||||
pNew->vMapping = vMapping;
|
||||
return pNew;
|
||||
}
|
||||
Vec_Ptr_t * Gia_ManDupDivide( Gia_Man_t * p, Vec_Wec_t * vCis, Vec_Wec_t * vAnds, Vec_Wec_t * vCos, char * pScript )
|
||||
{
|
||||
Vec_Ptr_t * vAigs = Vec_PtrAlloc( Vec_WecSize(vCis) ); int i;
|
||||
for ( i = 0; i < Vec_WecSize(vCis); i++ )
|
||||
{
|
||||
Gia_ManCollectNodes( p, Vec_WecEntry(vCis, i), Vec_WecEntry(vAnds, i), Vec_WecEntry(vCos, i) );
|
||||
Vec_PtrPush( vAigs, Gia_ManDupDivideOne(p, Vec_WecEntry(vCis, i), Vec_WecEntry(vAnds, i), Vec_WecEntry(vCos, i)) );
|
||||
}
|
||||
Gia_ManStochSynthesis( vAigs, pScript );
|
||||
return vAigs;
|
||||
}
|
||||
Gia_Man_t * Gia_ManDupStitch( Gia_Man_t * p, Vec_Wec_t * vCis, Vec_Wec_t * vAnds, Vec_Wec_t * vCos, Vec_Ptr_t * vAigs, int fHash )
|
||||
{
|
||||
Gia_Man_t * pGia, * pNew;
|
||||
Gia_Obj_t * pObj; int i, k;
|
||||
pNew = Gia_ManStart( Gia_ManObjNum(p) );
|
||||
pNew->pName = Abc_UtilStrsav( p->pName );
|
||||
pNew->pSpec = Abc_UtilStrsav( p->pSpec );
|
||||
Gia_ManCleanValue( p );
|
||||
Gia_ManConst0(p)->Value = 0;
|
||||
Gia_ManForEachCi( p, pObj, i )
|
||||
pObj->Value = Gia_ManAppendCi( pNew );
|
||||
if ( fHash )
|
||||
Gia_ManHashAlloc( pNew );
|
||||
Vec_PtrForEachEntry( Gia_Man_t *, vAigs, pGia, i )
|
||||
{
|
||||
Vec_Int_t * vCi = Vec_WecEntry( vCis, i );
|
||||
Vec_Int_t * vCo = Vec_WecEntry( vCos, i );
|
||||
Gia_ManCleanValue( pGia );
|
||||
Gia_ManConst0(pGia)->Value = 0;
|
||||
Gia_ManForEachObjVec( vCi, p, pObj, k )
|
||||
Gia_ManCi(pGia, k)->Value = pObj->Value;
|
||||
if ( fHash )
|
||||
Gia_ManForEachAnd( pGia, pObj, k )
|
||||
pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
|
||||
else
|
||||
Gia_ManForEachAnd( pGia, pObj, k )
|
||||
pObj->Value = Gia_ManAppendAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
|
||||
Gia_ManForEachObjVec( vCo, p, pObj, k )
|
||||
pObj->Value = Gia_ObjFanin0Copy(Gia_ManCo(pGia, k));
|
||||
}
|
||||
Gia_ManForEachCo( p, pObj, i )
|
||||
Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
|
||||
if ( fHash )
|
||||
{
|
||||
pNew = Gia_ManCleanup( pGia = pNew );
|
||||
Gia_ManStop( pGia );
|
||||
}
|
||||
Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
|
||||
return pNew;
|
||||
}
|
||||
Gia_Man_t * Gia_ManDupStitchMap( Gia_Man_t * p, Vec_Wec_t * vCis, Vec_Wec_t * vAnds, Vec_Wec_t * vCos, Vec_Ptr_t * vAigs )
|
||||
{
|
||||
Vec_Int_t * vMapping; int n;
|
||||
Gia_Man_t * pGia, * pNew = Gia_ManDupStitch( p, vCis, vAnds, vCos, vAigs, !Gia_ManHasMapping(p) );
|
||||
if ( !Gia_ManHasMapping(p) )
|
||||
return pNew;
|
||||
vMapping = Vec_IntAlloc( Vec_IntSize(p->vMapping) );
|
||||
Vec_IntFill( vMapping, Gia_ManObjNum(pNew), 0 );
|
||||
Vec_PtrForEachEntry( Gia_Man_t *, vAigs, pGia, n )
|
||||
{
|
||||
Gia_Obj_t * pFanin; int iObj, k;
|
||||
//printf( "Gia %d has %d Luts\n", n, Gia_ManLutNum(pGia) );
|
||||
|
||||
Gia_ManForEachLut( pGia, iObj )
|
||||
{
|
||||
Gia_Obj_t * pObj = Gia_ManObj( pGia, iObj );
|
||||
Vec_IntWriteEntry( vMapping, Abc_Lit2Var(pObj->Value), Vec_IntSize(vMapping) );
|
||||
Vec_IntPush( vMapping, Gia_ObjLutSize(pGia, iObj) );
|
||||
Gia_LutForEachFaninObj( pGia, iObj, pFanin, k )
|
||||
Vec_IntPush( vMapping, Abc_Lit2Var(pFanin->Value) );
|
||||
Vec_IntPush( vMapping, Abc_Lit2Var(pObj->Value) );
|
||||
}
|
||||
}
|
||||
pNew->vMapping = vMapping;
|
||||
return pNew;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Vec_Wec_t * Gia_ManStochNodes( Gia_Man_t * p, int nMaxSize, int Seed )
|
||||
{
|
||||
Vec_Wec_t * vRes = Vec_WecAlloc( 100 );
|
||||
Vec_Int_t * vPart = Vec_WecPushLevel( vRes );
|
||||
int i, iStart = Seed % Gia_ManCoNum(p);
|
||||
//Gia_ManLevelNum( p );
|
||||
Gia_ManIncrementTravId( p );
|
||||
for ( i = 0; i < Gia_ManCoNum(p); i++ )
|
||||
{
|
||||
Gia_Obj_t * pObj = Gia_ManCo( p, (iStart+i) % Gia_ManCoNum(p) );
|
||||
if ( Vec_IntSize(vPart) > nMaxSize )
|
||||
vPart = Vec_WecPushLevel( vRes );
|
||||
Gia_ManCollectNodes_rec( p, Gia_ObjFaninId0p(p, pObj), vPart );
|
||||
}
|
||||
if ( Vec_IntSize(vPart) == 0 )
|
||||
Vec_WecShrink( vRes, Vec_WecSize(vRes)-1 );
|
||||
//Vec_WecPrint( vRes, 0 );
|
||||
return vRes;
|
||||
}
|
||||
Vec_Wec_t * Gia_ManStochInputs( Gia_Man_t * p, Vec_Wec_t * vAnds )
|
||||
{
|
||||
Vec_Wec_t * vRes = Vec_WecAlloc( 100 );
|
||||
Vec_Int_t * vLevel; Gia_Obj_t * pObj; int i, k, iObj, iFan, f;
|
||||
Vec_WecForEachLevel( vAnds, vLevel, i )
|
||||
{
|
||||
Vec_Int_t * vVec = Vec_WecPushLevel( vRes );
|
||||
assert( Vec_IntSize(vVec) == 0 );
|
||||
Gia_ManIncrementTravId( p );
|
||||
Vec_IntForEachEntry( vLevel, iObj, k )
|
||||
Gia_ObjSetTravIdCurrentId( p, iObj );
|
||||
if ( Gia_ManHasMapping(p) )
|
||||
{
|
||||
Vec_IntForEachEntry( vLevel, iObj, k )
|
||||
if ( Gia_ObjIsLut(p, iObj) )
|
||||
Gia_LutForEachFanin( p, iObj, iFan, f )
|
||||
if ( !Gia_ObjUpdateTravIdCurrentId(p, iFan) )
|
||||
Vec_IntPush( vVec, iFan );
|
||||
}
|
||||
else
|
||||
{
|
||||
Gia_ManForEachObjVec( vLevel, p, pObj, k )
|
||||
{
|
||||
iObj = Gia_ObjFaninId0p(p, pObj);
|
||||
if ( !Gia_ObjUpdateTravIdCurrentId(p, iObj) )
|
||||
Vec_IntPush( vVec, iObj );
|
||||
iObj = Gia_ObjFaninId1p(p, pObj);
|
||||
if ( !Gia_ObjUpdateTravIdCurrentId(p, iObj) )
|
||||
Vec_IntPush( vVec, iObj );
|
||||
}
|
||||
}
|
||||
assert( Vec_IntSize(vVec) > 0 );
|
||||
}
|
||||
return vRes;
|
||||
}
|
||||
Vec_Wec_t * Gia_ManStochOutputs( Gia_Man_t * p, Vec_Wec_t * vAnds )
|
||||
{
|
||||
Vec_Wec_t * vRes = Vec_WecAlloc( 100 );
|
||||
Vec_Int_t * vLevel; Gia_Obj_t * pObj; int i, k, iObj, iFan, f;
|
||||
if ( Gia_ManHasMapping(p) )
|
||||
{
|
||||
Gia_ManSetLutRefs( p );
|
||||
Vec_WecForEachLevel( vAnds, vLevel, i )
|
||||
{
|
||||
Vec_Int_t * vVec = Vec_WecPushLevel( vRes );
|
||||
assert( Vec_IntSize(vVec) == 0 );
|
||||
Vec_IntForEachEntry( vLevel, iObj, k )
|
||||
if ( Gia_ObjIsLut(p, iObj) )
|
||||
Gia_LutForEachFanin( p, iObj, iFan, f )
|
||||
Gia_ObjLutRefDecId( p, iFan );
|
||||
Vec_IntForEachEntry( vLevel, iObj, k )
|
||||
if ( Gia_ObjIsLut(p, iObj) )
|
||||
if ( Gia_ObjLutRefNumId(p, iObj) )
|
||||
Vec_IntPush( vVec, iObj );
|
||||
Vec_IntForEachEntry( vLevel, iObj, k )
|
||||
if ( Gia_ObjIsLut(p, iObj) )
|
||||
Gia_LutForEachFanin( p, iObj, iFan, f )
|
||||
Gia_ObjLutRefIncId( p, iFan );
|
||||
assert( Vec_IntSize(vVec) > 0 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Gia_ManCreateRefs( p );
|
||||
Vec_WecForEachLevel( vAnds, vLevel, i )
|
||||
{
|
||||
Vec_Int_t * vVec = Vec_WecPushLevel( vRes );
|
||||
Gia_ManForEachObjVec( vLevel, p, pObj, k )
|
||||
{
|
||||
Gia_ObjRefDecId( p, Gia_ObjFaninId0p(p, pObj) );
|
||||
Gia_ObjRefDecId( p, Gia_ObjFaninId1p(p, pObj) );
|
||||
}
|
||||
Gia_ManForEachObjVec( vLevel, p, pObj, k )
|
||||
if ( Gia_ObjRefNum(p, pObj) )
|
||||
Vec_IntPush( vVec, Gia_ObjId(p, pObj) );
|
||||
Gia_ManForEachObjVec( vLevel, p, pObj, k )
|
||||
{
|
||||
Gia_ObjRefIncId( p, Gia_ObjFaninId0p(p, pObj) );
|
||||
Gia_ObjRefIncId( p, Gia_ObjFaninId1p(p, pObj) );
|
||||
}
|
||||
}
|
||||
}
|
||||
return vRes;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_ManStochSyn( int nMaxSize, int nIters, int TimeOut, int Seed, int fVerbose, char * pScript )
|
||||
{
|
||||
abctime nTimeToStop = TimeOut ? Abc_Clock() + TimeOut * CLOCKS_PER_SEC : 0;
|
||||
abctime clkStart = Abc_Clock();
|
||||
int fMapped = Gia_ManHasMapping(Abc_FrameReadGia(Abc_FrameGetGlobalFrame()));
|
||||
int nLutEnd, nLutBeg = fMapped ? Gia_ManLutNum(Abc_FrameReadGia(Abc_FrameGetGlobalFrame())) : 0;
|
||||
int i, nEnd, nBeg = Gia_ManAndNum(Abc_FrameReadGia(Abc_FrameGetGlobalFrame()));
|
||||
Abc_Random(1);
|
||||
for ( i = 0; i < 10+Seed; i++ )
|
||||
Abc_Random(0);
|
||||
if ( fVerbose )
|
||||
printf( "Running %d iterations of script \"%s\".\n", nIters, pScript );
|
||||
for ( i = 0; i < nIters; i++ )
|
||||
{
|
||||
abctime clk = Abc_Clock();
|
||||
Gia_Man_t * pGia = Gia_ManDupWithMapping( Abc_FrameReadGia(Abc_FrameGetGlobalFrame()) );
|
||||
Vec_Wec_t * vAnds = Gia_ManStochNodes( pGia, nMaxSize, Abc_Random(0) & 0x7FFFFFFF );
|
||||
Vec_Wec_t * vIns = Gia_ManStochInputs( pGia, vAnds );
|
||||
Vec_Wec_t * vOuts = Gia_ManStochOutputs( pGia, vAnds );
|
||||
Vec_Ptr_t * vAigs = Gia_ManDupDivide( pGia, vIns, vAnds, vOuts, pScript );
|
||||
Gia_Man_t * pNew = Gia_ManDupStitchMap( pGia, vIns, vAnds, vOuts, vAigs );
|
||||
int fMapped = Gia_ManHasMapping(pGia) && Gia_ManHasMapping(pNew);
|
||||
Abc_FrameUpdateGia( Abc_FrameGetGlobalFrame(), pNew );
|
||||
if ( fVerbose )
|
||||
printf( "Iteration %3d : Using %3d partitions. Reducing %6d to %6d %s. ",
|
||||
i, Vec_PtrSize(vAigs), fMapped ? Gia_ManLutNum(pGia) : Gia_ManAndNum(pGia),
|
||||
fMapped ? Gia_ManLutNum(pNew) : Gia_ManAndNum(pNew),
|
||||
fMapped ? "LUTs" : "ANDs" );
|
||||
if ( fVerbose )
|
||||
Abc_PrintTime( 0, "Time", Abc_Clock() - clk );
|
||||
Gia_ManStop( pGia );
|
||||
Vec_PtrFreeFunc( vAigs, (void (*)(void *)) Gia_ManStop );
|
||||
Vec_WecFree( vAnds );
|
||||
Vec_WecFree( vIns );
|
||||
Vec_WecFree( vOuts );
|
||||
if ( nTimeToStop && Abc_Clock() > nTimeToStop )
|
||||
{
|
||||
printf( "Runtime limit (%d sec) is reached after %d iterations.\n", TimeOut, i );
|
||||
break;
|
||||
}
|
||||
}
|
||||
fMapped &= Gia_ManHasMapping(Abc_FrameReadGia(Abc_FrameGetGlobalFrame()));
|
||||
nLutEnd = fMapped ? Gia_ManLutNum(Abc_FrameReadGia(Abc_FrameGetGlobalFrame())) : 0;
|
||||
nEnd = Gia_ManAndNum(Abc_FrameReadGia(Abc_FrameGetGlobalFrame()));
|
||||
if ( fVerbose )
|
||||
printf( "Cumulatively reduced %d %s after %d iterations. ",
|
||||
fMapped ? nLutBeg - nLutEnd : nBeg - nEnd, fMapped ? "LUTs" : "ANDs", nIters );
|
||||
if ( fVerbose )
|
||||
Abc_PrintTime( 0, "Total time", Abc_Clock() - clkStart );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
||||
|
|
@ -736,7 +736,7 @@ Str_Ntk_t * Str_ManNormalizeInt( Gia_Man_t * p, Vec_Wec_t * vGroups, Vec_Int_t *
|
|||
if ( p->vStore == NULL )
|
||||
p->vStore = Vec_IntAlloc( STR_SUPER );
|
||||
Gia_ManFillValue( p );
|
||||
pNtk = Str_NtkCreate( Gia_ManObjNum(p), 1 + Gia_ManCoNum(p) + 2 * Gia_ManAndNum(p) + Gia_ManMuxNum(p) );
|
||||
pNtk = Str_NtkCreate( Gia_ManObjNum(p) + 10000, 1 + Gia_ManCoNum(p) + 2 * Gia_ManAndNum(p) + Gia_ManMuxNum(p) + 10000 );
|
||||
Gia_ManConst0(p)->Value = 0;
|
||||
Gia_ManForEachObj1( p, pObj, i )
|
||||
{
|
||||
|
|
@ -749,7 +749,7 @@ Str_Ntk_t * Str_ManNormalizeInt( Gia_Man_t * p, Vec_Wec_t * vGroups, Vec_Int_t *
|
|||
pObj->Value = Str_ObjCreate( pNtk, STR_PO, 1, &iFanin );
|
||||
}
|
||||
}
|
||||
assert( pNtk->nObjs <= Gia_ManObjNum(p) );
|
||||
//assert( pNtk->nObjs <= Gia_ManObjNum(p) );
|
||||
return pNtk;
|
||||
}
|
||||
Str_Ntk_t * Str_ManNormalize( Gia_Man_t * p )
|
||||
|
|
@ -859,21 +859,23 @@ static inline void transpose64( word A[64] )
|
|||
static inline int Str_ManNum( Gia_Man_t * p, int iObj ) { return Vec_IntEntry(&p->vCopies, iObj); }
|
||||
static inline void Str_ManSetNum( Gia_Man_t * p, int iObj, int Num ) { Vec_IntWriteEntry(&p->vCopies, iObj, Num); }
|
||||
|
||||
int Str_ManVectorAffinity( Gia_Man_t * p, Vec_Int_t * vSuper, Vec_Int_t * vDelay, word Matrix[256], int nLimit )
|
||||
int Str_ManVectorAffinity( Gia_Man_t * p, Vec_Int_t * vSuper, Vec_Int_t * vDelay, word * Matrix, int nLimit )
|
||||
{
|
||||
int fVerbose = 0;
|
||||
int Levels[256];
|
||||
int * Levels = NULL;
|
||||
int nSize = Vec_IntSize(vSuper);
|
||||
int Prev = nSize, nLevels = 1;
|
||||
int i, k, iLit, iFanin, nSizeNew;
|
||||
word Mask;
|
||||
assert( nSize > 2 );
|
||||
assert( nSize <= nLimit );
|
||||
if ( nSize > 64 )
|
||||
{
|
||||
for ( i = 0; i < 64; i++ )
|
||||
Matrix[i] = 0;
|
||||
return 0;
|
||||
}
|
||||
Levels = ABC_ALLOC( int, nLimit+256 );
|
||||
// mark current nodes
|
||||
Gia_ManIncrementTravId( p );
|
||||
Vec_IntForEachEntry( vSuper, iLit, i )
|
||||
|
|
@ -948,6 +950,7 @@ int Str_ManVectorAffinity( Gia_Man_t * p, Vec_Int_t * vSuper, Vec_Int_t * vDelay
|
|||
if ( nSizeNew == 0 )
|
||||
{
|
||||
Vec_IntShrink( vSuper, nSize );
|
||||
ABC_FREE( Levels );
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
|
|
@ -979,6 +982,7 @@ int Str_ManVectorAffinity( Gia_Man_t * p, Vec_Int_t * vSuper, Vec_Int_t * vDelay
|
|||
}
|
||||
i = 0;
|
||||
}
|
||||
ABC_FREE( Levels );
|
||||
Vec_IntShrink( vSuper, nSize );
|
||||
return nSizeNew;
|
||||
}
|
||||
|
|
@ -1088,15 +1092,14 @@ int Str_NtkBalanceTwo( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, int i,
|
|||
|
||||
void Str_NtkBalanceMulti( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, Vec_Int_t * vDelay, int nLutSize )
|
||||
{
|
||||
word pMatrix[256];
|
||||
int Limit = 256;
|
||||
word * pMatrix = ABC_ALLOC( word, pObj->nFanins+256 );
|
||||
Vec_Int_t * vSuper = pNew->vSuper;
|
||||
Vec_Int_t * vCosts = pNew->vStore;
|
||||
int * pSuper = Vec_IntArray(vSuper);
|
||||
int * pCost = Vec_IntArray(vCosts);
|
||||
int k, iLit, MatrixSize = 0;
|
||||
assert( Limit <= Vec_IntCap(vSuper) );
|
||||
assert( Limit <= Vec_IntCap(vCosts) );
|
||||
assert( (int)pObj->nFanins <= Vec_IntCap(vSuper) );
|
||||
assert( (int)pObj->nFanins <= Vec_IntCap(vCosts) );
|
||||
|
||||
// collect nodes
|
||||
Vec_IntClear( vSuper );
|
||||
|
|
@ -1111,11 +1114,13 @@ void Str_NtkBalanceMulti( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, Vec
|
|||
if ( Vec_IntSize(vSuper) == 1 )
|
||||
{
|
||||
pObj->iCopy = Vec_IntEntry(vSuper, 0);
|
||||
ABC_FREE( pMatrix );
|
||||
return;
|
||||
}
|
||||
if ( Vec_IntSize(vSuper) == 2 )
|
||||
{
|
||||
pObj->iCopy = Str_NtkBalanceTwo( pNew, p, pObj, 0, 1, vDelay, pCost, pSuper, pMatrix, 2, nLutSize, -1 );
|
||||
ABC_FREE( pMatrix );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1127,7 +1132,7 @@ void Str_NtkBalanceMulti( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, Vec
|
|||
|
||||
// compute affinity
|
||||
if ( Vec_IntSize(vSuper) < 64 )
|
||||
MatrixSize = Str_ManVectorAffinity( pNew, vSuper, vCosts, pMatrix, Limit );
|
||||
MatrixSize = Str_ManVectorAffinity( pNew, vSuper, vCosts, pMatrix, pObj->nFanins );
|
||||
|
||||
// start the new product
|
||||
while ( Vec_IntSize(vSuper) > 2 )
|
||||
|
|
@ -1147,7 +1152,7 @@ void Str_NtkBalanceMulti( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, Vec
|
|||
|
||||
// compute affinity
|
||||
if ( Vec_IntSize(vSuper) == 64 )
|
||||
MatrixSize = Str_ManVectorAffinity( pNew, vSuper, vCosts, pMatrix, Limit );
|
||||
MatrixSize = Str_ManVectorAffinity( pNew, vSuper, vCosts, pMatrix, pObj->nFanins );
|
||||
assert( Vec_IntSize(vSuper) <= 64 );
|
||||
// Str_PrintState( pCost, pSuper, pMatrix, Vec_IntSize(vSuper) );
|
||||
|
||||
|
|
@ -1236,6 +1241,7 @@ void Str_NtkBalanceMulti( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, Vec
|
|||
continue;
|
||||
}
|
||||
pObj->iCopy = Str_NtkBalanceTwo( pNew, p, pObj, 0, 1, vDelay, pCost, pSuper, pMatrix, 2, nLutSize, -1 );
|
||||
ABC_FREE( pMatrix );
|
||||
|
||||
/*
|
||||
// simple
|
||||
|
|
|
|||
|
|
@ -0,0 +1,817 @@
|
|||
/**CFile****************************************************************
|
||||
|
||||
FileName [giaSupp.c]
|
||||
|
||||
SystemName [ABC: Logic synthesis and verification system.]
|
||||
|
||||
PackageName [Scalable AIG package.]
|
||||
|
||||
Synopsis [Support computation manager.]
|
||||
|
||||
Author [Alan Mishchenko]
|
||||
|
||||
Affiliation [UC Berkeley]
|
||||
|
||||
Date [Ver. 1.0. Started - June 20, 2005.]
|
||||
|
||||
Revision [$Id: giaSupp.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
|
||||
|
||||
***********************************************************************/
|
||||
|
||||
#include "aig/gia/gia.h"
|
||||
#include "base/main/mainInt.h"
|
||||
#include "misc/util/utilTruth.h"
|
||||
#include "misc/extra/extra.h"
|
||||
#include "misc/vec/vecHsh.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// DECLARATIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct Supp_Man_t_ Supp_Man_t;
|
||||
struct Supp_Man_t_
|
||||
{
|
||||
// user data
|
||||
int nIters; // optimization rounds
|
||||
int nRounds; // optimization rounds
|
||||
int nWords; // the number of simulation words
|
||||
int nDivWords; // the number of divisor words
|
||||
Vec_Wrd_t * vIsfs; // functions to synthesize
|
||||
Vec_Int_t * vCands; // candidate divisors
|
||||
Vec_Int_t * vWeights; // divisor weights (optional)
|
||||
Vec_Wrd_t * vSims; // simulation values
|
||||
Vec_Wrd_t * vSimsC; // simulation values
|
||||
Gia_Man_t * pGia; // used for object names
|
||||
// computed data
|
||||
Vec_Wrd_t * vDivs[2]; // simulation values
|
||||
Vec_Wrd_t * vPats[2]; // simulation values
|
||||
Vec_Ptr_t * vMatrix; // simulation values
|
||||
Vec_Wrd_t * vMask; // simulation values
|
||||
Vec_Wrd_t * vRowTemp; // simulation values
|
||||
Vec_Int_t * vCosts; // candidate costs
|
||||
Hsh_VecMan_t * pHash; // subsets considered
|
||||
Vec_Wrd_t * vSFuncs; // ISF storage
|
||||
Vec_Int_t * vSStarts; // subset function starts
|
||||
Vec_Int_t * vSCount; // subset function count
|
||||
Vec_Int_t * vSPairs; // subset pair count
|
||||
Vec_Int_t * vTemp; // temporary
|
||||
Vec_Int_t * vTempSets; // temporary
|
||||
Vec_Int_t * vTempPairs; // temporary
|
||||
Vec_Wec_t * vSolutions; // solutions for each node count
|
||||
};
|
||||
|
||||
extern void Extra_BitMatrixTransposeP( Vec_Wrd_t * vSimsIn, int nWordsIn, Vec_Wrd_t * vSimsOut, int nWordsOut );
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// FUNCTION DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Supp_ManFuncInit( Vec_Wrd_t * vFuncs, int nWords )
|
||||
{
|
||||
int i, k = 0, nFuncs = Vec_WrdSize(vFuncs) / nWords / 2;
|
||||
assert( 2 * nFuncs * nWords == Vec_WrdSize(vFuncs) );
|
||||
for ( i = 0; i < nFuncs; i++ )
|
||||
{
|
||||
word * pFunc0 = Vec_WrdEntryP(vFuncs, (2*i+0)*nWords);
|
||||
word * pFunc1 = Vec_WrdEntryP(vFuncs, (2*i+1)*nWords);
|
||||
if ( Abc_TtIsConst0(pFunc0, nWords) || Abc_TtIsConst0(pFunc1, nWords) )
|
||||
continue;
|
||||
if ( k < i ) Abc_TtCopy( Vec_WrdEntryP(vFuncs, (2*k+0)*nWords), pFunc0, nWords, 0 );
|
||||
if ( k < i ) Abc_TtCopy( Vec_WrdEntryP(vFuncs, (2*k+1)*nWords), pFunc1, nWords, 0 );
|
||||
k++;
|
||||
}
|
||||
Vec_WrdShrink( vFuncs, 2*k*nWords );
|
||||
return k;
|
||||
}
|
||||
int Supp_ManCostInit( Vec_Wrd_t * vFuncs, int nWords )
|
||||
{
|
||||
int Res = 0, i, nFuncs = Vec_WrdSize(vFuncs) / nWords / 2;
|
||||
assert( 2 * nFuncs * nWords == Vec_WrdSize(vFuncs) );
|
||||
for ( i = 0; i < nFuncs; i++ )
|
||||
{
|
||||
word * pFunc0 = Vec_WrdEntryP(vFuncs, (2*i+0)*nWords);
|
||||
word * pFunc1 = Vec_WrdEntryP(vFuncs, (2*i+1)*nWords);
|
||||
Res += Abc_TtCountOnesVec(pFunc0, nWords) * Abc_TtCountOnesVec(pFunc1, nWords);
|
||||
}
|
||||
assert( nFuncs < 128 );
|
||||
assert( Res < (1 << 24) );
|
||||
return (nFuncs << 24) | Res;
|
||||
}
|
||||
void Supp_ManInit( Supp_Man_t * p )
|
||||
{
|
||||
int Value, nFuncs, iSet = Hsh_VecManAdd( p->pHash, p->vTemp ); // empty set
|
||||
assert( iSet == 0 );
|
||||
Vec_IntPush( p->vSStarts, Vec_WrdSize(p->vSFuncs) );
|
||||
Vec_WrdAppend( p->vSFuncs, p->vIsfs );
|
||||
nFuncs = Supp_ManFuncInit( p->vSFuncs, p->nWords );
|
||||
assert( Vec_WrdSize(p->vSFuncs) == 2 * nFuncs * p->nWords );
|
||||
Value = Supp_ManCostInit(p->vSFuncs, p->nWords);
|
||||
Vec_IntPush( p->vSCount, Value >> 24 );
|
||||
Vec_IntPush( p->vSPairs, Value & 0xFFFFFF );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Supp_DeriveLines( Supp_Man_t * p )
|
||||
{
|
||||
int n, i, iObj, nWords = p->nWords;
|
||||
int nDivWords = Abc_Bit6WordNum( Vec_IntSize(p->vCands) );
|
||||
for ( n = 0; n < 2; n++ )
|
||||
{
|
||||
p->vDivs[n] = Vec_WrdStart( 64*nWords*nDivWords );
|
||||
p->vPats[n] = Vec_WrdStart( 64*nWords*nDivWords );
|
||||
if ( p->vSimsC )
|
||||
Vec_IntForEachEntry( p->vCands, iObj, i )
|
||||
Abc_TtAndSharp( Vec_WrdEntryP(p->vDivs[n], i*nWords), Vec_WrdEntryP(p->vSimsC, iObj*nWords), Vec_WrdEntryP(p->vSims, iObj*nWords), nWords, !n );
|
||||
else
|
||||
Vec_IntForEachEntry( p->vCands, iObj, i )
|
||||
Abc_TtCopy( Vec_WrdEntryP(p->vDivs[n], i*nWords), Vec_WrdEntryP(p->vSims, iObj*nWords), nWords, !n );
|
||||
Extra_BitMatrixTransposeP( p->vDivs[n], nWords, p->vPats[n], nDivWords );
|
||||
}
|
||||
return nDivWords;
|
||||
}
|
||||
Supp_Man_t * Supp_ManCreate( Vec_Wrd_t * vIsfs, Vec_Int_t * vCands, Vec_Int_t * vWeights, Vec_Wrd_t * vSims, Vec_Wrd_t * vSimsC, int nWords, Gia_Man_t * pGia, int nIters, int nRounds )
|
||||
{
|
||||
Supp_Man_t * p = ABC_CALLOC( Supp_Man_t, 1 );
|
||||
p->nIters = nIters;
|
||||
p->nRounds = nRounds;
|
||||
p->nWords = nWords;
|
||||
p->vIsfs = vIsfs;
|
||||
p->vCands = vCands;
|
||||
p->vWeights = vWeights;
|
||||
p->vSims = vSims;
|
||||
p->vSimsC = vSimsC;
|
||||
p->pGia = pGia;
|
||||
// computed data
|
||||
p->nDivWords = Supp_DeriveLines( p );
|
||||
p->vMatrix = Vec_PtrAlloc( 100 );
|
||||
p->vMask = Vec_WrdAlloc( 100 );
|
||||
p->vRowTemp = Vec_WrdStart( 64*p->nDivWords );
|
||||
p->vCosts = Vec_IntStart( Vec_IntSize(p->vCands) );
|
||||
p->pHash = Hsh_VecManStart( 1000 );
|
||||
p->vSFuncs = Vec_WrdAlloc( 1000 );
|
||||
p->vSStarts = Vec_IntAlloc( 1000 );
|
||||
p->vSCount = Vec_IntAlloc( 1000 );
|
||||
p->vSPairs = Vec_IntAlloc( 1000 );
|
||||
p->vSolutions = Vec_WecStart( 16 );
|
||||
p->vTemp = Vec_IntAlloc( 10 );
|
||||
p->vTempSets = Vec_IntAlloc( 10 );
|
||||
p->vTempPairs = Vec_IntAlloc( 10 );
|
||||
Supp_ManInit( p );
|
||||
return p;
|
||||
}
|
||||
void Supp_ManCleanMatrix( Supp_Man_t * p )
|
||||
{
|
||||
Vec_Wrd_t * vTemp; int i;
|
||||
Vec_PtrForEachEntry( Vec_Wrd_t *, p->vMatrix, vTemp, i )
|
||||
Vec_WrdFreeP( &vTemp );
|
||||
Vec_PtrClear( p->vMatrix );
|
||||
}
|
||||
void Supp_ManDelete( Supp_Man_t * p )
|
||||
{
|
||||
Supp_ManCleanMatrix( p );
|
||||
Vec_WrdFreeP( &p->vDivs[0] );
|
||||
Vec_WrdFreeP( &p->vDivs[1] );
|
||||
Vec_WrdFreeP( &p->vPats[0] );
|
||||
Vec_WrdFreeP( &p->vPats[1] );
|
||||
Vec_PtrFreeP( &p->vMatrix );
|
||||
Vec_WrdFreeP( &p->vMask );
|
||||
Vec_WrdFreeP( &p->vRowTemp );
|
||||
Vec_IntFreeP( &p->vCosts );
|
||||
Hsh_VecManStop( p->pHash );
|
||||
Vec_WrdFreeP( &p->vSFuncs );
|
||||
Vec_IntFreeP( &p->vSStarts );
|
||||
Vec_IntFreeP( &p->vSCount );
|
||||
Vec_IntFreeP( &p->vSPairs );
|
||||
Vec_WecFreeP( &p->vSolutions );
|
||||
Vec_IntFreeP( &p->vTemp );
|
||||
Vec_IntFreeP( &p->vTempSets );
|
||||
Vec_IntFreeP( &p->vTempPairs );
|
||||
ABC_FREE( p );
|
||||
}
|
||||
int Supp_ManMemory( Supp_Man_t * p )
|
||||
{
|
||||
int nMem = sizeof(Supp_Man_t);
|
||||
nMem += 2*(int)Vec_WrdMemory( p->vDivs[0] );
|
||||
nMem += 2*(int)Vec_WrdMemory( p->vPats[0] );
|
||||
nMem += (Vec_PtrSize(p->vMatrix)+1)*(int)Vec_WrdMemory( p->vRowTemp );
|
||||
nMem += (int)Vec_WrdMemory( p->vMask );
|
||||
nMem += (int)Vec_IntMemory( p->vCosts );
|
||||
nMem += (int)Hsh_VecManMemory( p->pHash );
|
||||
nMem += (int)Vec_WrdMemory( p->vSFuncs );
|
||||
nMem += (int)Vec_IntMemory( p->vSStarts );
|
||||
nMem += (int)Vec_IntMemory( p->vSCount );
|
||||
nMem += (int)Vec_IntMemory( p->vSPairs );
|
||||
nMem += (int)Vec_WecMemory( p->vSolutions );
|
||||
nMem += (int)Vec_IntMemory( p->vTemp );
|
||||
nMem += (int)Vec_IntMemory( p->vTempSets );
|
||||
nMem += (int)Vec_IntMemory( p->vTempPairs );
|
||||
return nMem;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Supp_ArrayWeight( Vec_Int_t * vRes, Vec_Int_t * vWeights )
|
||||
{
|
||||
int i, iObj, Cost = 0;
|
||||
if ( !vWeights )
|
||||
return Vec_IntSize(vRes);
|
||||
Vec_IntForEachEntry( vRes, iObj, i )
|
||||
Cost += Vec_IntEntry(vWeights, iObj);
|
||||
return Cost;
|
||||
}
|
||||
int Supp_SetWeight( Supp_Man_t * p, int iSet )
|
||||
{
|
||||
return Supp_ArrayWeight( Hsh_VecReadEntry(p->pHash, iSet), p->vWeights );
|
||||
}
|
||||
int Supp_SetSize( Supp_Man_t * p, int iSet )
|
||||
{
|
||||
return Vec_IntSize( Hsh_VecReadEntry(p->pHash, iSet) );
|
||||
}
|
||||
int Supp_SetFuncNum( Supp_Man_t * p, int iSet )
|
||||
{
|
||||
return Vec_IntEntry(p->vSCount, iSet);
|
||||
}
|
||||
int Supp_SetPairNum( Supp_Man_t * p, int iSet )
|
||||
{
|
||||
return Vec_IntEntry(p->vSPairs, iSet);
|
||||
}
|
||||
void Supp_SetConvert( Vec_Int_t * vSet, Vec_Int_t * vCands )
|
||||
{
|
||||
int i, iObj;
|
||||
Vec_IntForEachEntry( vSet, iObj, i )
|
||||
Vec_IntWriteEntry( vSet, i, Vec_IntEntry(vCands, iObj) );
|
||||
}
|
||||
void Supp_PrintNodes( Gia_Man_t * pGia, Vec_Int_t * vObjs, int Skip, int Limit )
|
||||
{
|
||||
int i, iObj;
|
||||
//printf( "Considering %d targets: ", Vec_IntSize(vObjs) );
|
||||
Vec_IntForEachEntryStart( vObjs, iObj, i, Skip )
|
||||
{
|
||||
if ( iObj < 0 )
|
||||
continue;
|
||||
printf( "(%d)", iObj );
|
||||
if ( pGia && pGia->vWeights && Vec_IntEntry(pGia->vWeights, iObj) > 0 )
|
||||
printf( "(%d)", Vec_IntEntry(pGia->vWeights, iObj) );
|
||||
if ( pGia )
|
||||
printf( " %s ", Gia_ObjName(pGia, iObj)+2 );
|
||||
else
|
||||
printf( " n%d ", iObj );
|
||||
if ( i >= Limit )
|
||||
{
|
||||
printf( "... " );
|
||||
break;
|
||||
}
|
||||
}
|
||||
printf( "Cost = %d", Supp_ArrayWeight(vObjs, pGia ? pGia->vWeights : NULL) );
|
||||
printf( "\n" );
|
||||
}
|
||||
void Supp_PrintOne( Supp_Man_t * p, int iSet )
|
||||
{
|
||||
Vec_Int_t * vSet = Hsh_VecReadEntry(p->pHash, iSet);
|
||||
printf( "Set %5d : ", iSet );
|
||||
printf( "Funcs %2d ", Supp_SetFuncNum(p, iSet) );
|
||||
printf( "Pairs %4d ", Supp_SetPairNum(p, iSet) );
|
||||
printf( "Start %8d ", Vec_IntEntry(p->vSStarts, iSet) );
|
||||
printf( "Weight %4d ", Supp_ArrayWeight(vSet, p->vWeights) );
|
||||
Vec_IntClearAppend( p->vTemp, vSet );
|
||||
Supp_SetConvert( p->vTemp, p->vCands );
|
||||
Supp_PrintNodes( p->pGia, p->vTemp, 0, 6 );
|
||||
}
|
||||
int Supp_ManRefine1( Supp_Man_t * p, int iSet, int iObj )
|
||||
{
|
||||
word * pSet = Vec_WrdEntryP( p->vSims, Vec_IntEntry(p->vCands, iObj)*p->nWords );
|
||||
word * pIsf; int nFuncs = Vec_IntEntry(p->vSCount, iSet);
|
||||
int i, n, f, w, nFuncsNew = 0, Mark = Vec_WrdSize(p->vSFuncs), Res = 0;
|
||||
if ( Vec_WrdSize(p->vSFuncs) + 4*nFuncs*p->nWords > Vec_WrdCap(p->vSFuncs) )
|
||||
Vec_WrdGrow( p->vSFuncs, 2*Vec_WrdCap(p->vSFuncs) );
|
||||
pIsf = Vec_WrdEntryP( p->vSFuncs, Vec_IntEntry(p->vSStarts, iSet) );
|
||||
for ( i = 0; i < nFuncs; i++ )
|
||||
{
|
||||
word * pFunc[2] = { pIsf + (2*i+0)*p->nWords, pIsf + (2*i+1)*p->nWords };
|
||||
for ( f = 0; f < 2; f++ )
|
||||
{
|
||||
int nOnes[2], Start = Vec_WrdSize(p->vSFuncs);
|
||||
for ( n = 0; n < 2; n++ )
|
||||
{
|
||||
word * pLimit = Vec_WrdLimit(p->vSFuncs);
|
||||
if ( f )
|
||||
for ( w = 0; w < p->nWords; w++ )
|
||||
Vec_WrdPush( p->vSFuncs, pFunc[n][w] & pSet[w] );
|
||||
else
|
||||
for ( w = 0; w < p->nWords; w++ )
|
||||
Vec_WrdPush( p->vSFuncs, pFunc[n][w] & ~pSet[w] );
|
||||
nOnes[n] = Abc_TtCountOnesVec( pLimit, p->nWords );
|
||||
}
|
||||
if ( nOnes[0] && nOnes[1] )
|
||||
Res += nOnes[0] * nOnes[1];
|
||||
else
|
||||
Vec_WrdShrink( p->vSFuncs, Start );
|
||||
}
|
||||
}
|
||||
assert( Res < (1 << 24) );
|
||||
nFuncsNew = (Vec_WrdSize(p->vSFuncs) - Mark)/2/p->nWords;
|
||||
assert( nFuncsNew < 128 );
|
||||
assert( nFuncsNew >= 0 && nFuncsNew <= 2*nFuncs );
|
||||
return (nFuncsNew << 24) | Res;
|
||||
}
|
||||
void Supp_ManRefine( Supp_Man_t * p, int iSet, int iObj, int * pnFuncs, int * pnPairs )
|
||||
{
|
||||
word * pDivs0 = Vec_WrdEntryP( p->vDivs[0], iObj*p->nWords );
|
||||
word * pDivs1 = Vec_WrdEntryP( p->vDivs[1], iObj*p->nWords );
|
||||
word * pIsf; int nFuncs = Supp_SetFuncNum(p, iSet);
|
||||
int i, f, w, nFuncsNew = 0, Mark = Vec_WrdSize(p->vSFuncs), Res = 0;
|
||||
if ( Vec_WrdSize(p->vSFuncs) + 6*nFuncs*p->nWords > Vec_WrdCap(p->vSFuncs) )
|
||||
Vec_WrdGrow( p->vSFuncs, 2*Vec_WrdCap(p->vSFuncs) );
|
||||
if ( Vec_WrdSize(p->vSFuncs) == Vec_IntEntry(p->vSStarts, iSet) )
|
||||
pIsf = Vec_WrdLimit( p->vSFuncs );
|
||||
else
|
||||
pIsf = Vec_WrdEntryP( p->vSFuncs, Vec_IntEntry(p->vSStarts, iSet) );
|
||||
for ( i = 0; i < nFuncs; i++ )
|
||||
{
|
||||
word * pFunc[2] = { pIsf + (2*i+0)*p->nWords, pIsf + (2*i+1)*p->nWords };
|
||||
for ( f = 0; f < 3; f++ )
|
||||
{
|
||||
int nOnes[2], Start = Vec_WrdSize(p->vSFuncs);
|
||||
word * pLimit[2] = { Vec_WrdLimit(p->vSFuncs), Vec_WrdLimit(p->vSFuncs) + p->nWords };
|
||||
if ( f == 0 )
|
||||
{
|
||||
for ( w = 0; w < p->nWords; w++ )
|
||||
Vec_WrdPush( p->vSFuncs, pFunc[0][w] & pDivs0[w] );
|
||||
for ( w = 0; w < p->nWords; w++ )
|
||||
Vec_WrdPush( p->vSFuncs, pFunc[1][w] & ~pDivs1[w] );
|
||||
}
|
||||
else if ( f == 1 )
|
||||
{
|
||||
for ( w = 0; w < p->nWords; w++ )
|
||||
Vec_WrdPush( p->vSFuncs, pFunc[0][w] & pDivs1[w] );
|
||||
for ( w = 0; w < p->nWords; w++ )
|
||||
Vec_WrdPush( p->vSFuncs, pFunc[1][w] & ~pDivs0[w] );
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( w = 0; w < p->nWords; w++ )
|
||||
Vec_WrdPush( p->vSFuncs, pFunc[0][w] & ~pDivs0[w] & ~pDivs1[w] );
|
||||
for ( w = 0; w < p->nWords; w++ )
|
||||
Vec_WrdPush( p->vSFuncs, pFunc[1][w] );
|
||||
}
|
||||
nOnes[0] = Abc_TtCountOnesVec( pLimit[0], p->nWords );
|
||||
nOnes[1] = Abc_TtCountOnesVec( pLimit[1], p->nWords );
|
||||
if ( nOnes[0] && nOnes[1] )
|
||||
Res += nOnes[0] * nOnes[1];
|
||||
else
|
||||
Vec_WrdShrink( p->vSFuncs, Start );
|
||||
}
|
||||
}
|
||||
assert( Res < (1 << 24) );
|
||||
nFuncsNew = (Vec_WrdSize(p->vSFuncs) - Mark)/2/p->nWords;
|
||||
*pnFuncs = nFuncsNew;
|
||||
*pnPairs = Res;
|
||||
}
|
||||
int Supp_ManSubsetAdd( Supp_Man_t * p, int iSet, int iObj, int fVerbose )
|
||||
{
|
||||
int iSetNew, nEntries = Hsh_VecSize( p->pHash );
|
||||
Vec_Int_t * vSet = Hsh_VecReadEntry( p->pHash, iSet );
|
||||
Vec_IntClear( p->vTemp );
|
||||
Vec_IntAppend( p->vTemp, vSet );
|
||||
Vec_IntPushOrder( p->vTemp, iObj );
|
||||
assert( Vec_IntIsOrdered(p->vTemp, 0) );
|
||||
iSetNew = Hsh_VecManAdd( p->pHash, p->vTemp );
|
||||
if ( iSetNew == nEntries ) // new entry
|
||||
{
|
||||
int nFuncs, nPairs;
|
||||
Vec_IntPush( p->vSStarts, Vec_WrdSize(p->vSFuncs) );
|
||||
Supp_ManRefine( p, iSet, iObj, &nFuncs, &nPairs );
|
||||
Vec_IntPush( p->vSCount, nFuncs );
|
||||
Vec_IntPush( p->vSPairs, nPairs );
|
||||
assert( Hsh_VecSize(p->pHash) == Vec_IntSize(p->vSStarts) );
|
||||
assert( Hsh_VecSize(p->pHash) == Vec_IntSize(p->vSCount) );
|
||||
assert( Hsh_VecSize(p->pHash) == Vec_IntSize(p->vSPairs) );
|
||||
if ( Supp_SetFuncNum(p, iSetNew) == 0 && Supp_SetSize(p, iSetNew) < Vec_WecSize(p->vSolutions) )
|
||||
Vec_WecPush( p->vSolutions, Supp_SetSize(p, iSetNew), iSetNew );
|
||||
if ( fVerbose )
|
||||
Supp_PrintOne( p, iSetNew );
|
||||
}
|
||||
return iSetNew;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Supp_ComputePair1( Supp_Man_t * p, int iSet )
|
||||
{
|
||||
int Random = 0xFFFFFF & Abc_Random(0);
|
||||
int nFuncs = Vec_IntEntry(p->vSCount, iSet);
|
||||
int iFunc = Random % nFuncs;
|
||||
word * pIsf = Vec_WrdEntryP( p->vSFuncs, Vec_IntEntry(p->vSStarts, iSet) );
|
||||
word * pFunc[2] = { pIsf + (2*iFunc+0)*p->nWords, pIsf + (2*iFunc+1)*p->nWords };
|
||||
int iBit0 = ((Random >> 16) & 1) ? Abc_TtFindFirstBit2(pFunc[0], p->nWords) : Abc_TtFindLastBit2(pFunc[0], p->nWords);
|
||||
int iBit1 = ((Random >> 17) & 1) ? Abc_TtFindFirstBit2(pFunc[1], p->nWords) : Abc_TtFindLastBit2(pFunc[1], p->nWords);
|
||||
if ( 1 )
|
||||
{
|
||||
Vec_Int_t * vSet = Hsh_VecReadEntry( p->pHash, iSet ); int i, iObj;
|
||||
Vec_IntForEachEntry( vSet, iObj, i )
|
||||
{
|
||||
word * pSet = Vec_WrdEntryP( p->vSims, Vec_IntEntry(p->vCands, iObj)*p->nWords );
|
||||
assert( Abc_TtGetBit(pSet, iBit0) == Abc_TtGetBit(pSet, iBit1) );
|
||||
}
|
||||
}
|
||||
return (iBit0 << 16) | iBit1;
|
||||
}
|
||||
int Supp_ComputePair( Supp_Man_t * p, int iSet )
|
||||
{
|
||||
int Random = 0xFFFFFF & Abc_Random(0);
|
||||
int nFuncs = Vec_IntEntry(p->vSCount, iSet);
|
||||
int iFunc = Random % nFuncs;
|
||||
word * pIsf = Vec_WrdEntryP( p->vSFuncs, Vec_IntEntry(p->vSStarts, iSet) );
|
||||
word * pFunc[2] = { pIsf + (2*iFunc+0)*p->nWords, pIsf + (2*iFunc+1)*p->nWords };
|
||||
int iBit0 = ((Random >> 16) & 1) ? Abc_TtFindFirstBit2(pFunc[0], p->nWords) : Abc_TtFindLastBit2(pFunc[0], p->nWords);
|
||||
int iBit1 = ((Random >> 17) & 1) ? Abc_TtFindFirstBit2(pFunc[1], p->nWords) : Abc_TtFindLastBit2(pFunc[1], p->nWords);
|
||||
if ( 1 )
|
||||
{
|
||||
Vec_Int_t * vSet = Hsh_VecReadEntry( p->pHash, iSet ); int i, iObj;
|
||||
Vec_IntForEachEntry( vSet, iObj, i )
|
||||
{
|
||||
word * pSet0 = Vec_WrdEntryP( p->vDivs[0], iObj*p->nWords );
|
||||
word * pSet1 = Vec_WrdEntryP( p->vDivs[1], iObj*p->nWords );
|
||||
int Value00 = Abc_TtGetBit(pSet0, iBit0);
|
||||
int Value01 = Abc_TtGetBit(pSet0, iBit1);
|
||||
int Value10 = Abc_TtGetBit(pSet1, iBit0);
|
||||
int Value11 = Abc_TtGetBit(pSet1, iBit1);
|
||||
assert( !Value00 || !Value11 );
|
||||
assert( !Value01 || !Value10 );
|
||||
}
|
||||
}
|
||||
return (iBit0 << 16) | iBit1;
|
||||
}
|
||||
Vec_Int_t * Supp_Compute64Pairs( Supp_Man_t * p, Vec_Int_t * vSets )
|
||||
{
|
||||
int i;
|
||||
Vec_IntClear( p->vTempPairs );
|
||||
for ( i = 0; i < 64; i++ )
|
||||
{
|
||||
int Rand = 0xFFFFFF & Abc_Random(0);
|
||||
int iSet = Vec_IntEntry( vSets, Rand % Vec_IntSize(vSets) );
|
||||
Vec_IntPush( p->vTempPairs, Supp_ComputePair(p, iSet) );
|
||||
}
|
||||
return p->vTempPairs;
|
||||
}
|
||||
void Supp_ManFillBlock( Supp_Man_t * p, Vec_Int_t * vPairs, Vec_Wrd_t * vRes )
|
||||
{
|
||||
int i, Pair;
|
||||
assert( Vec_IntSize(vPairs) == 64 );
|
||||
Vec_IntForEachEntry( vPairs, Pair, i )
|
||||
{
|
||||
int iBit0 = Pair >> 16, iBit1 = Pair & 0xFFFF;
|
||||
word * pPat00 = Vec_WrdEntryP(p->vPats[0], iBit0*p->nDivWords);
|
||||
word * pPat01 = Vec_WrdEntryP(p->vPats[0], iBit1*p->nDivWords);
|
||||
word * pPat10 = Vec_WrdEntryP(p->vPats[1], iBit0*p->nDivWords);
|
||||
word * pPat11 = Vec_WrdEntryP(p->vPats[1], iBit1*p->nDivWords);
|
||||
word * pPat = Vec_WrdEntryP(p->vRowTemp, i*p->nDivWords);
|
||||
Abc_TtAnd( pPat, pPat00, pPat11, p->nDivWords, 0 );
|
||||
Abc_TtOrAnd( pPat, pPat01, pPat10, p->nDivWords );
|
||||
}
|
||||
Extra_BitMatrixTransposeP( p->vRowTemp, p->nDivWords, vRes, 1 );
|
||||
}
|
||||
void Supp_ManAddPatterns( Supp_Man_t * p, Vec_Int_t * vSets )
|
||||
{
|
||||
Vec_Int_t * vPairs = Supp_Compute64Pairs( p, vSets );
|
||||
Vec_Wrd_t * vRow = Vec_WrdStart( 64*p->nDivWords );
|
||||
Supp_ManFillBlock( p, vPairs, vRow );
|
||||
Vec_PtrPush( p->vMatrix, vRow );
|
||||
}
|
||||
Vec_Int_t * Supp_ManCollectOnes( word * pSim, int nWords )
|
||||
{
|
||||
Vec_Int_t * vRes = Vec_IntAlloc( 100 ); int i;
|
||||
for ( i = 0; i < 64*nWords; i++ )
|
||||
if ( Abc_TtGetBit(pSim, i) )
|
||||
Vec_IntPush( vRes, i );
|
||||
return vRes;
|
||||
}
|
||||
Vec_Int_t * Supp_Compute64PairsFunc( Supp_Man_t * p, Vec_Int_t * vBits0, Vec_Int_t * vBits1 )
|
||||
{
|
||||
int i;
|
||||
Vec_IntClear( p->vTempPairs );
|
||||
for ( i = 0; i < 64; i++ )
|
||||
{
|
||||
int Random = 0xFFFFFF & Abc_Random(0);
|
||||
int iBit0 = Vec_IntEntry( vBits0, (Random & 0xFFF) % Vec_IntSize(vBits0) );
|
||||
int iBit1 = Vec_IntEntry( vBits1, (Random >> 12) % Vec_IntSize(vBits1) );
|
||||
Vec_IntPush( p->vTempPairs, (iBit0 << 16) | iBit1 );
|
||||
}
|
||||
return p->vTempPairs;
|
||||
}
|
||||
void Supp_ManAddPatternsFunc( Supp_Man_t * p, int nBatches )
|
||||
{
|
||||
int b;
|
||||
Vec_Int_t * vBits0 = Supp_ManCollectOnes( Vec_WrdEntryP(p->vSFuncs, 0*p->nWords), p->nWords );
|
||||
Vec_Int_t * vBits1 = Supp_ManCollectOnes( Vec_WrdEntryP(p->vSFuncs, 1*p->nWords), p->nWords );
|
||||
for ( b = 0; b < nBatches; b++ )
|
||||
{
|
||||
Vec_Int_t * vPairs = Supp_Compute64PairsFunc( p, vBits0, vBits1 );
|
||||
Vec_Wrd_t * vRow = Vec_WrdStart( 64*p->nDivWords );
|
||||
Supp_ManFillBlock( p, vPairs, vRow );
|
||||
Vec_PtrPush( p->vMatrix, vRow );
|
||||
}
|
||||
Vec_IntFree( vBits0 );
|
||||
Vec_IntFree( vBits1 );
|
||||
}
|
||||
int Supp_FindNextDiv( Supp_Man_t * p, int Pair )
|
||||
{
|
||||
int iDiv, iBit0 = Pair >> 16, iBit1 = Pair & 0xFFFF;
|
||||
word * pPat00 = Vec_WrdEntryP(p->vPats[0], iBit0*p->nDivWords);
|
||||
word * pPat01 = Vec_WrdEntryP(p->vPats[0], iBit1*p->nDivWords);
|
||||
word * pPat10 = Vec_WrdEntryP(p->vPats[1], iBit0*p->nDivWords);
|
||||
word * pPat11 = Vec_WrdEntryP(p->vPats[1], iBit1*p->nDivWords);
|
||||
int iDiv1 = Abc_TtFindFirstAndBit2( pPat00, pPat11, p->nDivWords );
|
||||
int iDiv2 = Abc_TtFindFirstAndBit2( pPat01, pPat10, p->nDivWords );
|
||||
iDiv1 = iDiv1 == -1 ? ABC_INFINITY : iDiv1;
|
||||
iDiv2 = iDiv2 == -1 ? ABC_INFINITY : iDiv2;
|
||||
iDiv = Abc_MinInt( iDiv1, iDiv2 );
|
||||
assert( iDiv >= 0 && iDiv < Vec_IntSize(p->vCands) );
|
||||
return iDiv;
|
||||
}
|
||||
int Supp_ManRandomSolution( Supp_Man_t * p, int iSet, int fVerbose )
|
||||
{
|
||||
Vec_IntClear( p->vTempSets );
|
||||
while ( Supp_SetFuncNum(p, iSet) > 0 )
|
||||
{
|
||||
int Pair = Supp_ComputePair( p, iSet );
|
||||
int iDiv = Supp_FindNextDiv( p, Pair );
|
||||
iSet = Supp_ManSubsetAdd( p, iSet, iDiv, fVerbose );
|
||||
if ( Supp_SetFuncNum(p, iSet) > 0 )
|
||||
Vec_IntPush( p->vTempSets, iSet );
|
||||
}
|
||||
if ( Vec_IntSize(p->vTempSets) < 2 )
|
||||
return iSet;
|
||||
Supp_ManAddPatterns( p, p->vTempSets );
|
||||
return iSet;
|
||||
}
|
||||
int Supp_ManSubsetRemove( Supp_Man_t * p, int iSet, int iPos )
|
||||
{
|
||||
int i, iSetNew = 0, nSize = Supp_SetSize(p, iSet);
|
||||
for ( i = 0; i < nSize; i++ )
|
||||
if ( i != iPos && Supp_SetFuncNum(p, iSetNew) > 0 )
|
||||
iSetNew = Supp_ManSubsetAdd( p, iSetNew, Vec_IntEntry(Hsh_VecReadEntry(p->pHash, iSet), i), 0 );
|
||||
return iSetNew;
|
||||
}
|
||||
int Supp_ManMinimize( Supp_Man_t * p, int iSet0, int r, int fVerbose )
|
||||
{
|
||||
int i, nSize = Supp_SetSize(p, iSet0);
|
||||
Vec_Int_t * vPerm = Vec_IntStartNatural( Supp_SetSize(p, iSet0) );
|
||||
Vec_IntRandomizeOrder( vPerm );
|
||||
Vec_IntClear( p->vTempSets );
|
||||
if ( fVerbose )
|
||||
printf( "Removing items from %d:\n", iSet0 );
|
||||
// make sure we first try to remove items with higher weight
|
||||
for ( i = 0; i < nSize; i++ )
|
||||
{
|
||||
int Index = Vec_IntEntry( vPerm, i );
|
||||
int iSet = Supp_ManSubsetRemove( p, iSet0, Index );
|
||||
if ( fVerbose )
|
||||
printf( "Item %2d : ", Index );
|
||||
if ( fVerbose )
|
||||
Supp_PrintOne( p, iSet );
|
||||
if ( Supp_SetFuncNum(p, iSet) == 0 )
|
||||
{
|
||||
Vec_IntFree( vPerm );
|
||||
return Supp_ManMinimize( p, iSet, r, fVerbose );
|
||||
}
|
||||
Vec_IntPush( p->vTempSets, iSet );
|
||||
}
|
||||
Supp_ManAddPatterns( p, p->vTempSets );
|
||||
Vec_IntFree( vPerm );
|
||||
return iSet0;
|
||||
}
|
||||
int Supp_ManFindNextObj( Supp_Man_t * p, int fVerbose )
|
||||
{
|
||||
Vec_Wrd_t * vTemp; int r, k, iDiv;
|
||||
word Sim, * pMask = Vec_WrdArray(p->vMask);
|
||||
assert( Vec_WrdSize(p->vMask) == Vec_PtrSize(p->vMatrix) );
|
||||
Vec_IntFill( p->vCosts, Vec_IntSize(p->vCosts), 0 );
|
||||
Vec_PtrForEachEntry( Vec_Wrd_t *, p->vMatrix, vTemp, r )
|
||||
Vec_WrdForEachEntryStop( vTemp, Sim, k, Vec_IntSize(p->vCosts) )
|
||||
Vec_IntAddToEntry( p->vCosts, k, Abc_TtCountOnes(Sim & pMask[r]) );
|
||||
iDiv = Vec_IntArgMax( p->vCosts );
|
||||
if ( fVerbose )
|
||||
printf( "Choosing divisor %d with weight %d.\n", iDiv, Vec_IntEntry(p->vCosts, iDiv) );
|
||||
Vec_PtrForEachEntry( Vec_Wrd_t *, p->vMatrix, vTemp, r )
|
||||
pMask[r] &= ~Vec_WrdEntry( vTemp, iDiv );
|
||||
return iDiv;
|
||||
}
|
||||
int Supp_ManReconstruct( Supp_Man_t * p, int fVerbose )
|
||||
{
|
||||
int iSet = 0;
|
||||
Vec_WrdFill( p->vMask, Vec_PtrSize(p->vMatrix), ~(word)0 );
|
||||
if ( fVerbose )
|
||||
printf( "\nBuilding a new set:\n" );
|
||||
while ( Supp_SetPairNum(p, iSet) )
|
||||
{
|
||||
int iDiv = Supp_ManFindNextObj( p, fVerbose );
|
||||
iSet = Supp_ManSubsetAdd( p, iSet, iDiv, fVerbose );
|
||||
if ( Abc_TtIsConst0(Vec_WrdArray(p->vMask), Vec_WrdSize(p->vMask)) )
|
||||
break;
|
||||
}
|
||||
if ( fVerbose )
|
||||
printf( "Adding random part:\n" );
|
||||
return Supp_ManRandomSolution( p, iSet, fVerbose );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Vec_Int_t * Supp_ManFindBestSolution( Supp_Man_t * p, Vec_Wec_t * vSols, int fVerbose, Vec_Int_t ** pvDivs )
|
||||
{
|
||||
Vec_Int_t * vLevel, * vRes = NULL;
|
||||
int i, k, iSet, nFuncs = 0, Count = 0;
|
||||
int iSolBest = -1, Cost, CostBest = ABC_INFINITY;
|
||||
Vec_WecForEachLevel( vSols, vLevel, i )
|
||||
{
|
||||
Count += Vec_IntSize(vLevel) > 0;
|
||||
Vec_IntForEachEntry( vLevel, iSet, k )
|
||||
{
|
||||
if ( fVerbose )
|
||||
printf( "%3d : ", nFuncs++ );
|
||||
Cost = Gia_ManEvalSolutionOne( p->pGia, p->vSims, p->vIsfs, p->vCands, Hsh_VecReadEntry(p->pHash, iSet), p->nWords, fVerbose );
|
||||
if ( Cost == -1 )
|
||||
continue;
|
||||
if ( CostBest > Cost )
|
||||
{
|
||||
CostBest = Cost;
|
||||
iSolBest = iSet;
|
||||
}
|
||||
if ( nFuncs > 5 )
|
||||
break;
|
||||
}
|
||||
if ( Count == 2 || k < Vec_IntSize(vLevel) )
|
||||
break;
|
||||
}
|
||||
if ( iSolBest > 0 && (CostBest >> 2) < 50 )
|
||||
{
|
||||
Vec_Int_t * vSet = Hsh_VecReadEntry( p->pHash, iSolBest ); int i, iObj;
|
||||
vRes = Gia_ManDeriveSolutionOne( p->pGia, p->vSims, p->vIsfs, p->vCands, vSet, p->nWords, CostBest & 3 );
|
||||
assert( !vRes || Vec_IntSize(vRes) == 2*(CostBest >> 2)+1 );
|
||||
if ( vRes && pvDivs )
|
||||
{
|
||||
Vec_IntClear( *pvDivs );
|
||||
Vec_IntPushTwo( *pvDivs, -1, -1 );
|
||||
Vec_IntForEachEntry( vSet, iObj, i )
|
||||
Vec_IntPush( *pvDivs, Vec_IntEntry(p->vCands, iObj) );
|
||||
}
|
||||
}
|
||||
return vRes;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Supp_FindGivenOne( Supp_Man_t * p )
|
||||
{
|
||||
int i, iObj, iSet = 0;
|
||||
Vec_Int_t * vSet = Vec_IntStart( 2 );
|
||||
//extern void Patch_GenerateSet11( Gia_Man_t * p, Vec_Int_t * vDivs, Vec_Int_t * vCands );
|
||||
//Patch_GenerateSet11( p->pGia, vSet, p->vCands );
|
||||
Vec_IntDrop( vSet, 0 );
|
||||
Vec_IntDrop( vSet, 0 );
|
||||
Vec_IntForEachEntry( vSet, iObj, i )
|
||||
iSet = Supp_ManSubsetAdd( p, iSet, iObj, 1 );
|
||||
Vec_IntFree( vSet );
|
||||
return iSet;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Vec_Int_t * Supp_ManCompute( Vec_Wrd_t * vIsfs, Vec_Int_t * vCands, Vec_Int_t * vWeights, Vec_Wrd_t * vSims, Vec_Wrd_t * vSimsC, int nWords, Gia_Man_t * pGia, Vec_Int_t ** pvDivs, int nIters, int nRounds, int fVerbose )
|
||||
{
|
||||
int fVeryVerbose = 0;
|
||||
int i, r, iSet, iBest = -1;
|
||||
abctime clk = Abc_Clock();
|
||||
Vec_Int_t * vRes = NULL;
|
||||
Supp_Man_t * p = Supp_ManCreate( vIsfs, vCands, vWeights, vSims, vSimsC, nWords, pGia, nIters, nRounds );
|
||||
if ( Supp_SetFuncNum(p, 0) == 0 )
|
||||
{
|
||||
Supp_ManDelete( p );
|
||||
Vec_IntClear( *pvDivs );
|
||||
Vec_IntPushTwo( *pvDivs, -1, -1 );
|
||||
vRes = Vec_IntAlloc( 1 );
|
||||
Vec_IntPush( vRes, Abc_TtIsConst0(Vec_WrdArray(vIsfs), nWords) );
|
||||
return vRes;
|
||||
}
|
||||
if ( fVerbose )
|
||||
printf( "\nUsing %d divisors with %d words. Problem has %d functions and %d minterm pairs.\n",
|
||||
Vec_IntSize(p->vCands), p->nWords, Supp_SetFuncNum(p, 0), Supp_SetPairNum(p, 0) );
|
||||
//iBest = Supp_FindGivenOne( p );
|
||||
if ( iBest == -1 )
|
||||
for ( i = 0; i < p->nIters; i++ )
|
||||
{
|
||||
Supp_ManAddPatternsFunc( p, i );
|
||||
iSet = Supp_ManRandomSolution( p, 0, fVeryVerbose );
|
||||
for ( r = 0; r < p->nRounds; r++ )
|
||||
{
|
||||
if ( fVeryVerbose )
|
||||
printf( "\n\nITER %d ROUND %d\n", i, r );
|
||||
iSet = Supp_ManMinimize( p, iSet, r, fVeryVerbose );
|
||||
if ( iBest == -1 || Supp_SetWeight(p, iBest) > Supp_SetWeight(p, iSet) )
|
||||
//if ( Supp_SetSize(p, iBest) > Supp_SetSize(p, iSet) )
|
||||
{
|
||||
if ( fVeryVerbose )
|
||||
printf( "\nThe best solution found:\n" );
|
||||
if ( fVeryVerbose )
|
||||
Supp_PrintOne( p, iSet );
|
||||
iBest = iSet;
|
||||
}
|
||||
iSet = Supp_ManReconstruct( p, fVeryVerbose );
|
||||
}
|
||||
if ( fVeryVerbose )
|
||||
printf( "Matrix size %d.\n", Vec_PtrSize(p->vMatrix) );
|
||||
Supp_ManCleanMatrix( p );
|
||||
}
|
||||
if ( fVerbose )
|
||||
{
|
||||
printf( "Explored %d divisor sets. Found %d solutions. Memory usage %.2f MB. ",
|
||||
Hsh_VecSize(p->pHash), Vec_WecSizeSize(p->vSolutions), 1.0*Supp_ManMemory(p)/(1<<20) );
|
||||
Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
|
||||
printf( "The best solution: " );
|
||||
if ( iBest == -1 )
|
||||
printf( "No solution.\n" );
|
||||
else
|
||||
Supp_PrintOne( p, iBest );
|
||||
}
|
||||
vRes = Supp_ManFindBestSolution( p, p->vSolutions, fVerbose, pvDivs );
|
||||
Supp_ManDelete( p );
|
||||
// if ( vRes && Vec_IntSize(vRes) == 0 )
|
||||
// Vec_IntFreeP( &vRes );
|
||||
return vRes;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
ABC_NAMESPACE_IMPL_END
|
||||
|
||||
|
|
@ -388,6 +388,14 @@ Vec_Int_t * Gia_ManComputeCarryOuts( Gia_Man_t * p )
|
|||
Tim_Man_t * pManTime = (Tim_Man_t *)p->pManTime;
|
||||
int i, iLast, iBox, nBoxes = Tim_ManBoxNum( pManTime );
|
||||
Vec_Int_t * vCarryOuts = Vec_IntAlloc( nBoxes );
|
||||
|
||||
// Create and populate reference count (and free later) only if not already
|
||||
// done.
|
||||
int createRefs = (p->pRefs == NULL);
|
||||
if (createRefs) {
|
||||
Gia_ManCreateRefs( p );
|
||||
}
|
||||
|
||||
for ( i = 0; i < nBoxes; i++ )
|
||||
{
|
||||
iLast = Tim_ManBoxInputLast( pManTime, i );
|
||||
|
|
@ -398,9 +406,24 @@ Vec_Int_t * Gia_ManComputeCarryOuts( Gia_Man_t * p )
|
|||
if ( iBox == -1 )
|
||||
continue;
|
||||
assert( Gia_ObjIsCi(pObj) );
|
||||
if ( Gia_ObjCioId(pObj) == Tim_ManBoxOutputLast(pManTime, iBox) )
|
||||
if ( Gia_ObjCioId(pObj) == Tim_ManBoxOutputLast(pManTime, iBox) ) {
|
||||
Vec_IntPush( vCarryOuts, Gia_ObjId(p, pObj) );
|
||||
|
||||
// We have identified a carry connection. Check if the carry out
|
||||
// of the destination box is unconnected. If so then add it to
|
||||
// the carry list as well.
|
||||
iLast = Tim_ManBoxOutputLast(pManTime, i);
|
||||
pObj = Gia_ManCi(p, iLast);
|
||||
if ( Gia_ObjRefNum(p, pObj) == 0 ) {
|
||||
Vec_IntPush( vCarryOuts, Gia_ObjId(p, pObj) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (createRefs) {
|
||||
ABC_FREE( p->pRefs );
|
||||
}
|
||||
|
||||
return vCarryOuts;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -118,27 +118,6 @@ word Gia_LutComputeTruth6Map( Gia_Man_t * p, int iPo, Vec_Int_t * vMap )
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static unsigned s_Truths5[5] = {
|
||||
0xAAAAAAAA,
|
||||
0xCCCCCCCC,
|
||||
0xF0F0F0F0,
|
||||
0xFF00FF00,
|
||||
0xFFFF0000,
|
||||
};
|
||||
static inline int Abc_Tt5HasVar( unsigned t, int iVar )
|
||||
{
|
||||
return ((t << (1<<iVar)) & s_Truths5[iVar]) != (t & s_Truths5[iVar]);
|
||||
}
|
||||
static inline unsigned Abc_Tt5Cofactor0( unsigned t, int iVar )
|
||||
{
|
||||
assert( iVar >= 0 && iVar < 6 );
|
||||
return (t & ~s_Truths5[iVar]) | ((t & ~s_Truths5[iVar]) << (1<<iVar));
|
||||
}
|
||||
static inline unsigned Abc_Tt5Cofactor1( unsigned t, int iVar )
|
||||
{
|
||||
assert( iVar >= 0 && iVar < 6 );
|
||||
return (t & s_Truths5[iVar]) | ((t & s_Truths5[iVar]) >> (1<<iVar));
|
||||
}
|
||||
int Gia_Truth5ToGia( Gia_Man_t * p, int * pVarLits, int nVars, unsigned Truth, int fHash )
|
||||
{
|
||||
int Var, Lit0, Lit1;
|
||||
|
|
@ -645,9 +624,18 @@ word * Gia_ObjComputeTruthTableCut( Gia_Man_t * p, Gia_Obj_t * pRoot, Vec_Int_t
|
|||
{
|
||||
Gia_Obj_t * pTemp;
|
||||
word * pTruth, * pTruthL, * pTruth0, * pTruth1;
|
||||
int i, iObj, Id0, Id1;
|
||||
int i, iObj, Id0, Id1, Index = Vec_IntFind(vLeaves, Gia_ObjId(p, pRoot));
|
||||
assert( p->vTtMemory != NULL );
|
||||
assert( Vec_IntSize(vLeaves) <= p->nTtVars );
|
||||
if ( Index >= 0 )
|
||||
return Gla_ObjTruthElem( p, Index );
|
||||
if ( Gia_ObjIsConst0(pRoot) )
|
||||
{
|
||||
if ( Vec_WrdSize(p->vTtMemory) < p->nTtWords )
|
||||
Vec_WrdFillExtra( p->vTtMemory, p->nTtWords, 0 );
|
||||
return Gla_ObjTruthConst0( p, Gla_ObjTruthFree1(p) );
|
||||
}
|
||||
assert( Gia_ObjIsAnd(pRoot) );
|
||||
// extend ID numbers
|
||||
if ( Vec_IntSize(p->vTtNums) < Gia_ManObjNum(p) )
|
||||
Vec_IntFillExtra( p->vTtNums, Gia_ManObjNum(p), -ABC_INFINITY );
|
||||
|
|
|
|||
|
|
@ -522,6 +522,28 @@ int Gia_ManLevelNum( Gia_Man_t * p )
|
|||
}
|
||||
return p->nLevels;
|
||||
}
|
||||
int Gia_ManLevelRNum( Gia_Man_t * p )
|
||||
{
|
||||
Gia_Obj_t * pObj;
|
||||
int i;
|
||||
Gia_ManCleanLevels( p, Gia_ManObjNum(p) );
|
||||
p->nLevels = 0;
|
||||
Gia_ManForEachObjReverse( p, pObj, i )
|
||||
{
|
||||
if ( !p->fGiaSimple && Gia_ObjIsBuf(pObj) )
|
||||
Gia_ObjUpdateLevelId( p, Gia_ObjFaninId0(pObj, i), Gia_ObjLevel(p, pObj) );
|
||||
else if ( Gia_ObjIsAnd(pObj) )
|
||||
{
|
||||
Gia_ObjUpdateLevelId( p, Gia_ObjFaninId0(pObj, i), 1+Gia_ObjLevel(p, pObj) );
|
||||
Gia_ObjUpdateLevelId( p, Gia_ObjFaninId1(pObj, i), 1+Gia_ObjLevel(p, pObj) );
|
||||
}
|
||||
else if ( Gia_ObjIsCo(pObj) )
|
||||
Gia_ObjUpdateLevelId( p, Gia_ObjFaninId0(pObj, i), 1 );
|
||||
else
|
||||
p->nLevels = Abc_MaxInt( p->nLevels, Gia_ObjLevel(p, pObj) );
|
||||
}
|
||||
return p->nLevels;
|
||||
}
|
||||
float Gia_ManLevelAve( Gia_Man_t * p )
|
||||
{
|
||||
Gia_Obj_t * pObj;
|
||||
|
|
@ -1101,19 +1123,20 @@ int Gia_NodeDeref_rec( Gia_Man_t * p, Gia_Obj_t * pNode )
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Gia_NodeRef_rec( Gia_Man_t * p, Gia_Obj_t * pNode )
|
||||
int Gia_NodeRef_rec( Gia_Man_t * p, Gia_Obj_t * pNode, int fMark )
|
||||
{
|
||||
Gia_Obj_t * pFanin;
|
||||
int Counter = 0;
|
||||
if ( Gia_ObjIsCi(pNode) )
|
||||
return 0;
|
||||
assert( Gia_ObjIsAnd(pNode) );
|
||||
if ( fMark ) Gia_ObjSetTravIdCurrent(p, pNode);
|
||||
pFanin = Gia_ObjFanin0(pNode);
|
||||
if ( Gia_ObjRefInc(p, pFanin) == 0 )
|
||||
Counter += Gia_NodeRef_rec( p, pFanin );
|
||||
Counter += Gia_NodeRef_rec( p, pFanin, fMark );
|
||||
pFanin = Gia_ObjFanin1(pNode);
|
||||
if ( Gia_ObjRefInc(p, pFanin) == 0 )
|
||||
Counter += Gia_NodeRef_rec( p, pFanin );
|
||||
Counter += Gia_NodeRef_rec( p, pFanin, fMark );
|
||||
return Counter + 1;
|
||||
}
|
||||
|
||||
|
|
@ -1152,7 +1175,19 @@ int Gia_NodeMffcSize( Gia_Man_t * p, Gia_Obj_t * pNode )
|
|||
assert( !Gia_IsComplement(pNode) );
|
||||
assert( Gia_ObjIsCand(pNode) );
|
||||
ConeSize1 = Gia_NodeDeref_rec( p, pNode );
|
||||
ConeSize2 = Gia_NodeRef_rec( p, pNode );
|
||||
ConeSize2 = Gia_NodeRef_rec( p, pNode, 0 );
|
||||
assert( ConeSize1 == ConeSize2 );
|
||||
assert( ConeSize1 >= 0 );
|
||||
return ConeSize1;
|
||||
}
|
||||
int Gia_NodeMffcSizeMark( Gia_Man_t * p, Gia_Obj_t * pNode )
|
||||
{
|
||||
int ConeSize1, ConeSize2;
|
||||
assert( !Gia_IsComplement(pNode) );
|
||||
assert( Gia_ObjIsCand(pNode) );
|
||||
ConeSize1 = Gia_NodeDeref_rec( p, pNode );
|
||||
Gia_ManIncrementTravId( p );
|
||||
ConeSize2 = Gia_NodeRef_rec( p, pNode, 1 );
|
||||
assert( ConeSize1 == ConeSize2 );
|
||||
assert( ConeSize1 >= 0 );
|
||||
return ConeSize1;
|
||||
|
|
@ -1193,12 +1228,59 @@ int Gia_NodeMffcSizeSupp( Gia_Man_t * p, Gia_Obj_t * pNode, Vec_Int_t * vSupp )
|
|||
ConeSize1 = Gia_NodeDeref_rec( p, pNode );
|
||||
Gia_NodeCollect_rec( p, Gia_ObjFanin0(pNode), vSupp );
|
||||
Gia_NodeCollect_rec( p, Gia_ObjFanin1(pNode), vSupp );
|
||||
ConeSize2 = Gia_NodeRef_rec( p, pNode );
|
||||
ConeSize2 = Gia_NodeRef_rec( p, pNode, 0 );
|
||||
assert( ConeSize1 == ConeSize2 );
|
||||
assert( ConeSize1 >= 0 );
|
||||
return ConeSize1;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Gia_NodeMffcMapping_rec( Gia_Man_t * p, int iObj, Vec_Int_t * vMapping, Vec_Int_t * vSupp )
|
||||
{
|
||||
Gia_Obj_t * pObj; int i, iNode, Count = 1;
|
||||
if ( !iObj || Vec_IntEntry(vMapping, iObj) )
|
||||
return 0;
|
||||
pObj = Gia_ManObj( p, iObj );
|
||||
if ( Gia_ObjIsCi(pObj) )
|
||||
return 0;
|
||||
Gia_NodeMffcSizeSupp( p, pObj, vSupp );
|
||||
Vec_IntSort( vSupp, 0 );
|
||||
Vec_IntWriteEntry( vMapping, iObj, Vec_IntSize(vMapping) );
|
||||
Vec_IntPush( vMapping, Vec_IntSize(vSupp) );
|
||||
Vec_IntAppend( vMapping, vSupp );
|
||||
Vec_IntPush( vMapping, iObj );
|
||||
Vec_IntForEachEntry( vSupp, iNode, i )
|
||||
Count += Gia_NodeMffcMapping_rec( p, iNode, vMapping, vSupp );
|
||||
return Count;
|
||||
}
|
||||
int Gia_NodeMffcMapping( Gia_Man_t * p )
|
||||
{
|
||||
int i, Id, Count = 0;
|
||||
int * pRefsOld;
|
||||
Vec_Int_t * vMapping, * vSupp = Vec_IntAlloc( 100 );
|
||||
vMapping = Vec_IntAlloc( 2 * Gia_ManObjNum(p) );
|
||||
Vec_IntFill( vMapping, Gia_ManObjNum(p), 0 );
|
||||
pRefsOld = p->pRefs; p->pRefs = NULL;
|
||||
Gia_ManCreateRefs( p );
|
||||
Gia_ManForEachCoDriverId( p, Id, i )
|
||||
Count += Gia_NodeMffcMapping_rec( p, Id, vMapping, vSupp );
|
||||
p->pRefs = pRefsOld;
|
||||
Vec_IntFree( vSupp );
|
||||
p->vMapping = vMapping;
|
||||
//printf( "Mapping is %.2fx larger than AIG manager.\n", 1.0*Vec_IntSize(vMapping)/Gia_ManObjNum(p) );
|
||||
return Count;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Returns 1 if AIG has dangling nodes.]
|
||||
|
|
@ -2027,11 +2109,13 @@ void Gia_AigerWriteLut( Gia_Man_t * p, char * pFileName )
|
|||
Gia_ManForEachObj( p, pObj, i )
|
||||
if ( i && Gia_ObjIsLut(p, i) )
|
||||
{
|
||||
word truth;
|
||||
pLuts[iLut].Type = 3;
|
||||
Gia_LutForEachFanin( p, i, iFan, k )
|
||||
pLuts[iLut].pFans[k] = Gia_ManObj(p, iFan)->Value;
|
||||
pLuts[iLut].nFans = k;
|
||||
*(word *)pLuts[iLut].pTruth = Gia_LutComputeTruth6(p, i, vTruths);
|
||||
truth = Gia_LutComputeTruth6(p, i, vTruths);
|
||||
memcpy( pLuts[iLut].pTruth, &truth, sizeof(word) );
|
||||
pObj->Value = pLuts[iLut].Out = Abc_Var2Lit( iLut, 0 );
|
||||
iLut++;
|
||||
}
|
||||
|
|
@ -2290,6 +2374,713 @@ Gia_Man_t * Gia_ManDupWithMuxPos( Gia_Man_t * p )
|
|||
return pNew;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Collect distance info.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_ManRingAdd( Gia_Man_t * p, int iObj, Vec_Int_t * vRes, Vec_Int_t * vDists, int Dist )
|
||||
{
|
||||
if ( Gia_ObjIsTravIdCurrentId(p, iObj) )
|
||||
return;
|
||||
Gia_ObjSetTravIdCurrentId(p, iObj);
|
||||
Vec_IntWriteEntry( vDists, iObj, Dist );
|
||||
Vec_IntPush( vRes, iObj );
|
||||
}
|
||||
void Gia_ManCollectRing( Gia_Man_t * p, Vec_Int_t * vStart, Vec_Int_t * vRes, Vec_Int_t * vDists )
|
||||
{
|
||||
int i, k, iObj, iFan;
|
||||
Vec_IntForEachEntry( vStart, iObj, i )
|
||||
{
|
||||
int Weight = Vec_IntEntry( vDists, iObj );
|
||||
Gia_Obj_t * pObj = Gia_ManObj(p, iObj);
|
||||
assert( Weight > 0 );
|
||||
if ( Gia_ObjIsAnd(pObj) )
|
||||
{
|
||||
Gia_ManRingAdd( p, Gia_ObjFaninId0(pObj, iObj), vRes, vDists, Weight + 1*!Gia_ObjIsBuf(Gia_ObjFanin0(pObj)) );
|
||||
Gia_ManRingAdd( p, Gia_ObjFaninId1(pObj, iObj), vRes, vDists, Weight + 1*!Gia_ObjIsBuf(Gia_ObjFanin1(pObj)) );
|
||||
}
|
||||
Gia_ObjForEachFanoutStaticId( p, iObj, iFan, k )
|
||||
Gia_ManRingAdd( p, iFan, vRes, vDists, Weight + 1*!Gia_ObjIsBuf(Gia_ManObj(p, iFan)) );
|
||||
}
|
||||
}
|
||||
Vec_Int_t * Gia_ManComputeDistanceInt( Gia_Man_t * p, int iTarg, Vec_Int_t * vObjs, int fVerbose )
|
||||
{
|
||||
int i, iObj;
|
||||
Vec_Int_t * vDists, * vStart, * vNexts;
|
||||
vStart = Vec_IntAlloc( 100 );
|
||||
vNexts = Vec_IntAlloc( 100 );
|
||||
vDists = Vec_IntStart( Gia_ManObjNum(p) );
|
||||
Gia_ManIncrementTravId( p );
|
||||
if ( vObjs )
|
||||
{
|
||||
Vec_IntForEachEntry( vObjs, iObj, i )
|
||||
{
|
||||
Gia_ObjSetTravIdCurrentId(p, iObj);
|
||||
Vec_IntWriteEntry( vDists, iObj, 1 );
|
||||
Vec_IntPush( vStart, iObj );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Gia_ObjSetTravIdCurrentId(p, iTarg);
|
||||
Vec_IntWriteEntry( vDists, iTarg, 1 );
|
||||
Vec_IntPush( vStart, iTarg );
|
||||
}
|
||||
for ( i = 0; ; i++ )
|
||||
{
|
||||
if ( fVerbose )
|
||||
printf( "Ring %2d : %6d\n", i, Vec_IntSize(vDists)-Vec_IntCountZero(vDists) );
|
||||
Gia_ManCollectRing( p, vStart, vNexts, vDists );
|
||||
if ( Vec_IntSize(vNexts) == 0 )
|
||||
break;
|
||||
Vec_IntClear( vStart );
|
||||
ABC_SWAP( Vec_Int_t, *vStart, *vNexts );
|
||||
}
|
||||
Vec_IntFree( vStart );
|
||||
Vec_IntFree( vNexts );
|
||||
return vDists;
|
||||
}
|
||||
Vec_Int_t * Gia_ManComputeDistance( Gia_Man_t * p, int iObj, Vec_Int_t * vObjs, int fVerbose )
|
||||
{
|
||||
Vec_Int_t * vDists;
|
||||
if ( p->vFanoutNums )
|
||||
vDists = Gia_ManComputeDistanceInt( p, iObj, vObjs, fVerbose );
|
||||
else
|
||||
{
|
||||
Gia_ManStaticFanoutStart( p );
|
||||
vDists = Gia_ManComputeDistanceInt( p, iObj, vObjs, fVerbose );
|
||||
Gia_ManStaticFanoutStop( p );
|
||||
}
|
||||
return vDists;
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_ComputeTest()
|
||||
{
|
||||
char * pStart, Line [1000]; float Total = 0;
|
||||
char * pFileName = "data.txt";
|
||||
FILE * pFile = fopen( pFileName, "r" );
|
||||
if ( pFile == NULL )
|
||||
{ printf( "Input file \"%s\" cannot be opened.\n", pFileName ); return; }
|
||||
while ( fgets( Line, 1000, pFile ) != NULL )
|
||||
{
|
||||
if ( !strstr(Line, "xxx") )
|
||||
continue;
|
||||
if ( !strstr(Line, "yyy") )
|
||||
continue;
|
||||
//printf( "%s", Line );
|
||||
pStart = strstr(Line, "zzz");
|
||||
if ( pStart == NULL )
|
||||
continue;
|
||||
//printf( "%s", pStart + 4 );
|
||||
Total += -atof( pStart + 4 );
|
||||
}
|
||||
printf( "Total = %.2f\n", Total );
|
||||
fclose( pFile );
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Computes sum total of support size of primary outputs.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Gia_ManSumTotalOfSupportSizes( Gia_Man_t * p )
|
||||
{
|
||||
Gia_Obj_t * pObj;
|
||||
Vec_Wec_t * vSupps = Vec_WecStart( Gia_ManObjNum(p) );
|
||||
int i, nResult = 0;
|
||||
for ( i = 0; i < Gia_ManCiNum(p); i++ )
|
||||
Vec_IntPush( Vec_WecEntry(vSupps, 1+i), i );
|
||||
Gia_ManForEachAnd( p, pObj, i )
|
||||
Vec_IntTwoMerge2( Vec_WecEntry(vSupps, Gia_ObjFaninId0(pObj, i)), Vec_WecEntry(vSupps, Gia_ObjFaninId1(pObj, i)), Vec_WecEntry(vSupps, i) );
|
||||
Gia_ManForEachCo( p, pObj, i )
|
||||
nResult += Vec_IntSize( Vec_WecEntry(vSupps, Gia_ObjFaninId0p(p, pObj)) );
|
||||
Vec_WecFree( vSupps );
|
||||
return nResult;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Computes sum total of support size of primary outputs.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Gia_ManSumTotalOfSupportSizes2( Gia_Man_t * p )
|
||||
{
|
||||
Vec_Wrd_t * vSims = Vec_WrdStart( Gia_ManObjNum(p) );
|
||||
int r, nResult = 0, nRounds = (Gia_ManCiNum(p) + 63)/64;
|
||||
for ( r = 0; r < nRounds; r++ )
|
||||
{
|
||||
Gia_Obj_t * pObj;
|
||||
int i, Limit = r == nRounds-1 ? Gia_ManCiNum(p) % 64 : 64;
|
||||
for ( i = 0; i < Limit; i++ )
|
||||
Vec_WrdWriteEntry( vSims, 1+64*r+i, (word)1 << i );
|
||||
Gia_ManForEachAnd( p, pObj, i )
|
||||
Vec_WrdWriteEntry( vSims, i, Vec_WrdEntry(vSims, Gia_ObjFaninId0(pObj, i)) | Vec_WrdEntry(vSims, Gia_ObjFaninId1(pObj, i)) );
|
||||
Gia_ManForEachCo( p, pObj, i )
|
||||
nResult += Abc_TtCountOnes( Vec_WrdEntry(vSims, Gia_ObjFaninId0p(p, pObj)) );
|
||||
for ( i = 0; i < Limit; i++ )
|
||||
Vec_WrdWriteEntry( vSims, 1+64*r+i, 0 );
|
||||
}
|
||||
Vec_WrdFree( vSims );
|
||||
return nResult;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Compute dependency.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Gia_Man_t * Gia_ManComputeCofs( Gia_Man_t * p, int nVars )
|
||||
{
|
||||
Gia_Man_t * pNew, * pTemp;
|
||||
Gia_Obj_t * pObj; int i, m;
|
||||
Gia_Obj_t * pSink = Gia_ManCo(p, 0);
|
||||
Vec_Int_t * vRoots = Vec_IntAlloc( 1 );
|
||||
Vec_Int_t * vNodes = Vec_IntAlloc( 1000 );
|
||||
Vec_IntPush( vRoots, Gia_ObjFaninId0p(p, pSink) );
|
||||
Gia_ManCollectTfi( p, vRoots, vNodes );
|
||||
pNew = Gia_ManStart( Gia_ManObjNum(p) );
|
||||
pNew->pName = Abc_UtilStrsav( p->pName );
|
||||
Gia_ManForEachCi( p, pObj, i )
|
||||
pObj->Value = Gia_ManAppendCi(pNew);
|
||||
Gia_ManHashAlloc( pNew );
|
||||
for ( m = 0; m < (1 << nVars); m++ )
|
||||
{
|
||||
for ( i = 0; i < nVars; i++ )
|
||||
Gia_ManCi(p, Gia_ManCiNum(p)-nVars+i)->Value = (m >> i) & 1;
|
||||
Gia_ManForEachObjVec( vNodes, p, pObj, i )
|
||||
pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
|
||||
Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pSink) );
|
||||
}
|
||||
pNew = Gia_ManCleanup( pTemp = pNew );
|
||||
Gia_ManStop( pTemp );
|
||||
Vec_IntFree( vRoots );
|
||||
Vec_IntFree( vNodes );
|
||||
return pNew;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Compute dependency.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Gia_Man_t * Gia_ManComputeCofs2( Gia_Man_t * p )
|
||||
{
|
||||
Gia_Man_t * pNew, * pTemp;
|
||||
Gia_Obj_t * pObj, * pSink; int i, o, m;
|
||||
Vec_Int_t * vSupp = Vec_IntAlloc( 1000 );
|
||||
Vec_Int_t * vAnds = Vec_IntAlloc( 1000 );
|
||||
pNew = Gia_ManStart( Gia_ManObjNum(p) );
|
||||
pNew->pName = Abc_UtilStrsav( p->pName );
|
||||
Gia_ManForEachCi( p, pObj, i )
|
||||
{
|
||||
pObj->Value = Gia_ManAppendCi(pNew);
|
||||
assert( (int)pObj->Value == Abc_Var2Lit( 1 + Gia_ObjCioId(pObj), 0 ) );
|
||||
}
|
||||
Gia_ManHashAlloc( pNew );
|
||||
Gia_ManForEachRi( p, pSink, o )
|
||||
{
|
||||
int Fanin = Gia_ObjFaninId0p( p, pSink );
|
||||
Vec_Int_t * vNodes = Gia_ManCollectNodesCis( p, &Fanin, 1 );
|
||||
Vec_IntClear( vSupp );
|
||||
Vec_IntClear( vAnds );
|
||||
Gia_ManForEachObjVec( vNodes, p, pObj, i )
|
||||
Vec_IntPush( Gia_ObjIsAnd(pObj) ? vAnds : vSupp, Gia_ObjId(p, pObj) );
|
||||
Vec_IntFree( vNodes );
|
||||
Vec_IntSort( vSupp, 0 );
|
||||
for ( m = 0; m < 5; m++ )
|
||||
{
|
||||
Gia_ManForEachObjVec( vSupp, p, pObj, i )
|
||||
if ( i >= Vec_IntSize(vSupp)-5 )
|
||||
pObj->Value = (i == Vec_IntSize(vSupp)-5+m) ? 1 : 0;
|
||||
Gia_ManForEachObjVec( vAnds, p, pObj, i )
|
||||
pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
|
||||
//if ( m == 4 )
|
||||
// Gia_ManAppendCo( pNew, 0 );
|
||||
//else
|
||||
Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pSink) );
|
||||
Gia_ManAppendCo( pNew, Abc_Var2Lit( Vec_IntEntry(vSupp, Vec_IntSize(vSupp)-5+m), 0 ) );
|
||||
Gia_ManForEachObjVec( vSupp, p, pObj, i )
|
||||
if ( i >= Vec_IntSize(vSupp)-5 )
|
||||
pObj->Value = Abc_Var2Lit( 1 + Gia_ObjCioId(pObj), 0 );
|
||||
}
|
||||
}
|
||||
pNew = Gia_ManCleanup( pTemp = pNew );
|
||||
Gia_ManStop( pTemp );
|
||||
Vec_IntFree( vSupp );
|
||||
Vec_IntFree( vAnds );
|
||||
return pNew;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Compute dependency.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Gia_Man_t * Gia_ManComputeDepAig( Gia_Man_t * p, int iIn, int iOut )
|
||||
{
|
||||
Gia_Man_t * pNew, * pTemp;
|
||||
Gia_Obj_t * pObj; int i, n, iLits[2];
|
||||
Gia_Obj_t * pPivot = Gia_ManCi(p, iIn);
|
||||
Gia_Obj_t * pSink = Gia_ManCo(p, iOut);
|
||||
Vec_Int_t * vRoots = Vec_IntAlloc( 1 );
|
||||
Vec_Int_t * vNodes = Vec_IntAlloc( 1000 );
|
||||
Vec_IntPush( vRoots, Gia_ObjFaninId0p(p, pSink) );
|
||||
Gia_ManCollectTfi( p, vRoots, vNodes );
|
||||
pNew = Gia_ManStart( Gia_ManObjNum(p) );
|
||||
pNew->pName = Abc_UtilStrsav( p->pName );
|
||||
Gia_ManForEachCi( p, pObj, i )
|
||||
pObj->Value = Gia_ManAppendCi(pNew);
|
||||
Gia_ManHashAlloc( pNew );
|
||||
for ( n = 0; n < 2; n++ )
|
||||
{
|
||||
pPivot->Value = n;
|
||||
Gia_ManForEachObjVec( vNodes, p, pObj, i )
|
||||
pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
|
||||
iLits[n] = Gia_ObjFanin0Copy(pSink);
|
||||
}
|
||||
Gia_ManAppendCo( pNew, Gia_ManHashAnd(pNew, iLits[1], Abc_LitNot(iLits[0])) );
|
||||
Gia_ManAppendCo( pNew, Gia_ManHashAnd(pNew, iLits[0], Abc_LitNot(iLits[1])) );
|
||||
pNew = Gia_ManCleanup( pTemp = pNew );
|
||||
Gia_ManStop( pTemp );
|
||||
Vec_IntFree( vRoots );
|
||||
Vec_IntFree( vNodes );
|
||||
return pNew;
|
||||
}
|
||||
int Gia_ManComputeDep( Gia_Man_t * p, int iIn, int iOut )
|
||||
{
|
||||
extern Gia_Man_t * Cec4_ManSimulateTest3( Gia_Man_t * p, int nBTLimit, int fVerbose );
|
||||
Gia_Man_t * pNew = Gia_ManComputeDepAig( p, iIn, iOut );
|
||||
Gia_Man_t * pSwp = Cec4_ManSimulateTest3( pNew, 100000, 0 );
|
||||
int iLit[2] = { Gia_ObjFaninId0p( pSwp, Gia_ManCo(pSwp, 0) ), Gia_ObjFaninId0p( pSwp, Gia_ManCo(pSwp, 1) ) };
|
||||
Gia_ManStop( pNew );
|
||||
Gia_ManStop( pSwp );
|
||||
if ( iLit[0] == 0 && iLit[1] == 0 )
|
||||
return 2;
|
||||
if ( iLit[1] == 0 )
|
||||
return 1;
|
||||
if ( iLit[0] == 0 )
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
Gia_Man_t * Gia_ManComputeDepTest( Gia_Man_t * p )
|
||||
{
|
||||
abctime clk = Abc_Clock();
|
||||
int i;
|
||||
for ( i = 0; i < Gia_ManCiNum(p); i++ )
|
||||
printf( "%3d : %3d\n", i, Gia_ManComputeDep(p, i, 0) );
|
||||
Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
|
||||
return Gia_ManDup(p);
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Compute support diffs.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Vec_Wec_t * Gia_ManComputeSupports( Gia_Man_t * p )
|
||||
{
|
||||
Vec_Wec_t * vRes = Vec_WecStart( Gia_ManCoNum(p) );
|
||||
Vec_Wec_t * vSupps = Vec_WecStart( Gia_ManObjNum(p) );
|
||||
Gia_Obj_t * pObj; int i;
|
||||
for ( i = 0; i < Gia_ManCiNum(p); i++ )
|
||||
Vec_IntPush( Vec_WecEntry(vSupps, 1+i), i );
|
||||
Gia_ManForEachAnd( p, pObj, i )
|
||||
Vec_IntTwoMerge2( Vec_WecEntry(vSupps, Gia_ObjFaninId0(pObj, i)), Vec_WecEntry(vSupps, Gia_ObjFaninId1(pObj, i)), Vec_WecEntry(vSupps, i) );
|
||||
Gia_ManForEachCo( p, pObj, i )
|
||||
Vec_IntAppend( Vec_WecEntry(vRes, i), Vec_WecEntry(vSupps, Gia_ObjFaninId0p(p, pObj)) );
|
||||
Vec_WecFree( vSupps );
|
||||
return vRes;
|
||||
}
|
||||
Vec_Wec_t * Gia_ManComputeSharing( Vec_Wec_t * vSupps )
|
||||
{
|
||||
Vec_Wec_t * vDiffs = Vec_WecStart( Vec_WecSize(vSupps) );
|
||||
Vec_Int_t * vNew, * vOld; int i;
|
||||
Vec_WecForEachLevelTwo( vDiffs, vSupps, vNew, vOld, i ) if ( i )
|
||||
Vec_IntTwoFindCommon( Vec_WecEntry(vSupps, i-1), vOld, vNew );
|
||||
return vDiffs;
|
||||
}
|
||||
Vec_Str_t * Gia_ManConvertDump( Gia_Man_t * p, Vec_Wec_t * vSupps )
|
||||
{
|
||||
int fPrintDep = 1;
|
||||
int nSize = Gia_ManCoNum(p) * (Gia_ManCiNum(p) + 1) + 1;
|
||||
Vec_Str_t * vRes = Vec_StrAlloc( nSize );
|
||||
Vec_Int_t * vLevel; int i, k, Obj;
|
||||
assert( Gia_ManCoNum(p) == Vec_WecSize(vSupps) );
|
||||
Vec_StrFill( vRes, nSize-1, '_' );
|
||||
Vec_StrPush( vRes, '\0' );
|
||||
Vec_WecForEachLevel( vSupps, vLevel, i )
|
||||
{
|
||||
Vec_IntForEachEntry( vLevel, Obj, k )
|
||||
{
|
||||
if ( !fPrintDep )
|
||||
Vec_StrWriteEntry( vRes, i * (Gia_ManCiNum(p) + 1) + Obj, '*' );
|
||||
else
|
||||
{
|
||||
int Value = Gia_ManComputeDep( p, Obj, i );
|
||||
if ( Value == -1 )
|
||||
Vec_StrWriteEntry( vRes, i * (Gia_ManCiNum(p) + 1) + Obj, '*' );
|
||||
else
|
||||
Vec_StrWriteEntry( vRes, i * (Gia_ManCiNum(p) + 1) + Obj, (char)('0'+Value) );
|
||||
}
|
||||
}
|
||||
Vec_StrWriteEntry( vRes, i * (Gia_ManCiNum(p) + 1) + Gia_ManCiNum(p), '\n' );
|
||||
//printf( "Output %d\n", i );
|
||||
}
|
||||
return vRes;
|
||||
}
|
||||
void Gia_ManDumpSuppFile( Vec_Str_t * p, char * pFileName )
|
||||
{
|
||||
FILE * pFile = fopen( pFileName, "wb" );
|
||||
if ( pFile == NULL )
|
||||
printf( "Cannot open file \"%s\" for writing.\n", pFileName );
|
||||
else
|
||||
{
|
||||
int nOuts = Vec_StrCountEntry(p, '\n');
|
||||
int nIns = Vec_StrSize(p)/Vec_StrCountEntry(p, '\n') - 1;
|
||||
int nSize1 = Vec_StrSize(p) - 1;
|
||||
int nSize2 = fwrite( Vec_StrArray(p), 1, nSize1, pFile );
|
||||
assert( nSize1 == nSize2 );
|
||||
printf( "Successfully dumped file \"%s\" with support data for %d outputs and %d inputs.\n", pFileName, nOuts, nIns );
|
||||
}
|
||||
fclose( pFile );
|
||||
}
|
||||
void Gia_ManDumpSuppFileTest3( Gia_Man_t * p, char * pFileName )
|
||||
{
|
||||
Vec_Wec_t * vSupps = Gia_ManComputeSupports( p );
|
||||
Vec_Wec_t * vDiffs = Gia_ManComputeSharing( vSupps );
|
||||
Vec_Wec_t * vDiffs2 = Gia_ManComputeSharing( vDiffs );
|
||||
Vec_Str_t * vRes = Gia_ManConvertDump( p, vDiffs2 );
|
||||
Gia_ManDumpSuppFile( vRes, pFileName );
|
||||
Vec_WecFree( vDiffs2 );
|
||||
Vec_WecFree( vDiffs );
|
||||
Vec_WecFree( vSupps );
|
||||
Vec_StrFree( vRes );
|
||||
}
|
||||
void Gia_ManDumpSuppFileTest( Gia_Man_t * p, char * pFileName )
|
||||
{
|
||||
Vec_Wec_t * vSupps = Gia_ManComputeSupports( p );
|
||||
Vec_Str_t * vRes = Gia_ManConvertDump( p, vSupps );
|
||||
Gia_ManDumpSuppFile( vRes, pFileName );
|
||||
Vec_WecFree( vSupps );
|
||||
Vec_StrFree( vRes );
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Compute support diffs.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_ManConvertSupp_rec( Gia_Man_t * pNew, Gia_Man_t * p, Gia_Obj_t * pObj )
|
||||
{
|
||||
if ( !Gia_ObjIsAnd(pObj) )
|
||||
return;
|
||||
if ( Gia_ObjIsTravIdCurrent(p, pObj) )
|
||||
return;
|
||||
Gia_ObjSetTravIdCurrent(p, pObj);
|
||||
Gia_ManConvertSupp_rec( pNew, p, Gia_ObjFanin0(pObj) );
|
||||
Gia_ManConvertSupp_rec( pNew, p, Gia_ObjFanin1(pObj) );
|
||||
pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
|
||||
}
|
||||
Gia_Man_t * Gia_ManConvertSupp( Gia_Man_t * p )
|
||||
{
|
||||
int fOnly1 = 0;
|
||||
int fVerbose = 1;
|
||||
abctime clk = Abc_Clock();
|
||||
Gia_Man_t * pNew, * pTemp;
|
||||
Gia_Obj_t * pObjPi, * pObjRi, * pObjRo;
|
||||
Vec_Int_t * vSupp = Vec_IntAlloc( 100 );
|
||||
Vec_Int_t * vAnds = Vec_IntAlloc( 100 );
|
||||
int i, n, iLits[2];
|
||||
assert( Gia_ManRegNum(p) && Gia_ManRegNum(p) % 8 == 0 );
|
||||
pNew = Gia_ManStart( Gia_ManObjNum(p) );
|
||||
pNew->pName = Abc_UtilStrsav( p->pName );
|
||||
pNew->pSpec = Abc_UtilStrsav( p->pSpec );
|
||||
Gia_ManFillValue(p);
|
||||
Gia_ManConst0(p)->Value = 0;
|
||||
Gia_ManForEachPi( p, pObjPi, i )
|
||||
pObjPi->Value = Gia_ManAppendCi( pNew );
|
||||
Gia_ManHashAlloc( pNew );
|
||||
Gia_ManForEachRi( p, pObjRi, i )
|
||||
{
|
||||
pObjRo = Gia_ObjRiToRo(p, pObjRi);
|
||||
if ( (i - Gia_ManPoNum(p)) % 8 != 0 )
|
||||
continue;
|
||||
if ( fOnly1 )
|
||||
{
|
||||
assert( pObjRo->Value == ~0 );
|
||||
for ( n = 0; n < 2; n++ )
|
||||
{
|
||||
pObjRo->Value = n;
|
||||
Gia_ManIncrementTravId( p );
|
||||
Gia_ManConvertSupp_rec( pNew, p, Gia_ObjFanin0(pObjRi) );
|
||||
iLits[n] = Gia_ObjFanin0Copy(pObjRi);
|
||||
}
|
||||
pObjRo->Value = ~0;
|
||||
Gia_ManAppendCo( pNew, Abc_LitNot(Gia_ManHashAnd( pNew, iLits[1], Abc_LitNot(iLits[0]) )) );
|
||||
}
|
||||
else
|
||||
{
|
||||
int Fanin = Gia_ObjFaninId0p( p, pObjRi );
|
||||
Vec_Int_t * vNodes = Gia_ManCollectNodesCis( p, &Fanin, 1 );
|
||||
Gia_Obj_t * pObj; int i, m;
|
||||
Vec_IntClear( vSupp );
|
||||
Vec_IntClear( vAnds );
|
||||
Gia_ManForEachObjVec( vNodes, p, pObj, i )
|
||||
Vec_IntPush( Gia_ObjIsAnd(pObj) ? vAnds : vSupp, Gia_ObjId(p, pObj) );
|
||||
Vec_IntFree( vNodes );
|
||||
Vec_IntSort( vSupp, 0 );
|
||||
for ( m = 0; m < 4; m++ )
|
||||
{
|
||||
Gia_ManForEachObjVec( vSupp, p, pObj, i )
|
||||
if ( i >= Vec_IntSize(vSupp)-5 )
|
||||
pObj->Value = (i == Vec_IntSize(vSupp)-5+m) ? 1 : 0;
|
||||
Gia_ManForEachObjVec( vAnds, p, pObj, i )
|
||||
pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
|
||||
//if ( m == 4 )
|
||||
// Gia_ManAppendCo( pNew, 0 );
|
||||
//else
|
||||
Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObjRi) );
|
||||
//Gia_ManAppendCo( pNew, Abc_Var2Lit( Vec_IntEntry(vSupp, Vec_IntSize(vSupp)-5+m), 0 ) );
|
||||
Gia_ManForEachObjVec( vSupp, p, pObj, i )
|
||||
if ( i >= Vec_IntSize(vSupp)-5 )
|
||||
pObj->Value = Abc_Var2Lit( 1 + Gia_ObjCioId(pObj), 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
Vec_IntFree( vSupp );
|
||||
Vec_IntFree( vAnds );
|
||||
Gia_ManHashStop( pNew );
|
||||
//Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
|
||||
pNew = Gia_ManCleanup( pTemp = pNew );
|
||||
Gia_ManStop( pTemp );
|
||||
if ( fVerbose )
|
||||
printf( "Transformed %d outputs, ", Gia_ManPoNum(pNew) );
|
||||
if ( fVerbose )
|
||||
Abc_PrintTime( 0, "Time", Abc_Clock() - clk );
|
||||
return pNew;
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Transform flops.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Gia_Man_t * Gia_ManTransformCond2( Gia_Man_t * p )
|
||||
{
|
||||
int fVerbose = 1;
|
||||
abctime clk = Abc_Clock();
|
||||
Gia_Man_t * pNew, * pTemp;
|
||||
Gia_Obj_t * pObjPi, * pObjRi, * pObjRo;
|
||||
int i, n, iTempLit, iLits[2];
|
||||
assert( Gia_ManRegNum(p) > 0 );
|
||||
pNew = Gia_ManStart( Gia_ManObjNum(p) );
|
||||
pNew->pName = Abc_UtilStrsav( p->pName );
|
||||
pNew->pSpec = Abc_UtilStrsav( p->pSpec );
|
||||
Gia_ManFillValue(p);
|
||||
Gia_ManConst0(p)->Value = 0;
|
||||
Gia_ManForEachCi( p, pObjPi, i )
|
||||
pObjPi->Value = Gia_ManAppendCi( pNew );
|
||||
Gia_ManHashAlloc( pNew );
|
||||
Gia_ManForEachRi( p, pObjRi, i )
|
||||
{
|
||||
//if ( (i - Gia_ManPoNum(p)) % 8 != 0 )
|
||||
// continue;
|
||||
pObjRo = Gia_ObjRiToRo(p, pObjRi);
|
||||
iTempLit = pObjRo->Value;
|
||||
for ( n = 0; n < 2; n++ )
|
||||
{
|
||||
pObjRo->Value = n;
|
||||
Gia_ManIncrementTravId( p );
|
||||
Gia_ManConvertSupp_rec( pNew, p, Gia_ObjFanin0(pObjRi) );
|
||||
iLits[n] = Gia_ObjFanin0Copy(pObjRi);
|
||||
}
|
||||
pObjRo->Value = iTempLit;
|
||||
Gia_ManAppendCo( pNew, Abc_LitNot(Gia_ManHashAnd( pNew, iLits[1], Abc_LitNot(iLits[0]) )) );
|
||||
Gia_ManAppendCo( pNew, Abc_LitNot(Gia_ManHashAnd( pNew, iLits[0], Abc_LitNot(iLits[1]) )) );
|
||||
}
|
||||
Gia_ManHashStop( pNew );
|
||||
//Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
|
||||
pNew = Gia_ManCleanup( pTemp = pNew );
|
||||
Gia_ManStop( pTemp );
|
||||
if ( fVerbose )
|
||||
printf( "Created %d outputs. ", Gia_ManPoNum(pNew) );
|
||||
if ( fVerbose )
|
||||
Abc_PrintTime( 0, "Time", Abc_Clock() - clk );
|
||||
return pNew;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Transform flops.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Vec_Wrd_t * Gia_ManDetectSims( Gia_Man_t * p, int iCo, int nWords )
|
||||
{
|
||||
extern int Cec4_ManGeneratePatterns_rec( Gia_Man_t * p, Gia_Obj_t * pObj, int Value, Vec_Int_t * vPat, Vec_Int_t * vVisit );
|
||||
Vec_Wrd_t * vSim = Vec_WrdStart( nWords * Gia_ManCiNum(p) );
|
||||
Vec_Int_t * vPat = Vec_IntAlloc( Gia_ManCiNum(p) );
|
||||
Vec_Int_t * vVis = Vec_IntAlloc( Gia_ManAndNum(p) );
|
||||
Gia_Obj_t * pObj = Gia_ManCo( p, iCo ), * pTemp; int iLit, i, k, nTries = 0;
|
||||
if ( Gia_ObjFanin0(pObj) == Gia_ManConst0(p) )
|
||||
return NULL;
|
||||
Gia_ManForEachObj( p, pTemp, k )
|
||||
assert( !pTemp->fMark0 && !pTemp->fMark1 );
|
||||
for ( i = 0; i < 64*nWords; )
|
||||
{
|
||||
int Res = Cec4_ManGeneratePatterns_rec( p, Gia_ObjFanin0(pObj), !Gia_ObjFaninC0(pObj), vPat, vVis );
|
||||
if ( Res )
|
||||
{
|
||||
Vec_IntForEachEntry( vPat, iLit, k )
|
||||
{
|
||||
if ( Abc_LitIsCompl(iLit) )
|
||||
continue;
|
||||
pTemp = Gia_ManObj( p, Abc_Lit2Var(iLit) );
|
||||
assert( Gia_ObjIsCi(pTemp) );
|
||||
Abc_InfoSetBit( (unsigned *)Vec_WrdEntryP(vSim, nWords*Gia_ObjCioId(pTemp)), i );
|
||||
}
|
||||
i++;
|
||||
}
|
||||
Gia_ManForEachObjVec( vVis, p, pTemp, k )
|
||||
pTemp->fMark0 = pTemp->fMark1 = 0;
|
||||
nTries++;
|
||||
}
|
||||
//printf( "%d ", nTries );
|
||||
Vec_IntFree( vPat );
|
||||
Vec_IntFree( vVis );
|
||||
return vSim;
|
||||
}
|
||||
Vec_Wrd_t * Vec_WrdInterleave( Vec_Wrd_t * p1, Vec_Wrd_t * p2, int nWords, int nIns )
|
||||
{
|
||||
Vec_Wrd_t * p = Vec_WrdAlloc( Vec_WrdSize(p1)+Vec_WrdSize(p2) );
|
||||
int i, k;
|
||||
assert( Vec_WrdSize(p1) == nWords*nIns );
|
||||
assert( Vec_WrdSize(p2) == nWords*nIns );
|
||||
for ( i = 0; i < nIns; i++ )
|
||||
{
|
||||
for ( k = 0; k < nWords; k++ )
|
||||
Vec_WrdPush( p, Vec_WrdEntry(p1, i*nWords+k) );
|
||||
for ( k = 0; k < nWords; k++ )
|
||||
Vec_WrdPush( p, Vec_WrdEntry(p2, i*nWords+k) );
|
||||
}
|
||||
return p;
|
||||
}
|
||||
Gia_Man_t * Gia_ManTransformCond( Gia_Man_t * p )
|
||||
{
|
||||
extern void Gia_ManResubPair( Vec_Wrd_t * vOn, Vec_Wrd_t * vOff, int nWords, int nIns );
|
||||
abctime clk = Abc_Clock();
|
||||
Vec_Wrd_t * vSims;
|
||||
Vec_Wrd_t * vSim[4];
|
||||
Vec_Wrd_t * vInt[6];
|
||||
int i;
|
||||
for ( i = 0; i < Gia_ManCoNum(p); i++ )
|
||||
{
|
||||
vSims = Gia_ManDetectSims( p, i, 1 );
|
||||
if ( i >= Gia_ManCoNum(p)-4 )
|
||||
vSim[i-(Gia_ManCoNum(p)-4)] = vSims;
|
||||
else
|
||||
Vec_WrdFreeP( &vSims );
|
||||
//Vec_PtrPush( vAll, vSims );
|
||||
}
|
||||
vInt[0] = Vec_WrdInterleave( vSim[0], vSim[1], 1, Gia_ManCiNum(p) );
|
||||
vInt[1] = Vec_WrdInterleave( vSim[0], vSim[2], 1, Gia_ManCiNum(p) );
|
||||
vInt[2] = Vec_WrdInterleave( vSim[0], vSim[3], 1, Gia_ManCiNum(p) );
|
||||
vInt[3] = Vec_WrdInterleave( vSim[1], vSim[2], 1, Gia_ManCiNum(p) );
|
||||
vInt[4] = Vec_WrdInterleave( vSim[1], vSim[3], 1, Gia_ManCiNum(p) );
|
||||
vInt[5] = Vec_WrdInterleave( vSim[2], vSim[3], 1, Gia_ManCiNum(p) );
|
||||
|
||||
Gia_ManResubPair( vInt[0], vInt[5], 2, Gia_ManCiNum(p) );
|
||||
Gia_ManResubPair( vInt[1], vInt[4], 2, Gia_ManCiNum(p) );
|
||||
Gia_ManResubPair( vInt[2], vInt[3], 2, Gia_ManCiNum(p) );
|
||||
|
||||
Gia_ManResubPair( vInt[5], vInt[0], 2, Gia_ManCiNum(p) );
|
||||
Gia_ManResubPair( vInt[4], vInt[1], 2, Gia_ManCiNum(p) );
|
||||
Gia_ManResubPair( vInt[3], vInt[2], 2, Gia_ManCiNum(p) );
|
||||
|
||||
/*
|
||||
for ( i = 0; i < 4; i++ )
|
||||
for ( k = i+1; k < 4; k++ )
|
||||
Gia_ManResubPair( vSim[i], vSim[k], 1, Gia_ManCiNum(p) );
|
||||
*/
|
||||
Abc_PrintTime( 0, "Time", Abc_Clock() - clk );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
|
|
|
|||
|
|
@ -14,8 +14,10 @@ SRC += src/aig/gia/giaAig.c \
|
|||
src/aig/gia/giaCSatOld.c \
|
||||
src/aig/gia/giaCSat.c \
|
||||
src/aig/gia/giaCSat2.c \
|
||||
src/aig/gia/giaCSat3.c \
|
||||
src/aig/gia/giaCTas.c \
|
||||
src/aig/gia/giaCut.c \
|
||||
src/aig/gia/giaDecs.c \
|
||||
src/aig/gia/giaDeep.c \
|
||||
src/aig/gia/giaDfs.c \
|
||||
src/aig/gia/giaDup.c \
|
||||
|
|
@ -51,14 +53,21 @@ SRC += src/aig/gia/giaAig.c \
|
|||
src/aig/gia/giaMem.c \
|
||||
src/aig/gia/giaMfs.c \
|
||||
src/aig/gia/giaMini.c \
|
||||
src/aig/gia/giaMinLut.c \
|
||||
src/aig/gia/giaMinLut2.c \
|
||||
src/aig/gia/giaMuxes.c \
|
||||
src/aig/gia/giaNf.c \
|
||||
src/aig/gia/giaOf.c \
|
||||
src/aig/gia/giaPack.c \
|
||||
src/aig/gia/giaPat.c \
|
||||
src/aig/gia/giaPat2.c \
|
||||
src/aig/gia/giaPf.c \
|
||||
src/aig/gia/giaQbf.c \
|
||||
src/aig/gia/giaReshape1.c \
|
||||
src/aig/gia/giaReshape2.c \
|
||||
src/aig/gia/giaResub.c \
|
||||
src/aig/gia/giaResub2.c \
|
||||
src/aig/gia/giaResub3.c \
|
||||
src/aig/gia/giaRetime.c \
|
||||
src/aig/gia/giaRex.c \
|
||||
src/aig/gia/giaSatEdge.c \
|
||||
|
|
@ -75,16 +84,16 @@ SRC += src/aig/gia/giaAig.c \
|
|||
src/aig/gia/giaShrink7.c \
|
||||
src/aig/gia/giaSim.c \
|
||||
src/aig/gia/giaSim2.c \
|
||||
src/aig/gia/giaSim4.c \
|
||||
src/aig/gia/giaSim5.c \
|
||||
src/aig/gia/giaSimBase.c \
|
||||
src/aig/gia/giaSort.c \
|
||||
src/aig/gia/giaSpeedup.c \
|
||||
src/aig/gia/giaSplit.c \
|
||||
src/aig/gia/giaStg.c \
|
||||
src/aig/gia/giaStoch.c \
|
||||
src/aig/gia/giaStr.c \
|
||||
src/aig/gia/giaSupMin.c \
|
||||
src/aig/gia/giaSupp.c \
|
||||
src/aig/gia/giaSupps.c \
|
||||
src/aig/gia/giaSweep.c \
|
||||
src/aig/gia/giaSweeper.c \
|
||||
src/aig/gia/giaSwitch.c \
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ Hop_Obj_t * Hop_NodeBalanceBuildSuper( Hop_Man_t * p, Vec_Ptr_t * vSuper, Hop_Ty
|
|||
int LeftBound;
|
||||
assert( vSuper->nSize > 1 );
|
||||
// sort the new nodes by level in the decreasing order
|
||||
Vec_PtrSort( vSuper, (int (*)(void))Hop_NodeCompareLevelsDecrease );
|
||||
Vec_PtrSort( vSuper, (int (*)(const void *, const void *))Hop_NodeCompareLevelsDecrease );
|
||||
// balance the nodes
|
||||
while ( vSuper->nSize > 1 )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ Ivy_Obj_t * Ivy_NodeBalanceBuildSuper( Ivy_Man_t * p, Vec_Ptr_t * vSuper, Ivy_Ty
|
|||
int LeftBound;
|
||||
assert( vSuper->nSize > 1 );
|
||||
// sort the new nodes by level in the decreasing order
|
||||
Vec_PtrSort( vSuper, (int (*)(void))Ivy_NodeCompareLevelsDecrease );
|
||||
Vec_PtrSort( vSuper, (int (*)(const void *, const void *))Ivy_NodeCompareLevelsDecrease );
|
||||
// balance the nodes
|
||||
while ( vSuper->nSize > 1 )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ void Ivy_NodeComputeVolume2( Ivy_Obj_t * pObj, int nNodeLimit, Vec_Ptr_t * vNode
|
|||
} while ( Vec_PtrSize(vNodes) < nNodeLimit );
|
||||
|
||||
// sort nodes by level
|
||||
Vec_PtrSort( vNodes, (int (*)(void))Ivy_CompareNodesByLevel );
|
||||
Vec_PtrSort( vNodes, (int (*)(const void *, const void *))Ivy_CompareNodesByLevel );
|
||||
// make sure the nodes are ordered in the increasing number of levels
|
||||
pFanin = (Ivy_Obj_t *)Vec_PtrEntry( vNodes, 0 );
|
||||
pPivot = (Ivy_Obj_t *)Vec_PtrEntryLast( vNodes );
|
||||
|
|
|
|||
|
|
@ -371,7 +371,7 @@ int Ivy_ManFindAlgCut( Ivy_Obj_t * pRoot, Vec_Ptr_t * vFront, Vec_Ptr_t * vLeave
|
|||
if ( Vec_PtrSize(vFront) <= 2 )
|
||||
return 1;
|
||||
// sort the entries in increasing order
|
||||
Vec_PtrSort( vFront, (int (*)(void))Ivy_ManFindAlgCutCompare );
|
||||
Vec_PtrSort( vFront, (int (*)(const void *, const void *))Ivy_ManFindAlgCutCompare );
|
||||
// remove duplicates from vFront and save the nodes in vLeaves
|
||||
pPrev = Vec_PtrEntry(vFront, 0);
|
||||
Vec_PtrPush( vLeaves, pPrev );
|
||||
|
|
|
|||
|
|
@ -29,7 +29,9 @@
|
|||
/// PARAMETERS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _YOSYS_
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// BASIC TYPES ///
|
||||
|
|
@ -232,6 +234,26 @@ static inline const char * Abc_OperName( int Type )
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// printing operator types
|
||||
static inline const char * Abc_OperNameSimple( int Type )
|
||||
{
|
||||
if ( Type == ABC_OPER_NONE ) return NULL;
|
||||
if ( Type == ABC_OPER_CONST_F ) return "buf";
|
||||
if ( Type == ABC_OPER_CONST_T ) return "buf";
|
||||
if ( Type == ABC_OPER_CONST_X ) return "buf";
|
||||
if ( Type == ABC_OPER_CONST_Z ) return "buf";
|
||||
if ( Type == ABC_OPER_BIT_BUF ) return "buf";
|
||||
if ( Type == ABC_OPER_BIT_INV ) return "not";
|
||||
if ( Type == ABC_OPER_BIT_AND ) return "and";
|
||||
if ( Type == ABC_OPER_BIT_OR ) return "or";
|
||||
if ( Type == ABC_OPER_BIT_XOR ) return "xor";
|
||||
if ( Type == ABC_OPER_BIT_NAND ) return "nand";
|
||||
if ( Type == ABC_OPER_BIT_NOR ) return "nor";
|
||||
if ( Type == ABC_OPER_BIT_NXOR ) return "xnor";
|
||||
assert( 0 );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// MACRO DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -244,9 +266,9 @@ static inline const char * Abc_OperName( int Type )
|
|||
/// FUNCTION DECLARATIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef _YOSYS_
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -179,7 +179,37 @@ static void Mini_LutPrintStats( Mini_Lut_t * p )
|
|||
nNodes = 0;
|
||||
Mini_LutForEachNode( p, i )
|
||||
nNodes++;
|
||||
printf( "PI = %d. PO = %d. LUT = %d.\n", nPis, nPos, nNodes );
|
||||
printf( "PI = %d. PO = %d. LUT = %d. FF = %d.\n", nPis, nPos, nNodes, p->nRegs );
|
||||
}
|
||||
static void Mini_LutPrint( Mini_Lut_t * p )
|
||||
{
|
||||
int i, k, Fan;
|
||||
printf( "MiniLUT statistics: " );
|
||||
Mini_LutPrintStats( p );
|
||||
printf( "Printout of nodes:\n" );
|
||||
for ( i = 0; i < p->nSize; i++ )
|
||||
{
|
||||
printf( "%6d : ", i );
|
||||
if ( Mini_LutNodeIsConst(p, i) )
|
||||
printf( "Const%d", i );
|
||||
else if ( Mini_LutNodeIsPi(p, i) )
|
||||
printf( "PI" );
|
||||
else if ( Mini_LutNodeIsPo(p, i) )
|
||||
printf( "PO" );
|
||||
else if ( Mini_LutNodeIsNode(p, i) )
|
||||
{
|
||||
printf( "LUT%d Fanins:", p->LutSize );
|
||||
Mini_LutForEachFanin( p, i, Fan, k )
|
||||
printf( " %6d", Fan );
|
||||
while ( k++ < p->LutSize )
|
||||
printf( " " );
|
||||
printf( " Function: " );
|
||||
for ( k = 31; k >= 0; k-- )
|
||||
printf( "%c", '0' + ((p->pTruths[i] >> k) & 1) );
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
printf( "End of printout.\n" );
|
||||
}
|
||||
|
||||
// serialization
|
||||
|
|
|
|||
|
|
@ -33,7 +33,9 @@
|
|||
|
||||
#include "abcOper.h"
|
||||
|
||||
#ifndef _YOSYS_
|
||||
ABC_NAMESPACE_HEADER_START
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define inline __inline
|
||||
|
|
@ -215,8 +217,9 @@ static inline void Ndr_DataPushString( Ndr_Data_t * p, int ObjType, int Type, ch
|
|||
return;
|
||||
if ( ObjType == ABC_OPER_LUT )
|
||||
{
|
||||
word Truth = (word)pFunc;
|
||||
Ndr_DataPushArray( p, Type, 2, (int *)&Truth );
|
||||
//word Truth = (word)pFunc;
|
||||
//Ndr_DataPushArray( p, Type, 2, (int *)&Truth );
|
||||
Ndr_DataPushArray( p, Type, 2, (int *)&pFunc );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -334,7 +337,7 @@ static inline int Ndr_DataObjNum( Ndr_Data_t * p, int Mod )
|
|||
}
|
||||
|
||||
// to write signal names, this procedure takes a mapping of name IDs into actual char-strings (pNames)
|
||||
static inline void Ndr_WriteVerilogModule( FILE * pFile, void * pDesign, int Mod, char ** pNames )
|
||||
static inline void Ndr_WriteVerilogModule( FILE * pFile, void * pDesign, int Mod, char ** pNames, int fSimple )
|
||||
{
|
||||
Ndr_Data_t * p = (Ndr_Data_t *)pDesign;
|
||||
int * pOuts = NDR_ALLOC( int, Ndr_DataCoNum(p, Mod) );
|
||||
|
|
@ -377,6 +380,8 @@ static inline void Ndr_WriteVerilogModule( FILE * pFile, void * pDesign, int Mod
|
|||
break;
|
||||
if ( k < i )
|
||||
continue;
|
||||
if ( Ndr_ObjReadOutName(p, Obj, pNames)[0] == '1' )
|
||||
continue;
|
||||
fprintf( pFile, " wire " );
|
||||
Ndr_ObjWriteRange( p, Obj, pFile, 1 );
|
||||
fprintf( pFile, " %s;\n", Ndr_ObjReadOutName(p, Obj, pNames) );
|
||||
|
|
@ -459,6 +464,24 @@ static inline void Ndr_WriteVerilogModule( FILE * pFile, void * pDesign, int Mod
|
|||
fprintf( pFile, ");\n" );
|
||||
continue;
|
||||
}
|
||||
if ( fSimple )
|
||||
{
|
||||
if ( Ndr_ObjReadOutName(p, Obj, pNames)[0] == '1' )
|
||||
continue;
|
||||
nArray = Ndr_ObjReadArray( p, Obj, NDR_INPUT, &pArray );
|
||||
fprintf( pFile, " %s ( %s", Abc_OperNameSimple(Type), Ndr_ObjReadOutName(p, Obj, pNames) );
|
||||
if ( nArray == 0 )
|
||||
fprintf( pFile, ", %s );\n", (char *)Ndr_ObjReadBodyP(p, Obj, NDR_FUNCTION) );
|
||||
else if ( nArray == 1 && Ndr_ObjReadBody(p, Obj, NDR_OPERTYPE) == ABC_OPER_BIT_BUF )
|
||||
fprintf( pFile, ", %s );\n", pNames[pArray[0]] );
|
||||
else
|
||||
{
|
||||
for ( i = 0; i < nArray; i++ )
|
||||
fprintf( pFile, ", %s", pNames[pArray[i]] );
|
||||
fprintf( pFile, " );\n" );
|
||||
}
|
||||
continue;
|
||||
}
|
||||
fprintf( pFile, " assign %s = ", Ndr_ObjReadOutName(p, Obj, pNames) );
|
||||
nArray = Ndr_ObjReadArray( p, Obj, NDR_INPUT, &pArray );
|
||||
if ( nArray == 0 )
|
||||
|
|
@ -492,15 +515,15 @@ static inline void Ndr_WriteVerilogModule( FILE * pFile, void * pDesign, int Mod
|
|||
}
|
||||
|
||||
// to write signal names, this procedure takes a mapping of name IDs into actual char-strings (pNames)
|
||||
static inline void Ndr_WriteVerilog( char * pFileName, void * pDesign, char ** pNames )
|
||||
static inline void Ndr_WriteVerilog( char * pFileName, void * pDesign, char ** pNames, int fSimple )
|
||||
{
|
||||
Ndr_Data_t * p = (Ndr_Data_t *)pDesign; int Mod;
|
||||
|
||||
FILE * pFile = pFileName ? fopen( pFileName, "wb" ) : stdout;
|
||||
if ( pFile == NULL ) { printf( "Cannot open file \"%s\" for writing.\n", pFileName ); return; }
|
||||
if ( pFile == NULL ) { printf( "Cannot open file \"%s\" for writing.\n", pFileName ? pFileName : "stdout" ); return; }
|
||||
|
||||
Ndr_DesForEachMod( p, Mod )
|
||||
Ndr_WriteVerilogModule( pFile, p, Mod, pNames );
|
||||
Ndr_WriteVerilogModule( pFile, p, Mod, pNames, fSimple );
|
||||
|
||||
if ( pFileName ) fclose( pFile );
|
||||
}
|
||||
|
|
@ -613,7 +636,7 @@ static inline void Ndr_Write( char * pFileName, void * pDesign )
|
|||
{
|
||||
Ndr_Data_t * p = (Ndr_Data_t *)pDesign; int RetValue;
|
||||
FILE * pFile = fopen( pFileName, "wb" );
|
||||
if ( pFile == NULL ) { printf( "Cannot open file \"%s\" for writing.\n", pFileName ); return; }
|
||||
if ( pFile == NULL ) { printf( "Cannot open file \"%s\" for writing.\n", pFileName ? pFileName : "stdout" ); return; }
|
||||
RetValue = (int)fwrite( p->pBody, 4, p->pBody[0], pFile );
|
||||
RetValue = (int)fwrite( p->pHead, 1, p->pBody[0], pFile );
|
||||
fclose( pFile );
|
||||
|
|
@ -642,7 +665,7 @@ static inline void Ndr_ModuleTest()
|
|||
// array of fanins of node s
|
||||
int Fanins[2] = { NameIdA, NameIdC };
|
||||
// map name IDs into char strings
|
||||
char * ppNames[5] = { NULL, "add10", "a", "s", "const10" };
|
||||
//char * ppNames[5] = { NULL, "add10", "a", "s", "const10" };
|
||||
|
||||
// create a new module
|
||||
void * pDesign = Ndr_Create( 1 );
|
||||
|
|
@ -651,13 +674,13 @@ static inline void Ndr_ModuleTest()
|
|||
|
||||
// add objects to the modele
|
||||
Ndr_AddObject( pDesign, ModuleID, ABC_OPER_CI, 0, 3, 0, 0, 0, NULL, 1, &NameIdA, NULL ); // no fanins
|
||||
Ndr_AddObject( pDesign, ModuleID, ABC_OPER_CONST, 0, 3, 0, 0, 0, NULL, 1, &NameIdC, "4'b1010" ); // no fanins
|
||||
Ndr_AddObject( pDesign, ModuleID, ABC_OPER_CONST, 0, 3, 0, 0, 0, NULL, 1, &NameIdC, (char*)"4'b1010" ); // no fanins
|
||||
Ndr_AddObject( pDesign, ModuleID, ABC_OPER_ARI_ADD, 0, 3, 0, 0, 2, Fanins, 1, &NameIdS, NULL ); // fanins are a and const10
|
||||
Ndr_AddObject( pDesign, ModuleID, ABC_OPER_CO, 0, 3, 0, 0, 1, &NameIdS, 0, NULL, NULL ); // fanin is a
|
||||
|
||||
// write Verilog for verification
|
||||
Ndr_WriteVerilog( NULL, pDesign, ppNames );
|
||||
Ndr_Write( "add4.ndr", pDesign );
|
||||
//Ndr_WriteVerilog( NULL, pDesign, ppNames, 0 );
|
||||
Ndr_Write( (char*)"add4.ndr", pDesign );
|
||||
Ndr_Delete( pDesign );
|
||||
}
|
||||
|
||||
|
|
@ -686,6 +709,7 @@ static inline void Ndr_ModuleTest()
|
|||
|
||||
static inline void Ndr_ModuleTestAdder()
|
||||
{
|
||||
/*
|
||||
// map name IDs into char strings
|
||||
char * ppNames[20] = { NULL,
|
||||
"a", "b", "s", "co", // 1, 2, 3, 4
|
||||
|
|
@ -693,6 +717,7 @@ static inline void Ndr_ModuleTestAdder()
|
|||
"r0", "s0", "rco", // 9, 10, 11
|
||||
"r1", "s1", "add8" // 12, 13, 14
|
||||
};
|
||||
*/
|
||||
// fanins
|
||||
int FaninA = 1;
|
||||
int FaninB = 2;
|
||||
|
|
@ -744,8 +769,8 @@ static inline void Ndr_ModuleTestAdder()
|
|||
Ndr_AddObject( pDesign, ModuleID, ABC_OPER_CO, 0, 0, 0, 0, 1, &FaninCO, 0, NULL, NULL );
|
||||
|
||||
// write Verilog for verification
|
||||
Ndr_WriteVerilog( NULL, pDesign, ppNames );
|
||||
Ndr_Write( "add8.ndr", pDesign );
|
||||
//Ndr_WriteVerilog( NULL, pDesign, ppNames, 0 );
|
||||
Ndr_Write( (char*)"add8.ndr", pDesign );
|
||||
Ndr_Delete( pDesign );
|
||||
|
||||
}
|
||||
|
|
@ -772,6 +797,7 @@ static inline void Ndr_ModuleTestAdder()
|
|||
|
||||
static inline void Ndr_ModuleTestHierarchy()
|
||||
{
|
||||
/*
|
||||
// map name IDs into char strings
|
||||
char * ppNames[20] = { NULL,
|
||||
"mux21w", "mux41w", // 1, 2
|
||||
|
|
@ -781,6 +807,7 @@ static inline void Ndr_ModuleTestHierarchy()
|
|||
"t0", "t1", // 12, 13
|
||||
"i0", "i1", "i2" // 14, 15, 16
|
||||
};
|
||||
*/
|
||||
// fanins
|
||||
int FaninSel = 3;
|
||||
int FaninSel0 = 10;
|
||||
|
|
@ -830,8 +857,8 @@ static inline void Ndr_ModuleTestHierarchy()
|
|||
Ndr_AddObject( pDesign, Module41, ABC_OPER_CO, 0, 3, 0, 0, 1, &FaninOut, 0, NULL, NULL );
|
||||
|
||||
// write Verilog for verification
|
||||
Ndr_WriteVerilog( NULL, pDesign, ppNames );
|
||||
Ndr_Write( "mux41w.ndr", pDesign );
|
||||
//Ndr_WriteVerilog( NULL, pDesign, ppNames, 0 );
|
||||
Ndr_Write( (char*)"mux41w.ndr", pDesign );
|
||||
Ndr_Delete( pDesign );
|
||||
}
|
||||
|
||||
|
|
@ -859,6 +886,7 @@ static inline void Ndr_ModuleTestHierarchy()
|
|||
|
||||
static inline void Ndr_ModuleTestMemory()
|
||||
{
|
||||
/*
|
||||
// map name IDs into char strings
|
||||
char * ppNames[20] = { NULL,
|
||||
"clk", "raddr", "waddr", "data", "mem_init", "out", // 1, 2, 3, 4, 5, 6
|
||||
|
|
@ -868,6 +896,7 @@ static inline void Ndr_ModuleTestMemory()
|
|||
"i_read1", "i_read2", // 15, 16
|
||||
"i_write1", "i_write2", "memtest" // 17, 18, 19
|
||||
};
|
||||
*/
|
||||
// inputs
|
||||
int NameIdClk = 1;
|
||||
int NameIdRaddr = 2;
|
||||
|
|
@ -919,8 +948,8 @@ static inline void Ndr_ModuleTestMemory()
|
|||
Ndr_AddObject( pDesign, ModuleID, ABC_OPER_COMP_NOTEQU, 0, 0, 0, 0, 2, FaninsComp, 1, &NameIdComp, NULL );
|
||||
|
||||
// write Verilog for verification
|
||||
Ndr_WriteVerilog( NULL, pDesign, ppNames );
|
||||
Ndr_Write( "memtest.ndr", pDesign );
|
||||
//Ndr_WriteVerilog( NULL, pDesign, ppNames, 0 );
|
||||
Ndr_Write( (char*)"memtest.ndr", pDesign );
|
||||
Ndr_Delete( pDesign );
|
||||
}
|
||||
|
||||
|
|
@ -934,7 +963,7 @@ static inline void Ndr_ModuleTestMemory()
|
|||
static inline void Ndr_ModuleTestFlop()
|
||||
{
|
||||
// map name IDs into char strings
|
||||
char * ppNames[12] = { NULL, "flop", "data", "clk", "reset", "set", "enable", "async", "sre", "init", "q" };
|
||||
//char * ppNames[12] = { NULL, "flop", "data", "clk", "reset", "set", "enable", "async", "sre", "init", "q" };
|
||||
// name IDs
|
||||
int NameIdData = 2;
|
||||
int NameIdClk = 3;
|
||||
|
|
@ -968,8 +997,8 @@ static inline void Ndr_ModuleTestFlop()
|
|||
Ndr_AddObject( pDesign, ModuleID, ABC_OPER_CO, 0, 3, 0, 0, 1, &NameIdQ, 0, NULL, NULL );
|
||||
|
||||
// write Verilog for verification
|
||||
Ndr_WriteVerilog( NULL, pDesign, ppNames );
|
||||
Ndr_Write( "flop.ndr", pDesign );
|
||||
//Ndr_WriteVerilog( NULL, pDesign, ppNames, 0 );
|
||||
Ndr_Write( (char*)"flop.ndr", pDesign );
|
||||
Ndr_Delete( pDesign );
|
||||
}
|
||||
|
||||
|
|
@ -1022,8 +1051,8 @@ static inline void Ndr_ModuleTestSelSel()
|
|||
Ndr_AddObject( pDesign, ModuleID, ABC_OPER_CO, 0, 2, 0, 0, 1, &NameIdOut,0, NULL, NULL );
|
||||
|
||||
// write Verilog for verification
|
||||
//Ndr_WriteVerilog( NULL, pDesign, ppNames );
|
||||
Ndr_Write( "sel.ndr", pDesign );
|
||||
//Ndr_WriteVerilog( NULL, pDesign, ppNames, 0 );
|
||||
Ndr_Write( (char*)"sel.ndr", pDesign );
|
||||
Ndr_Delete( pDesign );
|
||||
}
|
||||
|
||||
|
|
@ -1056,7 +1085,7 @@ static inline void Ndr_ModuleTestDec()
|
|||
Ndr_AddObject( pDesign, ModuleID, ABC_OPER_SEL_DEC, 0, 3, 0, 0, 1, &NameIdIn, 1, &NameIdOut, NULL );
|
||||
Ndr_AddObject( pDesign, ModuleID, ABC_OPER_CO, 0, 3, 0, 0, 1, &NameIdOut, 0, NULL, NULL );
|
||||
|
||||
Ndr_Write( "dec.ndr", pDesign );
|
||||
Ndr_Write( (char*)"dec.ndr", pDesign );
|
||||
Ndr_Delete( pDesign );
|
||||
}
|
||||
|
||||
|
|
@ -1092,7 +1121,7 @@ static inline void Ndr_ModuleTestAddSub()
|
|||
Ndr_AddObject( pDesign, ModuleID, ABC_OPER_ARI_ADDSUB, 0, 3, 0, 0, 4, Fanins, 1, &NameIdOut, NULL );
|
||||
Ndr_AddObject( pDesign, ModuleID, ABC_OPER_CO, 0, 3, 0, 0, 1, &NameIdOut, 0, NULL, NULL );
|
||||
|
||||
Ndr_Write( "addsub.ndr", pDesign );
|
||||
Ndr_Write( (char*)"addsub.ndr", pDesign );
|
||||
Ndr_Delete( pDesign );
|
||||
}
|
||||
|
||||
|
|
@ -1116,16 +1145,20 @@ static inline void Ndr_ModuleTestLut()
|
|||
|
||||
int ModuleID = Ndr_AddModule( pDesign, 1 );
|
||||
|
||||
unsigned pTruth[2] = { 0x88888888, 0x88888888 };
|
||||
|
||||
// add objects to the modele
|
||||
Ndr_AddObject( pDesign, ModuleID, ABC_OPER_CI, 0, 1, 0, 0, 0, NULL, 1, &NameIdIn, NULL );
|
||||
Ndr_AddObject( pDesign, ModuleID, ABC_OPER_LUT, 0, 0, 0, 0, 1, &NameIdIn, 1, &NameIdOut, (char *)(ABC_CONST(0x8)) );
|
||||
Ndr_AddObject( pDesign, ModuleID, ABC_OPER_LUT, 0, 0, 0, 0, 1, &NameIdIn, 1, &NameIdOut, (char *)pTruth );
|
||||
Ndr_AddObject( pDesign, ModuleID, ABC_OPER_CO, 0, 0, 0, 0, 1, &NameIdOut, 0, NULL, NULL );
|
||||
|
||||
Ndr_Write( "lut_test.ndr", pDesign );
|
||||
Ndr_Write( (char*)"lut_test.ndr", pDesign );
|
||||
Ndr_Delete( pDesign );
|
||||
}
|
||||
|
||||
#ifndef _YOSYS_
|
||||
ABC_NAMESPACE_HEADER_END
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -300,8 +300,8 @@ Aig_Man_t * Saig_ManDupUnfoldConstrs( Aig_Man_t * pAig )
|
|||
Vec_VecFree( (Vec_Vec_t *)vConsAll );
|
||||
return Aig_ManDupDfs( pAig );
|
||||
}
|
||||
Vec_PtrSort( vOuts, (int (*)(void))Saig_ManDupCompare );
|
||||
Vec_PtrSort( vCons, (int (*)(void))Saig_ManDupCompare );
|
||||
Vec_PtrSort( vOuts, (int (*)(const void *, const void *))Saig_ManDupCompare );
|
||||
Vec_PtrSort( vCons, (int (*)(const void *, const void *))Saig_ManDupCompare );
|
||||
Vec_PtrPush( vOutsAll, vOuts );
|
||||
Vec_PtrPush( vConsAll, vCons );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ Vec_Int_t * Saig_ManFindIsoPermCos( Aig_Man_t * pAig, Vec_Int_t * vPermCis )
|
|||
pObj->iData = Abc_Var2Lit( pFanin->iData, Aig_ObjFaninC0(pObj) );
|
||||
Vec_PtrPush( vRoots, pObj );
|
||||
}
|
||||
Vec_PtrSort( vRoots, (int (*)(void))Iso_ObjCompareByData );
|
||||
Vec_PtrSort( vRoots, (int (*)(const void *, const void *))Iso_ObjCompareByData );
|
||||
Vec_PtrForEachEntry( Aig_Obj_t *, vRoots, pObj, i )
|
||||
Vec_IntPush( vPermCos, Aig_ObjCioId(pObj) );
|
||||
Vec_PtrFree( vRoots );
|
||||
|
|
@ -467,7 +467,7 @@ Aig_Man_t * Iso_ManFilterPos( Aig_Man_t * pAig, Vec_Ptr_t ** pvPosEquivs, int fV
|
|||
|
||||
// sort the infos
|
||||
clk = Abc_Clock();
|
||||
Vec_PtrSort( vBuffers, (int (*)(void))Iso_StoCompareVecStr );
|
||||
Vec_PtrSort( vBuffers, (int (*)(const void *, const void *))Iso_StoCompareVecStr );
|
||||
|
||||
// create classes
|
||||
clk = Abc_Clock();
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ Vec_Vec_t * Saig_IsoDetectFast( Aig_Man_t * pAig )
|
|||
|
||||
// sort the infos
|
||||
clk = Abc_Clock();
|
||||
Vec_PtrSort( vInfos, (int (*)(void))Iso_StoCompareVecInt );
|
||||
Vec_PtrSort( vInfos, (int (*)(const void *, const void *))Iso_StoCompareVecInt );
|
||||
|
||||
// create classes
|
||||
clk = Abc_Clock();
|
||||
|
|
|
|||
|
|
@ -572,8 +572,8 @@ void Iso_ManCollectClasses( Iso_Man_t * p )
|
|||
}
|
||||
}
|
||||
clk = Abc_Clock();
|
||||
Vec_PtrSort( p->vSingles, (int (*)(void))Iso_ObjCompare );
|
||||
Vec_PtrSort( p->vClasses, (int (*)(void))Iso_ObjCompare );
|
||||
Vec_PtrSort( p->vSingles, (int (*)(const void *, const void *))Iso_ObjCompare );
|
||||
Vec_PtrSort( p->vClasses, (int (*)(const void *, const void *))Iso_ObjCompare );
|
||||
p->timeSort += Abc_Clock() - clk;
|
||||
assert( Vec_PtrSize(p->vSingles) == p->nSingles );
|
||||
assert( Vec_PtrSize(p->vClasses) == p->nClasses );
|
||||
|
|
@ -1115,8 +1115,8 @@ Vec_Int_t * Iso_ManFinalize( Iso_Man_t * p )
|
|||
Vec_PtrPush( p->vTemp1, pObj );
|
||||
}
|
||||
// sort CIs by their IDs
|
||||
Vec_PtrSort( p->vTemp1, (int (*)(void))Iso_ObjCompareByData );
|
||||
Vec_PtrSort( p->vTemp2, (int (*)(void))Iso_ObjCompareByData );
|
||||
Vec_PtrSort( p->vTemp1, (int (*)(const void *, const void *))Iso_ObjCompareByData );
|
||||
Vec_PtrSort( p->vTemp2, (int (*)(const void *, const void *))Iso_ObjCompareByData );
|
||||
// create the result
|
||||
vRes = Vec_IntAlloc( Aig_ManCiNum(p->pAig) );
|
||||
Vec_PtrForEachEntry( Aig_Obj_t *, p->vTemp1, pObj, i )
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ Vec_Ptr_t * Saig_ManWindowOutline( Aig_Man_t * p, Aig_Obj_t * pObj, int nDist )
|
|||
vNodes = Vec_PtrAlloc( 1000 );
|
||||
Aig_ManIncrementTravId( p );
|
||||
Saig_ManWindowOutline_rec( p, pObj, nDist, vNodes, pDists );
|
||||
Vec_PtrSort( vNodes, (int (*)(void))Aig_ObjCompareIdIncrease );
|
||||
Vec_PtrSort( vNodes, (int (*)(const void *, const void *))Aig_ObjCompareIdIncrease );
|
||||
// make sure LI/LO are labeled/unlabeled mutually
|
||||
Saig_ManForEachLiLo( p, pObjLi, pObjLo, i )
|
||||
assert( Aig_ObjIsTravIdCurrent(p, pObjLi) ==
|
||||
|
|
|
|||
|
|
@ -600,7 +600,7 @@ extern ABC_DLL int Abc_NtkCheckUniqueCiNames( Abc_Ntk_t * pNtk );
|
|||
extern ABC_DLL int Abc_NtkCheckUniqueCoNames( Abc_Ntk_t * pNtk );
|
||||
extern ABC_DLL int Abc_NtkCheckUniqueCioNames( Abc_Ntk_t * pNtk );
|
||||
/*=== abcCollapse.c ==========================================================*/
|
||||
extern ABC_DLL Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fReverse, int fVerbose );
|
||||
extern ABC_DLL Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fReverse, int fDumpOrder, int fVerbose );
|
||||
extern ABC_DLL Abc_Ntk_t * Abc_NtkCollapseSat( Abc_Ntk_t * pNtk, int nCubeLim, int nBTLimit, int nCostMax, int fCanon, int fReverse, int fCnfShared, int fVerbose );
|
||||
extern ABC_DLL Gia_Man_t * Abc_NtkClpGia( Abc_Ntk_t * pNtk );
|
||||
/*=== abcCut.c ==========================================================*/
|
||||
|
|
@ -671,7 +671,7 @@ extern ABC_DLL Abc_Ntk_t * Abc_NtkFraigRestore( int nPatsRand, int nPatsD
|
|||
extern ABC_DLL void Abc_NtkFraigStoreClean();
|
||||
/*=== abcFunc.c ==========================================================*/
|
||||
extern ABC_DLL int Abc_NtkSopToBdd( Abc_Ntk_t * pNtk );
|
||||
extern ABC_DLL int Abc_NtkBddToSop( Abc_Ntk_t * pNtk, int fMode, int nCubeLimit );
|
||||
extern ABC_DLL int Abc_NtkBddToSop( Abc_Ntk_t * pNtk, int fMode, int nCubeLimit, int fCubeSort );
|
||||
extern ABC_DLL void Abc_NodeBddToCnf( Abc_Obj_t * pNode, Mem_Flex_t * pMmMan, Vec_Str_t * vCube, int fAllPrimes, char ** ppSop0, char ** ppSop1 );
|
||||
extern ABC_DLL void Abc_NtkLogicMakeDirectSops( Abc_Ntk_t * pNtk );
|
||||
extern ABC_DLL int Abc_NtkSopToAig( Abc_Ntk_t * pNtk );
|
||||
|
|
@ -752,6 +752,7 @@ extern ABC_DLL void Abc_NtkAddDummyPiNames( Abc_Ntk_t * pNtk );
|
|||
extern ABC_DLL void Abc_NtkAddDummyPoNames( Abc_Ntk_t * pNtk );
|
||||
extern ABC_DLL void Abc_NtkAddDummyBoxNames( Abc_Ntk_t * pNtk );
|
||||
extern ABC_DLL void Abc_NtkShortNames( Abc_Ntk_t * pNtk );
|
||||
extern ABC_DLL void Abc_NtkCleanNames( Abc_Ntk_t * pNtk );
|
||||
extern ABC_DLL void Abc_NtkStartNameIds( Abc_Ntk_t * p );
|
||||
extern ABC_DLL void Abc_NtkTransferNameIds( Abc_Ntk_t * p, Abc_Ntk_t * pNew );
|
||||
extern ABC_DLL void Abc_NtkUpdateNameIds( Abc_Ntk_t * p );
|
||||
|
|
@ -761,7 +762,7 @@ extern ABC_DLL Abc_Ntk_t * Abc_NtkToNetlist( Abc_Ntk_t * pNtk );
|
|||
extern ABC_DLL Abc_Ntk_t * Abc_NtkToNetlistBench( Abc_Ntk_t * pNtk );
|
||||
/*=== abcNtbdd.c ==========================================================*/
|
||||
extern ABC_DLL Abc_Ntk_t * Abc_NtkDeriveFromBdd( void * dd, void * bFunc, char * pNamePo, Vec_Ptr_t * vNamesPi );
|
||||
extern ABC_DLL Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk, int fGlobal, int Limit );
|
||||
extern ABC_DLL Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk, int fGlobal, int Limit, int fUseAdd );
|
||||
extern ABC_DLL void * Abc_NtkBuildGlobalBdds( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDropInternal, int fReorder, int fReverse, int fVerbose );
|
||||
extern ABC_DLL void * Abc_NtkFreeGlobalBdds( Abc_Ntk_t * pNtk, int fFreeMan );
|
||||
extern ABC_DLL int Abc_NtkSizeOfGlobalBdds( Abc_Ntk_t * pNtk );
|
||||
|
|
|
|||
|
|
@ -865,7 +865,7 @@ int Abc_NtkCheckUniqueCiNames( Abc_Ntk_t * pNtk )
|
|||
vNames = Vec_PtrAlloc( Abc_NtkCiNum(pNtk) );
|
||||
Abc_NtkForEachCi( pNtk, pObj, i )
|
||||
Vec_PtrPush( vNames, Abc_ObjName(pObj) );
|
||||
Vec_PtrSort( vNames, (int (*)())Abc_NtkNamesCompare );
|
||||
Vec_PtrSort( vNames, (int (*)(const void *, const void *))Abc_NtkNamesCompare );
|
||||
for ( i = 1; i < Abc_NtkCiNum(pNtk); i++ )
|
||||
if ( !strcmp( (const char *)Vec_PtrEntry(vNames,i-1), (const char *)Vec_PtrEntry(vNames,i) ) )
|
||||
{
|
||||
|
|
@ -896,7 +896,7 @@ int Abc_NtkCheckUniqueCoNames( Abc_Ntk_t * pNtk )
|
|||
vNames = Vec_PtrAlloc( Abc_NtkCoNum(pNtk) );
|
||||
Abc_NtkForEachCo( pNtk, pObj, i )
|
||||
Vec_PtrPush( vNames, Abc_ObjName(pObj) );
|
||||
Vec_PtrSort( vNames, (int (*)())Abc_NtkNamesCompare );
|
||||
Vec_PtrSort( vNames, (int (*)(const void *, const void *))Abc_NtkNamesCompare );
|
||||
for ( i = 1; i < Abc_NtkCoNum(pNtk); i++ )
|
||||
{
|
||||
// printf( "%s\n", Vec_PtrEntry(vNames,i) );
|
||||
|
|
|
|||
|
|
@ -897,9 +897,9 @@ Vec_Ptr_t * Abc_NtkNodeSupport( Abc_Ntk_t * pNtk, Abc_Obj_t ** ppNodes, int nNod
|
|||
vNodes = Vec_PtrAlloc( 100 );
|
||||
// go through the PO nodes and call for each of them
|
||||
for ( i = 0; i < nNodes; i++ )
|
||||
if ( Abc_ObjIsCo(ppNodes[i]) )
|
||||
if ( Abc_ObjIsCo(ppNodes[i]) && Abc_ObjFaninNum(Abc_ObjFanin0(ppNodes[i])) != 0 )
|
||||
Abc_NtkNodeSupport_rec( Abc_ObjFanin0(ppNodes[i]), vNodes );
|
||||
else
|
||||
else if ( !Abc_ObjIsCo(ppNodes[i]) && Abc_ObjFaninNum(ppNodes[i]) != 0 )
|
||||
Abc_NtkNodeSupport_rec( ppNodes[i], vNodes );
|
||||
return vNodes;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -476,9 +476,9 @@ void Abc_NodeSortCubes( Abc_Obj_t * pNode, Vec_Ptr_t * vCubes, Vec_Str_t * vStor
|
|||
Vec_PtrPush( vCubes, pCube );
|
||||
}
|
||||
if ( fWeight )
|
||||
Vec_PtrSort( vCubes, (int (*)())Abc_NodeCompareCubes2 );
|
||||
Vec_PtrSort( vCubes, (int (*)(const void *, const void *))Abc_NodeCompareCubes2 );
|
||||
else
|
||||
Vec_PtrSort( vCubes, (int (*)())Abc_NodeCompareCubes1 );
|
||||
Vec_PtrSort( vCubes, (int (*)(const void *, const void *))Abc_NodeCompareCubes1 );
|
||||
Vec_StrGrow( vStore, Vec_PtrSize(vCubes) * (nVars + 3) );
|
||||
pPivot = Vec_StrArray( vStore );
|
||||
Vec_PtrForEachEntry( char *, vCubes, pCube, i )
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ char * Abc_ConvertBddToSop( Mem_Flex_t * pMan, DdManager * dd, DdNode * bFuncOn,
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Abc_NtkBddToSop( Abc_Ntk_t * pNtk, int fMode, int nCubeLimit )
|
||||
int Abc_NtkBddToSop( Abc_Ntk_t * pNtk, int fMode, int nCubeLimit, int fCubeSort )
|
||||
{
|
||||
Vec_Int_t * vGuide;
|
||||
Vec_Str_t * vCube;
|
||||
|
|
@ -445,6 +445,7 @@ int Abc_NtkBddToSop( Abc_Ntk_t * pNtk, int fMode, int nCubeLimit )
|
|||
Extra_StopManager( dd );
|
||||
|
||||
// reorder fanins and cubes to make SOPs more human-readable
|
||||
if ( fCubeSort )
|
||||
Abc_NtkSortSops( pNtk );
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -788,7 +789,7 @@ DdNode * Abc_ConvertAigToBdd( DdManager * dd, Hop_Obj_t * pRoot )
|
|||
#else
|
||||
|
||||
int Abc_NtkSopToBdd( Abc_Ntk_t * pNtk ) { return 1; }
|
||||
int Abc_NtkBddToSop( Abc_Ntk_t * pNtk, int fMode, int nCubeLimit ) { return 1; }
|
||||
int Abc_NtkBddToSop( Abc_Ntk_t * pNtk, int fMode, int nCubeLimit, int fCubeSort ) { return 1; }
|
||||
void Abc_NodeBddToCnf( Abc_Obj_t * pNode, Mem_Flex_t * pMmMan, Vec_Str_t * vCube, int fAllPrimes, char ** ppSop0, char ** ppSop1 ) {}
|
||||
void Abc_NtkLogicMakeDirectSops( Abc_Ntk_t * pNtk ) {}
|
||||
int Abc_NtkAigToBdd( Abc_Ntk_t * pNtk ) { return 1; }
|
||||
|
|
@ -1178,17 +1179,17 @@ int Abc_NtkToSop( Abc_Ntk_t * pNtk, int fMode, int nCubeLimit )
|
|||
return 1;
|
||||
if ( !Abc_NtkSopToBdd(pNtk) )
|
||||
return 0;
|
||||
return Abc_NtkBddToSop(pNtk, fMode, nCubeLimit);
|
||||
return Abc_NtkBddToSop(pNtk, fMode, nCubeLimit, 1);
|
||||
}
|
||||
if ( Abc_NtkHasMapping(pNtk) )
|
||||
return Abc_NtkMapToSop(pNtk);
|
||||
if ( Abc_NtkHasBdd(pNtk) )
|
||||
return Abc_NtkBddToSop(pNtk, fMode, nCubeLimit);
|
||||
return Abc_NtkBddToSop(pNtk, fMode, nCubeLimit, 1);
|
||||
if ( Abc_NtkHasAig(pNtk) )
|
||||
{
|
||||
if ( !Abc_NtkAigToBdd(pNtk) )
|
||||
return 0;
|
||||
return Abc_NtkBddToSop(pNtk, fMode, nCubeLimit);
|
||||
return Abc_NtkBddToSop(pNtk, fMode, nCubeLimit, 1);
|
||||
}
|
||||
assert( 0 );
|
||||
return 0;
|
||||
|
|
@ -1253,7 +1254,7 @@ int Abc_NtkToAig( Abc_Ntk_t * pNtk )
|
|||
}
|
||||
if ( Abc_NtkHasBdd(pNtk) )
|
||||
{
|
||||
if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY) )
|
||||
if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY, 1) )
|
||||
return 0;
|
||||
return Abc_NtkSopToAig(pNtk);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -442,7 +442,7 @@ void Abc_NtkPrintBoxInfo( Abc_Ntk_t * pNtk )
|
|||
}
|
||||
// sort models by name
|
||||
vMods = pNtk->pDesign->vModules;
|
||||
Vec_PtrSort( vMods, (int(*)())Abc_NtkCompareNames );
|
||||
Vec_PtrSort( vMods, (int(*)(const void *, const void *))Abc_NtkCompareNames );
|
||||
// Vec_PtrForEachEntry( Abc_Ntk_t *, vMods, pModel, i )
|
||||
// printf( "%s\n", Abc_NtkName(pModel) );
|
||||
|
||||
|
|
|
|||
|
|
@ -558,7 +558,7 @@ void Au_ManPrintBoxInfo( Au_Ntk_t * pNtk )
|
|||
vMods->nSize--;
|
||||
vMods->pArray++;
|
||||
// sort models by name
|
||||
Vec_PtrSort( vMods, (int(*)())Au_NtkCompareNames );
|
||||
Vec_PtrSort( vMods, (int(*)(const void *, const void *))Au_NtkCompareNames );
|
||||
// swap the first model
|
||||
Num = Vec_PtrFind( vMods, pNtk );
|
||||
assert( Num >= 0 && Num < Vec_PtrSize(vMods) );
|
||||
|
|
@ -643,7 +643,7 @@ void Au_ManPrintBoxInfoSorted( Au_Ntk_t * pNtk )
|
|||
vMods->pArray--;
|
||||
vMods->nSize++;
|
||||
|
||||
Vec_PtrSort( vModsNew, (int(*)())Au_NtkCompareSign );
|
||||
Vec_PtrSort( vModsNew, (int(*)(const void *, const void *))Au_NtkCompareSign );
|
||||
Vec_PtrForEachEntryStart( Au_Ntk_t *, vModsNew, pModel, i, 1 )
|
||||
{
|
||||
printf( "MODULE " );
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ int Abc_NtkRemoveSelfFeedLatches( Abc_Ntk_t * pNtk )
|
|||
void Abc_NtkLatchPipe( Abc_Ntk_t * pNtk, int nLatches )
|
||||
{
|
||||
Vec_Ptr_t * vNodes;
|
||||
Abc_Obj_t * pObj, * pLatch, * pFanin, * pFanout;
|
||||
Abc_Obj_t * pObj, * pFanin, * pFanout;
|
||||
int i, k, nTotal, nDigits;
|
||||
if ( nLatches < 1 )
|
||||
return;
|
||||
|
|
@ -157,18 +157,9 @@ void Abc_NtkLatchPipe( Abc_Ntk_t * pNtk, int nLatches )
|
|||
vNodes = Vec_PtrAlloc( 100 );
|
||||
Abc_NtkForEachPi( pNtk, pObj, i )
|
||||
{
|
||||
// remember current fanins of the PI
|
||||
Abc_NodeCollectFanouts( pObj, vNodes );
|
||||
// create the latches
|
||||
for ( pFanin = pObj, k = 0; k < nLatches; k++, pFanin = pLatch )
|
||||
{
|
||||
pLatch = Abc_NtkCreateLatch( pNtk );
|
||||
Abc_ObjAddFanin( pLatch, pFanin );
|
||||
Abc_LatchSetInitDc( pLatch );
|
||||
// create the name of the new latch
|
||||
Abc_ObjAssignName( pLatch, Abc_ObjNameDummy("LL", i*nLatches + k, nDigits), NULL );
|
||||
}
|
||||
// patch the PI fanouts
|
||||
for ( pFanin = pObj, k = 0; k < nLatches; k++ )
|
||||
pFanin = Abc_NtkAddLatch( pNtk, pFanin, ABC_INIT_ZERO );
|
||||
Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pFanout, k )
|
||||
Abc_ObjPatchFanin( pFanout, pObj, pFanin );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ int Abc_NtkMinimumBase( Abc_Ntk_t * pNtk )
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Abc_NodeMinimumBase( Abc_Obj_t * pNode )
|
||||
int Abc_NodeMinimumBase_buggy( Abc_Obj_t * pNode )
|
||||
{
|
||||
Vec_Str_t * vSupport;
|
||||
Vec_Ptr_t * vFanins;
|
||||
|
|
@ -107,6 +107,55 @@ int Abc_NodeMinimumBase( Abc_Obj_t * pNode )
|
|||
return 1;
|
||||
}
|
||||
|
||||
int Abc_NodeMinimumBase( Abc_Obj_t * pNode )
|
||||
{
|
||||
DdManager * dd = (DdManager *)pNode->pNtk->pManFunc;
|
||||
DdNode * bTemp, ** pbVars;
|
||||
Vec_Str_t * vSupport;
|
||||
int i, nVars, j, iFanin, iFanin2, k = 0;
|
||||
|
||||
assert( Abc_NtkIsBddLogic(pNode->pNtk) );
|
||||
assert( Abc_ObjIsNode(pNode) );
|
||||
|
||||
// compute support
|
||||
vSupport = Vec_StrAlloc( 10 );
|
||||
nVars = Abc_NodeSupport( Cudd_Regular(pNode->pData), vSupport, Abc_ObjFaninNum(pNode) );
|
||||
if ( nVars == Abc_ObjFaninNum(pNode) )
|
||||
{
|
||||
Vec_StrFree( vSupport );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// remove unused fanins
|
||||
pbVars = ABC_CALLOC( DdNode *, Abc_ObjFaninNum(pNode) );
|
||||
Vec_IntForEachEntry( &pNode->vFanins, iFanin, i )
|
||||
{
|
||||
Abc_Obj_t * pFanin = Abc_NtkObj( pNode->pNtk, iFanin );
|
||||
if ( !Vec_StrEntry(vSupport, i) )
|
||||
{
|
||||
if ( !Vec_IntRemove( &pFanin->vFanouts, pNode->Id ) )
|
||||
printf( "The obj %d is not found among the fanouts of obj %d ...\n", pNode->Id, iFanin );
|
||||
continue;
|
||||
}
|
||||
Vec_IntForEachEntryStop( &pNode->vFanins, iFanin2, j, k )
|
||||
if ( iFanin == iFanin2 )
|
||||
break;
|
||||
if ( j == k )
|
||||
Vec_IntWriteEntry( &pNode->vFanins, k++, iFanin );
|
||||
else if ( !Vec_IntRemove( &pFanin->vFanouts, pNode->Id ) )
|
||||
printf( "The obj %d is not found among the fanouts of obj %d ...\n", pNode->Id, iFanin );
|
||||
pbVars[i] = Cudd_bddIthVar( dd, j );
|
||||
}
|
||||
Vec_IntShrink( &pNode->vFanins, k );
|
||||
|
||||
// update the function of the node
|
||||
pNode->pData = Cudd_bddVectorCompose( dd, bTemp = (DdNode *)pNode->pData, pbVars ); Cudd_Ref( (DdNode *)pNode->pData );
|
||||
Cudd_RecursiveDeref( dd, bTemp );
|
||||
Vec_StrFree( vSupport );
|
||||
ABC_FREE( pbVars );
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Makes nodes of the network fanin-dup-free.]
|
||||
|
|
@ -447,7 +496,7 @@ int Abc_NtkEliminate( Abc_Ntk_t * pNtk, int nMaxSize, int fReverse, int fVerbose
|
|||
return 0;
|
||||
}
|
||||
// prepare nodes for sweeping
|
||||
Abc_NtkRemoveDupFanins( pNtk );
|
||||
//Abc_NtkRemoveDupFanins( pNtk );
|
||||
Abc_NtkMinimumBase( pNtk );
|
||||
Abc_NtkCleanup( pNtk, 0 );
|
||||
// get the nodes in the given order
|
||||
|
|
@ -703,7 +752,7 @@ void Abc_ObjSortInReverseOrder( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes )
|
|||
vOrder = Abc_NtkDfsReverse( pNtk );
|
||||
Vec_PtrForEachEntry( Abc_Obj_t *, vOrder, pNode, i )
|
||||
pNode->iTemp = i;
|
||||
Vec_PtrSort( vNodes, (int (*)())Abc_ObjCompareByNumber );
|
||||
Vec_PtrSort( vNodes, (int (*)(const void *, const void *))Abc_ObjCompareByNumber );
|
||||
Vec_PtrForEachEntry( Abc_Obj_t *, vOrder, pNode, i )
|
||||
pNode->iTemp = 0;
|
||||
Vec_PtrFree( vOrder );
|
||||
|
|
@ -740,7 +789,7 @@ int Abc_NtkEliminateSpecial( Abc_Ntk_t * pNtk, int nMaxSize, int fVerbose )
|
|||
}
|
||||
|
||||
// prepare nodes for sweeping
|
||||
Abc_NtkRemoveDupFanins( pNtk );
|
||||
//Abc_NtkRemoveDupFanins( pNtk );
|
||||
Abc_NtkMinimumBase( pNtk );
|
||||
Abc_NtkCleanup( pNtk, 0 );
|
||||
|
||||
|
|
|
|||
|
|
@ -606,6 +606,17 @@ void Abc_NtkShortNames( Abc_Ntk_t * pNtk )
|
|||
Abc_NtkAddDummyPoNames( pNtk );
|
||||
Abc_NtkAddDummyBoxNames( pNtk );
|
||||
}
|
||||
void Abc_NtkCleanNames( Abc_Ntk_t * pNtk )
|
||||
{
|
||||
Abc_Obj_t * pObj; int i;
|
||||
Nm_Man_t * pManName = Nm_ManCreate( Abc_NtkCiNum(pNtk) + Abc_NtkCoNum(pNtk) + Abc_NtkBoxNum(pNtk) );
|
||||
Abc_NtkForEachCi( pNtk, pObj, i )
|
||||
Nm_ManStoreIdName( pManName, pObj->Id, pObj->Type, Abc_ObjName(pObj), NULL );
|
||||
Abc_NtkForEachCo( pNtk, pObj, i )
|
||||
Nm_ManStoreIdName( pManName, pObj->Id, pObj->Type, Abc_ObjName(pObj), NULL );
|
||||
Nm_ManFree( pNtk->pManName );
|
||||
pNtk->pManName = pManName;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
|
|
|
|||
|
|
@ -1286,6 +1286,7 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk )
|
|||
Abc_Obj_t * pObj;
|
||||
void * pAttrMan;
|
||||
int TotalMemory, i;
|
||||
int fWarning = 0;
|
||||
// int LargePiece = (4 << ABC_NUM_STEPS);
|
||||
if ( pNtk == NULL )
|
||||
return;
|
||||
|
|
@ -1310,9 +1311,11 @@ void Abc_NtkDelete( Abc_Ntk_t * pNtk )
|
|||
// ABC_FREE( pObj->vFanouts.pArray );
|
||||
// these flags should be always zero
|
||||
// if this is not true, something is wrong somewhere
|
||||
assert( pObj->fMarkA == 0 );
|
||||
assert( pObj->fMarkB == 0 );
|
||||
assert( pObj->fMarkC == 0 );
|
||||
// assert( pObj->fMarkA == 0 );
|
||||
// assert( pObj->fMarkB == 0 );
|
||||
// assert( pObj->fMarkC == 0 );
|
||||
if ( !fWarning && (pObj->fMarkA || pObj->fMarkB || pObj->fMarkC) )
|
||||
{ printf( "Flags A, B, or C are not zero.\n" ), fWarning = 1; }
|
||||
}
|
||||
// free the nodes
|
||||
if ( pNtk->pMmStep == NULL )
|
||||
|
|
|
|||
|
|
@ -393,6 +393,7 @@ Abc_Obj_t * Abc_NtkDupObj( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pObj, int fCopyName
|
|||
}
|
||||
else if ( Abc_ObjIsLatch(pObj) ) // copy the reset value
|
||||
pObjNew->pData = pObj->pData;
|
||||
pObjNew->fPersist = pObj->fPersist;
|
||||
// transfer HAIG
|
||||
// pObjNew->pEquiv = pObj->pEquiv;
|
||||
// remember the new node in the old node
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ void Abc_NodeShowBdd( Abc_Obj_t * pNode, int fCompl )
|
|||
// visualize the file
|
||||
Abc_ShowFile( FileNameDot );
|
||||
}
|
||||
void Abc_NtkShowBdd( Abc_Ntk_t * pNtk, int fCompl )
|
||||
void Abc_NtkShowBdd( Abc_Ntk_t * pNtk, int fCompl, int fReorder )
|
||||
{
|
||||
char FileNameDot[200];
|
||||
char ** ppNamesIn, ** ppNamesOut;
|
||||
|
|
@ -131,7 +131,7 @@ void Abc_NtkShowBdd( Abc_Ntk_t * pNtk, int fCompl )
|
|||
FILE * pFile;
|
||||
|
||||
assert( Abc_NtkIsStrash(pNtk) );
|
||||
dd = (DdManager *)Abc_NtkBuildGlobalBdds( pNtk, 10000000, 1, 1, 0, 0 );
|
||||
dd = (DdManager *)Abc_NtkBuildGlobalBdds( pNtk, 10000000, 1, fReorder, 0, 0 );
|
||||
if ( dd == NULL )
|
||||
{
|
||||
printf( "Construction of global BDDs has failed.\n" );
|
||||
|
|
@ -186,7 +186,7 @@ void Abc_NtkShowBdd( Abc_Ntk_t * pNtk, int fCompl )
|
|||
|
||||
#else
|
||||
void Abc_NodeShowBdd( Abc_Obj_t * pNode, int fCompl ) {}
|
||||
void Abc_NtkShowBdd( Abc_Ntk_t * pNtk, int fCompl ) {}
|
||||
void Abc_NtkShowBdd( Abc_Ntk_t * pNtk, int fCompl, int fReorder ) {}
|
||||
#endif
|
||||
|
||||
/**Function*************************************************************
|
||||
|
|
|
|||
|
|
@ -3122,7 +3122,10 @@ Vec_Wec_t * Abc_SopSynthesize( Vec_Ptr_t * vSops )
|
|||
Abc_Obj_t * pObj, * pFanin;
|
||||
int i, k, iNode = 0;
|
||||
Abc_FrameReplaceCurrentNetwork( Abc_FrameReadGlobalFrame(), pNtk );
|
||||
Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "fx; strash; balance; dc2; map -a" );
|
||||
//Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "fx; strash; balance; dc2; map -a" );
|
||||
Abc_FrameSetBatchMode( 1 );
|
||||
Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "st; collapse; sop; fx; strash; &get; &ps; &deepsyn -I 4 -J 50 -T 5 -S 111 -t; &ps; &put; map -a" );
|
||||
Abc_FrameSetBatchMode( 0 );
|
||||
pNtkNew = Abc_FrameReadNtk( Abc_FrameReadGlobalFrame() );
|
||||
vRes = Vec_WecStart( Abc_NtkPiNum(pNtkNew) + Abc_NtkNodeNum(pNtkNew) + Abc_NtkPoNum(pNtkNew) );
|
||||
Abc_NtkForEachPi( pNtkNew, pObj, i )
|
||||
|
|
@ -3149,7 +3152,9 @@ Vec_Wec_t * Abc_GiaSynthesize( Vec_Ptr_t * vGias, Gia_Man_t * pMulti )
|
|||
Abc_Obj_t * pObj, * pFanin;
|
||||
int i, k, iNode = 0;
|
||||
Abc_FrameReplaceCurrentNetwork( Abc_FrameReadGlobalFrame(), pNtk );
|
||||
Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "compress2rs; dch; map -a; strash; compress2rs; dch; map -a; strash; compress2rs; dch; map -a" );
|
||||
Abc_FrameSetBatchMode( 1 );
|
||||
Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "clp; sop; fx; strash; compress2rs; dch; map -a; strash; compress2rs; dch; map -a" );
|
||||
Abc_FrameSetBatchMode( 0 );
|
||||
pNtkNew = Abc_FrameReadNtk( Abc_FrameReadGlobalFrame() );
|
||||
vRes = Vec_WecStart( Abc_NtkPiNum(pNtkNew) + Abc_NtkNodeNum(pNtkNew) + Abc_NtkPoNum(pNtkNew) );
|
||||
Abc_NtkForEachPi( pNtkNew, pObj, i )
|
||||
|
|
@ -3253,9 +3258,11 @@ Gia_Man_t * Abc_SopSynthesizeOne( char * pSop, int fClp )
|
|||
pNtk = Abc_NtkCreateFromSops( "top", vSops );
|
||||
Vec_PtrFree( vSops );
|
||||
Abc_FrameReplaceCurrentNetwork( Abc_FrameReadGlobalFrame(), pNtk );
|
||||
Abc_FrameSetBatchMode( 1 );
|
||||
if ( fClp )
|
||||
Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "clp; sop" );
|
||||
Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "fx; strash; balance; dc2" );
|
||||
Abc_FrameSetBatchMode( 0 );
|
||||
pNtkNew = Abc_FrameReadNtk( Abc_FrameReadGlobalFrame() );
|
||||
return Abc_NtkStrashToGia( pNtkNew );
|
||||
}
|
||||
|
|
|
|||
2113
src/base/abci/abc.c
2113
src/base/abci/abc.c
File diff suppressed because it is too large
Load Diff
|
|
@ -266,7 +266,7 @@ Abc_Obj_t * Abc_NodeBalance_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNodeOld, Vec_
|
|||
if ( vSuper->nSize < 2 )
|
||||
printf( "BUG!\n" );
|
||||
// sort the new nodes by level in the decreasing order
|
||||
Vec_PtrSort( vSuper, (int (*)(void))Abc_NodeCompareLevelsDecrease );
|
||||
Vec_PtrSort( vSuper, (int (*)(const void *, const void *))Abc_NodeCompareLevelsDecrease );
|
||||
// balance the nodes
|
||||
assert( vSuper->nSize > 1 );
|
||||
while ( vSuper->nSize > 1 )
|
||||
|
|
|
|||
|
|
@ -195,7 +195,16 @@ Abc_Ntk_t * Abc_NtkFromGlobalBdds( Abc_Ntk_t * pNtk, int fReverse )
|
|||
Extra_ProgressBarStop( pProgress );
|
||||
return pNtkNew;
|
||||
}
|
||||
Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fReverse, int fVerbose )
|
||||
void Abc_NtkDumpVariableOrder( Abc_Ntk_t * pNtk )
|
||||
{
|
||||
DdManager * dd = (DdManager *)Abc_NtkGlobalBddMan( pNtk );
|
||||
FILE * pFile = fopen( "order.txt", "wb" ); int i;
|
||||
for ( i = 0; i < dd->size; i++ )
|
||||
fprintf( pFile, "%d ", dd->invperm[i] );
|
||||
fprintf( pFile, "\n" );
|
||||
fclose( pFile );
|
||||
}
|
||||
Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fReverse, int fDumpOrder, int fVerbose )
|
||||
{
|
||||
Abc_Ntk_t * pNtkNew;
|
||||
abctime clk = Abc_Clock();
|
||||
|
|
@ -210,6 +219,8 @@ Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, i
|
|||
printf( "Shared BDD size = %6d nodes. ", Cudd_ReadKeys(dd) - Cudd_ReadDead(dd) );
|
||||
ABC_PRT( "BDD construction time", Abc_Clock() - clk );
|
||||
}
|
||||
if ( fDumpOrder )
|
||||
Abc_NtkDumpVariableOrder( pNtk );
|
||||
|
||||
// create the new network
|
||||
pNtkNew = Abc_NtkFromGlobalBdds( pNtk, fReverse );
|
||||
|
|
@ -236,7 +247,7 @@ Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, i
|
|||
|
||||
#else
|
||||
|
||||
Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fReverse, int fVerbose )
|
||||
Abc_Ntk_t * Abc_NtkCollapse( Abc_Ntk_t * pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fReverse, int fDumpOrder, int fVerbose )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ void Abc_CollectTopOr( Abc_Obj_t * pObj, Vec_Ptr_t * vSuper )
|
|||
if ( Abc_ObjIsComplement(pObj) )
|
||||
{
|
||||
Abc_CollectTopOr_rec( Abc_ObjNot(pObj), vSuper );
|
||||
Vec_PtrUniqify( vSuper, (int (*)())Abc_ObjCompareById );
|
||||
Vec_PtrUniqify( vSuper, (int (*)(const void *, const void *))Abc_ObjCompareById );
|
||||
}
|
||||
else
|
||||
Vec_PtrPush( vSuper, Abc_ObjNot(pObj) );
|
||||
|
|
@ -858,6 +858,7 @@ Abc_Ntk_t * Abc_NtkFromMappedGia( Gia_Man_t * p, int fFindEnables, int fUseBuffs
|
|||
Gia_LutForEachFanin( p, i, iFan, k )
|
||||
Abc_ObjAddFanin( pObjNew, Abc_NtkObj(pNtkNew, Gia_ObjValue(Gia_ManObj(p, iFan))) );
|
||||
pObjNew->pData = Abc_ObjHopFromGia( (Hop_Man_t *)pNtkNew->pManFunc, p, i, vReflect );
|
||||
pObjNew->fPersist = Gia_ObjLutIsMux(p, i) && Gia_ObjLutSize(p, i) == 3;
|
||||
pObj->Value = Abc_ObjId( pObjNew );
|
||||
}
|
||||
Vec_PtrFree( vReflect );
|
||||
|
|
@ -1650,6 +1651,7 @@ Abc_Ntk_t * Abc_NtkDChoice( Abc_Ntk_t * pNtk, int fBalance, int fUpdateLevel, in
|
|||
***********************************************************************/
|
||||
Abc_Ntk_t * Abc_NtkDch( Abc_Ntk_t * pNtk, Dch_Pars_t * pPars )
|
||||
{
|
||||
extern Aig_Man_t * Dar_ManChoiceNew( Aig_Man_t * pAig, Dch_Pars_t * pPars );
|
||||
extern Gia_Man_t * Dar_NewChoiceSynthesis( Aig_Man_t * pAig, int fBalance, int fUpdateLevel, int fPower, int fLightSynth, int fVerbose );
|
||||
extern Aig_Man_t * Cec_ComputeChoices( Gia_Man_t * pGia, Dch_Pars_t * pPars );
|
||||
|
||||
|
|
@ -1661,23 +1663,28 @@ Abc_Ntk_t * Abc_NtkDch( Abc_Ntk_t * pNtk, Dch_Pars_t * pPars )
|
|||
pMan = Abc_NtkToDar( pNtk, 0, 0 );
|
||||
if ( pMan == NULL )
|
||||
return NULL;
|
||||
if ( pPars->fUseNew )
|
||||
pMan = Dar_ManChoiceNew( pMan, pPars );
|
||||
else
|
||||
{
|
||||
clk = Abc_Clock();
|
||||
if ( pPars->fSynthesis )
|
||||
pGia = Dar_NewChoiceSynthesis( pMan, 1, 1, pPars->fPower, pPars->fLightSynth, pPars->fVerbose );
|
||||
else
|
||||
{
|
||||
pGia = Gia_ManFromAig( pMan );
|
||||
Aig_ManStop( pMan );
|
||||
}
|
||||
if ( pPars->fSynthesis )
|
||||
pGia = Dar_NewChoiceSynthesis( pMan, 1, 1, pPars->fPower, pPars->fLightSynth, pPars->fVerbose );
|
||||
else
|
||||
{
|
||||
pGia = Gia_ManFromAig( pMan );
|
||||
Aig_ManStop( pMan );
|
||||
}
|
||||
pPars->timeSynth = Abc_Clock() - clk;
|
||||
if ( pPars->fUseGia )
|
||||
pMan = Cec_ComputeChoices( pGia, pPars );
|
||||
else
|
||||
{
|
||||
pMan = Gia_ManToAigSkip( pGia, 3 );
|
||||
Gia_ManStop( pGia );
|
||||
pMan = Dch_ComputeChoices( pTemp = pMan, pPars );
|
||||
Aig_ManStop( pTemp );
|
||||
if ( pPars->fUseGia )
|
||||
pMan = Cec_ComputeChoices( pGia, pPars );
|
||||
else
|
||||
{
|
||||
pMan = Gia_ManToAigSkip( pGia, 3 );
|
||||
Gia_ManStop( pGia );
|
||||
pMan = Dch_ComputeChoices( pTemp = pMan, pPars );
|
||||
Aig_ManStop( pTemp );
|
||||
}
|
||||
}
|
||||
pNtkAig = Abc_NtkFromDarChoices( pNtk, pMan );
|
||||
Aig_ManStop( pMan );
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include "base/abc/abc.h"
|
||||
#include "aig/aig/aig.h"
|
||||
#include "proof/dch/dch.h"
|
||||
#include "aig/gia/giaAig.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
|
|
@ -272,6 +273,32 @@ Vec_Ptr_t * Abc_NtkDressMapIds( Aig_Man_t * pMiter, Abc_Ntk_t * pNtk1, Abc_Ntk_t
|
|||
return vRes;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Alternative way to compute equivalences.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Dch_ComputeEquivalences2( Aig_Man_t * pMiter, Dch_Pars_t * pPars )
|
||||
{
|
||||
extern Gia_Man_t * Cec4_ManSimulateTest3( Gia_Man_t * p, int nBTLimit, int fVerbose );
|
||||
Gia_Man_t * pGia = Gia_ManFromAigSimple(pMiter);
|
||||
Gia_Man_t * pNew = Cec4_ManSimulateTest3( pGia, pPars->nBTLimit, pPars->fVerbose );
|
||||
int i, k;
|
||||
ABC_FREE( pMiter->pReprs );
|
||||
pMiter->pReprs = ABC_CALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pMiter) );
|
||||
Gia_ManForEachClass( pGia, i )
|
||||
Gia_ClassForEachObj1( pGia, i, k )
|
||||
pMiter->pReprs[k] = Aig_ManObj( pMiter, i );
|
||||
Gia_ManStop( pGia );
|
||||
Gia_ManStop( pNew );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Computes equivalence classes of objects in pNtk1 and pNtk2.]
|
||||
|
|
@ -307,7 +334,7 @@ Vec_Ptr_t * Abc_NtkDressComputeEquivs( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int
|
|||
pPars->nBTLimit = nConflictLimit;
|
||||
pPars->fVerbose = fVerbose;
|
||||
// perform SAT sweeping
|
||||
Dch_ComputeEquivalences( pMiter, pPars );
|
||||
Dch_ComputeEquivalences2( pMiter, pPars );
|
||||
// now, pMiter is annotated with the equivl class info
|
||||
// convert this info into the resulting array
|
||||
vRes = Abc_NtkDressMapIds( pMiter, pNtk1, pNtk2 );
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ void Abc_NtkEspresso( Abc_Ntk_t * pNtk, int fVerbose )
|
|||
Abc_NtkMapToSop(pNtk);
|
||||
else if ( Abc_NtkHasBdd(pNtk) )
|
||||
{
|
||||
if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY) )
|
||||
if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY, 1) )
|
||||
{
|
||||
printf( "Abc_NtkEspresso(): Converting to SOPs has failed.\n" );
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
***********************************************************************/
|
||||
|
||||
#include "base/abc/abc.h"
|
||||
#include "aig/gia/giaAig.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
|
|
@ -741,7 +742,21 @@ Abc_Ntk_t * Abc_NtkShareXor( Abc_Ntk_t * pNtk, int nMultiSize, int fAnd, int fVe
|
|||
Abc_ShaManStop( p );
|
||||
return pNtkNew;
|
||||
}
|
||||
|
||||
Gia_Man_t * Abc_NtkShareXorGia( Gia_Man_t * p, int nMultiSize, int fAnd, int fVerbose )
|
||||
{
|
||||
extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
|
||||
extern Abc_Ntk_t * Abc_NtkFromAigPhase( Aig_Man_t * pMan );
|
||||
Aig_Man_t * pMan = Gia_ManToAig( p, 0 );
|
||||
Abc_Ntk_t * pNtk = Abc_NtkFromAigPhase( pMan );
|
||||
Abc_Ntk_t * pNtkNew = Abc_NtkShareXor( pNtk, nMultiSize, fAnd, fVerbose );
|
||||
Aig_Man_t * pAig = Abc_NtkToDar( pNtkNew, 0, 0 );
|
||||
Gia_Man_t * pNew = Gia_ManFromAig( pAig );
|
||||
Abc_NtkDelete( pNtkNew );
|
||||
Abc_NtkDelete( pNtk );
|
||||
Aig_ManStop( pAig );
|
||||
Aig_ManStop( pMan );
|
||||
return pNew;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ void Abc_NtkFxInsert( Abc_Ntk_t * pNtk, Vec_Wec_t * vCubes )
|
|||
// quit if nothing changes
|
||||
if ( iNodeMax < Abc_NtkObjNumMax(pNtk) )
|
||||
{
|
||||
printf( "The network is unchanged by fast extract.\n" );
|
||||
//printf( "The network is unchanged by fast extract.\n" );
|
||||
return;
|
||||
}
|
||||
// create new nodes
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ int Abc_NtkFastExtract( Abc_Ntk_t * pNtk, Fxu_Data_t * p )
|
|||
if ( Abc_NtkIsSopLogic(pNtk) )
|
||||
{ // to make sure the SOPs are SCC-free
|
||||
// Abc_NtkSopToBdd(pNtk);
|
||||
// Abc_NtkBddToSop(pNtk);
|
||||
// Abc_NtkBddToSop(pNtk, 1);
|
||||
}
|
||||
// get the network in the SOP form
|
||||
if ( !Abc_NtkToSop(pNtk, -1, ABC_INFINITY) )
|
||||
|
|
|
|||
|
|
@ -230,9 +230,13 @@ If_Man_t * Abc_NtkToIf( Abc_Ntk_t * pNtk, If_Par_t * pPars )
|
|||
Abc_AigConst1(pNtk)->pCopy = (Abc_Obj_t *)If_ManConst1( pIfMan );
|
||||
Abc_NtkForEachCi( pNtk, pNode, i )
|
||||
{
|
||||
pNode->pCopy = (Abc_Obj_t *)If_ManCreateCi( pIfMan );
|
||||
If_Obj_t * pIfObj = If_ManCreateCi( pIfMan );
|
||||
pNode->pCopy = (Abc_Obj_t *)pIfObj;
|
||||
// transfer logic level information
|
||||
Abc_ObjIfCopy(pNode)->Level = pNode->Level;
|
||||
// mark the largest level
|
||||
if ( pIfMan->nLevelMax < (int)pIfObj->Level )
|
||||
pIfMan->nLevelMax = (int)pIfObj->Level;
|
||||
}
|
||||
|
||||
// load the AIG into the mapper
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ Ivy_Man_t * Abc_NtkIvyBefore( Abc_Ntk_t * pNtk, int fSeq, int fUseDc )
|
|||
assert( !Abc_NtkIsNetlist(pNtk) );
|
||||
if ( Abc_NtkIsBddLogic(pNtk) )
|
||||
{
|
||||
if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY) )
|
||||
if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY, 1) )
|
||||
{
|
||||
printf( "Abc_NtkIvyBefore(): Converting to SOPs has failed.\n" );
|
||||
return NULL;
|
||||
|
|
@ -601,7 +601,7 @@ int Abc_NtkIvyProve( Abc_Ntk_t ** ppNtk, void * pPars )
|
|||
printf( "Attempting BDDs with node limit %d ...\n", pParams->nBddSizeLimit );
|
||||
fflush( stdout );
|
||||
}
|
||||
pNtk = Abc_NtkCollapse( pNtkTemp = pNtk, pParams->nBddSizeLimit, 0, pParams->fBddReorder, 0, 0 );
|
||||
pNtk = Abc_NtkCollapse( pNtkTemp = pNtk, pParams->nBddSizeLimit, 0, pParams->fBddReorder, 0, 0, 0 );
|
||||
if ( pNtk )
|
||||
{
|
||||
Abc_NtkDelete( pNtkTemp );
|
||||
|
|
@ -640,7 +640,7 @@ Abc_Ntk_t * Abc_NtkIvy( Abc_Ntk_t * pNtk )
|
|||
assert( !Abc_NtkIsNetlist(pNtk) );
|
||||
if ( Abc_NtkIsBddLogic(pNtk) )
|
||||
{
|
||||
if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY) )
|
||||
if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY, 1) )
|
||||
{
|
||||
Vec_IntFree( vInit );
|
||||
printf( "Abc_NtkIvy(): Converting to SOPs has failed.\n" );
|
||||
|
|
|
|||
|
|
@ -783,6 +783,166 @@ int Abc_NodeDecomposeStep( Abc_ManScl_t * p )
|
|||
return 1;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Performs specialized mapping.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
static word s__Truths6[6] = {
|
||||
ABC_CONST(0xAAAAAAAAAAAAAAAA),
|
||||
ABC_CONST(0xCCCCCCCCCCCCCCCC),
|
||||
ABC_CONST(0xF0F0F0F0F0F0F0F0),
|
||||
ABC_CONST(0xFF00FF00FF00FF00),
|
||||
ABC_CONST(0xFFFF0000FFFF0000),
|
||||
ABC_CONST(0xFFFFFFFF00000000)
|
||||
};
|
||||
word Abc_ObjComputeTruth( Abc_Obj_t * pObj, Vec_Int_t * vSupp )
|
||||
{
|
||||
int Index; word t0, t1, tc;
|
||||
assert( Vec_IntSize(vSupp) <= 6 );
|
||||
if ( (Index = Vec_IntFind(vSupp, Abc_ObjId(pObj))) >= 0 )
|
||||
return s__Truths6[Index];
|
||||
assert( Abc_ObjIsNode(pObj) );
|
||||
if ( Abc_ObjFaninNum(pObj) == 0 )
|
||||
return Abc_NodeIsConst0(pObj) ? (word)0 : ~(word)0;
|
||||
assert( Abc_ObjFaninNum(pObj) == 3 );
|
||||
t0 = Abc_ObjComputeTruth( Abc_ObjFanin(pObj, 2), vSupp );
|
||||
t1 = Abc_ObjComputeTruth( Abc_ObjFanin(pObj, 1), vSupp );
|
||||
tc = Abc_ObjComputeTruth( Abc_ObjFanin(pObj, 0), vSupp );
|
||||
return (tc & t1) | (~tc & t0);
|
||||
}
|
||||
Abc_Obj_t * Abc_NtkSpecialMap_rec( Abc_Ntk_t * pNew, Abc_Obj_t * pObj, Vec_Wec_t * vSupps, Vec_Int_t * vCover )
|
||||
{
|
||||
if ( pObj->pCopy )
|
||||
return pObj->pCopy;
|
||||
if ( Abc_ObjFaninNum(pObj) == 0 )
|
||||
return NULL;
|
||||
assert( Abc_ObjFaninNum(pObj) == 3 );
|
||||
if ( pObj->fMarkA || pObj->fMarkB )
|
||||
{
|
||||
Abc_Obj_t * pFan0 = Abc_NtkSpecialMap_rec( pNew, Abc_ObjFanin(pObj, 2), vSupps, vCover );
|
||||
Abc_Obj_t * pFan1 = Abc_NtkSpecialMap_rec( pNew, Abc_ObjFanin(pObj, 1), vSupps, vCover );
|
||||
Abc_Obj_t * pFanC = Abc_NtkSpecialMap_rec( pNew, Abc_ObjFanin(pObj, 0), vSupps, vCover );
|
||||
if ( pFan0 == NULL )
|
||||
pFan0 = Abc_NodeIsConst0(Abc_ObjFanin(pObj, 2)) ? Abc_NtkCreateNodeConst0(pNew) : Abc_NtkCreateNodeConst1(pNew);
|
||||
if ( pFan1 == NULL )
|
||||
pFan1 = Abc_NodeIsConst0(Abc_ObjFanin(pObj, 1)) ? Abc_NtkCreateNodeConst0(pNew) : Abc_NtkCreateNodeConst1(pNew);
|
||||
pObj->pCopy = Abc_NtkCreateNodeMux( pNew, pFanC, pFan1, pFan0 );
|
||||
pObj->pCopy->fMarkA = pObj->fMarkA;
|
||||
pObj->pCopy->fMarkB = pObj->fMarkB;
|
||||
}
|
||||
else
|
||||
{
|
||||
Abc_Obj_t * pTemp; int i; word Truth;
|
||||
Vec_Int_t * vSupp = Vec_WecEntry( vSupps, Abc_ObjId(pObj) );
|
||||
Abc_NtkForEachObjVec( vSupp, pObj->pNtk, pTemp, i )
|
||||
Abc_NtkSpecialMap_rec( pNew, pTemp, vSupps, vCover );
|
||||
pObj->pCopy = Abc_NtkCreateNode( pNew );
|
||||
Abc_NtkForEachObjVec( vSupp, pObj->pNtk, pTemp, i )
|
||||
Abc_ObjAddFanin( pObj->pCopy, pTemp->pCopy );
|
||||
Truth = Abc_ObjComputeTruth( pObj, vSupp );
|
||||
pObj->pCopy->pData = Abc_SopCreateFromTruthIsop( (Mem_Flex_t *)pNew->pManFunc, Vec_IntSize(vSupp), &Truth, vCover );
|
||||
assert( Abc_SopGetVarNum((char *)pObj->pCopy->pData) == Vec_IntSize(vSupp) );
|
||||
}
|
||||
return pObj->pCopy;
|
||||
}
|
||||
Abc_Ntk_t * Abc_NtkSpecialMapping( Abc_Ntk_t * pNtk, int fVerbose )
|
||||
{
|
||||
Abc_Ntk_t * pNtkNew;
|
||||
Vec_Int_t * vCover = Vec_IntAlloc( 1 << 16 );
|
||||
Vec_Wec_t * vSupps = Vec_WecStart( Abc_NtkObjNumMax(pNtk) );
|
||||
Abc_Obj_t * pObj, * pFan0, * pFan1, * pFanC; int i, Count[2] = {0};
|
||||
Abc_NtkForEachCi( pNtk, pObj, i )
|
||||
Vec_IntPush( Vec_WecEntry(vSupps, i), i );
|
||||
Abc_NtkForEachNode( pNtk, pObj, i )
|
||||
{
|
||||
Vec_Int_t * vSupp = Vec_WecEntry(vSupps, i);
|
||||
if ( Abc_ObjFaninNum(pObj) == 0 )
|
||||
continue;
|
||||
assert( Abc_ObjFaninNum(pObj) == 3 );
|
||||
pFan0 = Abc_ObjFanin( pObj, 2 );
|
||||
pFan1 = Abc_ObjFanin( pObj, 1 );
|
||||
pFanC = Abc_ObjFanin0( pObj );
|
||||
assert( Abc_ObjIsCi(pFanC) );
|
||||
if ( pFan0->fMarkA && pFan1->fMarkA )
|
||||
{
|
||||
pObj->fMarkB = 1;
|
||||
Vec_IntPush( vSupp, Abc_ObjId(pObj) );
|
||||
continue;
|
||||
}
|
||||
Vec_IntTwoMerge2( Vec_WecEntry(vSupps, Abc_ObjId(pFan0)), Vec_WecEntry(vSupps, Abc_ObjId(pFan1)), vSupp );
|
||||
assert( Vec_IntFind(vSupp, Abc_ObjId(pFanC)) == -1 );
|
||||
Vec_IntPushOrder( vSupp, Abc_ObjId(pFanC) );
|
||||
if ( Vec_IntSize(vSupp) <= 6 )
|
||||
continue;
|
||||
Vec_IntClear( vSupp );
|
||||
if ( !pFan0->fMarkA && !pFan1->fMarkA )
|
||||
{
|
||||
pObj->fMarkA = 1;
|
||||
Vec_IntPush( vSupp, Abc_ObjId(pObj) );
|
||||
}
|
||||
else
|
||||
{
|
||||
Vec_IntPushOrder( vSupp, Abc_ObjId(pFan0) );
|
||||
Vec_IntPushOrder( vSupp, Abc_ObjId(pFan1) );
|
||||
Vec_IntPushOrder( vSupp, Abc_ObjId(pFanC) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( fVerbose )
|
||||
{
|
||||
Abc_NtkForEachNode( pNtk, pObj, i )
|
||||
{
|
||||
printf( "Node %4d : ", i );
|
||||
if ( pObj->fMarkA )
|
||||
printf( " MarkA " );
|
||||
else
|
||||
printf( " " );
|
||||
if ( pObj->fMarkB )
|
||||
printf( " MarkB " );
|
||||
else
|
||||
printf( " " );
|
||||
Vec_IntPrint( Vec_WecEntry(vSupps, i) );
|
||||
}
|
||||
}
|
||||
|
||||
Abc_NtkCleanCopy( pNtk );
|
||||
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP );
|
||||
Abc_NtkForEachCo( pNtk, pObj, i )
|
||||
if ( Abc_ObjFaninNum(Abc_ObjFanin0(pObj)) == 0 )
|
||||
Abc_ObjFanin0(pObj)->pCopy = Abc_NodeIsConst0(Abc_ObjFanin0(pObj)) ? Abc_NtkCreateNodeConst0(pNtkNew) : Abc_NtkCreateNodeConst1(pNtkNew);
|
||||
else
|
||||
Abc_NtkSpecialMap_rec( pNtkNew, Abc_ObjFanin0(pObj), vSupps, vCover );
|
||||
Abc_NtkFinalize( pNtk, pNtkNew );
|
||||
Abc_NtkCleanMarkAB( pNtk );
|
||||
Vec_WecFree( vSupps );
|
||||
Vec_IntFree( vCover );
|
||||
|
||||
Abc_NtkForEachNode( pNtkNew, pObj, i )
|
||||
{
|
||||
Count[0] += pObj->fMarkA,
|
||||
Count[1] += pObj->fMarkB;
|
||||
pObj->fPersist = pObj->fMarkA | pObj->fMarkB;
|
||||
pObj->fMarkA = pObj->fMarkB = 0;
|
||||
}
|
||||
//printf( "Total = %3d. Nodes = %3d. MarkA = %3d. MarkB = %3d.\n", Abc_NtkNodeNum(pNtkNew),
|
||||
// Abc_NtkNodeNum(pNtkNew) - Count[0] - Count[1], Count[0], Count[1] );
|
||||
|
||||
if ( !Abc_NtkCheck( pNtkNew ) )
|
||||
{
|
||||
printf( "Abc_NtkSpecialMapping: The network check has failed.\n" );
|
||||
Abc_NtkDelete( pNtkNew );
|
||||
return NULL;
|
||||
}
|
||||
return pNtkNew;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -610,7 +610,7 @@ Abc_Obj_t * Abc_NtkBddDecompose( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode, int nLu
|
|||
// cofactor w.r.t. the bound set variables
|
||||
vCofs = Abc_NtkBddCofactors( dd, (DdNode *)pNode->pData, nLutSize );
|
||||
vUniq = Vec_PtrDup( vCofs );
|
||||
Vec_PtrUniqify( vUniq, (int (*)())Vec_PtrSortCompare );
|
||||
Vec_PtrUniqify( vUniq, (int (*)(const void *, const void *))Vec_PtrSortCompare );
|
||||
// only perform decomposition with it is support reduring with two less vars
|
||||
if( Vec_PtrSize(vUniq) > (1 << (nLutSize-2)) )
|
||||
{
|
||||
|
|
@ -739,7 +739,7 @@ Abc_Ntk_t * Abc_NtkLutmin( Abc_Ntk_t * pNtkInit, int nLutSize, int fVerbose )
|
|||
else
|
||||
pNtkNew = Abc_NtkStrash( pNtkInit, 0, 1, 0 );
|
||||
// collapse the network
|
||||
pNtkNew = Abc_NtkCollapse( pTemp = pNtkNew, 10000, 0, 1, 0, 0 );
|
||||
pNtkNew = Abc_NtkCollapse( pTemp = pNtkNew, 10000, 0, 1, 0, 0, 0 );
|
||||
Abc_NtkDelete( pTemp );
|
||||
if ( pNtkNew == NULL )
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ ABC_NAMESPACE_IMPL_START
|
|||
/// DECLARATIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static Map_Man_t * Abc_NtkToMap( Abc_Ntk_t * pNtk, double DelayTarget, int fRecovery, float * pSwitching, int fVerbose );
|
||||
static Abc_Ntk_t * Abc_NtkFromMap( Map_Man_t * pMan, Abc_Ntk_t * pNtk, int fUseBuffs );
|
||||
extern Map_Man_t * Abc_NtkToMap( Abc_Ntk_t * pNtk, double DelayTarget, int fRecovery, float * pSwitching, int fVerbose );
|
||||
extern Abc_Ntk_t * Abc_NtkFromMap( Map_Man_t * pMan, Abc_Ntk_t * pNtk, int fUseBuffs );
|
||||
static Abc_Obj_t * Abc_NodeFromMap_rec( Abc_Ntk_t * pNtkNew, Map_Node_t * pNodeMap, int fPhase );
|
||||
static Abc_Obj_t * Abc_NodeFromMapPhase_rec( Abc_Ntk_t * pNtkNew, Map_Node_t * pNodeMap, int fPhase );
|
||||
|
||||
|
|
@ -612,7 +612,7 @@ Abc_Ntk_t * Abc_NtkFromMapSuperChoice( Map_Man_t * pMan, Abc_Ntk_t * pNtk )
|
|||
// duplicate the network
|
||||
pNtkNew2 = Abc_NtkDup( pNtk );
|
||||
pNtkNew = Abc_NtkMulti( pNtkNew2, 0, 20, 0, 0, 1, 0 );
|
||||
if ( !Abc_NtkBddToSop( pNtkNew, -1, ABC_INFINITY ) )
|
||||
if ( !Abc_NtkBddToSop( pNtkNew, -1, ABC_INFINITY, 1 ) )
|
||||
{
|
||||
printf( "Abc_NtkFromMapSuperChoice(): Converting to SOPs has failed.\n" );
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -1141,7 +1141,7 @@ Vec_Ptr_t * Abc_NktMffcServer( Abc_Ntk_t * pNtk, int nInMax, int nOutMax )
|
|||
// sort by their MFFC size
|
||||
Vec_PtrForEachEntry( Abc_Obj_t *, vPivots, pObj, i )
|
||||
pObj->iTemp = Vec_IntSize((Vec_Int_t *)Vec_PtrEntry(vVolumes, Abc_ObjId(pObj)));
|
||||
Vec_PtrSort( vPivots, (int (*)(void))Abc_NodeCompareVolumeDecrease );
|
||||
Vec_PtrSort( vPivots, (int (*)(const void *, const void *))Abc_NodeCompareVolumeDecrease );
|
||||
// create marks
|
||||
vMarks = Vec_IntStart( Abc_NtkObjNumMax(pNtk) );
|
||||
Vec_PtrForEachEntry( Abc_Obj_t *, vPivots, pObj, i )
|
||||
|
|
|
|||
|
|
@ -863,7 +863,7 @@ void Abc_NtkAddFrame( Abc_Ntk_t * pNtkFrames, Abc_Ntk_t * pNtk, int iFrame )
|
|||
{
|
||||
int fVerbose = 0;
|
||||
int NodeBef = Abc_NtkNodeNum(pNtkFrames);
|
||||
char Buffer[10];
|
||||
char Buffer[16];
|
||||
Abc_Obj_t * pNode, * pLatch;
|
||||
int i;
|
||||
// create the prefix to be added to the node names
|
||||
|
|
@ -1008,7 +1008,7 @@ Abc_Ntk_t * Abc_NtkFrames2( Abc_Ntk_t * pNtk, int nFrames, int fInitial, AddFram
|
|||
void Abc_NtkAddFrame2( Abc_Ntk_t * pNtkFrames, Abc_Ntk_t * pNtk, int iFrame, Vec_Ptr_t * vNodes, AddFrameMapping addFrameMapping, void* arg )
|
||||
{
|
||||
/*
|
||||
char Buffer[10];
|
||||
char Buffer[16];
|
||||
Abc_Obj_t * pNode, * pNodeNew, * pLatch;
|
||||
Abc_Obj_t * pConst1, * pConst1New;
|
||||
int i;
|
||||
|
|
|
|||
|
|
@ -564,7 +564,7 @@ void Npn_ManWrite( Npn_Man_t * p, char * pFileName )
|
|||
for ( i = 0; i < p->nBins; i++ )
|
||||
for ( pEntry = Npn_ManObj(p, p->pBins[i]); pEntry; pEntry = Npn_ManObj(p, pEntry->iNext) )
|
||||
Vec_PtrPush( vEntries, pEntry );
|
||||
Vec_PtrSort( vEntries, (int (*)())Npn_ManCompareEntries );
|
||||
Vec_PtrSort( vEntries, (int (*)(const void *, const void *))Npn_ManCompareEntries );
|
||||
Vec_PtrForEachEntry( Npn_Obj_t *, vEntries, pEntry, i )
|
||||
{
|
||||
Extra_PrintHexadecimal( pFile, (unsigned *)&pEntry->uTruth, 6 );
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ ABC_NAMESPACE_IMPL_START
|
|||
|
||||
#ifdef ABC_USE_CUDD
|
||||
|
||||
static int Abc_NtkBddToMuxesPerformGlo( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, int Limit );
|
||||
int Abc_NtkBddToMuxesPerformGlo( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, int Limit, int fReorder, int fUseAdd );
|
||||
static void Abc_NtkBddToMuxesPerform( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew );
|
||||
static Abc_Obj_t * Abc_NodeBddToMuxes( Abc_Obj_t * pNodeOld, Abc_Ntk_t * pNtkNew );
|
||||
static Abc_Obj_t * Abc_NodeBddToMuxes_rec( DdManager * dd, DdNode * bFunc, Abc_Ntk_t * pNtkNew, st__table * tBdd2Node );
|
||||
|
|
@ -129,13 +129,13 @@ Abc_Ntk_t * Abc_NtkDeriveFromBdd( void * dd0, void * bFunc, char * pNamePo, Vec_
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk, int fGlobal, int Limit )
|
||||
Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk, int fGlobal, int Limit, int fUseAdd )
|
||||
{
|
||||
Abc_Ntk_t * pNtkNew;
|
||||
pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_SOP );
|
||||
if ( fGlobal )
|
||||
{
|
||||
if ( !Abc_NtkBddToMuxesPerformGlo( pNtk, pNtkNew, Limit ) )
|
||||
if ( !Abc_NtkBddToMuxesPerformGlo( pNtk, pNtkNew, Limit, 0, fUseAdd ) )
|
||||
{
|
||||
Abc_NtkDelete( pNtkNew );
|
||||
return NULL;
|
||||
|
|
@ -237,8 +237,10 @@ Abc_Obj_t * Abc_NodeBddToMuxes_rec( DdManager * dd, DdNode * bFunc, Abc_Ntk_t *
|
|||
{
|
||||
Abc_Obj_t * pNodeNew, * pNodeNew0, * pNodeNew1, * pNodeNewC;
|
||||
assert( !Cudd_IsComplement(bFunc) );
|
||||
if ( bFunc == b1 )
|
||||
if ( bFunc == b1 || bFunc == a1 )
|
||||
return Abc_NtkCreateNodeConst1(pNtkNew);
|
||||
if ( bFunc == a0 )
|
||||
return Abc_NtkCreateNodeConst0(pNtkNew);
|
||||
if ( st__lookup( tBdd2Node, (char *)bFunc, (char **)&pNodeNew ) )
|
||||
return pNodeNew;
|
||||
// solve for the children nodes
|
||||
|
|
@ -265,13 +267,14 @@ Abc_Obj_t * Abc_NodeBddToMuxes_rec( DdManager * dd, DdNode * bFunc, Abc_Ntk_t *
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Abc_NtkBddToMuxesPerformGlo( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, int Limit )
|
||||
int Abc_NtkBddToMuxesPerformGlo( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, int Limit, int fReorder, int fUseAdd )
|
||||
{
|
||||
DdManager * dd;
|
||||
Vec_Ptr_t * vAdds = fUseAdd ? Vec_PtrAlloc(100) : NULL;
|
||||
Abc_Obj_t * pObj, * pObjNew; int i;
|
||||
st__table * tBdd2Node;
|
||||
assert( Abc_NtkIsStrash(pNtk) );
|
||||
dd = (DdManager *)Abc_NtkBuildGlobalBdds( pNtk, Limit, 1, 1, 0, 0 );
|
||||
dd = (DdManager *)Abc_NtkBuildGlobalBdds( pNtk, Limit, 1, fReorder, 0, 0 );
|
||||
if ( dd == NULL )
|
||||
{
|
||||
printf( "Construction of global BDDs has failed.\n" );
|
||||
|
|
@ -286,16 +289,32 @@ int Abc_NtkBddToMuxesPerformGlo( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkNew, int Limi
|
|||
// complement the global functions
|
||||
Abc_NtkForEachCo( pNtk, pObj, i )
|
||||
{
|
||||
DdNode * bFunc = Abc_ObjGlobalBdd(pObj);
|
||||
pObjNew = Abc_NodeBddToMuxes_rec( dd, Cudd_Regular(bFunc), pNtkNew, tBdd2Node );
|
||||
if ( Cudd_IsComplement(bFunc) )
|
||||
pObjNew = Abc_NtkCreateNodeInv( pNtkNew, pObjNew );
|
||||
DdNode * bFunc = (DdNode *)Abc_ObjGlobalBdd(pObj);
|
||||
if ( fUseAdd )
|
||||
{
|
||||
DdNode * aFunc = Cudd_BddToAdd( dd, bFunc ); Cudd_Ref( aFunc );
|
||||
pObjNew = Abc_NodeBddToMuxes_rec( dd, aFunc, pNtkNew, tBdd2Node );
|
||||
Vec_PtrPush( vAdds, aFunc );
|
||||
}
|
||||
else
|
||||
{
|
||||
pObjNew = Abc_NodeBddToMuxes_rec( dd, Cudd_Regular(bFunc), pNtkNew, tBdd2Node );
|
||||
if ( Cudd_IsComplement(bFunc) )
|
||||
pObjNew = Abc_NtkCreateNodeInv( pNtkNew, pObjNew );
|
||||
}
|
||||
Abc_ObjAddFanin( pObj->pCopy, pObjNew );
|
||||
}
|
||||
|
||||
// cleanup
|
||||
st__free_table( tBdd2Node );
|
||||
Abc_NtkFreeGlobalBdds( pNtk, 0 );
|
||||
if ( vAdds )
|
||||
{
|
||||
DdNode * aTemp;
|
||||
Vec_PtrForEachEntry( DdNode *, vAdds, aTemp, i )
|
||||
Cudd_RecursiveDeref( dd, aTemp );
|
||||
Vec_PtrFree( vAdds );
|
||||
}
|
||||
Extra_StopManager( dd );
|
||||
Abc_NtkCleanCopy( pNtk );
|
||||
return 1;
|
||||
|
|
@ -410,6 +429,7 @@ void * Abc_NtkBuildGlobalBdds( Abc_Ntk_t * pNtk, int nBddSizeMax, int fDropInter
|
|||
if ( fReorder )
|
||||
{
|
||||
Cudd_ReduceHeap( dd, CUDD_REORDER_SYMM_SIFT, 1 );
|
||||
// Cudd_ReduceHeap( dd, CUDD_REORDER_SYMM_SIFT, 1 );
|
||||
Cudd_AutodynDisable( dd );
|
||||
}
|
||||
// Cudd_PrintInfo( dd, stdout );
|
||||
|
|
@ -662,7 +682,7 @@ ABC_PRT( "Time", Abc_Clock() - clk );
|
|||
#else
|
||||
|
||||
double Abc_NtkSpacePercentage( Abc_Obj_t * pNode ) { return 0.0; }
|
||||
Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk, int fGlobal, int Limit ) { return NULL; }
|
||||
Abc_Ntk_t * Abc_NtkBddToMuxes( Abc_Ntk_t * pNtk, int fGlobal, int Limit, int fUseAdd ) { return NULL; }
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -453,6 +453,15 @@ void Abc_NtkPrintStats( Abc_Ntk_t * pNtk, int fFactored, int fSaveBest, int fDum
|
|||
// if ( Abc_NtkHasSop(pNtk) )
|
||||
// printf( "The total number of cube pairs = %d.\n", Abc_NtkGetCubePairNum(pNtk) );
|
||||
|
||||
if ( 0 )
|
||||
{
|
||||
FILE * pTable = fopen( "stats.txt", "a+" );
|
||||
if ( Abc_NtkIsStrash(pNtk) )
|
||||
fprintf( pTable, "%s ", pNtk->pName );
|
||||
fprintf( pTable, "%d ", Abc_NtkNodeNum(pNtk) );
|
||||
fclose( pTable );
|
||||
}
|
||||
|
||||
fflush( stdout );
|
||||
if ( pNtk->pExdc )
|
||||
Abc_NtkPrintStats( pNtk->pExdc, fFactored, fSaveBest, fDumpResult, fUseLutLib, fPrintMuxes, fPower, fGlitch, fSkipBuf, fSkipSmall, fPrintMem );
|
||||
|
|
@ -1399,7 +1408,7 @@ void Abc_NtkPrintGates( Abc_Ntk_t * pNtk, int fUseLibrary, int fUpdateProfile )
|
|||
// transform logic functions from BDD to SOP
|
||||
if ( (fHasBdds = Abc_NtkIsBddLogic(pNtk)) )
|
||||
{
|
||||
if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY) )
|
||||
if ( !Abc_NtkBddToSop(pNtk, -1, ABC_INFINITY, 1) )
|
||||
{
|
||||
printf( "Abc_NtkPrintGates(): Converting to SOPs has failed.\n" );
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ int Abc_NtkMiterProve( Abc_Ntk_t ** ppNtk, void * pPars )
|
|||
fflush( stdout );
|
||||
}
|
||||
clk = Abc_Clock();
|
||||
pNtk = Abc_NtkCollapse( pNtkTemp = pNtk, pParams->nBddSizeLimit, 0, pParams->fBddReorder, 0, 0 );
|
||||
pNtk = Abc_NtkCollapse( pNtkTemp = pNtk, pParams->nBddSizeLimit, 0, pParams->fBddReorder, 0, 0, 0 );
|
||||
if ( pNtk )
|
||||
{
|
||||
Abc_NtkDelete( pNtkTemp );
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ void Abc_NtkBddReorder( Abc_Ntk_t * pNtk, int fVerbose )
|
|||
reo_man * p;
|
||||
Abc_Obj_t * pNode;
|
||||
int i;
|
||||
Abc_NtkRemoveDupFanins( pNtk );
|
||||
//Abc_NtkRemoveDupFanins( pNtk );
|
||||
Abc_NtkMinimumBase( pNtk );
|
||||
p = Extra_ReorderInit( Abc_NtkGetFaninMax(pNtk), 100 );
|
||||
Abc_NtkForEachNode( pNtk, pNode, i )
|
||||
|
|
|
|||
|
|
@ -548,25 +548,27 @@ Abc_Obj_t * Abc_NtkTopmost_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode, int Leve
|
|||
Abc_Ntk_t * Abc_NtkTopmost( Abc_Ntk_t * pNtk, int nLevels )
|
||||
{
|
||||
Abc_Ntk_t * pNtkNew;
|
||||
Abc_Obj_t * pObjNew, * pObjPo;
|
||||
int LevelCut;
|
||||
Abc_Obj_t * pObjNew, * pObj;
|
||||
int LevelCut, i;
|
||||
assert( Abc_NtkIsStrash(pNtk) );
|
||||
assert( Abc_NtkCoNum(pNtk) == 1 );
|
||||
// get the cutoff level
|
||||
LevelCut = Abc_MaxInt( 0, Abc_AigLevel(pNtk) - nLevels );
|
||||
// start the network
|
||||
pNtkNew = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
|
||||
pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
|
||||
Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
|
||||
// create PIs below the cut and nodes above the cut
|
||||
Abc_NtkCleanCopy( pNtk );
|
||||
pObjNew = Abc_NtkTopmost_rec( pNtkNew, Abc_ObjFanin0(Abc_NtkPo(pNtk, 0)), LevelCut );
|
||||
pObjNew = Abc_ObjNotCond( pObjNew, Abc_ObjFaninC0(Abc_NtkPo(pNtk, 0)) );
|
||||
Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
|
||||
Abc_NtkForEachCo( pNtk, pObj, i )
|
||||
{
|
||||
pObjNew = Abc_NtkTopmost_rec( pNtkNew, Abc_ObjFanin0(pObj), LevelCut );
|
||||
pObjNew = Abc_ObjNotCond( pObjNew, Abc_ObjFaninC0(pObj) );
|
||||
Abc_ObjAddFanin( (pObj->pCopy = Abc_NtkCreatePo(pNtkNew)), pObjNew );
|
||||
}
|
||||
// add the PO node and name
|
||||
pObjPo = Abc_NtkCreatePo(pNtkNew);
|
||||
Abc_ObjAddFanin( pObjPo, pObjNew );
|
||||
Abc_NtkAddDummyPiNames( pNtkNew );
|
||||
Abc_ObjAssignName( pObjPo, Abc_ObjName(Abc_NtkPo(pNtk, 0)), NULL );
|
||||
Abc_NtkForEachCo( pNtk, pObj, i )
|
||||
Abc_ObjAssignName( pObj->pCopy, Abc_ObjName(pObj), NULL );
|
||||
// make sure everything is okay
|
||||
if ( !Abc_NtkCheck( pNtkNew ) )
|
||||
{
|
||||
|
|
@ -578,6 +580,74 @@ Abc_Ntk_t * Abc_NtkTopmost( Abc_Ntk_t * pNtk, int nLevels )
|
|||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Copies the bottommost levels of the network.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Abc_Obj_t * Abc_NtkBottommost_rec( Abc_Ntk_t * pNtkNew, Abc_Obj_t * pNode, int LevelCut )
|
||||
{
|
||||
assert( !Abc_ObjIsComplement(pNode) );
|
||||
if ( pNode->pCopy )
|
||||
return pNode->pCopy;
|
||||
Abc_NtkBottommost_rec( pNtkNew, Abc_ObjFanin0(pNode), LevelCut );
|
||||
Abc_NtkBottommost_rec( pNtkNew, Abc_ObjFanin1(pNode), LevelCut );
|
||||
if ( pNode->Level > (unsigned)LevelCut )
|
||||
return NULL;
|
||||
return pNode->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pNode), Abc_ObjChild1Copy(pNode) );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Copies the topmost levels of the network.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Abc_Ntk_t * Abc_NtkBottommost( Abc_Ntk_t * pNtk, int nLevels )
|
||||
{
|
||||
Abc_Ntk_t * pNtkNew;
|
||||
Abc_Obj_t * pObj, * pObjNew;
|
||||
int i;
|
||||
assert( Abc_NtkIsStrash(pNtk) );
|
||||
assert( nLevels >= 0 );
|
||||
// start the network
|
||||
pNtkNew = Abc_NtkAlloc( ABC_NTK_STRASH, ABC_FUNC_AIG, 1 );
|
||||
pNtkNew->pName = Extra_UtilStrsav(pNtk->pName);
|
||||
// create PIs below the cut and nodes above the cut
|
||||
Abc_NtkCleanCopy( pNtk );
|
||||
Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
|
||||
Abc_NtkForEachCi( pNtk, pObj, i )
|
||||
pObj->pCopy = Abc_NtkCreatePi( pNtkNew );
|
||||
Abc_NtkForEachCo( pNtk, pObj, i )
|
||||
Abc_NtkBottommost_rec( pNtkNew, Abc_ObjFanin0(pObj), nLevels );
|
||||
// add POs to nodes without fanout
|
||||
Abc_NtkForEachNode( pNtkNew, pObjNew, i )
|
||||
if ( Abc_ObjFanoutNum(pObjNew) == 0 )
|
||||
Abc_ObjAddFanin( Abc_NtkCreatePo(pNtkNew), pObjNew );
|
||||
Abc_NtkAddDummyPiNames( pNtkNew );
|
||||
Abc_NtkAddDummyPoNames( pNtkNew );
|
||||
// make sure everything is okay
|
||||
if ( !Abc_NtkCheck( pNtkNew ) )
|
||||
{
|
||||
printf( "Abc_NtkBottommost: The network check has failed.\n" );
|
||||
Abc_NtkDelete( pNtkNew );
|
||||
return NULL;
|
||||
}
|
||||
return pNtkNew;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
|
|
@ -642,7 +712,7 @@ Vec_Ptr_t * Abc_NodeGetSuper( Abc_Obj_t * pNode )
|
|||
Vec_PtrFree( vSuper );
|
||||
vSuper = vFront;
|
||||
// uniquify and return the frontier
|
||||
Vec_PtrUniqify( vSuper, (int (*)())Vec_CompareNodeIds );
|
||||
Vec_PtrUniqify( vSuper, (int (*)(const void *, const void *))Vec_CompareNodeIds );
|
||||
return vSuper;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -619,7 +619,7 @@ int Abc_NtkSweep( Abc_Ntk_t * pNtk, int fVerbose )
|
|||
nNodesOld = Abc_NtkNodeNum(pNtk);
|
||||
Abc_NtkCleanup( pNtk, 0 );
|
||||
// prepare nodes for sweeping
|
||||
Abc_NtkRemoveDupFanins(pNtk);
|
||||
//Abc_NtkRemoveDupFanins(pNtk);
|
||||
Abc_NtkMinimumBase(pNtk);
|
||||
// collect sweepable nodes
|
||||
vNodes = Vec_PtrAlloc( 100 );
|
||||
|
|
@ -649,7 +649,7 @@ int Abc_NtkSweep( Abc_Ntk_t * pNtk, int fVerbose )
|
|||
Abc_NodeComplementInput( pFanout, pNode );
|
||||
Abc_ObjPatchFanin( pFanout, pNode, pDriver );
|
||||
}
|
||||
Abc_NodeRemoveDupFanins( pFanout );
|
||||
//Abc_NodeRemoveDupFanins( pFanout );
|
||||
Abc_NodeMinimumBase( pFanout );
|
||||
// check if the fanout should be added
|
||||
if ( Abc_ObjFaninNum(pFanout) < 2 )
|
||||
|
|
@ -888,7 +888,7 @@ int Abc_NtkReplaceAutonomousLogic( Abc_Ntk_t * pNtk )
|
|||
Vec_PtrPush( vNodes, pFanin );
|
||||
}
|
||||
}
|
||||
Vec_PtrUniqify( vNodes, (int (*)(void))Abc_ObjPointerCompare );
|
||||
Vec_PtrUniqify( vNodes, (int (*)(const void *, const void *))Abc_ObjPointerCompare );
|
||||
// replace these nodes by the PIs
|
||||
Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNode, i )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,9 +24,11 @@
|
|||
#include "base/main/main.h"
|
||||
#include "map/mio/mio.h"
|
||||
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// DECLARATIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
@ -187,8 +189,9 @@ void Abc_NtkTimeSetDefaultRequired( Abc_Ntk_t * pNtk, float Rise, float Fall )
|
|||
pNtk->pManTime->tReqDef.Rise = Rise;
|
||||
pNtk->pManTime->tReqDef.Fall = Fall;
|
||||
// set the required times for each output
|
||||
Abc_NtkForEachCo( pNtk, pObj, i )
|
||||
Abc_NtkTimeSetRequired( pNtk, Abc_ObjId(pObj), Rise, Fall );
|
||||
Abc_NtkForEachCo( pNtk, pObj, i ){
|
||||
Abc_NtkTimeSetRequired( pNtk, Abc_ObjId(pObj), Rise, Fall );
|
||||
}
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
|
@ -206,6 +209,7 @@ void Abc_NtkTimeSetArrival( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall
|
|||
{
|
||||
Vec_Ptr_t * vTimes;
|
||||
Abc_Time_t * pTime;
|
||||
|
||||
if ( pNtk->pManTime == NULL )
|
||||
pNtk->pManTime = Abc_ManTimeStart(pNtk);
|
||||
Abc_ManTimeExpand( pNtk->pManTime, ObjId + 1, 1 );
|
||||
|
|
@ -214,6 +218,8 @@ void Abc_NtkTimeSetArrival( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall
|
|||
pTime = (Abc_Time_t *)vTimes->pArray[ObjId];
|
||||
pTime->Rise = Rise;
|
||||
pTime->Fall = Fall;
|
||||
|
||||
|
||||
}
|
||||
void Abc_NtkTimeSetRequired( Abc_Ntk_t * pNtk, int ObjId, float Rise, float Fall )
|
||||
{
|
||||
|
|
@ -473,6 +479,7 @@ Abc_ManTime_t * Abc_ManTimeStart( Abc_Ntk_t * pNtk )
|
|||
{
|
||||
int fUseZeroDefaultOutputRequired = 1;
|
||||
Abc_ManTime_t * p;
|
||||
Abc_Time_t* pTime;
|
||||
Abc_Obj_t * pObj; int i;
|
||||
p = pNtk->pManTime = ABC_ALLOC( Abc_ManTime_t, 1 );
|
||||
memset( p, 0, sizeof(Abc_ManTime_t) );
|
||||
|
|
@ -480,16 +487,49 @@ Abc_ManTime_t * Abc_ManTimeStart( Abc_Ntk_t * pNtk )
|
|||
p->vReqs = Vec_PtrAlloc( 0 );
|
||||
// set default default input=arrivals (assumed to be 0)
|
||||
// set default default output-requireds (can be either 0 or +infinity, based on the flag)
|
||||
p->tReqDef.Rise = fUseZeroDefaultOutputRequired ? 0 : ABC_INFINITY;
|
||||
p->tReqDef.Fall = fUseZeroDefaultOutputRequired ? 0 : ABC_INFINITY;
|
||||
|
||||
// extend manager
|
||||
Abc_ManTimeExpand( p, Abc_NtkObjNumMax(pNtk) + 1, 0 );
|
||||
// set the default timing for CIs
|
||||
Abc_NtkForEachCi( pNtk, pObj, i )
|
||||
Abc_NtkTimeSetArrival( pNtk, Abc_ObjId(pObj), p->tArrDef.Rise, p->tArrDef.Rise );
|
||||
// set the default timing for COs
|
||||
Abc_NtkForEachCo( pNtk, pObj, i )
|
||||
Abc_NtkTimeSetRequired( pNtk, Abc_ObjId(pObj), p->tReqDef.Rise, p->tReqDef.Rise );
|
||||
Abc_NtkForEachCi( pNtk, pObj, i ){
|
||||
|
||||
//get the constrained value, if there is one
|
||||
Vec_Ptr_t * vTimes;
|
||||
vTimes = pNtk->pManTime->vArrs;
|
||||
pTime = (Abc_Time_t *)vTimes->pArray[Abc_ObjId(pObj)];
|
||||
//unconstrained arrival defaults. Note that
|
||||
//unconstrained value in vTimes set to -ABC_INFINITY.
|
||||
if (pTime &&
|
||||
(!(p-> tArrDef.Fall == -ABC_INFINITY ||
|
||||
p-> tArrDef.Rise != -ABC_INFINITY ))
|
||||
){
|
||||
p->tArrDef.Fall = pTime -> Fall;
|
||||
p->tArrDef.Rise = pTime -> Rise;
|
||||
}
|
||||
else {
|
||||
//use the default arrival time 0 (implicit in memset 0, above).
|
||||
p->tArrDef.Rise = 0;
|
||||
p->tArrDef.Fall = 0;
|
||||
}
|
||||
Abc_NtkTimeSetArrival( pNtk, Abc_ObjId(pObj), p->tArrDef.Rise, p->tArrDef.Rise );
|
||||
}
|
||||
|
||||
|
||||
Abc_NtkForEachCo( pNtk, pObj, i ){
|
||||
Vec_Ptr_t * vTimes;
|
||||
vTimes = pNtk->pManTime->vArrs;
|
||||
pTime = (Abc_Time_t *)vTimes->pArray[Abc_ObjId(pObj)];
|
||||
if (pTime){
|
||||
p->tReqDef.Fall = pTime -> Fall;
|
||||
p->tReqDef.Rise = pTime -> Rise;
|
||||
}
|
||||
else{
|
||||
//use the default
|
||||
p->tReqDef.Rise = fUseZeroDefaultOutputRequired ? 0 : ABC_INFINITY;
|
||||
p->tReqDef.Fall = fUseZeroDefaultOutputRequired ? 0 : ABC_INFINITY;
|
||||
}
|
||||
Abc_NtkTimeSetRequired( pNtk, Abc_ObjId(pObj), p->tReqDef.Rise, p->tReqDef.Rise );
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
|
|
@ -571,6 +611,8 @@ void Abc_ManTimeDup( Abc_Ntk_t * pNtkOld, Abc_Ntk_t * pNtkNew )
|
|||
pNtkNew->pManTime->tOutLoad = ABC_ALLOC( Abc_Time_t, Abc_NtkCiNum(pNtkOld) );
|
||||
memcpy( pNtkNew->pManTime->tOutLoad, pNtkOld->pManTime->tOutLoad, sizeof(Abc_Time_t) * Abc_NtkCoNum(pNtkOld) );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ Abc_Ntk_t * Abc_NtkConstructExdc( DdManager * dd, Abc_Ntk_t * pNtk, DdNode * bUn
|
|||
Abc_NtkLogicMakeSimpleCos( pNtkNew, 0 );
|
||||
|
||||
// transform the network to the SOP representation
|
||||
if ( !Abc_NtkBddToSop( pNtkNew, -1, ABC_INFINITY ) )
|
||||
if ( !Abc_NtkBddToSop( pNtkNew, -1, ABC_INFINITY, 1 ) )
|
||||
{
|
||||
printf( "Abc_NtkConstructExdc(): Converting to SOPs has failed.\n" );
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -781,6 +781,8 @@ void Abc_NtkVerifyReportError( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int * pMode
|
|||
Abc_NtkForEachCi( pNtk1, pNode, i )
|
||||
pNode->pCopy = (Abc_Obj_t *)(ABC_PTRINT_T)i;
|
||||
// print the model
|
||||
if ( Vec_PtrSize(vNodes) )
|
||||
{
|
||||
pNode = (Abc_Obj_t *)Vec_PtrEntry( vNodes, 0 );
|
||||
if ( Abc_ObjIsCi(pNode) )
|
||||
{
|
||||
|
|
@ -790,6 +792,7 @@ void Abc_NtkVerifyReportError( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int * pMode
|
|||
printf( " %s=%d", Abc_ObjName(pNode), pModel[(int)(ABC_PTRINT_T)pNode->pCopy] );
|
||||
}
|
||||
}
|
||||
}
|
||||
printf( "\n" );
|
||||
Vec_PtrFree( vNodes );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1019,6 +1019,12 @@ static inline void Acb_ManPrintStats( Acb_Man_t * p, int nModules, int fVerbose
|
|||
extern Vec_Int_t * Acb_ObjCollectTfi( Acb_Ntk_t * p, int iObj, int fTerm );
|
||||
extern Vec_Int_t * Acb_ObjCollectTfo( Acb_Ntk_t * p, int iObj, int fTerm );
|
||||
|
||||
extern Vec_Int_t * Acb_ObjCollectTfiVec( Acb_Ntk_t * p, Vec_Int_t * vObjs );
|
||||
extern Vec_Int_t * Acb_ObjCollectTfoVec( Acb_Ntk_t * p, Vec_Int_t * vObjs );
|
||||
extern int Acb_NtkCountPiBuffers( Acb_Ntk_t * p, Vec_Int_t * vObjs );
|
||||
extern int Acb_NtkCountPoDrivers( Acb_Ntk_t * p, Vec_Int_t * vObjs );
|
||||
extern int Acb_NtkFindMffcSize( Acb_Ntk_t * p, Vec_Int_t * vObjsRefed, Vec_Int_t * vObjsDerefed, int nGates[5] );
|
||||
|
||||
extern int Acb_ObjComputeLevelD( Acb_Ntk_t * p, int iObj );
|
||||
extern int Acb_NtkComputeLevelD( Acb_Ntk_t * p, Vec_Int_t * vTfo );
|
||||
extern void Acb_NtkUpdateLevelD( Acb_Ntk_t * p, int iObj );
|
||||
|
|
|
|||
|
|
@ -35,8 +35,6 @@ ABC_NAMESPACE_IMPL_START
|
|||
/// DECLARATIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define ACB_LAST_NAME_ID 14
|
||||
|
||||
typedef enum {
|
||||
ACB_NONE = 0, // 0: unused
|
||||
ACB_MODULE, // 1: "module"
|
||||
|
|
@ -52,6 +50,8 @@ typedef enum {
|
|||
ACB_NOR, // 11: "nor"
|
||||
ACB_XOR, // 12: "xor"
|
||||
ACB_XNOR, // 13: "xnor"
|
||||
ACB_MUX, // 14: "_HMUX"
|
||||
ACB_DC, // 15: "_DC"
|
||||
ACB_UNUSED // 14: unused
|
||||
} Acb_KeyWords_t;
|
||||
|
||||
|
|
@ -70,6 +70,8 @@ static inline char * Acb_Num2Name( int i )
|
|||
if ( i == 11 ) return "nor";
|
||||
if ( i == 12 ) return "xor";
|
||||
if ( i == 13 ) return "xnor";
|
||||
if ( i == 14 ) return "_HMUX";
|
||||
if ( i == 15 ) return "_DC";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -83,6 +85,8 @@ static inline int Acb_Type2Oper( int i )
|
|||
if ( i == 11 ) return ABC_OPER_BIT_NOR;
|
||||
if ( i == 12 ) return ABC_OPER_BIT_XOR;
|
||||
if ( i == 13 ) return ABC_OPER_BIT_NXOR;
|
||||
if ( i == 14 ) return ABC_OPER_BIT_MUX;
|
||||
if ( i == 15 ) return ABC_OPER_TRI;
|
||||
assert( 0 );
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -91,6 +95,7 @@ static inline char * Acb_Oper2Name( int i )
|
|||
{
|
||||
if ( i == ABC_OPER_CONST_F ) return "const0";
|
||||
if ( i == ABC_OPER_CONST_T ) return "const1";
|
||||
if ( i == ABC_OPER_CONST_X ) return "constX";
|
||||
if ( i == ABC_OPER_BIT_BUF ) return "buf";
|
||||
if ( i == ABC_OPER_BIT_INV ) return "not";
|
||||
if ( i == ABC_OPER_BIT_AND ) return "and";
|
||||
|
|
@ -99,6 +104,8 @@ static inline char * Acb_Oper2Name( int i )
|
|||
if ( i == ABC_OPER_BIT_NOR ) return "nor";
|
||||
if ( i == ABC_OPER_BIT_XOR ) return "xor";
|
||||
if ( i == ABC_OPER_BIT_NXOR ) return "xnor";
|
||||
if ( i == ABC_OPER_BIT_MUX ) return "mux";
|
||||
if ( i == ABC_OPER_TRI ) return "_DC";
|
||||
assert( 0 );
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -138,15 +145,28 @@ char * pLibStr[25] = {
|
|||
"GATE zero 0 O=CONST0;\n"
|
||||
"GATE one 0 O=CONST1;\n"
|
||||
};
|
||||
void Acb_IntallLibrary()
|
||||
char * pLibStr2[25] = {
|
||||
"GATE buf 1 O=a; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
|
||||
"GATE inv 1 O=!a; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
|
||||
"GATE and2 1 O=a*b; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
|
||||
"GATE or2 1 O=a+b; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
|
||||
"GATE nand2 1 O=!(a*b); PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
|
||||
"GATE nor2 1 O=!(a+b); PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
|
||||
"GATE xor 1 O=!a*b+a*!b; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
|
||||
"GATE xnor 1 O=a*b+!a*!b; PIN * INV 1 999 1.0 0.0 1.0 0.0\n"
|
||||
"GATE zero 0 O=CONST0;\n"
|
||||
"GATE one 0 O=CONST1;\n"
|
||||
};
|
||||
void Acb_IntallLibrary( int f2Ins )
|
||||
{
|
||||
extern Mio_Library_t * Mio_LibraryReadBuffer( char * pBuffer, int fExtendedFormat, st__table * tExcludeGate, int fVerbose );
|
||||
Mio_Library_t * pLib;
|
||||
int i;
|
||||
// create library string
|
||||
Vec_Str_t * vLibStr = Vec_StrAlloc( 1000 );
|
||||
for ( i = 0; pLibStr[i]; i++ )
|
||||
Vec_StrAppend( vLibStr, pLibStr[i] );
|
||||
char ** ppLibStr = f2Ins ? pLibStr2 : pLibStr;
|
||||
for ( i = 0; ppLibStr[i]; i++ )
|
||||
Vec_StrAppend( vLibStr, ppLibStr[i] );
|
||||
Vec_StrPush( vLibStr, '\0' );
|
||||
// create library
|
||||
pLib = Mio_LibraryReadBuffer( Vec_StrArray(vLibStr), 0, NULL, 0 );
|
||||
|
|
@ -190,17 +210,78 @@ Vec_Int_t * Acb_VerilogSimpleLex( char * pFileName, Abc_Nam_t * pNames )
|
|||
Vec_Int_t * vBuffer = Vec_IntAlloc( 1000 );
|
||||
char * pBuffer = Extra_FileReadContents( pFileName );
|
||||
char * pToken, * pStart, * pLimit = pBuffer + strlen(pBuffer);
|
||||
int i, iToken, RLeft = -1, RRight = -1;
|
||||
if ( pBuffer == NULL )
|
||||
return NULL;
|
||||
Acb_VerilogRemoveComments( pBuffer );
|
||||
pToken = strtok( pBuffer, " \n\r\t(),;=" );
|
||||
while ( pToken )
|
||||
{
|
||||
int iToken = Abc_NamStrFindOrAdd( pNames, pToken, NULL );
|
||||
if ( 0 )
|
||||
{
|
||||
if ( !strcmp(pToken, "assign") )
|
||||
{
|
||||
int fBuffer = 0;
|
||||
int nToks = 0, pToks[4];
|
||||
while ( 1 )
|
||||
{
|
||||
pToken = strtok( NULL, " \n\r\t(),=~&" );
|
||||
if ( pToken[0] == ';' )
|
||||
break;
|
||||
if ( pToken[strlen(pToken)-1] == ';' )
|
||||
{
|
||||
pToken[strlen(pToken)-1] = 0;
|
||||
assert( nToks < 3 );
|
||||
pToks[nToks++] = Abc_NamStrFindOrAdd( pNames, pToken, NULL );
|
||||
fBuffer = 1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert( nToks < 3 );
|
||||
pToks[nToks++] = Abc_NamStrFindOrAdd( pNames, pToken, NULL );
|
||||
}
|
||||
}
|
||||
assert( nToks == 2 || nToks == 3 );
|
||||
Vec_IntPush( vBuffer, fBuffer ? ACB_AND : ACB_NAND );
|
||||
Vec_IntPush( vBuffer, pToks[0] );
|
||||
Vec_IntPush( vBuffer, pToks[1] );
|
||||
Vec_IntPush( vBuffer, nToks == 3 ? pToks[2] : pToks[1] );
|
||||
pToken = strtok( NULL, " \n\r\t(),;=" );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ( pToken[0] == '[' )
|
||||
{
|
||||
assert( RLeft == -1 );
|
||||
RLeft = atoi(pToken+1);
|
||||
RRight = atoi(strstr(pToken,":")+1);
|
||||
pToken = strtok( NULL, " \n\r\t(),;=" );
|
||||
continue;
|
||||
}
|
||||
if ( pToken[0] == '\\' )
|
||||
pToken++;
|
||||
if ( !strcmp(pToken, "assign") )
|
||||
Vec_IntPush( vBuffer, ACB_BUF );
|
||||
iToken = ACB_BUF;
|
||||
else
|
||||
Vec_IntPush( vBuffer, iToken );
|
||||
iToken = Abc_NamStrFindOrAdd( pNames, pToken, NULL );
|
||||
if ( iToken < ACB_UNUSED )
|
||||
RLeft = RRight = -1;
|
||||
else if ( RLeft != -1 )
|
||||
{
|
||||
char Buffer[1000];
|
||||
assert( strlen(pToken) < 990 );
|
||||
for ( i = RRight; i <= RLeft; i++ )
|
||||
{
|
||||
sprintf( Buffer, "%s[%d]", pToken, i );
|
||||
iToken = Abc_NamStrFindOrAdd( pNames, Buffer, NULL );
|
||||
Vec_IntPush( vBuffer, iToken );
|
||||
}
|
||||
pToken = strtok( NULL, " \n\r\t(),;=" );
|
||||
continue;
|
||||
}
|
||||
Vec_IntPush( vBuffer, iToken );
|
||||
if ( iToken >= ACB_BUF && iToken < ACB_UNUSED )
|
||||
{
|
||||
for ( pStart = pToken; pStart < pLimit && *pStart != '\n'; pStart++ )
|
||||
|
|
@ -245,14 +326,11 @@ void * Acb_VerilogSimpleParse( Vec_Int_t * vBuffer, Abc_Nam_t * pNames )
|
|||
vCur = vOutputs;
|
||||
else if ( Token == ACB_WIRE )
|
||||
vCur = vWires;
|
||||
else if ( Token >= ACB_BUF && Token <= ACB_XNOR )
|
||||
else if ( Token >= ACB_BUF && Token < ACB_UNUSED )
|
||||
{
|
||||
//char * pToken = Abc_NamStr(pNames, Vec_IntEntry(vBuffer, i+1));
|
||||
Vec_IntPush( vTypes, Token );
|
||||
Vec_IntPush( vTypes, Vec_IntSize(vFanins) );
|
||||
vCur = vFanins;
|
||||
//if ( pToken[1] == 'z' && pToken[2] == '_' && pToken[3] == 'g' && pToken[4] == '_' )
|
||||
// i++;
|
||||
}
|
||||
else
|
||||
Vec_IntPush( vCur, Token );
|
||||
|
|
@ -288,6 +366,8 @@ void * Acb_VerilogSimpleParse( Vec_Int_t * vBuffer, Abc_Nam_t * pNames )
|
|||
Ndr_AddObject( pDesign, ModuleID, ABC_OPER_CONST_F, 0, 0, 0, 0, 0, NULL, 1, &Token, NULL ); // no fanins
|
||||
if ( (Token = Abc_NamStrFind(pNames, "1\'b1")) )
|
||||
Ndr_AddObject( pDesign, ModuleID, ABC_OPER_CONST_T, 0, 0, 0, 0, 0, NULL, 1, &Token, NULL ); // no fanins
|
||||
if ( (Token = Abc_NamStrFind(pNames, "1\'bx")) )
|
||||
Ndr_AddObject( pDesign, ModuleID, ABC_OPER_CONST_X, 0, 0, 0, 0, 0, NULL, 1, &Token, NULL ); // no fanins
|
||||
Vec_IntForEachEntryDouble( vTypes, Token, Size, i )
|
||||
if ( Token > 0 )
|
||||
{
|
||||
|
|
@ -307,6 +387,182 @@ void * Acb_VerilogSimpleParse( Vec_Int_t * vBuffer, Abc_Nam_t * pNames )
|
|||
return pDesign;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Gia_FileSimpleParse_rec( Gia_Man_t * pNew, int Token, Vec_Int_t * vMapType, Vec_Int_t * vTypes, Vec_Int_t * vFanins, Vec_Int_t * vMap )
|
||||
{
|
||||
int nFanins, * pFanins, pLits[16];
|
||||
int i, Type, Size, Place = Vec_IntEntry( vMapType, Token );
|
||||
int iLit = Vec_IntEntry( vMap, Token );
|
||||
if ( iLit >= 0 )
|
||||
return iLit;
|
||||
Place = Vec_IntEntry( vMapType, Token );
|
||||
assert( Place >= 0 );
|
||||
Type = Vec_IntEntry( vTypes, Place );
|
||||
Size = Vec_IntEntry( vTypes, Place+1 );
|
||||
nFanins = Vec_IntEntry(vTypes, Place+3) - Size - 1;
|
||||
pFanins = Vec_IntEntryP(vFanins, Size+1);
|
||||
assert( nFanins > 0 && nFanins < 16 );
|
||||
for ( i = 0; i < nFanins; i++ )
|
||||
Gia_FileSimpleParse_rec( pNew, pFanins[i], vMapType, vTypes, vFanins, vMap );
|
||||
for ( i = 0; i < nFanins; i++ )
|
||||
pLits[i] = Vec_IntEntry( vMap, pFanins[i] );
|
||||
if ( nFanins == 1 )
|
||||
{
|
||||
assert( Type == ACB_BUF || Type == ACB_NOT );
|
||||
iLit = Abc_LitNotCond( pLits[0], Type == ACB_NOT );
|
||||
iLit = Gia_ManAppendAnd2( pNew, iLit, iLit );
|
||||
}
|
||||
else
|
||||
{
|
||||
iLit = pLits[0];
|
||||
if ( Type == ACB_AND || Type == ACB_NAND )
|
||||
for ( i = 1; i < nFanins; i++ )
|
||||
iLit = Gia_ManAppendAnd2( pNew, iLit, pLits[i] );
|
||||
else if ( Type == ACB_OR || Type == ACB_NOR )
|
||||
for ( i = 1; i < nFanins; i++ )
|
||||
iLit = Gia_ManAppendOr2( pNew, iLit, pLits[i] );
|
||||
else if ( Type == ACB_XOR || Type == ACB_XNOR )
|
||||
for ( i = 1; i < nFanins; i++ )
|
||||
iLit = Gia_ManAppendXor2( pNew, iLit, pLits[i] );
|
||||
else assert( 0 );
|
||||
iLit = Abc_LitNotCond( iLit, (Type == ACB_NAND || Type == ACB_NOR || Type == ACB_XNOR) );
|
||||
}
|
||||
Vec_IntWriteEntry( vMap, Token, iLit );
|
||||
return iLit;
|
||||
}
|
||||
Gia_Man_t * Gia_FileSimpleParse( Vec_Int_t * vBuffer, Abc_Nam_t * pNames, int fNames, char * pFileW )
|
||||
{
|
||||
Gia_Man_t * pNew = NULL;
|
||||
Vec_Int_t * vInputs = Vec_IntAlloc(100);
|
||||
Vec_Int_t * vOutputs = Vec_IntAlloc(100);
|
||||
Vec_Int_t * vWires = Vec_IntAlloc(100);
|
||||
Vec_Int_t * vTypes = Vec_IntAlloc(100);
|
||||
Vec_Int_t * vFanins = Vec_IntAlloc(100);
|
||||
Vec_Int_t * vCur = NULL;
|
||||
Vec_Int_t * vMap = Vec_IntStartFull( Abc_NamObjNumMax(pNames) );
|
||||
Vec_Int_t * vMapType = Vec_IntStartFull( Abc_NamObjNumMax(pNames) );
|
||||
int i, iLit, Token, Size;
|
||||
char Buffer[1000];
|
||||
assert( Vec_IntEntry(vBuffer, 0) == ACB_MODULE );
|
||||
Vec_IntForEachEntryStart( vBuffer, Token, i, 2 )
|
||||
{
|
||||
if ( vCur == NULL && Token >= ACB_UNUSED )
|
||||
continue;
|
||||
if ( Token == ACB_ENDMODULE )
|
||||
break;
|
||||
if ( Token == ACB_INPUT )
|
||||
vCur = vInputs;
|
||||
else if ( Token == ACB_OUTPUT )
|
||||
vCur = vOutputs;
|
||||
else if ( Token == ACB_WIRE )
|
||||
vCur = vWires;
|
||||
else if ( Token >= ACB_BUF && Token < ACB_UNUSED )
|
||||
{
|
||||
Vec_IntPush( vTypes, Token );
|
||||
Vec_IntPush( vTypes, Vec_IntSize(vFanins) );
|
||||
vCur = vFanins;
|
||||
}
|
||||
else if ( pFileW && vCur == vWires && Abc_NamStr(pNames, Token)[0] == 't' )
|
||||
Vec_IntPush( vInputs, Token );
|
||||
else
|
||||
Vec_IntPush( vCur, Token );
|
||||
}
|
||||
Vec_IntPush( vTypes, -1 );
|
||||
Vec_IntPush( vTypes, Vec_IntSize(vFanins) );
|
||||
// map types
|
||||
Vec_IntForEachEntryDouble( vTypes, Token, Size, i )
|
||||
if ( Token > 0 )
|
||||
Vec_IntWriteEntry( vMapType, Vec_IntEntry(vFanins, Size), i );
|
||||
// create design
|
||||
pNew = Gia_ManStart( 10000 );
|
||||
pNew->pName = Abc_UtilStrsav( Abc_NamStr(pNames, Vec_IntEntry(vBuffer, 1)) );
|
||||
pNew->fGiaSimple = 1;
|
||||
if ( (Token = Abc_NamStrFind(pNames, "1\'b0")) )
|
||||
Vec_IntWriteEntry( vMap, Token, 0 );
|
||||
if ( (Token = Abc_NamStrFind(pNames, "1\'b1")) )
|
||||
Vec_IntWriteEntry( vMap, Token, 1 );
|
||||
if ( (Token = Abc_NamStrFind(pNames, "1\'bx")) )
|
||||
Vec_IntWriteEntry( vMap, Token, 0 );
|
||||
if ( (Token = Abc_NamStrFind(pNames, "1\'bz")) )
|
||||
Vec_IntWriteEntry( vMap, Token, 0 );
|
||||
Vec_IntForEachEntry( vInputs, Token, i )
|
||||
Gia_ManAppendCi(pNew);
|
||||
Vec_IntForEachEntry( vInputs, Token, i )
|
||||
Vec_IntWriteEntry( vMap, Token, Gia_ManAppendAnd2(pNew, Gia_ManCiLit(pNew, i), Gia_ManCiLit(pNew, i)) );
|
||||
Vec_IntForEachEntry( vOutputs, Token, i )
|
||||
Gia_FileSimpleParse_rec( pNew, Token, vMapType, vTypes, vFanins, vMap );
|
||||
Vec_IntForEachEntry( vOutputs, Token, i )
|
||||
Gia_ManAppendCo( pNew, Vec_IntEntry(vMap, Token) );
|
||||
// create names
|
||||
if ( fNames )
|
||||
{
|
||||
pNew->vPolars = Vec_BitStart( Gia_ManObjNum(pNew) );
|
||||
pNew->vNamesNode = Vec_PtrStart( Gia_ManObjNum(pNew) );
|
||||
Vec_IntForEachEntry( vMap, iLit, Token )
|
||||
{
|
||||
if ( iLit == -1 || !Gia_ObjIsAnd(Gia_ManObj(pNew, Abc_Lit2Var(iLit))) )
|
||||
continue;
|
||||
sprintf( Buffer, "%c_%s", Abc_LitIsCompl(iLit) ? 'c' : 'd', Abc_NamStr(pNames, Token) );
|
||||
assert( Vec_PtrEntry(pNew->vNamesNode, Abc_Lit2Var(iLit)) == NULL );
|
||||
Vec_PtrWriteEntry( pNew->vNamesNode, Abc_Lit2Var(iLit), Abc_UtilStrsav(Buffer) );
|
||||
Vec_BitWriteEntry( pNew->vPolars, Abc_Lit2Var(iLit), Abc_LitIsCompl(iLit) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Gia_Man_t * pTemp;
|
||||
pNew = Gia_ManDupDfsRehash( pTemp = pNew );
|
||||
Gia_ManStop( pTemp );
|
||||
}
|
||||
pNew->vNamesIn = Vec_PtrAlloc( Vec_IntSize(vInputs) );
|
||||
Vec_IntForEachEntry( vInputs, Token, i )
|
||||
Vec_PtrPush( pNew->vNamesIn, Abc_UtilStrsav(Abc_NamStr(pNames, Token)) );
|
||||
pNew->vNamesOut = Vec_PtrAlloc( Vec_IntSize(vOutputs) );
|
||||
Vec_IntForEachEntry( vOutputs, Token, i )
|
||||
Vec_PtrPush( pNew->vNamesOut, Abc_UtilStrsav(Abc_NamStr(pNames, Token)) );
|
||||
if ( pFileW && fNames )
|
||||
{
|
||||
extern Vec_Int_t * Acb_ReadWeightMap( char * pFileName, Abc_Nam_t * pNames );
|
||||
Vec_Int_t * vT2W = Acb_ReadWeightMap( pFileW, pNames );
|
||||
assert( pNew->vWeights == NULL );
|
||||
pNew->vWeights = Vec_IntStartFull( Gia_ManObjNum(pNew) );
|
||||
Vec_IntForEachEntry( vMap, iLit, Token )
|
||||
if ( iLit != -1 && Vec_IntEntry(vT2W, Token) != -1 )
|
||||
Vec_IntWriteEntry( pNew->vWeights, Abc_Lit2Var(iLit), Vec_IntEntry(vT2W, Token) );
|
||||
Vec_IntFree( vT2W );
|
||||
}
|
||||
// cleanup
|
||||
Vec_IntFree( vInputs );
|
||||
Vec_IntFree( vOutputs );
|
||||
Vec_IntFree( vWires );
|
||||
Vec_IntFree( vTypes );
|
||||
Vec_IntFree( vFanins );
|
||||
Vec_IntFree( vMap );
|
||||
Vec_IntFree( vMapType );
|
||||
return pNew;
|
||||
}
|
||||
Gia_Man_t * Gia_FileSimpleRead( char * pFileName, int fNames, char * pFileW )
|
||||
{
|
||||
Abc_Nam_t * pNames = Acb_VerilogStartNames();
|
||||
Vec_Int_t * vBuffer = Acb_VerilogSimpleLex( pFileName, pNames );
|
||||
Gia_Man_t * pNew = vBuffer ? Gia_FileSimpleParse( vBuffer, pNames, fNames, pFileW ) : NULL;
|
||||
assert( pNew->pSpec == NULL );
|
||||
pNew->pSpec = Abc_UtilStrsav( pFileName );
|
||||
Abc_NamDeref( pNames );
|
||||
Vec_IntFree( vBuffer );
|
||||
return pNew;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Read weights of nodes from the weight file.]
|
||||
|
|
@ -355,10 +611,18 @@ Vec_Int_t * Acb_ReadWeightMap( char * pFileName, Abc_Nam_t * pNames )
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
char ** Acb_PrepareNames( Abc_Nam_t * p )
|
||||
{
|
||||
char ** ppRes = ABC_CALLOC( char *, Abc_NamObjNumMax(p) );
|
||||
int i;
|
||||
for ( i = 0; i < Abc_NamObjNumMax(p); i++ )
|
||||
ppRes[i] = Abc_NamStr( p, i );
|
||||
return ppRes;
|
||||
}
|
||||
Acb_Ntk_t * Acb_VerilogSimpleRead( char * pFileName, char * pFileNameW )
|
||||
{
|
||||
extern Acb_Ntk_t * Acb_NtkFromNdr( char * pFileName, void * pModule, Abc_Nam_t * pNames, Vec_Int_t * vWeights, int nNameIdMax );
|
||||
Acb_Ntk_t * pNtk;
|
||||
Acb_Ntk_t * pNtk;
|
||||
Abc_Nam_t * pNames = Acb_VerilogStartNames();
|
||||
Vec_Int_t * vBuffer = Acb_VerilogSimpleLex( pFileName, pNames );
|
||||
void * pModule = vBuffer ? Acb_VerilogSimpleParse( vBuffer, pNames ) : NULL;
|
||||
|
|
@ -373,7 +637,12 @@ Acb_Ntk_t * Acb_VerilogSimpleRead( char * pFileName, char * pFileNameW )
|
|||
printf( "Cannot read weight file \"%s\".\n", pFileNameW );
|
||||
return NULL;
|
||||
}
|
||||
// Ndr_ModuleWriteVerilog( "iccad17/unit1/test.v", pModule, pNameStrs );
|
||||
if ( 0 )
|
||||
{
|
||||
char ** ppNames = Acb_PrepareNames(pNames);
|
||||
Ndr_WriteVerilog( Extra_FileNameGenericAppend(pFileName, "_ndr.v"), pModule, ppNames, 1 );
|
||||
ABC_FREE( ppNames );
|
||||
}
|
||||
pNtk = Acb_NtkFromNdr( pFileName, pModule, pNames, vWeights, Abc_NamObjNumMax(pNames) );
|
||||
Ndr_Delete( pModule );
|
||||
Vec_IntFree( vBuffer );
|
||||
|
|
@ -381,6 +650,11 @@ Acb_Ntk_t * Acb_VerilogSimpleRead( char * pFileName, char * pFileNameW )
|
|||
Abc_NamDeref( pNames );
|
||||
return pNtk;
|
||||
}
|
||||
void Acb_VerilogSimpleReadTest( char * pFileName )
|
||||
{
|
||||
Acb_Ntk_t * p = Acb_VerilogSimpleRead( pFileName, NULL );
|
||||
Acb_NtkFree( p );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
|
|
@ -440,7 +714,10 @@ void Acb_VerilogSimpleWrite( Acb_Ntk_t * p, char * pFileName )
|
|||
{
|
||||
assert( Acb_ObjType(p, iObj) == ABC_OPER_CONST_F || Acb_ObjType(p, iObj) == ABC_OPER_CONST_T );
|
||||
fprintf( pFile, " %s (", Acb_Oper2Name( ABC_OPER_BIT_BUF ) );
|
||||
fprintf( pFile, " 1\'b%d", Acb_ObjType(p, iObj) == ABC_OPER_CONST_T );
|
||||
if ( Acb_ObjType(p, iObj) == ABC_OPER_CONST_X )
|
||||
fprintf( pFile, " 1\'bx" );
|
||||
else
|
||||
fprintf( pFile, " 1\'b%d", Acb_ObjType(p, iObj) == ABC_OPER_CONST_T );
|
||||
fprintf( pFile, " );\n" );
|
||||
}
|
||||
|
||||
|
|
@ -579,12 +856,18 @@ Vec_Int_t * Acb_NtkFindDivsCis( Acb_Ntk_t * p, Vec_Int_t * vSupp )
|
|||
printf( "Divisors are %d support variables (CIs in the TFO of the targets).\n", Vec_IntSize(vSupp) );
|
||||
return vDivs;
|
||||
}
|
||||
Vec_Int_t * Acb_NtkFindDivs( Acb_Ntk_t * p, Vec_Int_t * vSupp, Vec_Bit_t * vBlock, int fVerbose )
|
||||
Vec_Int_t * Acb_NtkFindDivs( Acb_Ntk_t * p, Vec_Int_t * vSupp, Vec_Bit_t * vBlock, int fUnitW, int fVerbose )
|
||||
{
|
||||
int fPrintWeights = 0;
|
||||
int nDivLimit = 5000;
|
||||
int i, iObj;
|
||||
Vec_Int_t * vDivs = Vec_IntAlloc( 1000 );
|
||||
if ( fUnitW )
|
||||
{
|
||||
Acb_NtkForEachNode( p, iObj )
|
||||
if ( Acb_ObjWeight(p, iObj) > 0 )
|
||||
Vec_IntWriteEntry( &p->vObjWeight, iObj, 1 );
|
||||
}
|
||||
// mark inputs
|
||||
Acb_NtkIncTravId( p );
|
||||
Acb_NtkForEachCiVec( vSupp, p, iObj, i )
|
||||
|
|
@ -754,6 +1037,31 @@ Gia_Man_t * Acb_NtkToGia( Acb_Ntk_t * p, Vec_Int_t * vSupp, Vec_Int_t * vNodes,
|
|||
Gia_ManStop( pOne );
|
||||
return pNew;
|
||||
}
|
||||
int Acb_NtkSaveNames( Acb_Ntk_t * p, Vec_Int_t * vSupp, Vec_Int_t * vNodes, Vec_Int_t * vRoots, Vec_Int_t * vDivs, Vec_Int_t * vTargets, Gia_Man_t * pNew )
|
||||
{
|
||||
int i, iObj;
|
||||
assert( pNew->vNamesIn == NULL );
|
||||
|
||||
pNew->vNamesIn = Vec_PtrAlloc( Gia_ManCiNum(pNew) );
|
||||
Acb_NtkForEachCiVec( vSupp, p, iObj, i )
|
||||
Vec_PtrPush( pNew->vNamesIn, Abc_UtilStrsav(Acb_ObjNameStr(p, iObj)) );
|
||||
if ( vTargets )
|
||||
Vec_IntForEachEntry( vTargets, iObj, i )
|
||||
Vec_PtrPush( pNew->vNamesIn, Abc_UtilStrsav(Acb_ObjNameStr(p, iObj)) );
|
||||
|
||||
pNew->vNamesOut = Vec_PtrAlloc( Gia_ManCoNum(pNew) );
|
||||
Acb_NtkForEachCoDriverVec( vRoots, p, iObj, i )
|
||||
Vec_PtrPush( pNew->vNamesOut, Abc_UtilStrsav(Acb_ObjNameStr(p, iObj)) );
|
||||
if ( vDivs )
|
||||
Vec_IntForEachEntry( vDivs, iObj, i )
|
||||
{
|
||||
char Buffer[100];
|
||||
assert( strlen(Acb_ObjNameStr(p, iObj)) < 90 );
|
||||
sprintf( Buffer, "%s_%d", Acb_ObjNameStr(p, iObj), Acb_ObjWeight(p, iObj) );
|
||||
Vec_PtrPush( pNew->vNamesOut, Abc_UtilStrsav(Buffer) );
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
|
|
@ -825,6 +1133,21 @@ void Vec_IntPermute( Vec_Int_t * p )
|
|||
}
|
||||
}
|
||||
|
||||
void Vec_IntPermute2( Vec_Int_t * p )
|
||||
{
|
||||
int i, nSize = Vec_IntSize( p );
|
||||
int * pArray = Vec_IntArray( p );
|
||||
srand( time(NULL) );
|
||||
for ( i = 0; i < nSize-1; i++ )
|
||||
{
|
||||
if ( rand() % 3 == 0 )
|
||||
{
|
||||
printf( "Permuting %d and %d\n", i, i+1 );
|
||||
ABC_SWAP( int, pArray[i], pArray[i+1] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Acb_PrintPatterns( Vec_Wrd_t * vPats, int nPats, Vec_Int_t * vWeights )
|
||||
{
|
||||
int i, k, Entry, nDivs = Vec_IntSize(vWeights);
|
||||
|
|
@ -1541,7 +1864,7 @@ char * Acb_EnumerateSatAssigns( sat_solver * pSat, int PivotVar, int FreeVar, Ve
|
|||
{
|
||||
if ( iMint == 1000 )
|
||||
{
|
||||
//if ( Vec_IntSize(vDivVars) == 0 )
|
||||
if ( Vec_IntSize(vDivVars) == 0 )
|
||||
{
|
||||
printf( "Assuming constant 0 function.\n" );
|
||||
Vec_StrClear( vTempSop );
|
||||
|
|
@ -1897,34 +2220,66 @@ Vec_Ptr_t * Acb_GenerateSignalNames( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t
|
|||
Vec_StrFree( vStr );
|
||||
return vRes;
|
||||
}
|
||||
Vec_Int_t * Acb_GetUsedDivs( Vec_Int_t * vDivs, Vec_Int_t * vUsed )
|
||||
{
|
||||
int i, iObj;
|
||||
Vec_Int_t * vRes = Vec_IntAlloc( Vec_IntSize(vUsed) );
|
||||
Vec_IntForEachEntryInVec( vDivs, vUsed, iObj, i )
|
||||
Vec_IntPush( vRes, iObj );
|
||||
return vRes;
|
||||
}
|
||||
Vec_Ptr_t * Acb_SignalNames( Acb_Ntk_t * p, Vec_Int_t * vObjs )
|
||||
{
|
||||
Vec_Ptr_t * vNames = Vec_PtrAlloc( Vec_IntSize(vObjs) );
|
||||
int i, iObj;
|
||||
Vec_IntForEachEntry( vObjs, iObj, i )
|
||||
Vec_PtrPush( vNames, Acb_ObjNameStr(p, iObj) );
|
||||
return vNames;
|
||||
}
|
||||
Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUsed, Vec_Ptr_t * vSops, Vec_Ptr_t * vGias, Vec_Int_t * vTars )
|
||||
{
|
||||
extern int Acb_NtkCollectMfsGates( char * pFileName, Vec_Ptr_t * vNamesRefed, Vec_Ptr_t * vNamesDerefed, int nGates1[5] );
|
||||
extern Vec_Wec_t * Abc_SopSynthesize( Vec_Ptr_t * vSops );
|
||||
extern Vec_Wec_t * Abc_GiaSynthesize( Vec_Ptr_t * vGias, Gia_Man_t * pMulti );
|
||||
Vec_Wec_t * vGates = vGias ? Abc_GiaSynthesize(vGias, NULL) : Abc_SopSynthesize(vSops); Vec_Int_t * vGate;
|
||||
int nOuts = vGias ? Vec_PtrSize(vGias) : Vec_PtrSize(vSops);
|
||||
int i, k, iObj, nWires = Vec_WecSize(vGates) - Vec_IntSize(vUsed) - nOuts, fFirst = 1;
|
||||
int nGates1[5] = {0}, nGates0[5] = {0};
|
||||
Vec_Ptr_t * vNames = Acb_GenerateSignalNames( p, vDivs, vUsed, nWires, vTars, vGates );
|
||||
Vec_Str_t * vStr = Vec_StrAlloc( 100 );
|
||||
|
||||
int nInvs = 0, nBufs = 0, nNodes = 0, nConst = 0;
|
||||
Vec_Int_t * vSup = Acb_GetUsedDivs( vDivs, vUsed );
|
||||
Vec_Ptr_t * vSpN = Acb_SignalNames( p, vSup );
|
||||
Vec_Int_t * vTfi = Acb_ObjCollectTfiVec( p, vSup );
|
||||
Vec_Int_t * vTfo = Acb_ObjCollectTfoVec( p, vTars );
|
||||
int nPiCount = Acb_NtkCountPiBuffers( p, vSup );
|
||||
int nPoCount = Acb_NtkCountPoDrivers( p, vTars );
|
||||
int nMffc = Abc_FrameReadSpecName() ? Acb_NtkCollectMfsGates( Abc_FrameReadSpecName(), vSpN, Abc_FrameReadSignalNames(), nGates1 ) : 0;
|
||||
Vec_PtrFree( vSpN );
|
||||
Vec_IntFree( vSup );
|
||||
Vec_WecForEachLevelStartStop( vGates, vGate, i, Vec_IntSize(vUsed), Vec_IntSize(vUsed)+nWires )
|
||||
{
|
||||
if ( Vec_IntSize(vGate) > 2 )
|
||||
{
|
||||
char * pName = Acb_Oper2Name(Vec_IntEntry(vGate, 0));
|
||||
if ( !strcmp(pName, "buf") )
|
||||
nBufs++;
|
||||
nGates0[2]++;
|
||||
else if ( !strcmp(pName, "not") )
|
||||
nInvs++;
|
||||
nGates0[3]++;
|
||||
else
|
||||
nNodes++;
|
||||
nGates0[4] += Vec_IntSize(vGate) - 3;
|
||||
}
|
||||
else
|
||||
nConst++;
|
||||
nGates0[Vec_IntEntry(vGate, 0) == ABC_OPER_CONST_T]++;
|
||||
}
|
||||
Vec_StrPrintF( vStr, "// Patch statistics: in = %d out = %d gate = %d (const = %d buf = %d inv = %d other = %d)\n\n",
|
||||
Vec_IntSize(vUsed), nOuts, nWires, nConst, nBufs, nInvs, nNodes );
|
||||
|
||||
Vec_StrPrintF( vStr, "// Patch : in = %d out = %d : pi_in = %d po_out = %d : tfi = %d tfo = %d\n", Vec_IntSize(vUsed), nOuts, nPiCount, nPoCount, Vec_IntSize(vTfi), Vec_IntSize(vTfo) );
|
||||
Vec_StrPrintF( vStr, "// Added : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires, nGates0[0], nGates0[1], nGates0[2], nGates0[3], nGates0[4] );
|
||||
if ( Abc_FrameReadSpecName() )
|
||||
Vec_StrPrintF( vStr, "// Removed : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nMffc, nGates1[0], nGates1[1], nGates1[2], nGates1[3], nGates1[4] );
|
||||
if ( Abc_FrameReadSpecName() )
|
||||
Vec_StrPrintF( vStr, "// TOTAL : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires-nMffc, nGates0[0]-nGates1[0], nGates0[1]-nGates1[1], nGates0[2]-nGates1[2], nGates0[3]-nGates1[3], nGates0[4]-nGates1[4] );
|
||||
Vec_StrPrintF( vStr, "\n" );
|
||||
|
||||
Vec_StrAppend( vStr, "module patch (" );
|
||||
|
||||
assert( Vec_IntSize(vTars) == nOuts );
|
||||
|
|
@ -1980,8 +2335,17 @@ Vec_Str_t * Acb_GeneratePatch( Acb_Ntk_t * p, Vec_Int_t * vDivs, Vec_Int_t * vUs
|
|||
Vec_PtrFreeFree( vNames );
|
||||
Vec_WecFree( vGates );
|
||||
|
||||
printf( "Synthesized patch with %d inputs, %d outputs and %d gates (const = %d buf = %d inv = %d other = %d).\n",
|
||||
Vec_IntSize(vUsed), nOuts, nWires, nConst, nBufs, nInvs, nNodes );
|
||||
// printf( "Synthesized patch with %d inputs, %d outputs and %d gates (const = %d buf = %d inv = %d other = %d).\n",
|
||||
// Vec_IntSize(vUsed), nOuts, nWires, nConst, nBufs, nInvs, nNodes );
|
||||
// printf( "Summary of the results\n" );
|
||||
printf( "\n" );
|
||||
printf( "Patch : in = %d out = %d : pi_in = %d po_out = %d : tfi = %d tfo = %d\n", Vec_IntSize(vUsed), nOuts, nPiCount, nPoCount, Vec_IntSize(vTfi), Vec_IntSize(vTfo) );
|
||||
printf( "Added : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires, nGates0[0], nGates0[1], nGates0[2], nGates0[3], nGates0[4] );
|
||||
if ( Abc_FrameReadSpecName() )
|
||||
printf( "Removed : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nMffc, nGates1[0], nGates1[1], nGates1[2], nGates1[3], nGates1[4] );
|
||||
if ( Abc_FrameReadSpecName() )
|
||||
printf( "TOTAL : gate =%4d : c0 =%2d c1 =%2d buf =%3d inv =%3d two-input =%4d\n", nWires-nMffc, nGates0[0]-nGates1[0], nGates0[1]-nGates1[1], nGates0[2]-nGates1[2], nGates0[3]-nGates1[3], nGates0[4]-nGates1[4] );
|
||||
printf( "\n" );
|
||||
return vStr;
|
||||
}
|
||||
|
||||
|
|
@ -2040,7 +2404,7 @@ Vec_Str_t * Acb_GeneratePatch2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t *
|
|||
extern Vec_Wec_t * Abc_GiaSynthesize( Vec_Ptr_t * vGias, Gia_Man_t * pMulti );
|
||||
Vec_Wec_t * vGates = Abc_GiaSynthesize( NULL, pGia ); Vec_Int_t * vGate;
|
||||
int nIns = Vec_PtrSize(vIns), nOuts = Vec_PtrSize(vOuts); char * pName;
|
||||
int i, k, iObj, nWires = Vec_WecSize(vGates) - nIns - nOuts, fFirst = 1;
|
||||
int i, k, iObj, nWires = Vec_WecSize(vGates) - nIns - nOuts, nTwoIns = 0, fFirst = 1;
|
||||
Vec_Ptr_t * vNames = Acb_GenerateSignalNames2( vGates, vIns, vOuts );
|
||||
|
||||
Vec_Str_t * vStr = Vec_StrAlloc( 100 );
|
||||
|
|
@ -2049,7 +2413,7 @@ Vec_Str_t * Acb_GeneratePatch2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t *
|
|||
Vec_PtrForEachEntry( char *, vOuts, pName, i )
|
||||
Vec_StrPrintF( vStr, "%s %s", i ? ",":"", pName );
|
||||
Vec_PtrForEachEntry( char *, vIns, pName, i )
|
||||
Vec_StrPrintF( vStr, ", %s", pName );
|
||||
Vec_StrPrintF( vStr, ", %s%s", i ? "":" ", pName );
|
||||
Vec_StrAppend( vStr, " );\n\n" );
|
||||
|
||||
Vec_StrAppend( vStr, " output" );
|
||||
|
|
@ -2071,8 +2435,9 @@ Vec_Str_t * Acb_GeneratePatch2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t *
|
|||
if ( !strncmp(pName, "ww", 2) )
|
||||
Vec_StrPrintF( vStr, "%s %s", fFirst ? "":",", pName ), fFirst = 0;
|
||||
}
|
||||
Vec_StrAppend( vStr, ";\n\n" );
|
||||
Vec_StrAppend( vStr, ";\n" );
|
||||
}
|
||||
Vec_StrAppend( vStr, "\n" );
|
||||
|
||||
// create internal nodes
|
||||
Vec_WecForEachLevelStartStop( vGates, vGate, i, nIns, nIns+nWires )
|
||||
|
|
@ -2083,6 +2448,7 @@ Vec_Str_t * Acb_GeneratePatch2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t *
|
|||
Vec_IntForEachEntryStart( vGate, iObj, k, 1 )
|
||||
Vec_StrPrintF( vStr, "%s %s", k > 1 ? ",":"", (char *)Vec_PtrEntry(vNames, iObj) );
|
||||
Vec_StrAppend( vStr, " );\n" );
|
||||
nTwoIns += Vec_IntSize(vGate) - 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -2098,14 +2464,14 @@ Vec_Str_t * Acb_GeneratePatch2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t *
|
|||
Vec_PtrFreeFree( vNames );
|
||||
Vec_WecFree( vGates );
|
||||
|
||||
printf( "Synthesized patch with %d inputs, %d outputs and %d gates.\n", nIns, nOuts, nWires );
|
||||
printf( "Synthesized patch with %d inputs, %d outputs and %d gates (including %d two-input gates).\n", nIns, nOuts, nWires, nTwoIns );
|
||||
return vStr;
|
||||
}
|
||||
void Acb_GenerateFile2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t * vOuts, char * pFileName, char * pFileNameOut )
|
||||
void Acb_GenerateFile2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t * vOuts, char * pFileName, char * pFileNameOut, int fSkipMffc )
|
||||
{
|
||||
extern void Acb_GenerateFilePatch( Vec_Str_t * p, char * pFileNamePatch );
|
||||
extern void Acb_GenerateFileOut( Vec_Str_t * vPatchLine, char * pFileNameF, char * pFileNameOut, Vec_Str_t * vPatch );
|
||||
extern void Acb_NtkInsert( char * pFileNameIn, char * pFileNameOut, Vec_Ptr_t * vNames, int fNumber );
|
||||
extern void Acb_NtkInsert( char * pFileNameIn, char * pFileNameOut, Vec_Ptr_t * vNames, int fNumber, int fSkipMffc );
|
||||
Vec_Str_t * vInst = Acb_GenerateInstance2( vIns, vOuts );
|
||||
Vec_Str_t * vPatch = Acb_GeneratePatch2( pGia, vIns, vOuts );
|
||||
//printf( "%s", Vec_StrArray(vPatch) );
|
||||
|
|
@ -2113,7 +2479,7 @@ void Acb_GenerateFile2( Gia_Man_t * pGia, Vec_Ptr_t * vIns, Vec_Ptr_t * vOuts, c
|
|||
// generate output files
|
||||
Acb_GenerateFilePatch( vPatch, "patch.v" );
|
||||
printf( "Finished dumping patch file \"%s\".\n", "patch.v" );
|
||||
Acb_NtkInsert( pFileName, "temp.v", vOuts, 0 );
|
||||
Acb_NtkInsert( pFileName, "temp.v", vOuts, 0, fSkipMffc );
|
||||
printf( "Finished dumping intermediate file \"%s\".\n", "temp.v" );
|
||||
Acb_GenerateFileOut( vInst, "temp.v", pFileNameOut, vPatch );
|
||||
printf( "Finished dumping the resulting file \"%s\".\n", pFileNameOut );
|
||||
|
|
@ -2479,7 +2845,7 @@ Vec_Ptr_t * Acb_TransformPatchFunctions( Vec_Ptr_t * vSops, Vec_Wec_t * vSupps,
|
|||
Vec_IntWriteEntry( vMap, iVar, Vec_IntSize(vUsed) );
|
||||
Vec_IntPush( vUsed, iVar );
|
||||
}
|
||||
printf( "The number of used variables %d (out of %d).\n", Vec_IntSum(vPres), Vec_IntSize(vPres) );
|
||||
//printf( "The number of used variables %d (out of %d).\n", Vec_IntSum(vPres), Vec_IntSize(vPres) );
|
||||
// remap SOPs
|
||||
Vec_WecForEachLevel( vSupps, vLevel, i )
|
||||
{
|
||||
|
|
@ -2505,13 +2871,14 @@ Vec_Ptr_t * Acb_TransformPatchFunctions( Vec_Ptr_t * vSops, Vec_Wec_t * vSupps,
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Acb_NtkEcoPerform( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG, char * pFileName[4], int fCisOnly, int fCheck, int fVerbose, int fVeryVerbose )
|
||||
int Acb_NtkEcoPerform( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG, char * pFileName[4], int nTimeout, int fCisOnly, int fInputs, int fCheck, int fUnitW, int fVerbose, int fVeryVerbose )
|
||||
{
|
||||
extern Gia_Man_t * Abc_SopSynthesizeOne( char * pSop, int fClp );
|
||||
|
||||
abctime clkStart = Abc_Clock();
|
||||
abctime clk = Abc_Clock();
|
||||
int nTargets = Vec_IntSize(&pNtkF->vTargets);
|
||||
int TimeOut = fCisOnly ? 0 : 60; // 60 seconds
|
||||
int TimeOut = fCisOnly ? 0 : 120; // 60 seconds
|
||||
int RetValue = 1;
|
||||
|
||||
// compute various sets of nodes
|
||||
|
|
@ -2520,7 +2887,7 @@ int Acb_NtkEcoPerform( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG, char * pFileName[4]
|
|||
Vec_Int_t * vSuppF = Acb_NtkFindSupp( pNtkF, vRoots );
|
||||
Vec_Int_t * vSuppG = Acb_NtkFindSupp( pNtkG, vRoots );
|
||||
Vec_Int_t * vSupp = Vec_IntTwoMerge( vSuppF, vSuppG );
|
||||
Vec_Int_t * vDivs = fCisOnly ? Acb_NtkFindDivsCis( pNtkF, vSupp ) : Acb_NtkFindDivs( pNtkF, vSupp, vBlock, fVerbose );
|
||||
Vec_Int_t * vDivs = (fCisOnly || fInputs) ? Acb_NtkFindDivsCis( pNtkF, vSupp ) : Acb_NtkFindDivs( pNtkF, vSupp, vBlock, fUnitW, fVerbose );
|
||||
Vec_Int_t * vNodesF = Acb_NtkFindNodes( pNtkF, vRoots, vDivs );
|
||||
Vec_Int_t * vNodesG = Acb_NtkFindNodes( pNtkG, vRoots, NULL );
|
||||
|
||||
|
|
@ -2543,6 +2910,10 @@ int Acb_NtkEcoPerform( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG, char * pFileName[4]
|
|||
char * pSop = NULL;
|
||||
int i;
|
||||
|
||||
// int Value = Acb_NtkSaveNames( pNtkF, vSupp, vNodesF, vRoots, vDivs, &pNtkF->vTargets, pGiaF );
|
||||
// Gia_AigerWrite( pGiaF, pFileBase, 0, 0, 0 );
|
||||
// return 0;
|
||||
|
||||
if ( fVerbose )
|
||||
{
|
||||
printf( "The number of targets = %d.\n", nTargets );
|
||||
|
|
@ -2622,6 +2993,14 @@ int Acb_NtkEcoPerform( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG, char * pFileName[4]
|
|||
RetValue = 0;
|
||||
goto cleanup;
|
||||
}
|
||||
if ( nTimeout && (Abc_Clock() - clkStart)/CLOCKS_PER_SEC >= nTimeout )
|
||||
{
|
||||
Vec_IntFreeP( &vSupp );
|
||||
ABC_FREE( pSop );
|
||||
printf( "The target computation timed out after %d seconds.\n", nTimeout );
|
||||
RetValue = 0;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// add new function to the miter
|
||||
pOne = Abc_SopSynthesizeOne( pSop, 1 );
|
||||
|
|
@ -2683,6 +3062,16 @@ int Acb_NtkEcoPerform( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG, char * pFileName[4]
|
|||
if ( pFileName[3] == NULL ) Acb_GenerateFilePatch( vPatch, "patch.v" );
|
||||
Acb_GenerateFileOut( vInst, pFileName[0], pFileName[3] ? pFileName[3] : (char *)"out.v", vPatch );
|
||||
printf( "Finished dumping resulting file \"%s\".\n\n", pFileName[3] ? pFileName[3] : "out.v" );
|
||||
/*
|
||||
{
|
||||
char * pFileBase = Extra_FileNameGenericAppend( pFileName[0], "_patch.v" );
|
||||
Acb_GenerateFilePatch( vPatch, pFileBase );
|
||||
pFileBase = Extra_FileNameGenericAppend( pFileName[0], "_out.v" );
|
||||
Acb_GenerateFileOut( vInst, pFileName[0], pFileName[3] ? pFileName[3] : pFileBase, vPatch );
|
||||
Acb_GenerateFileOut( vInst, pFileName[0], pFileName[3] ? pFileName[3] : "out.v", vPatch );
|
||||
printf( "Finished dumping resulting file \"%s\".\n\n", pFileName[3] ? pFileName[3] : pFileBase );
|
||||
}
|
||||
*/
|
||||
//Gia_AigerWrite( pGiaG, "test.aig", 0, 0, 0 );
|
||||
cleanup:
|
||||
// cleanup
|
||||
|
|
@ -2734,7 +3123,7 @@ void Acb_NtkTestRun2( char * pFileNames[3], int fVerbose )
|
|||
Acb_Ntk_t * pNtk = Acb_VerilogSimpleRead( pFileNames[0], pFileNames[2] );
|
||||
Acb_VerilogSimpleWrite( pNtk, pFileNameOut );
|
||||
Acb_ManFree( pNtk->pDesign );
|
||||
Acb_IntallLibrary();
|
||||
Acb_IntallLibrary( 0 );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
|
@ -2748,7 +3137,7 @@ void Acb_NtkTestRun2( char * pFileNames[3], int fVerbose )
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fRandom, int fVerbose, int fVeryVerbose )
|
||||
void Acb_NtkRunEco( char * pFileNames[4], int nTimeout, int fCheck, int fRandom, int fInputs, int fUnitW, int fVerbose, int fVeryVerbose )
|
||||
{
|
||||
char Command[1000]; int Result = 1;
|
||||
Acb_Ntk_t * pNtkF = Acb_VerilogSimpleRead( pFileNames[0], pFileNames[2] );
|
||||
|
|
@ -2768,12 +3157,12 @@ void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fRandom, int fVerbose,
|
|||
assert( Acb_NtkCiNum(pNtkF) == Acb_NtkCiNum(pNtkG) );
|
||||
assert( Acb_NtkCoNum(pNtkF) == Acb_NtkCoNum(pNtkG) );
|
||||
|
||||
Acb_IntallLibrary();
|
||||
Acb_IntallLibrary( Abc_FrameReadSignalNames() != NULL );
|
||||
|
||||
if ( !Acb_NtkEcoPerform( pNtkF, pNtkG, pFileNames, 0, fCheck, fVerbose, fVeryVerbose ) )
|
||||
if ( !Acb_NtkEcoPerform( pNtkF, pNtkG, pFileNames, nTimeout, 0, fInputs, fCheck, fUnitW, fVerbose, fVeryVerbose ) )
|
||||
{
|
||||
// printf( "General computation timed out. Trying inputs only.\n\n" );
|
||||
// if ( !Acb_NtkEcoPerform( pNtkF, pNtkG, pFileNames, 1, fCheck, fVerbose, fVeryVerbose ) )
|
||||
// if ( !Acb_NtkEcoPerform( pNtkF, pNtkG, pFileNames, nTimeout, 1, fInputs, fCheck, fUnitW, fVerbose, fVeryVerbose ) )
|
||||
// printf( "Input-only computation also timed out.\n\n" );
|
||||
printf( "Computation did not succeed.\n" );
|
||||
Result = 0;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,11 @@
|
|||
***********************************************************************/
|
||||
|
||||
#include "acb.h"
|
||||
#include "aig/saig/saig.h"
|
||||
#include "aig/gia/giaAig.h"
|
||||
#include "base/abc/abc.h"
|
||||
#include "proof/fraig/fraig.h"
|
||||
#include "misc/util/utilTruth.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
|
|
@ -26,10 +31,571 @@ ABC_NAMESPACE_IMPL_START
|
|||
/// DECLARATIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int fForceZero = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// FUNCTION DEFINITIONS ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_ManSimTry( Gia_Man_t * pF, Gia_Man_t * pG )
|
||||
{
|
||||
int i, j, n, nWords = 500;
|
||||
Vec_Wrd_t * vSimsF, * vSimsG;
|
||||
Abc_Random(1);
|
||||
Vec_WrdFreeP( &pF->vSimsPi );
|
||||
Vec_WrdFreeP( &pG->vSimsPi );
|
||||
pF->vSimsPi = Vec_WrdStartRandom( Gia_ManCiNum(pF) * nWords );
|
||||
pG->vSimsPi = Vec_WrdDup( pF->vSimsPi );
|
||||
vSimsF = Gia_ManSimPatSim( pF );
|
||||
vSimsG = Gia_ManSimPatSim( pG );
|
||||
assert( Gia_ManObjNum(pF) * nWords == Vec_WrdSize(vSimsF) );
|
||||
for ( i = 0; i < Gia_ManCoNum(pF)/2; i++ )
|
||||
{
|
||||
Gia_Obj_t * pObjFb = Gia_ManCo( pF, 2*i+0 );
|
||||
Gia_Obj_t * pObjFx = Gia_ManCo( pF, 2*i+1 );
|
||||
Gia_Obj_t * pObjGb = Gia_ManCo( pG, 2*i+0 );
|
||||
Gia_Obj_t * pObjGx = Gia_ManCo( pG, 2*i+1 );
|
||||
word * pSimFb = Vec_WrdEntryP(vSimsF, Gia_ObjId(pF, pObjFb)*nWords);
|
||||
word * pSimFx = Vec_WrdEntryP(vSimsF, Gia_ObjId(pF, pObjFx)*nWords);
|
||||
word * pSimGb = Vec_WrdEntryP(vSimsG, Gia_ObjId(pG, pObjGb)*nWords);
|
||||
word * pSimGx = Vec_WrdEntryP(vSimsG, Gia_ObjId(pG, pObjGx)*nWords);
|
||||
|
||||
int nBitsFx = Abc_TtCountOnesVec(pSimFx, nWords);
|
||||
int nBitsF1 = Abc_TtCountOnesVecMask(pSimFx, pSimFb, nWords, 1);
|
||||
int nBitsF0 = nWords*64 - nBitsFx - nBitsF1;
|
||||
|
||||
int nBitsGx = Abc_TtCountOnesVec(pSimGx, nWords);
|
||||
int nBitsG1 = Abc_TtCountOnesVecMask(pSimGx, pSimGb, nWords, 1);
|
||||
int nBitsG0 = nWords*64 - nBitsGx - nBitsG1;
|
||||
|
||||
printf( "Output %4d : ", i );
|
||||
|
||||
printf( " RF : " );
|
||||
printf( "0 =%7.3f %% ", 100.0*nBitsF0/64/nWords );
|
||||
printf( "1 =%7.3f %% ", 100.0*nBitsF1/64/nWords );
|
||||
printf( "X =%7.3f %% ", 100.0*nBitsFx/64/nWords );
|
||||
|
||||
printf( " GF : " );
|
||||
printf( "0 =%7.3f %% ", 100.0*nBitsG0/64/nWords );
|
||||
printf( "1 =%7.3f %% ", 100.0*nBitsG1/64/nWords );
|
||||
printf( "X =%7.3f %% ", 100.0*nBitsGx/64/nWords );
|
||||
|
||||
printf( "\n" );
|
||||
if ( i == 20 )
|
||||
break;
|
||||
}
|
||||
|
||||
printf( "\n" );
|
||||
for ( j = 0; j < 20; j++ )
|
||||
{
|
||||
for ( n = 0; n < 2; n++ )
|
||||
{
|
||||
for ( i = 0; i < Gia_ManCoNum(pF)/2; i++ )
|
||||
{
|
||||
Gia_Obj_t * pObjFb = Gia_ManCo( pF, 2*i+0 );
|
||||
Gia_Obj_t * pObjFx = Gia_ManCo( pF, 2*i+1 );
|
||||
Gia_Obj_t * pObjGb = Gia_ManCo( pG, 2*i+0 );
|
||||
Gia_Obj_t * pObjGx = Gia_ManCo( pG, 2*i+1 );
|
||||
word * pSimFb = Vec_WrdEntryP(vSimsF, Gia_ObjId(pF, pObjFb)*nWords);
|
||||
word * pSimFx = Vec_WrdEntryP(vSimsF, Gia_ObjId(pF, pObjFx)*nWords);
|
||||
word * pSimGb = Vec_WrdEntryP(vSimsG, Gia_ObjId(pG, pObjGb)*nWords);
|
||||
word * pSimGx = Vec_WrdEntryP(vSimsG, Gia_ObjId(pG, pObjGx)*nWords);
|
||||
word * pSimb = n ? pSimGb : pSimFb;
|
||||
word * pSimx = n ? pSimGx : pSimFx;
|
||||
if ( Abc_TtGetBit(pSimx, j) )
|
||||
printf( "x" );
|
||||
else if ( Abc_TtGetBit(pSimb, j) )
|
||||
printf( "1" );
|
||||
else
|
||||
printf( "0" );
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
Vec_WrdFree( vSimsF );
|
||||
Vec_WrdFree( vSimsG );
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Gia_ManDualNot( Gia_Man_t * p, int LitA[2], int LitZ[2] )
|
||||
{
|
||||
LitZ[0] = Abc_LitNot(LitA[0]);
|
||||
LitZ[1] = LitA[1];
|
||||
|
||||
if ( fForceZero ) LitZ[0] = Gia_ManHashAnd( p, LitZ[0], Abc_LitNot(LitZ[1]) );
|
||||
}
|
||||
// computes Z = XOR(A, B) where A, B, Z belong to {0,1,x} encoded as 0=00, 1=01, x=1-
|
||||
void Gia_ManDualXor2( Gia_Man_t * p, int LitA[2], int LitB[2], int LitZ[2] )
|
||||
{
|
||||
LitZ[0] = Gia_ManHashXor( p, LitA[0], LitB[0] );
|
||||
LitZ[1] = Gia_ManHashOr( p, LitA[1], LitB[1] );
|
||||
|
||||
if ( fForceZero ) LitZ[0] = Gia_ManHashAnd( p, LitZ[0], Abc_LitNot(LitZ[1]) );
|
||||
}
|
||||
void Gia_ManDualXorN( Gia_Man_t * p, int * pLits, int n, int LitZ[2] )
|
||||
{
|
||||
int i;
|
||||
LitZ[0] = 0;
|
||||
LitZ[1] = 0;
|
||||
for ( i = 0; i < n; i++ )
|
||||
{
|
||||
LitZ[0] = Gia_ManHashXor( p, LitZ[0], pLits[2*i] );
|
||||
LitZ[1] = Gia_ManHashOr ( p, LitZ[1], pLits[2*i+1] );
|
||||
}
|
||||
}
|
||||
// computes Z = AND(A, B) where A, B, Z belong to {0,1,x} encoded as 0=00, 1=01, z=1-
|
||||
void Gia_ManDualAnd2( Gia_Man_t * p, int LitA[2], int LitB[2], int LitZ[2] )
|
||||
{
|
||||
int ZeroA = Gia_ManHashAnd( p, Abc_LitNot(LitA[0]), Abc_LitNot(LitA[1]) );
|
||||
int ZeroB = Gia_ManHashAnd( p, Abc_LitNot(LitB[0]), Abc_LitNot(LitB[1]) );
|
||||
int ZeroZ = Gia_ManHashOr( p, ZeroA, ZeroB );
|
||||
LitZ[0] = Gia_ManHashAnd( p, LitA[0], LitB[0] );
|
||||
LitZ[1] = Gia_ManHashAnd( p, Gia_ManHashOr( p, LitA[1], LitB[1] ), Abc_LitNot(ZeroZ) );
|
||||
|
||||
//LitZ[0] = Gia_ManHashAnd( p, Gia_ManHashAnd(p, LitA[0], Abc_LitNot(LitA[1])), Gia_ManHashAnd(p, LitB[0], Abc_LitNot(LitB[1])) );
|
||||
//LitZ[1] = Gia_ManHashAnd( p, Gia_ManHashOr(p, LitA[0], LitA[1]), Gia_ManHashOr(p, LitB[0], LitB[1]) );
|
||||
//LitZ[1] = Gia_ManHashAnd( p, LitZ[1], Abc_LitNot(LitZ[0]) );
|
||||
}
|
||||
void Gia_ManDualAndN( Gia_Man_t * p, int * pLits, int n, int LitZ[2] )
|
||||
{
|
||||
int i, LitZero = 0, LitOne = 0;
|
||||
LitZ[0] = 1;
|
||||
for ( i = 0; i < n; i++ )
|
||||
{
|
||||
int Lit = Gia_ManHashAnd( p, Abc_LitNot(pLits[2*i]), Abc_LitNot(pLits[2*i+1]) );
|
||||
LitZero = Gia_ManHashOr( p, LitZero, Lit );
|
||||
LitOne = Gia_ManHashOr( p, LitOne, pLits[2*i+1] );
|
||||
LitZ[0] = Gia_ManHashAnd( p, LitZ[0], pLits[2*i] );
|
||||
}
|
||||
LitZ[1] = Gia_ManHashAnd( p, LitOne, Abc_LitNot(LitZero) );
|
||||
|
||||
if ( fForceZero ) LitZ[0] = Gia_ManHashAnd( p, LitZ[0], Abc_LitNot(LitZ[1]) );
|
||||
}
|
||||
/*
|
||||
module _DC(O, C, D);
|
||||
output O;
|
||||
input C, D;
|
||||
assign O = D ? 1'bx : C;
|
||||
endmodule
|
||||
*/
|
||||
void Gia_ManDualDc( Gia_Man_t * p, int LitC[2], int LitD[2], int LitZ[2] )
|
||||
{
|
||||
LitZ[0] = LitC[0];
|
||||
// LitZ[0] = Gia_ManHashMux( p, LitD[0], 0, LitC[0] );
|
||||
LitZ[1] = Gia_ManHashOr(p, Gia_ManHashOr(p,LitD[0],LitD[1]), LitC[1] );
|
||||
|
||||
if ( fForceZero ) LitZ[0] = Gia_ManHashAnd( p, LitZ[0], Abc_LitNot(LitZ[1]) );
|
||||
}
|
||||
void Gia_ManDualMux( Gia_Man_t * p, int LitC[2], int LitT[2], int LitE[2], int LitZ[2] )
|
||||
{
|
||||
/*
|
||||
// total logic size: 18 nodes
|
||||
int Xnor = Gia_ManHashXor( p, Abc_LitNot(LitT[0]), LitE[0] );
|
||||
int Cond = Gia_ManHashAnd( p, Abc_LitNot(LitT[1]), Abc_LitNot(LitE[1]) );
|
||||
int pTempE[2], pTempT[2];
|
||||
pTempE[0] = Gia_ManHashMux( p, LitC[0], LitT[0], LitE[0] );
|
||||
pTempE[1] = Gia_ManHashMux( p, LitC[0], LitT[1], LitE[1] );
|
||||
//pTempT[0] = LitT[0];
|
||||
pTempT[0] = Gia_ManHashAnd( p, LitT[0], LitE[0] );
|
||||
pTempT[1] = Gia_ManHashAnd( p, Cond, Xnor );
|
||||
LitZ[0] = Gia_ManHashMux( p, LitC[1], pTempT[0], pTempE[0] );
|
||||
LitZ[1] = Gia_ManHashMux( p, LitC[1], pTempT[1], pTempE[1] );
|
||||
*/
|
||||
// total logic size: 14 nodes
|
||||
int Xnor = Gia_ManHashXor( p, Abc_LitNot(LitT[0]), LitE[0] );
|
||||
int Cond = Gia_ManHashAnd( p, Abc_LitNot(LitT[1]), Abc_LitNot(LitE[1]) );
|
||||
int XVal1 = Abc_LitNot( Gia_ManHashAnd( p, Cond, Xnor ) );
|
||||
int XVal0 = Gia_ManHashMux( p, LitC[0], LitT[1], LitE[1] );
|
||||
LitZ[0] = Gia_ManHashMux( p, LitC[0], LitT[0], LitE[0] );
|
||||
LitZ[1] = Gia_ManHashMux( p, LitC[1], XVal1, XVal0 );
|
||||
|
||||
if ( fForceZero ) LitZ[0] = Gia_ManHashAnd( p, LitZ[0], Abc_LitNot(LitZ[1]) );
|
||||
}
|
||||
int Gia_ManDualCompare( Gia_Man_t * p, int LitF[2], int LitS[2] )
|
||||
{
|
||||
int iMiter = Gia_ManHashXor( p, LitF[0], LitS[0] );
|
||||
iMiter = Gia_ManHashOr( p, LitF[1], iMiter );
|
||||
iMiter = Gia_ManHashAnd( p, Abc_LitNot(LitS[1]), iMiter );
|
||||
return iMiter;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Acb_ObjToGiaDual( Gia_Man_t * pNew, Acb_Ntk_t * p, int iObj, Vec_Int_t * vTemp, Vec_Int_t * vCopies, int pRes[2] )
|
||||
{
|
||||
//char * pName = Abc_NamStr( p->pDesign->pStrs, Acb_ObjName(p, iObj) );
|
||||
int * pFanin, iFanin, k, Type;
|
||||
assert( !Acb_ObjIsCio(p, iObj) );
|
||||
Vec_IntClear( vTemp );
|
||||
Acb_ObjForEachFaninFast( p, iObj, pFanin, iFanin, k )
|
||||
{
|
||||
int * pLits = Vec_IntEntryP( vCopies, 2*iFanin );
|
||||
assert( pLits[0] >= 0 && pLits[1] >= 0 );
|
||||
Vec_IntPushTwo( vTemp, pLits[0], pLits[1] );
|
||||
}
|
||||
Type = Acb_ObjType( p, iObj );
|
||||
if ( Type == ABC_OPER_CONST_F )
|
||||
{
|
||||
pRes[0] = 0;
|
||||
pRes[1] = 0;
|
||||
return;
|
||||
}
|
||||
if ( Type == ABC_OPER_CONST_T )
|
||||
{
|
||||
pRes[0] = 1;
|
||||
pRes[1] = 0;
|
||||
return;
|
||||
}
|
||||
if ( Type == ABC_OPER_CONST_X )
|
||||
{
|
||||
pRes[0] = 0;
|
||||
pRes[1] = 1;
|
||||
return;
|
||||
}
|
||||
if ( Type == ABC_OPER_BIT_BUF )
|
||||
{
|
||||
pRes[0] = Vec_IntEntry(vTemp, 0);
|
||||
pRes[1] = Vec_IntEntry(vTemp, 1);
|
||||
return;
|
||||
}
|
||||
if ( Type == ABC_OPER_BIT_INV )
|
||||
{
|
||||
Gia_ManDualNot( pNew, Vec_IntArray(vTemp), pRes );
|
||||
return;
|
||||
}
|
||||
if ( Type == ABC_OPER_TRI )
|
||||
{
|
||||
// in the file inputs are ordered as follows: _DC \n6_5[9] ( .O(\108 ), .C(\96 ), .D(\107 ));
|
||||
// in this code, we expect them as follows: void Gia_ManDualDc( Gia_Man_t * p, int LitC[2], int LitD[2], int LitZ[2] )
|
||||
assert( Vec_IntSize(vTemp) == 4 );
|
||||
Gia_ManDualDc( pNew, Vec_IntArray(vTemp), Vec_IntArray(vTemp) + 2, pRes );
|
||||
return;
|
||||
}
|
||||
if ( Type == ABC_OPER_BIT_MUX )
|
||||
{
|
||||
// in the file inputs are ordered as follows: _HMUX \U$1 ( .O(\282 ), .I0(1'b1), .I1(\277 ), .S(\281 ));
|
||||
// in this code, we expect them as follows: void Gia_ManDualMux( Gia_Man_t * p, int LitC[2], int LitT[2], int LitE[2], int LitZ[2] )
|
||||
assert( Vec_IntSize(vTemp) == 6 );
|
||||
ABC_SWAP( int, Vec_IntArray(vTemp)[0], Vec_IntArray(vTemp)[4] );
|
||||
ABC_SWAP( int, Vec_IntArray(vTemp)[1], Vec_IntArray(vTemp)[5] );
|
||||
Gia_ManDualMux( pNew, Vec_IntArray(vTemp), Vec_IntArray(vTemp) + 2, Vec_IntArray(vTemp) + 4, pRes );
|
||||
return;
|
||||
}
|
||||
if ( Type == ABC_OPER_BIT_AND || Type == ABC_OPER_BIT_NAND )
|
||||
{
|
||||
Gia_ManDualAndN( pNew, Vec_IntArray(vTemp), Vec_IntSize(vTemp)/2, pRes );
|
||||
if ( Type == ABC_OPER_BIT_NAND )
|
||||
pRes[0] = Abc_LitNot( pRes[0] );
|
||||
return;
|
||||
}
|
||||
if ( Type == ABC_OPER_BIT_OR || Type == ABC_OPER_BIT_NOR )
|
||||
{
|
||||
int * pArray = Vec_IntArray( vTemp );
|
||||
for ( k = 0; k < Vec_IntSize(vTemp)/2; k++ )
|
||||
pArray[2*k] = Abc_LitNot( pArray[2*k] );
|
||||
Gia_ManDualAndN( pNew, pArray, Vec_IntSize(vTemp)/2, pRes );
|
||||
if ( Type == ABC_OPER_BIT_OR )
|
||||
pRes[0] = Abc_LitNot( pRes[0] );
|
||||
return;
|
||||
}
|
||||
if ( Type == ABC_OPER_BIT_XOR || Type == ABC_OPER_BIT_NXOR )
|
||||
{
|
||||
assert( Vec_IntSize(vTemp) == 4 );
|
||||
Gia_ManDualXor2( pNew, Vec_IntArray(vTemp), Vec_IntArray(vTemp) + 2, pRes );
|
||||
if ( Type == ABC_OPER_BIT_NXOR )
|
||||
pRes[0] = Abc_LitNot( pRes[0] );
|
||||
return;
|
||||
}
|
||||
assert( 0 );
|
||||
}
|
||||
Gia_Man_t * Acb_NtkGiaDeriveDual( Acb_Ntk_t * p )
|
||||
{
|
||||
extern Vec_Int_t * Acb_NtkFindNodes2( Acb_Ntk_t * p );
|
||||
Gia_Man_t * pNew, * pOne;
|
||||
Vec_Int_t * vFanins, * vNodes;
|
||||
Vec_Int_t * vCopies = Vec_IntStartFull( 2*Acb_NtkObjNum(p) );
|
||||
int i, iObj, * pLits;
|
||||
pNew = Gia_ManStart( 5 * Acb_NtkObjNum(p) );
|
||||
pNew->pName = Abc_UtilStrsav(Acb_NtkName(p));
|
||||
Gia_ManHashAlloc( pNew );
|
||||
pLits = Vec_IntEntryP( vCopies, 0 );
|
||||
pLits[0] = 0;
|
||||
pLits[1] = 0;
|
||||
Acb_NtkForEachCi( p, iObj, i )
|
||||
{
|
||||
pLits = Vec_IntEntryP( vCopies, 2*iObj );
|
||||
pLits[0] = Gia_ManAppendCi(pNew);
|
||||
pLits[1] = 0;
|
||||
}
|
||||
vFanins = Vec_IntAlloc( 4 );
|
||||
vNodes = Acb_NtkFindNodes2( p );
|
||||
Vec_IntForEachEntry( vNodes, iObj, i )
|
||||
{
|
||||
pLits = Vec_IntEntryP( vCopies, 2*iObj );
|
||||
Acb_ObjToGiaDual( pNew, p, iObj, vFanins, vCopies, pLits );
|
||||
}
|
||||
Vec_IntFree( vNodes );
|
||||
Vec_IntFree( vFanins );
|
||||
Acb_NtkForEachCo( p, iObj, i )
|
||||
{
|
||||
pLits = Vec_IntEntryP( vCopies, 2*Acb_ObjFanin(p, iObj, 0) );
|
||||
Gia_ManAppendCo( pNew, pLits[0] );
|
||||
Gia_ManAppendCo( pNew, pLits[1] );
|
||||
}
|
||||
Vec_IntFree( vCopies );
|
||||
pNew = Gia_ManCleanup( pOne = pNew );
|
||||
Gia_ManStop( pOne );
|
||||
return pNew;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
Gia_Man_t * Acb_NtkGiaDeriveMiter( Gia_Man_t * pOne, Gia_Man_t * pTwo, int Type )
|
||||
{
|
||||
Gia_Man_t * pNew, * pTemp;
|
||||
Gia_Obj_t * pObj;
|
||||
int i;
|
||||
assert( Gia_ManCiNum(pOne) == Gia_ManCiNum(pTwo) );
|
||||
assert( Gia_ManCoNum(pOne) == Gia_ManCoNum(pTwo) );
|
||||
pNew = Gia_ManStart( Gia_ManObjNum(pOne) + Gia_ManObjNum(pTwo) + 5*Gia_ManCoNum(pOne)/2 );
|
||||
pNew->pName = Abc_UtilStrsav( "miter" );
|
||||
pNew->pSpec = NULL;
|
||||
Gia_ManHashAlloc( pNew );
|
||||
Gia_ManConst0(pOne)->Value = 0;
|
||||
Gia_ManConst0(pTwo)->Value = 0;
|
||||
Gia_ManForEachCi( pOne, pObj, i )
|
||||
pObj->Value = Gia_ManAppendCi( pNew );
|
||||
Gia_ManForEachCi( pTwo, pObj, i )
|
||||
pObj->Value = Gia_ManCi(pOne, i)->Value;
|
||||
Gia_ManForEachAnd( pOne, pObj, i )
|
||||
pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
|
||||
Gia_ManForEachAnd( pTwo, pObj, i )
|
||||
pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
|
||||
Gia_ManForEachCo( pOne, pObj, i )
|
||||
pObj->Value = Gia_ObjFanin0Copy(pObj);
|
||||
Gia_ManForEachCo( pTwo, pObj, i )
|
||||
pObj->Value = Gia_ObjFanin0Copy(pObj);
|
||||
if ( Type == 0 ) // only main circuit
|
||||
{
|
||||
for ( i = 0; i < Gia_ManCoNum(pOne); i += 2 )
|
||||
{
|
||||
int pLitsF[2] = { Gia_ManCo(pOne, i)->Value, Gia_ManCo(pOne, i+1)->Value };
|
||||
int pLitsS[2] = { Gia_ManCo(pTwo, i)->Value, Gia_ManCo(pTwo, i+1)->Value };
|
||||
Gia_ManAppendCo( pNew, pLitsF[0] );
|
||||
Gia_ManAppendCo( pNew, pLitsS[0] );
|
||||
}
|
||||
}
|
||||
else if ( Type == 1 ) // only shadow circuit
|
||||
{
|
||||
for ( i = 0; i < Gia_ManCoNum(pOne); i += 2 )
|
||||
{
|
||||
int pLitsF[2] = { Gia_ManCo(pOne, i)->Value, Gia_ManCo(pOne, i+1)->Value };
|
||||
int pLitsS[2] = { Gia_ManCo(pTwo, i)->Value, Gia_ManCo(pTwo, i+1)->Value };
|
||||
Gia_ManAppendCo( pNew, pLitsF[1] );
|
||||
Gia_ManAppendCo( pNew, pLitsS[1] );
|
||||
}
|
||||
}
|
||||
else // comparator of the two
|
||||
{
|
||||
for ( i = 0; i < Gia_ManCoNum(pOne); i += 2 )
|
||||
{
|
||||
int pLitsF[2] = { Gia_ManCo(pOne, i)->Value, Gia_ManCo(pOne, i+1)->Value };
|
||||
int pLitsS[2] = { Gia_ManCo(pTwo, i)->Value, Gia_ManCo(pTwo, i+1)->Value };
|
||||
Gia_ManAppendCo( pNew, Gia_ManDualCompare( pNew, pLitsF, pLitsS ) );
|
||||
}
|
||||
}
|
||||
Gia_ManHashStop( pNew );
|
||||
pNew = Gia_ManCleanup( pTemp = pNew );
|
||||
Gia_ManStop( pTemp );
|
||||
return pNew;
|
||||
}
|
||||
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Acb_OutputFile( char * pFileName, Acb_Ntk_t * pNtkF, int * pModel )
|
||||
{
|
||||
char * pFileName0 = pFileName? pFileName : "output";
|
||||
FILE * pFile = fopen( pFileName0, "wb" );
|
||||
if ( pFile == NULL )
|
||||
{
|
||||
printf( "Cannot open results file \"%s\".\n", pFileName0 );
|
||||
return;
|
||||
}
|
||||
if ( pModel == NULL )
|
||||
fprintf( pFile, "EQ\n" );
|
||||
else
|
||||
{
|
||||
/*
|
||||
NEQ
|
||||
in 1
|
||||
a 1
|
||||
b 0
|
||||
*/
|
||||
int i, iObj;
|
||||
fprintf( pFile, "NEQ\n" );
|
||||
Acb_NtkForEachPi( pNtkF, iObj, i )
|
||||
fprintf( pFile, "%s %d\n", Acb_ObjNameStr(pNtkF, iObj), pModel[i] );
|
||||
}
|
||||
fclose( pFile );
|
||||
printf( "Produced output file \"%s\".\n\n", pFileName0 );
|
||||
}
|
||||
int * Acb_NtkSolve( Gia_Man_t * p )
|
||||
{
|
||||
extern Abc_Ntk_t * Abc_NtkFromAigPhase( Aig_Man_t * pMan );
|
||||
Aig_Man_t * pMan = Gia_ManToAig( p, 0 );
|
||||
Abc_Ntk_t * pNtkTemp = Abc_NtkFromAigPhase( pMan );
|
||||
Prove_Params_t Params, * pParams = &Params;
|
||||
Prove_ParamsSetDefault( pParams );
|
||||
pParams->fUseRewriting = 1;
|
||||
pParams->fVerbose = 0;
|
||||
Aig_ManStop( pMan );
|
||||
if ( pNtkTemp )
|
||||
{
|
||||
abctime clk = Abc_Clock();
|
||||
int RetValue = Abc_NtkIvyProve( &pNtkTemp, pParams );
|
||||
int * pModel = pNtkTemp->pModel;
|
||||
pNtkTemp->pModel = NULL;
|
||||
Abc_NtkDelete( pNtkTemp );
|
||||
printf( "The networks are %s. ", RetValue == 1 ? "equivalent" : (RetValue == 0 ? "NOT equivalent" : "UNDECIDED") );
|
||||
Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
|
||||
if ( RetValue == 0 )
|
||||
return pModel;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Various statistics.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Acb_NtkPrintCecStats( Acb_Ntk_t * pNtk )
|
||||
{
|
||||
int iObj, nDcs = 0, nMuxes = 0;
|
||||
Acb_NtkForEachNode( pNtk, iObj )
|
||||
if ( Acb_ObjType( pNtk, iObj ) == ABC_OPER_TRI )
|
||||
nDcs++;
|
||||
else if ( Acb_ObjType( pNtk, iObj ) == ABC_OPER_BIT_MUX )
|
||||
nMuxes++;
|
||||
|
||||
printf( "PI = %6d ", Acb_NtkCiNum(pNtk) );
|
||||
printf( "PO = %6d ", Acb_NtkCoNum(pNtk) );
|
||||
printf( "Obj = %6d ", Acb_NtkObjNum(pNtk) );
|
||||
printf( "DC = %4d ", nDcs );
|
||||
printf( "Mux = %4d ", nMuxes );
|
||||
printf( "\n" );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Changing the PI order.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Acb_NtkUpdateCiOrder( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG )
|
||||
{
|
||||
int i, iObj;
|
||||
Vec_Int_t * vMap = Vec_IntStartFull( Acb_ManNameIdMax(pNtkG->pDesign) );
|
||||
Vec_Int_t * vOrder = Vec_IntStartFull( Acb_NtkCiNum(pNtkG) );
|
||||
Acb_NtkForEachCi( pNtkG, iObj, i )
|
||||
Vec_IntWriteEntry( vMap, Acb_ObjName(pNtkG, iObj), i );
|
||||
Acb_NtkForEachCi( pNtkF, iObj, i )
|
||||
{
|
||||
int NameIdG = Acb_ManStrId( pNtkG->pDesign, Acb_ObjNameStr(pNtkF, iObj) );
|
||||
int iPerm = NameIdG < Vec_IntSize(vMap) ? Vec_IntEntry( vMap, NameIdG ) : -1;
|
||||
if ( iPerm == -1 )
|
||||
printf( "Cannot find name \"%s\" of PI %d of F among PIs of G.\n", Acb_ObjNameStr(pNtkF, iObj), i );
|
||||
else
|
||||
Vec_IntWriteEntry( vOrder, iPerm, iObj );
|
||||
}
|
||||
Vec_IntClear( &pNtkF->vCis );
|
||||
Vec_IntAppend( &pNtkF->vCis, vOrder );
|
||||
Vec_IntFree( vOrder );
|
||||
Vec_IntFree( vMap );
|
||||
}
|
||||
int Acb_NtkCheckPiOrder( Acb_Ntk_t * pNtkF, Acb_Ntk_t * pNtkG )
|
||||
{
|
||||
int i, nPis = Acb_NtkCiNum(pNtkF);
|
||||
for ( i = 0; i < nPis; i++ )
|
||||
{
|
||||
char * pNameF = Acb_ObjNameStr( pNtkF, Acb_NtkCi(pNtkF, i) );
|
||||
char * pNameG = Acb_ObjNameStr( pNtkG, Acb_NtkCi(pNtkG, i) );
|
||||
if ( strcmp(pNameF, pNameG) )
|
||||
{
|
||||
// printf( "PI %d has different names (%s and %s) in these networks.\n", i, pNameF, pNameG );
|
||||
printf( "Networks have different PI names. Reordering PIs of the implementation network.\n" );
|
||||
Acb_NtkUpdateCiOrder( pNtkF, pNtkG );
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( i == nPis )
|
||||
printf( "Networks have the same PI names.\n" );
|
||||
return i == nPis;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
|
@ -43,6 +609,51 @@ ABC_NAMESPACE_IMPL_START
|
|||
***********************************************************************/
|
||||
void Acb_NtkRunTest( char * pFileNames[4], int fFancy, int fVerbose )
|
||||
{
|
||||
extern Acb_Ntk_t * Acb_VerilogSimpleRead( char * pFileName, char * pFileNameW );
|
||||
extern void Gia_AigerWrite( Gia_Man_t * p, char * pFileName, int fWriteSymbols, int fCompact, int fWriteNewLine );
|
||||
|
||||
int fSolve = 1;
|
||||
int * pModel = NULL;
|
||||
Gia_Man_t * pGiaF = NULL;
|
||||
Gia_Man_t * pGiaG = NULL;
|
||||
Gia_Man_t * pGia = NULL;
|
||||
Acb_Ntk_t * pNtkF = Acb_VerilogSimpleRead( pFileNames[0], NULL );
|
||||
Acb_Ntk_t * pNtkG = Acb_VerilogSimpleRead( pFileNames[1], NULL );
|
||||
if ( !pNtkF || !pNtkG )
|
||||
return;
|
||||
|
||||
assert( Acb_NtkCiNum(pNtkF) == Acb_NtkCiNum(pNtkG) );
|
||||
assert( Acb_NtkCoNum(pNtkF) == Acb_NtkCoNum(pNtkG) );
|
||||
|
||||
Acb_NtkCheckPiOrder( pNtkF, pNtkG );
|
||||
//Acb_NtkCheckPiOrder( pNtkG, pNtkF );
|
||||
Acb_NtkPrintCecStats( pNtkF );
|
||||
Acb_NtkPrintCecStats( pNtkG );
|
||||
|
||||
pGiaF = Acb_NtkGiaDeriveDual( pNtkF );
|
||||
pGiaG = Acb_NtkGiaDeriveDual( pNtkG );
|
||||
pGia = Acb_NtkGiaDeriveMiter( pGiaF, pGiaG, 2 );
|
||||
//Gia_AigerWrite( pGiaF, Extra_FileNameGenericAppend(pFileNames[1], "_f2.aig"), 0, 0, 0 );
|
||||
//Gia_AigerWrite( pGiaG, Extra_FileNameGenericAppend(pFileNames[1], "_g2.aig"), 0, 0, 0 );
|
||||
//Gia_AigerWrite( pGia, Extra_FileNameGenericAppend(pFileNames[1], "_miter_0.aig"), 0, 0, 0 );
|
||||
//printf( "Written the miter info file \"%s\".\n", Extra_FileNameGenericAppend(pFileNames[1], "_miter_0.aig") );
|
||||
|
||||
//Gia_ManPrintStats( pGia, NULL );
|
||||
//Gia_ManSimTry( pGiaF, pGiaG );
|
||||
|
||||
if ( fSolve )
|
||||
{
|
||||
pModel = Acb_NtkSolve( pGia );
|
||||
Acb_OutputFile( pFileNames[2], pNtkF, pModel );
|
||||
ABC_FREE( pModel );
|
||||
}
|
||||
|
||||
Gia_ManStop( pGia );
|
||||
Gia_ManStop( pGiaF );
|
||||
Gia_ManStop( pGiaG );
|
||||
|
||||
Acb_ManFree( pNtkF->pDesign );
|
||||
Acb_ManFree( pNtkG->pDesign );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include "acb.h"
|
||||
#include "base/abc/abc.h"
|
||||
#include "base/io/ioAbc.h"
|
||||
#include "base/main/main.h"
|
||||
|
||||
ABC_NAMESPACE_IMPL_START
|
||||
|
||||
|
|
@ -71,6 +72,15 @@ Vec_Int_t * Acb_ObjCollectTfi( Acb_Ntk_t * p, int iObj, int fTerm )
|
|||
Acb_ObjCollectTfi_rec( p, iObj, fTerm );
|
||||
return &p->vArray0;
|
||||
}
|
||||
Vec_Int_t * Acb_ObjCollectTfiVec( Acb_Ntk_t * p, Vec_Int_t * vObjs )
|
||||
{
|
||||
int i, iObj;
|
||||
Vec_IntClear( &p->vArray0 );
|
||||
Acb_NtkIncTravId( p );
|
||||
Vec_IntForEachEntry( vObjs, iObj, i )
|
||||
Acb_ObjCollectTfi_rec( p, iObj, 0 );
|
||||
return &p->vArray0;
|
||||
}
|
||||
|
||||
void Acb_ObjCollectTfo_rec( Acb_Ntk_t * p, int iObj, int fTerm )
|
||||
{
|
||||
|
|
@ -95,6 +105,219 @@ Vec_Int_t * Acb_ObjCollectTfo( Acb_Ntk_t * p, int iObj, int fTerm )
|
|||
Acb_ObjCollectTfo_rec( p, iObj, fTerm );
|
||||
return &p->vArray1;
|
||||
}
|
||||
Vec_Int_t * Acb_ObjCollectTfoVec( Acb_Ntk_t * p, Vec_Int_t * vObjs )
|
||||
{
|
||||
int i, iObj;
|
||||
if ( !Acb_NtkHasObjFanout(p) )
|
||||
Acb_NtkCreateFanout( p );
|
||||
Vec_IntClear( &p->vArray1 );
|
||||
Acb_NtkIncTravId( p );
|
||||
Vec_IntForEachEntry( vObjs, iObj, i )
|
||||
Acb_ObjCollectTfo_rec( p, iObj, 0 );
|
||||
return &p->vArray1;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Count the number of nodes driving the POs.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Acb_NtkIsPiBuffers( Acb_Ntk_t * p, int iObj )
|
||||
{
|
||||
if ( Acb_ObjIsCi(p, iObj) )
|
||||
return 1;
|
||||
if ( Acb_ObjFaninNum(p, iObj) != 1 )
|
||||
return 0;
|
||||
return Acb_NtkIsPiBuffers( p, Acb_ObjFanin(p, iObj, 0) );
|
||||
}
|
||||
int Acb_NtkCountPiBuffers( Acb_Ntk_t * p, Vec_Int_t * vObjs )
|
||||
{
|
||||
int i, iObj, Count = 0;
|
||||
Vec_IntForEachEntry( vObjs, iObj, i )
|
||||
Count += Acb_NtkIsPiBuffers( p, iObj );
|
||||
return Count;
|
||||
}
|
||||
int Acb_NtkCountPoDrivers( Acb_Ntk_t * p, Vec_Int_t * vObjs )
|
||||
{
|
||||
int i, iObj, Count = 0;
|
||||
Acb_NtkIncTravId( p );
|
||||
Acb_NtkForEachCo( p, iObj, i )
|
||||
{
|
||||
int Fanin0 = Acb_ObjFanin0(p, iObj);
|
||||
Acb_ObjSetTravIdCur( p, iObj );
|
||||
Acb_ObjSetTravIdCur( p, Fanin0 );
|
||||
if ( Acb_ObjFaninNum(p, Fanin0) == 1 )
|
||||
Acb_ObjSetTravIdCur( p, Acb_ObjFanin0(p, Fanin0) );
|
||||
}
|
||||
Vec_IntForEachEntry( vObjs, iObj, i )
|
||||
Count += Acb_ObjIsTravIdCur(p, iObj);
|
||||
return Count;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Compute MFFC size.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Acb_NtkNodeDeref_rec( Vec_Int_t * vRefs, Acb_Ntk_t * p, int iObj )
|
||||
{
|
||||
int i, Fanin, * pFanins, Counter = 1;
|
||||
if ( Acb_ObjIsCi(p, iObj) )
|
||||
return 0;
|
||||
Acb_ObjForEachFaninFast( p, iObj, pFanins, Fanin, i )
|
||||
{
|
||||
assert( Vec_IntEntry(vRefs, Fanin) > 0 );
|
||||
Vec_IntAddToEntry( vRefs, Fanin, -1 );
|
||||
if ( Vec_IntEntry(vRefs, Fanin) == 0 )
|
||||
Counter += Acb_NtkNodeDeref_rec( vRefs, p, Fanin );
|
||||
}
|
||||
return Counter;
|
||||
}
|
||||
int Acb_NtkNodeRef_rec( Vec_Int_t * vRefs, Acb_Ntk_t * p, int iObj )
|
||||
{
|
||||
int i, Fanin, * pFanins, Counter = 1;
|
||||
if ( Acb_ObjIsCi(p, iObj) )
|
||||
return 0;
|
||||
Acb_ObjForEachFaninFast( p, iObj, pFanins, Fanin, i )
|
||||
{
|
||||
if ( Vec_IntEntry(vRefs, Fanin) == 0 )
|
||||
Counter += Acb_NtkNodeRef_rec( vRefs, p, Fanin );
|
||||
Vec_IntAddToEntry( vRefs, Fanin, 1 );
|
||||
}
|
||||
return Counter;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis [Computing and updating direct and reverse logic level.]
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Acb_NtkCollectDeref_rec( Vec_Int_t * vRefs, Acb_Ntk_t * p, int iObj, Vec_Int_t * vRes )
|
||||
{
|
||||
int i, Fanin, * pFanins;
|
||||
if ( Acb_ObjIsCi(p, iObj) )
|
||||
return;
|
||||
Vec_IntPush( vRes, iObj );
|
||||
Acb_ObjForEachFaninFast( p, iObj, pFanins, Fanin, i )
|
||||
{
|
||||
assert( Vec_IntEntry(vRefs, Fanin) > 0 );
|
||||
Vec_IntAddToEntry( vRefs, Fanin, -1 );
|
||||
if ( Vec_IntEntry(vRefs, Fanin) == 0 )
|
||||
Acb_NtkCollectDeref_rec( vRefs, p, Fanin, vRes );
|
||||
}
|
||||
}
|
||||
Vec_Int_t * Acb_NtkCollectMffc( Acb_Ntk_t * p, Vec_Int_t * vObjsRefed, Vec_Int_t * vObjsDerefed )
|
||||
{
|
||||
Vec_Int_t * vRes = Vec_IntAlloc( 100 );
|
||||
Vec_Int_t * vRefs = Vec_IntStart( Acb_NtkObjNumMax(p) );
|
||||
int i, iObj, Fanin, * pFanins;
|
||||
Acb_NtkForEachObj( p, iObj )
|
||||
Acb_ObjForEachFaninFast( p, iObj, pFanins, Fanin, i )
|
||||
Vec_IntAddToEntry( vRefs, Fanin, 1 );
|
||||
Acb_NtkForEachCo( p, iObj, i )
|
||||
Vec_IntAddToEntry( vRefs, iObj, 1 );
|
||||
if ( vObjsRefed )
|
||||
Vec_IntForEachEntry( vObjsRefed, iObj, i )
|
||||
Vec_IntAddToEntry( vRefs, iObj, 1 );
|
||||
Vec_IntForEachEntry( vObjsDerefed, iObj, i )
|
||||
{
|
||||
if ( Acb_ObjIsCo(p, iObj) )
|
||||
iObj = Acb_ObjFanin0(p, iObj);
|
||||
if ( Vec_IntEntry(vRefs, iObj) != 0 )
|
||||
Acb_NtkCollectDeref_rec( vRefs, p, iObj, vRes );
|
||||
}
|
||||
Vec_IntFree( vRefs );
|
||||
Vec_IntUniqify( vRes );
|
||||
return vRes;
|
||||
}
|
||||
|
||||
Vec_Int_t * Acb_NamesToIds( Acb_Ntk_t * pNtk, Vec_Int_t * vNamesInv, Vec_Ptr_t * vNames )
|
||||
{
|
||||
Vec_Int_t * vRes = Vec_IntAlloc( Vec_PtrSize(vNames) );
|
||||
char * pName; int i;
|
||||
Vec_PtrForEachEntry( char *, vNames, pName, i )
|
||||
{
|
||||
int NameId = Acb_NtkStrId(pNtk, pName);
|
||||
int iObjId = 0;
|
||||
if ( NameId < 1 )
|
||||
printf( "Cannot find name \"%s\" in the network \"%s\".\n", pName, pNtk->pDesign->pName );
|
||||
else
|
||||
iObjId = Vec_IntEntry( vNamesInv, NameId );
|
||||
Vec_IntPush( vRes, iObjId );
|
||||
}
|
||||
return vRes;
|
||||
}
|
||||
int Acb_NtkCollectMfsGates( char * pFileName, Vec_Ptr_t * vNamesRefed, Vec_Ptr_t * vNamesDerefed, int nGates[5] )
|
||||
{
|
||||
Acb_Ntk_t * pNtkF = Acb_VerilogSimpleRead( pFileName, NULL );
|
||||
Vec_Int_t * vNamesInv = Vec_IntInvert( &pNtkF->vObjName, 0 ) ;
|
||||
Vec_Int_t * vObjsRefed = Acb_NamesToIds( pNtkF, vNamesInv, vNamesRefed );
|
||||
Vec_Int_t * vObjsDerefed = Acb_NamesToIds( pNtkF, vNamesInv, vNamesDerefed );
|
||||
Vec_Int_t * vNodes = Acb_NtkCollectMffc( pNtkF, vObjsRefed, vObjsDerefed );
|
||||
int i, iObj, RetValue = Vec_IntSize(vNodes);
|
||||
Vec_IntFree( vNamesInv );
|
||||
Vec_IntFree( vObjsRefed );
|
||||
Vec_IntFree( vObjsDerefed );
|
||||
for ( i = 0; i < 5; i++ )
|
||||
nGates[i] = 0;
|
||||
Vec_IntForEachEntry( vNodes, iObj, i )
|
||||
{
|
||||
int nFan = Acb_ObjFaninNum(pNtkF, iObj);
|
||||
int Type = Acb_ObjType( pNtkF, iObj );
|
||||
if ( Type == ABC_OPER_CONST_F )
|
||||
nGates[0]++;
|
||||
else if ( Type == ABC_OPER_CONST_T )
|
||||
nGates[1]++;
|
||||
else if ( Type == ABC_OPER_BIT_BUF || Type == ABC_OPER_CO )
|
||||
nGates[2]++;
|
||||
else if ( Type == ABC_OPER_BIT_INV )
|
||||
nGates[3]++;
|
||||
else
|
||||
{
|
||||
assert( nFan >= 2 );
|
||||
nGates[4] += Acb_ObjFaninNum(pNtkF, iObj)-1;
|
||||
}
|
||||
}
|
||||
Vec_IntFree( vNodes );
|
||||
Acb_ManFree( pNtkF->pDesign );
|
||||
return RetValue;
|
||||
}
|
||||
Vec_Ptr_t * Acb_NtkReturnMfsGates( char * pFileName, Vec_Ptr_t * vNodes )
|
||||
{
|
||||
Vec_Ptr_t * vMffc = Vec_PtrAlloc( 100 );
|
||||
Acb_Ntk_t * pNtkF = Acb_VerilogSimpleRead( pFileName, NULL );
|
||||
Vec_Int_t * vNamesInv = Vec_IntInvert( &pNtkF->vObjName, 0 ) ;
|
||||
Vec_Int_t * vNodeObjs = Acb_NamesToIds( pNtkF, vNamesInv, vNodes );
|
||||
Vec_Int_t * vNodeMffc = Acb_NtkCollectMffc( pNtkF, NULL, vNodeObjs );
|
||||
int i, iObj;
|
||||
Vec_IntForEachEntry( vNodeMffc, iObj, i )
|
||||
Vec_PtrPush( vMffc, Abc_UtilStrsav( Acb_ObjNameStr(pNtkF, iObj) ) );
|
||||
//Vec_IntPrint( vNodeMffc );
|
||||
//Vec_PtrPrintNames( vMffc );
|
||||
Vec_IntFree( vNodeMffc );
|
||||
Vec_IntFree( vNodeObjs );
|
||||
Vec_IntFree( vNamesInv );
|
||||
Acb_ManFree( pNtkF->pDesign );
|
||||
return vMffc;
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
|
|
@ -671,6 +894,8 @@ int Acb_NtkExtract( char * pFileName0, char * pFileName1, int fUseXors, int fVer
|
|||
int nTargets = Vec_IntSize(&pNtkF->vTargets);
|
||||
Gia_Man_t * pGiaF = Acb_NtkToGia2( pNtkF, fUseBuf, fUseXors, &pNtkF->vTargets, 0 );
|
||||
Gia_Man_t * pGiaG = Acb_NtkToGia2( pNtkG, 0, 0, NULL, nTargets );
|
||||
pGiaF->pSpec = Abc_UtilStrsav( pNtkF->pDesign->pSpec );
|
||||
pGiaG->pSpec = Abc_UtilStrsav( pNtkG->pDesign->pSpec );
|
||||
assert( Acb_NtkCiNum(pNtkF) == Acb_NtkCiNum(pNtkG) );
|
||||
assert( Acb_NtkCoNum(pNtkF) == Acb_NtkCoNum(pNtkG) );
|
||||
*ppGiaF = pGiaF;
|
||||
|
|
@ -784,6 +1009,8 @@ int Abc_NtkExtract( char * pFileName0, char * pFileName1, int fUseXors, int fVer
|
|||
Gia_Man_t * pGiaG = Abc_NtkToGia2( pNtkG, 0 );
|
||||
assert( Abc_NtkCiNum(pNtkF) == Abc_NtkCiNum(pNtkG) );
|
||||
assert( Abc_NtkCoNum(pNtkF) == Abc_NtkCoNum(pNtkG) );
|
||||
pGiaF->pSpec = Abc_UtilStrsav( pNtkF->pSpec );
|
||||
pGiaG->pSpec = Abc_UtilStrsav( pNtkG->pSpec );
|
||||
*ppGiaF = pGiaF;
|
||||
*ppGiaG = pGiaG;
|
||||
*pvNodes = Abc_NtkCollectCopies( pNtkF, pGiaF, pvNodesR, pvPolar );
|
||||
|
|
@ -846,7 +1073,7 @@ Vec_Int_t * Acb_NtkPlaces( char * pFileName, Vec_Ptr_t * vNames )
|
|||
ABC_FREE( pBuffer );
|
||||
return vPlaces;
|
||||
}
|
||||
void Acb_NtkInsert( char * pFileNameIn, char * pFileNameOut, Vec_Ptr_t * vNames, int fNumber )
|
||||
void Acb_NtkInsert( char * pFileNameIn, char * pFileNameOut, Vec_Ptr_t * vNames, int fNumber, int fSkipMffc )
|
||||
{
|
||||
int i, k, Prev = 0, Pos, Pos2, iObj;
|
||||
Vec_Int_t * vPlaces;
|
||||
|
|
@ -864,15 +1091,32 @@ void Acb_NtkInsert( char * pFileNameIn, char * pFileNameOut, Vec_Ptr_t * vNames,
|
|||
printf( "Cannot open input file \"%s\".\n", pFileNameIn );
|
||||
return;
|
||||
}
|
||||
vPlaces = Acb_NtkPlaces( pFileNameIn, vNames );
|
||||
Vec_IntForEachEntryDouble( vPlaces, Pos, iObj, i )
|
||||
if ( fSkipMffc )
|
||||
{
|
||||
for ( k = Prev; k < Pos; k++ )
|
||||
fputc( pBuffer[k], pFile );
|
||||
fprintf( pFile, "// [t_%d = %s] //", iObj, (char *)Vec_PtrEntry(vNames, iObj) );
|
||||
Prev = Pos;
|
||||
Vec_Ptr_t * vMffcNames = Acb_NtkReturnMfsGates( pFileNameIn, vNames );
|
||||
vPlaces = Acb_NtkPlaces( pFileNameIn, vMffcNames );
|
||||
Vec_IntForEachEntryDouble( vPlaces, Pos, iObj, i )
|
||||
{
|
||||
for ( k = Prev; k < Pos; k++ )
|
||||
fputc( pBuffer[k], pFile );
|
||||
fprintf( pFile, "// MFFC %d = %s //", iObj, (char *)Vec_PtrEntry(vMffcNames, iObj) );
|
||||
Prev = Pos;
|
||||
}
|
||||
Vec_IntFree( vPlaces );
|
||||
Vec_PtrFreeFree( vMffcNames );
|
||||
}
|
||||
else
|
||||
{
|
||||
vPlaces = Acb_NtkPlaces( pFileNameIn, vNames );
|
||||
Vec_IntForEachEntryDouble( vPlaces, Pos, iObj, i )
|
||||
{
|
||||
for ( k = Prev; k < Pos; k++ )
|
||||
fputc( pBuffer[k], pFile );
|
||||
fprintf( pFile, "// [t_%d = %s] //", iObj, (char *)Vec_PtrEntry(vNames, iObj) );
|
||||
Prev = Pos;
|
||||
}
|
||||
Vec_IntFree( vPlaces );
|
||||
}
|
||||
Vec_IntFree( vPlaces );
|
||||
pName = strstr(pBuffer, "endmodule");
|
||||
Pos2 = pName - pBuffer;
|
||||
for ( k = Prev; k < Pos2; k++ )
|
||||
|
|
@ -939,7 +1183,7 @@ void Acb_Ntk4CollectRing( Acb_Ntk_t * pNtk, Vec_Int_t * vStart, Vec_Int_t * vRes
|
|||
}
|
||||
void Acb_Ntk4DumpWeightsInt( Acb_Ntk_t * pNtk, Vec_Int_t * vObjs, char * pFileName )
|
||||
{
|
||||
int i, iObj;//, Weight;
|
||||
int i, iObj;//, Count = 0;//, Weight;
|
||||
Vec_Int_t * vDists, * vStart, * vNexts;
|
||||
FILE * pFile = fopen( pFileName, "wb" );
|
||||
if ( pFile == NULL )
|
||||
|
|
@ -971,15 +1215,30 @@ void Acb_Ntk4DumpWeightsInt( Acb_Ntk_t * pNtk, Vec_Int_t * vObjs, char * pFileNa
|
|||
// Vec_IntForEachEntry( vDists, Weight, i )
|
||||
// if ( Weight && Acb_ObjNameStr(pNtk, i)[0] != '1' )
|
||||
// fprintf( pFile, "%s %d\n", Acb_ObjNameStr(pNtk, i), 10000+Weight );
|
||||
/*
|
||||
// mark reachable
|
||||
Vec_IntClear( &pNtk->vArray0 );
|
||||
Acb_NtkIncTravId( pNtk );
|
||||
Acb_NtkForEachCo( pNtk, iObj, i )
|
||||
if ( !Vec_IntEntry(vStatus, i) )
|
||||
Acb_ObjCollectTfi_rec( pNtk, iObj, 0 );
|
||||
*/
|
||||
Acb_NtkForEachObj( pNtk, iObj )
|
||||
{
|
||||
char * pName = Acb_ObjNameStr(pNtk, iObj);
|
||||
int Weight = Vec_IntEntry(vDists, iObj);
|
||||
if ( Weight == 0 )
|
||||
Weight = 10000;
|
||||
/*
|
||||
if ( !Acb_ObjSetTravIdCur(pNtk, iObj) )
|
||||
{
|
||||
Count++;
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
fprintf( pFile, "%s %d\n", pName, 100000+Weight );
|
||||
}
|
||||
|
||||
//printf( "Skipped %d nodes.\n", Count );
|
||||
Vec_IntFree( vDists );
|
||||
fclose( pFile );
|
||||
}
|
||||
|
|
@ -1000,27 +1259,6 @@ void Acb_Ntk4DumpWeights( char * pFileNameIn, Vec_Ptr_t * vObjNames, char * pFil
|
|||
Vec_IntFree( vObjs );
|
||||
}
|
||||
|
||||
/**Function*************************************************************
|
||||
|
||||
Synopsis []
|
||||
|
||||
Description []
|
||||
|
||||
SideEffects []
|
||||
|
||||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
void Acb_NtkRunSim( char * pFileName[4], int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fRandom, int fUseWeights, int fVerbose, int fVeryVerbose )
|
||||
{
|
||||
extern int Gia_Sim4Try( char * pFileName0, char * pFileName1, char * pFileName2, int nWords, int nBeam, int LevL, int LevU, int fOrder, int fFancy, int fUseBuf, int fVerbose );
|
||||
extern void Acb_NtkRunEco( char * pFileNames[4], int fCheck, int fRandom, int fVerbose, int fVeryVerbose );
|
||||
char * pFileNames[4] = { pFileName[2], pFileName[1], fUseWeights ? (char *)"weights.txt" : NULL, pFileName[2] };
|
||||
if ( Gia_Sim4Try( pFileName[0], pFileName[1], pFileName[2], nWords, nBeam, LevL, LevU, fOrder, fFancy, fUseBuf, fVerbose ) )
|
||||
Acb_NtkRunEco( pFileNames, 1, fRandom, fVerbose, fVeryVerbose );
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
/// END OF FILE ///
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue