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

Go to the source code of this file.

Macros

#define Aig_ObjForEachFanoutStatic(pObj, pFan, i)   for ( i = 0; (i < (int)(pObj)->nRefs) && ((pFan) = Aig_ObjFanoutStatic(pObj, i)); i++ )
 

Functions

static
ABC_NAMESPACE_IMPL_START
Aig_Obj_t
Aig_ObjFanoutStatic (Aig_Obj_t *pObj, int i)
 DECLARATIONS ///. More...
 
static void Aig_ObjSetFanoutStatic (Aig_Obj_t *pObj, Aig_Obj_t *pFan)
 
Aig_Obj_t ** Aig_ManStaticFanoutStart (Aig_Man_t *p)
 FUNCTION DEFINITIONS ///. More...
 
void Aig_ManMarkAutonomous_rec (Aig_Man_t *p, Aig_Obj_t *pObj)
 
void Saig_ManMarkAutonomous (Aig_Man_t *p)
 
Aig_Man_tSaig_ManRetimeForwardOne (Aig_Man_t *p, int *pnRegFixed, int *pnRegMoves)
 
Aig_Man_tSaig_ManRetimeForward (Aig_Man_t *p, int nMaxIters, int fVerbose)
 

Macro Definition Documentation

#define Aig_ObjForEachFanoutStatic (   pObj,
  pFan,
 
)    for ( i = 0; (i < (int)(pObj)->nRefs) && ((pFan) = Aig_ObjFanoutStatic(pObj, i)); i++ )

Definition at line 33 of file saigRetFwd.c.

Function Documentation

void Aig_ManMarkAutonomous_rec ( Aig_Man_t p,
Aig_Obj_t pObj 
)

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

Synopsis [Marks the objects reachable from the given object.]

Description []

SideEffects []

SeeAlso []

Definition at line 89 of file saigRetFwd.c.

