diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2012-11-02 12:02:16 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2012-11-02 12:02:16 -0700 |
commit | 96d3348d8ffc7324472c9fa8e65d1d4c9e4752df (patch) | |
tree | 8421dd238219a9cfa6996a26710e3435ae9879bf /src/aig/gia | |
parent | f829eca5483d4bec52bc1f090f8e7def180b3454 (diff) | |
download | abc-96d3348d8ffc7324472c9fa8e65d1d4c9e4752df.tar.gz abc-96d3348d8ffc7324472c9fa8e65d1d4c9e4752df.tar.bz2 abc-96d3348d8ffc7324472c9fa8e65d1d4c9e4752df.zip |
Fixing out-of-bound problem when collecting GIA nodes.
Diffstat (limited to 'src/aig/gia')
-rw-r--r-- | src/aig/gia/gia.h | 2 | ||||
-rw-r--r-- | src/aig/gia/giaTruth.c | 22 |
2 files changed, 17 insertions, 7 deletions
diff --git a/src/aig/gia/gia.h b/src/aig/gia/gia.h index 35d80047..8c3d761c 100644 --- a/src/aig/gia/gia.h +++ b/src/aig/gia/gia.h @@ -889,7 +889,7 @@ extern float Gia_ManEvaluateSwitching( Gia_Man_t * p ); extern float Gia_ManComputeSwitching( Gia_Man_t * p, int nFrames, int nPref, int fProbOne ); /*=== giaTruth.c ===========================================================*/ extern word Gia_ObjComputeTruthTable6( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vSupp, Vec_Wrd_t * vTruths ); -extern void Gia_ObjCollectInternal( Gia_Man_t * p, Gia_Obj_t * pObj ); +extern int Gia_ObjCollectInternal( Gia_Man_t * p, Gia_Obj_t * pObj ); extern unsigned * Gia_ObjComputeTruthTable( Gia_Man_t * p, Gia_Obj_t * pObj ); extern void Gia_ObjComputeTruthTableStart( Gia_Man_t * p, int nVarsMax ); extern void Gia_ObjComputeTruthTableStop( Gia_Man_t * p ); diff --git a/src/aig/gia/giaTruth.c b/src/aig/gia/giaTruth.c index 24d8d879..d8a1bb49 100644 --- a/src/aig/gia/giaTruth.c +++ b/src/aig/gia/giaTruth.c @@ -105,23 +105,28 @@ word Gia_ObjComputeTruthTable6( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vSu SeeAlso [] ***********************************************************************/ -void Gia_ObjCollectInternal_rec( Gia_Man_t * p, Gia_Obj_t * pObj ) +int Gia_ObjCollectInternal_rec( Gia_Man_t * p, Gia_Obj_t * pObj ) { if ( !Gia_ObjIsAnd(pObj) ) - return; + return 0; if ( pObj->fMark0 ) - return; + return 0; pObj->fMark0 = 1; Gia_ObjCollectInternal_rec( p, Gia_ObjFanin0(pObj) ); Gia_ObjCollectInternal_rec( p, Gia_ObjFanin1(pObj) ); + if ( Vec_IntSize(p->vTtNodes) > 253 ) + return 1; Gia_ObjSetNum( p, pObj, Vec_IntSize(p->vTtNodes) ); Vec_IntPush( p->vTtNodes, Gia_ObjId(p, pObj) ); + return 0; } -void Gia_ObjCollectInternal( Gia_Man_t * p, Gia_Obj_t * pObj ) +int Gia_ObjCollectInternal( Gia_Man_t * p, Gia_Obj_t * pObj ) { + int RetValue; Vec_IntClear( p->vTtNodes ); - Gia_ObjCollectInternal_rec( p, pObj ); + RetValue = Gia_ObjCollectInternal_rec( p, pObj ); assert( Vec_IntSize(p->vTtNodes) < 254 ); + return RetValue; } /**Function************************************************************* @@ -158,7 +163,12 @@ unsigned * Gia_ObjComputeTruthTable( Gia_Man_t * p, Gia_Obj_t * pObj ) } // collect internal nodes pRoot = Gia_ObjIsCo(pObj) ? Gia_ObjFanin0(pObj) : pObj; - Gia_ObjCollectInternal( p, pRoot ); + if ( Gia_ObjCollectInternal( p, pRoot ) ) + { + Gia_ManForEachObjVec( p->vTtNodes, p, pTemp, i ) + pTemp->fMark0 = 0; + return NULL; + } // compute the truth table for internal nodes Gia_ManForEachObjVec( p->vTtNodes, p, pTemp, i ) { |