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

Go to the source code of this file.

Functions

static ABC_NAMESPACE_IMPL_START int Abc_NtkRetimeOneWay (Abc_Ntk_t *pNtk, int fForward, int fVerbose)
 DECLARATIONS ///. More...
 
int Abc_NtkRetimeIncremental (Abc_Ntk_t *pNtk, int nDelayLim, int fForward, int fMinDelay, int fOneStep, int fVerbose)
 FUNCTION DEFINITIONS ///. More...
 
st__tableAbc_NtkRetimePrepareLatches (Abc_Ntk_t *pNtk)
 
int Abc_NtkRetimeFinalizeLatches (Abc_Ntk_t *pNtk, st__table *tLatches, int nIdMaxStart)
 
int Abc_NtkRetimeNodeIsEnabled (Abc_Obj_t *pObj, int fForward)
 
void Abc_NtkRetimeNode (Abc_Obj_t *pObj, int fForward, int fInitial)
 
int Abc_NtkRetimeCheckCompatibleLatchFanouts (Abc_Obj_t *pObj)
 
void Abc_NtkRetimeShareLatches (Abc_Ntk_t *pNtk, int fInitial)
 

Function Documentation

int Abc_NtkRetimeCheckCompatibleLatchFanouts ( Abc_Obj_t pObj)

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

Synopsis [Returns the number of compatible fanout latches.]

Description []

SideEffects []

SeeAlso []

Definition at line 396 of file retIncrem.c.

397 {
398  Abc_Obj_t * pFanout;
399  int i, nLatches = 0, Init = -1;
400  Abc_ObjForEachFanout( pObj, pFanout, i )
401  {
402  if ( !Abc_ObjIsLatch(pFanout) )
403  continue;
404  if ( Init == -1 )
405  {
406  Init = (int)(ABC_PTRUINT_T)pObj->pData;
407  nLatches++;
408  }
409  else if ( Init == (int)(ABC_PTRUINT_T)pObj->pData )
410  nLatches++;
411  }
412  return nLatches;
413 }
static int Abc_ObjIsLatch(Abc_Obj_t *pObj)
Definition: abc.h:356
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
void * pData
Definition: abc.h:145
int Abc_NtkRetimeFinalizeLatches ( Abc_Ntk_t pNtk,
st__table tLatches,
int  nIdMaxStart 
)

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

Synopsis [Finalizes the latches after retiming.]

Description [Reuses the LIs/LOs for old latches.]

SideEffects []

SeeAlso []

Definition at line 146 of file retIncrem.c.

