ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
nwkFlow_depth.c File Reference
#include "nwk.h"
Include dependency graph for nwkFlow_depth.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)
 

Variables

ABC_NAMESPACE_IMPL_START int DepthFwd
 
ABC_NAMESPACE_IMPL_START int DepthBwd
 
ABC_NAMESPACE_IMPL_START int DepthFwdMax
 
ABC_NAMESPACE_IMPL_START int DepthBwdMax
 

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 114 of file nwkFlow_depth.c.

115{
116 Nwk_Obj_t * pNext;
117 int i;
118 if ( pObj->MarkA )
119 return;
120 pObj->MarkA = 1;
121 Nwk_ObjForEachFanin( pObj, pNext, i )
122 Nwk_ManMarkTfiCone_rec( pNext );
123}
void Nwk_ManMarkTfiCone_rec(Nwk_Obj_t *pObj)
FUNCTION DEFINITIONS ///.
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 136 of file nwkFlow_depth.c.

137{
138 Nwk_Obj_t * pNext;
139 int i;
140 if ( pObj->MarkA )
141 return;
142 pObj->MarkA = 1;
143 Nwk_ObjForEachFanout( pObj, pNext, i )
144 Nwk_ManMarkTfoCone_rec( pNext );
145}
void Nwk_ManMarkTfoCone_rec(Nwk_Obj_t *pObj)
#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 192 of file nwkFlow_depth.c.

