summaryrefslogtreecommitdiffstats
path: root/src/map/if
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2014-04-19 19:57:32 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2014-04-19 19:57:32 -0700
commit606fed3b847bc2029a9eb4622f0e23eae3c3bb1c (patch)
tree7c18a2f82f814aa01e5b3ff2ae655aae238cf50f /src/map/if
parente868d057bbc6d0d0a0a32bd39f0b90698c50428d (diff)
downloadabc-606fed3b847bc2029a9eb4622f0e23eae3c3bb1c.tar.gz
abc-606fed3b847bc2029a9eb4622f0e23eae3c3bb1c.tar.bz2
abc-606fed3b847bc2029a9eb4622f0e23eae3c3bb1c.zip
Added optimization for average rather than maximum delay.
Diffstat (limited to 'src/map/if')
-rw-r--r--src/map/if/if.h6
-rw-r--r--src/map/if/ifTime.c251
-rw-r--r--src/map/if/ifUtil.c242
3 files changed, 254 insertions, 245 deletions
diff --git a/src/map/if/if.h b/src/map/if/if.h
index eeb1abd7..69f8100c 100644
--- a/src/map/if/if.h
+++ b/src/map/if/if.h
@@ -132,7 +132,7 @@ struct If_Par_t_
int fUseDsd; // compute DSD of the cut functions
int fUseTtPerm; // compute truth tables of the cut functions
int fDeriveLuts; // enables deriving LUT structures
- int fRepack; // repack after mapping
+ int fDoAverage; // optimize average rather than maximum level
int fVerbose; // the verbosity flag
char * pLutStruct; // LUT structure
float WireDelay; // wire delay
@@ -605,6 +605,8 @@ extern int If_ManPerformMappingSeq( If_Man_t * p );
/*=== ifTime.c ============================================================*/
extern float If_CutDelay( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut );
extern void If_CutPropagateRequired( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut, float Required );
+extern float If_ManDelayMax( If_Man_t * p, int fSeq );
+extern void If_ManComputeRequired( If_Man_t * p );
/*=== ifTruth.c ===========================================================*/
extern void If_CutRotatePins( If_Man_t * p, If_Cut_t * pCut );
extern int If_CutComputeTruth( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_Cut_t * pCut1, int fCompl0, int fCompl1 );
@@ -613,8 +615,6 @@ extern int If_CutComputeTruthPerm( If_Man_t * p, If_Cut_t * pCut, If
extern void If_ManCleanNodeCopy( If_Man_t * p );
extern void If_ManCleanCutData( If_Man_t * p );
extern void If_ManCleanMarkV( If_Man_t * p );
-extern float If_ManDelayMax( If_Man_t * p, int fSeq );
-extern void If_ManComputeRequired( If_Man_t * p );
extern float If_ManScanMapping( If_Man_t * p );
extern float If_ManScanMappingDirect( If_Man_t * p );
extern float If_ManScanMappingSeq( If_Man_t * p );
diff --git a/src/map/if/ifTime.c b/src/map/if/ifTime.c
index 3193c8b0..7402bd31 100644
--- a/src/map/if/ifTime.c
+++ b/src/map/if/ifTime.c
@@ -236,6 +236,257 @@ void If_CutPropagateRequired( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut, fl
}
}
+/**Function*************************************************************
+
+ Synopsis [Returns the max delay of the POs.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+float If_ManDelayMax( If_Man_t * p, int fSeq )
+{
+ If_Obj_t * pObj;
+ float DelayBest;
+ int i;
+ if ( p->pPars->fLatchPaths && (p->pPars->nLatchesCi == 0 || p->pPars->nLatchesCo == 0) )
+ {
+ Abc_Print( 0, "Delay optimization of latch path is not performed because there is no latches.\n" );
+ p->pPars->fLatchPaths = 0;
+ }
+ DelayBest = -IF_FLOAT_LARGE;
+ if ( fSeq )
+ {
+ assert( p->pPars->nLatchesCi > 0 );
+ If_ManForEachPo( p, pObj, i )
+ if ( DelayBest < If_ObjArrTime(If_ObjFanin0(pObj)) )
+ DelayBest = If_ObjArrTime(If_ObjFanin0(pObj));
+ }
+ else if ( p->pPars->fLatchPaths )
+ {
+ If_ManForEachLatchInput( p, pObj, i )
+ if ( DelayBest < If_ObjArrTime(If_ObjFanin0(pObj)) )
+ DelayBest = If_ObjArrTime(If_ObjFanin0(pObj));
+ }
+ else
+ {
+ If_ManForEachCo( p, pObj, i )
+ if ( DelayBest < If_ObjArrTime(If_ObjFanin0(pObj)) )
+ DelayBest = If_ObjArrTime(If_ObjFanin0(pObj));
+ }
+ return DelayBest;
+}
+
+/**Function*************************************************************
+
+ Synopsis [Computes the required times of all nodes.]
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+void If_ManComputeRequired( If_Man_t * p )
+{
+ If_Obj_t * pObj;
+ int i, Counter;
+ float reqTime;
+
+ // compute area, clean required times, collect nodes used in the mapping
+// p->AreaGlo = If_ManScanMapping( p );
+ If_ManMarkMapping( p );
+ if ( p->pManTim == NULL )
+ {
+ // consider the case when the required times are given
+ if ( p->pPars->pTimesReq && !p->pPars->fAreaOnly )
+ {
+ // make sure that the required time hold
+ Counter = 0;
+ If_ManForEachCo( p, pObj, i )
+ {
+ if ( If_ObjArrTime(If_ObjFanin0(pObj)) > p->pPars->pTimesReq[i] + p->fEpsilon )
+ {
+ If_ObjFanin0(pObj)->Required = If_ObjArrTime(If_ObjFanin0(pObj));
+ Counter++;
+ // Abc_Print( 0, "Required times are violated for output %d (arr = %d; req = %d).\n",
+ // i, (int)If_ObjArrTime(If_ObjFanin0(pObj)), (int)p->pPars->pTimesReq[i] );
+ }
+ else
+ If_ObjFanin0(pObj)->Required = p->pPars->pTimesReq[i];
+ }
+ if ( Counter && !p->fReqTimeWarn )
+ {
+ Abc_Print( 0, "Required times are exceeded at %d output%s. The earliest arrival times are used.\n", Counter, Counter > 1 ? "s":"" );
+ p->fReqTimeWarn = 1;
+ }
+ }
+ else
+ {
+ // get the global required times
+ p->RequiredGlo = If_ManDelayMax( p, 0 );
+
+ // find new delay target
+ if ( p->pPars->nRelaxRatio && p->pPars->DelayTargetNew == 0 )
+ p->pPars->DelayTargetNew = p->RequiredGlo * (100.0 + p->pPars->nRelaxRatio) / 100.0;
+
+ // update the required times according to the target
+ if ( p->pPars->DelayTarget != -1 )
+ {
+ if ( p->RequiredGlo > p->pPars->DelayTarget + p->fEpsilon )
+ {
+ if ( p->fNextRound == 0 )
+ {
+ p->fNextRound = 1;
+ Abc_Print( 0, "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 ( p->fNextRound == 0 )
+ {
+ p->fNextRound = 1;
+// Abc_Print( 0, "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->RequiredGlo, p->pPars->DelayTarget );
+ }
+ p->RequiredGlo = p->pPars->DelayTarget;
+ }
+ }
+ else if ( p->pPars->DelayTargetNew > 0 ) // relax the required times
+ p->RequiredGlo = p->pPars->DelayTargetNew;
+ // do not propagate required times if area minimization is requested
+ if ( p->pPars->fAreaOnly )
+ return;
+ // set the required times for the POs
+ if ( p->pPars->fDoAverage )
+ {
+ If_ManForEachCo( p, pObj, i )
+ If_ObjFanin0(pObj)->Required = If_ObjArrTime(If_ObjFanin0(pObj));
+ }
+ else if ( p->pPars->fLatchPaths )
+ {
+ If_ManForEachLatchInput( 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( If_Obj_t *, p->vMapped, pObj, i )
+ // If_CutPropagateRequired( p, pObj, If_ObjCutBest(pObj), pObj->Required );
+ If_ManForEachObjReverse( p, pObj, i )
+ {
+ if ( pObj->nRefs == 0 )
+ continue;
+ If_CutPropagateRequired( p, pObj, If_ObjCutBest(pObj), pObj->Required );
+ }
+ }
+ else
+ {
+ // get the global required times
+ p->RequiredGlo = If_ManDelayMax( p, 0 );
+
+ // find new delay target
+ if ( p->pPars->nRelaxRatio && p->pPars->DelayTargetNew == 0 )
+ p->pPars->DelayTargetNew = p->RequiredGlo * (100.0 + p->pPars->nRelaxRatio) / 100.0;
+
+ // update the required times according to the target
+ if ( p->pPars->DelayTarget != -1 )
+ {
+ if ( p->RequiredGlo > p->pPars->DelayTarget + p->fEpsilon )
+ {
+ if ( p->fNextRound == 0 )
+ {
+ p->fNextRound = 1;
+ Abc_Print( 0, "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 ( p->fNextRound == 0 )
+ {
+ p->fNextRound = 1;
+// Abc_Print( 0, "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->RequiredGlo, p->pPars->DelayTarget );
+ }
+ p->RequiredGlo = p->pPars->DelayTarget;
+ }
+ }
+ else if ( p->pPars->DelayTargetNew > 0 ) // relax the required times
+ p->RequiredGlo = p->pPars->DelayTargetNew;
+
+ // do not propagate required times if area minimization is requested
+ if ( p->pPars->fAreaOnly )
+ return;
+ // set the required times for the POs
+ Tim_ManIncrementTravId( p->pManTim );
+ if ( p->vCoAttrs )
+ {
+ assert( If_ManCoNum(p) == Vec_IntSize(p->vCoAttrs) );
+ If_ManForEachCo( p, pObj, i )
+ {
+ if ( Vec_IntEntry(p->vCoAttrs, i) == -1 ) // -1=internal
+ continue;
+ if ( Vec_IntEntry(p->vCoAttrs, i) == 0 ) // 0=optimize
+ Tim_ManSetCoRequired( p->pManTim, i, p->RequiredGlo );
+ else if ( Vec_IntEntry(p->vCoAttrs, i) == 1 ) // 1=keep
+ Tim_ManSetCoRequired( p->pManTim, i, If_ObjArrTime(If_ObjFanin0(pObj)) );
+ else if ( Vec_IntEntry(p->vCoAttrs, i) == 2 ) // 2=relax
+ Tim_ManSetCoRequired( p->pManTim, i, IF_FLOAT_LARGE );
+ else assert( 0 );
+ }
+ }
+ else if ( p->pPars->fDoAverage )
+ {
+ If_ManForEachCo( p, pObj, i )
+ Tim_ManSetCoRequired( p->pManTim, i, If_ObjArrTime(If_ObjFanin0(pObj)) );
+ }
+ else if ( p->pPars->fLatchPaths )
+ {
+ If_ManForEachPo( p, pObj, i )
+ Tim_ManSetCoRequired( p->pManTim, i, IF_FLOAT_LARGE );
+ If_ManForEachLatchInput( p, pObj, i )
+ Tim_ManSetCoRequired( p->pManTim, i, p->RequiredGlo );
+ }
+ else
+ {
+ Tim_ManInitPoRequiredAll( p->pManTim, p->RequiredGlo );
+// If_ManForEachCo( p, pObj, i )
+// Tim_ManSetCoRequired( p->pManTim, pObj->IdPio, p->RequiredGlo );
+ }
+ // go through the nodes in the reverse topological order
+ If_ManForEachObjReverse( p, pObj, i )
+ {
+ if ( If_ObjIsAnd(pObj) )
+ {
+ if ( pObj->nRefs == 0 )
+ continue;
+ If_CutPropagateRequired( p, pObj, If_ObjCutBest(pObj), pObj->Required );
+ }
+ else if ( If_ObjIsCi(pObj) )
+ {
+ reqTime = pObj->Required;
+ Tim_ManSetCiRequired( p->pManTim, pObj->IdPio, reqTime );
+ }
+ else if ( If_ObjIsCo(pObj) )
+ {
+ reqTime = Tim_ManGetCoRequired( p->pManTim, pObj->IdPio );
+ If_ObjFanin0(pObj)->Required = IF_MIN( reqTime, If_ObjFanin0(pObj)->Required );
+ }
+ else if ( If_ObjIsConst1(pObj) )
+ {
+ }
+ else // add the node to the mapper
+ assert( 0 );
+ }
+ }
+}
+
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/map/if/ifUtil.c b/src/map/if/ifUtil.c
index eca5fbc6..ec172b1b 100644
--- a/src/map/if/ifUtil.c
+++ b/src/map/if/ifUtil.c
@@ -87,248 +87,6 @@ void If_ManCleanMarkV( If_Man_t * p )
If_ManForEachObj( p, pObj, i )
pObj->fVisit = 0;
}
-
-/**Function*************************************************************
-
- Synopsis [Returns the max delay of the POs.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-float If_ManDelayMax( If_Man_t * p, int fSeq )
-{
- If_Obj_t * pObj;
- float DelayBest;
- int i;
- if ( p->pPars->fLatchPaths && (p->pPars->nLatchesCi == 0 || p->pPars->nLatchesCo == 0) )
- {
- Abc_Print( 0, "Delay optimization of latch path is not performed because there is no latches.\n" );
- p->pPars->fLatchPaths = 0;
- }
- DelayBest = -IF_FLOAT_LARGE;
- if ( fSeq )
- {
- assert( p->pPars->nLatchesCi > 0 );
- If_ManForEachPo( p, pObj, i )
- if ( DelayBest < If_ObjArrTime(If_ObjFanin0(pObj)) )
- DelayBest = If_ObjArrTime(If_ObjFanin0(pObj));
- }
- else if ( p->pPars->fLatchPaths )
- {
- If_ManForEachLatchInput( p, pObj, i )
- if ( DelayBest < If_ObjArrTime(If_ObjFanin0(pObj)) )
- DelayBest = If_ObjArrTime(If_ObjFanin0(pObj));
- }
- else
- {
- If_ManForEachCo( p, pObj, i )
- if ( DelayBest < If_ObjArrTime(If_ObjFanin0(pObj)) )
- DelayBest = If_ObjArrTime(If_ObjFanin0(pObj));
- }
- return DelayBest;
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes the required times of all nodes.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-void If_ManComputeRequired( If_Man_t * p )
-{
- If_Obj_t * pObj;
- int i, Counter;
- float reqTime;
-
- // compute area, clean required times, collect nodes used in the mapping
-// p->AreaGlo = If_ManScanMapping( p );
- If_ManMarkMapping( p );
-
- if ( p->pManTim == NULL )
- {
- // consider the case when the required times are given
- if ( p->pPars->pTimesReq && !p->pPars->fAreaOnly )
- {
- // make sure that the required time hold
- Counter = 0;
- If_ManForEachCo( p, pObj, i )
- {
- if ( If_ObjArrTime(If_ObjFanin0(pObj)) > p->pPars->pTimesReq[i] + p->fEpsilon )
- {
- If_ObjFanin0(pObj)->Required = If_ObjArrTime(If_ObjFanin0(pObj));
- Counter++;
- // Abc_Print( 0, "Required times are violated for output %d (arr = %d; req = %d).\n",
- // i, (int)If_ObjArrTime(If_ObjFanin0(pObj)), (int)p->pPars->pTimesReq[i] );
- }
- else
- If_ObjFanin0(pObj)->Required = p->pPars->pTimesReq[i];
- }
- if ( Counter && !p->fReqTimeWarn )
- {
- Abc_Print( 0, "Required times are exceeded at %d output%s. The earliest arrival times are used.\n", Counter, Counter > 1 ? "s":"" );
- p->fReqTimeWarn = 1;
- }
- }
- else
- {
- // get the global required times
- p->RequiredGlo = If_ManDelayMax( p, 0 );
-
- // find new delay target
- if ( p->pPars->nRelaxRatio && p->pPars->DelayTargetNew == 0 )
- p->pPars->DelayTargetNew = p->RequiredGlo * (100.0 + p->pPars->nRelaxRatio) / 100.0;
-
- // update the required times according to the target
- if ( p->pPars->DelayTarget != -1 )
- {
- if ( p->RequiredGlo > p->pPars->DelayTarget + p->fEpsilon )
- {
- if ( p->fNextRound == 0 )
- {
- p->fNextRound = 1;
- Abc_Print( 0, "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 ( p->fNextRound == 0 )
- {
- p->fNextRound = 1;
-// Abc_Print( 0, "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->RequiredGlo, p->pPars->DelayTarget );
- }
- p->RequiredGlo = p->pPars->DelayTarget;
- }
- }
- else if ( p->pPars->DelayTargetNew > 0 ) // relax the required times
- p->RequiredGlo = p->pPars->DelayTargetNew;
- // do not propagate required times if area minimization is requested
- if ( p->pPars->fAreaOnly )
- return;
- // set the required times for the POs
- if ( p->pPars->fLatchPaths )
- {
- If_ManForEachLatchInput( 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( If_Obj_t *, p->vMapped, pObj, i )
- // If_CutPropagateRequired( p, pObj, If_ObjCutBest(pObj), pObj->Required );
- If_ManForEachObjReverse( p, pObj, i )
- {
- if ( pObj->nRefs == 0 )
- continue;
- If_CutPropagateRequired( p, pObj, If_ObjCutBest(pObj), pObj->Required );
- }
- }
- else
- {
- // get the global required times
- p->RequiredGlo = If_ManDelayMax( p, 0 );
-
- // find new delay target
- if ( p->pPars->nRelaxRatio && p->pPars->DelayTargetNew == 0 )
- p->pPars->DelayTargetNew = p->RequiredGlo * (100.0 + p->pPars->nRelaxRatio) / 100.0;
-
- // update the required times according to the target
- if ( p->pPars->DelayTarget != -1 )
- {
- if ( p->RequiredGlo > p->pPars->DelayTarget + p->fEpsilon )
- {
- if ( p->fNextRound == 0 )
- {
- p->fNextRound = 1;
- Abc_Print( 0, "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 ( p->fNextRound == 0 )
- {
- p->fNextRound = 1;
-// Abc_Print( 0, "Relaxing the required times from (%4.2f) to the target (%4.2f).\n", p->RequiredGlo, p->pPars->DelayTarget );
- }
- p->RequiredGlo = p->pPars->DelayTarget;
- }
- }
- else if ( p->pPars->DelayTargetNew > 0 ) // relax the required times
- p->RequiredGlo = p->pPars->DelayTargetNew;
-
- // do not propagate required times if area minimization is requested
- if ( p->pPars->fAreaOnly )
- return;
- // set the required times for the POs
- Tim_ManIncrementTravId( p->pManTim );
- if ( p->vCoAttrs )
- {
- assert( If_ManCoNum(p) == Vec_IntSize(p->vCoAttrs) );
- If_ManForEachCo( p, pObj, i )
- {
- if ( Vec_IntEntry(p->vCoAttrs, i) == -1 ) // -1=internal
- continue;
- if ( Vec_IntEntry(p->vCoAttrs, i) == 0 ) // 0=optimize
- Tim_ManSetCoRequired( p->pManTim, i, p->RequiredGlo );
- else if ( Vec_IntEntry(p->vCoAttrs, i) == 1 ) // 1=keep
- Tim_ManSetCoRequired( p->pManTim, i, If_ObjArrTime(If_ObjFanin0(pObj)) );
- else if ( Vec_IntEntry(p->vCoAttrs, i) == 2 ) // 2=relax
- Tim_ManSetCoRequired( p->pManTim, i, IF_FLOAT_LARGE );
- else assert( 0 );
- }
- }
- else if ( p->pPars->fLatchPaths )
- {
- If_ManForEachPo( p, pObj, i )
- Tim_ManSetCoRequired( p->pManTim, i, IF_FLOAT_LARGE );
- If_ManForEachLatchInput( p, pObj, i )
- Tim_ManSetCoRequired( p->pManTim, i, p->RequiredGlo );
- }
- else
- {
- Tim_ManInitPoRequiredAll( p->pManTim, p->RequiredGlo );
-// If_ManForEachCo( p, pObj, i )
-// Tim_ManSetCoRequired( p->pManTim, pObj->IdPio, p->RequiredGlo );
- }
- // go through the nodes in the reverse topological order
- If_ManForEachObjReverse( p, pObj, i )
- {
- if ( If_ObjIsAnd(pObj) )
- {
- if ( pObj->nRefs == 0 )
- continue;
- If_CutPropagateRequired( p, pObj, If_ObjCutBest(pObj), pObj->Required );
- }
- else if ( If_ObjIsCi(pObj) )
- {
- reqTime = pObj->Required;
- Tim_ManSetCiRequired( p->pManTim, pObj->IdPio, reqTime );
- }
- else if ( If_ObjIsCo(pObj) )
- {
- reqTime = Tim_ManGetCoRequired( p->pManTim, pObj->IdPio );
- If_ObjFanin0(pObj)->Required = IF_MIN( reqTime, If_ObjFanin0(pObj)->Required );
- }
- else if ( If_ObjIsConst1(pObj) )
- {
- }
- else // add the node to the mapper
- assert( 0 );
- }
- }
-}
#if 0