From d02f9dd4df982d3d2b438344e798c09c79be9222 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 29 Jun 2016 15:36:31 -0700 Subject: Bug fix in blasting shifters with large bit-width. --- src/base/wlc/wlcBlast.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/base') diff --git a/src/base/wlc/wlcBlast.c b/src/base/wlc/wlcBlast.c index 3ec7256a..3327e909 100644 --- a/src/base/wlc/wlcBlast.c +++ b/src/base/wlc/wlcBlast.c @@ -143,16 +143,19 @@ void Wlc_BlastShiftRightInt( Gia_Man_t * pNew, int * pNum, int nNum, int * pShif void Wlc_BlastShiftRight( Gia_Man_t * pNew, int * pNum, int nNum, int * pShift, int nShift, int fSticky, Vec_Int_t * vRes ) { int nShiftMax = Abc_Base2Log(nNum); + int * pShiftNew = ABC_ALLOC( int, nShift ); + memcpy( pShiftNew, pShift, sizeof(int)*nShift ); if ( nShiftMax < nShift && nShift > 30 ) { - int i, iRes = pShift[nShiftMax]; + int i, iRes = pShiftNew[nShiftMax]; for ( i = nShiftMax + 1; i < nShift; i++ ) - iRes = Gia_ManHashOr( pNew, iRes, pShift[i] ); - pShift[nShiftMax++] = iRes; + iRes = Gia_ManHashOr( pNew, iRes, pShiftNew[i] ); + pShiftNew[nShiftMax++] = iRes; } else nShiftMax = nShift; - Wlc_BlastShiftRightInt( pNew, pNum, nNum, pShift, nShiftMax, fSticky, vRes ); + Wlc_BlastShiftRightInt( pNew, pNum, nNum, pShiftNew, nShiftMax, fSticky, vRes ); + ABC_FREE( pShiftNew ); } void Wlc_BlastShiftLeftInt( Gia_Man_t * pNew, int * pNum, int nNum, int * pShift, int nShift, int fSticky, Vec_Int_t * vRes ) { @@ -176,16 +179,19 @@ void Wlc_BlastShiftLeftInt( Gia_Man_t * pNew, int * pNum, int nNum, int * pShift void Wlc_BlastShiftLeft( Gia_Man_t * pNew, int * pNum, int nNum, int * pShift, int nShift, int fSticky, Vec_Int_t * vRes ) { int nShiftMax = Abc_Base2Log(nNum); - if ( nShiftMax < nShift && nShift > 30 ) + int * pShiftNew = ABC_ALLOC( int, nShift ); + memcpy( pShiftNew, pShift, sizeof(int)*nShift ); + if ( nShiftMax < nShift ) { - int i, iRes = pShift[nShiftMax]; + int i, iRes = pShiftNew[nShiftMax]; for ( i = nShiftMax + 1; i < nShift; i++ ) - iRes = Gia_ManHashOr( pNew, iRes, pShift[i] ); - pShift[nShiftMax++] = iRes; + iRes = Gia_ManHashOr( pNew, iRes, pShiftNew[i] ); + pShiftNew[nShiftMax++] = iRes; } else nShiftMax = nShift; - Wlc_BlastShiftLeftInt( pNew, pNum, nNum, pShift, nShiftMax, fSticky, vRes ); + Wlc_BlastShiftLeftInt( pNew, pNum, nNum, pShiftNew, nShiftMax, fSticky, vRes ); + ABC_FREE( pShiftNew ); } void Wlc_BlastRotateRight( Gia_Man_t * pNew, int * pNum, int nNum, int * pShift, int nShift, Vec_Int_t * vRes ) { -- cgit v1.2.3