abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
giaEra.c File Reference
#include "gia.h"
#include "misc/mem/mem.h"

Go to the source code of this file.

Data Structures

struct  Gia_ObjEra_t_
 
struct  Gia_ManEra_t_
 

Typedefs

typedef
typedefABC_NAMESPACE_IMPL_START
struct Gia_ObjEra_t_ 
Gia_ObjEra_t
 DECLARATIONS ///. More...
 
typedef struct Gia_ManEra_t_ Gia_ManEra_t
 

Functions

static unsigned * Gia_ManEraData (Gia_ManEra_t *p, int i)
 
static Gia_ObjEra_tGia_ManEraState (Gia_ManEra_t *p, int i)
 
Gia_ManEra_tGia_ManEraCreate (Gia_Man_t *pAig)
 FUNCTION DEFINITIONS ///. More...
 
void Gia_ManEraFree (Gia_ManEra_t *p)
 
Gia_ObjEra_tGia_ManEraCreateState (Gia_ManEra_t *p)
 
int Gia_ManEraStateHash (unsigned *pState, int nWordsSim, int nTableSize)
 
static unsigned * Gia_ManEraHashFind (Gia_ManEra_t *p, Gia_ObjEra_t *pState, int *pStateNum)
 
void Gia_ManEraHashResize (Gia_ManEra_t *p)
 
void Gia_ManInsertState (Gia_ManEra_t *p, Gia_ObjEra_t *pState)
 
static int Gia_ManOutputAsserted (Gia_ManEra_t *p, Gia_Obj_t *pObj)
 
static void Gia_ManSimulateCo (Gia_ManEra_t *p, Gia_Obj_t *pObj)
 
static void Gia_ManSimulateNode (Gia_ManEra_t *p, Gia_Obj_t *pObj)
 
void Gia_ManPerformOneIter (Gia_ManEra_t *p)
 
Vec_Int_tGia_ManCollectBugTrace (Gia_ManEra_t *p, Gia_ObjEra_t *pState, int iCond)
 
int Gia_ManCountDepth (Gia_ManEra_t *p)
 
int Gia_ManAnalyzeResult (Gia_ManEra_t *p, Gia_ObjEra_t *pState, int fMiter, int fStgDump)
 
int Gia_ManCollectReachable (Gia_Man_t *pAig, int nStatesMax, int fMiter, int fDumpFile, int fVerbose)
 

Typedef Documentation

typedef struct Gia_ManEra_t_ Gia_ManEra_t

Definition at line 43 of file giaEra.c.

typedef typedefABC_NAMESPACE_IMPL_START struct Gia_ObjEra_t_ Gia_ObjEra_t

DECLARATIONS ///.

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

