summaryrefslogtreecommitdiffstats
path: root/src/aig/gia
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2014-06-12 21:27:14 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2014-06-12 21:27:14 -0700
commitfcdd9148b456e7efec1db8b4cf81adbb305401d7 (patch)
tree99b8147233b967ecba6ba18fcaf16fffb40801ba /src/aig/gia
parent865f6fd43fb55f4873275c2ceeae79d32f4f4d9b (diff)
downloadabc-fcdd9148b456e7efec1db8b4cf81adbb305401d7.tar.gz
abc-fcdd9148b456e7efec1db8b4cf81adbb305401d7.tar.bz2
abc-fcdd9148b456e7efec1db8b4cf81adbb305401d7.zip
Various modifications.
Diffstat (limited to 'src/aig/gia')
-rw-r--r--src/aig/gia/gia.h9
-rw-r--r--src/aig/gia/giaBalance.c16
-rw-r--r--src/aig/gia/giaMan.c29
-rw-r--r--src/aig/gia/giaMuxes.c61
-rw-r--r--src/aig/gia/giaResub.c2
-rw-r--r--src/aig/gia/giaSwitch.c1
-rw-r--r--src/aig/gia/giaUtil.c28
7 files changed, 77 insertions, 69 deletions
diff --git a/src/aig/gia/gia.h b/src/aig/gia/gia.h
index 011f4f91..38f70c9c 100644
--- a/src/aig/gia/gia.h
+++ b/src/aig/gia/gia.h
@@ -927,10 +927,14 @@ static inline int Gia_ObjLutFanin( Gia_Man_t * p, int Id, int i ) { re
for ( i = 0; (i < p->nObjs) && ((pObj) = Gia_ManObj(p, i)); i++ ) if ( !Gia_ObjIsMuxId(p, i) ) {} else
#define Gia_ManForEachCi( p, pObj, i ) \
for ( i = 0; (i < Vec_IntSize(p->vCis)) && ((pObj) = Gia_ManCi(p, i)); i++ )
+#define Gia_ManForEachCiId( p, Id, i ) \
+ for ( i = 0; (i < Vec_IntSize(p->vCis)) && ((Id) = Gia_ObjId(p, Gia_ManCi(p, i))); i++ )
#define Gia_ManForEachCiReverse( p, pObj, i ) \
for ( i = Vec_IntSize(p->vCis) - 1; (i >= 0) && ((pObj) = Gia_ManCi(p, i)); i-- )
#define Gia_ManForEachCo( p, pObj, i ) \
for ( i = 0; (i < Vec_IntSize(p->vCos)) && ((pObj) = Gia_ManCo(p, i)); i++ )
+#define Gia_ManForEachCoId( p, Id, i ) \
+ for ( i = 0; (i < Vec_IntSize(p->vCos)) && ((Id) = Gia_ObjId(p, Gia_ManCo(p, i))); i++ )
#define Gia_ManForEachCoReverse( p, pObj, i ) \
for ( i = Vec_IntSize(p->vCos) - 1; (i >= 0) && ((pObj) = Gia_ManCo(p, i)); i-- )
#define Gia_ManForEachCoDriver( p, pObj, i ) \
@@ -1172,7 +1176,9 @@ extern int Gia_MmStepReadMemUsage( Gia_MmStep_t * p );
extern Gia_Man_t * Gia_ManReadMiniAig( char * pFileName );
extern void Gia_ManWriteMiniAig( Gia_Man_t * pGia, char * pFileName );
/*=== giaMuxes.c ===========================================================*/
-extern Gia_Man_t * Gia_ManDupMuxes( Gia_Man_t * p );
+extern void Gia_ManCountMuxXor( Gia_Man_t * p, int * pnMuxes, int * pnXors );
+extern void Gia_ManPrintMuxStats( Gia_Man_t * p );
+extern Gia_Man_t * Gia_ManDupMuxes( Gia_Man_t * p, int Limit );
extern Gia_Man_t * Gia_ManDupNoMuxes( Gia_Man_t * p );
/*=== giaPat.c ===========================================================*/
extern void Gia_SatVerifyPattern( Gia_Man_t * p, Gia_Obj_t * pRoot, Vec_Int_t * vCex, Vec_Int_t * vVisit );
@@ -1282,7 +1288,6 @@ extern Vec_Int_t * Gia_ManRequiredLevel( Gia_Man_t * p );
extern void Gia_ManCreateValueRefs( Gia_Man_t * p );
extern void Gia_ManCreateRefs( Gia_Man_t * p );
extern int * Gia_ManCreateMuxRefs( Gia_Man_t * p );
-extern void Gia_ManCountMuxXor( Gia_Man_t * p, int * pnMuxes, int * pnXors );
extern int Gia_ManCrossCut( Gia_Man_t * p, int fReverse );
extern int Gia_ManIsNormalized( Gia_Man_t * p );
extern Vec_Int_t * Gia_ManCollectPoIds( Gia_Man_t * p );
diff --git a/src/aig/gia/giaBalance.c b/src/aig/gia/giaBalance.c
index 77b85b48..9760cf39 100644
--- a/src/aig/gia/giaBalance.c
+++ b/src/aig/gia/giaBalance.c
@@ -358,7 +358,7 @@ Gia_Man_t * Gia_ManBalance( Gia_Man_t * p, int fSimpleAnd, int fVerbose )
{
Gia_Man_t * pNew, * pNew1, * pNew2;
if ( fVerbose ) Gia_ManPrintStats( p, NULL );
- pNew = fSimpleAnd ? Gia_ManDup( p ) : Gia_ManDupMuxes( p );
+ pNew = fSimpleAnd ? Gia_ManDup( p ) : Gia_ManDupMuxes( p, 2 );
if ( fVerbose ) Gia_ManPrintStats( pNew, NULL );
pNew1 = Gia_ManBalanceInt( pNew );
if ( fVerbose ) Gia_ManPrintStats( pNew1, NULL );
@@ -958,7 +958,7 @@ Gia_Man_t * Gia_ManAreaBalance( Gia_Man_t * p, int fSimpleAnd, int nNewNodesMax,
pNew0 = Gia_ManHasMapping(p) ? (Gia_Man_t *)Dsm_ManDeriveGia(p, 0) : p;
if ( fVerbose ) Gia_ManPrintStats( pNew0, NULL );
// derive internal manager
- pNew = fSimpleAnd ? Gia_ManDup( pNew0 ) : Gia_ManDupMuxes( pNew0 );
+ pNew = fSimpleAnd ? Gia_ManDup( pNew0 ) : Gia_ManDupMuxes( pNew0, 2 );
if ( fVerbose ) Gia_ManPrintStats( pNew, NULL );
if ( pNew0 != p ) Gia_ManStop( pNew0 );
// perform the operation
@@ -1046,7 +1046,7 @@ Gia_Man_t * Gia_ManAigSyn3( Gia_Man_t * p, int fVerbose, int fVeryVerbose )
{
Gia_Man_t * pNew, * pTemp;
Jf_Par_t Pars, * pPars = &Pars;
- Lf_ManSetDefaultPars( pPars );
+ Jf_ManSetDefaultPars( pPars );
pPars->nRelaxRatio = 40;
if ( fVerbose ) Gia_ManPrintStats( p, NULL );
if ( Gia_ManAndNum(p) == 0 )
@@ -1057,7 +1057,7 @@ Gia_Man_t * Gia_ManAigSyn3( Gia_Man_t * p, int fVerbose, int fVeryVerbose )
Gia_ManAigTransferPiLevels( pNew, p );
// perform mapping
pPars->nLutSize = 6;
- pNew = Lf_ManPerformMapping( pTemp = pNew, pPars );
+ pNew = Jf_ManPerformMapping( pTemp = pNew, pPars );
if ( fVerbose ) Gia_ManPrintStats( pNew, NULL );
// Gia_ManStop( pTemp );
// perform balancing
@@ -1067,7 +1067,7 @@ Gia_Man_t * Gia_ManAigSyn3( Gia_Man_t * p, int fVerbose, int fVeryVerbose )
Gia_ManStop( pTemp );
// perform mapping
pPars->nLutSize = 4;
- pNew = Lf_ManPerformMapping( pTemp = pNew, pPars );
+ pNew = Jf_ManPerformMapping( pTemp = pNew, pPars );
if ( fVerbose ) Gia_ManPrintStats( pNew, NULL );
// Gia_ManStop( pTemp );
// perform balancing
@@ -1081,7 +1081,7 @@ Gia_Man_t * Gia_ManAigSyn4( Gia_Man_t * p, int fVerbose, int fVeryVerbose )
{
Gia_Man_t * pNew, * pTemp;
Jf_Par_t Pars, * pPars = &Pars;
- Lf_ManSetDefaultPars( pPars );
+ Jf_ManSetDefaultPars( pPars );
pPars->nRelaxRatio = 40;
if ( fVerbose ) Gia_ManPrintStats( p, NULL );
if ( Gia_ManAndNum(p) == 0 )
@@ -1093,7 +1093,7 @@ Gia_Man_t * Gia_ManAigSyn4( Gia_Man_t * p, int fVerbose, int fVeryVerbose )
Gia_ManAigTransferPiLevels( pNew, p );
// perform mapping
pPars->nLutSize = 7;
- pNew = Lf_ManPerformMapping( pTemp = pNew, pPars );
+ pNew = Jf_ManPerformMapping( pTemp = pNew, pPars );
if ( fVerbose ) Gia_ManPrintStats( pNew, NULL );
// Gia_ManStop( pTemp );
// perform extraction
@@ -1108,7 +1108,7 @@ Gia_Man_t * Gia_ManAigSyn4( Gia_Man_t * p, int fVerbose, int fVeryVerbose )
Gia_ManStop( pTemp );
// perform mapping
pPars->nLutSize = 5;
- pNew = Lf_ManPerformMapping( pTemp = pNew, pPars );
+ pNew = Jf_ManPerformMapping( pTemp = pNew, pPars );
if ( fVerbose ) Gia_ManPrintStats( pNew, NULL );
// Gia_ManStop( pTemp );
// perform extraction
diff --git a/src/aig/gia/giaMan.c b/src/aig/gia/giaMan.c
index 3b9e6d3b..f1470287 100644
--- a/src/aig/gia/giaMan.c
+++ b/src/aig/gia/giaMan.c
@@ -421,32 +421,13 @@ void Gia_ManPrintStats( Gia_Man_t * p, Gps_Par_t * pPars )
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 )
- {
- int nAnds = Gia_ManAndNum(p)-Gia_ManXorNum(p)-Gia_ManMuxNum(p);
- int nXors = Gia_ManXorNum(p);
- int nMuxes = Gia_ManMuxNum(p);
- int nTotal = nAnds + 3*nXors + 3*nMuxes;
- Abc_Print( 1, "\nXOR/MUX stats:" );
- Abc_Print( 1, " xor =%8d (%6.2f %%) ", nXors, 300.0*nXors/nTotal );
- Abc_Print( 1, " mux =%8d (%6.2f %%) ", nMuxes, 300.0*nMuxes/nTotal );
- Abc_Print( 1, " and =%8d (%6.2f %%) ", nAnds, 100.0*nAnds/nTotal );
- }
- else if ( pPars->fMuxXor )
- {
- int nAnds, nMuxes, nXors, nTotal = Gia_ManAndNum(p);
- Gia_ManCountMuxXor( p, &nMuxes, &nXors );
- nAnds = Gia_ManAndNum(p)-3*nMuxes-3*nXors;
- Abc_Print( 1, "\nXOR/MUX stats:" );
- Abc_Print( 1, " xor =%8d (%6.2f %%) ", nXors, 300.0*nXors/nTotal );
- Abc_Print( 1, " mux =%8d (%6.2f %%) ", nMuxes, 300.0*nMuxes/nTotal );
- Abc_Print( 1, " and =%8d (%6.2f %%) ", nAnds, 100.0*nAnds/nTotal );
- }
+ if ( pPars && pPars->fMuxXor )
+ printf( "\nXOR/MUX " ), Gia_ManPrintMuxStats( p );
if ( pPars && pPars->fSwitch )
{
- if ( p->pSwitching )
- Abc_Print( 1, " power =%7.2f", Gia_ManEvaluateSwitching(p) );
- else
+// if ( p->pSwitching )
+// Abc_Print( 1, " power =%7.2f", Gia_ManEvaluateSwitching(p) );
+// else
Abc_Print( 1, " power =%7.2f", Gia_ManComputeSwitching(p, 48, 16, 0) );
}
// Abc_Print( 1, "obj =%5d ", Gia_ManObjNum(p) );
diff --git a/src/aig/gia/giaMuxes.c b/src/aig/gia/giaMuxes.c
index b4afe214..db44e219 100644
--- a/src/aig/gia/giaMuxes.c
+++ b/src/aig/gia/giaMuxes.c
@@ -33,7 +33,7 @@ ABC_NAMESPACE_IMPL_START
/**Function*************************************************************
- Synopsis [Derives GIA with MUXes.]
+ Synopsis [Counts XORs and MUXes.]
Description []
@@ -42,7 +42,56 @@ ABC_NAMESPACE_IMPL_START
SeeAlso []
***********************************************************************/
-Gia_Man_t * Gia_ManDupMuxes( Gia_Man_t * p )
+void Gia_ManCountMuxXor( Gia_Man_t * p, int * pnMuxes, int * pnXors )
+{
+ Gia_Obj_t * pObj, * pFan0, * pFan1; int i;
+ *pnMuxes = *pnXors = 0;
+ Gia_ManForEachAnd( p, pObj, i )
+ {
+ if ( !Gia_ObjIsMuxType(pObj) )
+ continue;
+ if ( Gia_ObjRecognizeExor(pObj, &pFan0, &pFan1) )
+ (*pnXors)++;
+ else
+ (*pnMuxes)++;
+ }
+}
+void Gia_ManPrintMuxStats( Gia_Man_t * p )
+{
+ int nAnds, nMuxes, nXors, nTotal;
+ if ( p->pMuxes )
+ {
+ nAnds = Gia_ManAndNum(p)-Gia_ManXorNum(p)-Gia_ManMuxNum(p);
+ nXors = Gia_ManXorNum(p);
+ nMuxes = Gia_ManMuxNum(p);
+ nTotal = nAnds + 3*nXors + 3*nMuxes;
+ }
+ else
+ {
+ Gia_ManCountMuxXor( p, &nMuxes, &nXors );
+ nAnds = Gia_ManAndNum(p) - 3*nMuxes - 3*nXors;
+ nTotal = Gia_ManAndNum(p);
+ }
+ Abc_Print( 1, "stats: " );
+ Abc_Print( 1, "xor =%8d %6.2f %% ", nXors, 300.0*nXors/nTotal );
+ Abc_Print( 1, "mux =%8d %6.2f %% ", nMuxes, 300.0*nMuxes/nTotal );
+ Abc_Print( 1, "and =%8d %6.2f %% ", nAnds, 100.0*nAnds/nTotal );
+ Abc_Print( 1, "obj =%8d ", Gia_ManAndNum(p) );
+ fflush( stdout );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Derives GIA with MUXes.]
+
+ Description [Create MUX if the sum of fanin references does not exceed limit.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+Gia_Man_t * Gia_ManDupMuxes( Gia_Man_t * p, int Limit )
{
Gia_Man_t * pNew, * pTemp;
Gia_Obj_t * pObj, * pFan0, * pFan1, * pFanC;
@@ -51,7 +100,7 @@ Gia_Man_t * Gia_ManDupMuxes( Gia_Man_t * p )
ABC_FREE( p->pRefs );
Gia_ManCreateRefs( p );
// start the new manager
- pNew = Gia_ManStart( 5000 );
+ pNew = Gia_ManStart( Gia_ManObjNum(p) );
pNew->pName = Abc_UtilStrsav( p->pName );
pNew->pSpec = Abc_UtilStrsav( p->pSpec );
pNew->pMuxes = ABC_CALLOC( unsigned, pNew->nObjsAlloc );
@@ -64,7 +113,7 @@ Gia_Man_t * Gia_ManDupMuxes( Gia_Man_t * p )
Gia_ManHashStart( pNew );
Gia_ManForEachAnd( p, pObj, i )
{
- if ( !Gia_ObjIsMuxType(pObj) || (Gia_ObjRefNum(p, Gia_ObjFanin0(pObj)) > 1 || Gia_ObjRefNum(p, Gia_ObjFanin1(pObj)) > 1) )
+ if ( !Gia_ObjIsMuxType(pObj) || Gia_ObjRefNum(p, Gia_ObjFanin0(pObj)) + Gia_ObjRefNum(p, Gia_ObjFanin1(pObj)) > Limit )
pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
else if ( Gia_ObjRecognizeExor(pObj, &pFan0, &pFan1) )
pObj->Value = Gia_ManHashXorReal( pNew, Gia_ObjLitCopy(p, Gia_ObjToLit(p, pFan0)), Gia_ObjLitCopy(p, Gia_ObjToLit(p, pFan1)) );
@@ -147,7 +196,7 @@ Gia_Man_t * Gia_ManDupNoMuxes( Gia_Man_t * p )
Gia_Man_t * Gia_ManDupMuxesTest( Gia_Man_t * p )
{
Gia_Man_t * pNew, * pNew2;
- pNew = Gia_ManDupMuxes( p );
+ pNew = Gia_ManDupMuxes( p, 2 );
pNew2 = Gia_ManDupNoMuxes( pNew );
Gia_ManPrintStats( p, NULL );
Gia_ManPrintStats( pNew, NULL );
@@ -277,7 +326,7 @@ void Gia_ManMuxProfiling( Gia_Man_t * p )
Vec_Int_t * vCounts;
int i, nRefs, Size, Count, Total = 0, Roots = 0;
- pNew = Gia_ManDupMuxes( p );
+ pNew = Gia_ManDupMuxes( p, 2 );
Gia_ManCreateRefs( pNew );
Gia_ManForEachCo( pNew, pObj, i )
Gia_ObjRefFanin0Inc( pNew, pObj );
diff --git a/src/aig/gia/giaResub.c b/src/aig/gia/giaResub.c
index 4b196fa4..b8c0e294 100644
--- a/src/aig/gia/giaResub.c
+++ b/src/aig/gia/giaResub.c
@@ -261,7 +261,7 @@ void Gia_ManAddDivisors( Gia_Man_t * p, Vec_Wec_t * vMffcs )
void Gia_ManResubTest( Gia_Man_t * p )
{
Vec_Wec_t * vMffcs;
- Gia_Man_t * pNew = Gia_ManDupMuxes( p );
+ Gia_Man_t * pNew = Gia_ManDupMuxes( p, 2 );
abctime clkStart = Abc_Clock();
vMffcs = Gia_ManComputeMffcs( pNew, 4, 100, 8, 100 );
Gia_ManAddDivisors( pNew, vMffcs );
diff --git a/src/aig/gia/giaSwitch.c b/src/aig/gia/giaSwitch.c
index 5e97910b..a7b63864 100644
--- a/src/aig/gia/giaSwitch.c
+++ b/src/aig/gia/giaSwitch.c
@@ -758,6 +758,7 @@ float Gia_ManComputeSwitching( Gia_Man_t * p, int nFrames, int nPref, int fProbO
// perform the computation of switching activity
vSwitching = Gia_ManComputeSwitchProbs( pDfs, nFrames, nPref, fProbOne );
// transfer the computed result to the original AIG
+ ABC_FREE( p->pSwitching );
p->pSwitching = ABC_CALLOC( unsigned char, Gia_ManObjNum(p) );
pSwitching = (float *)vSwitching->pArray;
Gia_ManForEachObj( p, pObj, i )
diff --git a/src/aig/gia/giaUtil.c b/src/aig/gia/giaUtil.c
index 365a8539..e16ee44f 100644
--- a/src/aig/gia/giaUtil.c
+++ b/src/aig/gia/giaUtil.c
@@ -746,34 +746,6 @@ int * Gia_ManCreateMuxRefs( Gia_Man_t * p )
/**Function*************************************************************
- Synopsis [Assigns references.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void Gia_ManCountMuxXor( Gia_Man_t * p, int * pnMuxes, int * pnXors )
-{
- Gia_Obj_t * pObj, * pFan0, * pFan1;
- int i;
- *pnMuxes = 0;
- *pnXors = 0;
- Gia_ManForEachAnd( p, pObj, i )
- {
- if ( !Gia_ObjIsMuxType(pObj) )
- continue;
- if ( Gia_ObjRecognizeExor(pObj, &pFan0, &pFan1) )
- (*pnXors)++;
- else
- (*pnMuxes)++;
- }
-}
-
-/**Function*************************************************************
-
Synopsis [Computes the maximum frontier size.]
Description []