summaryrefslogtreecommitdiffstats
path: root/src/aig
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2014-06-05 17:00:04 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2014-06-05 17:00:04 -0700
commit78e09e91197a97cd22f63ad612d5900cd5e02a8b (patch)
tree15997123c5857468a967add69346d65133a8ab52 /src/aig
parentc5b620b9bf861db4bce9d60d5ce3edb3f4a4845d (diff)
downloadabc-78e09e91197a97cd22f63ad612d5900cd5e02a8b.tar.gz
abc-78e09e91197a97cd22f63ad612d5900cd5e02a8b.tar.bz2
abc-78e09e91197a97cd22f63ad612d5900cd5e02a8b.zip
Correcting switching activity computation.
Diffstat (limited to 'src/aig')
-rw-r--r--src/aig/gia/giaIf.c10
-rw-r--r--src/aig/gia/giaSwitch.c16
2 files changed, 11 insertions, 15 deletions
diff --git a/src/aig/gia/giaIf.c b/src/aig/gia/giaIf.c
index 11a349e3..4b6095e5 100644
--- a/src/aig/gia/giaIf.c
+++ b/src/aig/gia/giaIf.c
@@ -1618,15 +1618,7 @@ Gia_Man_t * Gia_ManPerformMapping( Gia_Man_t * p, void * pp, int fNormalized )
}
// compute switching for the IF objects
if ( pPars->fPower )
- {
- Gia_Obj_t * pObj; int i;
- assert( pIfMan->vSwitching == NULL );
- pIfMan->vSwitching = Vec_IntStart( If_ManObjNum(pIfMan) );
- Gia_ManForEachObj( p, pObj, i )
- if ( ~Gia_ObjValue(pObj) )
- Vec_IntWriteEntry( pIfMan->vSwitching, Gia_ObjValue(pObj), Vec_IntEntry(p->vSwitching, i) );
-// Vec_IntFreeP( &p->vSwitching );
- }
+ If_ManComputeSwitching( pIfMan );
if ( p->pManTime )
pIfMan->pManTim = Tim_ManDup( (Tim_Man_t *)p->pManTime, 0 );
if ( !If_ManPerformMapping( pIfMan ) )
diff --git a/src/aig/gia/giaSwitch.c b/src/aig/gia/giaSwitch.c
index 18ff0a89..5e97910b 100644
--- a/src/aig/gia/giaSwitch.c
+++ b/src/aig/gia/giaSwitch.c
@@ -745,10 +745,13 @@ float Gia_ManComputeSwitching( Gia_Man_t * p, int nFrames, int nPref, int fProbO
Gia_Man_t * pDfs;
Gia_Obj_t * pObj, * pObjDfs;
Vec_Int_t * vSwitching;
- float * pSwitching, Switch, SwitchTotal = 0.0;//, SwitchTotal2 = 0.0;
+ float * pSwitching, Switch, SwitchTotal = 0.0;
int i;
// derives the DFS ordered AIG
- Gia_ManCreateRefs( p );
+ if ( Gia_ManHasMapping(p) )
+ Gia_ManSetRefsMapped(p);
+ else
+ Gia_ManCreateRefs( p );
// pDfs = Gia_ManDupOrderDfs( p );
pDfs = Gia_ManDup( p );
assert( Gia_ManObjNum(pDfs) == Gia_ManObjNum(p) );
@@ -762,11 +765,12 @@ float Gia_ManComputeSwitching( Gia_Man_t * p, int nFrames, int nPref, int fProbO
pObjDfs = Gia_ObjFromLit( pDfs, pObj->Value );
Switch = pSwitching[ Gia_ObjId(pDfs, pObjDfs) ];
p->pSwitching[i] = (char)((Switch >= 1.0) ? 255 : (int)((0.002 + Switch) * 255)); // 0.00196 = (1/255)/2
- SwitchTotal += (float)Gia_ObjRefNum(p, pObj) * p->pSwitching[i] / 255;
-// SwitchTotal2 += Gia_ObjRefNum(p, pObj) * Switch;
-// printf( "%d = %.2f\n", i, Gia_ObjRefNum(p, pObj) * Switch );
+ if ( Gia_ObjIsCi(pObj) || (Gia_ObjIsAnd(pObj) && (!Gia_ManHasMapping(p) || Gia_ObjIsLut(p, i))) )
+ {
+ SwitchTotal += (float)Gia_ObjRefNum(p, pObj) * p->pSwitching[i] / 255;
+// printf( "%d = %.2f\n", i, (float)Gia_ObjRefNum(p, pObj) * p->pSwitching[i] / 255 );
+ }
}
-// printf( "\nSwitch float = %f. Switch char = %f.\n", SwitchTotal2, SwitchTotal );
Vec_IntFree( vSwitching );
Gia_ManStop( pDfs );
return SwitchTotal;