147 {
148  Vec_Ptr_t * vCisOld, * vCosOld, * vBoxesOld, * vCisNew, * vCosNew, * vBoxesNew;
149  Abc_Obj_t * pObj, * pLatch, * pLatchIn, * pLatchOut;
150  int i, Index;
151  // create new arrays
152  vCisOld = pNtk->vCis; pNtk->vCis = NULL; vCisNew = Vec_PtrAlloc( 100 );
153  vCosOld = pNtk->vCos; pNtk->vCos = NULL; vCosNew = Vec_PtrAlloc( 100 );
154  vBoxesOld = pNtk->vBoxes; pNtk->vBoxes = NULL; vBoxesNew = Vec_PtrAlloc( 100 );
155  // copy boxes and their CIs/COs
156  Vec_PtrForEachEntryStop( Abc_Obj_t *, vCisOld, pObj, i, Vec_PtrSize(vCisOld) - st__count(tLatches) )
157  Vec_PtrPush( vCisNew, pObj );
158  Vec_PtrForEachEntryStop( Abc_Obj_t *, vCosOld, pObj, i, Vec_PtrSize(vCosOld) - st__count(tLatches) )
159  Vec_PtrPush( vCosNew, pObj );
160  Vec_PtrForEachEntryStop( Abc_Obj_t *, vBoxesOld, pObj, i, Vec_PtrSize(vBoxesOld) - st__count(tLatches) )
161  Vec_PtrPush( vBoxesNew, pObj );
162  // go through the latches
163  Abc_NtkForEachObj( pNtk, pLatch, i )
164  {
165  if ( !Abc_ObjIsLatch(pLatch) )
166  continue;
167  if ( Abc_ObjId(pLatch) >= (unsigned)nIdMaxStart )
168  {
169  // this is a new latch
170  pLatchIn = Abc_NtkCreateBi(pNtk);
171  pLatchOut = Abc_NtkCreateBo(pNtk);
172  Abc_ObjAssignName( pLatchOut, Abc_ObjName(pLatch), "_out" );
173  Abc_ObjAssignName( pLatchIn, Abc_ObjName(pLatch), "_in" );
174  }
175  else
176  {
177  // this is an old latch
178  // get its number in the original order
179  if ( ! st__lookup( tLatches, (char *)pLatch, (char **)&Index ) )
180  {
181  printf( "Abc_NtkRetimeFinalizeLatches(): Internal error.\n" );
182  return 0;
183  }
184  assert( pLatch == Vec_PtrEntry(vBoxesOld, Vec_PtrSize(vBoxesOld) - st__count(tLatches) + Index) );
185  // reconnect with the old LIs/LOs
186  pLatchIn = (Abc_Obj_t *)Vec_PtrEntry( vCosOld, Vec_PtrSize(vCosOld) - st__count(tLatches) + Index );
187  pLatchOut = (Abc_Obj_t *)Vec_PtrEntry( vCisOld, Vec_PtrSize(vCisOld) - st__count(tLatches) + Index );
188  }
189  // connect
190  Abc_ObjAddFanin( pLatchIn, Abc_ObjFanin0(pLatch) );
191  Abc_ObjPatchFanin( pLatch, Abc_ObjFanin0(pLatch), pLatchIn );
192  if ( Abc_ObjFanoutNum(pLatch) > 0 )
193  Abc_ObjTransferFanout( pLatch, pLatchOut );
194  Abc_ObjAddFanin( pLatchOut, pLatch );
195  // add to the arrays
196  Vec_PtrPush( vCisNew, pLatchOut );
197  Vec_PtrPush( vCosNew, pLatchIn );
198  Vec_PtrPush( vBoxesNew, pLatch );
199  }
200  // free useless Cis/Cos
201  Vec_PtrForEachEntry( Abc_Obj_t *, vCisOld, pObj, i )
202  if ( !Abc_ObjIsPi(pObj) && Abc_ObjFaninNum(pObj) == 0 && Abc_ObjFanoutNum(pObj) == 0 )
203  Abc_NtkDeleteObj(pObj);
204  Vec_PtrForEachEntry( Abc_Obj_t *, vCosOld, pObj, i )
205  if ( !Abc_ObjIsPo(pObj) && Abc_ObjFaninNum(pObj) == 0 && Abc_ObjFanoutNum(pObj) == 0 )
206  Abc_NtkDeleteObj(pObj);
207  // set the new arrays
208  pNtk->vCis = vCisNew; Vec_PtrFree( vCisOld );
209  pNtk->vCos = vCosNew; Vec_PtrFree( vCosOld );
210  pNtk->vBoxes = vBoxesNew; Vec_PtrFree( vBoxesOld );
211  return 1;
212 }
static unsigned Abc_ObjId(Abc_Obj_t *pObj)
Definition: abc.h:329
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Vec_Ptr_t * vBoxes
Definition: abc.h:168
static int Abc_ObjIsLatch(Abc_Obj_t *pObj)
Definition: abc.h:356
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Abc_ObjIsPi(Abc_Obj_t *pObj)
Definition: abc.h:347
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition: abcNames.c:68
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
Vec_Ptr_t * vCis
Definition: abc.h:165
static Abc_Obj_t * Abc_NtkCreateBo(Abc_Ntk_t *pNtk)
Definition: abc.h:306
ABC_DLL void Abc_ObjPatchFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFaninOld, Abc_Obj_t *pFaninNew)
Definition: abcFanio.c:172
#define st__count(table)
Definition: st.h:71
ABC_DLL void Abc_NtkDeleteObj(Abc_Obj_t *pObj)
Definition: abcObj.c:167
Vec_Ptr_t * vCos
Definition: abc.h:166
if(last==0)
Definition: sparse_int.h:34
ABC_DLL void Abc_ObjTransferFanout(Abc_Obj_t *pObjOld, Abc_Obj_t *pObjNew)
Definition: abcFanio.c:264
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
int st__lookup(st__table *table, const char *key, char **value)
Definition: st.c:114
#define Vec_PtrForEachEntryStop(Type, vVec, pEntry, i, Stop)
Definition: vecPtr.h:59
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
static int Abc_ObjIsPo(Abc_Obj_t *pObj)
Definition: abc.h:348
#define assert(ex)
Definition: util_old.h:213
static Abc_Obj_t * Abc_NtkCreateBi(Abc_Ntk_t *pNtk)
Definition: abc.h:305
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
int Abc_NtkRetimeIncremental ( Abc_Ntk_t pNtk,
int  nDelayLim,
int  fForward,
int  fMinDelay,
int  fOneStep,
int  fVerbose 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Performs retiming in one direction.]

