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 /src/base/abci/abcIf.c | |
parent | c5b620b9bf861db4bce9d60d5ce3edb3f4a4845d (diff) | |
download | abc-78e09e91197a97cd22f63ad612d5900cd5e02a8b.tar.gz abc-78e09e91197a97cd22f63ad612d5900cd5e02a8b.tar.bz2 abc-78e09e91197a97cd22f63ad612d5900cd5e02a8b.zip |
Correcting switching activity computation.
Diffstat (limited to 'src/base/abci/abcIf.c')
-rw-r--r-- | src/base/abci/abcIf.c | 74 |
1 files changed, 33 insertions, 41 deletions
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 ) |