ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
giaEra.c File Reference
#include "gia.h"
#include "misc/mem/mem.h"
Include dependency graph for giaEra.c:

Go to the source code of this file.

Classes

struct  Gia_ObjEra_t_
 
struct  Gia_ManEra_t_
 

Typedefs

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

Functions

Gia_ManEra_tGia_ManEraCreate (Gia_Man_t *pAig)
 FUNCTION DEFINITIONS ///.
 
void Gia_ManEraFree (Gia_ManEra_t *p)
 
Gia_ObjEra_tGia_ManEraCreateState (Gia_ManEra_t *p)
 
int Gia_ManEraStateHash (unsigned *pState, int nWordsSim, int nTableSize)
 
void Gia_ManEraHashResize (Gia_ManEra_t *p)
 
void Gia_ManInsertState (Gia_ManEra_t *p, Gia_ObjEra_t *pState)
 
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

◆ Gia_ManEra_t

typedef struct Gia_ManEra_t_ Gia_ManEra_t

Definition at line 43 of file giaEra.c.

◆ Gia_ObjEra_t

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

◆ Gia_ManAnalyzeResult()

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 )
472 p->pStateNew = Gia_ManEraCreateState( p );
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}
Cube * p
Definition exorList.c:222
Vec_Int_t * Gia_ManCollectBugTrace(Gia_ManEra_t *p, Gia_ObjEra_t *pState, int iCond)
Definition giaEra.c:404
Gia_ObjEra_t * Gia_ManEraCreateState(Gia_ManEra_t *p)
Definition giaEra.c:143
void Gia_ManEraHashResize(Gia_ManEra_t *p)
Definition giaEra.c:229
#define Gia_ManForEachPo(p, pObj, i)
Definition gia.h:1250
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
#define Gia_ManForEachRi(p, pObj, i)
Definition gia.h:1254
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManCollectBugTrace()

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
Here is the caller graph for this function:

◆ Gia_ManCollectReachable()

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. ",
571 p->iCurState, Vec_PtrSize(p->vStates), 1.0*p->iCurState/Vec_PtrSize(p->vStates), Gia_ManCountDepth(p),
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}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
Gia_ManEra_t * Gia_ManEraCreate(Gia_Man_t *pAig)
FUNCTION DEFINITIONS ///.
Definition giaEra.c:79
void Gia_ManPerformOneIter(Gia_ManEra_t *p)
Definition giaEra.c:380
struct Gia_ManEra_t_ Gia_ManEra_t
Definition giaEra.c:43
void Gia_ManInsertState(Gia_ManEra_t *p, Gia_ObjEra_t *pState)
Definition giaEra.c:270
int Gia_ManEraStateHash(unsigned *pState, int nWordsSim, int nTableSize)
Definition giaEra.c:165
typedefABC_NAMESPACE_IMPL_START struct Gia_ObjEra_t_ Gia_ObjEra_t
DECLARATIONS ///.
Definition giaEra.c:32
int Gia_ManCountDepth(Gia_ManEra_t *p)
Definition giaEra.c:426
void Gia_ManEraFree(Gia_ManEra_t *p)
Definition giaEra.c:121
int Gia_ManAnalyzeResult(Gia_ManEra_t *p, Gia_ObjEra_t *pState, int fMiter, int fStgDump)
Definition giaEra.c:449
void Gia_ManStgPrint(FILE *pFile, Vec_Int_t *vLines, int nIns, int nOuts, int nStates)
Definition giaStg.c:407
char * memset()
Here is the call graph for this function:

◆ Gia_ManCountDepth()

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}
Here is the caller graph for this function:

◆ Gia_ManEraCreate()

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;
83 unsigned * pTruth, * pSimInfo;
84 int i;
86 p->pAig = pAig;
87 p->nWordsSim = Abc_TruthWordNum( Gia_ManPiNum(pAig) );
88 p->nWordsDat = Abc_BitWordNum( Gia_ManRegNum(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}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
Mem_Fixed_t * Mem_FixedStart(int nEntrySize)
FUNCTION DEFINITIONS ///.
Definition mem.c:100
char * memcpy()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManEraCreateState()

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}
char * Mem_FixedEntryFetch(Mem_Fixed_t *p)
Definition mem.c:184
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManEraFree()

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}
#define ABC_FREE(obj)
Definition abc_global.h:267
void Mem_FixedStop(Mem_Fixed_t *p, int fVerbose)
Definition mem.c:139
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManEraHashResize()

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}
Here is the caller graph for this function:

◆ Gia_ManEraStateHash()

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}
Here is the caller graph for this function:

◆ Gia_ManInsertState()

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}
#define Gia_ManForEachRo(p, pObj, i)
Definition gia.h:1252
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManPerformOneIter()

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}
#define Gia_ManForEachObj1(p, pObj, i)
Definition gia.h:1192
Here is the caller graph for this function: