ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
wlnRetime.c File Reference
#include "wln.h"
#include "misc/vec/vecHsh.h"
Include dependency graph for wlnRetime.c:

Go to the source code of this file.

Classes

struct  Wln_Ret_t_
 

Macros

#define Wln_RetForEachFanin(p, iObj, iFanin, pLink, i)
 
#define Wln_RetForEachFanout(p, iObj, iFanout, pLink, i)
 

Typedefs

typedef typedefABC_NAMESPACE_IMPL_START struct Wln_Ret_t_ Wln_Ret_t
 DECLARATIONS ///.
 

Functions

void Wln_RetPrintObj (Wln_Ret_t *p, int iObj)
 FUNCTION DEFINITIONS ///.
 
void Wln_RetPrint (Wln_Ret_t *p, int fVerbose)
 
int Wln_RetComputeFfClasses (Wln_Ntk_t *pNtk, Vec_Int_t *vClasses)
 
Wln_Ret_tWln_RetAlloc (Wln_Ntk_t *pNtk)
 
void Wln_RetFree (Wln_Ret_t *p)
 
int Wln_RetMemUsage (Wln_Ret_t *p)
 
void Wln_RetMarkChanges_rec (Wln_Ret_t *p, int iObj)
 
void Wln_RetMarkChanges (Wln_Ret_t *p, Vec_Int_t *vFront)
 
int Wln_RetPropDelay_rec (Wln_Ret_t *p, int iObj)
 
int Wln_RetPropDelay (Wln_Ret_t *p)
 
void Wln_RetFindSources_rec (Wln_Ret_t *p, int iObj)
 
void Wln_RetFindSources (Wln_Ret_t *p)
 
int Wln_RetMarkPaths_rec (Wln_Ntk_t *p, int iObj, int fVerbose)
 
void Wln_RetMarkPaths (Wln_Ntk_t *p, int fVerbose)
 
int * Wln_RetHeadToTail (Wln_Ret_t *p, int *pHead)
 
int Wln_RetCheckForward (Wln_Ret_t *p, Vec_Int_t *vSet)
 
int Wln_RetCheckBackward (Wln_Ret_t *p, Vec_Int_t *vSet)
 
int Wln_RetRemoveOneFanin (Wln_Ret_t *p, int iObj)
 
int Wln_RetRemoveOneFanout (Wln_Ret_t *p, int iObj)
 
void Wln_RetInsertOneFanin (Wln_Ret_t *p, int iObj, int iFlop)
 
void Wln_RetInsertOneFanout (Wln_Ret_t *p, int iObj, int iFlop)
 
void Wln_RetRetimeForward (Wln_Ret_t *p, Vec_Int_t *vSet)
 
void Wln_RetRetimeBackward (Wln_Ret_t *p, Vec_Int_t *vSet)
 
void Wln_RetAddToMoves (Wln_Ret_t *p, Vec_Int_t *vSet, int Delay, int fForward, int nMoves, int fSkipSimple, int fVerbose)
 
void Wln_NtkRetimeCreateDelayInfo (Wln_Ntk_t *pNtk)
 
Vec_Int_tWln_NtkRetime_int (Wln_Ntk_t *pNtk, int fSkipSimple, int fVerbose)
 
Vec_Int_tWln_NtkRetime (Wln_Ntk_t *pNtk, int fIgnoreIO, int fSkipSimple, int fVerbose)
 

Macro Definition Documentation

◆ Wln_RetForEachFanin

#define Wln_RetForEachFanin ( p,
iObj,
iFanin,
pLink,
i )
Value:
for ( i = 0; (i < Wln_ObjFaninNum(p->pNtk, iObj)) && \
(((iFanin) = Wln_RetFanins(p, iObj)[2*i]), 1) && \
((pLink) = (Wln_RetFanins(p, iObj)+2*i+1)); i++ ) if ( !iFanin || (!Wln_ObjFaninNum(p->pNtk, iFanin) && !Wln_ObjIsCi(p->pNtk, iFanin)) ) {} else
Cube * p
Definition exorList.c:222

Definition at line 51 of file wlnRetime.c.

51#define Wln_RetForEachFanin( p, iObj, iFanin, pLink, i ) \
52 for ( i = 0; (i < Wln_ObjFaninNum(p->pNtk, iObj)) && \
53 (((iFanin) = Wln_RetFanins(p, iObj)[2*i]), 1) && \
54 ((pLink) = (Wln_RetFanins(p, iObj)+2*i+1)); i++ ) if ( !iFanin || (!Wln_ObjFaninNum(p->pNtk, iFanin) && !Wln_ObjIsCi(p->pNtk, iFanin)) ) {} else

◆ Wln_RetForEachFanout

#define Wln_RetForEachFanout ( p,
iObj,
iFanout,
pLink,
i )
Value:
for ( i = 0; (i < Wln_ObjRefs(p->pNtk, iObj)) && \
(((iFanout) = Wln_RetFanouts(p, iObj)[2*i]), 1) && \
((pLink) = Vec_IntEntryP(&p->vFanins, Wln_RetFanouts(p, iObj)[2*i+1])); i++ ) if ( !iFanout ) {} else

Definition at line 56 of file wlnRetime.c.

