mirror of https://github.com/YosysHQ/abc.git
Bug fix in sweep (which happens to be a rare bug in Abc_NodeMinimumBase).
This commit is contained in:
parent
d4f073bad7
commit
456e381a02
|
|
@ -72,7 +72,7 @@ int Abc_NtkMinimumBase( Abc_Ntk_t * pNtk )
|
|||
SeeAlso []
|
||||
|
||||
***********************************************************************/
|
||||
int Abc_NodeMinimumBase( Abc_Obj_t * pNode )
|
||||
int Abc_NodeMinimumBase_buggy( Abc_Obj_t * pNode )
|
||||
{
|
||||
Vec_Str_t * vSupport;
|
||||
Vec_Ptr_t * vFanins;
|
||||
|
|
@ -107,6 +107,55 @@ int Abc_NodeMinimumBase( Abc_Obj_t * pNode )
|
|||
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*************************************************************
|
||||
|
||||
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
|
|||
return 0;
|
||||
}
|
||||
// prepare nodes for sweeping
|
||||
Abc_NtkRemoveDupFanins( pNtk );
|
||||
//Abc_NtkRemoveDupFanins( pNtk );
|
||||
Abc_NtkMinimumBase( pNtk );
|
||||
Abc_NtkCleanup( pNtk, 0 );
|
||||
// get the nodes in the given order
|
||||
|
|
@ -740,7 +789,7 @@ int Abc_NtkEliminateSpecial( Abc_Ntk_t * pNtk, int nMaxSize, int fVerbose )
|
|||
}
|
||||
|
||||
// prepare nodes for sweeping
|
||||
Abc_NtkRemoveDupFanins( pNtk );
|
||||
//Abc_NtkRemoveDupFanins( pNtk );
|
||||
Abc_NtkMinimumBase( pNtk );
|
||||
Abc_NtkCleanup( pNtk, 0 );
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ void Abc_NtkBddReorder( Abc_Ntk_t * pNtk, int fVerbose )
|
|||
reo_man * p;
|
||||
Abc_Obj_t * pNode;
|
||||
int i;
|
||||
Abc_NtkRemoveDupFanins( pNtk );
|
||||
//Abc_NtkRemoveDupFanins( pNtk );
|
||||
Abc_NtkMinimumBase( pNtk );
|
||||
p = Extra_ReorderInit( Abc_NtkGetFaninMax(pNtk), 100 );
|
||||
Abc_NtkForEachNode( pNtk, pNode, i )
|
||||
|
|
|
|||
|
|
@ -619,7 +619,7 @@ int Abc_NtkSweep( Abc_Ntk_t * pNtk, int fVerbose )
|
|||
nNodesOld = Abc_NtkNodeNum(pNtk);
|
||||
Abc_NtkCleanup( pNtk, 0 );
|
||||
// prepare nodes for sweeping
|
||||
Abc_NtkRemoveDupFanins(pNtk);
|
||||
//Abc_NtkRemoveDupFanins(pNtk);
|
||||
Abc_NtkMinimumBase(pNtk);
|
||||
// collect sweepable nodes
|
||||
vNodes = Vec_PtrAlloc( 100 );
|
||||
|
|
@ -649,7 +649,7 @@ int Abc_NtkSweep( Abc_Ntk_t * pNtk, int fVerbose )
|
|||
Abc_NodeComplementInput( pFanout, pNode );
|
||||
Abc_ObjPatchFanin( pFanout, pNode, pDriver );
|
||||
}
|
||||
Abc_NodeRemoveDupFanins( pFanout );
|
||||
//Abc_NodeRemoveDupFanins( pFanout );
|
||||
Abc_NodeMinimumBase( pFanout );
|
||||
// check if the fanout should be added
|
||||
if ( Abc_ObjFaninNum(pFanout) < 2 )
|
||||
|
|
|
|||
Loading…
Reference in New Issue