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

Go to the source code of this file.

Data Structures

struct  Fra_Lcr_t_
 

Typedefs

typedef
typedefABC_NAMESPACE_IMPL_START
struct Fra_Lcr_t_ 
Fra_Lcr_t
 DECLARATIONS ///. More...
 

Functions

Fra_Lcr_tLcr_ManAlloc (Aig_Man_t *pAig)
 FUNCTION DEFINITIONS ///. More...
 
void Lcr_ManPrint (Fra_Lcr_t *p)
 
void Lcr_ManFree (Fra_Lcr_t *p)
 
Fra_Man_tFra_LcrAigPrepare (Aig_Man_t *pAig)
 
void Fra_LcrAigPrepareTwo (Aig_Man_t *pAig, Fra_Man_t *p)
 
int Fra_LcrNodesAreEqual (Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
 
int Fra_LcrNodeIsConst (Aig_Obj_t *pObj)
 
Aig_Obj_tFra_LcrManDup_rec (Aig_Man_t *pNew, Aig_Man_t *p, Aig_Obj_t *pObj)
 
Aig_Man_tFra_LcrDeriveAigForPartitioning (Fra_Lcr_t *pLcr)
 
void Fra_LcrRemapPartitions (Vec_Ptr_t *vParts, Fra_Cla_t *pCla, int *pInToOutPart, int *pInToOutNum)
 
Aig_Obj_tFra_LcrCreatePart_rec (Fra_Cla_t *pCla, Aig_Man_t *pNew, Aig_Man_t *p, Aig_Obj_t *pObj)
 
Aig_Man_tFra_LcrCreatePart (Fra_Lcr_t *p, Vec_Int_t *vPart)
 
void Fra_ClassNodesMark (Fra_Lcr_t *p)
 
void Fra_ClassNodesUnmark (Fra_Lcr_t *p)
 
Aig_Man_tFra_FraigLatchCorrespondence (Aig_Man_t *pAig, int nFramesP, int nConfMax, int fProve, int fVerbose, int *pnIter, float TimeLimit)
 

Typedef Documentation

typedef typedefABC_NAMESPACE_IMPL_START struct Fra_Lcr_t_ Fra_Lcr_t

DECLARATIONS ///.

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

FileName [fraLcorr.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [New FRAIG package.]

Synopsis [Latch correspondence computation.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 30, 2007.]

Revision [

Id:
fraLcorr.c,v 1.00 2007/06/30 00:00:00 alanmi Exp

]

Definition at line 30 of file fraLcr.c.

Function Documentation

void Fra_ClassNodesMark ( Fra_Lcr_t p)

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

Synopsis [Marks the nodes belonging to the equivalence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 465 of file fraLcr.c.

466 {
467  Aig_Obj_t * pObj, ** ppClass;
468  int i, c, Offset;
469  // compute the LO/LI offset
470  Offset = Aig_ManCoNum(p->pCla->pAig) - Aig_ManCiNum(p->pCla->pAig);
471  // mark the nodes remaining in the classes
472  Vec_PtrForEachEntry( Aig_Obj_t *, p->pCla->vClasses1, pObj, i )
473  {
474  pObj = Aig_ManCo( p->pCla->pAig, Offset+(long)pObj->pNext );
475  pObj->fMarkA = 1;
476  }
477  Vec_PtrForEachEntry( Aig_Obj_t **, p->pCla->vClasses, ppClass, i )
478  {
479  for ( c = 0; ppClass[c]; c++ )
480  {
481  pObj = Aig_ManCo( p->pCla->pAig, Offset+(long)ppClass[c]->pNext );
482  pObj->fMarkA = 1;
483  }
484  }
485 }
Aig_Man_t * pAig
Definition: llb3Image.c:49
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned int fMarkA
Definition: aig.h:79
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
Definition: aig.h:69
Aig_Obj_t * pNext
Definition: aig.h:72
static Aig_Obj_t * Aig_ManCo(Aig_Man_t *p, int i)
Definition: aig.h:267
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
void Fra_ClassNodesUnmark ( Fra_Lcr_t p)

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

Synopsis [Unmarks the nodes belonging to the equivalence classes.]

Description []

SideEffects []

SeeAlso []

Definition at line 498 of file fraLcr.c.

499 {
500  Aig_Obj_t * pObj, ** ppClass;
501  int i, c, Offset;
502  // compute the LO/LI offset
503  Offset = Aig_ManCoNum(p->pCla->pAig) - Aig_ManCiNum(p->pCla->pAig);
504  // mark the nodes remaining in the classes
505  Vec_PtrForEachEntry( Aig_Obj_t *, p->pCla->vClasses1, pObj, i )
506  {
507  pObj = Aig_ManCo( p->pCla->pAig, Offset+(long)pObj->pNext );
508  pObj->fMarkA = 0;
509  }
510  Vec_PtrForEachEntry( Aig_Obj_t **, p->pCla->vClasses, ppClass, i )
511  {
512  for ( c = 0; ppClass[c]; c++ )
513  {
514  pObj = Aig_ManCo( p->pCla->pAig, Offset+(long)ppClass[c]->pNext );
515  pObj->fMarkA = 0;
516  }
517  }
518 }
Aig_Man_t * pAig
Definition: llb3Image.c:49
static Llb_Mgr_t * p
Definition: llb3Image.c:950
unsigned int fMarkA
Definition: aig.h:79
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
Definition: aig.h:69
Aig_Obj_t * pNext
Definition: aig.h:72
static Aig_Obj_t * Aig_ManCo(Aig_Man_t *p, int i)
Definition: aig.h:267
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Aig_Man_t* Fra_FraigLatchCorrespondence ( Aig_Man_t pAig,
int  nFramesP,
int  nConfMax,
int  fProve,
int  fVerbose,
int *  pnIter,
float  TimeLimit 
)

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

Synopsis [Performs choicing of the AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 531 of file fraLcr.c.

532 {
533  int nPartSize = 200;
534  int fReprSelect = 0;
535  Fra_Lcr_t * p;
536  Fra_Sml_t * pSml;
537  Fra_Man_t * pTemp;
538  Aig_Man_t * pAigPart, * pAigTemp, * pAigNew = NULL;
539  Vec_Int_t * vPart;
540  int i, nIter;
541  abctime timeSim, clk2, clk3, clk = Abc_Clock();
542  abctime TimeToStop = TimeLimit ? TimeLimit * CLOCKS_PER_SEC + Abc_Clock() : 0;
543  if ( Aig_ManNodeNum(pAig) == 0 )
544  {
545  if ( pnIter ) *pnIter = 0;
546  // Ntl_ManFinalize() requires the following to satisfy an assertion.
548  return Aig_ManDupOrdered(pAig);
549  }
550  assert( Aig_ManRegNum(pAig) > 0 );
551 
552  // simulate the AIG
553 clk2 = Abc_Clock();
554 if ( fVerbose )
555 printf( "Simulating AIG with %d nodes for %d cycles ... ", Aig_ManNodeNum(pAig), nFramesP + 32 );
556  pSml = Fra_SmlSimulateSeq( pAig, nFramesP, 32, 1, 1 );
557 if ( fVerbose )
558 {
559 ABC_PRT( "Time", Abc_Clock() - clk2 );
560 }
561 timeSim = Abc_Clock() - clk2;
562 
563  // check if simulation discovered non-constant-0 POs
564  if ( fProve && pSml->fNonConstOut )
565  {
566  pAig->pSeqModel = Fra_SmlGetCounterExample( pSml );
567  Fra_SmlStop( pSml );
568  return NULL;
569  }
570 
571  // start the manager
572  p = Lcr_ManAlloc( pAig );
573  p->nFramesP = nFramesP;
574  p->fVerbose = fVerbose;
575  p->timeSim += timeSim;
576 
577  pTemp = Fra_LcrAigPrepare( pAig );
578  pTemp->pBmc = (Fra_Bmc_t *)p;
579  pTemp->pSml = pSml;
580 
581  // get preliminary info about equivalence classes
582  pTemp->pCla = p->pCla = Fra_ClassesStart( p->pAig );
583  Fra_ClassesPrepare( p->pCla, 1, 0 );
584  p->pCla->pFuncNodeIsConst = Fra_LcrNodeIsConst;
585  p->pCla->pFuncNodesAreEqual = Fra_LcrNodesAreEqual;
586  Fra_SmlStop( pTemp->pSml );
587 
588  // partition the AIG for latch correspondence computation
589 clk2 = Abc_Clock();
590 if ( fVerbose )
591 printf( "Partitioning AIG ... " );
592  pAigPart = Fra_LcrDeriveAigForPartitioning( p );
593  p->vParts = (Vec_Ptr_t *)Aig_ManPartitionSmart( pAigPart, nPartSize, 0, NULL );
594  Fra_LcrRemapPartitions( p->vParts, p->pCla, p->pInToOutPart, p->pInToOutNum );
595  Aig_ManStop( pAigPart );
596 if ( fVerbose )
597 {
598 ABC_PRT( "Time", Abc_Clock() - clk2 );
599 p->timePart += Abc_Clock() - clk2;
600 }
601 
602  // get the initial stats
603  p->nLitsBeg = Fra_ClassesCountLits( p->pCla );
604  p->nNodesBeg = Aig_ManNodeNum(p->pAig);
605  p->nRegsBeg = Aig_ManRegNum(p->pAig);
606 
607  // perforn interative reduction of the partitions
608  p->fRefining = 1;
609  for ( nIter = 0; p->fRefining; nIter++ )
610  {
611  p->fRefining = 0;
612  clk3 = Abc_Clock();
613  // derive AIGs for each partition
614  Fra_ClassNodesMark( p );
615  Vec_PtrClear( p->vFraigs );
616  Vec_PtrForEachEntry( Vec_Int_t *, p->vParts, vPart, i )
617  {
618  if ( TimeLimit != 0.0 && Abc_Clock() > TimeToStop )
619  {
620  Vec_PtrForEachEntry( Aig_Man_t *, p->vFraigs, pAigPart, i )
621  Aig_ManStop( pAigPart );
622  Aig_ManCleanMarkA( pAig );
623  Aig_ManCleanMarkB( pAig );
624  printf( "Fra_FraigLatchCorrespondence(): Runtime limit exceeded.\n" );
625  goto finish;
626  }
627 clk2 = Abc_Clock();
628  pAigPart = Fra_LcrCreatePart( p, vPart );
629 p->timeTrav += Abc_Clock() - clk2;
630 clk2 = Abc_Clock();
631  pAigTemp = Fra_FraigEquivence( pAigPart, nConfMax, 0 );
632 p->timeFraig += Abc_Clock() - clk2;
633  Vec_PtrPush( p->vFraigs, pAigTemp );
634 /*
635  {
636  char Name[1000];
637  sprintf( Name, "part%04d.blif", i );
638  Aig_ManDumpBlif( pAigPart, Name, NULL, NULL );
639  }
640 printf( "Finished part %4d (out of %4d). ", i, Vec_PtrSize(p->vParts) );
641 ABC_PRT( "Time", Abc_Clock() - clk3 );
642 */
643 
644  Aig_ManStop( pAigPart );
645  }
647  // report the intermediate results
648  if ( fVerbose )
649  {
650  printf( "%3d : Const = %6d. Class = %6d. L = %6d. Part = %3d. ",
651  nIter, Vec_PtrSize(p->pCla->vClasses1), Vec_PtrSize(p->pCla->vClasses),
652  Fra_ClassesCountLits(p->pCla), Vec_PtrSize(p->vParts) );
653  ABC_PRT( "T", Abc_Clock() - clk3 );
654  }
655  // refine the classes
656  Fra_LcrAigPrepareTwo( p->pAig, pTemp );
657  if ( Fra_ClassesRefine( p->pCla ) )
658  p->fRefining = 1;
659  if ( Fra_ClassesRefine1( p->pCla, 0, NULL ) )
660  p->fRefining = 1;
661  // clean the fraigs
662  Vec_PtrForEachEntry( Aig_Man_t *, p->vFraigs, pAigPart, i )
663  Aig_ManStop( pAigPart );
664 
665  // repartition if needed
666  if ( 1 )
667  {
668 clk2 = Abc_Clock();
669  Vec_VecFree( (Vec_Vec_t *)p->vParts );
670  pAigPart = Fra_LcrDeriveAigForPartitioning( p );
671  p->vParts = (Vec_Ptr_t *)Aig_ManPartitionSmart( pAigPart, nPartSize, 0, NULL );
672  Fra_LcrRemapPartitions( p->vParts, p->pCla, p->pInToOutPart, p->pInToOutNum );
673  Aig_ManStop( pAigPart );
674 p->timePart += Abc_Clock() - clk2;
675  }
676  }
677  p->nIters = nIter;
678 
679  // move the classes into representatives and reduce AIG
680 clk2 = Abc_Clock();
681 // Fra_ClassesPrint( p->pCla, 1 );
682  if ( fReprSelect )
683  Fra_ClassesSelectRepr( p->pCla );
684  Fra_ClassesCopyReprs( p->pCla, NULL );
685  pAigNew = Aig_ManDupRepr( p->pAig, 0 );
686  Aig_ManSeqCleanup( pAigNew );
687 // Aig_ManCountMergeRegs( pAigNew );
688 p->timeUpdate += Abc_Clock() - clk2;
689 p->timeTotal = Abc_Clock() - clk;
690  // get the final stats
691  p->nLitsEnd = Fra_ClassesCountLits( p->pCla );
692  p->nNodesEnd = Aig_ManNodeNum(pAigNew);
693  p->nRegsEnd = Aig_ManRegNum(pAigNew);
694 finish:
695  ABC_FREE( pTemp );
696  Lcr_ManFree( p );
697  if ( pnIter ) *pnIter = nIter;
698  return pAigNew;
699 }
typedefABC_NAMESPACE_IMPL_START struct Fra_Lcr_t_ Fra_Lcr_t
DECLARATIONS ///.
Definition: fraLcr.c:30
int fNonConstOut
Definition: fra.h:179
int Fra_ClassesRefine1(Fra_Cla_t *p, int fRefineNewClass, int *pSkipped)
Definition: fraClass.c:527
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Aig_Man_t * Fra_LcrCreatePart(Fra_Lcr_t *p, Vec_Int_t *vPart)
Definition: fraLcr.c:429
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
Vec_Ptr_t * Aig_ManPartitionSmart(Aig_Man_t *p, int nPartSizeLimit, int fVerbose, Vec_Ptr_t **pvPartSupps)
Definition: aigPart.c:686
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
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
Fra_Sml_t * Fra_SmlSimulateSeq(Aig_Man_t *pAig, int nPref, int nFrames, int nWords, int fCheckMiter)
Definition: fraSim.c:1021
int Aig_ManSeqCleanup(Aig_Man_t *p)
Definition: aigScl.c:158
Fra_Cla_t * Fra_ClassesStart(Aig_Man_t *pAig)
FUNCTION DEFINITIONS ///.
Definition: fraClass.c:60
Fra_Cla_t * pCla
Definition: fra.h:198
Aig_Man_t * Fra_FraigEquivence(Aig_Man_t *pManAig, int nConfMax, int fProve)
Definition: fraCore.c:468
int Fra_ClassesCountLits(Fra_Cla_t *p)
Definition: fraClass.c:164
Fra_Sml_t * pSml
Definition: fra.h:200
Aig_Man_t * Aig_ManDupOrdered(Aig_Man_t *p)
Definition: aigDup.c:277
void Aig_ManCleanMarkB(Aig_Man_t *p)
Definition: aigUtil.c:167
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
void Fra_LcrAigPrepareTwo(Aig_Man_t *pAig, Fra_Man_t *p)
Definition: fraLcr.c:182
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
DECLARATIONS ///.
Definition: fraBmc.c:31
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
Fra_Bmc_t * pBmc
Definition: fra.h:202
void Fra_ClassNodesMark(Fra_Lcr_t *p)
Definition: fraLcr.c:465
void Fra_ClassesPrepare(Fra_Cla_t *p, int fLatchCorr, int nMaxLevs)
Definition: fraClass.c:276
Abc_Cex_t * Fra_SmlGetCounterExample(Fra_Sml_t *p)
Definition: fraSim.c:1043
void Lcr_ManFree(Fra_Lcr_t *p)
Definition: fraLcr.c:131
void Aig_ManReprStart(Aig_Man_t *p, int nIdMax)
DECLARATIONS ///.
Definition: aigRepr.c:45
int Fra_LcrNodeIsConst(Aig_Obj_t *pObj)
Definition: fraLcr.c:239
Fra_Man_t * Fra_LcrAigPrepare(Aig_Man_t *pAig)
Definition: fraLcr.c:158
if(last==0)
Definition: sparse_int.h:34
Aig_Man_t * Aig_ManDupRepr(Aig_Man_t *p, int fOrdered)
Definition: aigRepr.c:267
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
int Fra_LcrNodesAreEqual(Aig_Obj_t *pObj0, Aig_Obj_t *pObj1)
Definition: fraLcr.c:201
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
void Fra_ClassesSelectRepr(Fra_Cla_t *p)
Definition: fraClass.c:706
Aig_Man_t * Fra_LcrDeriveAigForPartitioning(Fra_Lcr_t *pLcr)
Definition: fraLcr.c:296
void Fra_ClassNodesUnmark(Fra_Lcr_t *p)
Definition: fraLcr.c:498
#define ABC_FREE(obj)
Definition: abc_global.h:232
int Fra_ClassesRefine(Fra_Cla_t *p)
Definition: fraClass.c:493
#define ABC_PRT(a, t)
Definition: abc_global.h:220
void Fra_ClassesCopyReprs(Fra_Cla_t *p, Vec_Ptr_t *vFailed)
Definition: fraClass.c:114
void Aig_ManCleanMarkA(Aig_Man_t *p)
Definition: aigUtil.c:148
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
ABC_INT64_T abctime
Definition: abc_global.h:278
Fra_Lcr_t * Lcr_ManAlloc(Aig_Man_t *pAig)
FUNCTION DEFINITIONS ///.
Definition: fraLcr.c:80
Aig_Man_t * Fra_FraigLatchCorrespondence(Aig_Man_t *pAig, int nFramesP, int nConfMax, int fProve, int fVerbose, int *pnIter, float TimeLimit)
Definition: fraLcr.c:531
void Fra_SmlStop(Fra_Sml_t *p)
Definition: fraSim.c:839
void Fra_LcrRemapPartitions(Vec_Ptr_t *vParts, Fra_Cla_t *pCla, int *pInToOutPart, int *pInToOutNum)
Definition: fraLcr.c:347
Fra_Man_t* Fra_LcrAigPrepare ( Aig_Man_t pAig)

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

Synopsis [Prepare the AIG for class computation.]

Description []

SideEffects []

SeeAlso []

Definition at line 158 of file fraLcr.c.

159 {
160  Fra_Man_t * p;
161  Aig_Obj_t * pObj;
162  int i;
163  p = ABC_ALLOC( Fra_Man_t, 1 );
164  memset( p, 0, sizeof(Fra_Man_t) );
165 // Aig_ManForEachCi( pAig, pObj, i )
166  Aig_ManForEachObj( pAig, pObj, i )
167  pObj->pData = p;
168  return p;
169 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Definition: aig.h:69
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
void Fra_LcrAigPrepareTwo ( Aig_Man_t pAig,
Fra_Man_t p 
)

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

Synopsis [Prepare the AIG for class computation.]

Description []

SideEffects []

SeeAlso []

Definition at line 182 of file fraLcr.c.

183 {
184  Aig_Obj_t * pObj;
185  int i;
186  Aig_ManForEachCi( pAig, pObj, i )
187  pObj->pData = p;
188 }
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
Definition: aig.h:69
Aig_Man_t* Fra_LcrCreatePart ( Fra_Lcr_t p,
Vec_Int_t vPart 
)

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

Synopsis [Creates AIG of one partition with speculative reduction.]

Description []

SideEffects []

SeeAlso []

Definition at line 429 of file fraLcr.c.

430 {
431  Aig_Man_t * pNew;
432  Aig_Obj_t * pObj, * pObjNew;
433  int Out, i;
434  // create new AIG for this partition
435  pNew = Aig_ManStartFrom( p->pAig );
439  Vec_IntForEachEntry( vPart, Out, i )
440  {
441  pObj = Aig_ManCo( p->pAig, Out );
442  if ( pObj->fMarkA )
443  {
444  pObjNew = Fra_LcrCreatePart_rec( p->pCla, pNew, p->pAig, Aig_ObjFanin0(pObj) );
445  pObjNew = Aig_NotCond( pObjNew, Aig_ObjFaninC0(pObj) );
446  }
447  else
448  pObjNew = Aig_ManConst1( pNew );
449  Aig_ObjCreateCo( pNew, pObjNew );
450  }
451  return pNew;
452 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
Aig_Man_t * pAig
Definition: llb3Image.c:49
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 * pData
Definition: aig.h:87
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
unsigned int fMarkA
Definition: aig.h:79
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
Definition: aig.h:69
Aig_Man_t * Aig_ManStartFrom(Aig_Man_t *p)
Definition: aigMan.c:92
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
static Aig_Obj_t * Aig_ManCo(Aig_Man_t *p, int i)
Definition: aig.h:267
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
Aig_Obj_t * Fra_LcrCreatePart_rec(Fra_Cla_t *pCla, Aig_Man_t *pNew, Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: fraLcr.c:394
Aig_Obj_t* Fra_LcrCreatePart_rec ( Fra_Cla_t pCla,
Aig_Man_t pNew,
Aig_Man_t p,
Aig_Obj_t pObj 
)

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

Synopsis [Creates AIG of one partition with speculative reduction.]

Description []

SideEffects []

SeeAlso []

Definition at line 394 of file fraLcr.c.

395 {
396  assert( !Aig_IsComplement(pObj) );
397  if ( Aig_ObjIsTravIdCurrent(p, pObj) )
398  return (Aig_Obj_t *)pObj->pData;
399  Aig_ObjSetTravIdCurrent(p, pObj);
400  if ( Aig_ObjIsCi(pObj) )
401  {
402 // Aig_Obj_t * pRepr = Fra_ClassObjRepr(pObj);
403  Aig_Obj_t * pRepr = pCla->pMemRepr[pObj->Id];
404  if ( pRepr == NULL )
405  pObj->pData = Aig_ObjCreateCi( pNew );
406  else
407  {
408  pObj->pData = Fra_LcrCreatePart_rec( pCla, pNew, p, pRepr );
409  pObj->pData = Aig_NotCond( (Aig_Obj_t *)pObj->pData, pRepr->fPhase ^ pObj->fPhase );
410  }
411  return (Aig_Obj_t *)pObj->pData;
412  }
413  Fra_LcrCreatePart_rec( pCla, pNew, p, Aig_ObjFanin0(pObj) );
414  Fra_LcrCreatePart_rec( pCla, pNew, p, Aig_ObjFanin1(pObj) );
415  return (Aig_Obj_t *)(pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) ));
416 }
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 * pData
Definition: aig.h:87
Aig_Obj_t ** pMemRepr
Definition: fra.h:153
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigObj.c:45
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
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
static Aig_Obj_t * Aig_ObjChild1Copy(Aig_Obj_t *pObj)
Definition: aig.h:313
Definition: aig.h:69
static Aig_Obj_t * Aig_ObjChild0Copy(Aig_Obj_t *pObj)
Definition: aig.h:312
unsigned int fPhase
Definition: aig.h:78
#define assert(ex)
Definition: util_old.h:213
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
int Id
Definition: aig.h:85
Aig_Obj_t * Fra_LcrCreatePart_rec(Fra_Cla_t *pCla, Aig_Man_t *pNew, Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: fraLcr.c:394
Aig_Man_t* Fra_LcrDeriveAigForPartitioning ( Fra_Lcr_t pLcr)

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

Synopsis [Give the AIG and classes, reduces AIG for partitioning.]

Description [Ignores registers that are not in the classes. Places candidate equivalent classes of registers into single outputs (for ease of partitioning). The resulting combinational AIG contains outputs in the same order as equivalence classes of registers, followed by constant-1 registers. Preserves the set of all inputs. Complemented attributes of the outputs do not matter because we need then only for collecting the structural info.]

SideEffects []

SeeAlso []

Definition at line 296 of file fraLcr.c.

297 {
298  Aig_Man_t * pNew;
299  Aig_Obj_t * pObj, * pObjPo, * pObjNew, ** ppClass, * pMiter;
300  int i, c, Offset;
301  // remember the numbers of the inputs of the original AIG
302  Aig_ManForEachCi( pLcr->pAig, pObj, i )
303  {
304  pObj->pData = pLcr;
305  pObj->pNext = (Aig_Obj_t *)(long)i;
306  }
307  // compute the LO/LI offset
308  Offset = Aig_ManCoNum(pLcr->pAig) - Aig_ManCiNum(pLcr->pAig);
309  // create the PIs
310  Aig_ManCleanData( pLcr->pAig );
311  pNew = Aig_ManStartFrom( pLcr->pAig );
312  // go over the equivalence classes
313  Vec_PtrForEachEntry( Aig_Obj_t **, pLcr->pCla->vClasses, ppClass, i )
314  {
315  pMiter = Aig_ManConst0(pNew);
316  for ( c = 0; ppClass[c]; c++ )
317  {
318  assert( Aig_ObjIsCi(ppClass[c]) );
319  pObjPo = Aig_ManCo( pLcr->pAig, Offset+(long)ppClass[c]->pNext );
320  pObjNew = Fra_LcrManDup_rec( pNew, pLcr->pAig, Aig_ObjFanin0(pObjPo) );
321  pMiter = Aig_Exor( pNew, pMiter, pObjNew );
322  }
323  Aig_ObjCreateCo( pNew, pMiter );
324  }
325  // go over the constant candidates
326  Vec_PtrForEachEntry( Aig_Obj_t *, pLcr->pCla->vClasses1, pObj, i )
327  {
328  assert( Aig_ObjIsCi(pObj) );
329  pObjPo = Aig_ManCo( pLcr->pAig, Offset+(long)pObj->pNext );
330  pMiter = Fra_LcrManDup_rec( pNew, pLcr->pAig, Aig_ObjFanin0(pObjPo) );
331  Aig_ObjCreateCo( pNew, pMiter );
332  }
333  return pNew;
334 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
void * pData
Definition: aig.h:87
Aig_Obj_t * Aig_Exor(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:220
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
static Aig_Obj_t * Aig_ManConst0(Aig_Man_t *p)
Definition: aig.h:263
Aig_Obj_t * Fra_LcrManDup_rec(Aig_Man_t *pNew, Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: fraLcr.c:266
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
Definition: aig.h:69
Aig_Obj_t * pNext
Definition: aig.h:72
Aig_Man_t * Aig_ManStartFrom(Aig_Man_t *p)
Definition: aigMan.c:92
static Aig_Obj_t * Aig_ManCo(Aig_Man_t *p, int i)
Definition: aig.h:267
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
void Aig_ManCleanData(Aig_Man_t *p)
Definition: aigUtil.c:205
Aig_Obj_t* Fra_LcrManDup_rec ( Aig_Man_t pNew,
Aig_Man_t p,
Aig_Obj_t pObj 
)

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

Synopsis [Duplicates the AIG manager recursively.]

Description []

SideEffects []

SeeAlso []

Definition at line 266 of file fraLcr.c.

267 {
268  Aig_Obj_t * pObjNew;
269  if ( pObj->pData )
270  return (Aig_Obj_t *)pObj->pData;
271  Fra_LcrManDup_rec( pNew, p, Aig_ObjFanin0(pObj) );
272  if ( Aig_ObjIsBuf(pObj) )
273  return (Aig_Obj_t *)(pObj->pData = Aig_ObjChild0Copy(pObj));
274  Fra_LcrManDup_rec( pNew, p, Aig_ObjFanin1(pObj) );
275  pObjNew = Aig_Oper( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj), Aig_ObjType(pObj) );
276  return (Aig_Obj_t *)(pObj->pData = pObjNew);
277 }
static Aig_Type_t Aig_ObjType(Aig_Obj_t *pObj)
Definition: aig.h:272
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
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
Aig_Obj_t * Aig_Oper(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1, Aig_Type_t Type)
Definition: aigOper.c:83
Aig_Obj_t * Fra_LcrManDup_rec(Aig_Man_t *pNew, Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: fraLcr.c:266
static int Aig_ObjIsBuf(Aig_Obj_t *pObj)
Definition: aig.h:277
static Aig_Obj_t * Aig_ObjChild1Copy(Aig_Obj_t *pObj)
Definition: aig.h:313
Definition: aig.h:69
static Aig_Obj_t * Aig_ObjChild0Copy(Aig_Obj_t *pObj)
Definition: aig.h:312
int Fra_LcrNodeIsConst ( Aig_Obj_t pObj)

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

Synopsis [Compares the node with a constant after partioned fraiging.]

Description []

SideEffects []

SeeAlso []

Definition at line 239 of file fraLcr.c.

240 {
241  Fra_Man_t * pTemp = (Fra_Man_t *)pObj->pData;
242  Fra_Lcr_t * pLcr = (Fra_Lcr_t *)pTemp->pBmc;
243  Aig_Man_t * pFraig;
244  Aig_Obj_t * pOut;
245  int nPart;
246  assert( Aig_ObjIsCi(pObj) );
247  // find the partition to which these nodes belong
248  nPart = pLcr->pInToOutPart[(long)pObj->pNext];
249  pFraig = (Aig_Man_t *)Vec_PtrEntry( pLcr->vFraigs, nPart );
250  // get the fraig outputs
251  pOut = Aig_ManCo( pFraig, pLcr->pInToOutNum[(long)pObj->pNext] );
252  return Aig_ObjFanin0(pOut) == Aig_ManConst1(pFraig);
253 }
typedefABC_NAMESPACE_IMPL_START struct Fra_Lcr_t_ Fra_Lcr_t
DECLARATIONS ///.
Definition: fraLcr.c:30
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
void * pData
Definition: aig.h:87
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
Fra_Bmc_t * pBmc
Definition: fra.h:202
Definition: aig.h:69
Aig_Obj_t * pNext
Definition: aig.h:72
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static Aig_Obj_t * Aig_ManCo(Aig_Man_t *p, int i)
Definition: aig.h:267
#define assert(ex)
Definition: util_old.h:213
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
int Fra_LcrNodesAreEqual ( Aig_Obj_t pObj0,
Aig_Obj_t pObj1 
)

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

Synopsis [Compares two nodes for equivalence after partitioned fraiging.]

Description []

SideEffects []

SeeAlso []

Definition at line 201 of file fraLcr.c.

202 {
203  Fra_Man_t * pTemp = (Fra_Man_t *)pObj0->pData;
204  Fra_Lcr_t * pLcr = (Fra_Lcr_t *)pTemp->pBmc;
205  Aig_Man_t * pFraig;
206  Aig_Obj_t * pOut0, * pOut1;
207  int nPart0, nPart1;
208  assert( Aig_ObjIsCi(pObj0) );
209  assert( Aig_ObjIsCi(pObj1) );
210  // find the partition to which these nodes belong
211  nPart0 = pLcr->pInToOutPart[(long)pObj0->pNext];
212  nPart1 = pLcr->pInToOutPart[(long)pObj1->pNext];
213  // if this is the result of refinement of the class created const-1 nodes
214  // the nodes may end up in different partions - we assume them equivalent
215  if ( nPart0 != nPart1 )
216  {
217  assert( 0 );
218  return 1;
219  }
220  assert( nPart0 == nPart1 );
221  pFraig = (Aig_Man_t *)Vec_PtrEntry( pLcr->vFraigs, nPart0 );
222  // get the fraig outputs
223  pOut0 = Aig_ManCo( pFraig, pLcr->pInToOutNum[(long)pObj0->pNext] );
224  pOut1 = Aig_ManCo( pFraig, pLcr->pInToOutNum[(long)pObj1->pNext] );
225  return Aig_ObjFanin0(pOut0) == Aig_ObjFanin0(pOut1);
226 }
typedefABC_NAMESPACE_IMPL_START struct Fra_Lcr_t_ Fra_Lcr_t
DECLARATIONS ///.
Definition: fraLcr.c:30
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
void * pData
Definition: aig.h:87
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
Fra_Bmc_t * pBmc
Definition: fra.h:202
Definition: aig.h:69
Aig_Obj_t * pNext
Definition: aig.h:72
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static Aig_Obj_t * Aig_ManCo(Aig_Man_t *p, int i)
Definition: aig.h:267
#define assert(ex)
Definition: util_old.h:213
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275
void Fra_LcrRemapPartitions ( Vec_Ptr_t vParts,
Fra_Cla_t pCla,
int *  pInToOutPart,
int *  pInToOutNum 
)

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

Synopsis [Remaps partitions into the inputs of original AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 347 of file fraLcr.c.

348 {
349  Vec_Int_t * vOne, * vOneNew;
350  Aig_Obj_t ** ppClass, * pObjPi;
351  int Out, Offset, i, k, c;
352  // compute the LO/LI offset
353  Offset = Aig_ManCoNum(pCla->pAig) - Aig_ManCiNum(pCla->pAig);
354  Vec_PtrForEachEntry( Vec_Int_t *, vParts, vOne, i )
355  {
356  vOneNew = Vec_IntAlloc( Vec_IntSize(vOne) );
357  Vec_IntForEachEntry( vOne, Out, k )
358  {
359  if ( Out < Vec_PtrSize(pCla->vClasses) )
360  {
361  ppClass = (Aig_Obj_t **)Vec_PtrEntry( pCla->vClasses, Out );
362  for ( c = 0; ppClass[c]; c++ )
363  {
364  pInToOutPart[(long)ppClass[c]->pNext] = i;
365  pInToOutNum[(long)ppClass[c]->pNext] = Vec_IntSize(vOneNew);
366  Vec_IntPush( vOneNew, Offset+(long)ppClass[c]->pNext );
367  }
368  }
369  else
370  {
371  pObjPi = (Aig_Obj_t *)Vec_PtrEntry( pCla->vClasses1, Out - Vec_PtrSize(pCla->vClasses) );
372  pInToOutPart[(long)pObjPi->pNext] = i;
373  pInToOutNum[(long)pObjPi->pNext] = Vec_IntSize(vOneNew);
374  Vec_IntPush( vOneNew, Offset+(long)pObjPi->pNext );
375  }
376  }
377  // replace the class
378  Vec_PtrWriteEntry( vParts, i, vOneNew );
379  Vec_IntFree( vOne );
380  }
381 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Vec_Ptr_t * vClasses
Definition: fra.h:154
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
Definition: aig.h:69
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
Aig_Obj_t * pNext
Definition: aig.h:72
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
Vec_Ptr_t * vClasses1
Definition: fra.h:155
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
Aig_Man_t * pAig
Definition: fra.h:152
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
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
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
Fra_Lcr_t* Lcr_ManAlloc ( Aig_Man_t pAig)

FUNCTION DEFINITIONS ///.

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

Synopsis [Allocates the retiming manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 80 of file fraLcr.c.

81 {
82  Fra_Lcr_t * p;
83  p = ABC_ALLOC( Fra_Lcr_t, 1 );
84  memset( p, 0, sizeof(Fra_Lcr_t) );
85  p->pAig = pAig;
86  p->pInToOutPart = ABC_ALLOC( int, Aig_ManCiNum(pAig) );
87  memset( p->pInToOutPart, 0, sizeof(int) * Aig_ManCiNum(pAig) );
88  p->pInToOutNum = ABC_ALLOC( int, Aig_ManCiNum(pAig) );
89  memset( p->pInToOutNum, 0, sizeof(int) * Aig_ManCiNum(pAig) );
90  p->vFraigs = Vec_PtrAlloc( 1000 );
91  return p;
92 }
char * memset()
typedefABC_NAMESPACE_IMPL_START struct Fra_Lcr_t_ Fra_Lcr_t
DECLARATIONS ///.
Definition: fraLcr.c:30
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
void Lcr_ManFree ( Fra_Lcr_t p)

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

Synopsis [Deallocates the retiming manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 131 of file fraLcr.c.

132 {
133  Aig_Obj_t * pObj;
134  int i;
135  if ( p->fVerbose )
136  Lcr_ManPrint( p );
137  Aig_ManForEachCi( p->pAig, pObj, i )
138  pObj->pNext = NULL;
139  Vec_PtrFree( p->vFraigs );
140  if ( p->pCla ) Fra_ClassesStop( p->pCla );
141  if ( p->vParts ) Vec_VecFree( (Vec_Vec_t *)p->vParts );
142  ABC_FREE( p->pInToOutPart );
143  ABC_FREE( p->pInToOutNum );
144  ABC_FREE( p );
145 }
Aig_Man_t * pAig
Definition: llb3Image.c:49
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
void Fra_ClassesStop(Fra_Cla_t *p)
Definition: fraClass.c:90
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Lcr_ManPrint(Fra_Lcr_t *p)
Definition: fraLcr.c:105
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Lcr_ManPrint ( Fra_Lcr_t p)

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

Synopsis [Prints stats for the fraiging manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 105 of file fraLcr.c.

106 {
107  printf( "Iterations = %d. LitBeg = %d. LitEnd = %d. (%6.2f %%).\n",
108  p->nIters, p->nLitsBeg, p->nLitsEnd, 100.0*p->nLitsEnd/p->nLitsBeg );
109  printf( "NBeg = %d. NEnd = %d. (Gain = %6.2f %%). RBeg = %d. REnd = %d. (Gain = %6.2f %%).\n",
110  p->nNodesBeg, p->nNodesEnd, 100.0*(p->nNodesBeg-p->nNodesEnd)/p->nNodesBeg,
111  p->nRegsBeg, p->nRegsEnd, 100.0*(p->nRegsBeg-p->nRegsEnd)/p->nRegsBeg );
112  ABC_PRT( "AIG simulation ", p->timeSim );
113  ABC_PRT( "AIG partitioning", p->timePart );
114  ABC_PRT( "AIG rebuiding ", p->timeTrav );
115  ABC_PRT( "FRAIGing ", p->timeFraig );
116  ABC_PRT( "AIG updating ", p->timeUpdate );
117  ABC_PRT( "TOTAL RUNTIME ", p->timeTotal );
118 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_PRT(a, t)
Definition: abc_global.h:220