56#define Wln_RetForEachFanout( p, iObj, iFanout, pLink, i ) \
57 for ( i = 0; (i < Wln_ObjRefs(p->pNtk, iObj)) && \
58 (((iFanout) = Wln_RetFanouts(p, iObj)[2*i]), 1) && \
59 ((pLink) = Vec_IntEntryP(&p->vFanins, Wln_RetFanouts(p, iObj)[2*i+1])); i++ ) if ( !iFanout ) {} else

Typedef Documentation

◆ Wln_Ret_t

typedef typedefABC_NAMESPACE_IMPL_START struct Wln_Ret_t_ Wln_Ret_t

DECLARATIONS ///.

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

FileName [wlnRetime.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Word-level network.]

Synopsis [Retiming.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - September 23, 2018.]

Revision [

Id
wlnRetime.c,v 1.00 2018/09/23 00:00:00 alanmi Exp

]

Definition at line 30 of file wlnRetime.c.

Function Documentation

◆ Wln_NtkRetime()

Vec_Int_t * Wln_NtkRetime ( Wln_Ntk_t * pNtk,
int fIgnoreIO,
int fSkipSimple,
int fVerbose )

Definition at line 718 of file wlnRetime.c.

719{
720 if ( fIgnoreIO )
721 Wln_RetMarkPaths( pNtk, fVerbose );
722 return Wln_NtkRetime_int( pNtk, fSkipSimple, fVerbose );
723}
Vec_Int_t * Wln_NtkRetime_int(Wln_Ntk_t *pNtk, int fSkipSimple, int fVerbose)
Definition wlnRetime.c:623
void Wln_RetMarkPaths(Wln_Ntk_t *p, int fVerbose)
Definition wlnRetime.c:374
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Wln_NtkRetime_int()

Vec_Int_t * Wln_NtkRetime_int ( Wln_Ntk_t * pNtk,
int fSkipSimple,
int fVerbose )

Definition at line 623 of file wlnRetime.c.

624{
625 Wln_Ret_t * p = Wln_RetAlloc( pNtk );
626 Vec_Int_t * vSources = &p->vSources;
627 Vec_Int_t * vSinks = &p->vSinks;
628 Vec_Int_t * vFront = &p->vFront;
629 Vec_Int_t * vMoves = Vec_IntAlloc(0);
630 int nMoves = 0, fPrevFwd = 0, fPrevBwd = 0, nCountIncrease = 0;
631 int DelayInit = 0, DelayBest = 0, nChange = 0;
632 Wln_RetPrint( p, fVerbose );
633 Wln_RetMarkChanges( p, NULL );
634 p->DelayMax = DelayInit = DelayBest = Wln_RetPropDelay( p );
636 Wln_RetAddToMoves( p, NULL, p->DelayMax, 0, nMoves, fSkipSimple, fVerbose );
637 while ( Vec_IntSize(vSources) || Vec_IntSize(vSinks) )
638 {
639 int DelayMaxPrev = p->DelayMax;
640 int fForward = Vec_IntSize(vSources) && Wln_RetCheckForward( p, vSources );
641 int fBackward = Vec_IntSize(vSinks) && Wln_RetCheckBackward( p, vSinks );
642 Vec_IntSort( vSources, 0 );
643 Vec_IntSort( vSinks, 0 );
644
645 if ( !fForward && !fBackward )
646 {
647 printf( "Cannot retime forward and backward.\n" );
648 break;
649 }
650 if ( Vec_IntTwoCountCommon(vSources, vSinks) )
651 {
652 printf( "Cannot reduce delay by retiming.\n" );
653 break;
654 }
655 nMoves++;
656 Vec_IntClear( vFront );
657 if ( (fPrevFwd && fForward) || (!(fPrevBwd && fBackward) && ((fForward && !fBackward) || (fForward && fBackward && Vec_IntSize(vSources) < Vec_IntSize(vSinks)))) )
658 {
659 Vec_IntAppend( vFront, vSources );
660 Wln_RetMarkChanges( p, vFront );
661 Wln_RetRetimeForward( p, vFront );
662 p->DelayMax = Wln_RetPropDelay( p );
663 fForward = 1, fBackward = 0;
664 fPrevFwd = 1;
665 }
666 else
667 {
668 Vec_IntAppend( vFront, vSinks );
669 Wln_RetRetimeBackward( p, vFront );
670 Wln_RetMarkChanges( p, vFront );
671 p->DelayMax = Wln_RetPropDelay( p );
672 fForward = 0, fBackward = 1;
673 fPrevBwd = 1;
674 }
675 DelayBest = Abc_MinInt( DelayBest, p->DelayMax );
676 //Wln_RetPrint( p );
677 if ( fVerbose )
678 printf( "\n" );
679 Wln_RetAddToMoves( p, vFront, p->DelayMax, fForward, nMoves, fSkipSimple, fVerbose );
680 if ( fVerbose )
681 {
682 printf( "Sinks: " );
683 Vec_IntPrint( &p->vSinks );
684 printf( "Sources: " );
685 Vec_IntPrint( &p->vSources );
686 }
687 if ( p->DelayMax >= DelayMaxPrev )
688 nCountIncrease++;
689 else
690 {
691 if ( nCountIncrease > 0 )
692 nChange++;
693 nCountIncrease = 0;
694 }
695 if ( nCountIncrease > 3 )
696 break;
697 if ( nChange > 5 )
698 break;
700 if ( 2*Vec_IntSize(&p->vEdgeLinks) > Vec_IntCap(&p->vEdgeLinks) )
701 Vec_IntGrow( &p->vEdgeLinks, 4*Vec_IntSize(&p->vEdgeLinks) );
702 }
703 ABC_SWAP( Vec_Int_t, *vMoves, p->vMoves );
704 Wln_RetFree( p );
705 if ( fVerbose )
706 {
707 printf( "\nThe resulting moves recorded in terms of name IDs of the NDR nodes:\n" );
708 Vec_IntPrint( vMoves );
709 }
710 else
711 {
712 printf( "Retiming instruction contains %d moves and %d total retimed objects.\n", nMoves, Vec_IntSize(vMoves)-2*nMoves-2 );
713 printf( "Initial delay = %d. The best delay achieved = %d. Improvement = %d. (%6.2f %%)\n",
714 DelayInit, DelayBest, DelayInit - DelayBest, 100.0 * (DelayInit - DelayBest) / DelayInit );
715 }
716 return vMoves;
717}
#define ABC_SWAP(Type, a, b)
Definition abc_global.h:253
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
void Wln_RetPrint(Wln_Ret_t *p, int fVerbose)
Definition wlnRetime.c:92
void Wln_RetRetimeBackward(Wln_Ret_t *p, Vec_Int_t *vSet)
Definition wlnRetime.c:544
int Wln_RetPropDelay(Wln_Ret_t *p)
Definition wlnRetime.c:285
void Wln_RetRetimeForward(Wln_Ret_t *p, Vec_Int_t *vSet)
Definition wlnRetime.c:533
int Wln_RetCheckForward(Wln_Ret_t *p, Vec_Int_t *vSet)
Definition wlnRetime.c:424
typedefABC_NAMESPACE_IMPL_START struct Wln_Ret_t_ Wln_Ret_t
DECLARATIONS ///.
Definition wlnRetime.c:30
void Wln_RetFindSources(Wln_Ret_t *p)
Definition wlnRetime.c:324
void Wln_RetFree(Wln_Ret_t *p)
Definition wlnRetime.c:201
void Wln_RetAddToMoves(Wln_Ret_t *p, Vec_Int_t *vSet, int Delay, int fForward, int nMoves, int fSkipSimple, int fVerbose)
Definition wlnRetime.c:555
void Wln_RetMarkChanges(Wln_Ret_t *p, Vec_Int_t *vFront)
Definition wlnRetime.c:252
Wln_Ret_t * Wln_RetAlloc(Wln_Ntk_t *pNtk)
Definition wlnRetime.c:149
int Wln_RetCheckBackward(Wln_Ret_t *p, Vec_Int_t *vSet)
Definition wlnRetime.c:452
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Wln_NtkRetimeCreateDelayInfo()

