ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
nwkFlow.c File Reference
#include "nwk.h"
Include dependency graph for nwkFlow.c:

Go to the source code of this file.

Functions

void Nwk_ManMarkTfiCone_rec (Nwk_Obj_t *pObj)
 FUNCTION DEFINITIONS ///.
 
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

◆ Nwk_ManMarkTfiCone_rec()

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}
void Nwk_ManMarkTfiCone_rec(Nwk_Obj_t *pObj)
FUNCTION DEFINITIONS ///.
Definition nwkFlow.c:112
typedefABC_NAMESPACE_HEADER_START struct Nwk_Obj_t_ Nwk_Obj_t
INCLUDES ///.
Definition nwk.h:49
#define Nwk_ObjForEachFanin(pObj, pFanin, i)
Definition nwk.h:199
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Nwk_ManMarkTfoCone_rec()

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}
void Nwk_ManMarkTfoCone_rec(Nwk_Obj_t *pObj)
Definition nwkFlow.c:134
#define Nwk_ObjForEachFanout(pObj, pFanout, i)
Definition nwk.h:201
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Nwk_ManPushBackwardFast_rec()

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}
int Nwk_ManPushBackwardFast_rec(Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
Definition nwkFlow.c:190
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Nwk_ManPushForwardFast_rec()

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}
int Nwk_ManPushForwardFast_rec(Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
Definition nwkFlow.c:156
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Nwk_ManRetimeCutBackward()

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 )
538 Nwk_ManForEachNode( pMan, pObj, i )
539 if ( Nwk_ObjFaninNum(pObj) == 0 )
540 pObj->MarkA = 1;
541 // start flow computation from each LI driver
542 Nwk_ManIncrementTravIdFlow( pMan );
543 Nwk_ManForEachLiSeq( pMan, pObj, i )
544 {
545 if ( !Nwk_ManPushBackwardFast_rec( Nwk_ObjFanin0(pObj), NULL ) )
546 continue;
547 Nwk_ManIncrementTravIdFlow( pMan );
548 Counter++;
549 }
550 if ( fVerbose )
551 printf( "Backward: Max-flow = %4d -> ", Counter );
552 // continue flow computation from each LI driver
553 Nwk_ManIncrementTravIdFlow( pMan );
554 Nwk_ManForEachLiSeq( pMan, pObj, i )
555 {
556 if ( !Nwk_ManPushBackwardBot_rec( Nwk_ObjFanin0(pObj), NULL ) )
557 continue;
558 Nwk_ManIncrementTravIdFlow( pMan );
559 Counter2++;
560 }
561 if ( fVerbose )
562 printf( "%4d. ", Counter+Counter2 );
563 // repeat flow computation from each LI driver
564 if ( Counter2 > 0 )
565 {
566 Nwk_ManIncrementTravIdFlow( pMan );
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 )
587 if ( Nwk_ObjVisitedBotOnly( Nwk_ObjFanin0(pObj) ) )
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}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
#define Nwk_ManForEachNode(p, pObj, i)
Definition nwk.h:192
#define Nwk_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition nwk.h:179
#define Nwk_ManForEachPoSeq(p, pObj, i)
Definition nwk.h:207
#define Nwk_ManForEachObj(p, pObj, i)
Definition nwk.h:189
ABC_DLL void Nwk_ManCleanMarks(Nwk_Man_t *pNtk)
Definition nwkUtil.c:464
#define Nwk_ManForEachLiSeq(p, pObj, i)
Definition nwk.h:211
int nLatches
Definition nwk.h:81
int nTruePis
Definition nwk.h:82
int nTruePos
Definition nwk.h:83
#define assert(ex)
Definition util_old.h:213
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42

◆ Nwk_ManRetimeCutForward()

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 )
457 // start flow computation from each LO
458 Nwk_ManIncrementTravIdFlow( pMan );
459 Nwk_ManForEachLoSeq( pMan, pObj, i )
460 {
461 if ( !Nwk_ManPushForwardFast_rec( pObj, NULL ) )
462 continue;
463 Nwk_ManIncrementTravIdFlow( pMan );
464 Counter++;
465 }
466 if ( fVerbose )
467 printf( "Forward: Max-flow = %4d -> ", Counter );
468 // continue flow computation from each LO
469 Nwk_ManIncrementTravIdFlow( pMan );
470 Nwk_ManForEachLoSeq( pMan, pObj, i )
471 {
472 if ( !Nwk_ManPushForwardBot_rec( pObj, NULL ) )
473 continue;
474 Nwk_ManIncrementTravIdFlow( pMan );
475 Counter2++;
476 }
477 if ( fVerbose )
478 printf( "%4d. ", Counter+Counter2 );
479 // repeat flow computation from each LO
480 if ( Counter2 > 0 )
481 {
482 Nwk_ManIncrementTravIdFlow( pMan );
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}
#define Nwk_ManForEachLoSeq(p, pObj, i)
Definition nwk.h:209
#define Nwk_ManForEachCo(p, pObj, i)
Definition nwk.h:181
#define Nwk_ManForEachPiSeq(p, pObj, i)
Definition nwk.h:205

◆ Nwk_ManRetimeVerifyCutBackward()

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}

◆ Nwk_ManRetimeVerifyCutForward()

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
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_ManVerifyCut_rec(Nwk_Obj_t *pObj)
Definition nwkFlow.c:366
ABC_DLL void Nwk_ManIncrementTravId(Nwk_Man_t *pNtk)
DECLARATIONS ///.
Definition nwkUtil.c:47
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:

◆ Nwk_ManVerifyCut_rec()

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}
Here is the call graph for this function:
Here is the caller graph for this function: