summaryrefslogtreecommitdiffstats
path: root/src/aig/gia/giaStr.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2021-05-08 13:28:27 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2021-05-08 13:28:27 -0700
commit174f27d9813dede18e5c06fe8c98d6819ce49835 (patch)
tree605186bc1166354fa894f5b4547a332d04248b39 /src/aig/gia/giaStr.c
parent7d90895dcf97c726deab121bb042e68abda301e9 (diff)
downloadabc-174f27d9813dede18e5c06fe8c98d6819ce49835.tar.gz
abc-174f27d9813dede18e5c06fe8c98d6819ce49835.tar.bz2
abc-174f27d9813dede18e5c06fe8c98d6819ce49835.zip
Bug fix in &blut.
Diffstat (limited to 'src/aig/gia/giaStr.c')
-rw-r--r--src/aig/gia/giaStr.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/aig/gia/giaStr.c b/src/aig/gia/giaStr.c
index 085738c3..2233d0fc 100644
--- a/src/aig/gia/giaStr.c
+++ b/src/aig/gia/giaStr.c
@@ -859,21 +859,23 @@ static inline void transpose64( word A[64] )
static inline int Str_ManNum( Gia_Man_t * p, int iObj ) { return Vec_IntEntry(&p->vCopies, iObj); }
static inline void Str_ManSetNum( Gia_Man_t * p, int iObj, int Num ) { Vec_IntWriteEntry(&p->vCopies, iObj, Num); }
-int Str_ManVectorAffinity( Gia_Man_t * p, Vec_Int_t * vSuper, Vec_Int_t * vDelay, word Matrix[256], int nLimit )
+int Str_ManVectorAffinity( Gia_Man_t * p, Vec_Int_t * vSuper, Vec_Int_t * vDelay, word * Matrix, int nLimit )
{
int fVerbose = 0;
- int Levels[256];
+ int * Levels = NULL;
int nSize = Vec_IntSize(vSuper);
int Prev = nSize, nLevels = 1;
int i, k, iLit, iFanin, nSizeNew;
word Mask;
assert( nSize > 2 );
+ assert( nSize <= nLimit );
if ( nSize > 64 )
{
for ( i = 0; i < 64; i++ )
Matrix[i] = 0;
return 0;
}
+ Levels = ABC_ALLOC( int, nLimit+256 );
// mark current nodes
Gia_ManIncrementTravId( p );
Vec_IntForEachEntry( vSuper, iLit, i )
@@ -948,6 +950,7 @@ int Str_ManVectorAffinity( Gia_Man_t * p, Vec_Int_t * vSuper, Vec_Int_t * vDelay
if ( nSizeNew == 0 )
{
Vec_IntShrink( vSuper, nSize );
+ ABC_FREE( Levels );
return 0;
}
/*
@@ -979,6 +982,7 @@ int Str_ManVectorAffinity( Gia_Man_t * p, Vec_Int_t * vSuper, Vec_Int_t * vDelay
}
i = 0;
}
+ ABC_FREE( Levels );
Vec_IntShrink( vSuper, nSize );
return nSizeNew;
}
@@ -1088,15 +1092,14 @@ int Str_NtkBalanceTwo( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, int i,
void Str_NtkBalanceMulti( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, Vec_Int_t * vDelay, int nLutSize )
{
- word pMatrix[256];
- int Limit = 256;
+ word * pMatrix = ABC_ALLOC( word, pObj->nFanins+256 );
Vec_Int_t * vSuper = pNew->vSuper;
Vec_Int_t * vCosts = pNew->vStore;
int * pSuper = Vec_IntArray(vSuper);
int * pCost = Vec_IntArray(vCosts);
int k, iLit, MatrixSize = 0;
- assert( Limit <= Vec_IntCap(vSuper) );
- assert( Limit <= Vec_IntCap(vCosts) );
+ assert( (int)pObj->nFanins <= Vec_IntCap(vSuper) );
+ assert( (int)pObj->nFanins <= Vec_IntCap(vCosts) );
// collect nodes
Vec_IntClear( vSuper );
@@ -1111,11 +1114,13 @@ void Str_NtkBalanceMulti( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, Vec
if ( Vec_IntSize(vSuper) == 1 )
{
pObj->iCopy = Vec_IntEntry(vSuper, 0);
+ ABC_FREE( pMatrix );
return;
}
if ( Vec_IntSize(vSuper) == 2 )
{
pObj->iCopy = Str_NtkBalanceTwo( pNew, p, pObj, 0, 1, vDelay, pCost, pSuper, pMatrix, 2, nLutSize, -1 );
+ ABC_FREE( pMatrix );
return;
}
@@ -1127,7 +1132,7 @@ void Str_NtkBalanceMulti( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, Vec
// compute affinity
if ( Vec_IntSize(vSuper) < 64 )
- MatrixSize = Str_ManVectorAffinity( pNew, vSuper, vCosts, pMatrix, Limit );
+ MatrixSize = Str_ManVectorAffinity( pNew, vSuper, vCosts, pMatrix, pObj->nFanins );
// start the new product
while ( Vec_IntSize(vSuper) > 2 )
@@ -1147,7 +1152,7 @@ void Str_NtkBalanceMulti( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, Vec
// compute affinity
if ( Vec_IntSize(vSuper) == 64 )
- MatrixSize = Str_ManVectorAffinity( pNew, vSuper, vCosts, pMatrix, Limit );
+ MatrixSize = Str_ManVectorAffinity( pNew, vSuper, vCosts, pMatrix, pObj->nFanins );
assert( Vec_IntSize(vSuper) <= 64 );
// Str_PrintState( pCost, pSuper, pMatrix, Vec_IntSize(vSuper) );
@@ -1236,6 +1241,7 @@ void Str_NtkBalanceMulti( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, Vec
continue;
}
pObj->iCopy = Str_NtkBalanceTwo( pNew, p, pObj, 0, 1, vDelay, pCost, pSuper, pMatrix, 2, nLutSize, -1 );
+ ABC_FREE( pMatrix );
/*
// simple