summaryrefslogtreecommitdiffstats
path: root/src/opt/ret
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2010-11-01 01:35:04 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2010-11-01 01:35:04 -0700
commit6130e39b18b5f53902e4eab14f6d5cdde5219563 (patch)
tree0db0628479a1b750e9af1f66cb8379ebd0913d31 /src/opt/ret
parentf0e77f6797c0504b0da25a56152b707d3357f386 (diff)
downloadabc-6130e39b18b5f53902e4eab14f6d5cdde5219563.tar.gz
abc-6130e39b18b5f53902e4eab14f6d5cdde5219563.tar.bz2
abc-6130e39b18b5f53902e4eab14f6d5cdde5219563.zip
initial commit of public abc
Diffstat (limited to 'src/opt/ret')
-rw-r--r--src/opt/ret/retArea.c33
-rw-r--r--src/opt/ret/retCore.c21
-rw-r--r--src/opt/ret/retDelay.c28
-rw-r--r--src/opt/ret/retFlow.c27
-rw-r--r--src/opt/ret/retIncrem.c35
-rw-r--r--src/opt/ret/retInit.c29
-rw-r--r--src/opt/ret/retInt.h14
-rw-r--r--src/opt/ret/retLvalue.c11
-rw-r--r--src/opt/ret/ret_.c5
9 files changed, 127 insertions, 76 deletions
diff --git a/src/opt/ret/retArea.c b/src/opt/ret/retArea.c
index 63503916..38f95c22 100644
--- a/src/opt/ret/retArea.c
+++ b/src/opt/ret/retArea.c
@@ -20,6 +20,9 @@
#include "retInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -227,7 +230,7 @@ void Abc_NtkRetimeMinAreaPrepare( Abc_Ntk_t * pNtk, int fForward )
if ( !pFanin->fMarkA )
Vec_PtrPush( vNodes, pFanin );
// mark these nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
pObj->fMarkA = 1;
Vec_PtrFree( vNodes );
}
@@ -270,7 +273,7 @@ int Abc_NtkRetimeMinAreaInitValues_rec( Abc_Obj_t * pObj )
if ( Abc_ObjIsBo(pObj) )
{
assert( Abc_ObjIsLatch(Abc_ObjFanin0(pObj)) );
- pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_NtkRetimeMinAreaInitValues_rec( Abc_ObjFanin0(pObj) );
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Abc_NtkRetimeMinAreaInitValues_rec( Abc_ObjFanin0(pObj) );
return (int)(ABC_PTRUINT_T)pObj->pCopy;
}
assert( Abc_ObjIsNode(pObj) );
@@ -278,7 +281,7 @@ int Abc_NtkRetimeMinAreaInitValues_rec( Abc_Obj_t * pObj )
Abc_ObjForEachFanin( pObj, pFanin, i )
Abc_NtkRetimeMinAreaInitValues_rec( pFanin );
// compute the value of the node
- pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_ObjSopSimulate(pObj);
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Abc_ObjSopSimulate(pObj);
return (int)(ABC_PTRUINT_T)pObj->pCopy;
}
@@ -301,11 +304,11 @@ void Abc_NtkRetimeMinAreaInitValues( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut )
Abc_NtkIncrementTravId(pNtk);
Abc_NtkForEachLatch( pNtk, pObj, i )
{
- pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_LatchIsInit1(pObj);
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Abc_LatchIsInit1(pObj);
Abc_NodeSetTravIdCurrent( pObj );
}
// propagate initial values
- Vec_PtrForEachEntry( vMinCut, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMinCut, pObj, i )
Abc_NtkRetimeMinAreaInitValues_rec( pObj );
// unmark the latches
Abc_NtkForEachLatch( pNtk, pObj, i )
@@ -368,7 +371,7 @@ Abc_Ntk_t * Abc_NtkRetimeMinAreaConstructNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMin
pNtkNew = Abc_NtkAlloc( ABC_NTK_LOGIC, ABC_FUNC_SOP, 1 );
// map new latches into PIs of the new network
Abc_NtkIncrementTravId(pNtk);
- Vec_PtrForEachEntry( vMinCut, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMinCut, pObj, i )
{
pObj->pCopy = Abc_NtkCreatePi(pNtkNew);
Abc_NodeSetTravIdCurrent( pObj );
@@ -380,7 +383,7 @@ Abc_Ntk_t * Abc_NtkRetimeMinAreaConstructNtk( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMin
Abc_ObjAddFanin( Abc_NtkCreatePo(pNtkNew), pObjNew );
}
// unmark the nodes in the cut
- Vec_PtrForEachEntry( vMinCut, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMinCut, pObj, i )
Abc_NodeSetTravIdPrevious( pObj );
// unmark the latches
Abc_NtkForEachLatch( pNtk, pObj, i )
@@ -418,13 +421,13 @@ void Abc_NtkRetimeMinAreaUpdateLatches( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, i
vBoxes = pNtk->vBoxes; pNtk->vBoxes = NULL;
// transfer boxes
vBoxesNew = Vec_PtrAlloc(100);
- Vec_PtrForEachEntry( vBoxes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vBoxes, pObj, i )
if ( !Abc_ObjIsLatch(pObj) )
Vec_PtrPush( vBoxesNew, pObj );
// create or reuse latches
vNodes = Vec_PtrAlloc( 100 );
vBuffers = Vec_PtrAlloc( 100 );
- Vec_PtrForEachEntry( vMinCut, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMinCut, pObj, i )
{
if ( Abc_ObjIsCi(pObj) && fForward )
{
@@ -448,7 +451,7 @@ void Abc_NtkRetimeMinAreaUpdateLatches( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, i
Vec_PtrPush( vBuffers, pBuffer );
// redirect edges to the unvisited fanouts of the node
Abc_NodeCollectFanouts( pObj, vNodes );
- Vec_PtrForEachEntry( vNodes, pNext, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNext, k )
if ( pNext->fMarkA )
Abc_ObjPatchFanin( pNext, pObj, pBuffer );
}
@@ -481,7 +484,7 @@ void Abc_NtkRetimeMinAreaUpdateLatches( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, i
pLatch->pData = (void *)(ABC_PTRUINT_T)(pObj->pCopy? ABC_INIT_ONE : ABC_INIT_ZERO);
// redirect edges to the unvisited fanouts of the node
Abc_NodeCollectFanouts( pObj, vNodes );
- Vec_PtrForEachEntry( vNodes, pNext, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNext, k )
if ( !pNext->fMarkA )
Abc_ObjPatchFanin( pNext, pObj, pLatchOut );
}
@@ -489,7 +492,7 @@ void Abc_NtkRetimeMinAreaUpdateLatches( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, i
{
// redirect edges to the visited fanouts of the node
Abc_NodeCollectFanouts( pObj, vNodes );
- Vec_PtrForEachEntry( vNodes, pNext, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNext, k )
if ( pNext->fMarkA )
Abc_ObjPatchFanin( pNext, pObj, pLatchOut );
}
@@ -502,14 +505,14 @@ void Abc_NtkRetimeMinAreaUpdateLatches( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, i
}
Vec_PtrFree( vNodes );
// remove buffers
- Vec_PtrForEachEntry( vBuffers, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vBuffers, pObj, i )
{
Abc_ObjTransferFanout( pObj, Abc_ObjFanin0(pObj) );
Abc_NtkDeleteObj( pObj );
}
Vec_PtrFree( vBuffers );
// remove useless latches
- Vec_PtrForEachEntry( vBoxes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vBoxes, pObj, i )
{
if ( !Abc_ObjIsLatch(pObj) )
continue;
@@ -537,3 +540,5 @@ void Abc_NtkRetimeMinAreaUpdateLatches( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, i
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/ret/retCore.c b/src/opt/ret/retCore.c
index 9de1b723..1b574001 100644
--- a/src/opt/ret/retCore.c
+++ b/src/opt/ret/retCore.c
@@ -20,6 +20,9 @@
#include "retInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -41,7 +44,7 @@ int timeRetime = 0;
SeeAlso []
***********************************************************************/
-int Abc_NtkRetime( Abc_Ntk_t * pNtk, int Mode, int fForwardOnly, int fBackwardOnly, int fOneStep, int fVerbose )
+int Abc_NtkRetime( Abc_Ntk_t * pNtk, int Mode, int nDelayLim, int fForwardOnly, int fBackwardOnly, int fOneStep, int fVerbose )
{
int nLatches = Abc_NtkLatchNum(pNtk);
int nLevels = Abc_NtkLevel(pNtk);
@@ -62,26 +65,26 @@ int Abc_NtkRetime( Abc_Ntk_t * pNtk, int Mode, int fForwardOnly, int fBackwardOn
switch ( Mode )
{
case 1: // forward
- RetValue = Abc_NtkRetimeIncremental( pNtk, 1, 0, 0, fVerbose );
+ RetValue = Abc_NtkRetimeIncremental( pNtk, nDelayLim, 1, 0, 0, fVerbose );
break;
case 2: // backward
- RetValue = Abc_NtkRetimeIncremental( pNtk, 0, 0, 0, fVerbose );
+ RetValue = Abc_NtkRetimeIncremental( pNtk, nDelayLim, 0, 0, 0, fVerbose );
break;
case 3: // min-area
RetValue = Abc_NtkRetimeMinArea( pNtk, fForwardOnly, fBackwardOnly, fVerbose );
break;
case 4: // min-delay
if ( !fBackwardOnly )
- RetValue += Abc_NtkRetimeIncremental( pNtk, 1, 1, fOneStep, fVerbose );
+ RetValue += Abc_NtkRetimeIncremental( pNtk, nDelayLim, 1, 1, fOneStep, fVerbose );
if ( !fForwardOnly )
- RetValue += Abc_NtkRetimeIncremental( pNtk, 0, 1, fOneStep, fVerbose );
+ RetValue += Abc_NtkRetimeIncremental( pNtk, nDelayLim, 0, 1, fOneStep, fVerbose );
break;
case 5: // min-area + min-delay
RetValue = Abc_NtkRetimeMinArea( pNtk, fForwardOnly, fBackwardOnly, fVerbose );
if ( !fBackwardOnly )
- RetValue += Abc_NtkRetimeIncremental( pNtk, 1, 1, 0, fVerbose );
+ RetValue += Abc_NtkRetimeIncremental( pNtk, nDelayLim, 1, 1, 0, fVerbose );
if ( !fForwardOnly )
- RetValue += Abc_NtkRetimeIncremental( pNtk, 0, 1, 0, fVerbose );
+ RetValue += Abc_NtkRetimeIncremental( pNtk, nDelayLim, 0, 1, 0, fVerbose );
break;
case 6: // Pan's algorithm
RetValue = Abc_NtkRetimeLValue( pNtk, 500, fVerbose );
@@ -121,7 +124,7 @@ int Abc_NtkRetimeDebug( Abc_Ntk_t * pNtk )
// fprintf( stdout, "Abc_NtkRetimeDebug(): Network check has failed.\n" );
// Io_WriteBlifLogic( pNtk, "debug_temp.blif", 1 );
pNtkRet = Abc_NtkDup( pNtk );
- Abc_NtkRetime( pNtkRet, 3, 0, 1, 0, 0 ); // debugging backward flow
+ Abc_NtkRetime( pNtkRet, 3, 0, 0, 1, 0, 0 ); // debugging backward flow
return !Abc_NtkSecFraig( pNtk, pNtkRet, 10000, 3, 0 );
}
@@ -130,3 +133,5 @@ int Abc_NtkRetimeDebug( Abc_Ntk_t * pNtk )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/ret/retDelay.c b/src/opt/ret/retDelay.c
index 0f3c3daa..0263c92f 100644
--- a/src/opt/ret/retDelay.c
+++ b/src/opt/ret/retDelay.c
@@ -20,11 +20,14 @@
#include "retInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
-static int Abc_NtkRetimeMinDelayTry( Abc_Ntk_t * pNtk, int fForward, int fInitial, int nIterLimit, int * pIterBest, int fVerbose );
+static int Abc_NtkRetimeMinDelayTry( Abc_Ntk_t * pNtk, int nDelayLim, int fForward, int fInitial, int nIterLimit, int * pIterBest, int fVerbose );
static int Abc_NtkRetimeTiming( Abc_Ntk_t * pNtk, int fForward, Vec_Ptr_t * vCritical );
static int Abc_NtkRetimeTiming_rec( Abc_Obj_t * pObj, int fForward );
@@ -44,16 +47,16 @@ static int Abc_NtkRetimeTiming_rec( Abc_Obj_t * pObj, int fForward );
SeeAlso []
***********************************************************************/
-int Abc_NtkRetimeMinDelay( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkCopy, int nIterLimit, int fForward, int fVerbose )
+int Abc_NtkRetimeMinDelay( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkCopy, int nDelayLim, int nIterLimit, int fForward, int fVerbose )
{
int IterBest, DelayBest;
int IterBest2, DelayBest2;
// try to find the best delay iteration on a copy
- DelayBest = Abc_NtkRetimeMinDelayTry( pNtkCopy, fForward, 0, nIterLimit, &IterBest, fVerbose );
+ DelayBest = Abc_NtkRetimeMinDelayTry( pNtkCopy, nDelayLim, fForward, 0, nIterLimit, &IterBest, fVerbose );
if ( IterBest == 0 )
return 1;
// perform the given number of iterations on the original network
- DelayBest2 = Abc_NtkRetimeMinDelayTry( pNtk, fForward, 1, IterBest, &IterBest2, fVerbose );
+ DelayBest2 = Abc_NtkRetimeMinDelayTry( pNtk, nDelayLim, fForward, 1, IterBest, &IterBest2, fVerbose );
assert( DelayBest == DelayBest2 );
assert( IterBest == IterBest2 );
return 1;
@@ -70,7 +73,7 @@ int Abc_NtkRetimeMinDelay( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkCopy, int nIterLimi
SeeAlso []
***********************************************************************/
-int Abc_NtkRetimeMinDelayTry( Abc_Ntk_t * pNtk, int fForward, int fInitial, int nIterLimit, int * pIterBest, int fVerbose )
+int Abc_NtkRetimeMinDelayTry( Abc_Ntk_t * pNtk, int nDelayLim, int fForward, int fInitial, int nIterLimit, int * pIterBest, int fVerbose )
{
Abc_Ntk_t * pNtkNew = NULL;
Vec_Ptr_t * vCritical;
@@ -123,8 +126,11 @@ if ( fVerbose && !fInitial )
// skip if 10 interations did not give improvement
if ( i - IterBest > 20 )
break;
+ // skip if delay limit is reached
+ if ( nDelayLim > 0 && DelayCur <= nDelayLim )
+ break;
// try retiming to improve the delay
- Vec_PtrForEachEntry( vCritical, pObj, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vCritical, pObj, k )
if ( Abc_NtkRetimeNodeIsEnabled(pObj, fForward) )
Abc_NtkRetimeNode( pObj, fForward, fInitial );
// share latches
@@ -183,7 +189,7 @@ int Abc_NtkRetimeTiming( Abc_Ntk_t * pNtk, int fForward, Vec_Ptr_t * vCritical )
// perform analysis from CIs/COs
if ( fForward )
{
- Vec_PtrForEachEntry( vLatches, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLatches, pObj, i )
{
Abc_ObjForEachFanout( pObj, pNext, k )
{
@@ -204,7 +210,7 @@ int Abc_NtkRetimeTiming( Abc_Ntk_t * pNtk, int fForward, Vec_Ptr_t * vCritical )
}
else
{
- Vec_PtrForEachEntry( vLatches, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLatches, pObj, i )
{
LevelCur = Abc_NtkRetimeTiming_rec( Abc_ObjFanin0(pObj), fForward );
if ( LevelMax < LevelCur )
@@ -222,7 +228,7 @@ int Abc_NtkRetimeTiming( Abc_Ntk_t * pNtk, int fForward, Vec_Ptr_t * vCritical )
Abc_NtkIncrementTravId(pNtk);
if ( fForward )
{
- Vec_PtrForEachEntry( vLatches, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLatches, pObj, i )
{
Abc_ObjForEachFanout( pObj, pNext, k )
{
@@ -238,7 +244,7 @@ int Abc_NtkRetimeTiming( Abc_Ntk_t * pNtk, int fForward, Vec_Ptr_t * vCritical )
}
else
{
- Vec_PtrForEachEntry( vLatches, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLatches, pObj, i )
{
Abc_ObjForEachFanin( pObj, pNext, k )
{
@@ -305,3 +311,5 @@ int Abc_NtkRetimeTiming_rec( Abc_Obj_t * pObj, int fForward )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/ret/retFlow.c b/src/opt/ret/retFlow.c
index 7c17c1f6..f684939c 100644
--- a/src/opt/ret/retFlow.c
+++ b/src/opt/ret/retFlow.c
@@ -20,6 +20,9 @@
#include "retInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -261,7 +264,7 @@ int Abc_NtkMaxFlowBwdPath_rec( Abc_Obj_t * pObj )
{
// start the path if we reached a terminal node
if ( pObj->fMarkA )
- return Abc_ObjSetPath( pObj, (void *)1 );
+ return Abc_ObjSetPath( pObj, (Abc_Obj_t *)1 );
// explore the fanins
Abc_ObjForEachFanin( pObj, pNext, i )
if ( pNext != pPred && !Abc_ObjIsLatch(pNext) && Abc_NtkMaxFlowBwdPath_rec(pNext) )
@@ -313,7 +316,7 @@ int Abc_NtkMaxFlowFwdPath_rec( Abc_Obj_t * pObj )
{
// start the path if we reached a terminal node
if ( pObj->fMarkA )
- return Abc_ObjSetPath( pObj, (void *)1 );
+ return Abc_ObjSetPath( pObj, (Abc_Obj_t *)1 );
// explore the fanins
Abc_ObjForEachFanout( pObj, pNext, i )
if ( pNext != pPred && !Abc_ObjIsLatch(pNext) && Abc_NtkMaxFlowFwdPath_rec(pNext) )
@@ -367,7 +370,7 @@ int Abc_NtkMaxFlowFwdPath3_rec( Abc_Obj_t * pObj, Abc_Obj_t * pPrev, int fFanin
{
// start the path if we reached a terminal node
if ( pObj->fMarkA )
- return Abc_ObjSetPath( pObj, (void *)1 );
+ return Abc_ObjSetPath( pObj, (Abc_Obj_t *)1 );
// try to push flow through the fanouts
Abc_ObjForEachFanout( pObj, pFanout, i )
if ( Abc_NtkMaxFlowFwdPath3_rec(pFanout, pObj, 1) )
@@ -404,7 +407,7 @@ int Abc_NtkMaxFlowBwdPath2_rec( Abc_Obj_t * pObj )
{
// start the path if we reached a terminal node
if ( pObj->fMarkA )
- return Abc_ObjSetPath( pObj, (void *)1 );
+ return Abc_ObjSetPath( pObj, (Abc_Obj_t *)1 );
// explore the fanins
Abc_ObjForEachFanin( pObj, pFanin, i )
if ( Abc_NtkMaxFlowBwdPath2_rec(pFanin) )
@@ -449,7 +452,7 @@ int Abc_NtkMaxFlowFwdPath2_rec( Abc_Obj_t * pObj )
{
// start the path if we reached a terminal node
if ( pObj->fMarkA )
- return Abc_ObjSetPath( pObj, (void *)1 );
+ return Abc_ObjSetPath( pObj, (Abc_Obj_t *)1 );
// explore the fanins
Abc_ObjForEachFanout( pObj, pFanout, i )
if ( Abc_NtkMaxFlowFwdPath2_rec(pFanout) )
@@ -575,7 +578,7 @@ void Abc_NtkMaxFlowMinCutUpdate( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, int fFor
Abc_NtkForEachLatch( pNtk, pObj, i )
Abc_ObjFanout0(pObj)->fMarkA = 1;
// traverse from cut nodes
- Vec_PtrForEachEntry( vMinCut, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMinCut, pObj, i )
Abc_NtkMaxFlowMarkCut_rec( pObj );
if ( fForward )
{
@@ -605,7 +608,7 @@ void Abc_NtkMaxFlowMinCutUpdate( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, int fFor
Abc_NtkForEachObj( pNtk, pObj, i )
pObj->fMarkA = Abc_NodeIsTravIdCurrent(pObj);
// unmark the cut nodes
- Vec_PtrForEachEntry( vMinCut, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMinCut, pObj, i )
pObj->fMarkA = 0;
}
}
@@ -668,7 +671,7 @@ int Abc_NtkMaxFlowVerifyCut( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut, int fForward
int i;
// mark the cut with the current traversal ID
Abc_NtkIncrementTravId(pNtk);
- Vec_PtrForEachEntry( vMinCut, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMinCut, pObj, i )
Abc_NodeSetTravIdCurrent( pObj );
// search from the latches for a path to the COs/CIs
Abc_NtkForEachLatch( pNtk, pObj, i )
@@ -714,7 +717,7 @@ void Abc_NtkMaxFlowPrintFlow( Abc_Ntk_t * pNtk, int fForward )
int i;
if ( fForward )
{
- Vec_PtrForEachEntry( pNtk->vBoxes, pLatch, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, pNtk->vBoxes, pLatch, i )
{
assert( !Abc_ObjFanout0(pLatch)->fMarkA );
if ( Abc_ObjGetPath(Abc_ObjFanout0(pLatch)) == NULL ) // no flow through this latch
@@ -732,7 +735,7 @@ void Abc_NtkMaxFlowPrintFlow( Abc_Ntk_t * pNtk, int fForward )
}
else
{
- Vec_PtrForEachEntry( pNtk->vBoxes, pLatch, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, pNtk->vBoxes, pLatch, i )
{
assert( !Abc_ObjFanin0(pLatch)->fMarkA );
if ( Abc_ObjGetPath(Abc_ObjFanin0(pLatch)) == NULL ) // no flow through this latch
@@ -766,7 +769,7 @@ void Abc_NtkMaxFlowPrintCut( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut )
Abc_Obj_t * pObj;
int i;
printf( "Min-cut: " );
- Vec_PtrForEachEntry( vMinCut, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vMinCut, pObj, i )
printf( "%s(%d) ", Abc_ObjName(pObj), pObj->Id );
printf( "\n" );
printf( "Marked nodes: " );
@@ -782,3 +785,5 @@ void Abc_NtkMaxFlowPrintCut( Abc_Ntk_t * pNtk, Vec_Ptr_t * vMinCut )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/ret/retIncrem.c b/src/opt/ret/retIncrem.c
index 1866e4c9..80b26914 100644
--- a/src/opt/ret/retIncrem.c
+++ b/src/opt/ret/retIncrem.c
@@ -20,6 +20,9 @@
#include "retInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -41,7 +44,7 @@ static int Abc_NtkRetimeOneWay( Abc_Ntk_t * pNtk, int fForward, int fVerbose );
SeeAlso []
***********************************************************************/
-int Abc_NtkRetimeIncremental( Abc_Ntk_t * pNtk, int fForward, int fMinDelay, int fOneStep, int fVerbose )
+int Abc_NtkRetimeIncremental( Abc_Ntk_t * pNtk, int nDelayLim, int fForward, int fMinDelay, int fOneStep, int fVerbose )
{
Abc_Ntk_t * pNtkCopy = NULL;
Vec_Ptr_t * vBoxes;
@@ -69,7 +72,7 @@ int Abc_NtkRetimeIncremental( Abc_Ntk_t * pNtk, int fForward, int fMinDelay, int
vBoxes = pNtk->vBoxes; pNtk->vBoxes = NULL;
// perform the retiming
if ( fMinDelay )
- Abc_NtkRetimeMinDelay( pNtk, pNtkCopy, nIterLimit, fForward, fVerbose );
+ Abc_NtkRetimeMinDelay( pNtk, pNtkCopy, nDelayLim, nIterLimit, fForward, fVerbose );
else
Abc_NtkRetimeOneWay( pNtk, fForward, fVerbose );
if ( fMinDelay )
@@ -113,7 +116,7 @@ st_table * Abc_NtkRetimePrepareLatches( Abc_Ntk_t * pNtk )
Abc_NtkForEachLatch( pNtk, pLatch, i )
{
// map latch into its true number
- st_insert( tLatches, (void *)(ABC_PTRUINT_T)pLatch, (void *)(ABC_PTRUINT_T)(i-nOffSet) );
+ st_insert( tLatches, (char *)(ABC_PTRUINT_T)pLatch, (char *)(ABC_PTRUINT_T)(i-nOffSet) );
// disconnect LI
pLatchIn = Abc_ObjFanin0(pLatch);
pFanin = Abc_ObjFanin0(pLatchIn);
@@ -150,11 +153,11 @@ int Abc_NtkRetimeFinalizeLatches( Abc_Ntk_t * pNtk, st_table * tLatches, int nId
vCosOld = pNtk->vCos; pNtk->vCos = NULL; vCosNew = Vec_PtrAlloc( 100 );
vBoxesOld = pNtk->vBoxes; pNtk->vBoxes = NULL; vBoxesNew = Vec_PtrAlloc( 100 );
// copy boxes and their CIs/COs
- Vec_PtrForEachEntryStop( vCisOld, pObj, i, Vec_PtrSize(vCisOld) - st_count(tLatches) )
+ Vec_PtrForEachEntryStop( Abc_Obj_t *, vCisOld, pObj, i, Vec_PtrSize(vCisOld) - st_count(tLatches) )
Vec_PtrPush( vCisNew, pObj );
- Vec_PtrForEachEntryStop( vCosOld, pObj, i, Vec_PtrSize(vCosOld) - st_count(tLatches) )
+ Vec_PtrForEachEntryStop( Abc_Obj_t *, vCosOld, pObj, i, Vec_PtrSize(vCosOld) - st_count(tLatches) )
Vec_PtrPush( vCosNew, pObj );
- Vec_PtrForEachEntryStop( vBoxesOld, pObj, i, Vec_PtrSize(vBoxesOld) - st_count(tLatches) )
+ Vec_PtrForEachEntryStop( Abc_Obj_t *, vBoxesOld, pObj, i, Vec_PtrSize(vBoxesOld) - st_count(tLatches) )
Vec_PtrPush( vBoxesNew, pObj );
// go through the latches
Abc_NtkForEachObj( pNtk, pLatch, i )
@@ -180,8 +183,8 @@ int Abc_NtkRetimeFinalizeLatches( Abc_Ntk_t * pNtk, st_table * tLatches, int nId
}
assert( pLatch == Vec_PtrEntry(vBoxesOld, Vec_PtrSize(vBoxesOld) - st_count(tLatches) + Index) );
// reconnect with the old LIs/LOs
- pLatchIn = Vec_PtrEntry( vCosOld, Vec_PtrSize(vCosOld) - st_count(tLatches) + Index );
- pLatchOut = Vec_PtrEntry( vCisOld, Vec_PtrSize(vCisOld) - st_count(tLatches) + Index );
+ pLatchIn = (Abc_Obj_t *)Vec_PtrEntry( vCosOld, Vec_PtrSize(vCosOld) - st_count(tLatches) + Index );
+ pLatchOut = (Abc_Obj_t *)Vec_PtrEntry( vCisOld, Vec_PtrSize(vCisOld) - st_count(tLatches) + Index );
}
// connect
Abc_ObjAddFanin( pLatchIn, Abc_ObjFanin0(pLatch) );
@@ -195,10 +198,10 @@ int Abc_NtkRetimeFinalizeLatches( Abc_Ntk_t * pNtk, st_table * tLatches, int nId
Vec_PtrPush( vBoxesNew, pLatch );
}
// free useless Cis/Cos
- Vec_PtrForEachEntry( vCisOld, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vCisOld, pObj, i )
if ( !Abc_ObjIsPi(pObj) && Abc_ObjFaninNum(pObj) == 0 && Abc_ObjFanoutNum(pObj) == 0 )
Abc_NtkDeleteObj(pObj);
- Vec_PtrForEachEntry( vCosOld, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vCosOld, pObj, i )
if ( !Abc_ObjIsPo(pObj) && Abc_ObjFaninNum(pObj) == 0 && Abc_ObjFanoutNum(pObj) == 0 )
Abc_NtkDeleteObj(pObj);
// set the new arrays
@@ -316,15 +319,15 @@ void Abc_NtkRetimeNode( Abc_Obj_t * pObj, int fForward, int fInitial )
Abc_Obj_t * pNext, * pLatch;
int i;
vNodes = Vec_PtrAlloc( 10 );
- if ( fForward )
+ if ( fForward )
{
// compute the initial value
if ( fInitial )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_ObjSopSimulate( pObj );
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Abc_ObjSopSimulate( pObj );
// collect fanins
Abc_NodeCollectFanins( pObj, vNodes );
// make the node point to the fanins fanins
- Vec_PtrForEachEntry( vNodes, pNext, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNext, i )
{
assert( Abc_ObjIsLatch(pNext) );
Abc_ObjPatchFanin( pObj, pNext, Abc_ObjFanin0(pNext) );
@@ -356,7 +359,7 @@ void Abc_NtkRetimeNode( Abc_Obj_t * pObj, int fForward, int fInitial )
// collect fanouts
Abc_NodeCollectFanouts( pObj, vNodes );
// make the fanouts fanouts point to the node
- Vec_PtrForEachEntry( vNodes, pNext, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNext, i )
{
assert( Abc_ObjIsLatch(pNext) );
Abc_ObjTransferFanout( pNext, pObj );
@@ -439,7 +442,7 @@ void Abc_NtkRetimeShareLatches( Abc_Ntk_t * pNtk, int fInitial )
assert( pLatchTop && Abc_ObjIsLatch(pLatchTop) );
// redirect compatible fanout latches to the first latch
Abc_NodeCollectFanouts( pFanin, vNodes );
- Vec_PtrForEachEntry( vNodes, pLatchCur, k )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pLatchCur, k )
{
if ( !Abc_ObjIsLatch(pLatchCur) )
continue;
@@ -463,3 +466,5 @@ void Abc_NtkRetimeShareLatches( Abc_Ntk_t * pNtk, int fInitial )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/ret/retInit.c b/src/opt/ret/retInit.c
index 72b384d9..44331e72 100644
--- a/src/opt/ret/retInit.c
+++ b/src/opt/ret/retInit.c
@@ -20,6 +20,9 @@
#include "retInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -88,7 +91,7 @@ Vec_Int_t * Abc_NtkRetimeInitialValues( Abc_Ntk_t * pNtkCone, Vec_Int_t * vValue
***********************************************************************/
int Abc_ObjSopSimulate( Abc_Obj_t * pObj )
{
- char * pCube, * pSop = pObj->pData;
+ char * pCube, * pSop = (char *)pObj->pData;
int nVars, Value, v, ResOr, ResAnd, ResVar;
assert( pSop && !Abc_SopIsExorType(pSop) );
// simulate the SOP of the node
@@ -134,11 +137,11 @@ int Abc_NtkRetimeVerifyModel( Abc_Ntk_t * pNtkCone, Vec_Int_t * vValues, int * p
assert( Abc_NtkIsSopLogic(pNtkCone) );
// set the PIs
Abc_NtkForEachPi( pNtkCone, pObj, i )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)pModel[i];
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)pModel[i];
// simulate the internal nodes
vNodes = Abc_NtkDfs( pNtkCone, 0 );
- Vec_PtrForEachEntry( vNodes, pObj, i )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_ObjSopSimulate( pObj );
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Abc_ObjSopSimulate( pObj );
Vec_PtrFree( vNodes );
// compare the outputs
Abc_NtkForEachPo( pNtkCone, pObj, i )
@@ -167,7 +170,7 @@ void Abc_NtkRetimeTranferToCopy( Abc_Ntk_t * pNtk )
int i;
Abc_NtkForEachObj( pNtk, pObj, i )
if ( Abc_ObjIsLatch(pObj) )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_LatchIsInit1(pObj);
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Abc_LatchIsInit1(pObj);
}
/**Function*************************************************************
@@ -230,10 +233,10 @@ void Abc_NtkRetimeInsertLatchValues( Abc_Ntk_t * pNtk, Vec_Int_t * vValues )
int i, Counter = 0;
Abc_NtkForEachObj( pNtk, pObj, i )
if ( Abc_ObjIsLatch(pObj) )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)Counter++;
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Counter++;
Abc_NtkForEachObj( pNtk, pObj, i )
if ( Abc_ObjIsLatch(pObj) )
- pObj->pData = (void *)(ABC_PTRUINT_T)(vValues? (Vec_IntEntry(vValues,(int)(ABC_PTRUINT_T)pObj->pCopy)? ABC_INIT_ONE : ABC_INIT_ZERO) : ABC_INIT_DC);
+ pObj->pData = (Abc_Obj_t *)(ABC_PTRUINT_T)(vValues? (Vec_IntEntry(vValues,(int)(ABC_PTRUINT_T)pObj->pCopy)? ABC_INIT_ONE : ABC_INIT_ZERO) : ABC_INIT_DC);
}
/**Function*************************************************************
@@ -316,22 +319,22 @@ void Abc_NtkCycleInitStateSop( Abc_Ntk_t * pNtk, int nFrames, int fVerbose )
srand( 0x12341234 );
// initialize the values
Abc_NtkForEachPi( pNtk, pObj, i )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)(rand() & 1);
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)(rand() & 1);
Abc_NtkForEachLatch( pNtk, pObj, i )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_LatchIsInit1(pObj);
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Abc_LatchIsInit1(pObj);
// simulate for the given number of timeframes
vNodes = Abc_NtkDfs( pNtk, 0 );
for ( f = 0; f < nFrames; f++ )
{
// simulate internal nodes
- Vec_PtrForEachEntry( vNodes, pObj, i )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)Abc_ObjSopSimulate( pObj );
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Abc_ObjSopSimulate( pObj );
// bring the results to the COs
Abc_NtkForEachCo( pNtk, pObj, i )
pObj->pCopy = Abc_ObjFanin0(pObj)->pCopy;
// assign PI values
Abc_NtkForEachPi( pNtk, pObj, i )
- pObj->pCopy = (void *)(ABC_PTRUINT_T)(rand() & 1);
+ pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)(rand() & 1);
// transfer the latch values
Abc_NtkForEachLatch( pNtk, pObj, i )
Abc_ObjFanout0(pObj)->pCopy = Abc_ObjFanin0(pObj)->pCopy;
@@ -347,3 +350,5 @@ void Abc_NtkCycleInitStateSop( Abc_Ntk_t * pNtk, int nFrames, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/ret/retInt.h b/src/opt/ret/retInt.h
index 51428bce..39a6296e 100644
--- a/src/opt/ret/retInt.h
+++ b/src/opt/ret/retInt.h
@@ -21,12 +21,16 @@
#ifndef __RET_INT_H__
#define __RET_INT_H__
+
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
#include "abc.h"
+ABC_NAMESPACE_HEADER_START
+
+
////////////////////////////////////////////////////////////////////////
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
@@ -46,11 +50,11 @@
/*=== retArea.c ========================================================*/
extern int Abc_NtkRetimeMinArea( Abc_Ntk_t * pNtk, int fForwardOnly, int fBackwardOnly, int fVerbose );
/*=== retCore.c ========================================================*/
-extern int Abc_NtkRetime( Abc_Ntk_t * pNtk, int Mode, int fForwardOnly, int fBackwardOnly, int fOneStep, int fVerbose );
+extern int Abc_NtkRetime( Abc_Ntk_t * pNtk, int Mode, int nDelayLim, int fForwardOnly, int fBackwardOnly, int fOneStep, int fVerbose );
/*=== retDelay.c ========================================================*/
-extern int Abc_NtkRetimeMinDelay( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkCopy, int nIterLimit, int fForward, int fVerbose );
+extern int Abc_NtkRetimeMinDelay( Abc_Ntk_t * pNtk, Abc_Ntk_t * pNtkCopy, int nDelayLim, int nIterLimit, int fForward, int fVerbose );
/*=== retDirect.c ========================================================*/
-extern int Abc_NtkRetimeIncremental( Abc_Ntk_t * pNtk, int fForward, int fMinDelay, int fOneStep, int fVerbose );
+extern int Abc_NtkRetimeIncremental( Abc_Ntk_t * pNtk, int nDelayLim, int fForward, int fMinDelay, int fOneStep, int fVerbose );
extern void Abc_NtkRetimeShareLatches( Abc_Ntk_t * pNtk, int fInitial );
extern int Abc_NtkRetimeNodeIsEnabled( Abc_Obj_t * pObj, int fForward );
extern void Abc_NtkRetimeNode( Abc_Obj_t * pObj, int fForward, int fInitial );
@@ -71,6 +75,10 @@ extern void Abc_NtkRetimeBackwardInitialFinish( Abc_Ntk_t * pNtk, Abc_Ntk
/*=== retLvalue.c ========================================================*/
extern int Abc_NtkRetimeLValue( Abc_Ntk_t * pNtk, int nIterLimit, int fVerbose );
+
+
+ABC_NAMESPACE_HEADER_END
+
#endif
////////////////////////////////////////////////////////////////////////
diff --git a/src/opt/ret/retLvalue.c b/src/opt/ret/retLvalue.c
index 02d9cac2..7d32dd7d 100644
--- a/src/opt/ret/retLvalue.c
+++ b/src/opt/ret/retLvalue.c
@@ -20,6 +20,9 @@
#include "retInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -38,7 +41,7 @@ static int Abc_NtkRetimeUsingLags( Abc_Ntk_t * pNtk, Vec_Int_t * vLags,
static inline int Abc_NodeComputeLag( int LValue, int Fi ) { return (LValue + (1<<16)*Fi)/Fi - (1<<16) - (int)(LValue % Fi == 0); }
static inline int Abc_NodeGetLValue( Abc_Obj_t * pNode ) { return (int)(ABC_PTRUINT_T)pNode->pCopy; }
-static inline void Abc_NodeSetLValue( Abc_Obj_t * pNode, int Value ) { pNode->pCopy = (void *)(ABC_PTRUINT_T)Value; }
+static inline void Abc_NodeSetLValue( Abc_Obj_t * pNode, int Value ) { pNode->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Value; }
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
@@ -247,7 +250,7 @@ int Abc_NtkRetimeUpdateLValue( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t *
int i, k, lValueNew, fChange;
// go through the nodes and detect change
fChange = 0;
- Vec_PtrForEachEntry( vNodes, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
{
assert( Abc_ObjIsNode(pObj) );
lValueNew = -ABC_INFINITY;
@@ -264,7 +267,7 @@ int Abc_NtkRetimeUpdateLValue( Abc_Ntk_t * pNtk, Vec_Ptr_t * vNodes, Vec_Ptr_t *
}
}
// propagate values through the latches
- Vec_PtrForEachEntry( vLatches, pObj, i )
+ Vec_PtrForEachEntry( Abc_Obj_t *, vLatches, pObj, i )
Abc_NodeSetLValue( Abc_ObjFanout0(pObj), Abc_NodeGetLValue(Abc_ObjFanin0(Abc_ObjFanin0(pObj))) - Fi );
return fChange;
}
@@ -393,3 +396,5 @@ int Abc_NtkRetimeUsingLags( Abc_Ntk_t * pNtk, Vec_Int_t * vLags, int fVerbose )
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+
diff --git a/src/opt/ret/ret_.c b/src/opt/ret/ret_.c
index 89625e17..1ee46e4a 100644
--- a/src/opt/ret/ret_.c
+++ b/src/opt/ret/ret_.c
@@ -20,6 +20,9 @@
#include "retInt.h"
+ABC_NAMESPACE_IMPL_START
+
+
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
@@ -46,3 +49,5 @@
////////////////////////////////////////////////////////////////////////
+ABC_NAMESPACE_IMPL_END
+