From 5b588e0951b1b392b0eed69c0339a83d1e4df8f2 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 5 Jun 2018 13:49:23 -0700 Subject: Exposing a switch to generate carry-lookahead adder during bit-blasting. --- src/base/wlc/wlc.h | 2 ++ src/base/wlc/wlcBlast.c | 65 +++++++++++++++++++++++++++++++++++++++---------- src/base/wlc/wlcCom.c | 8 ++++-- 3 files changed, 60 insertions(+), 15 deletions(-) diff --git a/src/base/wlc/wlc.h b/src/base/wlc/wlc.h index 02921722..aacd27a7 100644 --- a/src/base/wlc/wlc.h +++ b/src/base/wlc/wlc.h @@ -208,6 +208,7 @@ struct Wlc_BstPar_t_ int fAddOutputs; int fMulti; int fBooth; + int fCla; int fNoCleanup; int fCreateMiter; int fDecMuxes; @@ -226,6 +227,7 @@ static inline void Wlc_BstParDefault( Wlc_BstPar_t * pPar ) pPar->fAddOutputs = 0; pPar->fMulti = 0; pPar->fBooth = 0; + pPar->fCla = 0; pPar->fCreateMiter = 0; pPar->fDecMuxes = 0; pPar->fVerbose = 0; diff --git a/src/base/wlc/wlcBlast.c b/src/base/wlc/wlcBlast.c index b97dfdad..8ced5b60 100644 --- a/src/base/wlc/wlcBlast.c +++ b/src/base/wlc/wlcBlast.c @@ -375,7 +375,7 @@ void Wlc_BlastAdderCLA_rec( Gia_Man_t * pNew, int * pGen, int * pPro, int * pCar 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 +void Wlc_BlastAdderCLA_int( 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 ); @@ -401,6 +401,27 @@ void Wlc_BlastAdderCLA( Gia_Man_t * pNew, int * pAdd0, int * pAdd1, int nBits ) ABC_FREE(pPro); ABC_FREE(pCar); } +void Wlc_BlastAdderCLA( Gia_Man_t * pNew, int * pAdd0, int * pAdd1, int nBits, int fSign ) // result is in pAdd0 +{ + int i, Log2 = Abc_Base2Log(nBits); + int * pAdd0n = ABC_CALLOC( int, 1<Type == WLC_OBJ_ARI_ADD ) - Wlc_BlastAdder( pNew, pArg0, pArg1, nRange, CarryIn ); // result is in pFan0 (vRes) -// Wlc_BlastAdderCLA( pNew, pArg0, pArg1, nRange ); // result is in pFan0 (vRes) + { + if ( pPar->fCla ) + Wlc_BlastAdderCLA( pNew, pArg0, pArg1, nRange, Wlc_ObjIsSignedFanin01(p, pObj) ); // result is in pFan0 (vRes) + else + Wlc_BlastAdder( pNew, pArg0, pArg1, nRange, CarryIn ); // result is in pFan0 (vRes) + } else Wlc_BlastSubtract( pNew, pArg0, pArg1, nRange ); // result is in pFan0 (vRes) Vec_IntShrink( vRes, nRange ); @@ -1416,10 +1454,11 @@ Gia_Man_t * Wlc_NtkBitBlast( Wlc_Ntk_t * p, Wlc_BstPar_t * pParIn ) if ( Wlc_NtkCountConstBits(pArg0, nRangeMax) < Wlc_NtkCountConstBits(pArg1, nRangeMax) ) ABC_SWAP( int *, pArg0, pArg1 ); if ( pPar->fBooth ) - Wlc_BlastBooth( pNew, pArg0, pArg1, nRange0, nRange1, vRes, fSigned ); + Wlc_BlastBooth( pNew, pArg0, pArg1, nRange0, nRange1, vRes, fSigned, pPar->fCla ); + else if ( pPar->fCla ) + Wlc_BlastMultiplier3( pNew, pArg0, pArg1, nRange0, nRange1, vRes, Wlc_ObjIsSignedFanin01(p, pObj), pPar->fCla ); else Wlc_BlastMultiplier( pNew, pArg0, pArg1, nRangeMax, nRangeMax, vTemp2, vRes, fSigned ); - //Wlc_BlastMultiplier3( pNew, pArg0, pArg1, nRange0, nRange1, vRes ); if ( nRange > Vec_IntSize(vRes) ) Vec_IntFillExtra( vRes, nRange, fSigned ? Vec_IntEntryLast(vRes) : 0 ); else diff --git a/src/base/wlc/wlcCom.c b/src/base/wlc/wlcCom.c index 711763c7..73b130e7 100644 --- a/src/base/wlc/wlcCom.c +++ b/src/base/wlc/wlcCom.c @@ -972,7 +972,7 @@ int Abc_CommandBlast( Abc_Frame_t * pAbc, int argc, char ** argv ) Wlc_BstParDefault( pPar ); pPar->nOutputRange = 2; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "ORAMcombdsvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "ORAMcombadsvh" ) ) != EOF ) { switch ( c ) { @@ -1032,6 +1032,9 @@ int Abc_CommandBlast( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'b': pPar->fBooth ^= 1; break; + case 'a': + pPar->fCla ^= 1; + break; case 'd': pPar->fCreateMiter ^= 1; break; @@ -1083,7 +1086,7 @@ int Abc_CommandBlast( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_FrameUpdateGia( pAbc, pNew ); return 0; usage: - Abc_Print( -2, "usage: %%blast [-ORAM num] [-combdsvh]\n" ); + Abc_Print( -2, "usage: %%blast [-ORAM num] [-combadsvh]\n" ); Abc_Print( -2, "\t performs bit-blasting of the word-level design\n" ); Abc_Print( -2, "\t-O num : zero-based index of the first word-level PO to bit-blast [default = %d]\n", pPar->iOutput ); Abc_Print( -2, "\t-R num : the total number of word-level POs to bit-blast [default = %d]\n", pPar->nOutputRange ); @@ -1093,6 +1096,7 @@ usage: Abc_Print( -2, "\t-o : toggle using additional POs on the word-level boundaries [default = %s]\n", pPar->fAddOutputs? "yes": "no" ); Abc_Print( -2, "\t-m : toggle creating boxes for all multipliers in the design [default = %s]\n", pPar->fMulti? "yes": "no" ); Abc_Print( -2, "\t-b : toggle generating radix-4 Booth multipliers [default = %s]\n", pPar->fBooth? "yes": "no" ); + Abc_Print( -2, "\t-a : toggle generating carry-look-ahead adder [default = %s]\n", pPar->fCla? "yes": "no" ); Abc_Print( -2, "\t-d : toggle creating dual-output miter [default = %s]\n", pPar->fCreateMiter? "yes": "no" ); Abc_Print( -2, "\t-s : toggle creating decoded MUXes [default = %s]\n", pPar->fDecMuxes? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pPar->fVerbose? "yes": "no" ); -- cgit v1.2.3