void Wln_NtkRetimeCreateDelayInfo ( Wln_Ntk_t * pNtk)

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

Synopsis [Retiming computation.]

Description []

SideEffects []

SeeAlso []

Definition at line 592 of file wlnRetime.c.

593{
594 int i, iObj;
595// if ( Wln_NtkHasInstId(pNtk) )
596// Vec_IntErase( &pNtk->vInstIds );
597 if ( Wln_NtkHasInstId(pNtk) )
598 {
599 printf( "Using delays given by the user in the input file.\n" );
600 Wln_NtkForEachObj( pNtk, iObj )
601 if ( !Wln_ObjIsCio(pNtk, iObj) && !Wln_ObjIsConst(pNtk, iObj) && Wln_ObjInstId(pNtk, iObj) == 0 )
602 printf( "Warning: Object %d of type %s has zero delay. Retiming will not work correctly.\n", iObj, Abc_OperName(Wln_ObjType(pNtk, iObj)) );
603 }
604 else
605 {
606 printf( "The design has no delay information.\n" );
607 Wln_NtkCleanInstId(pNtk);
608 Wln_NtkForEachObj( pNtk, iObj )
609 {
610 if ( Wln_ObjIsFf(pNtk, iObj) || Wln_ObjType(pNtk, iObj) == ABC_OPER_SLICE || Wln_ObjType(pNtk, iObj) == ABC_OPER_CONCAT )
611 Wln_ObjSetInstId( pNtk, iObj, 1 );
612 else if ( !Wln_ObjIsCio(pNtk, iObj) && Wln_ObjFaninNum(pNtk, iObj) > 0 )
613 Wln_ObjSetInstId( pNtk, iObj, 10 );
614 }
615 Wln_NtkForEachCo( pNtk, iObj, i )
616 {
617 if ( Wln_ObjType(pNtk, Wln_ObjFanin0(pNtk, iObj)) != ABC_OPER_LUT )
618 Wln_ObjSetInstId( pNtk, Wln_ObjFanin0(pNtk, iObj), 1 );
619 }
620 printf( "Assuming default delays: 10 units for most nodes and 1 unit for bit-slice, concat, and buffers driving COs.\n" );
621 }
622}
@ ABC_OPER_LUT
Definition abcOper.h:127
@ ABC_OPER_CONCAT
Definition abcOper.h:147
@ ABC_OPER_SLICE
Definition abcOper.h:146
#define Wln_NtkForEachCo(p, iCo, i)
Definition wln.h:200
#define Wln_NtkForEachObj(p, i)
MACRO DEFINITIONS ///.
Definition wln.h:187
Here is the caller graph for this function:

