abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcLatch.c File Reference
#include "abc.h"
#include "misc/extra/extraBdd.h"
#include "aig/gia/giaAig.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Abc_NtkLatchIsSelfFeed_rec (Abc_Obj_t *pLatch, Abc_Obj_t *pLatchRoot)
 DECLARATIONS ///. More...
 
int Abc_NtkLatchIsSelfFeed (Abc_Obj_t *pLatch)
 
int Abc_NtkCountSelfFeedLatches (Abc_Ntk_t *pNtk)
 
int Abc_NtkRemoveSelfFeedLatches (Abc_Ntk_t *pNtk)
 
void Abc_NtkLatchPipe (Abc_Ntk_t *pNtk, int nLatches)
 
Vec_Int_tAbc_NtkCollectLatchValues (Abc_Ntk_t *pNtk)
 
char * Abc_NtkCollectLatchValuesStr (Abc_Ntk_t *pNtk)
 
void Abc_NtkInsertLatchValues (Abc_Ntk_t *pNtk, Vec_Int_t *vValues)
 
Abc_Obj_tAbc_NtkAddLatch (Abc_Ntk_t *pNtk, Abc_Obj_t *pDriver, Abc_InitType_t Init)
 
void Abc_NtkNodeConvertToMux (Abc_Ntk_t *pNtk, Abc_Obj_t *pNodeC, Abc_Obj_t *pNode1, Abc_Obj_t *pNode0, Abc_Obj_t *pMux)
 
void Abc_NtkConvertDcLatches (Abc_Ntk_t *pNtk)
 
Vec_Ptr_tAbc_NtkConverLatchNamesIntoNumbers (Abc_Ntk_t *pNtk)
 
Abc_Ntk_tAbc_NtkConvertOnehot (Abc_Ntk_t *pNtk)
 
ABC_NAMESPACE_IMPL_END
ABC_NAMESPACE_IMPL_START
Aig_Man_t
Abc_NtkRetimeWithClassesAig (Aig_Man_t *pMan, Vec_Int_t *vClasses, Vec_Int_t **pvClasses, int fVerbose)
 
Abc_Ntk_tAbc_NtkRetimeWithClassesNtk (Abc_Ntk_t *pNtk, Vec_Int_t *vClasses, Vec_Int_t **pvClasses, int fVerbose)
 
void Abc_NtkTransformBack (Abc_Ntk_t *pNtkOld, Abc_Ntk_t *pNtkNew, Vec_Ptr_t *vControls, Vec_Int_t *vClasses)
 
Abc_Ntk_tAbc_NtkCRetime (Abc_Ntk_t *pNtk, int fVerbose)
 
int Abc_NtkVerifyCex (Abc_Ntk_t *pNtk, Abc_Cex_t *p)
 

Function Documentation

Abc_Obj_t* Abc_NtkAddLatch ( Abc_Ntk_t pNtk,
Abc_Obj_t pDriver,
Abc_InitType_t  Init 
)

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

Synopsis [Creates latch with the given initial value.]

Description []

SideEffects []

SeeAlso []

Definition at line 260 of file abcLatch.c.

261 {
262  Abc_Obj_t * pLatchOut, * pLatch, * pLatchIn;
263  pLatchOut = Abc_NtkCreateBo(pNtk);
264  pLatch = Abc_NtkCreateLatch(pNtk);
265  pLatchIn = Abc_NtkCreateBi(pNtk);
266  Abc_ObjAssignName( pLatchOut, Abc_ObjName(pLatch), "_lo" );
267  Abc_ObjAssignName( pLatchIn, Abc_ObjName(pLatch), "_li" );
268  Abc_ObjAddFanin( pLatchOut, pLatch );
269  Abc_ObjAddFanin( pLatch, pLatchIn );
270  if ( pDriver )
271  Abc_ObjAddFanin( pLatchIn, pDriver );
272  pLatch->pData = (void *)Init;
273  return pLatchOut;
274 }
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition: abcNames.c:68
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
static Abc_Obj_t * Abc_NtkCreateBo(Abc_Ntk_t *pNtk)
Definition: abc.h:306
static Abc_Obj_t * Abc_NtkCreateLatch(Abc_Ntk_t *pNtk)
Definition: abc.h:309
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
void * pData
Definition: abc.h:145
static Abc_Obj_t * Abc_NtkCreateBi(Abc_Ntk_t *pNtk)
Definition: abc.h:305
Vec_Int_t* Abc_NtkCollectLatchValues ( Abc_Ntk_t pNtk)

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

Synopsis [Strashes one logic node using its SOP.]

Description []

SideEffects []

SeeAlso []

Definition at line 187 of file abcLatch.c.

