abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
nwkFlow.c File Reference
#include "nwk.h"

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START
Nwk_Obj_t
Nwk_ObjPred (Nwk_Obj_t *pObj)
 DECLARATIONS ///. More...
 
static int Nwk_ObjSetPred (Nwk_Obj_t *pObj, Nwk_Obj_t *p)
 
static int Nwk_ObjIsSink (Nwk_Obj_t *pObj)
 
static void Nwk_ObjSetSink (Nwk_Obj_t *pObj)
 
static int Nwk_ObjHasFlow (Nwk_Obj_t *pObj)
 
static void Nwk_ObjSetFlow (Nwk_Obj_t *pObj)
 
static void Nwk_ObjClearFlow (Nwk_Obj_t *pObj)
 
static int Nwk_ObjVisitedBotOnly (Nwk_Obj_t *pObj)
 
static int Nwk_ObjVisitedBot (Nwk_Obj_t *pObj)
 
static int Nwk_ObjVisitedTop (Nwk_Obj_t *pObj)
 
static void Nwk_ObjSetVisitedBot (Nwk_Obj_t *pObj)
 
static void Nwk_ObjSetVisitedTop (Nwk_Obj_t *pObj)
 
static void Nwk_ManIncrementTravIdFlow (Nwk_Man_t *pMan)
 
