Commit 61ee156b by Alan Mishchenko

New logic sharing extraction.

parent f9b11cc9
......@@ -2791,6 +2791,10 @@ SOURCE=.\src\misc\vec\vecHash.h
# End Source File
# Begin Source File
SOURCE=.\src\misc\vec\vecHsh.h
# End Source File
# Begin Source File
SOURCE=.\src\misc\vec\vecInt.h
# End Source File
# Begin Source File
......
......@@ -179,8 +179,8 @@ struct Gia_Man_t_
Vec_Ptr_t * vTtInputs; // truth tables for constant and primary inputs
Vec_Wrd_t * vTtMemory; // truth tables for internal nodes
// balancing
Vec_Int_t * vStore; // node storage
Vec_Int_t * vSuper; // supergate
Vec_Int_t * vStore; // node storage
};
......@@ -929,7 +929,9 @@ extern void Gia_DumpAiger( Gia_Man_t * p, char * pFilePrefix, int
extern Vec_Str_t * Gia_AigerWriteIntoMemoryStr( Gia_Man_t * p );
extern Vec_Str_t * Gia_AigerWriteIntoMemoryStrPart( Gia_Man_t * p, Vec_Int_t * vCis, Vec_Int_t * vAnds, Vec_Int_t * vCos, int nRegs );
extern void Gia_AigerWriteSimple( Gia_Man_t * pInit, char * pFileName );
/*=== giaBalance.c ===========================================================*/
extern Gia_Man_t * Gia_ManBalance( Gia_Man_t * p, int fSimpleAnd, int fVerbose );
extern Gia_Man_t * Gia_ManMultiExtract( Gia_Man_t * p, int fSimpleAnd, int nNewNodesMax, int fVerbose );
/*=== giaBidec.c ===========================================================*/
extern unsigned * Gia_ManConvertAigToTruth( Gia_Man_t * p, Gia_Obj_t * pRoot, Vec_Int_t * vLeaves, Vec_Int_t * vTruth, Vec_Int_t * vVisited );
extern Gia_Man_t * Gia_ManPerformBidec( Gia_Man_t * p, int fVerbose );
......
......@@ -518,6 +518,12 @@ int Gia_ManHashMuxReal( Gia_Man_t * p, int iLitC, int iLit1, int iLit0 )
{
int fCompl = 0;
assert( p->fAddStrash == 0 );
if ( iLitC < 2 )
return iLitC ? iLit1 : iLit0;
if ( iLit0 < 2 )
return iLit0 ? Gia_ManHashOr(p, Abc_LitNot(iLitC), iLit1) : Gia_ManHashAnd(p, iLitC, iLit1);
if ( iLit1 < 2 )
return iLit1 ? Gia_ManHashOr(p, iLitC, iLit0) : Gia_ManHashAnd(p, Abc_LitNot(iLitC), iLit0);
assert( iLit0 > 1 && iLit1 > 1 && iLitC > 1 );
if ( iLit0 == iLit1 )
return iLit0;
......
......@@ -77,6 +77,8 @@ void Gia_ManStop( Gia_Man_t * p )
assert( p->pManTime == NULL );
Vec_PtrFreeFree( p->vNamesIn );
Vec_PtrFreeFree( p->vNamesOut );
Vec_IntFreeP( &p->vSuper );
Vec_IntFreeP( &p->vStore );
Vec_IntFreeP( &p->vClassNew );
Vec_IntFreeP( &p->vClassOld );
Vec_WrdFreeP( &p->vSims );
......@@ -335,13 +337,19 @@ void Gia_ManPrintStats( Gia_Man_t * p, Gps_Par_t * pPars )
Abc_Print( 1, "(c=%d)", Gia_ManConstrNum(p) );
if ( Gia_ManRegNum(p) )
Abc_Print( 1, " ff =%7d", Gia_ManRegNum(p) );
Abc_Print( 1, " and =%8d", Gia_ManAndNum(p) );
Abc_Print( 1, " %s =%8d", p->pMuxes? "nod" : "and", Gia_ManAndNum(p) );
Abc_Print( 1, " lev =%5d", Gia_ManLevelNum(p) ); Vec_IntFreeP( &p->vLevels );
if ( pPars && pPars->fCut )
Abc_Print( 1, " cut = %d(%d)", Gia_ManCrossCut(p, 0), Gia_ManCrossCut(p, 1) );
Abc_Print( 1, " mem =%5.2f MB", Gia_ManMemory(p)/(1<<20) );
if ( Gia_ManHasDangling(p) )
Abc_Print( 1, " ch =%5d", Gia_ManEquivCountClasses(p) );
if ( p->pMuxes )
{
Abc_Print( 1, " and =%5d", Gia_ManAndNum(p)-Gia_ManXorNum(p)-Gia_ManMuxNum(p) );
Abc_Print( 1, " xor =%5d", Gia_ManXorNum(p) );
Abc_Print( 1, " mux =%5d", Gia_ManMuxNum(p) );
}
if ( pPars && pPars->fSwitch )
{
if ( p->pSwitching )
......
......@@ -1008,13 +1008,19 @@ int Gia_ManHasDangling( Gia_Man_t * p )
Gia_ManForEachObj( p, pObj, i )
{
pObj->fMark0 = 0;
if ( Gia_ObjIsAnd(pObj) )
if ( Gia_ObjIsCo(pObj) )
Gia_ObjFanin0(pObj)->fMark0 = 1;
else if ( Gia_ObjIsMux(p, pObj) )
{
Gia_ObjFanin0(pObj)->fMark0 = 1;
Gia_ObjFanin1(pObj)->fMark0 = 1;
Gia_ObjFanin2(p, pObj)->fMark0 = 1;
}
else if ( Gia_ObjIsCo(pObj) )
else if ( Gia_ObjIsAnd(pObj) )
{
Gia_ObjFanin0(pObj)->fMark0 = 1;
Gia_ObjFanin1(pObj)->fMark0 = 1;
}
}
Gia_ManForEachAnd( p, pObj, i )
Counter += !pObj->fMark0;
......
......@@ -27410,12 +27410,13 @@ usage:
int Abc_CommandAbc9Balance( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Gia_Man_t * pTemp = NULL;
int c,fVerbose = 0;
int fSimpleAnd = 0;
int fKeepLevel = 0;
int nFanoutMax = 50;
int nNewNodesMax = ABC_INFINITY;
int fMultiExt = 0;
int fSimpleAnd = 0;
int fKeepLevel = 0;
int c, fVerbose = 1;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "Nlavh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "Nealvh" ) ) != EOF )
{
switch ( c )
{
......@@ -27425,17 +27426,20 @@ int Abc_CommandAbc9Balance( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Command line switch \"-N\" should be followed by a char string.\n" );
goto usage;
}
nFanoutMax = atoi(argv[globalUtilOptind]);
nNewNodesMax = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nFanoutMax < 0 )
if ( nNewNodesMax < 0 )
goto usage;
break;
case 'l':
fKeepLevel ^= 1;
case 'e':
fMultiExt ^= 1;
break;
case 'a':
fSimpleAnd ^= 1;
break;
case 'l':
fKeepLevel ^= 1;
break;
case 'v':
fVerbose ^= 1;
break;
......@@ -27455,14 +27459,20 @@ int Abc_CommandAbc9Balance( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Abc_CommandAbc9Balance(): The current AIG is mapped.\n" );
return 1;
}
pTemp = Gia_ManBalance( pAbc->pGia, fSimpleAnd, fVerbose );
if ( fMultiExt )
pTemp = Gia_ManMultiExtract( pAbc->pGia, fSimpleAnd, nNewNodesMax, fVerbose );
else
pTemp = Gia_ManBalance( pAbc->pGia, fSimpleAnd, fVerbose );
Abc_FrameUpdateGia( pAbc, pTemp );
return 0;
usage:
Abc_Print( -2, "usage: &b [-avh]\n" );
Abc_Print( -2, "usage: &b [-N num] [-ealvh]\n" );
Abc_Print( -2, "\t performs AIG balancing to reduce delay\n" );
Abc_Print( -2, "\t-N num : the max fanout count to skip a divisor [default = %d]\n", nNewNodesMax );
Abc_Print( -2, "\t-e : toggle extacting shared logic while balancing [default = %s]\n", fMultiExt? "yes": "no" );
Abc_Print( -2, "\t-a : toggle using AND instead of AND/XOR/MUX [default = %s]\n", fSimpleAnd? "yes": "no" );
Abc_Print( -2, "\t-l : toggle level update during shrinking [default = %s]\n", fKeepLevel? "yes": "no" );
Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment