abc/src/base/abc/abcRewrite.c

92 lines
2.7 KiB
C
Raw Normal View History

2005-08-07 17:01:00 +02:00
/**CFile****************************************************************
FileName [abcRes.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Network and node package.]
Synopsis [Technology-independent resynthesis of the AIG.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: abcRes.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "abc.h"
2005-08-18 17:01:00 +02:00
#include "rwr.h"
2005-08-07 17:01:00 +02:00
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
2005-08-17 17:01:00 +02:00
Synopsis [Performs incremental rewriting of the AIG.]
2005-08-07 17:01:00 +02:00
2005-08-17 17:01:00 +02:00
Description []
2005-08-07 17:01:00 +02:00
SideEffects []
SeeAlso []
***********************************************************************/
2005-08-17 17:01:00 +02:00
int Abc_NtkRewrite( Abc_Ntk_t * pNtk )
2005-08-07 17:01:00 +02:00
{
int fCheck = 1;
ProgressBar * pProgress;
2005-08-18 17:01:00 +02:00
Rwr_Man_t * p;
2005-08-07 17:01:00 +02:00
Abc_Obj_t * pNode;
2005-08-17 17:01:00 +02:00
int i, nNodes, nGain;
2005-08-07 17:01:00 +02:00
assert( Abc_NtkIsAig(pNtk) );
2005-08-17 17:01:00 +02:00
// start the rewriting manager
2005-08-19 17:01:00 +02:00
p = Rwr_ManStart( 0 );
if ( p == NULL )
return 0;
2005-08-18 17:01:00 +02:00
Rwr_ManPrepareNetwork( p, pNtk );
2005-08-07 17:01:00 +02:00
2005-08-17 17:01:00 +02:00
// resynthesize each node once
nNodes = Abc_NtkObjNumMax(pNtk);
pProgress = Extra_ProgressBarStart( stdout, nNodes );
2005-08-07 17:01:00 +02:00
Abc_NtkForEachNode( pNtk, pNode, i )
{
2005-08-24 17:01:00 +02:00
Extra_ProgressBarUpdate( pProgress, i, NULL );
// stop if all nodes have been tried once
if ( i >= nNodes )
break;
// skip the constant node
if ( Abc_NodeIsConst(pNode) )
continue;
2005-08-17 17:01:00 +02:00
// for each cut, try to resynthesize it
2005-08-18 17:01:00 +02:00
if ( (nGain = Rwr_NodeRewrite( p, pNode )) >= 0 )
Abc_NodeUpdate( pNode, Rwr_ManReadFanins(p), Rwr_ManReadDecs(p), nGain );
2005-08-07 17:01:00 +02:00
}
Extra_ProgressBarStop( pProgress );
2005-08-17 17:01:00 +02:00
// delete the manager
2005-08-18 17:01:00 +02:00
Rwr_ManStop( p );
2005-08-07 17:01:00 +02:00
// check
if ( fCheck && !Abc_NtkCheck( pNtk ) )
{
2005-08-17 17:01:00 +02:00
printf( "Abc_NtkRewrite: The network check has failed.\n" );
2005-08-07 17:01:00 +02:00
return 0;
}
return 1;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////