188 {
189  Vec_Int_t * vValues;
190  Abc_Obj_t * pLatch;
191  int i;
192  vValues = Vec_IntAlloc( Abc_NtkLatchNum(pNtk) );
193  Abc_NtkForEachLatch( pNtk, pLatch, i )
194  Vec_IntPush( vValues, Abc_LatchIsInit1(pLatch) );
195  return vValues;
196 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
static int Abc_LatchIsInit1(Abc_Obj_t *pLatch)
Definition: abc.h:423
char* Abc_NtkCollectLatchValuesStr ( Abc_Ntk_t pNtk)

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

Synopsis [Derives latch init string.]

Description []

SideEffects []

SeeAlso []

Definition at line 209 of file abcLatch.c.

210 {
211  char * pInits;
212  Abc_Obj_t * pLatch;
213  int i;
214  pInits = ABC_ALLOC( char, Abc_NtkLatchNum(pNtk) + 1 );
215  Abc_NtkForEachLatch( pNtk, pLatch, i )
216  {
217  if ( Abc_LatchIsInit0(pLatch) )
218  pInits[i] = '0';
219  else if ( Abc_LatchIsInit1(pLatch) )
220  pInits[i] = '1';
221  else if ( Abc_LatchIsInitDc(pLatch) )
222  pInits[i] = 'x';
223  else
224  assert( 0 );
225  }
226  pInits[i] = 0;
227  return pInits;
228 }
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
static int Abc_LatchIsInit0(Abc_Obj_t *pLatch)
Definition: abc.h:422
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Abc_LatchIsInitDc(Abc_Obj_t *pLatch)
Definition: abc.h:424
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
static int Abc_LatchIsInit1(Abc_Obj_t *pLatch)
Definition: abc.h:423
#define assert(ex)
Definition: util_old.h:213
Vec_Ptr_t* Abc_NtkConverLatchNamesIntoNumbers ( Abc_Ntk_t pNtk)

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

Synopsis [Transfors the array of latch names into that of latch numbers.]

Description []

SideEffects []

SeeAlso []

Definition at line 368 of file abcLatch.c.

369 {
370  Vec_Ptr_t * vResult, * vNames;
371  Vec_Int_t * vNumbers;
372  Abc_Obj_t * pObj;
373  char * pName;
374  int i, k, Num;
375  if ( pNtk->vOnehots == NULL )
376  return NULL;
377  // set register numbers
378  Abc_NtkForEachLatch( pNtk, pObj, i )
379  pObj->pNext = (Abc_Obj_t *)(ABC_PTRINT_T)i;
380  // add the numbers
381  vResult = Vec_PtrAlloc( Vec_PtrSize(pNtk->vOnehots) );
382  Vec_PtrForEachEntry( Vec_Ptr_t *, pNtk->vOnehots, vNames, i )
383  {
384  vNumbers = Vec_IntAlloc( Vec_PtrSize(vNames) );
385  Vec_PtrForEachEntry( char *, vNames, pName, k )
386  {
387  Num = Nm_ManFindIdByName( pNtk->pManName, pName, ABC_OBJ_BO );
388  if ( Num < 0 )
389  continue;
390  pObj = Abc_NtkObj( pNtk, Num );
391  if ( Abc_ObjFaninNum(pObj) != 1 || !Abc_ObjIsLatch(Abc_ObjFanin0(pObj)) )
392  continue;
393  Vec_IntPush( vNumbers, (int)(ABC_PTRINT_T)pObj->pNext );
394  }
395  if ( Vec_IntSize( vNumbers ) > 1 )
396  {
397  Vec_PtrPush( vResult, vNumbers );
398 printf( "Converted %d one-hot registers.\n", Vec_IntSize(vNumbers) );
399  }
400  else
401  Vec_IntFree( vNumbers );
402  }
403  // clean the numbers
404  Abc_NtkForEachLatch( pNtk, pObj, i )
405  pObj->pNext = NULL;
406  return vResult;
407 }
int Nm_ManFindIdByName(Nm_Man_t *p, char *pName, int Type)
Definition: nmApi.c:219
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Nm_Man_t * pManName
Definition: abc.h:160
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Abc_ObjIsLatch(Abc_Obj_t *pObj)
Definition: abc.h:356
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static Abc_Obj_t * Abc_NtkObj(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:314
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
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
Vec_Ptr_t * vOnehots
Definition: abc.h:211
Definition: abc.h:92
Abc_Obj_t * pNext
Definition: abc.h:131
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
void Abc_NtkConvertDcLatches ( Abc_Ntk_t pNtk)

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

Synopsis [Converts registers with DC values into additional PIs.]

Description []

SideEffects []

SeeAlso []

Definition at line 314 of file abcLatch.c.

315 {
316  Abc_Obj_t * pCtrl, * pLatch, * pMux, * pPi;
318  int i, fFound = 0, Counter;
319  // check if there are latches with DC values
320  Abc_NtkForEachLatch( pNtk, pLatch, i )
321  if ( Abc_LatchIsInitDc(pLatch) )
322  {
323  fFound = 1;
324  break;
325  }
326  if ( !fFound )
327  return;
328  // add control latch
329  pCtrl = Abc_NtkAddLatch( pNtk, Abc_NtkCreateNodeConst1(pNtk), Init );
330  // add fanouts for each latch with DC values
331  Counter = 0;
332  Abc_NtkForEachLatch( pNtk, pLatch, i )
333  {
334  if ( !Abc_LatchIsInitDc(pLatch) )
335  continue;
336  // change latch value
337  pLatch->pData = (void *)Init;
338  // if the latch output has the same name as a PO, rename it
339  if ( Abc_NodeFindCoFanout( Abc_ObjFanout0(pLatch) ) )
340  {
341  Nm_ManDeleteIdName( pLatch->pNtk->pManName, Abc_ObjFanout0(pLatch)->Id );
342  Abc_ObjAssignName( Abc_ObjFanout0(pLatch), Abc_ObjName(pLatch), "_lo" );
343  }
344  // create new PIs
345  pPi = Abc_NtkCreatePi( pNtk );
346  Abc_ObjAssignName( pPi, Abc_ObjName(pLatch), "_pi" );
347  // create a new node and transfer fanout from latch output to the new node
348  pMux = Abc_NtkCreateNode( pNtk );
349  Abc_ObjTransferFanout( Abc_ObjFanout0(pLatch), pMux );
350  // convert the node into a mux
351  Abc_NtkNodeConvertToMux( pNtk, pCtrl, Abc_ObjFanout0(pLatch), pPi, pMux );
352  Counter++;
353  }
354  printf( "The number of converted latches with DC values = %d.\n", Counter );
355 }
Abc_Obj_t * Abc_NtkAddLatch(Abc_Ntk_t *pNtk, Abc_Obj_t *pDriver, Abc_InitType_t Init)
Definition: abcLatch.c:260
void Nm_ManDeleteIdName(Nm_Man_t *p, int ObjId)
Definition: nmApi.c:149
Nm_Man_t * pManName
Definition: abc.h:160
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
Definition: abcObj.c:633
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition: abcNames.c:68
void Abc_NtkNodeConvertToMux(Abc_Ntk_t *pNtk, Abc_Obj_t *pNodeC, Abc_Obj_t *pNode1, Abc_Obj_t *pNode0, Abc_Obj_t *pMux)
Definition: abcLatch.c:287
static int Abc_LatchIsInitDc(Abc_Obj_t *pLatch)
Definition: abc.h:424
if(last==0)
Definition: sparse_int.h:34
static int Counter
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
static Abc_Obj_t * Abc_NtkCreatePi(Abc_Ntk_t *pNtk)
Definition: abc.h:303
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
ABC_DLL Abc_Obj_t * Abc_NodeFindCoFanout(Abc_Obj_t *pNode)
Definition: abcUtil.c:779
Abc_InitType_t
Definition: abc.h:102
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
void * pData
Definition: abc.h:145
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
Abc_Ntk_t* Abc_NtkConvertOnehot ( Abc_Ntk_t pNtk)

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

Synopsis [Converts registers with DC values into additional PIs.]

Description []

SideEffects []

SeeAlso []

Definition at line 421 of file abcLatch.c.

422 {
423  Vec_Ptr_t * vNodes;
424  Abc_Ntk_t * pNtkNew;
425  Abc_Obj_t * pObj, * pFanin, * pObjNew, * pObjLiNew, * pObjLoNew;
426  int i, k, nFlops, nStates, iState, pfCompl[32];
427  assert( Abc_NtkIsLogic(pNtk) );
428  nFlops = Abc_NtkLatchNum(pNtk);
429  if ( nFlops == 0 )
430  return Abc_NtkDup( pNtk );
431  if ( nFlops > 16 )
432  {
433  printf( "Cannot reencode %d flops because it will lead to 2^%d states.\n", nFlops, nFlops );
434  return NULL;
435  }
436  // check if there are latches with DC values
437  iState = 0;
438  Abc_NtkForEachLatch( pNtk, pObj, i )
439  {
440  if ( Abc_LatchIsInitDc(pObj) )
441  {
442  printf( "Cannot process logic network with don't-care init values. Run \"zero\".\n" );
443  return NULL;
444  }
445  if ( Abc_LatchIsInit1(pObj) )
446  iState |= (1 << i);
447  }
448  // transfer logic to SOPs
449  Abc_NtkToSop( pNtk, 0 );
450  // create new network
451  pNtkNew = Abc_NtkStartFromNoLatches( pNtk, pNtk->ntkType, pNtk->ntkFunc );
452  nStates = (1 << nFlops);
453  for ( i = 0; i < nStates; i++ )
454  {
455  pObjNew = Abc_NtkCreateLatch( pNtkNew );
456  pObjLiNew = Abc_NtkCreateBi( pNtkNew );
457  pObjLoNew = Abc_NtkCreateBo( pNtkNew );
458  Abc_ObjAddFanin( pObjNew, pObjLiNew );
459  Abc_ObjAddFanin( pObjLoNew, pObjNew );
460  if ( i == iState )
461  Abc_LatchSetInit1( pObjNew );
462  else
463  Abc_LatchSetInit0( pObjNew );
464  }
465  Abc_NtkAddDummyBoxNames( pNtkNew );
466  assert( Abc_NtkLatchNum(pNtkNew) == nStates );
467  assert( Abc_NtkPiNum(pNtkNew) == Abc_NtkPiNum(pNtk) );
468  assert( Abc_NtkPoNum(pNtkNew) == Abc_NtkPoNum(pNtk) );
469  assert( Abc_NtkCiNum(pNtkNew) == Abc_NtkPiNum(pNtkNew) + nStates );
470  assert( Abc_NtkCoNum(pNtkNew) == Abc_NtkPoNum(pNtkNew) + nStates );
471  assert( Abc_NtkCiNum(pNtk) == Abc_NtkPiNum(pNtk) + nFlops );
472  assert( Abc_NtkCoNum(pNtk) == Abc_NtkPoNum(pNtk) + nFlops );
473  // create hot-to-log transformers
474  for ( i = 0; i < nFlops; i++ )
475  {
476  pObjNew = Abc_NtkCreateNode( pNtkNew );
477  for ( k = 0; k < nStates; k++ )
478  if ( (k >> i) & 1 )
479  Abc_ObjAddFanin( pObjNew, Abc_NtkCi(pNtkNew, Abc_NtkPiNum(pNtkNew)+k) );
480  assert( Abc_ObjFaninNum(pObjNew) == nStates/2 );
481  pObjNew->pData = Abc_SopCreateOr( (Mem_Flex_t *)pNtkNew->pManFunc, nStates/2, NULL );
482  // save the new flop
483  pObj = Abc_NtkCi( pNtk, Abc_NtkPiNum(pNtk) + i );
484  pObj->pCopy = pObjNew;
485  }
486  // duplicate the nodes
487  vNodes = Abc_NtkDfs( pNtk, 0 );
488  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
489  {
490  pObj->pCopy = Abc_NtkDupObj( pNtkNew, pObj, 1 );
491  Abc_ObjForEachFanin( pObj, pFanin, k )
492  Abc_ObjAddFanin( pObj->pCopy, pFanin->pCopy );
493  }
494  Vec_PtrFree( vNodes );
495  // connect the POs
496  Abc_NtkForEachPo( pNtk, pObj, i )
497  Abc_ObjAddFanin( pObj->pCopy, Abc_ObjNotCond(Abc_ObjFanin0(pObj)->pCopy, Abc_ObjFaninC0(pObj)) );
498  // write entries into the nodes
499  Abc_NtkForEachCo( pNtk, pObj, i )
500  pObj->pCopy = Abc_ObjNotCond(Abc_ObjFanin0(pObj)->pCopy, Abc_ObjFaninC0(pObj));
501  // create log-to-hot transformers
502  for ( k = 0; k < nStates; k++ )
503  {
504  pObjNew = Abc_NtkCreateNode( pNtkNew );
505  for ( i = 0; i < nFlops; i++ )
506  {
507  pObj = Abc_NtkCo( pNtk, Abc_NtkPoNum(pNtk) + i );
508  Abc_ObjAddFanin( pObjNew, Abc_ObjRegular(pObj->pCopy) );
509  pfCompl[i] = Abc_ObjIsComplement(pObj->pCopy) ^ !((k >> i) & 1);
510  }
511  pObjNew->pData = Abc_SopCreateAnd( (Mem_Flex_t *)pNtkNew->pManFunc, nFlops, pfCompl );
512  // connect it to the flop input
513  Abc_ObjAddFanin( Abc_NtkCo(pNtkNew, Abc_NtkPoNum(pNtkNew)+k), pObjNew );
514  }
515  if ( !Abc_NtkCheck( pNtkNew ) )
516  fprintf( stdout, "Abc_NtkConvertOnehot(): Network check has failed.\n" );
517  return pNtkNew;
518 }
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
ABC_DLL char * Abc_SopCreateAnd(Mem_Flex_t *pMan, int nVars, int *pfCompl)
Definition: abcSop.c:162
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 int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
ABC_DLL Abc_Ntk_t * Abc_NtkDup(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:419
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Abc_Obj_t * Abc_NtkCi(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:317
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
ABC_DLL Vec_Ptr_t * Abc_NtkDfs(Abc_Ntk_t *pNtk, int fCollectAll)
Definition: abcDfs.c:81
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
for(p=first;p->value< newval;p=p->next)
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
static Abc_Obj_t * Abc_NtkCo(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:318
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
static Abc_Obj_t * Abc_NtkCreateBo(Abc_Ntk_t *pNtk)
Definition: abc.h:306
void * pManFunc
Definition: abc.h:191
Abc_Obj_t * pCopy
Definition: abc.h:148
ABC_DLL int Abc_NtkToSop(Abc_Ntk_t *pNtk, int fDirect)
Definition: abcFunc.c:1124
static int Abc_LatchIsInitDc(Abc_Obj_t *pLatch)
Definition: abc.h:424
ABC_DLL void Abc_NtkAddDummyBoxNames(Abc_Ntk_t *pNtk)
Definition: abcNames.c:418
static Abc_Obj_t * Abc_NtkCreateLatch(Abc_Ntk_t *pNtk)
Definition: abc.h:309
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
static int Abc_LatchIsInit1(Abc_Obj_t *pLatch)
Definition: abc.h:423
static void Abc_LatchSetInit1(Abc_Obj_t *pLatch)
Definition: abc.h:419
static Abc_Obj_t * Abc_ObjRegular(Abc_Obj_t *p)
Definition: abc.h:323
static int Abc_NtkPoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:286
Abc_NtkFunc_t ntkFunc
Definition: abc.h:157
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
ABC_DLL Abc_Ntk_t * Abc_NtkStartFromNoLatches(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition: abcNtk.c:248
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:285
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
static Abc_Obj_t * Abc_ObjNotCond(Abc_Obj_t *p, int c)
Definition: abc.h:325
#define assert(ex)
Definition: util_old.h:213
void * pData
Definition: abc.h:145
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
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
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
static void Abc_LatchSetInit0(Abc_Obj_t *pLatch)
Definition: abc.h:418
ABC_DLL char * Abc_SopCreateOr(Mem_Flex_t *pMan, int nVars, int *pfCompl)
Definition: abcSop.c:206
Abc_NtkType_t ntkType
Definition: abc.h:156
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
int Abc_NtkCountSelfFeedLatches ( Abc_Ntk_t pNtk)

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

Synopsis [Checks if latches form self-loop.]

Description []

SideEffects []

SeeAlso []

Definition at line 89 of file abcLatch.c.

90 {
91  Abc_Obj_t * pLatch;
92  int i, Counter;
93  Counter = 0;
94  Abc_NtkForEachLatch( pNtk, pLatch, i )
95  {
96 // if ( Abc_NtkLatchIsSelfFeed(pLatch) && Abc_ObjFanoutNum(pLatch) > 1 )
97 // printf( "Fanouts = %d.\n", Abc_ObjFanoutNum(pLatch) );
98  Counter += Abc_NtkLatchIsSelfFeed( pLatch );
99  }
100  return Counter;
101 }
static int Counter
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
int Abc_NtkLatchIsSelfFeed(Abc_Obj_t *pLatch)
Definition: abcLatch.c:68
Abc_Ntk_t* Abc_NtkCRetime ( Abc_Ntk_t pNtk,
int  fVerbose 
)

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

Synopsis [Classify flops.]

Description []

SideEffects []

SeeAlso []

Definition at line 641 of file abcLatch.c.

642 {
643  Abc_Ntk_t * pNtkNew;
644  Vec_Ptr_t * vControls;
645  Vec_Int_t * vFlopClasses, * vFlopClassesNew;
646  Abc_Obj_t * pObj, * pDriver, * pFlopOut, * pObjPo;
647  int i, iFlop, CountN = 0, Count2 = 0, Count1 = 0, Count0 = 0;
648 
649  // duplicate the AIG
650  pNtk = Abc_NtkDup( pNtk );
651 
652  // update registers
653  vControls = Vec_PtrAlloc( 100 );
654  vFlopClasses = Vec_IntAlloc( 100 );
655  Abc_NtkForEachLatch( pNtk, pObj, i )
656  {
657  pFlopOut = Abc_ObjFanout0(pObj);
658  pDriver = Abc_ObjFanin0( Abc_ObjFanin0(pObj) );
659  if ( Abc_ObjFaninNum(pDriver) != 3 )
660  {
661  Vec_IntPush( vFlopClasses, -1 );
662  CountN++;
663  continue;
664  }
665  if ( Abc_ObjFanin(pDriver, 1) != pFlopOut && Abc_ObjFanin(pDriver, 2) != pFlopOut )
666  {
667  Vec_IntPush( vFlopClasses, -1 );
668  Count2++;
669  continue;
670  }
671  if ( Abc_ObjFanin(pDriver, 1) == pFlopOut )
672  {
673  Vec_IntPush( vFlopClasses, -1 );
674  Count1++;
675  continue;
676  }
677  assert( Abc_ObjFanin(pDriver, 2) == pFlopOut );
678  Count0++;
679  Vec_PtrPushUnique( vControls, Abc_ObjFanin0(pDriver) );
680  // set the flop class
681  iFlop = Vec_PtrFind( vControls, Abc_ObjFanin0(pDriver) );
682  Vec_IntPush( vFlopClasses, iFlop );
683  // update
684  Abc_ObjPatchFanin( Abc_ObjFanin0(pObj), pDriver, Abc_ObjFanin(pDriver, 1) );
685  }
686  if ( Count1 )
687  printf( "Opposite phase enable is present in %d flops (out of %d).\n", Count1, Abc_NtkLatchNum(pNtk) );
688  if ( fVerbose )
689  printf( "CountN = %4d. Count2 = %4d. Count1 = %4d. Count0 = %4d. Ctrls = %d.\n",
690  CountN, Count2, Count1, Count0, Vec_PtrSize(vControls) );
691 
692  // add the controls to the list of POs
693  Vec_PtrForEachEntry( Abc_Obj_t *, vControls, pObj, i )
694  {
695  pObjPo = Abc_NtkCreatePo( pNtk );
696  Abc_ObjAddFanin( pObjPo, pObj );
697  Abc_ObjAssignName( pObjPo, Abc_ObjName(pObjPo), NULL );
698  Vec_PtrWriteEntry( vControls, i, pObjPo );
699  }
700  Abc_NtkOrderCisCos( pNtk );
701  Abc_NtkCleanup( pNtk, fVerbose );
702 
703  // performs retiming with classes
704  pNtkNew = Abc_NtkRetimeWithClassesNtk( pNtk, vFlopClasses, &vFlopClassesNew, fVerbose );
705  Abc_NtkTransformBack( pNtk, pNtkNew, vControls, vFlopClassesNew );
706 // assert( Abc_NtkPoNum(pNtkNew) == Abc_NtkPoNum(pNtk) );
707  Abc_NtkDelete( pNtk );
708 
709  Vec_PtrFree( vControls );
710 // Vec_IntFree( vFlopClasses );
711  Vec_IntFree( vFlopClassesNew );
712  return pNtkNew;
713 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Vec_PtrPushUnique(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:656
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
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 char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition: abcNames.c:68
ABC_DLL int Abc_NtkCleanup(Abc_Ntk_t *pNtk, int fVerbose)
Definition: abcSweep.c:476
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
static int Vec_PtrFind(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:694
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
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
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
Abc_Ntk_t * Abc_NtkRetimeWithClassesNtk(Abc_Ntk_t *pNtk, Vec_Int_t *vClasses, Vec_Int_t **pvClasses, int fVerbose)
Definition: abcLatch.c:565
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
#define assert(ex)
Definition: util_old.h:213
static Abc_Obj_t * Abc_ObjFanin(Abc_Obj_t *pObj, int i)
Definition: abc.h:372
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_DLL void Abc_NtkOrderCisCos(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:71
static Abc_Obj_t * Abc_NtkCreatePo(Abc_Ntk_t *pNtk)
Definition: abc.h:304
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
void Abc_NtkTransformBack(Abc_Ntk_t *pNtkOld, Abc_Ntk_t *pNtkNew, Vec_Ptr_t *vControls, Vec_Int_t *vClasses)
Definition: abcLatch.c:594
void Abc_NtkInsertLatchValues ( Abc_Ntk_t pNtk,
Vec_Int_t vValues 
)

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

Synopsis [Strashes one logic node using its SOP.]

Description []

SideEffects []

SeeAlso []

Definition at line 241 of file abcLatch.c.

242 {
243  Abc_Obj_t * pLatch;
244  int i;
245  Abc_NtkForEachLatch( pNtk, pLatch, i )
246  pLatch->pData = (void *)(ABC_PTRINT_T)(vValues? (Vec_IntEntry(vValues,i)? ABC_INIT_ONE : ABC_INIT_ZERO) : ABC_INIT_DC);
247 }
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
int Abc_NtkLatchIsSelfFeed ( Abc_Obj_t pLatch)

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

Synopsis [Checks if latches form self-loop.]

Description []

SideEffects []

SeeAlso []

Definition at line 68 of file abcLatch.c.

69 {
70  Abc_Obj_t * pFanin;
71  assert( Abc_ObjIsLatch(pLatch) );
72  pFanin = Abc_ObjFanin0(Abc_ObjFanin0(pLatch));
73  if ( !Abc_ObjIsBo(pFanin) || !Abc_ObjIsLatch(Abc_ObjFanin0(pFanin)) )
74  return 0;
75  return Abc_NtkLatchIsSelfFeed_rec( Abc_ObjFanin0(pFanin), pLatch );
76 }
static int Abc_ObjIsBo(Abc_Obj_t *pObj)
Definition: abc.h:350
static int Abc_ObjIsLatch(Abc_Obj_t *pObj)
Definition: abc.h:356
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
#define assert(ex)
Definition: util_old.h:213
ABC_NAMESPACE_IMPL_START int Abc_NtkLatchIsSelfFeed_rec(Abc_Obj_t *pLatch, Abc_Obj_t *pLatchRoot)
DECLARATIONS ///.
Definition: abcLatch.c:45
ABC_NAMESPACE_IMPL_START int Abc_NtkLatchIsSelfFeed_rec ( Abc_Obj_t pLatch,
Abc_Obj_t pLatchRoot 
)

DECLARATIONS ///.

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

FileName [abcLatch.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Network and node package.]

Synopsis [Procedures working with latches.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Checks if latches form self-loop.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file abcLatch.c.

46 {
47  Abc_Obj_t * pFanin;
48  assert( Abc_ObjIsLatch(pLatch) );
49  if ( pLatch == pLatchRoot )
50  return 1;
51  pFanin = Abc_ObjFanin0(Abc_ObjFanin0(pLatch));
52  if ( !Abc_ObjIsBo(pFanin) || !Abc_ObjIsLatch(Abc_ObjFanin0(pFanin)) )
53  return 0;
54  return Abc_NtkLatchIsSelfFeed_rec( Abc_ObjFanin0(pFanin), pLatch );
55 }
static int Abc_ObjIsBo(Abc_Obj_t *pObj)
Definition: abc.h:350
static int Abc_ObjIsLatch(Abc_Obj_t *pObj)
Definition: abc.h:356
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
#define assert(ex)
Definition: util_old.h:213
ABC_NAMESPACE_IMPL_START int Abc_NtkLatchIsSelfFeed_rec(Abc_Obj_t *pLatch, Abc_Obj_t *pLatchRoot)
DECLARATIONS ///.
Definition: abcLatch.c:45
void Abc_NtkLatchPipe ( Abc_Ntk_t pNtk,
int  nLatches 
)

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

Synopsis [Pipelines the network with latches.]

Description []

SideEffects [Does not check the names of the added latches!!!]

SeeAlso []

Definition at line 145 of file abcLatch.c.

146 {
147  Vec_Ptr_t * vNodes;
148  Abc_Obj_t * pObj, * pLatch, * pFanin, * pFanout;
149  int i, k, nTotal, nDigits;
150  if ( nLatches < 1 )
151  return;
152  nTotal = nLatches * Abc_NtkPiNum(pNtk);
153  nDigits = Abc_Base10Log( nTotal );
154  vNodes = Vec_PtrAlloc( 100 );
155  Abc_NtkForEachPi( pNtk, pObj, i )
156  {
157  // remember current fanins of the PI
158  Abc_NodeCollectFanouts( pObj, vNodes );
159  // create the latches
160  for ( pFanin = pObj, k = 0; k < nLatches; k++, pFanin = pLatch )
161  {
162  pLatch = Abc_NtkCreateLatch( pNtk );
163  Abc_ObjAddFanin( pLatch, pFanin );
164  Abc_LatchSetInitDc( pLatch );
165  // create the name of the new latch
166  Abc_ObjAssignName( pLatch, Abc_ObjNameDummy("LL", i*nLatches + k, nDigits), NULL );
167  }
168  // patch the PI fanouts
169  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pFanout, k )
170  Abc_ObjPatchFanin( pFanout, pObj, pFanin );
171  }
172  Vec_PtrFree( vNodes );
173  Abc_NtkLogicMakeSimpleCos( pNtk, 0 );
174 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
ABC_DLL char * Abc_ObjAssignName(Abc_Obj_t *pObj, char *pName, char *pSuffix)
Definition: abcNames.c:68
static void Abc_LatchSetInitDc(Abc_Obj_t *pLatch)
Definition: abc.h:420
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
static int Abc_Base10Log(unsigned n)
Definition: abc_global.h:252
ABC_DLL char * Abc_ObjNameDummy(char *pPrefix, int Num, int nDigits)
Definition: abcNames.c:121
static Abc_Obj_t * Abc_NtkCreateLatch(Abc_Ntk_t *pNtk)
Definition: abc.h:309
ABC_DLL int Abc_NtkLogicMakeSimpleCos(Abc_Ntk_t *pNtk, int fDuplicate)
Definition: abcUtil.c:1047
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:285
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
int nTotal
DECLARATIONS ///.
Definition: cutTruth.c:37
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Abc_NtkNodeConvertToMux ( Abc_Ntk_t pNtk,
Abc_Obj_t pNodeC,
Abc_Obj_t pNode1,
Abc_Obj_t pNode0,
Abc_Obj_t pMux 
)

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

Synopsis [Creates MUX.]

Description []

SideEffects []

SeeAlso []

Definition at line 287 of file abcLatch.c.

288 {
289  assert( Abc_NtkIsLogic(pNtk) );
290  Abc_ObjAddFanin( pMux, pNodeC );
291  Abc_ObjAddFanin( pMux, pNode1 );
292  Abc_ObjAddFanin( pMux, pNode0 );
293  if ( Abc_NtkHasSop(pNtk) )
294  pMux->pData = Abc_SopRegister( (Mem_Flex_t *)pNtk->pManFunc, "11- 1\n0-1 1\n" );
295  else if ( Abc_NtkHasBdd(pNtk) )
297  else if ( Abc_NtkHasAig(pNtk) )
298  pMux->pData = Hop_Mux((Hop_Man_t *)pNtk->pManFunc,Hop_IthVar((Hop_Man_t *)pNtk->pManFunc,0),Hop_IthVar((Hop_Man_t *)pNtk->pManFunc,1),Hop_IthVar((Hop_Man_t *)pNtk->pManFunc,2));
299  else
300  assert( 0 );
301 }
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
static int Abc_NtkHasBdd(Abc_Ntk_t *pNtk)
Definition: abc.h:254
static int Abc_NtkHasSop(Abc_Ntk_t *pNtk)
Definition: abc.h:253
Definition: cudd.h:278
DdNode * Cudd_bddIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddBddIte.c:143
Hop_Obj_t * Hop_Mux(Hop_Man_t *p, Hop_Obj_t *pC, Hop_Obj_t *p1, Hop_Obj_t *p0)
Definition: hopOper.c:187
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
void * pManFunc
Definition: abc.h:191
ABC_DLL char * Abc_SopRegister(Mem_Flex_t *pMan, char *pName)
DECLARATIONS ///.
Definition: abcSop.c:56
DdNode * Cudd_bddIthVar(DdManager *dd, int i)
Definition: cuddAPI.c:416
#define assert(ex)
Definition: util_old.h:213
static int Abc_NtkHasAig(Abc_Ntk_t *pNtk)
Definition: abc.h:255
void * pData
Definition: abc.h:145
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition: hop.h:49
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition: hopOper.c:63
int Abc_NtkRemoveSelfFeedLatches ( Abc_Ntk_t pNtk)

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

Synopsis [Replaces self-feeding latches by latches with constant inputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 114 of file abcLatch.c.

115 {
116  Abc_Obj_t * pLatch, * pConst1;
117  int i, Counter;
118  Counter = 0;
119  Abc_NtkForEachLatch( pNtk, pLatch, i )
120  {
121  if ( Abc_NtkLatchIsSelfFeed( pLatch ) )
122  {
123  if ( Abc_NtkIsStrash(pNtk) )
124  pConst1 = Abc_AigConst1(pNtk);
125  else
126  pConst1 = Abc_NtkCreateNodeConst1(pNtk);
127  Abc_ObjPatchFanin( Abc_ObjFanin0(pLatch), Abc_ObjFanin0(Abc_ObjFanin0(pLatch)), pConst1 );
128  Counter++;
129  }
130  }
131  return Counter;
132 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
ABC_DLL Abc_Obj_t * Abc_NtkCreateNodeConst1(Abc_Ntk_t *pNtk)
Definition: abcObj.c:633
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
ABC_DLL void Abc_ObjPatchFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFaninOld, Abc_Obj_t *pFaninNew)
Definition: abcFanio.c:172
static int Counter
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
int Abc_NtkLatchIsSelfFeed(Abc_Obj_t *pLatch)
Definition: abcLatch.c:68
ABC_NAMESPACE_IMPL_END ABC_NAMESPACE_IMPL_START Aig_Man_t* Abc_NtkRetimeWithClassesAig ( Aig_Man_t pMan,
Vec_Int_t vClasses,
Vec_Int_t **  pvClasses,
int  fVerbose 
)

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

Synopsis [Performs retiming with classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 538 of file abcLatch.c.

539 {
540  Aig_Man_t * pManNew;
541  Gia_Man_t * pGia, * pGiaNew;
542  pGia = Gia_ManFromAigSimple( pMan );
543  assert( Gia_ManRegNum(pGia) == Vec_IntSize(vClasses) );
544  pGia->vFlopClasses = vClasses;
545  pGiaNew = Gia_ManRetimeForward( pGia, 10, fVerbose );
546  *pvClasses = pGiaNew->vFlopClasses;
547  pGiaNew->vFlopClasses = NULL;
548  pManNew = Gia_ManToAig( pGiaNew, 0 );
549  Gia_ManStop( pGiaNew );
550  Gia_ManStop( pGia );
551  return pManNew;
552 }
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
Vec_Int_t * vFlopClasses
Definition: gia.h:140
Gia_Man_t * Gia_ManFromAigSimple(Aig_Man_t *p)
Definition: giaAig.c:171
Gia_Man_t * Gia_ManRetimeForward(Gia_Man_t *p, int nMaxIters, int fVerbose)
Definition: giaRetime.c:267
Aig_Man_t * Gia_ManToAig(Gia_Man_t *p, int fChoices)
Definition: giaAig.c:277
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Definition: gia.h:95
#define assert(ex)
Definition: util_old.h:213
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
Abc_Ntk_t* Abc_NtkRetimeWithClassesNtk ( Abc_Ntk_t pNtk,
Vec_Int_t vClasses,
Vec_Int_t **  pvClasses,
int  fVerbose 
)

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

Synopsis [Performs retiming with classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 565 of file abcLatch.c.

566 {
567  extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
568  extern Abc_Ntk_t * Abc_NtkFromDarSeqSweep( Abc_Ntk_t * pNtkOld, Aig_Man_t * pMan );
569  Abc_Ntk_t * pNtkAig, * pNtkAigRet, * pNtkRes;
570  Aig_Man_t * pMan, * pManNew;
571  pNtkAig = Abc_NtkStrash( pNtk, 0, 1, 0 );
572  pMan = Abc_NtkToDar( pNtkAig, 0, 1 );
573  pManNew = Abc_NtkRetimeWithClassesAig( pMan, vClasses, pvClasses, fVerbose );
574  pNtkAigRet = Abc_NtkFromDarSeqSweep( pNtkAig, pManNew );
575  pNtkRes = Abc_NtkToLogic( pNtkAigRet );
576  Abc_NtkDelete( pNtkAigRet );
577  Abc_NtkDelete( pNtkAig );
578  Aig_ManStop( pManNew );
579  Aig_ManStop( pMan );
580  return pNtkRes;
581 }
ABC_NAMESPACE_IMPL_END ABC_NAMESPACE_IMPL_START Aig_Man_t * Abc_NtkRetimeWithClassesAig(Aig_Man_t *pMan, Vec_Int_t *vClasses, Vec_Int_t **pvClasses, int fVerbose)
Definition: abcLatch.c:538
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
ABC_DLL Abc_Ntk_t * Abc_NtkStrash(Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
Definition: abcStrash.c:265
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
ABC_DLL Abc_Ntk_t * Abc_NtkToLogic(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcNetlist.c:52
Aig_Man_t * Abc_NtkToDar(Abc_Ntk_t *pNtk, int fExors, int fRegisters)
Definition: abcDar.c:233
Abc_Ntk_t * Abc_NtkFromDarSeqSweep(Abc_Ntk_t *pNtkOld, Aig_Man_t *pMan)
Definition: abcDar.c:468
void Abc_NtkTransformBack ( Abc_Ntk_t pNtkOld,
Abc_Ntk_t pNtkNew,
Vec_Ptr_t vControls,
Vec_Int_t vClasses 
)

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

Synopsis [Returns self-loops back into the network.]

Description []

SideEffects []

SeeAlso []

Definition at line 594 of file abcLatch.c.

595 {
596  Abc_Obj_t * pObj, * pNodeNew, * pCtrl, * pDriver;
597  int i, Class;
598  assert( Abc_NtkPoNum(pNtkOld) == Abc_NtkPoNum(pNtkNew) );
599  // match the POs of the old into new
600  Abc_NtkForEachPo( pNtkOld, pObj, i )
601  pObj->pCopy = Abc_NtkPo( pNtkNew, i );
602  // remap the flops
603  Vec_PtrForEachEntry( Abc_Obj_t *, vControls, pObj, i )
604  {
605  assert( Abc_ObjIsPo(pObj) && pObj->pNtk == pNtkOld );
606  Vec_PtrWriteEntry( vControls, i, pObj->pCopy );
607  }
608  // create self-loops
609  assert( Abc_NtkLatchNum(pNtkNew) == Vec_IntSize(vClasses) );
610  Abc_NtkForEachLatch( pNtkNew, pObj, i )
611  {
612  Class = Vec_IntEntry( vClasses, i );
613  if ( Class == -1 )
614  continue;
615  pDriver = Abc_ObjFanin0(Abc_ObjFanin0(pObj));
616  pCtrl = (Abc_Obj_t *)Vec_PtrEntry( vControls, Class );
617  pCtrl = Abc_ObjFanin0( pCtrl );
618  pNodeNew = Abc_NtkCreateNode( pNtkNew );
619  Abc_ObjAddFanin( pNodeNew, pCtrl );
620  Abc_ObjAddFanin( pNodeNew, pDriver );
621  Abc_ObjAddFanin( pNodeNew, Abc_ObjFanout0(pObj) );
622  Abc_ObjSetData( pNodeNew, Abc_SopRegister((Mem_Flex_t *)pNtkNew->pManFunc, "0-1 1\n11- 1\n") );
623  Abc_ObjPatchFanin( Abc_ObjFanin0(pObj), pDriver, pNodeNew );
624  }
625  // remove the useless POs
626  Vec_PtrForEachEntry( Abc_Obj_t *, vControls, pObj, i )
627  Abc_NtkDeleteObj( pObj );
628 }
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
static void Abc_ObjSetData(Abc_Obj_t *pObj, void *pData)
Definition: abc.h:343
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_DLL char * Abc_SopRegister(Mem_Flex_t *pMan, char *pName)
DECLARATIONS ///.
Definition: abcSop.c:56
ABC_DLL void Abc_NtkDeleteObj(Abc_Obj_t *pObj)
Definition: abcObj.c:167
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static Abc_Obj_t * Abc_NtkPo(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:316
static int Abc_NtkPoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:286
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
Definition: abc.h:308
static int Abc_ObjIsPo(Abc_Obj_t *pObj)
Definition: abc.h:348
#define assert(ex)
Definition: util_old.h:213
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
#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
int Abc_NtkVerifyCex ( Abc_Ntk_t pNtk,
Abc_Cex_t p 
)

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

Synopsis [Resimulates CEX and return the ID of the PO that failed.]

Description []

SideEffects []

SeeAlso []

Definition at line 726 of file abcLatch.c.

727 {
728  Abc_Obj_t * pObj;
729  int RetValue, i, k, iBit = 0;
730  assert( Abc_NtkIsStrash(pNtk) );
731  assert( p->nPis == Abc_NtkPiNum(pNtk) );
732  assert( p->nRegs == Abc_NtkLatchNum(pNtk) );
733  Abc_NtkCleanMarkC( pNtk );
734  Abc_AigConst1(pNtk)->fMarkC = 1;
735  // initialize flops
736  Abc_NtkForEachLatch( pNtk, pObj, i )
737  Abc_ObjFanout0(pObj)->fMarkC = Abc_InfoHasBit(p->pData, iBit++);
738  // simulate timeframes
739  for ( i = 0; i <= p->iFrame; i++ )
740  {
741  Abc_NtkForEachPi( pNtk, pObj, k )
742  pObj->fMarkC = Abc_InfoHasBit(p->pData, iBit++);
743  Abc_NtkForEachNode( pNtk, pObj, k )
744  pObj->fMarkC = (Abc_ObjFanin0(pObj)->fMarkC ^ Abc_ObjFaninC0(pObj)) &
745  (Abc_ObjFanin1(pObj)->fMarkC ^ Abc_ObjFaninC1(pObj));
746  Abc_NtkForEachCo( pNtk, pObj, k )
747  pObj->fMarkC = Abc_ObjFanin0(pObj)->fMarkC ^ Abc_ObjFaninC0(pObj);
748  Abc_NtkForEachLatch( pNtk, pObj, k )
749  Abc_ObjFanout0(pObj)->fMarkC = Abc_ObjFanin0(pObj)->fMarkC;
750  }
751  assert( iBit == p->nBits );
752  // figure out the number of failed output
753  RetValue = -1;
754  Abc_NtkForEachPo( pNtk, pObj, i )
755  {
756  if ( pObj->fMarkC )
757  {
758  RetValue = i;
759  break;
760  }
761  }
762  Abc_NtkCleanMarkC( pNtk );
763  return RetValue;
764 }
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
Definition: abc.h:378
static int Abc_InfoHasBit(unsigned *p, int i)
Definition: abc_global.h:258
ABC_DLL void Abc_NtkCleanMarkC(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:701
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
Definition: abc.h:294
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
for(p=first;p->value< newval;p=p->next)
unsigned fMarkC
Definition: abc.h:136
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:285
#define assert(ex)
Definition: util_old.h:213
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
static Abc_Obj_t * Abc_ObjFanout0(Abc_Obj_t *pObj)
Definition: abc.h:371
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513