summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2013-09-30 22:41:55 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2013-09-30 22:41:55 -0700
commit1fb7ef8153eb42bc8b614f109571c9e47138b956 (patch)
tree4dbed89f936a808c2b73343289f9716a33e5ab6a /src
parent4f72aff1d164b1ebb190ac5e1e7a5c01d8d1e720 (diff)
downloadabc-1fb7ef8153eb42bc8b614f109571c9e47138b956.tar.gz
abc-1fb7ef8153eb42bc8b614f109571c9e47138b956.tar.bz2
abc-1fb7ef8153eb42bc8b614f109571c9e47138b956.zip
Converting mapped AIG into strashed AIG.
Diffstat (limited to 'src')
-rw-r--r--src/aig/gia/giaBalance.c15
-rw-r--r--src/aig/gia/giaJf.c2
-rw-r--r--src/base/abci/abc.c5
-rw-r--r--src/opt/dau/dau.h3
-rw-r--r--src/opt/dau/dauGia.c63
5 files changed, 76 insertions, 12 deletions
diff --git a/src/aig/gia/giaBalance.c b/src/aig/gia/giaBalance.c
index 6f1b615c..3aa17845 100644
--- a/src/aig/gia/giaBalance.c
+++ b/src/aig/gia/giaBalance.c
@@ -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 );
diff --git a/src/aig/gia/giaJf.c b/src/aig/gia/giaJf.c
index e330fb80..6af8a4b3 100644
--- a/src/aig/gia/giaJf.c
+++ b/src/aig/gia/giaJf.c
@@ -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 );
}
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index 7b9c8f82..675e9734 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -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
diff --git a/src/opt/dau/dau.h b/src/opt/dau/dau.h
index f91d2831..a928fecf 100644
--- a/src/opt/dau/dau.h
+++ b/src/opt/dau/dau.h
@@ -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 );
diff --git a/src/opt/dau/dauGia.c b/src/opt/dau/dauGia.c
index 7e7d9094..a714f622 100644
--- a/src/opt/dau/dauGia.c
+++ b/src/opt/dau/dauGia.c
@@ -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 ///