static int Nwk_ManPushForwardTop_rec (Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
 
static int Nwk_ManPushForwardBot_rec (Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
 
static int Nwk_ManPushBackwardTop_rec (Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
 
static int Nwk_ManPushBackwardBot_rec (Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
 
void Nwk_ManMarkTfiCone_rec (Nwk_Obj_t *pObj)
 FUNCTION DEFINITIONS ///. More...
 
void Nwk_ManMarkTfoCone_rec (Nwk_Obj_t *pObj)
 
int Nwk_ManPushForwardFast_rec (Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
 
int Nwk_ManPushBackwardFast_rec (Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
 
int Nwk_ManVerifyCut_rec (Nwk_Obj_t *pObj)
 
int Nwk_ManRetimeVerifyCutForward (Nwk_Man_t *pMan, Vec_Ptr_t *vNodes)
 
int Nwk_ManRetimeVerifyCutBackward (Nwk_Man_t *pMan, Vec_Ptr_t *vNodes)
 
Vec_Ptr_tNwk_ManRetimeCutForward (Nwk_Man_t *pMan, int nLatches, int fVerbose)
 
Vec_Ptr_tNwk_ManRetimeCutBackward (Nwk_Man_t *pMan, int nLatches, int fVerbose)
 

Function Documentation

static void Nwk_ManIncrementTravIdFlow ( Nwk_Man_t pMan)
inlinestatic

Definition at line 84 of file nwkFlow.c.

85 {
86  Nwk_ManIncrementTravId( pMan );
87  Nwk_ManIncrementTravId( pMan );
88  Nwk_ManIncrementTravId( pMan );
89 }
ABC_DLL void Nwk_ManIncrementTravId(Nwk_Man_t *pNtk)
DECLARATIONS ///.
Definition: nwkUtil.c:47
void Nwk_ManMarkTfiCone_rec ( Nwk_Obj_t pObj)

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis [Marks TFI of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 112 of file nwkFlow.c.

113 {
114  Nwk_Obj_t * pNext;
115  int i;
116  if ( pObj->MarkA )
117  return;
118  pObj->MarkA = 1;
119  Nwk_ObjForEachFanin( pObj, pNext, i )
120  Nwk_ManMarkTfiCone_rec( pNext );
121 }
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
void Nwk_ManMarkTfiCone_rec(Nwk_Obj_t *pObj)
FUNCTION DEFINITIONS ///.
Definition: nwkFlow.c:112
#define Nwk_ObjForEachFanin(pObj, pFanin, i)
Definition: nwk.h:199
void Nwk_ManMarkTfoCone_rec ( Nwk_Obj_t pObj)

Function*************************************************************

Synopsis [Marks TFO of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 134 of file nwkFlow.c.

135 {
136  Nwk_Obj_t * pNext;
137  int i;
138  if ( pObj->MarkA )
139  return;
140  pObj->MarkA = 1;
141  Nwk_ObjForEachFanout( pObj, pNext, i )
142  Nwk_ManMarkTfoCone_rec( pNext );
143 }
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
#define Nwk_ObjForEachFanout(pObj, pFanout, i)
Definition: nwk.h:201
void Nwk_ManMarkTfoCone_rec(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:134
int Nwk_ManPushBackwardBot_rec ( Nwk_Obj_t pObj,
Nwk_Obj_t pPred 
)
static

Function*************************************************************

Synopsis [Pushing the flow through the bottom part of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 296 of file nwkFlow.c.

297 {
298  if ( Nwk_ObjVisitedBot(pObj) )
299  return 0;
300  Nwk_ObjSetVisitedBot(pObj);
301  // propagate through the internal edge
302  if ( Nwk_ObjHasFlow(pObj) )
303  {
304  if ( Nwk_ObjPred(pObj) )
305  if ( Nwk_ManPushBackwardTop_rec( Nwk_ObjPred(pObj), Nwk_ObjPred(pObj) ) )
306  return Nwk_ObjSetPred( pObj, pPred );
307  }
308  else if ( Nwk_ManPushBackwardTop_rec(pObj, pObj) )
309  {
310  Nwk_ObjSetFlow( pObj );
311  return Nwk_ObjSetPred( pObj, pPred );
312  }
313  return 0;
314 }
static ABC_NAMESPACE_IMPL_START Nwk_Obj_t * Nwk_ObjPred(Nwk_Obj_t *pObj)
DECLARATIONS ///.
Definition: nwkFlow.c:39
static void Nwk_ObjSetVisitedBot(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:66
static void Nwk_ObjSetFlow(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:46
static int Nwk_ManPushBackwardTop_rec(Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
Definition: nwkFlow.c:327
static int Nwk_ObjVisitedBot(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:58
static int Nwk_ObjHasFlow(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:45
static int Nwk_ObjSetPred(Nwk_Obj_t *pObj, Nwk_Obj_t *p)
Definition: nwkFlow.c:40
int Nwk_ManPushBackwardFast_rec ( Nwk_Obj_t pObj,
Nwk_Obj_t pPred 
)

Function*************************************************************

Synopsis [Fast backward flow pushing.]

Description []

SideEffects []

SeeAlso []

Definition at line 190 of file nwkFlow.c.

191 {
192  Nwk_Obj_t * pNext;
193  int i;
194  if ( Nwk_ObjIsTravIdCurrent( pObj ) )
195  return 0;
196  Nwk_ObjSetTravIdCurrent( pObj );
197  if ( Nwk_ObjHasFlow(pObj) )
198  return 0;
199  if ( Nwk_ObjIsSink(pObj) )
200  {
201  Nwk_ObjSetFlow(pObj);
202  return Nwk_ObjSetPred( pObj, pPred );
203  }
204  Nwk_ObjForEachFanin( pObj, pNext, i )
205  if ( Nwk_ManPushBackwardFast_rec( pNext, pObj ) )
206  {
207  Nwk_ObjSetFlow(pObj);
208  return Nwk_ObjSetPred( pObj, pPred );
209  }
210  return 0;
211 }
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
int Nwk_ManPushBackwardFast_rec(Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
Definition: nwkFlow.c:190
static void Nwk_ObjSetFlow(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:46
static void Nwk_ObjSetTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:166
static int Nwk_ObjIsSink(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:42
static int Nwk_ObjIsTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:168
if(last==0)
Definition: sparse_int.h:34
static int Nwk_ObjHasFlow(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:45
#define Nwk_ObjForEachFanin(pObj, pFanin, i)
Definition: nwk.h:199
static int Nwk_ObjSetPred(Nwk_Obj_t *pObj, Nwk_Obj_t *p)
Definition: nwkFlow.c:40
int Nwk_ManPushBackwardTop_rec ( Nwk_Obj_t pObj,
Nwk_Obj_t pPred 
)
static

Function*************************************************************

Synopsis [Pushing the flow through the top part of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 327 of file nwkFlow.c.

328 {
329  Nwk_Obj_t * pNext;
330  int i;
331  if ( Nwk_ObjVisitedTop(pObj) )
332  return 0;
333  Nwk_ObjSetVisitedTop(pObj);
334  // check if this is the sink
335  if ( Nwk_ObjIsSink(pObj) )
336  return 1;
337  // try to push through the fanins
338  Nwk_ObjForEachFanin( pObj, pNext, i )
339  if ( Nwk_ManPushBackwardBot_rec( pNext, pPred ) )
340  return 1;
341  // try to push through the fanouts
342  Nwk_ObjForEachFanout( pObj, pNext, i )
343  if ( !Nwk_ObjIsCo(pObj) && Nwk_ManPushBackwardTop_rec( pNext, pPred ) )
344  return 1;
345  // redirect the flow
346  if ( Nwk_ObjHasFlow(pObj) )
347  if ( Nwk_ObjPred(pObj) && Nwk_ManPushBackwardBot_rec( pObj, Nwk_ObjPred(pObj) ) )
348  {
349  Nwk_ObjClearFlow( pObj );
350  return Nwk_ObjSetPred( pObj, NULL );
351  }
352  return 0;
353 }
static ABC_NAMESPACE_IMPL_START Nwk_Obj_t * Nwk_ObjPred(Nwk_Obj_t *pObj)
DECLARATIONS ///.
Definition: nwkFlow.c:39
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
static void Nwk_ObjClearFlow(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:47
#define Nwk_ObjForEachFanout(pObj, pFanout, i)
Definition: nwk.h:201
static int Nwk_ManPushBackwardTop_rec(Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
Definition: nwkFlow.c:327
static int Nwk_ObjIsSink(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:42
static int Nwk_ObjIsCo(Nwk_Obj_t *p)
Definition: nwk.h:147
static int Nwk_ObjVisitedTop(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:62
if(last==0)
Definition: sparse_int.h:34
static void Nwk_ObjSetVisitedTop(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:75
static int Nwk_ObjHasFlow(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:45
#define Nwk_ObjForEachFanin(pObj, pFanin, i)
Definition: nwk.h:199
static int Nwk_ManPushBackwardBot_rec(Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
Definition: nwkFlow.c:296
static int Nwk_ObjSetPred(Nwk_Obj_t *pObj, Nwk_Obj_t *p)
Definition: nwkFlow.c:40
int Nwk_ManPushForwardBot_rec ( Nwk_Obj_t pObj,
Nwk_Obj_t pPred 
)
static

Function*************************************************************

Synopsis [Pushing the flow through the bottom part of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 224 of file nwkFlow.c.

225 {
226  Nwk_Obj_t * pNext;
227  int i;
228  if ( Nwk_ObjVisitedBot(pObj) )
229  return 0;
230  Nwk_ObjSetVisitedBot(pObj);
231  // propagate through the internal edge
232  if ( Nwk_ObjHasFlow(pObj) )
233  {
234  if ( Nwk_ObjPred(pObj) )
235  if ( Nwk_ManPushForwardTop_rec( Nwk_ObjPred(pObj), Nwk_ObjPred(pObj) ) )
236  return Nwk_ObjSetPred( pObj, pPred );
237  }
238  else if ( Nwk_ManPushForwardTop_rec(pObj, pObj) )
239  {
240  Nwk_ObjSetFlow( pObj );
241  return Nwk_ObjSetPred( pObj, pPred );
242  }
243  // try to push through the fanins
244  Nwk_ObjForEachFanin( pObj, pNext, i )
245  if ( Nwk_ManPushForwardBot_rec( pNext, pPred ) )
246  return 1;
247  return 0;
248 }
static ABC_NAMESPACE_IMPL_START Nwk_Obj_t * Nwk_ObjPred(Nwk_Obj_t *pObj)
DECLARATIONS ///.
Definition: nwkFlow.c:39
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
static void Nwk_ObjSetVisitedBot(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:66
static void Nwk_ObjSetFlow(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:46
static int Nwk_ObjVisitedBot(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:58
static int Nwk_ManPushForwardTop_rec(Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
Definition: nwkFlow.c:261
if(last==0)
Definition: sparse_int.h:34
static int Nwk_ManPushForwardBot_rec(Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
Definition: nwkFlow.c:224
static int Nwk_ObjHasFlow(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:45
#define Nwk_ObjForEachFanin(pObj, pFanin, i)
Definition: nwk.h:199
static int Nwk_ObjSetPred(Nwk_Obj_t *pObj, Nwk_Obj_t *p)
Definition: nwkFlow.c:40
int Nwk_ManPushForwardFast_rec ( Nwk_Obj_t pObj,
Nwk_Obj_t pPred 
)

Function*************************************************************

Synopsis [Fast forward flow pushing.]

Description []

SideEffects []

SeeAlso []

Definition at line 156 of file nwkFlow.c.

157 {
158  Nwk_Obj_t * pNext;
159  int i;
160  if ( Nwk_ObjIsTravIdCurrent( pObj ) )
161  return 0;
162  Nwk_ObjSetTravIdCurrent( pObj );
163  if ( Nwk_ObjHasFlow(pObj) )
164  return 0;
165  if ( Nwk_ObjIsSink(pObj) )
166  {
167  Nwk_ObjSetFlow(pObj);
168  return Nwk_ObjSetPred( pObj, pPred );
169  }
170  Nwk_ObjForEachFanout( pObj, pNext, i )
171  if ( Nwk_ManPushForwardFast_rec( pNext, pObj ) )
172  {
173  Nwk_ObjSetFlow(pObj);
174  return Nwk_ObjSetPred( pObj, pPred );
175  }
176  return 0;
177 }
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
#define Nwk_ObjForEachFanout(pObj, pFanout, i)
Definition: nwk.h:201
static void Nwk_ObjSetFlow(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:46
int Nwk_ManPushForwardFast_rec(Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
Definition: nwkFlow.c:156
static void Nwk_ObjSetTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:166
static int Nwk_ObjIsSink(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:42
static int Nwk_ObjIsTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:168
if(last==0)
Definition: sparse_int.h:34
static int Nwk_ObjHasFlow(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:45
static int Nwk_ObjSetPred(Nwk_Obj_t *pObj, Nwk_Obj_t *p)
Definition: nwkFlow.c:40
int Nwk_ManPushForwardTop_rec ( Nwk_Obj_t pObj,
Nwk_Obj_t pPred 
)
static

Function*************************************************************

Synopsis [Pushing the flow through the top part of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 261 of file nwkFlow.c.

262 {
263  Nwk_Obj_t * pNext;
264  int i;
265  if ( Nwk_ObjVisitedTop(pObj) )
266  return 0;
267  Nwk_ObjSetVisitedTop(pObj);
268  // check if this is the sink
269  if ( Nwk_ObjIsSink(pObj) )
270  return 1;
271  // try to push through the fanouts
272  Nwk_ObjForEachFanout( pObj, pNext, i )
273  if ( Nwk_ManPushForwardBot_rec( pNext, pPred ) )
274  return 1;
275  // redirect the flow
276  if ( Nwk_ObjHasFlow(pObj) && !Nwk_ObjIsCi(pObj) )
277  if ( Nwk_ManPushForwardBot_rec( pObj, Nwk_ObjPred(pObj) ) )
278  {
279  Nwk_ObjClearFlow( pObj );
280  return Nwk_ObjSetPred( pObj, NULL );
281  }
282  return 0;
283 }
static int Nwk_ObjIsCi(Nwk_Obj_t *p)
Definition: nwk.h:146
static ABC_NAMESPACE_IMPL_START Nwk_Obj_t * Nwk_ObjPred(Nwk_Obj_t *pObj)
DECLARATIONS ///.
Definition: nwkFlow.c:39
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
static void Nwk_ObjClearFlow(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:47
#define Nwk_ObjForEachFanout(pObj, pFanout, i)
Definition: nwk.h:201
static int Nwk_ObjIsSink(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:42
static int Nwk_ObjVisitedTop(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:62
if(last==0)
Definition: sparse_int.h:34
static void Nwk_ObjSetVisitedTop(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:75
static int Nwk_ManPushForwardBot_rec(Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
Definition: nwkFlow.c:224
static int Nwk_ObjHasFlow(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:45
static int Nwk_ObjSetPred(Nwk_Obj_t *pObj, Nwk_Obj_t *p)
Definition: nwkFlow.c:40
Vec_Ptr_t* Nwk_ManRetimeCutBackward ( Nwk_Man_t pMan,
int  nLatches,
int  fVerbose 
)

Function*************************************************************

Synopsis [Computes minimum cut for backward retiming.]

Description []

SideEffects []

SeeAlso []

Definition at line 523 of file nwkFlow.c.

524 {
525  Vec_Ptr_t * vNodes;
526  Nwk_Obj_t * pObj;
527  int i, RetValue, Counter = 0, Counter2 = 0;
528  abctime clk = Abc_Clock();
529  // set the sequential parameters
530  pMan->nLatches = nLatches;
531  pMan->nTruePis = Nwk_ManCiNum(pMan) - nLatches;
532  pMan->nTruePos = Nwk_ManCoNum(pMan) - nLatches;
533  // mark the CIs, the TFI of POs, and the constant nodes
534  Nwk_ManForEachCi( pMan, pObj, i )
535  pObj->MarkA = 1;
536  Nwk_ManForEachPoSeq( pMan, pObj, i )
537  Nwk_ManMarkTfiCone_rec( pObj );
538  Nwk_ManForEachNode( pMan, pObj, i )
539  if ( Nwk_ObjFaninNum(pObj) == 0 )
540  pObj->MarkA = 1;
541  // start flow computation from each LI driver
543  Nwk_ManForEachLiSeq( pMan, pObj, i )
544  {
545  if ( !Nwk_ManPushBackwardFast_rec( Nwk_ObjFanin0(pObj), NULL ) )
546  continue;
548  Counter++;
549  }
550  if ( fVerbose )
551  printf( "Backward: Max-flow = %4d -> ", Counter );
552  // continue flow computation from each LI driver
554  Nwk_ManForEachLiSeq( pMan, pObj, i )
555  {
556  if ( !Nwk_ManPushBackwardBot_rec( Nwk_ObjFanin0(pObj), NULL ) )
557  continue;
559  Counter2++;
560  }
561  if ( fVerbose )
562  printf( "%4d. ", Counter+Counter2 );
563  // repeat flow computation from each LI driver
564  if ( Counter2 > 0 )
565  {
567  Nwk_ManForEachLiSeq( pMan, pObj, i )
568  {
569  RetValue = Nwk_ManPushBackwardBot_rec( Nwk_ObjFanin0(pObj), NULL );
570  assert( !RetValue );
571  }
572  }
573  // cut is a set of nodes whose bottom is visited but top is not visited
574  vNodes = Vec_PtrAlloc( Counter+Counter2 );
575  Nwk_ManForEachObj( pMan, pObj, i )
576  {
577  if ( Nwk_ObjVisitedBotOnly(pObj) )
578  {
579  assert( Nwk_ObjHasFlow(pObj) );
580  assert( !Nwk_ObjIsCo(pObj) );
581  Vec_PtrPush( vNodes, pObj );
582  }
583  }
584  // count CO drivers
585  Counter = 0;
586  Nwk_ManForEachLiSeq( pMan, pObj, i )
588  Counter++;
589  Nwk_ManCleanMarks( pMan );
590 // assert( Nwk_ManRetimeVerifyCutBackward(pMan, vNodes) );
591  if ( fVerbose )
592  {
593  printf( "Min-cut = %4d. Unmoved = %4d. ", Vec_PtrSize(vNodes), Counter );
594  ABC_PRT( "Time", Abc_Clock() - clk );
595  }
596  return vNodes;
597 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Nwk_ObjVisitedBotOnly(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:54
ABC_DLL void Nwk_ManCleanMarks(Nwk_Man_t *pNtk)
Definition: nwkUtil.c:464
int nTruePis
Definition: nwk.h:82
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
#define Nwk_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: nwk.h:179
int Nwk_ManPushBackwardFast_rec(Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
Definition: nwkFlow.c:190
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Nwk_ObjFaninNum(Nwk_Obj_t *p)
Definition: nwk.h:137
static int Nwk_ObjIsCo(Nwk_Obj_t *p)
Definition: nwk.h:147
#define Nwk_ManForEachPoSeq(p, pObj, i)
Definition: nwk.h:207
if(last==0)
Definition: sparse_int.h:34
void Nwk_ManMarkTfiCone_rec(Nwk_Obj_t *pObj)
FUNCTION DEFINITIONS ///.
Definition: nwkFlow.c:112
static int Counter
static int Nwk_ManCiNum(Nwk_Man_t *p)
MACRO DEFINITIONS ///.
Definition: nwk.h:125
static int Nwk_ObjHasFlow(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:45
#define Nwk_ManForEachLiSeq(p, pObj, i)
Definition: nwk.h:211
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_PRT(a, t)
Definition: abc_global.h:220
#define Nwk_ManForEachObj(p, pObj, i)
Definition: nwk.h:189
static Nwk_Obj_t * Nwk_ObjFanin0(Nwk_Obj_t *p)
Definition: nwk.h:140
#define assert(ex)
Definition: util_old.h:213
static void Nwk_ManIncrementTravIdFlow(Nwk_Man_t *pMan)
Definition: nwkFlow.c:84
static int Nwk_ManPushBackwardBot_rec(Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
Definition: nwkFlow.c:296
int nLatches
Definition: nwk.h:81
ABC_INT64_T abctime
Definition: abc_global.h:278
int nTruePos
Definition: nwk.h:83
static int Nwk_ManCoNum(Nwk_Man_t *p)
Definition: nwk.h:126
#define Nwk_ManForEachNode(p, pObj, i)
Definition: nwk.h:192
Vec_Ptr_t* Nwk_ManRetimeCutForward ( Nwk_Man_t pMan,
int  nLatches,
int  fVerbose 
)

Function*************************************************************

Synopsis [Computes minimum cut for forward retiming.]

Description []

SideEffects []

SeeAlso []

Definition at line 442 of file nwkFlow.c.

443 {
444  Vec_Ptr_t * vNodes;
445  Nwk_Obj_t * pObj;
446  int i, RetValue, Counter = 0, Counter2 = 0;
447  abctime clk = Abc_Clock();
448  // set the sequential parameters
449  pMan->nLatches = nLatches;
450  pMan->nTruePis = Nwk_ManCiNum(pMan) - nLatches;
451  pMan->nTruePos = Nwk_ManCoNum(pMan) - nLatches;
452  // mark the COs and the TFO of PIs
453  Nwk_ManForEachCo( pMan, pObj, i )
454  pObj->MarkA = 1;
455  Nwk_ManForEachPiSeq( pMan, pObj, i )
456  Nwk_ManMarkTfoCone_rec( pObj );
457  // start flow computation from each LO
459  Nwk_ManForEachLoSeq( pMan, pObj, i )
460  {
461  if ( !Nwk_ManPushForwardFast_rec( pObj, NULL ) )
462  continue;
464  Counter++;
465  }
466  if ( fVerbose )
467  printf( "Forward: Max-flow = %4d -> ", Counter );
468  // continue flow computation from each LO
470  Nwk_ManForEachLoSeq( pMan, pObj, i )
471  {
472  if ( !Nwk_ManPushForwardBot_rec( pObj, NULL ) )
473  continue;
475  Counter2++;
476  }
477  if ( fVerbose )
478  printf( "%4d. ", Counter+Counter2 );
479  // repeat flow computation from each LO
480  if ( Counter2 > 0 )
481  {
483  Nwk_ManForEachLoSeq( pMan, pObj, i )
484  {
485  RetValue = Nwk_ManPushForwardBot_rec( pObj, NULL );
486  assert( !RetValue );
487  }
488  }
489  // cut is a set of nodes whose bottom is visited but top is not visited
490  vNodes = Vec_PtrAlloc( Counter+Counter2 );
491  Counter = 0;
492  Nwk_ManForEachObj( pMan, pObj, i )
493  {
494  if ( Nwk_ObjVisitedBotOnly(pObj) )
495  {
496  assert( Nwk_ObjHasFlow(pObj) );
497  assert( !Nwk_ObjIsCo(pObj) );
498  Vec_PtrPush( vNodes, pObj );
499  Counter += Nwk_ObjIsCi(pObj);
500  }
501  }
502  Nwk_ManCleanMarks( pMan );
503 // assert( Nwk_ManRetimeVerifyCutForward(pMan, vNodes) );
504  if ( fVerbose )
505  {
506  printf( "Min-cut = %4d. Unmoved = %4d. ", Vec_PtrSize(vNodes), Counter );
507  ABC_PRT( "Time", Abc_Clock() - clk );
508  }
509  return vNodes;
510 }
static int Nwk_ObjIsCi(Nwk_Obj_t *p)
Definition: nwk.h:146
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Nwk_ObjVisitedBotOnly(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:54
ABC_DLL void Nwk_ManCleanMarks(Nwk_Man_t *pNtk)
Definition: nwkUtil.c:464
#define Nwk_ManForEachCo(p, pObj, i)
Definition: nwk.h:181
int nTruePis
Definition: nwk.h:82
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
#define Nwk_ManForEachLoSeq(p, pObj, i)
Definition: nwk.h:209
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
#define Nwk_ManForEachPiSeq(p, pObj, i)
Definition: nwk.h:205
int Nwk_ManPushForwardFast_rec(Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
Definition: nwkFlow.c:156
void Nwk_ManMarkTfoCone_rec(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:134
static int Nwk_ObjIsCo(Nwk_Obj_t *p)
Definition: nwk.h:147
static int Nwk_ManPushForwardBot_rec(Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
Definition: nwkFlow.c:224
static int Counter
static int Nwk_ManCiNum(Nwk_Man_t *p)
MACRO DEFINITIONS ///.
Definition: nwk.h:125
static int Nwk_ObjHasFlow(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:45
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_PRT(a, t)
Definition: abc_global.h:220
#define Nwk_ManForEachObj(p, pObj, i)
Definition: nwk.h:189
#define assert(ex)
Definition: util_old.h:213
static void Nwk_ManIncrementTravIdFlow(Nwk_Man_t *pMan)
Definition: nwkFlow.c:84
int nLatches
Definition: nwk.h:81
ABC_INT64_T abctime
Definition: abc_global.h:278
int nTruePos
Definition: nwk.h:83
static int Nwk_ManCoNum(Nwk_Man_t *p)
Definition: nwk.h:126
int Nwk_ManRetimeVerifyCutBackward ( Nwk_Man_t pMan,
Vec_Ptr_t vNodes 
)

Function*************************************************************

Synopsis [Verifies the forward cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 426 of file nwkFlow.c.

427 {
428  return 1;
429 }
int Nwk_ManRetimeVerifyCutForward ( Nwk_Man_t pMan,
Vec_Ptr_t vNodes 
)

Function*************************************************************

Synopsis [Verifies the forward cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 394 of file nwkFlow.c.

395 {
396  Nwk_Obj_t * pObj;
397  int i;
398  // mark the nodes
399  Vec_PtrForEachEntry( Nwk_Obj_t *, vNodes, pObj, i )
400  {
401  assert( pObj->MarkA == 0 );
402  pObj->MarkA = 1;
403  }
404  // traverse from the COs
405  Nwk_ManIncrementTravId( pMan );
406  Nwk_ManForEachCo( pMan, pObj, i )
407  if ( !Nwk_ManVerifyCut_rec( pObj ) )
408  printf( "Nwk_ManRetimeVerifyCutForward(): Internal cut verification failed.\n" );
409  // unmark the nodes
410  Vec_PtrForEachEntry( Nwk_Obj_t *, vNodes, pObj, i )
411  pObj->MarkA = 0;
412  return 1;
413 }
int Nwk_ManRetimeVerifyCutForward(Nwk_Man_t *pMan, Vec_Ptr_t *vNodes)
Definition: nwkFlow.c:394
#define Nwk_ManForEachCo(p, pObj, i)
Definition: nwk.h:181
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
int Nwk_ManVerifyCut_rec(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:366
if(last==0)
Definition: sparse_int.h:34
ABC_DLL void Nwk_ManIncrementTravId(Nwk_Man_t *pNtk)
DECLARATIONS ///.
Definition: nwkUtil.c:47
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
int Nwk_ManVerifyCut_rec ( Nwk_Obj_t pObj)

Function*************************************************************

Synopsis [Returns 0 if there is an unmarked path to a CI.]

Description []

SideEffects []

SeeAlso []

Definition at line 366 of file nwkFlow.c.

367 {
368  Nwk_Obj_t * pNext;
369  int i;
370  if ( pObj->MarkA )
371  return 1;
372  if ( Nwk_ObjIsLo(pObj) )
373  return 0;
374  if ( Nwk_ObjIsTravIdCurrent( pObj ) )
375  return 1;
376  Nwk_ObjSetTravIdCurrent( pObj );
377  Nwk_ObjForEachFanin( pObj, pNext, i )
378  if ( !Nwk_ManVerifyCut_rec( pNext ) )
379  return 0;
380  return 1;
381 }
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
static void Nwk_ObjSetTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:166
static int Nwk_ObjIsLo(Nwk_Obj_t *p)
Definition: nwk.h:153
static int Nwk_ObjIsTravIdCurrent(Nwk_Obj_t *pObj)
Definition: nwk.h:168
int Nwk_ManVerifyCut_rec(Nwk_Obj_t *pObj)
Definition: nwkFlow.c:366
if(last==0)
Definition: sparse_int.h:34
#define Nwk_ObjForEachFanin(pObj, pFanin, i)
Definition: nwk.h:199
static void Nwk_ObjClearFlow ( Nwk_Obj_t pObj)
inlinestatic

Definition at line 47 of file nwkFlow.c.

47 { pObj->MarkB = 0; }
static int Nwk_ObjHasFlow ( Nwk_Obj_t pObj)
inlinestatic

Definition at line 45 of file nwkFlow.c.

45 { return pObj->MarkB; }
static int Nwk_ObjIsSink ( Nwk_Obj_t pObj)
inlinestatic

Definition at line 42 of file nwkFlow.c.

42 { return pObj->MarkA; }
static ABC_NAMESPACE_IMPL_START Nwk_Obj_t* Nwk_ObjPred ( Nwk_Obj_t pObj)
inlinestatic

DECLARATIONS ///.

CFile****************************************************************

FileName [nwkFlow.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Netlist representation.]

Synopsis [Max-flow/min-cut computation.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
nwkFlow.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 39 of file nwkFlow.c.

39 { return (Nwk_Obj_t *)pObj->pCopy; }
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition: nwk.h:49
static void Nwk_ObjSetFlow ( Nwk_Obj_t pObj)
inlinestatic

Definition at line 46 of file nwkFlow.c.

46 { pObj->MarkB = 1; }
static int Nwk_ObjSetPred ( Nwk_Obj_t pObj,
Nwk_Obj_t p 
)
inlinestatic

Definition at line 40 of file nwkFlow.c.

40 { pObj->pCopy = p; return 1; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Nwk_ObjSetSink ( Nwk_Obj_t pObj)
inlinestatic

Definition at line 43 of file nwkFlow.c.

43 { pObj->MarkA = 1; }
static void Nwk_ObjSetVisitedBot ( Nwk_Obj_t pObj)
inlinestatic

Definition at line 66 of file nwkFlow.c.

67 {
68  if ( pObj->TravId < pObj->pMan->nTravIds - 2 )
69  pObj->TravId = pObj->pMan->nTravIds - 2;
70  else if ( pObj->TravId == pObj->pMan->nTravIds - 1 )
71  pObj->TravId = pObj->pMan->nTravIds;
72  else
73  assert( 0 );
74 }
#define assert(ex)
Definition: util_old.h:213
static void Nwk_ObjSetVisitedTop ( Nwk_Obj_t pObj)
inlinestatic

Definition at line 75 of file nwkFlow.c.

76 {
77  if ( pObj->TravId < pObj->pMan->nTravIds - 2 )
78  pObj->TravId = pObj->pMan->nTravIds - 1;
79  else if ( pObj->TravId == pObj->pMan->nTravIds - 2 )
80  pObj->TravId = pObj->pMan->nTravIds;
81  else
82  assert( 0 );
83 }
#define assert(ex)
Definition: util_old.h:213
static int Nwk_ObjVisitedBot ( Nwk_Obj_t pObj)
inlinestatic

Definition at line 58 of file nwkFlow.c.

59 {
60  return pObj->TravId == pObj->pMan->nTravIds - 2 || pObj->TravId == pObj->pMan->nTravIds;
61 }
static int Nwk_ObjVisitedBotOnly ( Nwk_Obj_t pObj)
inlinestatic

Definition at line 54 of file nwkFlow.c.

55 {
56  return pObj->TravId == pObj->pMan->nTravIds - 2;
57 }
static int Nwk_ObjVisitedTop ( Nwk_Obj_t pObj)
inlinestatic

Definition at line 62 of file nwkFlow.c.

63 {
64  return pObj->TravId == pObj->pMan->nTravIds - 1 || pObj->TravId == pObj->pMan->nTravIds;
65 }