FileName [giaEra.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Explicit reachability analysis.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 32 of file giaEra.c.

Function Documentation

int Gia_ManAnalyzeResult ( Gia_ManEra_t p,
Gia_ObjEra_t pState,
int  fMiter,
int  fStgDump 
)

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

Synopsis [Analized reached states.]

Description []

SideEffects []

SeeAlso []

Definition at line 449 of file giaEra.c.

450 {
451  Gia_Obj_t * pObj;
452  unsigned * pSimInfo, * piPlace, uOutput = 0;
453  int i, k, iCond, nMints, iNextState;
454  // check if the miter is asserted
455  if ( fMiter )
456  {
457  Gia_ManForEachPo( p->pAig, pObj, i )
458  {
459  iCond = Gia_ManOutputAsserted( p, pObj );
460  if ( iCond >= 0 )
461  {
462  p->vBugTrace = Gia_ManCollectBugTrace( p, pState, iCond );
463  return 1;
464  }
465  }
466  }
467  // collect reached states
468  nMints = (1 << Gia_ManPiNum(p->pAig));
469  for ( k = 0; k < nMints; k++ )
470  {
471  if ( p->pStateNew == NULL )
473  p->pStateNew->pData[p->nWordsDat-1] = 0;
474  Gia_ManForEachRi( p->pAig, pObj, i )
475  {
476  pSimInfo = Gia_ManEraData( p, Gia_ObjId(p->pAig, pObj) );
477  if ( Abc_InfoHasBit(p->pStateNew->pData, i) != Abc_InfoHasBit(pSimInfo, k) )
478  Abc_InfoXorBit( p->pStateNew->pData, i );
479  }
480  if ( fStgDump )
481  {
482  uOutput = 0;
483  Gia_ManForEachPo( p->pAig, pObj, i )
484  {
485  pSimInfo = Gia_ManEraData( p, Gia_ObjId(p->pAig, pObj) );
486  if ( Abc_InfoHasBit(pSimInfo, k) && i < 32 )
487  Abc_InfoXorBit( &uOutput, i );
488  }
489  }
490  piPlace = Gia_ManEraHashFind( p, p->pStateNew, &iNextState );
491  if ( fStgDump ) Vec_IntPush( p->vStgDump, k );
492  if ( fStgDump ) Vec_IntPush( p->vStgDump, pState->Num );
493  if ( piPlace == NULL )
494  {
495  if ( fStgDump ) Vec_IntPush( p->vStgDump, iNextState );
496  if ( fStgDump ) Vec_IntPush( p->vStgDump, uOutput );
497  continue;
498  }
499  if ( fStgDump ) Vec_IntPush( p->vStgDump, p->pStateNew->Num );
500  if ( fStgDump ) Vec_IntPush( p->vStgDump, uOutput );
501 //printf( "Inserting %d ", Vec_PtrSize(p->vStates) );
502 //Extra_PrintBinary( stdout, p->pStateNew->pData, Gia_ManRegNum(p->pAig) ); printf( "\n" );
503  assert( *piPlace == 0 );
504  *piPlace = p->pStateNew->Num;
505  p->pStateNew->Cond = k;
506  p->pStateNew->iPrev = pState->Num;
507  p->pStateNew->iNext = 0;
508  p->pStateNew = NULL;
509  // expand hash table if needed
510  if ( Vec_PtrSize(p->vStates) > 2 * p->nBins )
512  }
513  return 0;
514 }
Gia_ObjEra_t * pStateNew
Definition: giaEra.c:52
static unsigned * Gia_ManEraHashFind(Gia_ManEra_t *p, Gia_ObjEra_t *pState, int *pStateNum)
Definition: giaEra.c:201
static int Abc_InfoHasBit(unsigned *p, int i)
Definition: abc_global.h:258
static void Abc_InfoXorBit(unsigned *p, int i)
Definition: abc_global.h:260
Vec_Int_t * vBugTrace
Definition: giaEra.c:54
int nBins
Definition: giaEra.c:57
Vec_Int_t * Gia_ManCollectBugTrace(Gia_ManEra_t *p, Gia_ObjEra_t *pState, int iCond)
Definition: giaEra.c:404
int nWordsDat
Definition: giaEra.c:48
static int Gia_ManOutputAsserted(Gia_ManEra_t *p, Gia_Obj_t *pObj)
Definition: giaEra.c:296
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Definition: gia.h:75
static unsigned * Gia_ManEraData(Gia_ManEra_t *p, int i)
Definition: giaEra.c:61
Vec_Int_t * vStgDump
Definition: giaEra.c:55
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
void Gia_ManEraHashResize(Gia_ManEra_t *p)
Definition: giaEra.c:229
Vec_Ptr_t * vStates
Definition: giaEra.c:51
#define assert(ex)
Definition: util_old.h:213
#define Gia_ManForEachRi(p, pObj, i)
Definition: gia.h:1040
Gia_Man_t * pAig
Definition: giaEra.c:46
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
#define Gia_ManForEachPo(p, pObj, i)
Definition: gia.h:1036
Gia_ObjEra_t * Gia_ManEraCreateState(Gia_ManEra_t *p)
Definition: giaEra.c:143
Vec_Int_t* Gia_ManCollectBugTrace ( Gia_ManEra_t p,
Gia_ObjEra_t pState,
int  iCond 
)

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

Synopsis [Performs one iteration of reachability analysis.]

Description []

SideEffects []

SeeAlso []

Definition at line 404 of file giaEra.c.

405 {
406  Vec_Int_t * vTrace;
407  vTrace = Vec_IntAlloc( 10 );
408  Vec_IntPush( vTrace, iCond );
409  for ( ; pState; pState = pState->iPrev ? Gia_ManEraState(p, pState->iPrev) : NULL )
410  Vec_IntPush( vTrace, pState->Cond );
411  Vec_IntReverseOrder( vTrace );
412  return vTrace;
413 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static void Vec_IntReverseOrder(Vec_Int_t *p)
Definition: vecInt.h:1042
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
static Gia_ObjEra_t * Gia_ManEraState(Gia_ManEra_t *p, int i)
Definition: giaEra.c:62
int Gia_ManCollectReachable ( Gia_Man_t pAig,
int  nStatesMax,
int  fMiter,
int  fDumpFile,
int  fVerbose 
)

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

Synopsis [Resizes the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 527 of file giaEra.c.

528 {
529  Gia_ManEra_t * p;
530  Gia_ObjEra_t * pState;
531  int Hash;
532  abctime clk = Abc_Clock();
533  int RetValue = 1;
534  assert( Gia_ManPiNum(pAig) <= 12 );
535  assert( Gia_ManRegNum(pAig) > 0 );
536  p = Gia_ManEraCreate( pAig );
537  // create init state
538  pState = Gia_ManEraCreateState( p );
539  pState->Cond = 0;
540  pState->iPrev = 0;
541  pState->iNext = 0;
542  memset( pState->pData, 0, sizeof(unsigned) * p->nWordsDat );
543  Hash = Gia_ManEraStateHash(pState->pData, p->nWordsDat, p->nBins);
544  p->pBins[ Hash ] = pState->Num;
545  // process reachable states
546  while ( p->iCurState < Vec_PtrSize( p->vStates ) - 1 )
547  {
548  if ( Vec_PtrSize(p->vStates) >= nStatesMax )
549  {
550  printf( "Reached the limit on states traversed (%d). ", nStatesMax );
551  RetValue = -1;
552  break;
553  }
554  pState = Gia_ManEraState( p, ++p->iCurState );
555  if ( p->iCurState > 1 && pState->iPrev == 0 )
556  continue;
557 //printf( "Extracting %d ", p->iCurState );
558 //Extra_PrintBinary( stdout, p->pStateNew->pData, Gia_ManRegNum(p->pAig) ); printf( "\n" );
559  Gia_ManInsertState( p, pState );
561  if ( Gia_ManAnalyzeResult( p, pState, fMiter, fDumpFile ) && fMiter )
562  {
563  RetValue = 0;
564  printf( "Miter failed in state %d after %d transitions. ",
565  p->iCurState, Vec_IntSize(p->vBugTrace)-1 );
566  break;
567  }
568  if ( fVerbose && p->iCurState % 5000 == 0 )
569  {
570  printf( "States =%10d. Reached =%10d. R = %5.3f. Depth =%6d. Mem =%9.2f MB. ",
572  (1.0/(1<<20))*(1.0*Vec_PtrSize(p->vStates)*(sizeof(Gia_ObjEra_t) + sizeof(unsigned) * p->nWordsDat) +
573  1.0*p->nBins*sizeof(unsigned) + 1.0*p->vStates->nCap * sizeof(void*)) );
574  ABC_PRT( "Time", Abc_Clock() - clk );
575  }
576  }
577  printf( "Reachability analysis traversed %d states with depth %d. ", p->iCurState-1, Gia_ManCountDepth(p) );
578  ABC_PRT( "Time", Abc_Clock() - clk );
579  if ( fDumpFile )
580  {
581  char * pFileName = "test.stg";
582  FILE * pFile = fopen( pFileName, "wb" );
583  if ( pFile == NULL )
584  printf( "Cannot open file \"%s\" for writing.\n", pFileName );
585  else
586  {
587  Gia_ManStgPrint( pFile, p->vStgDump, Gia_ManPiNum(pAig), Gia_ManPoNum(pAig), p->iCurState-1 );
588  fclose( pFile );
589  printf( "Extracted STG was written into file \"%s\".\n", pFileName );
590  }
591  }
592  Gia_ManEraFree( p );
593  return RetValue;
594 }
char * memset()
int Gia_ManCountDepth(Gia_ManEra_t *p)
Definition: giaEra.c:426
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
unsigned * pBins
Definition: giaEra.c:58
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Gia_ManEraFree(Gia_ManEra_t *p)
Definition: giaEra.c:121
void Gia_ManStgPrint(FILE *pFile, Vec_Int_t *vLines, int nIns, int nOuts, int nStates)
Definition: giaStg.c:407
Vec_Int_t * vBugTrace
Definition: giaEra.c:54
int nBins
Definition: giaEra.c:57
Gia_ManEra_t * Gia_ManEraCreate(Gia_Man_t *pAig)
FUNCTION DEFINITIONS ///.
Definition: giaEra.c:79
int nWordsDat
Definition: giaEra.c:48
int Gia_ManAnalyzeResult(Gia_ManEra_t *p, Gia_ObjEra_t *pState, int fMiter, int fStgDump)
Definition: giaEra.c:449
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Vec_Int_t * vStgDump
Definition: giaEra.c:55
typedefABC_NAMESPACE_IMPL_START struct Gia_ObjEra_t_ Gia_ObjEra_t
DECLARATIONS ///.
Definition: giaEra.c:32
int Gia_ManEraStateHash(unsigned *pState, int nWordsSim, int nTableSize)
Definition: giaEra.c:165
void Gia_ManInsertState(Gia_ManEra_t *p, Gia_ObjEra_t *pState)
Definition: giaEra.c:270
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
void Gia_ManPerformOneIter(Gia_ManEra_t *p)
Definition: giaEra.c:380
#define ABC_PRT(a, t)
Definition: abc_global.h:220
Vec_Ptr_t * vStates
Definition: giaEra.c:51
#define assert(ex)
Definition: util_old.h:213
int iCurState
Definition: giaEra.c:53
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
ABC_INT64_T abctime
Definition: abc_global.h:278
static Gia_ObjEra_t * Gia_ManEraState(Gia_ManEra_t *p, int i)
Definition: giaEra.c:62
Gia_ObjEra_t * Gia_ManEraCreateState(Gia_ManEra_t *p)
Definition: giaEra.c:143
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
int Gia_ManCountDepth ( Gia_ManEra_t p)

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

Synopsis [Counts the depth of state transitions leading ot this state.]

Description []

SideEffects []

SeeAlso []

Definition at line 426 of file giaEra.c.

427 {
428  Gia_ObjEra_t * pState;
429  int Counter = 0;
430  pState = (Gia_ObjEra_t *)Vec_PtrEntryLast( p->vStates );
431  if ( pState->iPrev == 0 && Vec_PtrSize(p->vStates) > 3 )
432  pState = (Gia_ObjEra_t *)Vec_PtrEntry( p->vStates, Vec_PtrSize(p->vStates) - 2 );
433  for ( ; pState; pState = pState->iPrev ? Gia_ManEraState(p, pState->iPrev) : NULL )
434  Counter++;
435  return Counter;
436 }
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void * Vec_PtrEntryLast(Vec_Ptr_t *p)
Definition: vecPtr.h:413
typedefABC_NAMESPACE_IMPL_START struct Gia_ObjEra_t_ Gia_ObjEra_t
DECLARATIONS ///.
Definition: giaEra.c:32
static int Counter
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
Vec_Ptr_t * vStates
Definition: giaEra.c:51
static Gia_ObjEra_t * Gia_ManEraState(Gia_ManEra_t *p, int i)
Definition: giaEra.c:62
Gia_ManEra_t* Gia_ManEraCreate ( Gia_Man_t pAig)

FUNCTION DEFINITIONS ///.

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

Synopsis [Creates reachability manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 79 of file giaEra.c.

80 {
81  Vec_Ptr_t * vTruths;
82  Gia_ManEra_t * p;
83  unsigned * pTruth, * pSimInfo;
84  int i;
85  p = ABC_CALLOC( Gia_ManEra_t, 1 );
86  p->pAig = pAig;
89  p->pDataSim = ABC_ALLOC( unsigned, p->nWordsSim*Gia_ManObjNum(pAig) );
90  p->pMemory = Mem_FixedStart( sizeof(Gia_ObjEra_t) + sizeof(unsigned) * p->nWordsDat );
91  p->vStates = Vec_PtrAlloc( 100000 );
92  p->nBins = Abc_PrimeCudd( 100000 );
93  p->pBins = ABC_CALLOC( unsigned, p->nBins );
94  Vec_PtrPush( p->vStates, NULL );
95  // assign primary input values
96  vTruths = Vec_PtrAllocTruthTables( Gia_ManPiNum(pAig) );
97  Vec_PtrForEachEntry( unsigned *, vTruths, pTruth, i )
98  {
99  pSimInfo = Gia_ManEraData( p, Gia_ObjId(pAig, Gia_ManPi(pAig, i)) );
100  memcpy( pSimInfo, pTruth, sizeof(unsigned) * p->nWordsSim );
101  }
102  Vec_PtrFree( vTruths );
103  // assign constant zero node
104  pSimInfo = Gia_ManEraData( p, 0 );
105  memset( pSimInfo, 0, sizeof(unsigned) * p->nWordsSim );
106  p->vStgDump = Vec_IntAlloc( 1000 );
107  return p;
108 }
char * memset()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
int nWordsSim
Definition: giaEra.c:47
unsigned * pBins
Definition: giaEra.c:58
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Mem_Fixed_t * pMemory
Definition: giaEra.c:50
int nBins
Definition: giaEra.c:57
int nWordsDat
Definition: giaEra.c:48
char * memcpy()
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Abc_TruthWordNum(int nVars)
Definition: abc_global.h:256
static Vec_Ptr_t * Vec_PtrAllocTruthTables(int nVars)
Definition: vecPtr.h:1065
Mem_Fixed_t * Mem_FixedStart(int nEntrySize)
FUNCTION DEFINITIONS ///.
Definition: mem.c:100
static unsigned * Gia_ManEraData(Gia_ManEra_t *p, int i)
Definition: giaEra.c:61
static Gia_Obj_t * Gia_ManPi(Gia_Man_t *p, int v)
Definition: gia.h:405
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
Vec_Int_t * vStgDump
Definition: giaEra.c:55
typedefABC_NAMESPACE_IMPL_START struct Gia_ObjEra_t_ Gia_ObjEra_t
DECLARATIONS ///.
Definition: giaEra.c:32
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
unsigned * pDataSim
Definition: giaEra.c:49
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
static int Abc_BitWordNum(int nBits)
Definition: abc_global.h:255
Vec_Ptr_t * vStates
Definition: giaEra.c:51
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
Gia_Man_t * pAig
Definition: giaEra.c:46
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
static int Gia_ManRegNum(Gia_Man_t *p)
Definition: gia.h:387
Gia_ObjEra_t* Gia_ManEraCreateState ( Gia_ManEra_t p)

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

Synopsis [Creates new state.]

Description []

SideEffects []

SeeAlso []

Definition at line 143 of file giaEra.c.

144 {
145  Gia_ObjEra_t * pNew;
146  pNew = (Gia_ObjEra_t *)Mem_FixedEntryFetch( p->pMemory );
147  pNew->Num = Vec_PtrSize( p->vStates );
148  pNew->iPrev = 0;
149  Vec_PtrPush( p->vStates, pNew );
150  return pNew;
151 }
Mem_Fixed_t * pMemory
Definition: giaEra.c:50
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
typedefABC_NAMESPACE_IMPL_START struct Gia_ObjEra_t_ Gia_ObjEra_t
DECLARATIONS ///.
Definition: giaEra.c:32
Vec_Ptr_t * vStates
Definition: giaEra.c:51
char * Mem_FixedEntryFetch(Mem_Fixed_t *p)
Definition: mem.c:168
static unsigned* Gia_ManEraData ( Gia_ManEra_t p,
int  i 
)
inlinestatic

Definition at line 61 of file giaEra.c.

61 { return p->pDataSim + i * p->nWordsSim; }
int nWordsSim
Definition: giaEra.c:47
unsigned * pDataSim
Definition: giaEra.c:49
void Gia_ManEraFree ( Gia_ManEra_t p)

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

Synopsis [Deletes reachability manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 121 of file giaEra.c.

122 {
123  Mem_FixedStop( p->pMemory, 0 );
124  Vec_IntFree( p->vStgDump );
125  Vec_PtrFree( p->vStates );
126  if ( p->vBugTrace ) Vec_IntFree( p->vBugTrace );
127  ABC_FREE( p->pDataSim );
128  ABC_FREE( p->pBins );
129  ABC_FREE( p );
130 }
unsigned * pBins
Definition: giaEra.c:58
Mem_Fixed_t * pMemory
Definition: giaEra.c:50
Vec_Int_t * vBugTrace
Definition: giaEra.c:54
void Mem_FixedStop(Mem_Fixed_t *p, int fVerbose)
Definition: mem.c:139
Vec_Int_t * vStgDump
Definition: giaEra.c:55
unsigned * pDataSim
Definition: giaEra.c:49
#define ABC_FREE(obj)
Definition: abc_global.h:232
Vec_Ptr_t * vStates
Definition: giaEra.c:51
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
static unsigned* Gia_ManEraHashFind ( Gia_ManEra_t p,
Gia_ObjEra_t pState,
int *  pStateNum 
)
inlinestatic

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

Synopsis [Returns the place of this state in the table or NULL if it exists.]

Description []

SideEffects []

SeeAlso []

Definition at line 201 of file giaEra.c.

202 {
203  Gia_ObjEra_t * pThis;
204  unsigned * pPlace = p->pBins + Gia_ManEraStateHash( pState->pData, p->nWordsDat, p->nBins );
205  for ( pThis = (*pPlace)? Gia_ManEraState(p, *pPlace) : NULL; pThis;
206  pPlace = (unsigned *)&pThis->iNext, pThis = (*pPlace)? Gia_ManEraState(p, *pPlace) : NULL )
207  if ( !memcmp( pState->pData, pThis->pData, sizeof(unsigned) * p->nWordsDat ) )
208  {
209  if ( pStateNum )
210  *pStateNum = pThis->Num;
211  return NULL;
212  }
213  if ( pStateNum )
214  *pStateNum = -1;
215  return pPlace;
216 }
unsigned * pBins
Definition: giaEra.c:58
int nBins
Definition: giaEra.c:57
int nWordsDat
Definition: giaEra.c:48
if(last==0)
Definition: sparse_int.h:34
int memcmp()
typedefABC_NAMESPACE_IMPL_START struct Gia_ObjEra_t_ Gia_ObjEra_t
DECLARATIONS ///.
Definition: giaEra.c:32
int Gia_ManEraStateHash(unsigned *pState, int nWordsSim, int nTableSize)
Definition: giaEra.c:165
static Gia_ObjEra_t * Gia_ManEraState(Gia_ManEra_t *p, int i)
Definition: giaEra.c:62
void Gia_ManEraHashResize ( Gia_ManEra_t p)

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

Synopsis [Resizes the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 229 of file giaEra.c.

230 {
231  Gia_ObjEra_t * pThis;
232  unsigned * pBinsOld, * piPlace;
233  int nBinsOld, iNext, Counter, i;
234  assert( p->pBins != NULL );
235  // replace the table
236  pBinsOld = p->pBins;
237  nBinsOld = p->nBins;
238  p->nBins = Abc_PrimeCudd( 3 * p->nBins );
239  p->pBins = ABC_CALLOC( unsigned, p->nBins );
240  // rehash the entries from the old table
241  Counter = 0;
242  for ( i = 0; i < nBinsOld; i++ )
243  for ( pThis = (pBinsOld[i]? Gia_ManEraState(p, pBinsOld[i]) : NULL),
244  iNext = (pThis? pThis->iNext : 0);
245  pThis; pThis = (iNext? Gia_ManEraState(p, iNext) : NULL),
246  iNext = (pThis? pThis->iNext : 0) )
247  {
248  assert( pThis->Num );
249  pThis->iNext = 0;
250  piPlace = Gia_ManEraHashFind( p, pThis, NULL );
251  assert( *piPlace == 0 ); // should not be there
252  *piPlace = pThis->Num;
253  Counter++;
254  }
255  assert( Counter == Vec_PtrSize( p->vStates ) - 1 );
256  ABC_FREE( pBinsOld );
257 }
static unsigned * Gia_ManEraHashFind(Gia_ManEra_t *p, Gia_ObjEra_t *pState, int *pStateNum)
Definition: giaEra.c:201
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
unsigned * pBins
Definition: giaEra.c:58
int nBins
Definition: giaEra.c:57
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
typedefABC_NAMESPACE_IMPL_START struct Gia_ObjEra_t_ Gia_ObjEra_t
DECLARATIONS ///.
Definition: giaEra.c:32
static int Counter
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
Vec_Ptr_t * vStates
Definition: giaEra.c:51
#define assert(ex)
Definition: util_old.h:213
static Gia_ObjEra_t * Gia_ManEraState(Gia_ManEra_t *p, int i)
Definition: giaEra.c:62
static Gia_ObjEra_t* Gia_ManEraState ( Gia_ManEra_t p,
int  i 
)
inlinestatic

Definition at line 62 of file giaEra.c.

62 { return (Gia_ObjEra_t *)Vec_PtrEntry(p->vStates, i); }
typedefABC_NAMESPACE_IMPL_START struct Gia_ObjEra_t_ Gia_ObjEra_t
DECLARATIONS ///.
Definition: giaEra.c:32
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
Vec_Ptr_t * vStates
Definition: giaEra.c:51
int Gia_ManEraStateHash ( unsigned *  pState,
int  nWordsSim,
int  nTableSize 
)

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

Synopsis [Computes hash value of the node using its simulation info.]

Description []

SideEffects []

SeeAlso []

Definition at line 165 of file giaEra.c.

166 {
167  static int s_FPrimes[128] = {
168  1009, 1049, 1093, 1151, 1201, 1249, 1297, 1361, 1427, 1459,
169  1499, 1559, 1607, 1657, 1709, 1759, 1823, 1877, 1933, 1997,
170  2039, 2089, 2141, 2213, 2269, 2311, 2371, 2411, 2467, 2543,
171  2609, 2663, 2699, 2741, 2797, 2851, 2909, 2969, 3037, 3089,
172  3169, 3221, 3299, 3331, 3389, 3461, 3517, 3557, 3613, 3671,
173  3719, 3779, 3847, 3907, 3943, 4013, 4073, 4129, 4201, 4243,
174  4289, 4363, 4441, 4493, 4549, 4621, 4663, 4729, 4793, 4871,
175  4933, 4973, 5021, 5087, 5153, 5227, 5281, 5351, 5417, 5471,
176  5519, 5573, 5651, 5693, 5749, 5821, 5861, 5923, 6011, 6073,
177  6131, 6199, 6257, 6301, 6353, 6397, 6481, 6563, 6619, 6689,
178  6737, 6803, 6863, 6917, 6977, 7027, 7109, 7187, 7237, 7309,
179  7393, 7477, 7523, 7561, 7607, 7681, 7727, 7817, 7877, 7933,
180  8011, 8039, 8059, 8081, 8093, 8111, 8123, 8147
181  };
182  unsigned uHash;
183  int i;
184  uHash = 0;
185  for ( i = 0; i < nWordsSim; i++ )
186  uHash ^= pState[i] * s_FPrimes[i & 0x7F];
187  return uHash % nTableSize;
188 }
void Gia_ManInsertState ( Gia_ManEra_t p,
Gia_ObjEra_t pState 
)

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

Synopsis [Initialize register output to the given state.]

Description []

SideEffects []

SeeAlso []

Definition at line 270 of file giaEra.c.

271 {
272  Gia_Obj_t * pObj;
273  unsigned * pSimInfo;
274  int i;
275  Gia_ManForEachRo( p->pAig, pObj, i )
276  {
277  pSimInfo = Gia_ManEraData( p, Gia_ObjId(p->pAig, pObj) );
278  if ( Abc_InfoHasBit(pState->pData, i) )
279  memset( pSimInfo, 0xff, sizeof(unsigned) * p->nWordsSim );
280  else
281  memset( pSimInfo, 0, sizeof(unsigned) * p->nWordsSim );
282  }
283 }
char * memset()
int nWordsSim
Definition: giaEra.c:47
static int Abc_InfoHasBit(unsigned *p, int i)
Definition: abc_global.h:258
Definition: gia.h:75
static unsigned * Gia_ManEraData(Gia_ManEra_t *p, int i)
Definition: giaEra.c:61
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
#define Gia_ManForEachRo(p, pObj, i)
Definition: gia.h:1038
Gia_Man_t * pAig
Definition: giaEra.c:46
static int Gia_ManOutputAsserted ( Gia_ManEra_t p,
Gia_Obj_t pObj 
)
inlinestatic

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

Synopsis [Returns -1 if outputs are not asserted.]

Description []

SideEffects []

SeeAlso []

Definition at line 296 of file giaEra.c.

297 {
298  unsigned * pInfo = Gia_ManEraData( p, Gia_ObjId(p->pAig, pObj) );
299  int w;
300  for ( w = 0; w < p->nWordsSim; w++ )
301  if ( pInfo[w] )
302  return 32*w + Gia_WordFindFirstBit( pInfo[w] );
303  return -1;
304 }
int nWordsSim
Definition: giaEra.c:47
static int Gia_WordFindFirstBit(unsigned uWord)
Definition: gia.h:321
static unsigned * Gia_ManEraData(Gia_ManEra_t *p, int i)
Definition: giaEra.c:61
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
Gia_Man_t * pAig
Definition: giaEra.c:46
void Gia_ManPerformOneIter ( Gia_ManEra_t p)

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

Synopsis [Performs one iteration of reachability analysis.]

Description []

SideEffects []

SeeAlso []

Definition at line 380 of file giaEra.c.

381 {
382  Gia_Obj_t * pObj;
383  int i;
384  Gia_ManForEachObj1( p->pAig, pObj, i )
385  {
386  if ( Gia_ObjIsAnd(pObj) )
387  Gia_ManSimulateNode( p, pObj );
388  else if ( Gia_ObjIsCo(pObj) )
389  Gia_ManSimulateCo( p, pObj );
390  }
391 }
static void Gia_ManSimulateCo(Gia_ManEra_t *p, Gia_Obj_t *pObj)
Definition: giaEra.c:317
static void Gia_ManSimulateNode(Gia_ManEra_t *p, Gia_Obj_t *pObj)
Definition: giaEra.c:342
Definition: gia.h:75
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
Definition: gia.h:421
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
#define Gia_ManForEachObj1(p, pObj, i)
Definition: gia.h:986
Gia_Man_t * pAig
Definition: giaEra.c:46
static void Gia_ManSimulateCo ( Gia_ManEra_t p,
Gia_Obj_t pObj 
)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 317 of file giaEra.c.

318 {
319  int Id = Gia_ObjId(p->pAig, pObj);
320  unsigned * pInfo = Gia_ManEraData( p, Id );
321  unsigned * pInfo0 = Gia_ManEraData( p, Gia_ObjFaninId0(pObj, Id) );
322  int w;
323  if ( Gia_ObjFaninC0(pObj) )
324  for ( w = p->nWordsSim-1; w >= 0; w-- )
325  pInfo[w] = ~pInfo0[w];
326  else
327  for ( w = p->nWordsSim-1; w >= 0; w-- )
328  pInfo[w] = pInfo0[w];
329 }
int nWordsSim
Definition: giaEra.c:47
static unsigned * Gia_ManEraData(Gia_ManEra_t *p, int i)
Definition: giaEra.c:61
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
Gia_Man_t * pAig
Definition: giaEra.c:46
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460
static void Gia_ManSimulateNode ( Gia_ManEra_t p,
Gia_Obj_t pObj 
)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 342 of file giaEra.c.

343 {
344  int Id = Gia_ObjId(p->pAig, pObj);
345  unsigned * pInfo = Gia_ManEraData( p, Id );
346  unsigned * pInfo0 = Gia_ManEraData( p, Gia_ObjFaninId0(pObj, Id) );
347  unsigned * pInfo1 = Gia_ManEraData( p, Gia_ObjFaninId1(pObj, Id) );
348  int w;
349  if ( Gia_ObjFaninC0(pObj) )
350  {
351  if ( Gia_ObjFaninC1(pObj) )
352  for ( w = p->nWordsSim-1; w >= 0; w-- )
353  pInfo[w] = ~(pInfo0[w] | pInfo1[w]);
354  else
355  for ( w = p->nWordsSim-1; w >= 0; w-- )
356  pInfo[w] = ~pInfo0[w] & pInfo1[w];
357  }
358  else
359  {
360  if ( Gia_ObjFaninC1(pObj) )
361  for ( w = p->nWordsSim-1; w >= 0; w-- )
362  pInfo[w] = pInfo0[w] & ~pInfo1[w];
363  else
364  for ( w = p->nWordsSim-1; w >= 0; w-- )
365  pInfo[w] = pInfo0[w] & pInfo1[w];
366  }
367 }
int nWordsSim
Definition: giaEra.c:47
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
Definition: gia.h:452
static unsigned * Gia_ManEraData(Gia_ManEra_t *p, int i)
Definition: giaEra.c:61
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
Definition: gia.h:451
Gia_Man_t * pAig
Definition: giaEra.c:46
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:461
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
Definition: gia.h:460