Commit 456e381a by Alan Mishchenko

Bug fix in sweep (which happens to be a rare bug in Abc_NodeMinimumBase).

parent d4f073ba
...@@ -72,7 +72,7 @@ int Abc_NtkMinimumBase( Abc_Ntk_t * pNtk ) ...@@ -72,7 +72,7 @@ int Abc_NtkMinimumBase( Abc_Ntk_t * pNtk )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Abc_NodeMinimumBase( Abc_Obj_t * pNode ) int Abc_NodeMinimumBase_buggy( Abc_Obj_t * pNode )
{ {
Vec_Str_t * vSupport; Vec_Str_t * vSupport;
Vec_Ptr_t * vFanins; Vec_Ptr_t * vFanins;
...@@ -107,6 +107,55 @@ int Abc_NodeMinimumBase( Abc_Obj_t * pNode ) ...@@ -107,6 +107,55 @@ int Abc_NodeMinimumBase( Abc_Obj_t * pNode )
return 1; return 1;
} }
int Abc_NodeMinimumBase( Abc_Obj_t * pNode )
{
DdManager * dd = (DdManager *)pNode->pNtk->pManFunc;
DdNode * bTemp, ** pbVars;
Vec_Str_t * vSupport;
int i, nVars, j, iFanin, iFanin2, k = 0;
assert( Abc_NtkIsBddLogic(pNode->pNtk) );
assert( Abc_ObjIsNode(pNode) );
// compute support
vSupport = Vec_StrAlloc( 10 );
nVars = Abc_NodeSupport( Cudd_Regular(pNode->pData), vSupport, Abc_ObjFaninNum(pNode) );
if ( nVars == Abc_ObjFaninNum(pNode) )
{
Vec_StrFree( vSupport );
return 0;
}
// remove unused fanins
pbVars = ABC_CALLOC( DdNode *, Abc_ObjFaninNum(pNode) );
Vec_IntForEachEntry( &pNode->vFanins, iFanin, i )
{
Abc_Obj_t * pFanin = Abc_NtkObj( pNode->pNtk, iFanin );
if ( !Vec_StrEntry(vSupport, i) )
{
if ( !Vec_IntRemove( &pFanin->vFanouts, pNode->Id ) )
printf( "The obj %d is not found among the fanouts of obj %d ...\n", pNode->Id, iFanin );
continue;
}
Vec_IntForEachEntryStop( &pNode->vFanins, iFanin2, j, k )
if ( iFanin == iFanin2 )
break;
if ( j == k )
Vec_IntWriteEntry( &pNode->vFanins, k++, iFanin );
else if ( !Vec_IntRemove( &pFanin->vFanouts, pNode->Id ) )
printf( "The obj %d is not found among the fanouts of obj %d ...\n", pNode->Id, iFanin );
pbVars[i] = Cudd_bddIthVar( dd, j );
}
Vec_IntShrink( &pNode->vFanins, k );
// update the function of the node
pNode->pData = Cudd_bddVectorCompose( dd, bTemp = (DdNode *)pNode->pData, pbVars ); Cudd_Ref( (DdNode *)pNode->pData );
Cudd_RecursiveDeref( dd, bTemp );
Vec_StrFree( vSupport );
ABC_FREE( pbVars );
return 1;
}
/**Function************************************************************* /**Function*************************************************************
Synopsis [Makes nodes of the network fanin-dup-free.] Synopsis [Makes nodes of the network fanin-dup-free.]
...@@ -447,7 +496,7 @@ int Abc_NtkEliminate( Abc_Ntk_t * pNtk, int nMaxSize, int fReverse, int fVerbose ...@@ -447,7 +496,7 @@ int Abc_NtkEliminate( Abc_Ntk_t * pNtk, int nMaxSize, int fReverse, int fVerbose
return 0; return 0;
} }
// prepare nodes for sweeping // prepare nodes for sweeping
Abc_NtkRemoveDupFanins( pNtk ); //Abc_NtkRemoveDupFanins( pNtk );
Abc_NtkMinimumBase( pNtk ); Abc_NtkMinimumBase( pNtk );
Abc_NtkCleanup( pNtk, 0 ); Abc_NtkCleanup( pNtk, 0 );
// get the nodes in the given order // get the nodes in the given order
...@@ -740,7 +789,7 @@ int Abc_NtkEliminateSpecial( Abc_Ntk_t * pNtk, int nMaxSize, int fVerbose ) ...@@ -740,7 +789,7 @@ int Abc_NtkEliminateSpecial( Abc_Ntk_t * pNtk, int nMaxSize, int fVerbose )
} }
// prepare nodes for sweeping // prepare nodes for sweeping
Abc_NtkRemoveDupFanins( pNtk ); //Abc_NtkRemoveDupFanins( pNtk );
Abc_NtkMinimumBase( pNtk ); Abc_NtkMinimumBase( pNtk );
Abc_NtkCleanup( pNtk, 0 ); Abc_NtkCleanup( pNtk, 0 );
......
...@@ -84,7 +84,7 @@ void Abc_NtkBddReorder( Abc_Ntk_t * pNtk, int fVerbose ) ...@@ -84,7 +84,7 @@ void Abc_NtkBddReorder( Abc_Ntk_t * pNtk, int fVerbose )
reo_man * p; reo_man * p;
Abc_Obj_t * pNode; Abc_Obj_t * pNode;
int i; int i;
Abc_NtkRemoveDupFanins( pNtk ); //Abc_NtkRemoveDupFanins( pNtk );
Abc_NtkMinimumBase( pNtk ); Abc_NtkMinimumBase( pNtk );
p = Extra_ReorderInit( Abc_NtkGetFaninMax(pNtk), 100 ); p = Extra_ReorderInit( Abc_NtkGetFaninMax(pNtk), 100 );
Abc_NtkForEachNode( pNtk, pNode, i ) Abc_NtkForEachNode( pNtk, pNode, i )
......
...@@ -619,7 +619,7 @@ int Abc_NtkSweep( Abc_Ntk_t * pNtk, int fVerbose ) ...@@ -619,7 +619,7 @@ int Abc_NtkSweep( Abc_Ntk_t * pNtk, int fVerbose )
nNodesOld = Abc_NtkNodeNum(pNtk); nNodesOld = Abc_NtkNodeNum(pNtk);
Abc_NtkCleanup( pNtk, 0 ); Abc_NtkCleanup( pNtk, 0 );
// prepare nodes for sweeping // prepare nodes for sweeping
Abc_NtkRemoveDupFanins(pNtk); //Abc_NtkRemoveDupFanins(pNtk);
Abc_NtkMinimumBase(pNtk); Abc_NtkMinimumBase(pNtk);
// collect sweepable nodes // collect sweepable nodes
vNodes = Vec_PtrAlloc( 100 ); vNodes = Vec_PtrAlloc( 100 );
...@@ -649,7 +649,7 @@ int Abc_NtkSweep( Abc_Ntk_t * pNtk, int fVerbose ) ...@@ -649,7 +649,7 @@ int Abc_NtkSweep( Abc_Ntk_t * pNtk, int fVerbose )
Abc_NodeComplementInput( pFanout, pNode ); Abc_NodeComplementInput( pFanout, pNode );
Abc_ObjPatchFanin( pFanout, pNode, pDriver ); Abc_ObjPatchFanin( pFanout, pNode, pDriver );
} }
Abc_NodeRemoveDupFanins( pFanout ); //Abc_NodeRemoveDupFanins( pFanout );
Abc_NodeMinimumBase( pFanout ); Abc_NodeMinimumBase( pFanout );
// check if the fanout should be added // check if the fanout should be added
if ( Abc_ObjFaninNum(pFanout) < 2 ) if ( Abc_ObjFaninNum(pFanout) < 2 )
......
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