summaryrefslogtreecommitdiffstats
path: root/src/aig/dar/darCore.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2007-04-28 08:01:00 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2007-04-28 08:01:00 -0700
commitfeb8fb692e09a2fc7c1da4f2fcf605d398e940f2 (patch)
tree9a1cc7b8e64719e109bbdb99b1e8d49dcb34715c /src/aig/dar/darCore.c
parentc09d4d499cee70f02e3e9a18226554b8d1d34488 (diff)
downloadabc-feb8fb692e09a2fc7c1da4f2fcf605d398e940f2.tar.gz
abc-feb8fb692e09a2fc7c1da4f2fcf605d398e940f2.tar.bz2
abc-feb8fb692e09a2fc7c1da4f2fcf605d398e940f2.zip
Version abc70428
Diffstat (limited to 'src/aig/dar/darCore.c')
-rw-r--r--src/aig/dar/darCore.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/src/aig/dar/darCore.c b/src/aig/dar/darCore.c
new file mode 100644
index 00000000..9f0f58f6
--- /dev/null
+++ b/src/aig/dar/darCore.c
@@ -0,0 +1,106 @@
+/**CFile****************************************************************
+
+ FileName [darCore.c]
+
+ SystemName [ABC: Logic synthesis and verification system.]
+
+ PackageName [DAG-aware AIG rewriting.]
+
+ Synopsis [Core of the rewriting package.]
+
+ Author [Alan Mishchenko]
+
+ Affiliation [UC Berkeley]
+
+ Date [Ver. 1.0. Started - April 28, 2007.]
+
+ Revision [$Id: darCore.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
+
+***********************************************************************/
+
+#include "dar.h"
+
+////////////////////////////////////////////////////////////////////////
+/// DECLARATIONS ///
+////////////////////////////////////////////////////////////////////////
+
+////////////////////////////////////////////////////////////////////////
+/// FUNCTION DEFINITIONS ///
+////////////////////////////////////////////////////////////////////////
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Dar_ManRewrite( Dar_Man_t * p )
+{
+ ProgressBar * pProgress;
+ Dar_Obj_t * pObj, * pObjNew;
+ int i, k, nNodesOld, nNodeBefore, nNodeAfter, Required;
+ int clk = 0, clkStart = clock();
+ // remove dangling nodes
+ Dar_ManCleanup( p );
+ // set elementary cuts for the PIs
+ Dar_ManSetupPis( p );
+// if ( p->pPars->fUpdateLevel )
+// Dar_NtkStartReverseLevels( p );
+ // resynthesize each node once
+ nNodesOld = Vec_PtrSize( p->vObjs );
+ pProgress = Extra_ProgressBarStart( stdout, nNodesOld );
+ Dar_ManForEachObj( p, pObj, i )
+ {
+ Extra_ProgressBarUpdate( pProgress, i, NULL );
+ if ( !Dar_ObjIsNode(pObj) )
+ continue;
+ if ( i > nNodesOld )
+ break;
+ // compute cuts for the node
+ Dar_ObjComputeCuts_rec( p, pObj );
+ // go through the cuts of this node
+ Required = 1000000;
+ p->GainBest = -1;
+ for ( k = 1; k < (int)pObj->nCuts; k++ )
+ Dar_LibEval( p, pObj, (Dar_Cut_t *)pObj->pData + k, Required );
+ // check the best gain
+ if ( !(p->GainBest > 0 || p->GainBest == 0 && p->pPars->fUseZeros) )
+ continue;
+ // if we end up here, a rewriting step is accepted
+ nNodeBefore = Dar_ManNodeNum( p );
+ pObjNew = Dar_LibBuildBest( p );
+ pObjNew = Dar_NotCond( pObjNew, pObjNew->fPhase ^ pObj->fPhase );
+ // remove the old nodes
+ Dar_ObjReplace( p, pObj, pObjNew );
+ // compare the gains
+ nNodeAfter = Dar_ManNodeNum( p );
+ assert( p->GainBest == nNodeBefore - nNodeAfter );
+ assert( (int)pObjNew->Level <= Required );
+ }
+ Extra_ProgressBarStop( pProgress );
+ Dar_ManCutsFree( p );
+ // put the nodes into the DFS order and reassign their IDs
+// Dar_NtkReassignIds( p );
+
+ // fix the levels
+// if ( p->pPars->fUpdateLevel )
+// Dar_NtkStopReverseLevels( p );
+ // check
+ if ( !Dar_ManCheck( p ) )
+ {
+ printf( "Dar_ManRewrite: The network check has failed.\n" );
+ return 0;
+ }
+ return 1;
+}
+
+////////////////////////////////////////////////////////////////////////
+/// END OF FILE ///
+////////////////////////////////////////////////////////////////////////
+
+