diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2014-06-05 17:00:04 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2014-06-05 17:00:04 -0700 |
commit | 78e09e91197a97cd22f63ad612d5900cd5e02a8b (patch) | |
tree | 15997123c5857468a967add69346d65133a8ab52 | |
parent | c5b620b9bf861db4bce9d60d5ce3edb3f4a4845d (diff) | |
download | abc-78e09e91197a97cd22f63ad612d5900cd5e02a8b.tar.gz abc-78e09e91197a97cd22f63ad612d5900cd5e02a8b.tar.bz2 abc-78e09e91197a97cd22f63ad612d5900cd5e02a8b.zip |
Correcting switching activity computation.
-rw-r--r-- | src/aig/gia/giaIf.c | 10 | ||||
-rw-r--r-- | src/aig/gia/giaSwitch.c | 16 | ||||
-rw-r--r-- | src/base/abci/abcIf.c | 74 | ||||
-rw-r--r-- | src/base/abci/abcPrint.c | 1 | ||||
-rw-r--r-- | src/map/if/if.h | 1 |
5 files changed, 46 insertions, 56 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; diff --git a/src/base/abci/abcIf.c b/src/base/abci/abcIf.c index 50abb6c7..51b2e66c 100644 --- a/src/base/abci/abcIf.c +++ b/src/base/abci/abcIf.c @@ -55,49 +55,41 @@ extern void Abc_NtkBidecResyn( Abc_Ntk_t * pNtk, int fVerbose ); SeeAlso [] ***********************************************************************/ -void Abc_NtkIfComputeSwitching( Abc_Ntk_t * pNtk, If_Man_t * pIfMan ) +void If_ManComputeSwitching( If_Man_t * pIfMan ) { - extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters ); - extern Vec_Int_t * Saig_ManComputeSwitchProbs( Aig_Man_t * p, int nFrames, int nPref, int fProbOne ); - Vec_Int_t * vSwitching; - float * pSwitching; - Abc_Obj_t * pObjAbc; - Aig_Obj_t * pObjAig; - Aig_Man_t * pAig; - If_Obj_t * pObjIf; - int i; abctime clk = Abc_Clock(); - // map IF objects into old network - Abc_NtkForEachObj( pNtk, pObjAbc, i ) - if ( (pObjIf = (If_Obj_t *)pObjAbc->pTemp) ) - pObjIf->pCopy = pObjAbc; - // map network into an AIG - pAig = Abc_NtkToDar( pNtk, 0, 0 ); - vSwitching = Saig_ManComputeSwitchProbs( pAig, 48, 16, 0 ); - pSwitching = (float *)vSwitching->pArray; - Abc_NtkForEachObj( pNtk, pObjAbc, i ) - if ( !Abc_ObjIsCo(pObjAbc) && (pObjAig = (Aig_Obj_t *)pObjAbc->pTemp) ) - { - pObjAbc->dTemp = pSwitching[pObjAig->Id]; - // J. Anderson and F. N. Najm, “Power-Aware Technology Mapping for LUT-Based FPGAs, - // IEEE Intl. Conf. on Field-Programmable Technology, 2002. -// pObjAbc->dTemp = (1.55 + 1.05 / (float) Abc_ObjFanoutNum(pObjAbc)) * pSwitching[pObjAig->Id]; - } - else - pObjAbc->dTemp = 0; - Vec_IntFree( vSwitching ); - Aig_ManStop( pAig ); - // compute switching for the IF objects + Gia_Man_t * pNew; + Vec_Int_t * vCopy; + If_Obj_t * pIfObj; + int i; assert( pIfMan->vSwitching == NULL ); - pIfMan->vSwitching = Vec_IntStart( If_ManObjNum(pIfMan) ); - pSwitching = (float *)pIfMan->vSwitching->pArray; - If_ManForEachObj( pIfMan, pObjIf, i ) - if ( (pObjAbc = (Abc_Obj_t *)pObjIf->pCopy) ) - pSwitching[i] = pObjAbc->dTemp; -if ( pIfMan->pPars->fVerbose ) -{ - ABC_PRT( "Computing switching activity", Abc_Clock() - clk ); -} + // create the new manager + pNew = Gia_ManStart( If_ManObjNum(pIfMan) ); + vCopy = Vec_IntAlloc( If_ManObjNum(pIfMan) ); + // constant and inputs + Vec_IntPush( vCopy, 1 ); + If_ManForEachCi( pIfMan, pIfObj, i ) + Vec_IntPush( vCopy, Gia_ManAppendCi(pNew) ); + // internal nodes + If_ManForEachNode( pIfMan, pIfObj, i ) + { + int iLit0 = Abc_LitNotCond( Vec_IntEntry(vCopy, If_ObjFanin0(pIfObj)->Id), If_ObjFaninC0(pIfObj) ); + int iLit1 = Abc_LitNotCond( Vec_IntEntry(vCopy, If_ObjFanin1(pIfObj)->Id), If_ObjFaninC1(pIfObj) ); + Vec_IntPush( vCopy, Gia_ManAppendAnd(pNew, iLit0, iLit1) ); + } + // outputs + If_ManForEachCo( pIfMan, pIfObj, i ) + { + int iLit0 = Abc_LitNotCond( Vec_IntEntry(vCopy, If_ObjFanin0(pIfObj)->Id), If_ObjFaninC0(pIfObj) ); + Vec_IntPush( vCopy, Gia_ManAppendCo(pNew, iLit0) ); + } + assert( Vec_IntSize(vCopy) == If_ManObjNum(pIfMan) ); + Vec_IntFree( vCopy ); + // compute switching activity + pIfMan->vSwitching = Gia_ManComputeSwitchProbs( pNew, 48, 16, 0 ); + Gia_ManStop( pNew ); + if ( pIfMan->pPars->fVerbose ) + Abc_PrintTime( 1, "Computing switching activity", Abc_Clock() - clk ); } /**Function************************************************************* @@ -135,7 +127,7 @@ Abc_Ntk_t * Abc_NtkIf( Abc_Ntk_t * pNtk, If_Par_t * pPars ) if ( pIfMan == NULL ) return NULL; if ( pPars->fPower ) - Abc_NtkIfComputeSwitching( pNtk, pIfMan ); + If_ManComputeSwitching( pIfMan ); // create DSD manager if ( pPars->fUseDsd ) diff --git a/src/base/abci/abcPrint.c b/src/base/abci/abcPrint.c index 8717c1ed..06e459fe 100644 --- a/src/base/abci/abcPrint.c +++ b/src/base/abci/abcPrint.c @@ -155,6 +155,7 @@ float Abc_NtkMfsTotalSwitching( Abc_Ntk_t * pNtk ) if ( (pObjAbc2 = Abc_ObjRegular((Abc_Obj_t *)pObjAbc->pTemp)) && (pObjAig = Aig_Regular((Aig_Obj_t *)pObjAbc2->pTemp)) ) { Result += Abc_ObjFanoutNum(pObjAbc) * pSwitching[pObjAig->Id]; +// Abc_ObjPrint( stdout, pObjAbc ); // printf( "%d = %.2f\n", i, Abc_ObjFanoutNum(pObjAbc) * pSwitching[pObjAig->Id] ); } } diff --git a/src/map/if/if.h b/src/map/if/if.h index 69f8100c..a2312667 100644 --- a/src/map/if/if.h +++ b/src/map/if/if.h @@ -482,6 +482,7 @@ static inline float If_CutLutDelay( If_LibLut_t * p, int Size, int iPin ) /*=== ifCore.c ===========================================================*/ extern int If_ManPerformMapping( If_Man_t * p ); extern int If_ManPerformMappingComb( If_Man_t * p ); +extern void If_ManComputeSwitching( If_Man_t * p ); /*=== ifCut.c ============================================================*/ extern int If_CutVerifyCuts( If_Set_t * pCutSet, int fOrdered ); extern int If_CutFilter( If_Set_t * pCutSet, If_Cut_t * pCut, int fSaveCut0 ); |