90 {
91  Aig_Obj_t * pFanout;
92  int i;
93  if ( Aig_ObjIsTravIdCurrent(p, pObj) )
94  return;
96  Aig_ObjForEachFanoutStatic( pObj, pFanout, i )
97  Aig_ManMarkAutonomous_rec( p, pFanout );
98 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Aig_ObjIsTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:295
void Aig_ManMarkAutonomous_rec(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: saigRetFwd.c:89
static void Aig_ObjSetTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:293
Definition: aig.h:69
#define Aig_ObjForEachFanoutStatic(pObj, pFan, i)
Definition: saigRetFwd.c:33
Aig_Obj_t** Aig_ManStaticFanoutStart ( Aig_Man_t p)

FUNCTION DEFINITIONS ///.

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

Synopsis [Allocate static fanout for all nodes in the AIG manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 51 of file saigRetFwd.c.

52 {
53  Aig_Obj_t ** ppFanouts, * pObj;
54  int i, nFanouts, nFanoutsAlloc;
55  // allocate fanouts
56  nFanoutsAlloc = 2 * Aig_ManObjNumMax(p) - Aig_ManCiNum(p) - Aig_ManCoNum(p);
57  ppFanouts = ABC_ALLOC( Aig_Obj_t *, nFanoutsAlloc );
58  // mark up storage
59  nFanouts = 0;
60  Aig_ManForEachObj( p, pObj, i )
61  {
62  pObj->pData = ppFanouts + nFanouts;
63  nFanouts += pObj->nRefs;
64  pObj->nRefs = 0;
65  }
66  assert( nFanouts < nFanoutsAlloc );
67  // add fanouts
68  Aig_ManForEachObj( p, pObj, i )
69  {
70  if ( Aig_ObjChild0(pObj) )
72  if ( Aig_ObjChild1(pObj) )
74  }
75  return ppFanouts;
76 }
static Aig_Obj_t * Aig_ObjChild0(Aig_Obj_t *pObj)
Definition: aig.h:310
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void * pData
Definition: aig.h:87
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
static Aig_Obj_t * Aig_ObjChild1(Aig_Obj_t *pObj)
Definition: aig.h:311
Definition: aig.h:69
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static void Aig_ObjSetFanoutStatic(Aig_Obj_t *pObj, Aig_Obj_t *pFan)
Definition: saigRetFwd.c:31
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
#define assert(ex)
Definition: util_old.h:213
unsigned int nRefs
Definition: aig.h:81
static ABC_NAMESPACE_IMPL_START Aig_Obj_t* Aig_ObjFanoutStatic ( Aig_Obj_t pObj,
int  i 
)
inlinestatic

DECLARATIONS ///.

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

FileName [saigRetFwd.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Sequential AIG package.]

Synopsis [Most-forward retiming.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 30 of file saigRetFwd.c.

30 { return ((Aig_Obj_t **)pObj->pData)[i]; }
void * pData
Definition: aig.h:87
Definition: aig.h:69
static void Aig_ObjSetFanoutStatic ( Aig_Obj_t pObj,
Aig_Obj_t pFan 
)
inlinestatic

Definition at line 31 of file saigRetFwd.c.

31 { ((Aig_Obj_t **)pObj->pData)[pObj->nRefs++] = pFan; }
void * pData
Definition: aig.h:87
Definition: aig.h:69
unsigned int nRefs
Definition: aig.h:81
void Saig_ManMarkAutonomous ( Aig_Man_t p)

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

Synopsis [Marks with current trav ID nodes reachable from Const1 and PIs.]

Description [Returns the number of unreachable registers.]

SideEffects []

SeeAlso []

Definition at line 111 of file saigRetFwd.c.

112 {
113  Aig_Obj_t ** ppFanouts;
114  Aig_Obj_t * pObj, * pObjLi, * pObjLo;
115  int i;
116  // temporarily connect register outputs to register inputs
117  Saig_ManForEachLiLo( p, pObjLi, pObjLo, i )
118  {
119  pObjLo->pFanin0 = pObjLi;
120  pObjLi->nRefs = 1;
121  }
122  // mark nodes reachable from Const1 and PIs
124  ppFanouts = Aig_ManStaticFanoutStart( p );
126  Saig_ManForEachPi( p, pObj, i )
127  Aig_ManMarkAutonomous_rec( p, pObj );
128  ABC_FREE( ppFanouts );
129  // disconnect LIs/LOs and label unreachable registers
130  Saig_ManForEachLiLo( p, pObjLi, pObjLo, i )
131  {
132  assert( pObjLo->pFanin0 && pObjLi->nRefs == 1 );
133  pObjLo->pFanin0 = NULL;
134  pObjLi->nRefs = 0;
135  }
136 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Saig_ManForEachLiLo(p, pObjLi, pObjLo, i)
Definition: saig.h:101
void Aig_ManMarkAutonomous_rec(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: saigRetFwd.c:89
void Aig_ManIncrementTravId(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigUtil.c:44
Definition: aig.h:69
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define assert(ex)
Definition: util_old.h:213
Aig_Obj_t * pFanin0
Definition: aig.h:75
unsigned int nRefs
Definition: aig.h:81
Aig_Obj_t ** Aig_ManStaticFanoutStart(Aig_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition: saigRetFwd.c:51
#define Saig_ManForEachPi(p, pObj, i)
Definition: saig.h:91
Aig_Man_t* Saig_ManRetimeForward ( Aig_Man_t p,
int  nMaxIters,
int  fVerbose 
)

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

Synopsis [Derives the cut for forward retiming.]

Description [Assumes topological ordering of the nodes.]

SideEffects []

SeeAlso []

Definition at line 213 of file saigRetFwd.c.

214 {
215  Aig_Man_t * pNew, * pTemp;
216  int i, nRegFixed, nRegMoves = 1;
217  abctime clk;
218  pNew = p;
219  for ( i = 0; i < nMaxIters && nRegMoves > 0; i++ )
220  {
221  clk = Abc_Clock();
222  pNew = Saig_ManRetimeForwardOne( pTemp = pNew, &nRegFixed, &nRegMoves );
223  if ( fVerbose )
224  {
225  printf( "%2d : And = %6d. Reg = %5d. Unret = %5d. Move = %6d. ",
226  i + 1, Aig_ManNodeNum(pTemp), Aig_ManRegNum(pTemp), nRegFixed, nRegMoves );
227  ABC_PRT( "Time", Abc_Clock() - clk );
228  }
229  if ( pTemp != p )
230  Aig_ManStop( pTemp );
231  }
232  clk = Abc_Clock();
233  pNew = Aig_ManReduceLaches( pNew, fVerbose );
234  if ( fVerbose )
235  {
236  ABC_PRT( "Register sharing time", Abc_Clock() - clk );
237  }
238  return pNew;
239 }
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
Aig_Man_t * Aig_ManReduceLaches(Aig_Man_t *p, int fVerbose)
Definition: aigScl.c:455
Aig_Man_t * Saig_ManRetimeForwardOne(Aig_Man_t *p, int *pnRegFixed, int *pnRegMoves)
Definition: saigRetFwd.c:149
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
#define ABC_PRT(a, t)
Definition: abc_global.h:220
ABC_INT64_T abctime
Definition: abc_global.h:278
Aig_Man_t* Saig_ManRetimeForwardOne ( Aig_Man_t p,
int *  pnRegFixed,
int *  pnRegMoves 
)

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

Synopsis [Derives the cut for forward retiming.]

Description [Assumes topological ordering of the nodes.]

SideEffects []

SeeAlso []

Definition at line 149 of file saigRetFwd.c.

150 {
151  Aig_Man_t * pNew;
152  Vec_Ptr_t * vCut;
153  Aig_Obj_t * pObj, * pFanin;
154  int i;
155  // mark the retimable nodes
157  // mark the retimable registers with the fresh trav ID
159  *pnRegFixed = 0;
160  Saig_ManForEachLo( p, pObj, i )
161  if ( Aig_ObjIsTravIdPrevious(p, pObj) )
162  Aig_ObjSetTravIdCurrent(p, pObj);
163  else
164  (*pnRegFixed)++;
165  // mark all the nodes that can be retimed forward
166  *pnRegMoves = 0;
167  Aig_ManForEachNode( p, pObj, i )
169  {
170  Aig_ObjSetTravIdCurrent(p, pObj);
171  (*pnRegMoves)++;
172  }
173  // mark the remaining registers
174  Saig_ManForEachLo( p, pObj, i )
175  Aig_ObjSetTravIdCurrent(p, pObj);
176  // find the cut (all such marked objects that fanout into unmarked nodes)
177  vCut = Vec_PtrAlloc( 1000 );
179  Aig_ManForEachObj( p, pObj, i )
180  {
181  if ( Aig_ObjIsTravIdPrevious(p, pObj) )
182  continue;
183  pFanin = Aig_ObjFanin0(pObj);
184  if ( pFanin && Aig_ObjIsTravIdPrevious(p, pFanin) )
185  {
186  Vec_PtrPush( vCut, pFanin );
187  Aig_ObjSetTravIdCurrent( p, pFanin );
188  }
189  pFanin = Aig_ObjFanin1(pObj);
190  if ( pFanin && Aig_ObjIsTravIdPrevious(p, pFanin) )
191  {
192  Vec_PtrPush( vCut, pFanin );
193  Aig_ObjSetTravIdCurrent( p, pFanin );
194  }
195  }
196  // finally derive the new manager
197  pNew = Saig_ManRetimeDupForward( p, vCut );
198  Vec_PtrFree( vCut );
199  return pNew;
200 }
static int Aig_ObjIsTravIdPrevious(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:296
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Aig_ObjIsTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:295
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static void Aig_ObjSetTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:293
void Aig_ManIncrementTravId(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigUtil.c:44
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
Aig_Man_t * Saig_ManRetimeDupForward(Aig_Man_t *p, Vec_Ptr_t *vCut)
Definition: saigRetMin.c:281
Definition: aig.h:69
#define Saig_ManForEachLo(p, pObj, i)
Definition: saig.h:96
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
void Saig_ManMarkAutonomous(Aig_Man_t *p)
Definition: saigRetFwd.c:111
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223