193{
194 Nwk_Obj_t * pNext;
195 int i;
196 if ( Nwk_ObjIsTravIdCurrent( pObj ) )
197 return 0;
198 Nwk_ObjSetTravIdCurrent( pObj );
199 if ( Nwk_ObjHasFlow(pObj) )
200 return 0;
201 if ( Nwk_ObjIsSink(pObj) )
202 {
203 Nwk_ObjSetFlow(pObj);
204 return Nwk_ObjSetPred( pObj, pPred );
205 }
206 Nwk_ObjForEachFanin( pObj, pNext, i )
207 if ( Nwk_ManPushBackwardFast_rec( pNext, pObj ) )
208 {
209 Nwk_ObjSetFlow(pObj);
210 return Nwk_ObjSetPred( pObj, pPred );
211 }
212 return 0;
213}
int Nwk_ManPushBackwardFast_rec(Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
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 158 of file nwkFlow_depth.c.

159{
160 Nwk_Obj_t * pNext;
161 int i;
162 if ( Nwk_ObjIsTravIdCurrent( pObj ) )
163 return 0;
164 Nwk_ObjSetTravIdCurrent( pObj );
165 if ( Nwk_ObjHasFlow(pObj) )
166 return 0;
167 if ( Nwk_ObjIsSink(pObj) )
168 {
169 Nwk_ObjSetFlow(pObj);
170 return Nwk_ObjSetPred( pObj, pPred );
171 }
172 Nwk_ObjForEachFanout( pObj, pNext, i )
173 if ( Nwk_ManPushForwardFast_rec( pNext, pObj ) )
174 {
175 Nwk_ObjSetFlow(pObj);
176 return Nwk_ObjSetPred( pObj, pPred );
177 }
178 return 0;
179}
int Nwk_ManPushForwardFast_rec(Nwk_Obj_t *pObj, Nwk_Obj_t *pPred)
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 548 of file nwkFlow_depth.c.

549{
550 Vec_Ptr_t * vNodes;
551 Nwk_Obj_t * pObj;
552 int i, RetValue, Counter = 0, Counter2 = 0;
553 clock_t clk = clock();
554 // set the sequential parameters
555 pMan->nLatches = nLatches;
556 pMan->nTruePis = Nwk_ManCiNum(pMan) - nLatches;
557 pMan->nTruePos = Nwk_ManCoNum(pMan) - nLatches;
558 // mark the CIs, the TFI of POs, and the constant nodes
559 Nwk_ManForEachCi( pMan, pObj, i )
560 pObj->MarkA = 1;
561 Nwk_ManForEachPoSeq( pMan, pObj, i )
563 Nwk_ManForEachNode( pMan, pObj, i )
564 if ( Nwk_ObjFaninNum(pObj) == 0 )
565 pObj->MarkA = 1;
566 // start flow computation from each LI driver
567 Nwk_ManIncrementTravIdFlow( pMan );
568 Nwk_ManForEachLiSeq( pMan, pObj, i )
569 {
570 if ( !Nwk_ManPushBackwardFast_rec( Nwk_ObjFanin0(pObj), NULL ) )
571 continue;
572 Nwk_ManIncrementTravIdFlow( pMan );
573 Counter++;
574 }
575 if ( fVerbose )
576 printf( "Backward: Max-flow = %4d -> ", Counter );
577 // continue flow computation from each LI driver
578 Nwk_ManIncrementTravIdFlow( pMan );
579 Nwk_ManForEachLiSeq( pMan, pObj, i )
580 {
581 if ( !Nwk_ManPushBackwardBot_rec( Nwk_ObjFanin0(pObj), NULL ) )
582 continue;
583 Nwk_ManIncrementTravIdFlow( pMan );
584 Counter2++;
585 }
586 if ( fVerbose )
587 printf( "%4d. ", Counter+Counter2 );
588 // repeat flow computation from each LI driver
589 if ( Counter2 > 0 )
590 {
591 Nwk_ManIncrementTravIdFlow( pMan );
592 Nwk_ManForEachLiSeq( pMan, pObj, i )
593 {
594 RetValue = Nwk_ManPushBackwardBot_rec( Nwk_ObjFanin0(pObj), NULL );
595 assert( !RetValue );
596 }
597 }
598 // cut is a set of nodes whose bottom is visited but top is not visited
599 vNodes = Vec_PtrAlloc( Counter+Counter2 );
600 Nwk_ManForEachObj( pMan, pObj, i )
601 {
602 if ( Nwk_ObjVisitedBotOnly(pObj) )
603 {
604 assert( Nwk_ObjHasFlow(pObj) );
605 assert( !Nwk_ObjIsCo(pObj) );
606 Vec_PtrPush( vNodes, pObj );
607 }
608 }
609 // count CO drivers
610 Counter = 0;
611 Nwk_ManForEachLiSeq( pMan, pObj, i )
612 if ( Nwk_ObjVisitedBotOnly( Nwk_ObjFanin0(pObj) ) )
613 Counter++;
614 Nwk_ManCleanMarks( pMan );
615 assert( Nwk_ManRetimeVerifyCutBackward(pMan, vNodes) );
616 if ( fVerbose )
617 {
618 printf( "Min-cut = %4d. Unmoved = %4d. ", Vec_PtrSize(vNodes), Counter );
619 PRT( "Time", clock() - clk );
620 }
621 return vNodes;
622}
#define PRT(FMT,...)
int Nwk_ManRetimeVerifyCutBackward(Nwk_Man_t *pMan, Vec_Ptr_t *vNodes)
#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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 463 of file nwkFlow_depth.c.

464{
465 Vec_Ptr_t * vNodes;
466 Nwk_Obj_t * pObj;
467 int i, RetValue, Counter = 0, Counter2 = 0;
468 clock_t clk = clock();
469 // set the sequential parameters
470 pMan->nLatches = nLatches;
471 pMan->nTruePis = Nwk_ManCiNum(pMan) - nLatches;
472 pMan->nTruePos = Nwk_ManCoNum(pMan) - nLatches;
473 // mark the COs and the TFO of PIs
474 Nwk_ManForEachCo( pMan, pObj, i )
475 pObj->MarkA = 1;
476 Nwk_ManForEachPiSeq( pMan, pObj, i )
478 // start flow computation from each LO
479 Nwk_ManIncrementTravIdFlow( pMan );
480 Nwk_ManForEachLoSeq( pMan, pObj, i )
481 {
482 if ( !Nwk_ManPushForwardFast_rec( pObj, NULL ) )
483 continue;
484 Nwk_ManIncrementTravIdFlow( pMan );
485 Counter++;
486 }
487 if ( fVerbose )
488 printf( "Forward: Max-flow = %4d -> ", Counter );
489 // continue flow computation from each LO
490 DepthFwdMax = DepthFwd = 0;
491 Nwk_ManIncrementTravIdFlow( pMan );
492 Nwk_ManForEachLoSeq( pMan, pObj, i )
493 {
494 printf( "%d ", DepthFwdMax );
495 if ( !Nwk_ManPushForwardBot_rec( pObj, NULL ) )
496 continue;
497 assert( DepthFwd == 0 );
498 Nwk_ManIncrementTravIdFlow( pMan );
499 Counter2++;
500 }
501 printf( "DepthMax = %d.\n", DepthFwdMax );
502 if ( fVerbose )
503 printf( "%4d. ", Counter+Counter2 );
504 // repeat flow computation from each LO
505 if ( Counter2 > 0 )
506 {
507 Nwk_ManIncrementTravIdFlow( pMan );
508 Nwk_ManForEachLoSeq( pMan, pObj, i )
509 {
510 RetValue = Nwk_ManPushForwardBot_rec( pObj, NULL );
511 assert( !RetValue );
512 }
513 }
514 // cut is a set of nodes whose bottom is visited but top is not visited
515 vNodes = Vec_PtrAlloc( Counter+Counter2 );
516 Counter = 0;
517 Nwk_ManForEachObj( pMan, pObj, i )
518 {
519 if ( Nwk_ObjVisitedBotOnly(pObj) )
520 {
521 assert( Nwk_ObjHasFlow(pObj) );
522 assert( !Nwk_ObjIsCo(pObj) );
523 Vec_PtrPush( vNodes, pObj );
524 Counter += Nwk_ObjIsCi(pObj);
525 }
526 }
527 Nwk_ManCleanMarks( pMan );
528 assert( Nwk_ManRetimeVerifyCutForward(pMan, vNodes) );
529 if ( fVerbose )
530 {
531 printf( "Min-cut = %4d. Unmoved = %4d. ", Vec_PtrSize(vNodes), Counter );
532 PRT( "Time", clock() - clk );
533 }
534 return vNodes;
535}
ABC_NAMESPACE_IMPL_START int DepthFwdMax
int Nwk_ManRetimeVerifyCutForward(Nwk_Man_t *pMan, Vec_Ptr_t *vNodes)
ABC_NAMESPACE_IMPL_START int DepthFwd
#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
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 447 of file nwkFlow_depth.c.

448{
449 return 1;
450}
Here is the caller graph for this function:

◆ 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 415 of file nwkFlow_depth.c.

416{
417 Nwk_Obj_t * pObj;
418 int i;
419 // mark the nodes
420 Vec_PtrForEachEntry( Nwk_Obj_t *, vNodes, pObj, i )
421 {
422 assert( pObj->MarkA == 0 );
423 pObj->MarkA = 1;
424 }
425 // traverse from the COs
427 Nwk_ManForEachCo( pMan, pObj, i )
428 if ( !Nwk_ManVerifyCut_rec( pObj ) )
429 printf( "Nwk_ManRetimeVerifyCutForward(): Internal cut verification failed.\n" );
430 // unmark the nodes
431 Vec_PtrForEachEntry( Nwk_Obj_t *, vNodes, pObj, i )
432 pObj->MarkA = 0;
433 return 1;
434}
int Nwk_ManVerifyCut_rec(Nwk_Obj_t *pObj)
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:
Here is the caller 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 387 of file nwkFlow_depth.c.

388{
389 Nwk_Obj_t * pNext;
390 int i;
391 if ( pObj->MarkA )
392 return 1;
393 if ( Nwk_ObjIsLo(pObj) )
394 return 0;
395 if ( Nwk_ObjIsTravIdCurrent( pObj ) )
396 return 1;
397 Nwk_ObjSetTravIdCurrent( pObj );
398 Nwk_ObjForEachFanin( pObj, pNext, i )
399 if ( !Nwk_ManVerifyCut_rec( pNext ) )
400 return 0;
401 return 1;
402}
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ DepthBwd

Definition at line 34 of file nwkFlow_depth.c.

◆ DepthBwdMax

ABC_NAMESPACE_IMPL_START int DepthBwdMax

Definition at line 34 of file nwkFlow_depth.c.

◆ DepthFwd

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 34 of file nwkFlow_depth.c.

◆ DepthFwdMax

ABC_NAMESPACE_IMPL_START int DepthFwdMax

Definition at line 34 of file nwkFlow_depth.c.