diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2009-02-20 08:01:00 -0800 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2009-02-20 08:01:00 -0800 |
commit | c03f9b516bed2c06ec2bfc78617eba5fc9a11c32 (patch) | |
tree | 58b8a5447d5ae7554fd5e9599f1fbe5a4f072617 /src/aig/gia/giaGlitch.c | |
parent | 28d4f8696dd2cf60f71fca5d83e5f038678f4828 (diff) | |
download | abc-c03f9b516bed2c06ec2bfc78617eba5fc9a11c32.tar.gz abc-c03f9b516bed2c06ec2bfc78617eba5fc9a11c32.tar.bz2 abc-c03f9b516bed2c06ec2bfc78617eba5fc9a11c32.zip |
Version abc90220
Diffstat (limited to 'src/aig/gia/giaGlitch.c')
-rw-r--r-- | src/aig/gia/giaGlitch.c | 92 |
1 files changed, 65 insertions, 27 deletions
diff --git a/src/aig/gia/giaGlitch.c b/src/aig/gia/giaGlitch.c index 6da24083..443a1ae8 100644 --- a/src/aig/gia/giaGlitch.c +++ b/src/aig/gia/giaGlitch.c @@ -630,23 +630,38 @@ static inline unsigned Gli_ManUpdateRandomInput( unsigned uInfo, float PiTransPr SeeAlso [] ***********************************************************************/ -static inline void Gli_ManSimulateSeqOne( Gli_Man_t * p, float PiTransProb ) +void Gli_ManSimulateSeqPref( Gli_Man_t * p, int nPref ) { Gli_Obj_t * pObj, * pObjRi, * pObjRo; - int i; + int i, f; + // initialize simulation data Gli_ManForEachPi( p, pObj, i ) - pObj->uSimInfo = Gli_ManUpdateRandomInput( pObj->uSimInfo, PiTransProb ); - Gli_ManForEachNode( p, pObj, i ) - pObj->uSimInfo = Gli_ManSimulateSeqNode( p, pObj ); - Gli_ManForEachRi( p, pObj, i ) - pObj->uSimInfo = Gli_ObjFanin(pObj, 0)->uSimInfo; - Gli_ManForEachRiRo( p, pObjRi, pObjRo, i ) - pObjRo->uSimInfo = pObjRi->uSimInfo; + pObj->uSimInfo = Gli_ManUpdateRandomInput( pObj->uSimInfo, 0.5 ); + Gli_ManForEachRo( p, pObj, i ) + pObj->uSimInfo = 0; + for ( f = 0; f < nPref; f++ ) + { + // simulate one frame + Gli_ManForEachNode( p, pObj, i ) + pObj->uSimInfo = Gli_ManSimulateSeqNode( p, pObj ); + Gli_ManForEachRi( p, pObj, i ) + pObj->uSimInfo = Gli_ObjFanin(pObj, 0)->uSimInfo; + // initialize the next frame + Gli_ManForEachPi( p, pObj, i ) + pObj->uSimInfo = Gli_ManUpdateRandomInput( pObj->uSimInfo, 0.5 ); + Gli_ManForEachRiRo( p, pObjRi, pObjRo, i ) + pObjRo->uSimInfo = pObjRi->uSimInfo; + } + // save simulation data after nPref timeframes + if ( p->pSimInfoPrev == NULL ) + p->pSimInfoPrev = ABC_ALLOC( unsigned, Gli_ManCiNum(p) ); + Gli_ManForEachCi( p, pObj, i ) + p->pSimInfoPrev[i] = pObj->uSimInfo; } /**Function************************************************************* - Synopsis [Simulates sequential network randomly for the given number of frames.] + Synopsis [Initialized object values to be one pattern in the saved data.] Description [] @@ -655,19 +670,19 @@ static inline void Gli_ManSimulateSeqOne( Gli_Man_t * p, float PiTransProb ) SeeAlso [] ***********************************************************************/ -static inline void Gli_ManSaveCiInfo( Gli_Man_t * p ) +void Gli_ManSetDataSaved( Gli_Man_t * p, int iBit ) { Gli_Obj_t * pObj; int i; - if ( p->pSimInfoPrev == NULL ) - p->pSimInfoPrev = ABC_ALLOC( unsigned, Gli_ManCiNum(p) ); Gli_ManForEachCi( p, pObj, i ) - p->pSimInfoPrev[i] = pObj->uSimInfo; + pObj->fPhase = pObj->fPhase2 = ((p->pSimInfoPrev[i] >> iBit) & 1); + Gli_ManForEachNode( p, pObj, i ) + pObj->fPhase = pObj->fPhase2 = Gli_NodeComputeValue( pObj ); } /**Function************************************************************* - Synopsis [Simulates sequential network randomly for the given number of frames.] + Synopsis [Sets random info at the PIs and collects changed PIs.] Description [] @@ -676,14 +691,37 @@ static inline void Gli_ManSaveCiInfo( Gli_Man_t * p ) SeeAlso [] ***********************************************************************/ -void Gli_ManSimulateSeqPref( Gli_Man_t * p, int nPref ) +void Gli_ManSetPiRandomSeq( Gli_Man_t * p, float PiTransProb ) { - Gli_Obj_t * pObj; - int i, f; - Gli_ManForEachRo( p, pObj, i ) - pObj->uSimInfo = 0; - for ( f = 0; f < nPref; f++ ) - Gli_ManSimulateSeqOne( p, 0.5 ); + Gli_Obj_t * pObj, * pObjRi; + float Multi = 1.0 / (1 << 16); + int i; + assert( 0.0 < PiTransProb && PiTransProb < 1.0 ); + // transfer data to the COs + Gli_ManForEachCo( p, pObj, i ) + pObj->fPhase = pObj->fPhase2 = Gli_ObjFanin(pObj, 0)->fPhase; + // set changed PIs + Vec_IntClear( p->vCisChanged ); + Gli_ManForEachPi( p, pObj, i ) + if ( Multi * (Aig_ManRandom(0) & 0xffff) < PiTransProb ) + { + Vec_IntPush( p->vCisChanged, pObj->Handle ); + pObj->fPhase ^= 1; + pObj->fPhase2 ^= 1; + pObj->nSwitches++; + pObj->nGlitches++; + } + // set changed ROs + Gli_ManForEachRiRo( p, pObjRi, pObj, i ) + if ( pObjRi->fPhase != pObj->fPhase ) + { + Vec_IntPush( p->vCisChanged, pObj->Handle ); + pObj->fPhase ^= 1; + pObj->fPhase2 ^= 1; + pObj->nSwitches++; + pObj->nGlitches++; + } + } /**Function************************************************************* @@ -714,14 +752,14 @@ void Gli_ManSwitchesAndGlitches( Gli_Man_t * p, int nPatterns, float PiTransProb } else { + int nIters = Aig_BitWordNum(nPatterns); Gli_ManSimulateSeqPref( p, 16 ); - for ( k = Aig_BitWordNum(nPatterns) - 1; k >= 0; k-- ) + for ( i = 0; i < 32; i++ ) { - Gli_ManSaveCiInfo( p ); - Gli_ManSimulateSeqOne( p, PiTransProb ); - for ( i = 0; i < 32; i++ ) + Gli_ManSetDataSaved( p, i ); + for ( k = 0; k < nIters; k++ ) { - Gli_ManSetPiFromSaved( p, i ); + Gli_ManSetPiRandomSeq( p, PiTransProb ); Gli_ManSwitching( p ); Gli_ManGlitching( p ); // Gli_ManVerify( p ); |