summaryrefslogtreecommitdiffstats
path: root/src/map/if/ifUtil.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2006-12-10 08:01:00 -0800
committerAlan Mishchenko <alanmi@berkeley.edu>2006-12-10 08:01:00 -0800
commitae037e45038cca6f0b86abea50692399a03b01be (patch)
tree6419a88dd09a51011be3fa98199775ae3cf68fae /src/map/if/ifUtil.c
parentb9abf9c00c02feb52a2c796199343acebe20d8ef (diff)
downloadabc-ae037e45038cca6f0b86abea50692399a03b01be.tar.gz
abc-ae037e45038cca6f0b86abea50692399a03b01be.tar.bz2
abc-ae037e45038cca6f0b86abea50692399a03b01be.zip
Version abc61210
Diffstat (limited to 'src/map/if/ifUtil.c')
-rw-r--r--src/map/if/ifUtil.c220
1 files changed, 153 insertions, 67 deletions
diff --git a/src/map/if/ifUtil.c b/src/map/if/ifUtil.c
index bb8e3dee..4b136f55 100644
--- a/src/map/if/ifUtil.c
+++ b/src/map/if/ifUtil.c
@@ -30,6 +30,65 @@
/**Function*************************************************************
+ Synopsis [Sets all the node copy to NULL.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void If_ManCleanNodeCopy( If_Man_t * p )
+{
+ If_Obj_t * pObj;
+ int i;
+ If_ManForEachObj( p, pObj, i )
+ If_ObjSetCopy( pObj, NULL );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Sets all the cut data to NULL.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void If_ManCleanCutData( If_Man_t * p )
+{
+ If_Obj_t * pObj;
+ If_Cut_t * pCut;
+ int i, k;
+ If_ManForEachObj( p, pObj, i )
+ If_ObjForEachCut( pObj, pCut, k )
+ If_CutSetData( pCut, NULL );
+}
+
+/**Function*************************************************************
+
+ Synopsis [Sets all visited marks to 0.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void If_ManCleanMarkV( If_Man_t * p )
+{
+ If_Obj_t * pObj;
+ int i;
+ If_ManForEachObj( p, pObj, i )
+ pObj->fVisit = 0;
+}
+
+/**Function*************************************************************
+
Synopsis [Returns the max delay of the POs.]
Description []
@@ -39,7 +98,7 @@
SeeAlso []
***********************************************************************/
-float If_ManDelayMax( If_Man_t * p )
+float If_ManDelayMax( If_Man_t * p, int fSeq )
{
If_Obj_t * pObj;
float DelayBest;
@@ -50,15 +109,22 @@ float If_ManDelayMax( If_Man_t * p )
p->pPars->fLatchPaths = 0;
}
DelayBest = -IF_FLOAT_LARGE;
- if ( p->pPars->fLatchPaths )
+ if ( fSeq )
+ {
+ assert( p->pPars->nLatches > 0 );
+ If_ManForEachPo( p, pObj, i )
+ if ( DelayBest < If_ObjCutBest( If_ObjFanin0(pObj) )->Delay )
+ DelayBest = If_ObjCutBest( If_ObjFanin0(pObj) )->Delay;
+ }
+ else if ( p->pPars->fLatchPaths )
{
If_ManForEachLatch( p, pObj, i )
if ( DelayBest < If_ObjCutBest( If_ObjFanin0(pObj) )->Delay )
DelayBest = If_ObjCutBest( If_ObjFanin0(pObj) )->Delay;
}
- else
+ else
{
- If_ManForEachPo( p, pObj, i )
+ If_ManForEachCo( p, pObj, i )
if ( DelayBest < If_ObjCutBest( If_ObjFanin0(pObj) )->Delay )
DelayBest = If_ObjCutBest( If_ObjFanin0(pObj) )->Delay;
}
@@ -67,7 +133,7 @@ float If_ManDelayMax( If_Man_t * p )
/**Function*************************************************************
- Synopsis [Sets all the node copy to NULL.]
+ Synopsis [Computes the required times of all nodes.]
Description []
@@ -76,33 +142,43 @@ float If_ManDelayMax( If_Man_t * p )
SeeAlso []
***********************************************************************/
-void If_ManCleanNodeCopy( If_Man_t * p )
+void If_ManComputeRequired( If_Man_t * p, int fFirstTime )
{
If_Obj_t * pObj;
int i;
- If_ManForEachObj( p, pObj, i )
- If_ObjSetCopy( pObj, NULL );
-}
-
-/**Function*************************************************************
-
- Synopsis [Sets all the cut data to NULL.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void If_ManCleanCutData( If_Man_t * p )
-{
- If_Obj_t * pObj;
- If_Cut_t * pCut;
- int i, k;
- If_ManForEachObj( p, pObj, i )
- If_ObjForEachCut( pObj, pCut, k )
- If_CutSetData( pCut, NULL );
+ // compute area, clean required times, collect nodes used in the mapping
+ p->AreaGlo = If_ManScanMapping( p );
+ // get the global required times
+ p->RequiredGlo = If_ManDelayMax( p, 0 );
+ // update the required times according to the target
+ if ( p->pPars->DelayTarget != -1 )
+ {
+ if ( p->RequiredGlo > p->pPars->DelayTarget + p->fEpsilon )
+ {
+ if ( fFirstTime )
+ printf( "Cannot meet the target required times (%4.2f). Mapping continues anyway.\n", p->pPars->DelayTarget );
+ }
+ else if ( p->RequiredGlo < p->pPars->DelayTarget - p->fEpsilon )
+ {
+ if ( fFirstTime )
+ printf( "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->RequiredGlo, p->pPars->DelayTarget );
+ p->RequiredGlo = p->pPars->DelayTarget;
+ }
+ }
+ // set the required times for the POs
+ if ( p->pPars->fLatchPaths )
+ {
+ If_ManForEachLatch( p, pObj, i )
+ If_ObjFanin0(pObj)->Required = p->RequiredGlo;
+ }
+ else
+ {
+ If_ManForEachCo( p, pObj, i )
+ If_ObjFanin0(pObj)->Required = p->RequiredGlo;
+ }
+ // go through the nodes in the reverse topological order
+ Vec_PtrForEachEntry( p->vMapped, pObj, i )
+ If_CutPropagateRequired( p, If_ObjCutBest(pObj), pObj->Required );
}
/**Function*************************************************************
@@ -122,7 +198,7 @@ float If_ManScanMapping_rec( If_Man_t * p, If_Obj_t * pObj, If_Obj_t ** ppStore
If_Cut_t * pCutBest;
float aArea;
int i;
- if ( pObj->nRefs++ || If_ObjIsPi(pObj) || If_ObjIsConst1(pObj) )
+ if ( pObj->nRefs++ || If_ObjIsCi(pObj) || If_ObjIsConst1(pObj) )
return 0.0;
// store the node in the structure by level
assert( If_ObjIsAnd(pObj) );
@@ -153,6 +229,7 @@ float If_ManScanMapping( If_Man_t * p )
If_Obj_t * pObj, ** ppStore;
float aArea;
int i;
+ assert( !p->pPars->fLiftLeaves );
// clean all references
If_ManForEachObj( p, pObj, i )
{
@@ -164,7 +241,7 @@ float If_ManScanMapping( If_Man_t * p )
memset( ppStore, 0, sizeof(If_Obj_t *) * (p->nLevelMax + 1) );
// collect nodes reachable from POs in the DFS order through the best cuts
aArea = 0;
- If_ManForEachPo( p, pObj, i )
+ If_ManForEachCo( p, pObj, i )
aArea += If_ManScanMapping_rec( p, If_ObjFanin0(pObj), ppStore );
// reconnect the nodes in reverse topological order
Vec_PtrClear( p->vMapped );
@@ -177,7 +254,7 @@ float If_ManScanMapping( If_Man_t * p )
/**Function*************************************************************
- Synopsis [Computes the required times of all nodes.]
+ Synopsis [Computes area, references, and nodes used in the mapping.]
Description []
@@ -186,46 +263,55 @@ float If_ManScanMapping( If_Man_t * p )
SeeAlso []
***********************************************************************/
-void If_ManComputeRequired( If_Man_t * p, int fFirstTime )
+float If_ManScanMappingSeq_rec( If_Man_t * p, If_Obj_t * pObj, Vec_Ptr_t * vMapped )
+{
+ If_Obj_t * pLeaf;
+ If_Cut_t * pCutBest;
+ float aArea;
+ int i, Shift;
+ if ( pObj->nRefs++ || If_ObjIsCi(pObj) || If_ObjIsConst1(pObj) )
+ return 0.0;
+ // store the node in the structure by level
+ assert( If_ObjIsAnd(pObj) );
+ // visit the transitive fanin of the selected cut
+ pCutBest = If_ObjCutBest(pObj);
+ aArea = If_ObjIsAnd(pObj)? If_CutLutArea(p, pCutBest) : (float)0.0;
+ If_CutForEachLeafSeq( p, pCutBest, pLeaf, Shift, i )
+ aArea += If_ManScanMappingSeq_rec( p, pLeaf, vMapped );
+ // add the node
+ Vec_PtrPush( vMapped, pObj );
+ return aArea;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes area, references, and nodes used in the mapping.]
+
+ Description [Collects the nodes in reverse topological order in array
+ p->vMapping.]
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+float If_ManScanMappingSeq( If_Man_t * p )
{
If_Obj_t * pObj;
+ float aArea;
int i;
- // compute area, clean required times, collect nodes used in the mapping
- p->AreaGlo = If_ManScanMapping( p );
- // get the global required times
- p->RequiredGlo = If_ManDelayMax( p );
- // update the required times according to the target
- if ( p->pPars->DelayTarget != -1 )
- {
- if ( p->RequiredGlo > p->pPars->DelayTarget + p->fEpsilon )
- {
- if ( fFirstTime )
- printf( "Cannot meet the target required times (%4.2f). Mapping continues anyway.\n", p->pPars->DelayTarget );
- }
- else if ( p->RequiredGlo < p->pPars->DelayTarget - p->fEpsilon )
- {
- if ( fFirstTime )
- printf( "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->RequiredGlo, p->pPars->DelayTarget );
- p->RequiredGlo = p->pPars->DelayTarget;
- }
- }
- // set the required times for the POs
- if ( p->pPars->fLatchPaths )
- {
- If_ManForEachLatch( p, pObj, i )
- If_ObjFanin0(pObj)->Required = p->RequiredGlo;
- }
- else
- {
- If_ManForEachPo( p, pObj, i )
- If_ObjFanin0(pObj)->Required = p->RequiredGlo;
- }
- // go through the nodes in the reverse topological order
- Vec_PtrForEachEntry( p->vMapped, pObj, i )
- If_CutPropagateRequired( p, If_ObjCutBest(pObj), pObj->Required );
+ assert( p->pPars->fLiftLeaves );
+ // clean all references
+ If_ManForEachObj( p, pObj, i )
+ pObj->nRefs = 0;
+ // collect nodes reachable from POs in the DFS order through the best cuts
+ aArea = 0;
+ Vec_PtrClear( p->vMapped );
+ If_ManForEachPo( p, pObj, i )
+ aArea += If_ManScanMappingSeq_rec( p, If_ObjFanin0(pObj), p->vMapped );
+ return aArea;
}
-
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////