◆ Wln_RetAddToMoves()

void Wln_RetAddToMoves ( Wln_Ret_t * p,
Vec_Int_t * vSet,
int Delay,
int fForward,
int nMoves,
int fSkipSimple,
int fVerbose )

Definition at line 555 of file wlnRetime.c.

556{
557 int i, iObj;
558 if ( vSet == NULL )
559 {
560 printf( "Move %4d : Recording initial state (delay = %6d)\n", nMoves, Delay );
561 Vec_IntPushTwo( &p->vMoves, Delay, 0 );
562 return;
563 }
564 printf( "Move %4d : Recording %s retiming (delay = %6d) :", nMoves, fForward ? "forward " : "backward", Delay );
565 Vec_IntPush( &p->vMoves, Delay );
566 Vec_IntForEachEntry( vSet, iObj, i )
567 {
568 int NameId = Vec_IntEntry( &p->pNtk->vNameIds, iObj );
569 if ( fSkipSimple && (Wln_ObjIsFf(p->pNtk, iObj) || Wln_ObjType(p->pNtk, iObj) == ABC_OPER_SLICE || Wln_ObjType(p->pNtk, iObj) == ABC_OPER_CONCAT) )
570 continue;
571 Vec_IntPush( &p->vMoves, fForward ? -NameId : NameId );
572 if ( fVerbose )
573 printf( " %d (NameID = %d) ", fForward ? -iObj : iObj, fForward ? -NameId : NameId );
574 }
575 Vec_IntPush( &p->vMoves, 0 );
576 if ( !fVerbose )
577 printf( " %3d retimed objects", Vec_IntSize(vSet) );
578 printf( "\n" );
579}
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the caller graph for this function:

◆ Wln_RetAlloc()

Wln_Ret_t * Wln_RetAlloc ( Wln_Ntk_t * pNtk)

Definition at line 149 of file wlnRetime.c.

150{
151 Wln_Ret_t * p; int k, iObj, iFanin, fFirst = 1;
152 Vec_Int_t * vRefsCopy = Vec_IntAlloc(0);
153 p = ABC_CALLOC( Wln_Ret_t, 1 );
154 p->pNtk = pNtk;
155 Wln_NtkCreateRefs( pNtk );
156 // print objects without fanout
157 Wln_NtkForEachObj( pNtk, iObj )
158 if ( Wln_ObjRefs(pNtk, iObj) == 0 && !Wln_ObjIsCio(pNtk, iObj) )
159 {
160 if ( fFirst )
161 {
162 fFirst = 0;
163 printf( "Objects without fanout:\n" );
164 }
165 Wln_ObjPrint(pNtk, iObj);
166 }
167 // start fanin/fanout maps
168 Wln_NtkStartFaninMap( pNtk, &p->vFanins, 2 );
169 Wln_NtkStartFanoutMap( pNtk, &p->vFanouts, &pNtk->vRefs, 2 );
170 ABC_SWAP( Vec_Int_t, *vRefsCopy, pNtk->vRefs );
171 Wln_NtkCleanRefs( pNtk );
172 Vec_IntGrow( &p->vEdgeLinks, 10*Wln_NtkFfNum(pNtk) );
173 Vec_IntPushTwo( &p->vEdgeLinks, -1, -1 );
174 Wln_NtkForEachObj( pNtk, iObj )
175 Wln_ObjForEachFanin( pNtk, iObj, iFanin, k )
176 {
177 int * pFanins = Wln_RetFanins( p, iObj );
178 int * pFanouts = Wln_RetFanouts( p, iFanin );
179 int Index = Wln_ObjRefsInc( pNtk, iFanin );
180 pFanins[2*k+0] = iFanin;
181 pFanins[2*k+1] = Wln_ObjIsFf(pNtk, iFanin) ? Vec_IntSize(&p->vEdgeLinks) : 0;
182 pFanouts[2*Index+0] = iObj;
183 pFanouts[2*Index+1] = Vec_IntEntry(&p->vFanins, iObj) + 2*k + 1;
184 if ( Wln_ObjIsFf(pNtk, iFanin) )
185 Vec_IntPushTwo( &p->vEdgeLinks, 0, iFanin );
186 }
187 // double-check the current number of fanouts added
188 Wln_NtkForEachObj( pNtk, iObj )
189 assert( Wln_ObjRefs(pNtk, iObj) == Vec_IntEntry(vRefsCopy, iObj) );
190 Vec_IntFree( vRefsCopy );
191 // other data
192 p->nClasses = Wln_RetComputeFfClasses( pNtk, &p->vFfClasses );
193 //ABC_SWAP( Vec_Int_t, p->vNodeDelays, pNtk->vInstIds );
194 Vec_IntAppend( &p->vNodeDelays, &pNtk->vInstIds );
195 Vec_IntGrow( &p->vSources, 1000 );
196 Vec_IntGrow( &p->vSinks, 1000 );
197 Vec_IntGrow( &p->vFront, 1000 );
198 Vec_IntGrow( &p->vMoves, 1000 );
199 return p;
200}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
Vec_Int_t vInstIds
Definition wln.h:69
Vec_Int_t vRefs
Definition wln.h:77
#define assert(ex)
Definition util_old.h:213
int Wln_RetComputeFfClasses(Wln_Ntk_t *pNtk, Vec_Int_t *vClasses)
Definition wlnRetime.c:130
void Wln_ObjPrint(Wln_Ntk_t *p, int iObj)
Definition wlnObj.c:136
#define Wln_ObjForEachFanin(p, iObj, iFanin, i)
Definition wln.h:205
void Wln_NtkStartFaninMap(Wln_Ntk_t *p, Vec_Int_t *vFaninMap, int nMulti)
Definition wlnNtk.c:372
void Wln_NtkStartFanoutMap(Wln_Ntk_t *p, Vec_Int_t *vFanoutMap, Vec_Int_t *vFanoutNums, int nMulti)
Definition wlnNtk.c:383
void Wln_NtkCreateRefs(Wln_Ntk_t *p)
Definition wlnNtk.c:357
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Wln_RetCheckBackward()

