Commit 174f27d9 by Alan Mishchenko

Bug fix in &blut.

parent 7d90895d
...@@ -859,21 +859,23 @@ static inline void transpose64( word A[64] ) ...@@ -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 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); } 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 fVerbose = 0;
int Levels[256]; int * Levels = NULL;
int nSize = Vec_IntSize(vSuper); int nSize = Vec_IntSize(vSuper);
int Prev = nSize, nLevels = 1; int Prev = nSize, nLevels = 1;
int i, k, iLit, iFanin, nSizeNew; int i, k, iLit, iFanin, nSizeNew;
word Mask; word Mask;
assert( nSize > 2 ); assert( nSize > 2 );
assert( nSize <= nLimit );
if ( nSize > 64 ) if ( nSize > 64 )
{ {
for ( i = 0; i < 64; i++ ) for ( i = 0; i < 64; i++ )
Matrix[i] = 0; Matrix[i] = 0;
return 0; return 0;
} }
Levels = ABC_ALLOC( int, nLimit+256 );
// mark current nodes // mark current nodes
Gia_ManIncrementTravId( p ); Gia_ManIncrementTravId( p );
Vec_IntForEachEntry( vSuper, iLit, i ) Vec_IntForEachEntry( vSuper, iLit, i )
...@@ -948,6 +950,7 @@ int Str_ManVectorAffinity( Gia_Man_t * p, Vec_Int_t * vSuper, Vec_Int_t * vDelay ...@@ -948,6 +950,7 @@ int Str_ManVectorAffinity( Gia_Man_t * p, Vec_Int_t * vSuper, Vec_Int_t * vDelay
if ( nSizeNew == 0 ) if ( nSizeNew == 0 )
{ {
Vec_IntShrink( vSuper, nSize ); Vec_IntShrink( vSuper, nSize );
ABC_FREE( Levels );
return 0; return 0;
} }
/* /*
...@@ -979,6 +982,7 @@ int Str_ManVectorAffinity( Gia_Man_t * p, Vec_Int_t * vSuper, Vec_Int_t * vDelay ...@@ -979,6 +982,7 @@ int Str_ManVectorAffinity( Gia_Man_t * p, Vec_Int_t * vSuper, Vec_Int_t * vDelay
} }
i = 0; i = 0;
} }
ABC_FREE( Levels );
Vec_IntShrink( vSuper, nSize ); Vec_IntShrink( vSuper, nSize );
return nSizeNew; return nSizeNew;
} }
...@@ -1088,15 +1092,14 @@ int Str_NtkBalanceTwo( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, int i, ...@@ -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 ) void Str_NtkBalanceMulti( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, Vec_Int_t * vDelay, int nLutSize )
{ {
word pMatrix[256]; word * pMatrix = ABC_ALLOC( word, pObj->nFanins+256 );
int Limit = 256;
Vec_Int_t * vSuper = pNew->vSuper; Vec_Int_t * vSuper = pNew->vSuper;
Vec_Int_t * vCosts = pNew->vStore; Vec_Int_t * vCosts = pNew->vStore;
int * pSuper = Vec_IntArray(vSuper); int * pSuper = Vec_IntArray(vSuper);
int * pCost = Vec_IntArray(vCosts); int * pCost = Vec_IntArray(vCosts);
int k, iLit, MatrixSize = 0; int k, iLit, MatrixSize = 0;
assert( Limit <= Vec_IntCap(vSuper) ); assert( (int)pObj->nFanins <= Vec_IntCap(vSuper) );
assert( Limit <= Vec_IntCap(vCosts) ); assert( (int)pObj->nFanins <= Vec_IntCap(vCosts) );
// collect nodes // collect nodes
Vec_IntClear( vSuper ); Vec_IntClear( vSuper );
...@@ -1111,11 +1114,13 @@ void Str_NtkBalanceMulti( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, Vec ...@@ -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 ) if ( Vec_IntSize(vSuper) == 1 )
{ {
pObj->iCopy = Vec_IntEntry(vSuper, 0); pObj->iCopy = Vec_IntEntry(vSuper, 0);
ABC_FREE( pMatrix );
return; return;
} }
if ( Vec_IntSize(vSuper) == 2 ) if ( Vec_IntSize(vSuper) == 2 )
{ {
pObj->iCopy = Str_NtkBalanceTwo( pNew, p, pObj, 0, 1, vDelay, pCost, pSuper, pMatrix, 2, nLutSize, -1 ); pObj->iCopy = Str_NtkBalanceTwo( pNew, p, pObj, 0, 1, vDelay, pCost, pSuper, pMatrix, 2, nLutSize, -1 );
ABC_FREE( pMatrix );
return; return;
} }
...@@ -1127,7 +1132,7 @@ void Str_NtkBalanceMulti( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, Vec ...@@ -1127,7 +1132,7 @@ void Str_NtkBalanceMulti( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, Vec
// compute affinity // compute affinity
if ( Vec_IntSize(vSuper) < 64 ) 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 // start the new product
while ( Vec_IntSize(vSuper) > 2 ) 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 ...@@ -1147,7 +1152,7 @@ void Str_NtkBalanceMulti( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, Vec
// compute affinity // compute affinity
if ( Vec_IntSize(vSuper) == 64 ) 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 ); assert( Vec_IntSize(vSuper) <= 64 );
// Str_PrintState( pCost, pSuper, pMatrix, Vec_IntSize(vSuper) ); // 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 ...@@ -1236,6 +1241,7 @@ void Str_NtkBalanceMulti( Gia_Man_t * pNew, Str_Ntk_t * p, Str_Obj_t * pObj, Vec
continue; continue;
} }
pObj->iCopy = Str_NtkBalanceTwo( pNew, p, pObj, 0, 1, vDelay, pCost, pSuper, pMatrix, 2, nLutSize, -1 ); pObj->iCopy = Str_NtkBalanceTwo( pNew, p, pObj, 0, 1, vDelay, pCost, pSuper, pMatrix, 2, nLutSize, -1 );
ABC_FREE( pMatrix );
/* /*
// simple // simple
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment