From 78e09e91197a97cd22f63ad612d5900cd5e02a8b Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 5 Jun 2014 17:00:04 -0700 Subject: Correcting switching activity computation. --- src/aig/gia/giaIf.c | 10 +--------- src/aig/gia/giaSwitch.c | 16 ++++++++++------ 2 files changed, 11 insertions(+), 15 deletions(-) (limited to 'src/aig') 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; -- cgit v1.2.3