From 615d249e0214a34e90a430038a1e2e75d232ef04 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Thu, 31 Oct 2013 17:00:06 -0400 Subject: GIA sweeper: adding APIs to return valid probe ID and run a command line. --- src/aig/gia/gia.h | 2 ++ src/aig/gia/giaSweeper.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) (limited to 'src') diff --git a/src/aig/gia/gia.h b/src/aig/gia/gia.h index 416ec8a0..36c53c71 100644 --- a/src/aig/gia/gia.h +++ b/src/aig/gia/gia.h @@ -1183,6 +1183,7 @@ extern int Gia_SweeperProbeCreate( Gia_Man_t * p, int iLit ); extern int Gia_SweeperProbeDelete( Gia_Man_t * p, int ProbeId ); extern int Gia_SweeperProbeUpdate( Gia_Man_t * p, int ProbeId, int iLitNew ); extern int Gia_SweeperProbeLit( Gia_Man_t * p, int ProbeId ); +extern Vec_Int_t * Gia_SweeperCollectValidProbeIds( Gia_Man_t * p ); extern int Gia_SweeperCondPop( Gia_Man_t * p ); extern void Gia_SweeperCondPush( Gia_Man_t * p, int ProbeId ); extern Vec_Int_t * Gia_SweeperCondVector( Gia_Man_t * p ); @@ -1192,6 +1193,7 @@ extern Gia_Man_t * Gia_SweeperExtractUserLogic( Gia_Man_t * p, Vec_Int_t extern Gia_Man_t * Gia_SweeperCleanup( Gia_Man_t * p, char * pCommLime ); extern Vec_Int_t * Gia_SweeperGraft( Gia_Man_t * pDst, Vec_Int_t * vProbes, Gia_Man_t * pSrc ); extern int Gia_SweeperFraig( Gia_Man_t * p, Vec_Int_t * vProbeIds, char * pCommLime, int nWords, int nConfs, int fVerbose ); +extern int Gia_SweeperRun( Gia_Man_t * p, Vec_Int_t * vProbeIds, char * pCommLime, int fVerbose ); /*=== giaSwitch.c ============================================================*/ extern float Gia_ManEvaluateSwitching( Gia_Man_t * p ); extern float Gia_ManComputeSwitching( Gia_Man_t * p, int nFrames, int nPref, int fProbOne ); diff --git a/src/aig/gia/giaSweeper.c b/src/aig/gia/giaSweeper.c index 1794d051..30d56dde 100644 --- a/src/aig/gia/giaSweeper.c +++ b/src/aig/gia/giaSweeper.c @@ -281,6 +281,30 @@ int Gia_SweeperProbeLit( Gia_Man_t * p, int ProbeId ) return iLit; } +/**Function************************************************************* + + Synopsis [This procedure returns indexes of all currently defined valid probes.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Vec_Int_t * Gia_SweeperCollectValidProbeIds( Gia_Man_t * p ) +{ + Swp_Man_t * pSwp = (Swp_Man_t *)p->pData; + Vec_Int_t * vProbeIds = Vec_IntAlloc( 1000 ); + int iLit, ProbeId; + Vec_IntForEachEntry( pSwp->vProbes, iLit, ProbeId ) + { + if ( iLit < 0 ) continue; + Vec_IntPush( vProbeIds, ProbeId ); + } + return vProbeIds; +} + /**Function************************************************************* Synopsis [] @@ -1032,6 +1056,52 @@ int Gia_SweeperFraig( Gia_Man_t * p, Vec_Int_t * vProbeIds, char * pCommLime, in return 1; } +/**Function************************************************************* + + Synopsis [Executes given command line for the logic defined by the probes.] + + Description [ ] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_SweeperRun( Gia_Man_t * p, Vec_Int_t * vProbeIds, char * pCommLime, int fVerbose ) +{ + Gia_Man_t * pNew; + Vec_Int_t * vLits; + int ProbeId, i; + // sweeper is running + assert( Gia_SweeperIsRunning(p) ); + // sweep the logic + pNew = Gia_SweeperExtractUserLogic( p, vProbeIds, NULL, NULL ); + // execute command line + if ( pCommLime ) + { + if ( fVerbose ) + printf( "GIA manager statistics before and after applying \"%s\":\n", pCommLine ); + if ( fVerbose ) + Gia_ManPrintStats( pNew, NULL ); + // set pNew to be current GIA in ABC + Abc_FrameUpdateGia( Abc_FrameGetGlobalFrame(), pNew ); + // execute command line pCommLine using Abc_CmdCommandExecute() + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), pCommLime ); + // get pNew to be current GIA in ABC + pNew = Abc_FrameGetGia( Abc_FrameGetGlobalFrame() ); + if ( fVerbose ) + Gia_ManPrintStats( pNew, NULL ); + } + // return logic back into the main manager + vLits = Gia_SweeperGraft( p, NULL, pNew ); + Gia_ManStop( pNew ); + // update the array of probes + Vec_IntForEachEntry( vProbeIds, ProbeId, i ) + Gia_SweeperProbeUpdate( p, ProbeId, Vec_IntEntry(vLits, i) ); + Vec_IntFree( vLits ); + return 1; +} + /**Function************************************************************* Synopsis [Sweeper sweeper test.] -- cgit v1.2.3