diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2016-02-06 12:08:23 -0800 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2016-02-06 12:08:23 -0800 |
commit | 02240391327b808f365e247afd77b2ae2a21d6ab (patch) | |
tree | 62e5a7dd997c806e6f5b9b2f9ce5c42ff7be3ec8 /src/base/wlc/wlcBlast.c | |
parent | 355865e81b56791b8189f1c369f804d16b0ef814 (diff) | |
download | abc-02240391327b808f365e247afd77b2ae2a21d6ab.tar.gz abc-02240391327b808f365e247afd77b2ae2a21d6ab.tar.bz2 abc-02240391327b808f365e247afd77b2ae2a21d6ab.zip |
Added recursive bit-blasting of a carry-lookahead adder.
Diffstat (limited to 'src/base/wlc/wlcBlast.c')
-rw-r--r-- | src/base/wlc/wlcBlast.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/base/wlc/wlcBlast.c b/src/base/wlc/wlcBlast.c index f3e0af8a..dfe46db5 100644 --- a/src/base/wlc/wlcBlast.c +++ b/src/base/wlc/wlcBlast.c @@ -274,6 +274,56 @@ void Wlc_BlastSubtract( Gia_Man_t * pNew, int * pAdd0, int * pAdd1, int nBits ) for ( b = 0; b < nBits; b++ ) Wlc_BlastFullAdder( pNew, pAdd0[b], Abc_LitNot(pAdd1[b]), Carry, &Carry, &pAdd0[b] ); } + +void Wlc_BlastAdderCLA_one( Gia_Man_t * pNew, int * pGen, int * pPro, int * pCar, int * pGen1, int * pPro1, int * pCar1 ) +{ + int Temp = Gia_ManHashAnd( pNew, pGen[0], pPro[1] ); + *pPro1 = Gia_ManHashAnd( pNew, pPro[0], pPro[1] ); + *pGen1 = Gia_ManHashOr( pNew, Gia_ManHashOr(pNew, pGen[1], Temp), Gia_ManHashAnd(pNew, *pPro1, pCar[0]) ); + *pCar1 = Gia_ManHashOr( pNew, pGen[0], Gia_ManHashAnd(pNew, pPro[0], pCar[0]) ); +} +void Wlc_BlastAdderCLA_rec( Gia_Man_t * pNew, int * pGen, int * pPro, int * pCar, int nBits, int * pGen1, int * pPro1 ) +{ + if ( nBits == 2 ) + Wlc_BlastAdderCLA_one( pNew, pGen, pPro, pCar, pGen1, pPro1, pCar+1 ); // returns *pGen1, *pPro1, pCar[1] + else + { + int pGen2[2], pPro2[2]; + assert( nBits % 2 == 0 ); + // call recursively + Wlc_BlastAdderCLA_rec( pNew, pGen, pPro, pCar, nBits/2, pGen2, pPro2 ); + pCar[nBits/2] = *pGen2; + Wlc_BlastAdderCLA_rec( pNew, pGen+nBits/2, pPro+nBits/2, pCar+nBits/2, nBits/2, pGen2+1, pPro2+1 ); + // create structure + Wlc_BlastAdderCLA_one( pNew, pGen2, pPro2, pCar, pGen1, pPro1, pCar+nBits/2 ); // returns *pGen1, *pPro1, pCar[nBits/2] + } +} +void Wlc_BlastAdderCLA( Gia_Man_t * pNew, int * pAdd0, int * pAdd1, int nBits ) // result is in pAdd0 +{ + int * pGen = ABC_CALLOC( int, nBits ); + int * pPro = ABC_CALLOC( int, nBits ); + int * pCar = ABC_CALLOC( int, nBits+1 ); + int b, Gen, Pro; + if ( nBits == 1 ) + { + int Carry = 0; + Wlc_BlastFullAdder( pNew, pAdd0[0], pAdd1[0], Carry, &Carry, &pAdd0[0] ); + return; + } + assert( nBits >= 2 ); + pCar[0] = 0; + for ( b = 0; b < nBits; b++ ) + { + pGen[b] = Gia_ManHashAnd(pNew, pAdd0[b], pAdd1[b]); + pPro[b] = Gia_ManHashXor(pNew, pAdd0[b], pAdd1[b]); + } + Wlc_BlastAdderCLA_rec( pNew, pGen, pPro, pCar, nBits, &Gen, &Pro ); + for ( b = 0; b < nBits; b++ ) + pAdd0[b] = Gia_ManHashXor(pNew, pPro[b], pCar[b]); + ABC_FREE(pGen); + ABC_FREE(pPro); + ABC_FREE(pCar); +} void Wlc_BlastMinus( Gia_Man_t * pNew, int * pNum, int nNum, Vec_Int_t * vRes ) { int * pRes = Wlc_VecCopy( vRes, pNum, nNum ); @@ -887,6 +937,7 @@ Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Vec_Int_t * vBoxIds ) int * pArg1 = Wlc_VecLoadFanins( vTemp1, pFans1, nRange1, nRangeMax, Wlc_ObjIsSignedFanin01(p, pObj) ); if ( pObj->Type == WLC_OBJ_ARI_ADD ) Wlc_BlastAdder( pNew, pArg0, pArg1, nRange ); // result is in pFan0 (vRes) +// Wlc_BlastAdderCLA( pNew, pArg0, pArg1, nRange ); // result is in pFan0 (vRes) else Wlc_BlastSubtract( pNew, pArg0, pArg1, nRange ); // result is in pFan0 (vRes) Vec_IntShrink( vRes, nRange ); |