Description [Currently does not retime over black boxes.]

SideEffects []

SeeAlso []

Definition at line 47 of file retIncrem.c.

48 {
49  Abc_Ntk_t * pNtkCopy = NULL;
50  Vec_Ptr_t * vBoxes;
51  st__table * tLatches;
52  int nLatches = Abc_NtkLatchNum(pNtk);
53  int nIdMaxStart = Abc_NtkObjNumMax(pNtk);
54  int RetValue;
55  int nIterLimit = -1; // Suppress "might be used uninitialized"
56  if ( Abc_NtkNodeNum(pNtk) == 0 )
57  return 0;
58  // reorder CI/CO/latch inputs
59  Abc_NtkOrderCisCos( pNtk );
60  if ( fMinDelay )
61  {
62  nIterLimit = fOneStep? 1 : 2 * Abc_NtkLevel(pNtk);
63  pNtkCopy = Abc_NtkDup( pNtk );
64  tLatches = Abc_NtkRetimePrepareLatches( pNtkCopy );
65  st__free_table( tLatches );
66  }
67  // collect latches and remove CIs/COs
68  tLatches = Abc_NtkRetimePrepareLatches( pNtk );
69  // share the latches
70  Abc_NtkRetimeShareLatches( pNtk, 0 );
71  // save boxes
72  vBoxes = pNtk->vBoxes; pNtk->vBoxes = NULL;
73  // perform the retiming
74  if ( fMinDelay )
75  Abc_NtkRetimeMinDelay( pNtk, pNtkCopy, nDelayLim, nIterLimit, fForward, fVerbose );
76  else
77  Abc_NtkRetimeOneWay( pNtk, fForward, fVerbose );
78  if ( fMinDelay )
79  Abc_NtkDelete( pNtkCopy );
80  // share the latches
81  Abc_NtkRetimeShareLatches( pNtk, 0 );
82  // restore boxes
83  pNtk->vBoxes = vBoxes;
84  // finalize the latches
85  RetValue = Abc_NtkRetimeFinalizeLatches( pNtk, tLatches, nIdMaxStart );
86  st__free_table( tLatches );
87  if ( RetValue == 0 )
88  return 0;
89  // fix the COs
90 // Abc_NtkLogicMakeSimpleCos( pNtk, 0 );
91  // check for correctness
92  if ( !Abc_NtkCheck( pNtk ) )
93  fprintf( stdout, "Abc_NtkRetimeForward(): Network check has failed.\n" );
94  // return the number of latches saved
95  return nLatches - Abc_NtkLatchNum(pNtk);
96 }
void st__free_table(st__table *table)
Definition: st.c:81
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
Vec_Ptr_t * vBoxes
Definition: abc.h:168
int Abc_NtkRetimeMinDelay(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkCopy, int nDelayLim, int nIterLimit, int fForward, int fVerbose)
FUNCTION DEFINITIONS ///.
Definition: retDelay.c:50
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:419
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
st__table * Abc_NtkRetimePrepareLatches(Abc_Ntk_t *pNtk)
Definition: retIncrem.c:109
void Abc_NtkRetimeShareLatches(Abc_Ntk_t *pNtk, int fInitial)
Definition: retIncrem.c:426
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
Definition: st.h:52
static ABC_NAMESPACE_IMPL_START int Abc_NtkRetimeOneWay(Abc_Ntk_t *pNtk, int fForward, int fVerbose)
DECLARATIONS ///.
Definition: retIncrem.c:225
int Abc_NtkRetimeFinalizeLatches(Abc_Ntk_t *pNtk, st__table *tLatches, int nIdMaxStart)
Definition: retIncrem.c:146
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
Definition: abcDfs.c:1265
ABC_DLL void Abc_NtkOrderCisCos(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:71
void Abc_NtkRetimeNode ( Abc_Obj_t pObj,
int  fForward,
int  fInitial 
)

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

Synopsis [Retimes the node backward or forward.]

Description []

SideEffects []

SeeAlso []

Definition at line 315 of file retIncrem.c.

316 {
317  Abc_Ntk_t * pNtkNew = NULL;
318  Vec_Ptr_t * vNodes;
319  Abc_Obj_t * pNext, * pLatch;
320  int i;
321  vNodes = Vec_PtrAlloc( 10 );
322  if ( fForward )
323  {
324  // compute the initial value
325  if ( fInitial )
326  pObj->pCopy = (Abc_Obj_t *)(ABC_PTRUINT_T)Abc_ObjSopSimulate( pObj );
327  // collect fanins
328  Abc_NodeCollectFanins( pObj, vNodes );
329  // make the node point to the fanins fanins
330  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNext, i )
331  {
332  assert( Abc_ObjIsLatch(pNext) );
333  Abc_ObjPatchFanin( pObj, pNext, Abc_ObjFanin0(pNext) );
334  if ( Abc_ObjFanoutNum(pNext) == 0 )
335  Abc_NtkDeleteObj(pNext);
336  }
337  // add a new latch on top
338  pNext = Abc_NtkCreateLatch(pObj->pNtk);
339  if ( Abc_ObjFanoutNum(pObj) > 0 )
340  Abc_ObjTransferFanout( pObj, pNext );
341  Abc_ObjAddFanin( pNext, pObj );
342  // set the initial value
343  if ( fInitial )
344  pNext->pCopy = pObj->pCopy;
345  }
346  else
347  {
348  // compute the initial value
349  if ( fInitial )
350  {
351  pNtkNew = Abc_ObjFanout0(pObj)->pCopy->pNtk;
352  Abc_NtkDupObj( pNtkNew, pObj, 0 );
353  Abc_ObjForEachFanout( pObj, pNext, i )
354  {
355  assert( Abc_ObjFaninNum(pNext->pCopy) == 0 );
356  Abc_ObjAddFanin( pNext->pCopy, pObj->pCopy );
357  }
358  }
359  // collect fanouts
360  Abc_NodeCollectFanouts( pObj, vNodes );
361  // make the fanouts fanouts point to the node
362  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pNext, i )
363  {
364  assert( Abc_ObjIsLatch(pNext) );
365  Abc_ObjTransferFanout( pNext, pObj );
366  Abc_NtkDeleteObj( pNext );
367  }
368  // add new latches to the fanins
369  Abc_ObjForEachFanin( pObj, pNext, i )
370  {
371  pLatch = Abc_NtkCreateLatch(pObj->pNtk);
372  Abc_ObjPatchFanin( pObj, pNext, pLatch );
373  Abc_ObjAddFanin( pLatch, pNext );
374  // create buffer isomorphic to this latch
375  if ( fInitial )
376  {
377  pLatch->pCopy = Abc_NtkCreateNodeBuf( pNtkNew, NULL );
378  Abc_ObjAddFanin( pObj->pCopy, pLatch->pCopy );
379  }
380  }
381  }
382  Vec_PtrFree( vNodes );
383 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_ObjIsLatch(Abc_Obj_t *pObj)
Definition: abc.h:356
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
Definition: abcObj.c:337
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL void Abc_ObjPatchFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFaninOld, Abc_Obj_t *pFaninNew)
Definition: abcFanio.c:172
Abc_Obj_t * pCopy
Definition: abc.h:148
ABC_DLL void Abc_NtkDeleteObj(Abc_Obj_t *pObj)
Definition: abcObj.c:167
int Abc_ObjSopSimulate(Abc_Obj_t *pObj)
Definition: retInit.c:93
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeBuf(Abc_Ntk_t *pNtk, Abc_Obj_t *pFanin)
Definition: abcObj.c:692
static Abc_Obj_t * Abc_NtkCreateLatch(Abc_Ntk_t *pNtk)
Definition: abc.h:309
ABC_DLL void Abc_ObjTransferFanout(Abc_Obj_t *pObjOld, Abc_Obj_t *pObjNew)
Definition: abcFanio.c:264
Abc_Ntk_t * pNtk
Definition: abc.h:130
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
ABC_DLL void Abc_NodeCollectFanins(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcUtil.c:1587
#define assert(ex)
Definition: util_old.h:213
ABC_DLL void Abc_NodeCollectFanouts(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcUtil.c:1607
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
int Abc_NtkRetimeNodeIsEnabled ( Abc_Obj_t pObj,
int  fForward 
)

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

Synopsis [Returns 1 if retiming forward/backward is possible.]

Description []

SideEffects []

SeeAlso []

Definition at line 284 of file retIncrem.c.

285 {
286  Abc_Obj_t * pNext;
287  int i;
288  assert( Abc_ObjIsNode(pObj) );
289  if ( fForward )
290  {
291  Abc_ObjForEachFanin( pObj, pNext, i )
292  if ( !Abc_ObjIsLatch(pNext) )
293  return 0;
294  }
295  else
296  {
297  Abc_ObjForEachFanout( pObj, pNext, i )
298  if ( !Abc_ObjIsLatch(pNext) )
299  return 0;
300  }
301  return 1;
302 }
static int Abc_ObjIsLatch(Abc_Obj_t *pObj)
Definition: abc.h:356
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
#define assert(ex)
Definition: util_old.h:213
int Abc_NtkRetimeOneWay ( Abc_Ntk_t pNtk,
int  fForward,
int  fVerbose 
)
static

DECLARATIONS ///.

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

FileName [retIncrem.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Retiming package.]

Synopsis [Incremental retiming in one direction.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - Oct 31, 2006.]

Revision [

Id:
retIncrem.c,v 1.00 2006/10/31 00:00:00 alanmi Exp

]

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

Synopsis [Performs retiming one way, forward or backward.]

Description []

SideEffects []

SeeAlso []

Definition at line 225 of file retIncrem.c.

226 {
227  Abc_Ntk_t * pNtkNew = NULL; // Suppress "might be used uninitialized"
228  Vec_Int_t * vValues = NULL; // Suppress "might be used uninitialized"
229  Abc_Obj_t * pObj;
230  int i, fChanges, nTotalMoves = 0, nTotalMovesLimit = 10000;
231  if ( fForward )
233  else
234  {
235  // save initial values of the latches
236  vValues = Abc_NtkRetimeCollectLatchValues( pNtk );
237  // start the network for initial value computation
238  pNtkNew = Abc_NtkRetimeBackwardInitialStart( pNtk );
239  }
240  // try to move latches forward whenever possible
241  do {
242  fChanges = 0;
243  Abc_NtkForEachObj( pNtk, pObj, i )
244  {
245  if ( !Abc_ObjIsNode(pObj) )
246  continue;
247  if ( Abc_NtkRetimeNodeIsEnabled( pObj, fForward ) )
248  {
249  Abc_NtkRetimeNode( pObj, fForward, 1 );
250  fChanges = 1;
251  nTotalMoves++;
252  if ( nTotalMoves >= nTotalMovesLimit )
253  {
254  printf( "Stopped after %d latch moves.\n", nTotalMoves );
255  break;
256  }
257  }
258  }
259  } while ( fChanges && nTotalMoves < nTotalMovesLimit );
260  // transfer the initial state back to the latches
261  if ( fForward )
263  else
264  {
265  Abc_NtkRetimeBackwardInitialFinish( pNtk, pNtkNew, vValues, fVerbose );
266  Abc_NtkDelete( pNtkNew );
267  Vec_IntFree( vValues );
268  }
269  return 0;
270 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
Abc_Ntk_t * Abc_NtkRetimeBackwardInitialStart(Abc_Ntk_t *pNtk)
Definition: retInit.c:254
void Abc_NtkRetimeTranferToCopy(Abc_Ntk_t *pNtk)
Definition: retInit.c:168
Vec_Int_t * Abc_NtkRetimeCollectLatchValues(Abc_Ntk_t *pNtk)
Definition: retInit.c:208
void Abc_NtkRetimeNode(Abc_Obj_t *pObj, int fForward, int fInitial)
Definition: retIncrem.c:315
int Abc_NtkRetimeNodeIsEnabled(Abc_Obj_t *pObj, int fForward)
Definition: retIncrem.c:284
void Abc_NtkRetimeBackwardInitialFinish(Abc_Ntk_t *pNtk, Abc_Ntk_t *pNtkNew, Vec_Int_t *vValuesOld, int fVerbose)
Definition: retInit.c:279
void Abc_NtkRetimeTranferFromCopy(Abc_Ntk_t *pNtk)
Definition: retInit.c:188
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
st__table* Abc_NtkRetimePrepareLatches ( Abc_Ntk_t pNtk)

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

Synopsis [Prepares the network for retiming.]

Description [Hash latches into their number in the original network.]

SideEffects []

SeeAlso []

Definition at line 109 of file retIncrem.c.

110 {
111  st__table * tLatches;
112  Abc_Obj_t * pLatch, * pLatchIn, * pLatchOut, * pFanin;
113  int i, nOffSet = Abc_NtkBoxNum(pNtk) - Abc_NtkLatchNum(pNtk);
114  // collect latches and remove CIs/COs
115  tLatches = st__init_table( st__ptrcmp, st__ptrhash );
116  Abc_NtkForEachLatch( pNtk, pLatch, i )
117  {
118  // map latch into its true number
119  st__insert( tLatches, (char *)(ABC_PTRUINT_T)pLatch, (char *)(ABC_PTRUINT_T)(i-nOffSet) );
120  // disconnect LI
121  pLatchIn = Abc_ObjFanin0(pLatch);
122  pFanin = Abc_ObjFanin0(pLatchIn);
123  Abc_ObjTransferFanout( pLatchIn, pFanin );
124  Abc_ObjDeleteFanin( pLatchIn, pFanin );
125  // disconnect LO
126  pLatchOut = Abc_ObjFanout0(pLatch);
127  pFanin = Abc_ObjFanin0(pLatchOut);
128  if ( Abc_ObjFanoutNum(pLatchOut) > 0 )
129  Abc_ObjTransferFanout( pLatchOut, pFanin );
130  Abc_ObjDeleteFanin( pLatchOut, pFanin );
131  }
132  return tLatches;
133 }
int st__insert(st__table *table, const char *key, char *value)
Definition: st.c:171
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
static int Abc_NtkBoxNum(Abc_Ntk_t *pNtk)
Definition: abc.h:289
int st__ptrcmp(const char *, const char *)
Definition: st.c:480
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
Definition: st.h:52
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
ABC_DLL void Abc_ObjTransferFanout(Abc_Obj_t *pObjOld, Abc_Obj_t *pObjNew)
Definition: abcFanio.c:264
ABC_DLL void Abc_ObjDeleteFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:111
int st__ptrhash(const char *, int)
Definition: st.c:468
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
void Abc_NtkRetimeShareLatches ( Abc_Ntk_t pNtk,
int  fInitial 
)

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

Synopsis [Retimes the node backward or forward.]

Description []

SideEffects []

SeeAlso []

Definition at line 426 of file retIncrem.c.

427 {
428  Vec_Ptr_t * vNodes;
429  Abc_Obj_t * pFanin, * pLatchTop, * pLatchCur;
430  int i, k;
431  vNodes = Vec_PtrAlloc( 10 );
432  // consider latch fanins
433  Abc_NtkForEachObj( pNtk, pFanin, i )
434  {
435  if ( Abc_NtkRetimeCheckCompatibleLatchFanouts(pFanin) <= 1 )
436  continue;
437  // get the first latch
438  pLatchTop = NULL;
439  Abc_ObjForEachFanout( pFanin, pLatchTop, k )
440  if ( Abc_ObjIsLatch(pLatchTop) )
441  break;
442  assert( pLatchTop && Abc_ObjIsLatch(pLatchTop) );
443  // redirect compatible fanout latches to the first latch
444  Abc_NodeCollectFanouts( pFanin, vNodes );
445  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pLatchCur, k )
446  {
447  if ( !Abc_ObjIsLatch(pLatchCur) )
448  continue;
449  if ( pLatchCur == pLatchTop )
450  continue;
451  if ( pLatchCur->pData != pLatchTop->pData )
452  continue;
453  // connect the initial state
454  if ( fInitial )
455  Abc_ObjAddFanin( pLatchCur->pCopy, pLatchTop->pCopy );
456  // redirect the fanouts
457  Abc_ObjTransferFanout( pLatchCur, pLatchTop );
458  Abc_NtkDeleteObj(pLatchCur);
459  }
460  }
461  Vec_PtrFree( vNodes );
462 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
int Abc_NtkRetimeCheckCompatibleLatchFanouts(Abc_Obj_t *pObj)
Definition: retIncrem.c:396
static int Abc_ObjIsLatch(Abc_Obj_t *pObj)
Definition: abc.h:356
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
ABC_DLL void Abc_NtkDeleteObj(Abc_Obj_t *pObj)
Definition: abcObj.c:167
if(last==0)
Definition: sparse_int.h:34
ABC_DLL void Abc_ObjTransferFanout(Abc_Obj_t *pObjOld, Abc_Obj_t *pObjNew)
Definition: abcFanio.c:264
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define assert(ex)
Definition: util_old.h:213
ABC_DLL void Abc_NodeCollectFanouts(Abc_Obj_t *pNode, Vec_Ptr_t *vNodes)
Definition: abcUtil.c:1607
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223