int Wln_RetCheckBackward ( Wln_Ret_t * p,
Vec_Int_t * vSet )

Definition at line 452 of file wlnRetime.c.

453{
454 int i, iObj;
455 Vec_IntForEachEntry( vSet, iObj, i )
456 if ( !Wln_RetCheckBackwardOne( p, iObj ) )
457 return 0;
458 return 1;
459}
Here is the caller graph for this function:

◆ Wln_RetCheckForward()

int Wln_RetCheckForward ( Wln_Ret_t * p,
Vec_Int_t * vSet )

Definition at line 424 of file wlnRetime.c.

425{
426 int i, iObj;
427 Vec_IntForEachEntry( vSet, iObj, i )
428 if ( !Wln_RetCheckForwardOne( p, iObj ) )
429 return 0;
430 return 1;
431}
Here is the caller graph for this function:

◆ Wln_RetComputeFfClasses()

int Wln_RetComputeFfClasses ( Wln_Ntk_t * pNtk,
Vec_Int_t * vClasses )

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

Synopsis [Retiming manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 130 of file wlnRetime.c.

131{
132 int i, k, iObj, nClasses;
133 Hsh_VecMan_t * p = Hsh_VecManStart( 10 );
134 Vec_Int_t * vFlop = Vec_IntAlloc( 6 );
135 Vec_IntFill( vClasses, Wln_NtkObjNum(pNtk), -1 );
136 Wln_NtkForEachFf( pNtk, iObj, i )
137 {
138 Vec_IntClear( vFlop );
139 for ( k = 1; k <= 6; k++ )
140 Vec_IntPush( vFlop, Wln_ObjFanin(pNtk, iObj, k) );
141 Vec_IntWriteEntry( vClasses, iObj, Hsh_VecManAdd(p, vFlop) );
142 }
143 nClasses = Hsh_VecSize( p );
144 Hsh_VecManStop( p );
145 Vec_IntFree( vFlop );
146 printf( "Detected %d flops and %d flop classes.\n", Wln_NtkFfNum(pNtk), nClasses );
147 return nClasses;
148}
struct Hsh_VecMan_t_ Hsh_VecMan_t
Definition vecHsh.h:85
#define Wln_NtkForEachFf(p, iFf, i)
Definition wln.h:202
Here is the caller graph for this function:

◆ Wln_RetFindSources()

void Wln_RetFindSources ( Wln_Ret_t * p)

Definition at line 324 of file wlnRetime.c.

325{
326 int i, iObj;
327 Vec_IntClear( &p->vSources );
328 Wln_NtkIncrementTravId( p->pNtk );
329 Vec_IntForEachEntry( &p->vSinks, iObj, i )
330 Wln_RetFindSources_rec( p, iObj );
331
332// printf( "Sources: " );
333// Vec_IntPrint( &p->vSources );
334}
void Wln_RetFindSources_rec(Wln_Ret_t *p, int iObj)
Definition wlnRetime.c:312
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Wln_RetFindSources_rec()

void Wln_RetFindSources_rec ( Wln_Ret_t * p,
int iObj )

Definition at line 312 of file wlnRetime.c.

313{
314 int k, iFanin, * pLink, FaninDelay;
315 if ( Wln_ObjIsCi(p->pNtk, iObj) || Wln_ObjCheckTravId(p->pNtk, iObj) )
316 return;
317 FaninDelay = Vec_IntEntry( &p->vPathDelays, iObj ) - Vec_IntEntry( &p->vNodeDelays, iObj );
318 Wln_RetForEachFanin( p, iObj, iFanin, pLink, k )
319 if ( !pLink[0] && Vec_IntEntry(&p->vPathDelays, iFanin) == FaninDelay )
320 Wln_RetFindSources_rec( p, iFanin );
321 if ( FaninDelay == 0 )
322 Vec_IntPush( &p->vSources, iObj );
323}
#define Wln_RetForEachFanin(p, iObj, iFanin, pLink, i)
Definition wlnRetime.c:51
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Wln_RetFree()

void Wln_RetFree ( Wln_Ret_t * p)

Definition at line 201 of file wlnRetime.c.

202{
203 ABC_FREE( p->vFanins.pArray );
204 ABC_FREE( p->vFanouts.pArray );
205 ABC_FREE( p->vEdgeLinks.pArray );
206 ABC_FREE( p->vFfClasses.pArray );
207 ABC_FREE( p->vNodeDelays.pArray );
208 ABC_FREE( p->vPathDelays.pArray );
209 ABC_FREE( p->vSources.pArray );
210 ABC_FREE( p->vSinks.pArray );
211 ABC_FREE( p->vFront.pArray );
212 ABC_FREE( p->vMoves.pArray );
213 ABC_FREE( p );
214}
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the caller graph for this function:

◆ Wln_RetHeadToTail()

int * Wln_RetHeadToTail ( Wln_Ret_t * p,
int * pHead )

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

Synopsis [Retimability check.]

Description []

SideEffects []

SeeAlso []

Definition at line 396 of file wlnRetime.c.

397{
398 int * pLink;
399 assert( pHead[0] );
400 pLink = Vec_IntEntryP( &p->vEdgeLinks, pHead[0] );
401 if ( pLink[0] == 0 )
402 return pHead;
403 return Wln_RetHeadToTail( p, pLink );
404}
int * Wln_RetHeadToTail(Wln_Ret_t *p, int *pHead)
Definition wlnRetime.c:396
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Wln_RetInsertOneFanin()

void Wln_RetInsertOneFanin ( Wln_Ret_t * p,
int iObj,
int iFlop )

Definition at line 506 of file wlnRetime.c.

507{
508 int k, iHead, iFanin, * pLink;
509 int * pFanins = Wln_RetFanins( p, iObj );
510 assert( Wln_ObjIsFf( p->pNtk, iFlop ) );
511 Wln_RetForEachFanin( p, iObj, iFanin, pLink, k )
512 {
513 if ( Wln_ObjIsFf(p->pNtk, iObj) && k > 0 )
514 continue;
515 iHead = pFanins[2*k+1];
516 pFanins[2*k+1] = Vec_IntSize(&p->vEdgeLinks);
517 Vec_IntPushTwo( &p->vEdgeLinks, iHead, iFlop );
518 }
519}
Here is the caller graph for this function:

◆ Wln_RetInsertOneFanout()

void Wln_RetInsertOneFanout ( Wln_Ret_t * p,
int iObj,
int iFlop )

Definition at line 520 of file wlnRetime.c.

521{
522 int k, iFanin, * pLink;
523 assert( Wln_ObjIsFf( p->pNtk, iFlop ) );
524 Wln_RetForEachFanout( p, iObj, iFanin, pLink, k )
525 {
526 if ( pLink[0] )
527 pLink = Wln_RetHeadToTail( p, pLink );
528 //assert( pLink[0] == 0 );
529 pLink[0] = Vec_IntSize(&p->vEdgeLinks);
530 Vec_IntPushTwo( &p->vEdgeLinks, 0, iFlop );
531 }
532}
#define Wln_RetForEachFanout(p, iObj, iFanout, pLink, i)
Definition wlnRetime.c:56
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Wln_RetMarkChanges()

void Wln_RetMarkChanges ( Wln_Ret_t * p,
Vec_Int_t * vFront )

Definition at line 252 of file wlnRetime.c.

253{
254 int i, iObj;
255 if ( vFront )
256 {
257 Vec_IntForEachEntry( vFront, iObj, i )
258 Wln_RetMarkChanges_rec( p, iObj );
259 }
260 else
261 {
262 Vec_IntFill( &p->vPathDelays, Wln_NtkObjNum(p->pNtk), -1 );
263 Wln_NtkForEachCi( p->pNtk, iObj, i )
264 Vec_IntWriteEntry( &p->vPathDelays, iObj, 0 );
265 }
266}
void Wln_RetMarkChanges_rec(Wln_Ret_t *p, int iObj)
Definition wlnRetime.c:242
#define Wln_NtkForEachCi(p, iCi, i)
Definition wln.h:198
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Wln_RetMarkChanges_rec()

void Wln_RetMarkChanges_rec ( Wln_Ret_t * p,
int iObj )

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

Synopsis [Delay propagation.]

Description []

SideEffects []

SeeAlso []

Definition at line 242 of file wlnRetime.c.

243{
244 int k, iFanout, * pLink, * pDelay = Vec_IntEntryP( &p->vPathDelays, iObj );
245 if ( *pDelay < 0 )
246 return;
247 *pDelay = -1;
248 Wln_RetForEachFanout( p, iObj, iFanout, pLink, k )
249 if ( !pLink[0] )
250 Wln_RetMarkChanges_rec( p, iFanout );
251}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Wln_RetMarkPaths()

void Wln_RetMarkPaths ( Wln_Ntk_t * p,
int fVerbose )

Definition at line 374 of file wlnRetime.c.

375{
376 int i, iObj;
377 Wln_NtkIncrementTravId( p );
378 Wln_NtkIncrementTravId( p );
379 Wln_NtkForEachPi( p, iObj, i )
380 Wln_ObjSetTravIdPrevious( p, iObj );
381 Wln_NtkForEachPo( p, iObj, i )
382 Wln_RetMarkPaths_rec( p, Wln_ObjFanin0(p, iObj), fVerbose );
383}
int Wln_RetMarkPaths_rec(Wln_Ntk_t *p, int iObj, int fVerbose)
Definition wlnRetime.c:347
#define Wln_NtkForEachPo(p, iPo, i)
Definition wln.h:196
#define Wln_NtkForEachPi(p, iPi, i)
Definition wln.h:194
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Wln_RetMarkPaths_rec()

int Wln_RetMarkPaths_rec ( Wln_Ntk_t * p,
int iObj,
int fVerbose )

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

Synopsis [Mark paths from PIs to POs.]

Description []

SideEffects []

SeeAlso []

Definition at line 347 of file wlnRetime.c.

348{
349 int k, iFanin, fPrev = 1;
350 if ( Wln_ObjIsTravIdPrevious(p, iObj) )
351 return 1;
352 if ( Wln_ObjIsTravIdCurrent(p, iObj) )
353 return 0;
354 if ( Wln_ObjIsCio(p, iObj) || Wln_ObjIsFf(p, iObj) )
355 return 0;
356 Wln_ObjForEachFanin( p, iObj, iFanin, k )
357 fPrev &= Wln_RetMarkPaths_rec( p, iFanin, fVerbose );
358 if ( fPrev )
359 {
360 Wln_ObjSetTravIdPrevious( p, iObj );
361 if ( Vec_IntEntry(&p->vInstIds, iObj) > 0 )
362 {
363 if ( fVerbose )
364 printf( "Updating delay %5d -> %5d : ", Vec_IntEntry(&p->vInstIds, iObj), 1 );
365 if ( fVerbose )
366 Wln_ObjPrint( p, iObj );
367 Vec_IntWriteEntry( &p->vInstIds, iObj, 1 );
368 }
369 return 1;
370 }
371 Wln_ObjSetTravIdCurrent( p, iObj );
372 return 0;
373}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Wln_RetMemUsage()

int Wln_RetMemUsage ( Wln_Ret_t * p)

Definition at line 215 of file wlnRetime.c.

216{
217 int Mem = sizeof(Wln_Ret_t);
218 Mem += 4 * p->vFanins.nCap;
219 Mem += 4 * p->vFanouts.nCap;
220 Mem += 4 * p->vEdgeLinks.nCap;
221 Mem += 4 * p->vFfClasses.nCap;
222 Mem += 4 * p->vNodeDelays.nCap;
223 Mem += 4 * p->vPathDelays.nCap;
224 Mem += 4 * p->vSources.nCap;
225 Mem += 4 * p->vSinks.nCap;
226 Mem += 4 * p->vFront.nCap;
227 Mem += 4 * p->vMoves.nCap;
228 return Mem;
229}

◆ Wln_RetPrint()

void Wln_RetPrint ( Wln_Ret_t * p,
int fVerbose )

Definition at line 92 of file wlnRetime.c.

93{
94 int iObj, nCount = 0;
95 Wln_NtkForEachObj( p->pNtk, iObj )
96 if ( Wln_ObjInstId(p->pNtk, iObj) > 1 )
97 nCount++;
98 printf( "Total number of objects = %d. Objects with non-trivial delay = %d.\n", Wln_NtkObjNum(p->pNtk), nCount );
99 if ( !fVerbose )
100 {
101 int nPrints = 0, nLimit = 5;
102 printf( "The following %d objects have non-trivial delays:\n", nLimit );
103 Wln_NtkForEachObj( p->pNtk, iObj )
104 {
105 if ( Wln_ObjInstId(p->pNtk, iObj) <= 1 )
106 continue;
107 Wln_RetPrintObj( p, iObj );
108 if ( ++nPrints == nLimit )
109 break;
110 }
111 return;
112 }
113 printf( "Printing %d objects of network \"%s\":\n", Wln_NtkObjNum(p->pNtk), p->pNtk->pName );
114 Wln_NtkForEachObj( p->pNtk, iObj )
115 Wln_RetPrintObj( p, iObj );
116 printf( "\n" );
117}
void Wln_RetPrintObj(Wln_Ret_t *p, int iObj)
FUNCTION DEFINITIONS ///.
Definition wlnRetime.c:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Wln_RetPrintObj()

void Wln_RetPrintObj ( Wln_Ret_t * p,
int iObj )

FUNCTION DEFINITIONS ///.

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

Synopsis [Printing procedure.]

Description []

SideEffects []

SeeAlso []

Definition at line 76 of file wlnRetime.c.

77{
78 int k, iFanin, Type = Wln_ObjType(p->pNtk, iObj), * pLink;
79 printf( "Obj %6d : Type = %6s NameId = %5d InstId = %5d Fanins = %d : ",
80 iObj, Abc_OperName(Type), Wln_ObjNameId(p->pNtk, iObj), Wln_ObjInstId(p->pNtk, iObj), Wln_ObjFaninNum(p->pNtk, iObj) );
81 Wln_RetForEachFanin( p, iObj, iFanin, pLink, k )
82 {
83 printf( "%5d ", iFanin );
84 if ( !pLink[0] )
85 continue;
86 printf( "(%d : %d %d) ", pLink[0],
87 Vec_IntEntry(&p->vEdgeLinks, pLink[0]),
88 Vec_IntEntry(&p->vEdgeLinks, pLink[0]+1) );
89 }
90 printf( "\n" );
91}
Here is the caller graph for this function:

◆ Wln_RetPropDelay()

int Wln_RetPropDelay ( Wln_Ret_t * p)

Definition at line 285 of file wlnRetime.c.

286{
287 int iObj, DelayMax = 0;
288 Vec_IntClear( &p->vSinks );
289 Wln_NtkForEachObj( p->pNtk, iObj )
290 if ( !Wln_ObjIsCio(p->pNtk, iObj) )
291 {
292 int Delay = Wln_RetPropDelay_rec(p, iObj);
293 if ( DelayMax == Delay )
294 Vec_IntPush( &p->vSinks, iObj );
295 else if ( DelayMax < Delay )
296 {
297 DelayMax = Delay;
298 Vec_IntFill( &p->vSinks, 1, iObj );
299 }
300 }
301
302// Vec_IntForEachEntry( &p->vPathDelays, iObj, i )
303// printf( "Obj = %d. Delay = %d.\n", i, iObj );
304// printf( "\n" );
305
306// printf( "Sinks: " );
307// Vec_IntPrint( &p->vSinks );
308
309 return DelayMax;
310}
int Wln_RetPropDelay_rec(Wln_Ret_t *p, int iObj)
Definition wlnRetime.c:267
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Wln_RetPropDelay_rec()

int Wln_RetPropDelay_rec ( Wln_Ret_t * p,
int iObj )

Definition at line 267 of file wlnRetime.c.

268{
269 int k, iFanin, * pLink, * pDelay = Vec_IntEntryP( &p->vPathDelays, iObj );
270 if ( *pDelay >= 0 )
271 return *pDelay;
272 *pDelay = 0;
273 Wln_RetForEachFanin( p, iObj, iFanin, pLink, k )
274 {
275 if ( Wln_ObjIsFf(p->pNtk, iObj) && k > 0 )
276 continue;
277 if ( pLink[0] )
278 *pDelay = Abc_MaxInt(*pDelay, 0);
279 else
280 *pDelay = Abc_MaxInt(*pDelay, Wln_RetPropDelay_rec(p, iFanin));
281 }
282 *pDelay += Vec_IntEntry( &p->vNodeDelays, iObj );
283 return *pDelay;
284}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Wln_RetRemoveOneFanin()

int Wln_RetRemoveOneFanin ( Wln_Ret_t * p,
int iObj )

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

Synopsis [Moving flops.]

Description []

SideEffects []

SeeAlso []

Definition at line 473 of file wlnRetime.c.

474{
475 int k, iFanin, * pLink, iFlop, iFlop1 = -1;
476 int * pFanins = Wln_RetFanins( p, iObj );
477 Wln_RetForEachFanin( p, iObj, iFanin, pLink, k )
478 {
479 if ( Wln_ObjIsFf(p->pNtk, iObj) && k > 0 )
480 continue;
481 assert( pLink[0] );
482 iFlop = Vec_IntEntry( &p->vEdgeLinks, pLink[0] + 1 );
483 pFanins[2*k+1] = Vec_IntEntry( &p->vEdgeLinks, pLink[0] );
484 assert( Wln_ObjIsFf( p->pNtk, iFlop ) );
485 if ( iFlop1 == -1 )
486 iFlop1 = iFlop;
487 }
488 return iFlop1;
489}
Here is the caller graph for this function:

◆ Wln_RetRemoveOneFanout()

int Wln_RetRemoveOneFanout ( Wln_Ret_t * p,
int iObj )

Definition at line 490 of file wlnRetime.c.

491{
492 int k, iFanin, * pLink, iFlop, iFlop1 = -1;
493 //int * pFanins = Wln_RetFanins( p, iObj );
494 Wln_RetForEachFanout( p, iObj, iFanin, pLink, k )
495 {
496 assert( pLink[0] );
497 pLink = Wln_RetHeadToTail( p, pLink );
498 iFlop = Vec_IntEntry( &p->vEdgeLinks, pLink[0] + 1 );
499 pLink[0] = 0;
500 assert( Wln_ObjIsFf( p->pNtk, iFlop ) );
501 if ( iFlop1 == -1 )
502 iFlop1 = iFlop;
503 }
504 return iFlop1;
505}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Wln_RetRetimeBackward()

void Wln_RetRetimeBackward ( Wln_Ret_t * p,
Vec_Int_t * vSet )

Definition at line 544 of file wlnRetime.c.

545{
546 int i, iObj, iFlop;
547 Vec_IntForEachEntry( vSet, iObj, i )
548 {
549 iFlop = Wln_RetRemoveOneFanout( p, iObj );
550 if ( iFlop == -1 )
551 continue;
552 Wln_RetInsertOneFanin( p, iObj, iFlop );
553 }
554}
int Wln_RetRemoveOneFanout(Wln_Ret_t *p, int iObj)
Definition wlnRetime.c:490
void Wln_RetInsertOneFanin(Wln_Ret_t *p, int iObj, int iFlop)
Definition wlnRetime.c:506
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Wln_RetRetimeForward()

void Wln_RetRetimeForward ( Wln_Ret_t * p,
Vec_Int_t * vSet )

Definition at line 533 of file wlnRetime.c.

534{
535 int i, iObj, iFlop;
536 Vec_IntForEachEntry( vSet, iObj, i )
537 {
538 iFlop = Wln_RetRemoveOneFanin( p, iObj );
539 if ( iFlop == -1 )
540 continue;
541 Wln_RetInsertOneFanout( p, iObj, iFlop );
542 }
543}
int Wln_RetRemoveOneFanin(Wln_Ret_t *p, int iObj)
Definition wlnRetime.c:473
void Wln_RetInsertOneFanout(Wln_Ret_t *p, int iObj, int iFlop)
Definition wlnRetime.c:520
Here is the call graph for this function:
Here is the caller graph for this function: