Converting mapped AIG into strashed AIG.

This commit is contained in:
Alan Mishchenko 2013-09-30 22:41:55 -07:00
parent 4f72aff1d1
commit 1fb7ef8153
5 changed files with 76 additions and 12 deletions

View File

@ -21,6 +21,7 @@
#include "gia.h"
#include "misc/vec/vecHash.h"
#include "misc/vec/vecQue.h"
#include "opt/dau/dau.h"
ABC_NAMESPACE_IMPL_START
@ -906,7 +907,7 @@ Gia_Man_t * Dam_ManMultiExtractInt( Gia_Man_t * pGia, int nNewNodesMax, int fVer
int i, iDiv;
p = Dam_ManAlloc( pGia );
Dam_ManCreatePairs( p, fVerbose );
for ( i = 0; i < nNewNodesMax && Vec_QueTopCost(p->vQue) > 0; i++ )
for ( i = 0; i < nNewNodesMax && Vec_QueTopCost(p->vQue) > 2; i++ )
{
iDiv = Vec_QuePop(p->vQue);
if ( fVeryVerbose )
@ -932,13 +933,19 @@ Gia_Man_t * Dam_ManMultiExtractInt( Gia_Man_t * pGia, int nNewNodesMax, int fVer
}
Gia_Man_t * Gia_ManAreaBalance( Gia_Man_t * p, int fSimpleAnd, int nNewNodesMax, int fVerbose, int fVeryVerbose )
{
Gia_Man_t * pNew, * pNew1, * pNew2;
if ( fVerbose ) Gia_ManPrintStats( p, NULL );
pNew = fSimpleAnd ? Gia_ManDup( p ) : Gia_ManDupMuxes( p );
Gia_Man_t * pNew0, * pNew, * pNew1, * pNew2;
// get the starting manager
pNew0 = Gia_ManHasMapping(p) ? (Gia_Man_t *)Dsm_ManDeriveGia(p) : p;
if ( fVerbose ) Gia_ManPrintStats( pNew0, NULL );
// derive internal manager
pNew = fSimpleAnd ? Gia_ManDup( pNew0 ) : Gia_ManDupMuxes( pNew0 );
if ( fVerbose ) Gia_ManPrintStats( pNew, NULL );
if ( pNew0 != p ) Gia_ManStop( pNew0 );
// perform the operation
pNew1 = Dam_ManMultiExtractInt( pNew, nNewNodesMax, fVerbose, fVeryVerbose );
if ( fVerbose ) Gia_ManPrintStats( pNew1, NULL );
Gia_ManStop( pNew );
// derive the final result
pNew2 = Gia_ManDupNoMuxes( pNew1 );
if ( fVerbose ) Gia_ManPrintStats( pNew2, NULL );
Gia_ManStop( pNew1 );

View File

@ -1499,7 +1499,7 @@ Gia_Man_t * Jf_ManDeriveGia( Jf_Man_t * p )
Jf_CutForEachLit( pCut, iLit, k )
Vec_IntPush( vLeaves, Abc_Lit2LitL(Vec_IntArray(vCopies), iLit) );
// create GIA
iLit = Dsm_ManDeriveGia( pNew, pTruth, vLeaves, vCover );
iLit = Dsm_ManTruthToGia( pNew, pTruth, vLeaves, vCover );
iLit = Abc_LitNotCond( iLit, (p->pPars->fCutMin && Jf_CutFuncCompl(pCut)) );
Vec_IntWriteEntry( vCopies, i, iLit );
}

View File

@ -27553,11 +27553,6 @@ int Abc_CommandAbc9Balance( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Abc_CommandAbc9Balance(): There is no AIG.\n" );
return 1;
}
if ( Gia_ManHasMapping(pAbc->pGia) )
{
Abc_Print( -1, "Abc_CommandAbc9Balance(): The current AIG is mapped.\n" );
return 1;
}
if ( fDelayOnly )
pTemp = Gia_ManBalance( pAbc->pGia, fSimpleAnd, fVerbose );
else

View File

@ -88,7 +88,8 @@ extern void Dau_DsdTruthCompose_rec( word * pFunc, word pFanins[DAU_MAX
extern int Dau_DsdCheck1Step( word * pTruth, int nVarsInit );
/*=== dauGia.c ==========================================================*/
extern int Dsm_ManDeriveGia( void * p, word * pTruth, Vec_Int_t * vLeaves, Vec_Int_t * vCover );
extern int Dsm_ManTruthToGia( void * p, word * pTruth, Vec_Int_t * vLeaves, Vec_Int_t * vCover );
extern void * Dsm_ManDeriveGia( void * p );
/*=== dauMerge.c ==========================================================*/
extern void Dau_DsdRemoveBraces( char * pDsd, int * pMatches );

View File

@ -207,7 +207,7 @@ int Dau_DsdToGia( Gia_Man_t * pGia, char * p, int * pLits, Vec_Int_t * vCover )
SeeAlso []
***********************************************************************/
int Dsm_ManDeriveGia( void * p, word * pTruth, Vec_Int_t * vLeaves, Vec_Int_t * vCover )
int Dsm_ManTruthToGia( void * p, word * pTruth, Vec_Int_t * vLeaves, Vec_Int_t * vCover )
{
Gia_Man_t * pGia = (Gia_Man_t *)p;
char pDsd[1000];
@ -239,6 +239,67 @@ void Dsm_ManReportStats()
m_Calls = m_NonDsd = m_Non1Step = 0;
}
/**Function*************************************************************
Synopsis [Performs structural hashing on the LUT functions.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void * Dsm_ManDeriveGia( void * pGia )
{
Gia_Man_t * p = (Gia_Man_t *)pGia;
Gia_Man_t * pNew, * pTemp;
Vec_Int_t * vCover, * vLeaves;
Gia_Obj_t * pObj;
int k, i, iLut, iVar;
word * pTruth;
assert( Gia_ManHasMapping(p) );
// create new manager
pNew = Gia_ManStart( Gia_ManObjNum(p) );
pNew->pName = Abc_UtilStrsav( p->pName );
pNew->pSpec = Abc_UtilStrsav( p->pSpec );
// map primary inputs
Gia_ManFillValue(p);
Gia_ManConst0(p)->Value = 0;
Gia_ManForEachCi( p, pObj, i )
pObj->Value = Gia_ManAppendCi(pNew);
// iterate through nodes used in the mapping
vLeaves = Vec_IntAlloc( 16 );
vCover = Vec_IntAlloc( 1 << 16 );
Gia_ManHashStart( pNew );
Gia_ObjComputeTruthTableStart( p, Gia_ManLutSizeMax(p) );
Gia_ManForEachLut( p, iLut )
{
// collect leaves
Vec_IntClear( vLeaves );
Gia_LutForEachFanin( p, iLut, iVar, k )
Vec_IntPush( vLeaves, iVar );
pTruth = Gia_ObjComputeTruthTableCut( p, Gia_ManObj(p, iLut), vLeaves );
// collect incoming literals
Vec_IntClear( vLeaves );
Gia_LutForEachFanin( p, iLut, iVar, k )
Vec_IntPush( vLeaves, Gia_ManObj(p, iVar)->Value );
Gia_ManObj(p, iLut)->Value = Dsm_ManTruthToGia( pNew, pTruth, vLeaves, vCover );
}
Gia_ObjComputeTruthTableStop( p );
Gia_ManForEachCo( p, pObj, i )
pObj->Value = Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) );
Gia_ManHashStop( pNew );
Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) );
Vec_IntFree( vLeaves );
Vec_IntFree( vCover );
// perform cleanup
pNew = Gia_ManCleanup( pTemp = pNew );
Gia_ManStop( pTemp );
return pNew;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///