abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
giaSweeper.c File Reference
#include "gia.h"
#include "base/main/main.h"
#include "sat/bsat/satSolver.h"
#include "proof/ssc/ssc.h"

Go to the source code of this file.

Data Structures

struct  Swp_Man_t_
 

Typedefs

typedef
typedefABC_NAMESPACE_IMPL_START
struct Swp_Man_t_ 
Swp_Man_t
 DECLARATIONS ///. More...
 

Functions

static int Swp_ManObj2Lit (Swp_Man_t *p, int Id)
 
static int Swp_ManLit2Lit (Swp_Man_t *p, int Lit)
 
static void Swp_ManSetObj2Lit (Swp_Man_t *p, int Id, int Lit)
 
static Swp_Man_tSwp_ManStart (Gia_Man_t *pGia)
 FUNCTION DEFINITIONS ///. More...
 
static void Swp_ManStop (Gia_Man_t *pGia)
 
Gia_Man_tGia_SweeperStart (Gia_Man_t *pGia)
 
void Gia_SweeperStop (Gia_Man_t *pGia)
 
int Gia_SweeperIsRunning (Gia_Man_t *pGia)
 
double Gia_SweeperMemUsage (Gia_Man_t *pGia)
 
void Gia_SweeperPrintStats (Gia_Man_t *pGia)
 
void Gia_SweeperSetConflictLimit (Gia_Man_t *p, int nConfMax)
 
void Gia_SweeperSetRuntimeLimit (Gia_Man_t *p, int nSeconds)
 
Vec_Int_tGia_SweeperGetCex (Gia_Man_t *p)
 
int Gia_SweeperProbeCreate (Gia_Man_t *p, int iLit)
 
int Gia_SweeperProbeDelete (Gia_Man_t *p, int ProbeId)
 
int Gia_SweeperProbeUpdate (Gia_Man_t *p, int ProbeId, int iLitNew)
 
int Gia_SweeperProbeLit (Gia_Man_t *p, int ProbeId)
 
Vec_Int_tGia_SweeperCollectValidProbeIds (Gia_Man_t *p)
 
void Gia_SweeperCondPush (Gia_Man_t *p, int ProbeId)
 
int Gia_SweeperCondPop (Gia_Man_t *p)
 
Vec_Int_tGia_SweeperCondVector (Gia_Man_t *p)
 
static void Gia_ManExtract_rec (Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vObjIds)
 
Gia_Man_tGia_SweeperExtractUserLogic (Gia_Man_t *p, Vec_Int_t *vProbeIds, Vec_Ptr_t *vInNames, Vec_Ptr_t *vOutNames)
 
void Gia_SweeperLogicDump (Gia_Man_t *p, Vec_Int_t *vProbeIds, int fDumpConds, char *pFileName)
 
Gia_Man_tGia_SweeperCleanup (Gia_Man_t *p, char *pCommLime)
 
static void Gia_ManAddClausesMux (Swp_Man_t *p, Gia_Obj_t *pNode)
 
static void Gia_ManAddClausesSuper (Swp_Man_t *p, Gia_Obj_t *pNode, Vec_Int_t *vSuper)
 
static void Gia_ManCollectSuper_rec (Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vSuper)
 
static void Gia_ManCollectSuper (Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vSuper)
 
static void Gia_ManObjAddToFrontier (Swp_Man_t *p, int Id, Vec_Int_t *vFront)
 
static void Gia_ManCnfNodeAddToSolver (Swp_Man_t *p, int NodeId)
 
static Vec_Int_tGia_ManGetCex (Gia_Man_t *pGia, Vec_Int_t *vId2Lit, sat_solver *pSat, Vec_Int_t *vCex)
 
int Gia_SweeperCheckEquiv (Gia_Man_t *pGia, int Probe1, int Probe2)
 
int Gia_SweeperCondCheckUnsat (Gia_Man_t *pGia)
 
Vec_Int_tGia_SweeperGraft (Gia_Man_t *pDst, Vec_Int_t *vProbes, Gia_Man_t *pSrc)
 
Gia_Man_tGia_SweeperSweep (Gia_Man_t *p, Vec_Int_t *vProbeOuts, int nWords, int nConfs, int fVerify, int fVerbose)
 
int Gia_SweeperFraig (Gia_Man_t *p, Vec_Int_t *vProbeIds, char *pCommLime, int nWords, int nConfs, int fVerify, int fVerbose)
 
int Gia_SweeperRun (Gia_Man_t *p, Vec_Int_t *vProbeIds, char *pCommLime, int fVerbose)
 
Gia_Man_tGia_SweeperFraigTest (Gia_Man_t *pInit, int nWords, int nConfs, int fVerbose)
 

Typedef Documentation

typedef typedefABC_NAMESPACE_IMPL_START struct Swp_Man_t_ Swp_Man_t

DECLARATIONS ///.

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

FileName [giaSweeper.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Incremental SAT sweeper.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 56 of file giaSweeper.c.

Function Documentation

static void Gia_ManAddClausesMux ( Swp_Man_t p,
Gia_Obj_t pNode 
)
static

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

Synopsis [Addes clauses to the solver.]

Description []

SideEffects []

SeeAlso []

Definition at line 543 of file giaSweeper.c.

544 {
545  Gia_Obj_t * pNodeI, * pNodeT, * pNodeE;
546  int pLits[4], LitF, LitI, LitT, LitE, RetValue;
547  assert( !Gia_IsComplement( pNode ) );
548  assert( Gia_ObjIsMuxType( pNode ) );
549  // get nodes (I = if, T = then, E = else)
550  pNodeI = Gia_ObjRecognizeMux( pNode, &pNodeT, &pNodeE );
551  // get the Litiable numbers
552  LitF = Swp_ManLit2Lit( p, Gia_Obj2Lit(p->pGia,pNode) );
553  LitI = Swp_ManLit2Lit( p, Gia_Obj2Lit(p->pGia,pNodeI) );
554  LitT = Swp_ManLit2Lit( p, Gia_Obj2Lit(p->pGia,pNodeT) );
555  LitE = Swp_ManLit2Lit( p, Gia_Obj2Lit(p->pGia,pNodeE) );
556 
557  // f = ITE(i, t, e)
558 
559  // i' + t' + f
560  // i' + t + f'
561  // i + e' + f
562  // i + e + f'
563 
564  // create four clauses
565  pLits[0] = Abc_LitNotCond(LitI, 1);
566  pLits[1] = Abc_LitNotCond(LitT, 1);
567  pLits[2] = Abc_LitNotCond(LitF, 0);
568  RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 );
569  assert( RetValue );
570  pLits[0] = Abc_LitNotCond(LitI, 1);
571  pLits[1] = Abc_LitNotCond(LitT, 0);
572  pLits[2] = Abc_LitNotCond(LitF, 1);
573  RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 );
574  assert( RetValue );
575  pLits[0] = Abc_LitNotCond(LitI, 0);
576  pLits[1] = Abc_LitNotCond(LitE, 1);
577  pLits[2] = Abc_LitNotCond(LitF, 0);
578  RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 );
579  assert( RetValue );
580  pLits[0] = Abc_LitNotCond(LitI, 0);
581  pLits[1] = Abc_LitNotCond(LitE, 0);
582  pLits[2] = Abc_LitNotCond(LitF, 1);
583  RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 );
584  assert( RetValue );
585 
586  // two additional clauses
587  // t' & e' -> f'
588  // t & e -> f
589 
590  // t + e + f'
591  // t' + e' + f
592 
593  if ( LitT == LitE )
594  {
595 // assert( fCompT == !fCompE );
596  return;
597  }
598 
599  pLits[0] = Abc_LitNotCond(LitT, 0);
600  pLits[1] = Abc_LitNotCond(LitE, 0);
601  pLits[2] = Abc_LitNotCond(LitF, 1);
602  RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 );
603  assert( RetValue );
604  pLits[0] = Abc_LitNotCond(LitT, 1);
605  pLits[1] = Abc_LitNotCond(LitE, 1);
606  pLits[2] = Abc_LitNotCond(LitF, 0);
607  RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 3 );
608  assert( RetValue );
609 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
Definition: gia.h:75
static int Swp_ManLit2Lit(Swp_Man_t *p, int Lit)
Definition: giaSweeper.c:89
int Gia_ObjIsMuxType(Gia_Obj_t *pNode)
Definition: giaUtil.c:885
static int Gia_IsComplement(Gia_Obj_t *p)
Definition: gia.h:380
Gia_Obj_t * Gia_ObjRecognizeMux(Gia_Obj_t *pNode, Gia_Obj_t **ppNodeT, Gia_Obj_t **ppNodeE)
Definition: giaUtil.c:959
#define assert(ex)
Definition: util_old.h:213
static int Gia_Obj2Lit(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:433
static void Gia_ManAddClausesSuper ( Swp_Man_t p,
Gia_Obj_t pNode,
Vec_Int_t vSuper 
)
static

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

Synopsis [Addes clauses to the solver.]

Description []

SideEffects []

SeeAlso []

Definition at line 622 of file giaSweeper.c.

623 {
624  int i, RetValue, Lit, LitNode, pLits[2];
625  assert( !Gia_IsComplement(pNode) );
626  assert( Gia_ObjIsAnd( pNode ) );
627  // suppose AND-gate is A & B = C
628  // add !A => !C or A + !C
629  // add !B => !C or B + !C
630  LitNode = Swp_ManLit2Lit( p, Gia_Obj2Lit(p->pGia,pNode) );
631  Vec_IntForEachEntry( vSuper, Lit, i )
632  {
633  pLits[0] = Swp_ManLit2Lit( p, Lit );
634  pLits[1] = Abc_LitNot( LitNode );
635  RetValue = sat_solver_addclause( p->pSat, pLits, pLits + 2 );
636  assert( RetValue );
637  // update literals
638  Vec_IntWriteEntry( vSuper, i, Abc_LitNot(pLits[0]) );
639  }
640  // add A & B => C or !A + !B + C
641  Vec_IntPush( vSuper, LitNode );
642  RetValue = sat_solver_addclause( p->pSat, Vec_IntArray(vSuper), Vec_IntArray(vSuper) + Vec_IntSize(vSuper) );
643  assert( RetValue );
644  (void) RetValue;
645 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Swp_ManLit2Lit(Swp_Man_t *p, int Lit)
Definition: giaSweeper.c:89
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Gia_IsComplement(Gia_Obj_t *p)
Definition: gia.h:380
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
#define assert(ex)
Definition: util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static int Gia_Obj2Lit(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:433
static void Gia_ManCnfNodeAddToSolver ( Swp_Man_t p,
int  NodeId 
)
static

Definition at line 701 of file giaSweeper.c.

702 {
703  Gia_Obj_t * pNode;
704  int i, k, Id, Lit;
705  abctime clk;
706  // quit if CNF is ready
707  if ( NodeId == 0 || Swp_ManObj2Lit(p, NodeId) )
708  return;
709 clk = Abc_Clock();
710  // start the frontier
711  Vec_IntClear( p->vFront );
712  Gia_ManObjAddToFrontier( p, NodeId, p->vFront );
713  // explore nodes in the frontier
714  Gia_ManForEachObjVec( p->vFront, p->pGia, pNode, i )
715  {
716  // create the supergate
717  assert( Swp_ManObj2Lit(p, Gia_ObjId(p->pGia, pNode)) );
718  if ( Gia_ObjIsMuxType(pNode) )
719  {
720  Vec_IntClear( p->vFanins );
721  Vec_IntPushUnique( p->vFanins, Gia_ObjFaninId0p( p->pGia, Gia_ObjFanin0(pNode) ) );
722  Vec_IntPushUnique( p->vFanins, Gia_ObjFaninId0p( p->pGia, Gia_ObjFanin1(pNode) ) );
723  Vec_IntPushUnique( p->vFanins, Gia_ObjFaninId1p( p->pGia, Gia_ObjFanin0(pNode) ) );
724  Vec_IntPushUnique( p->vFanins, Gia_ObjFaninId1p( p->pGia, Gia_ObjFanin1(pNode) ) );
725  Vec_IntForEachEntry( p->vFanins, Id, k )
726  Gia_ManObjAddToFrontier( p, Id, p->vFront );
727  Gia_ManAddClausesMux( p, pNode );
728  }
729  else
730  {
731  Gia_ManCollectSuper( p->pGia, pNode, p->vFanins );
732  Vec_IntForEachEntry( p->vFanins, Lit, k )
733  Gia_ManObjAddToFrontier( p, Abc_Lit2Var(Lit), p->vFront );
734  Gia_ManAddClausesSuper( p, pNode, p->vFanins );
735  }
736  assert( Vec_IntSize(p->vFanins) > 1 );
737  }
738 p->timeCnf += Abc_Clock() - clk;
739 }
static void Gia_ManCollectSuper(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vSuper)
Definition: giaSweeper.c:670
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Gia_ObjFaninId1p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:464
static void Gia_ManAddClausesMux(Swp_Man_t *p, Gia_Obj_t *pNode)
Definition: giaSweeper.c:543
static abctime Abc_Clock()
Definition: abc_global.h:279
Definition: gia.h:75
static int Swp_ManObj2Lit(Swp_Man_t *p, int Id)
Definition: giaSweeper.c:88
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
else
Definition: sparse_int.h:55
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:410
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition: gia.h:988
static void Gia_ManAddClausesSuper(Swp_Man_t *p, Gia_Obj_t *pNode, Vec_Int_t *vSuper)
Definition: giaSweeper.c:622
int Gia_ObjIsMuxType(Gia_Obj_t *pNode)
Definition: giaUtil.c:885
static void Gia_ManObjAddToFrontier(Swp_Man_t *p, int Id, Vec_Int_t *vFront)
Definition: giaSweeper.c:690
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
static int Gia_ObjFaninId0p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:463
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
#define assert(ex)
Definition: util_old.h:213
ABC_NAMESPACE_IMPL_START abctime timeCnf
DECLARATIONS ///.
Definition: abcDar.c:3798
static int Vec_IntPushUnique(Vec_Int_t *p, int Entry)
Definition: vecInt.h:832
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
ABC_INT64_T abctime
Definition: abc_global.h:278
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static void Gia_ManCollectSuper ( Gia_Man_t p,
Gia_Obj_t pObj,
Vec_Int_t vSuper 
)
static

Definition at line 670 of file giaSweeper.c.

671 {
672  assert( !Gia_IsComplement(pObj) );
673  assert( Gia_ObjIsAnd(pObj) );
674  Vec_IntClear( vSuper );
675  Gia_ManCollectSuper_rec( p, Gia_ObjChild0(pObj), vSuper );
676  Gia_ManCollectSuper_rec( p, Gia_ObjChild1(pObj), vSuper );
677 }
static Gia_Obj_t * Gia_ObjChild0(Gia_Obj_t *pObj)
Definition: gia.h:457
static Gia_Obj_t * Gia_ObjChild1(Gia_Obj_t *pObj)
Definition: gia.h:458
static void Gia_ManCollectSuper_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vSuper)
Definition: giaSweeper.c:659
static int Gia_IsComplement(Gia_Obj_t *p)
Definition: gia.h:380
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
static void Gia_ManCollectSuper_rec ( Gia_Man_t p,
Gia_Obj_t pObj,
Vec_Int_t vSuper 
)
static

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

Synopsis [Collects the supergate.]

Description []

SideEffects []

SeeAlso []

Definition at line 659 of file giaSweeper.c.

660 {
661  // stop at complements, shared, PIs, and MUXes
662  if ( Gia_IsComplement(pObj) || pObj->fMark1 || Gia_ObjIsCi(pObj) || Gia_ObjIsMuxType(pObj) )
663  {
664  Vec_IntPushUnique( vSuper, Gia_Obj2Lit(p, pObj) );
665  return;
666  }
667  Gia_ManCollectSuper_rec( p, Gia_ObjChild0(pObj), vSuper );
668  Gia_ManCollectSuper_rec( p, Gia_ObjChild1(pObj), vSuper );
669 }
static Gia_Obj_t * Gia_ObjChild0(Gia_Obj_t *pObj)
Definition: gia.h:457
unsigned fMark1
Definition: gia.h:84
static Gia_Obj_t * Gia_ObjChild1(Gia_Obj_t *pObj)
Definition: gia.h:458
static void Gia_ManCollectSuper_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vSuper)
Definition: giaSweeper.c:659
int Gia_ObjIsMuxType(Gia_Obj_t *pNode)
Definition: giaUtil.c:885
static int Gia_IsComplement(Gia_Obj_t *p)
Definition: gia.h:380
static int Vec_IntPushUnique(Vec_Int_t *p, int Entry)
Definition: vecInt.h:832
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
Definition: gia.h:420
static int Gia_Obj2Lit(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:433
static void Gia_ManExtract_rec ( Gia_Man_t p,
Gia_Obj_t pObj,
Vec_Int_t vObjIds 
)
static

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 347 of file giaSweeper.c.

348 {
349  if ( !Gia_ObjIsAnd(pObj) )
350  return;
351  if ( Gia_ObjIsTravIdCurrent(p, pObj) )
352  return;
353  Gia_ObjSetTravIdCurrent(p, pObj);
354  Gia_ManExtract_rec( p, Gia_ObjFanin0(pObj), vObjIds );
355  Gia_ManExtract_rec( p, Gia_ObjFanin1(pObj), vObjIds );
356  Vec_IntPush( vObjIds, Gia_ObjId(p, pObj) );
357 }
static int Gia_ObjIsTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:533
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
Definition: gia.h:454
static void Gia_ObjSetTravIdCurrent(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:531
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
static void Gia_ManExtract_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vObjIds)
Definition: giaSweeper.c:347
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
Definition: gia.h:455
static Vec_Int_t* Gia_ManGetCex ( Gia_Man_t pGia,
Vec_Int_t vId2Lit,
sat_solver pSat,
Vec_Int_t vCex 
)
static

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 753 of file giaSweeper.c.

754 {
755  Gia_Obj_t * pObj;
756  int i, LitSat, Value;
757  Vec_IntClear( vCex );
758  Gia_ManForEachPi( pGia, pObj, i )
759  {
760  if ( Gia_ObjId(pGia, pObj) >= Vec_IntSize(vId2Lit) )
761  {
762  Vec_IntPush( vCex, 2 );
763  continue;
764  }
765  LitSat = Vec_IntEntry( vId2Lit, Gia_ObjId(pGia, pObj) );
766  if ( LitSat == 0 )
767  {
768  Vec_IntPush( vCex, 2 );
769  continue;
770  }
771  assert( LitSat > 0 );
772  Value = sat_solver_var_value(pSat, Abc_Lit2Var(LitSat)) ^ Abc_LitIsCompl(LitSat);
773  Vec_IntPush( vCex, Value );
774  }
775  return vCex;
776 }
Definition: gia.h:75
static int sat_solver_var_value(sat_solver *s, int v)
Definition: satSolver.h:200
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
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
#define Gia_ManForEachPi(p, pObj, i)
Definition: gia.h:1034
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
static void Gia_ManObjAddToFrontier ( Swp_Man_t p,
int  Id,
Vec_Int_t vFront 
)
static

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

Synopsis [Updates the solver clause database.]

Description []

SideEffects []

SeeAlso []

Definition at line 690 of file giaSweeper.c.

691 {
692  Gia_Obj_t * pObj;
693  if ( Id == 0 || Swp_ManObj2Lit(p, Id) )
694  return;
695  pObj = Gia_ManObj( p->pGia, Id );
696  Swp_ManSetObj2Lit( p, Id, Abc_Var2Lit(p->nSatVars++, pObj->fPhase) );
697  sat_solver_setnvars( p->pSat, p->nSatVars + 100 );
698  if ( Gia_ObjIsAnd(pObj) )
699  Vec_IntPush( vFront, Id );
700 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
Definition: gia.h:402
Definition: gia.h:75
static int Swp_ManObj2Lit(Swp_Man_t *p, int Id)
Definition: giaSweeper.c:88
void sat_solver_setnvars(sat_solver *s, int n)
Definition: satSolver.c:1072
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
unsigned fPhase
Definition: gia.h:85
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
Definition: gia.h:422
static void Swp_ManSetObj2Lit(Swp_Man_t *p, int Id, int Lit)
Definition: giaSweeper.c:90
int Gia_SweeperCheckEquiv ( Gia_Man_t pGia,
int  Probe1,
int  Probe2 
)

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

Synopsis [Runs equivalence test for probes.]

Description []

SideEffects []

SeeAlso []

Definition at line 789 of file giaSweeper.c.

790 {
791  Swp_Man_t * p = (Swp_Man_t *)pGia->pData;
792  int iLitOld, iLitNew, iLitAig, pLitsSat[2], RetValue, RetValue1, ProbeId, i;
793  abctime clk;
794  p->nSatCalls++;
795  assert( p->pSat != NULL );
796  p->vCexUser = NULL;
797 
798  // get the literals
799  iLitOld = Gia_SweeperProbeLit( pGia, Probe1 );
800  iLitNew = Gia_SweeperProbeLit( pGia, Probe2 );
801  // if the literals are identical, the probes are equivalent
802  if ( iLitOld == iLitNew )
803  return 1;
804  // if the literals are opposites, the probes are not equivalent
805  if ( Abc_LitRegular(iLitOld) == Abc_LitRegular(iLitNew) )
806  {
807  Vec_IntFill( p->vCexSwp, Gia_ManPiNum(pGia), 2 );
808  p->vCexUser = p->vCexSwp;
809  return 0;
810  }
811  // order the literals
812  if ( iLitOld < iLitNew )
813  ABC_SWAP( int, iLitOld, iLitNew );
814  assert( iLitOld > iLitNew );
815 
816  // create logic cones and the array of assumptions
817  Vec_IntClear( p->vCondAssump );
818  Vec_IntForEachEntry( p->vCondProbes, ProbeId, i )
819  {
820  iLitAig = Gia_SweeperProbeLit( pGia, ProbeId );
821  Gia_ManCnfNodeAddToSolver( p, Abc_Lit2Var(iLitAig) );
822  Vec_IntPush( p->vCondAssump, Abc_LitNot(Swp_ManLit2Lit(p, iLitAig)) );
823  }
824  Gia_ManCnfNodeAddToSolver( p, Abc_Lit2Var(iLitOld) );
825  Gia_ManCnfNodeAddToSolver( p, Abc_Lit2Var(iLitNew) );
826  sat_solver_compress( p->pSat );
827 
828  // set the SAT literals
829  pLitsSat[0] = Swp_ManLit2Lit( p, iLitOld );
830  pLitsSat[1] = Swp_ManLit2Lit( p, iLitNew );
831 
832  // solve under assumptions
833  // A = 1; B = 0 OR A = 1; B = 1
834  Vec_IntPush( p->vCondAssump, pLitsSat[0] );
835  Vec_IntPush( p->vCondAssump, Abc_LitNot(pLitsSat[1]) );
836 
837  // set runtime limit for this call
838  if ( p->nTimeOut )
839  sat_solver_set_runtime_limit( p->pSat, p->nTimeOut * CLOCKS_PER_SEC + Abc_Clock() );
840 
841 clk = Abc_Clock();
842  RetValue1 = sat_solver_solve( p->pSat, Vec_IntArray(p->vCondAssump), Vec_IntArray(p->vCondAssump) + Vec_IntSize(p->vCondAssump),
843  (ABC_INT64_T)p->nConfMax, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
844  Vec_IntShrink( p->vCondAssump, Vec_IntSize(p->vCondAssump) - 2 );
845 p->timeSat += Abc_Clock() - clk;
846  if ( RetValue1 == l_False )
847  {
848  pLitsSat[0] = Abc_LitNot( pLitsSat[0] );
849  RetValue = sat_solver_addclause( p->pSat, pLitsSat, pLitsSat + 2 );
850  assert( RetValue );
851  pLitsSat[0] = Abc_LitNot( pLitsSat[0] );
852 p->timeSatUnsat += Abc_Clock() - clk;
853  p->nSatCallsUnsat++;
854  }
855  else if ( RetValue1 == l_True )
856  {
857  p->vCexUser = Gia_ManGetCex( p->pGia, p->vId2Lit, p->pSat, p->vCexSwp );
858 p->timeSatSat += Abc_Clock() - clk;
859  p->nSatCallsSat++;
860  return 0;
861  }
862  else // if ( RetValue1 == l_Undef )
863  {
864 p->timeSatUndec += Abc_Clock() - clk;
865  p->nSatCallsUndec++;
866  return -1;
867  }
868 
869  // if the old node was constant 0, we already know the answer
870  if ( Gia_ManIsConstLit(iLitNew) )
871  {
872  p->nSatProofs++;
873  return 1;
874  }
875 
876  // solve under assumptions
877  // A = 0; B = 1 OR A = 0; B = 0
878  Vec_IntPush( p->vCondAssump, Abc_LitNot(pLitsSat[0]) );
879  Vec_IntPush( p->vCondAssump, pLitsSat[1] );
880 
881 clk = Abc_Clock();
882  RetValue1 = sat_solver_solve( p->pSat, Vec_IntArray(p->vCondAssump), Vec_IntArray(p->vCondAssump) + Vec_IntSize(p->vCondAssump),
883  (ABC_INT64_T)p->nConfMax, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
884  Vec_IntShrink( p->vCondAssump, Vec_IntSize(p->vCondAssump) - 2 );
885 p->timeSat += Abc_Clock() - clk;
886  if ( RetValue1 == l_False )
887  {
888  pLitsSat[1] = Abc_LitNot( pLitsSat[1] );
889  RetValue = sat_solver_addclause( p->pSat, pLitsSat, pLitsSat + 2 );
890  assert( RetValue );
891  pLitsSat[1] = Abc_LitNot( pLitsSat[1] );
892 p->timeSatUnsat += Abc_Clock() - clk;
893  p->nSatCallsUnsat++;
894  }
895  else if ( RetValue1 == l_True )
896  {
897  p->vCexUser = Gia_ManGetCex( p->pGia, p->vId2Lit, p->pSat, p->vCexSwp );
898 p->timeSatSat += Abc_Clock() - clk;
899  p->nSatCallsSat++;
900  return 0;
901  }
902  else // if ( RetValue1 == l_Undef )
903  {
904 p->timeSatUndec += Abc_Clock() - clk;
905  p->nSatCallsUndec++;
906  return -1;
907  }
908  // return SAT proof
909  p->nSatProofs++;
910  return 1;
911 }
static abctime sat_solver_set_runtime_limit(sat_solver *s, abctime Limit)
Definition: satSolver.h:233
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
static int Gia_ManIsConstLit(int iLit)
Definition: gia.h:375
int sat_solver_solve(sat_solver *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
Definition: satSolver.c:1700
static void sat_solver_compress(sat_solver *s)
Definition: satSolver.h:217
#define l_True
Definition: SolverTypes.h:84
static abctime Abc_Clock()
Definition: abc_global.h:279
#define ABC_SWAP(Type, a, b)
Definition: abc_global.h:218
static int Swp_ManLit2Lit(Swp_Man_t *p, int Lit)
Definition: giaSweeper.c:89
void * pData
Definition: gia.h:169
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static void Vec_IntShrink(Vec_Int_t *p, int nSizeNew)
Definition: bblif.c:435
typedefABC_NAMESPACE_IMPL_START struct Swp_Man_t_ Swp_Man_t
DECLARATIONS ///.
Definition: giaSweeper.c:56
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define l_False
Definition: SolverTypes.h:85
static void Gia_ManCnfNodeAddToSolver(Swp_Man_t *p, int NodeId)
Definition: giaSweeper.c:701
static int Abc_LitRegular(int Lit)
Definition: abc_global.h:268
#define assert(ex)
Definition: util_old.h:213
int Gia_SweeperProbeLit(Gia_Man_t *p, int ProbeId)
Definition: giaSweeper.c:276
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
ABC_INT64_T abctime
Definition: abc_global.h:278
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static Vec_Int_t * Gia_ManGetCex(Gia_Man_t *pGia, Vec_Int_t *vId2Lit, sat_solver *pSat, Vec_Int_t *vCex)
Definition: giaSweeper.c:753
Gia_Man_t* Gia_SweeperCleanup ( Gia_Man_t p,
char *  pCommLime 
)

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

Synopsis [Sweeper cleanup.]

Description [Returns new GIA with sweeper defined, which is the same as the original sweeper, with all the dangling logic removed and SAT solver restarted. The probe IDs are guaranteed to have the same logic functions as in the original manager.]

SideEffects [The input manager is deleted inside this procedure.]

SeeAlso []

Definition at line 461 of file giaSweeper.c.

462 {
463  Swp_Man_t * pSwp = (Swp_Man_t *)p->pData;
464  Vec_Int_t * vObjIds;
465  Gia_Man_t * pNew, * pTemp;
466  Gia_Obj_t * pObj;
467  int i, iLit, ProbeId;
468 
469  // collect all internal nodes pointed to by currently-used probes
471  vObjIds = Vec_IntAlloc( 1000 );
472  Vec_IntForEachEntry( pSwp->vProbes, iLit, ProbeId )
473  {
474  if ( iLit < 0 ) continue;
475  pObj = Gia_Lit2Obj( p, iLit );
476  Gia_ManExtract_rec( p, Gia_Regular(pObj), vObjIds );
477  }
478  // create new manager
479  pNew = Gia_ManStart( 1 + Gia_ManPiNum(p) + Vec_IntSize(vObjIds) + 100 );
480  pNew->pName = Abc_UtilStrsav( p->pName );
481  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
482  Gia_ManConst0(p)->Value = 0;
483  Gia_ManForEachPi( p, pObj, i )
484  pObj->Value = Gia_ManAppendCi(pNew);
485  // create internal nodes
486  Gia_ManHashStart( pNew );
487  Gia_ManForEachObjVec( vObjIds, p, pObj, i )
488  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
489  Gia_ManHashStop( pNew );
490  // create outputs
491  Vec_IntForEachEntry( pSwp->vProbes, iLit, ProbeId )
492  {
493  if ( iLit < 0 ) continue;
494  pObj = Gia_Lit2Obj( p, iLit );
495  iLit = Gia_Regular(pObj)->Value ^ Gia_IsComplement(pObj);
496  Vec_IntWriteEntry( pSwp->vProbes, ProbeId, iLit );
497  }
498  Vec_IntFree( vObjIds );
499  // duplicate if needed
500  if ( Gia_ManHasDangling(pNew) )
501  {
502  pNew = Gia_ManCleanup( pTemp = pNew );
503  Gia_ManStop( pTemp );
504  }
505  // execute command line
506  if ( pCommLime )
507  {
508  // set pNew to be current GIA in ABC
510  // execute command line pCommLine using Abc_CmdCommandExecute()
512  // get pNew to be current GIA in ABC
514  }
515  // restart the SAT solver
516  Vec_IntClear( pSwp->vId2Lit );
517  sat_solver_delete( pSwp->pSat );
518  pSwp->pSat = sat_solver_new();
519  pSwp->nSatVars = 1;
520  sat_solver_setnvars( pSwp->pSat, 1000 );
521  Swp_ManSetObj2Lit( pSwp, 0, (iLit = Abc_Var2Lit(pSwp->nSatVars++, 0)) );
522  iLit = Abc_LitNot(iLit);
523  sat_solver_addclause( pSwp->pSat, &iLit, &iLit + 1 );
524  pSwp->timeStart = Abc_Clock();
525  // return the result
526  pNew->pData = p->pData; p->pData = NULL;
527  Gia_ManStop( p );
528  return pNew;
529 }
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int Cmd_CommandExecute(void *pAbc, char *pCommandLine)
static Gia_Obj_t * Gia_Regular(Gia_Obj_t *p)
Definition: gia.h:377
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
static abctime Abc_Clock()
Definition: abc_global.h:279
Definition: gia.h:75
int Gia_ManHasDangling(Gia_Man_t *p)
Definition: giaUtil.c:1155
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
char * pName
Definition: gia.h:97
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Gia_ObjFanin1Copy(Gia_Obj_t *pObj)
Definition: gia.h:482
void sat_solver_setnvars(sat_solver *s, int n)
Definition: satSolver.c:1072
void * pData
Definition: gia.h:169
void * Abc_FrameGetGlobalFrame()
Definition: mainFrame.c:593
void Gia_ManHashStart(Gia_Man_t *p)
Definition: giaHash.c:117
char * pSpec
Definition: gia.h:98
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
static void Gia_ManExtract_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vObjIds)
Definition: giaSweeper.c:347
#define Gia_ManForEachPi(p, pObj, i)
Definition: gia.h:1034
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
Definition: gia.h:481
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition: gia.h:988
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
sat_solver * sat_solver_new(void)
Definition: satSolver.c:1001
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Gia_IsComplement(Gia_Obj_t *p)
Definition: gia.h:380
Definition: gia.h:95
typedefABC_NAMESPACE_IMPL_START struct Swp_Man_t_ Swp_Man_t
DECLARATIONS ///.
Definition: giaSweeper.c:56
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
void Abc_FrameUpdateGia(Abc_Frame_t *pAbc, Gia_Man_t *pNew)
Definition: abc.c:616
static void Swp_ManSetObj2Lit(Swp_Man_t *p, int Id, int Lit)
Definition: giaSweeper.c:90
unsigned Value
Definition: gia.h:87
static Gia_Obj_t * Gia_Lit2Obj(Gia_Man_t *p, int iLit)
Definition: gia.h:434
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition: giaUtil.c:149
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
Gia_Man_t * Abc_FrameGetGia(Abc_Frame_t *pAbc)
Definition: abc.c:656
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition: giaScl.c:84
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
void Gia_ManHashStop(Gia_Man_t *p)
Definition: giaHash.c:142
Vec_Int_t* Gia_SweeperCollectValidProbeIds ( Gia_Man_t p)

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

Synopsis [This procedure returns indexes of all currently defined valid probes.]

Description []

SideEffects []

SeeAlso []

Definition at line 295 of file giaSweeper.c.

296 {
297  Swp_Man_t * pSwp = (Swp_Man_t *)p->pData;
298  Vec_Int_t * vProbeIds = Vec_IntAlloc( 1000 );
299  int iLit, ProbeId;
300  Vec_IntForEachEntry( pSwp->vProbes, iLit, ProbeId )
301  {
302  if ( iLit < 0 ) continue;
303  Vec_IntPush( vProbeIds, ProbeId );
304  }
305  return vProbeIds;
306 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
void * pData
Definition: gia.h:169
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
typedefABC_NAMESPACE_IMPL_START struct Swp_Man_t_ Swp_Man_t
DECLARATIONS ///.
Definition: giaSweeper.c:56
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int Gia_SweeperCondCheckUnsat ( Gia_Man_t pGia)

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

Synopsis [Returns 1 if the set of conditions is UNSAT (0 if SAT; -1 if undecided).]

Description []

SideEffects []

SeeAlso []

Definition at line 924 of file giaSweeper.c.

925 {
926  Swp_Man_t * p = (Swp_Man_t *)pGia->pData;
927  int RetValue, ProbeId, iLitAig, i;
928  abctime clk;
929  assert( p->pSat != NULL );
930  p->nSatCalls++;
931  p->vCexUser = NULL;
932 
933  // create logic cones and the array of assumptions
934  Vec_IntClear( p->vCondAssump );
935  Vec_IntForEachEntry( p->vCondProbes, ProbeId, i )
936  {
937  iLitAig = Gia_SweeperProbeLit( pGia, ProbeId );
938  Gia_ManCnfNodeAddToSolver( p, Abc_Lit2Var(iLitAig) );
939  Vec_IntPush( p->vCondAssump, Abc_LitNot(Swp_ManLit2Lit(p, iLitAig)) );
940  }
941  sat_solver_compress( p->pSat );
942 
943  // set runtime limit for this call
944  if ( p->nTimeOut )
945  sat_solver_set_runtime_limit( p->pSat, p->nTimeOut * CLOCKS_PER_SEC + Abc_Clock() );
946 
947 clk = Abc_Clock();
948  RetValue = sat_solver_solve( p->pSat, Vec_IntArray(p->vCondAssump), Vec_IntArray(p->vCondAssump) + Vec_IntSize(p->vCondAssump),
949  (ABC_INT64_T)p->nConfMax, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
950 p->timeSat += Abc_Clock() - clk;
951  if ( RetValue == l_False )
952  {
953  assert( Vec_IntSize(p->vCondProbes) > 0 );
954 p->timeSatUnsat += Abc_Clock() - clk;
955  p->nSatCallsUnsat++;
956  p->nSatProofs++;
957  return 1;
958  }
959  else if ( RetValue == l_True )
960  {
961  p->vCexUser = Gia_ManGetCex( p->pGia, p->vId2Lit, p->pSat, p->vCexSwp );
962 p->timeSatSat += Abc_Clock() - clk;
963  p->nSatCallsSat++;
964  return 0;
965  }
966  else // if ( RetValue1 == l_Undef )
967  {
968 p->timeSatUndec += Abc_Clock() - clk;
969  p->nSatCallsUndec++;
970  return -1;
971  }
972 }
static abctime sat_solver_set_runtime_limit(sat_solver *s, abctime Limit)
Definition: satSolver.h:233
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int sat_solver_solve(sat_solver *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
Definition: satSolver.c:1700
static void sat_solver_compress(sat_solver *s)
Definition: satSolver.h:217
#define l_True
Definition: SolverTypes.h:84
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Swp_ManLit2Lit(Swp_Man_t *p, int Lit)
Definition: giaSweeper.c:89
void * pData
Definition: gia.h:169
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
typedefABC_NAMESPACE_IMPL_START struct Swp_Man_t_ Swp_Man_t
DECLARATIONS ///.
Definition: giaSweeper.c:56
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define l_False
Definition: SolverTypes.h:85
static void Gia_ManCnfNodeAddToSolver(Swp_Man_t *p, int NodeId)
Definition: giaSweeper.c:701
#define assert(ex)
Definition: util_old.h:213
int Gia_SweeperProbeLit(Gia_Man_t *p, int ProbeId)
Definition: giaSweeper.c:276
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
ABC_INT64_T abctime
Definition: abc_global.h:278
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static Vec_Int_t * Gia_ManGetCex(Gia_Man_t *pGia, Vec_Int_t *vId2Lit, sat_solver *pSat, Vec_Int_t *vCex)
Definition: giaSweeper.c:753
int Gia_SweeperCondPop ( Gia_Man_t p)

Definition at line 324 of file giaSweeper.c.

325 {
326  Swp_Man_t * pSwp = (Swp_Man_t *)p->pData;
327  return Vec_IntPop( pSwp->vCondProbes );
328 }
void * pData
Definition: gia.h:169
static int Vec_IntPop(Vec_Int_t *p)
typedefABC_NAMESPACE_IMPL_START struct Swp_Man_t_ Swp_Man_t
DECLARATIONS ///.
Definition: giaSweeper.c:56
void Gia_SweeperCondPush ( Gia_Man_t p,
int  ProbeId 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 319 of file giaSweeper.c.

320 {
321  Swp_Man_t * pSwp = (Swp_Man_t *)p->pData;
322  Vec_IntPush( pSwp->vCondProbes, ProbeId );
323 }
void * pData
Definition: gia.h:169
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
typedefABC_NAMESPACE_IMPL_START struct Swp_Man_t_ Swp_Man_t
DECLARATIONS ///.
Definition: giaSweeper.c:56
Vec_Int_t* Gia_SweeperCondVector ( Gia_Man_t p)

Definition at line 329 of file giaSweeper.c.

330 {
331  Swp_Man_t * pSwp = (Swp_Man_t *)p->pData;
332  return pSwp->vCondProbes;
333 }
void * pData
Definition: gia.h:169
typedefABC_NAMESPACE_IMPL_START struct Swp_Man_t_ Swp_Man_t
DECLARATIONS ///.
Definition: giaSweeper.c:56
Gia_Man_t* Gia_SweeperExtractUserLogic ( Gia_Man_t p,
Vec_Int_t vProbeIds,
Vec_Ptr_t vInNames,
Vec_Ptr_t vOutNames 
)

Definition at line 358 of file giaSweeper.c.

359 {
360  Vec_Int_t * vObjIds, * vValues;
361  Gia_Man_t * pNew, * pTemp;
362  Gia_Obj_t * pObj;
363  int i, ProbeId;
364  assert( vInNames == NULL || Gia_ManPiNum(p) == Vec_PtrSize(vInNames) );
365  assert( vOutNames == NULL || Vec_IntSize(vProbeIds) == Vec_PtrSize(vOutNames) );
366  // create new
368  vObjIds = Vec_IntAlloc( 1000 );
369  Vec_IntForEachEntry( vProbeIds, ProbeId, i )
370  {
371  pObj = Gia_Lit2Obj( p, Gia_SweeperProbeLit(p, ProbeId) );
372  Gia_ManExtract_rec( p, Gia_Regular(pObj), vObjIds );
373  }
374  // create new manager
375  pNew = Gia_ManStart( 1 + Gia_ManPiNum(p) + Vec_IntSize(vObjIds) + Vec_IntSize(vProbeIds) + 100 );
376  pNew->pName = Abc_UtilStrsav( p->pName );
377  pNew->pSpec = Abc_UtilStrsav( p->pSpec );
378  Gia_ManConst0(p)->Value = 0;
379  Gia_ManForEachPi( p, pObj, i )
380  pObj->Value = Gia_ManAppendCi(pNew);
381  // create internal nodes
382  Gia_ManHashStart( pNew );
383  vValues = Vec_IntAlloc( Vec_IntSize(vObjIds) );
384  Gia_ManForEachObjVec( vObjIds, p, pObj, i )
385  {
386  Vec_IntPush( vValues, pObj->Value );
387  pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
388  }
389  Gia_ManHashStop( pNew );
390  // create outputs
391  Vec_IntForEachEntry( vProbeIds, ProbeId, i )
392  {
393  pObj = Gia_Lit2Obj( p, Gia_SweeperProbeLit(p, ProbeId) );
394  Gia_ManAppendCo( pNew, Gia_Regular(pObj)->Value ^ Gia_IsComplement(pObj) );
395  }
396  // return the values back
397  Gia_ManForEachPi( p, pObj, i )
398  pObj->Value = 0;
399  Gia_ManForEachObjVec( vObjIds, p, pObj, i )
400  pObj->Value = Vec_IntEntry( vValues, i );
401  Vec_IntFree( vObjIds );
402  Vec_IntFree( vValues );
403  // duplicate if needed
404  if ( Gia_ManHasDangling(pNew) )
405  {
406  pNew = Gia_ManCleanup( pTemp = pNew );
407  Gia_ManStop( pTemp );
408  }
409  // copy names if present
410  if ( vInNames )
411  pNew->vNamesIn = Vec_PtrDupStr( vInNames );
412  if ( vOutNames )
413  pNew->vNamesOut = Vec_PtrDupStr( vOutNames );
414  return pNew;
415 }
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static Gia_Obj_t * Gia_Regular(Gia_Obj_t *p)
Definition: gia.h:377
static int Gia_ManAppendCi(Gia_Man_t *p)
Definition: gia.h:583
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Definition: gia.h:75
int Gia_ManHasDangling(Gia_Man_t *p)
Definition: giaUtil.c:1155
char * pName
Definition: gia.h:97
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static int Gia_ObjFanin1Copy(Gia_Obj_t *pObj)
Definition: gia.h:482
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
if(last==0)
Definition: sparse_int.h:34
void Gia_ManHashStart(Gia_Man_t *p)
Definition: giaHash.c:117
char * pSpec
Definition: gia.h:98
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static void Gia_ManExtract_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vObjIds)
Definition: giaSweeper.c:347
#define Gia_ManForEachPi(p, pObj, i)
Definition: gia.h:1034
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
Definition: gia.h:481
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Definition: gia.h:988
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Gia_IsComplement(Gia_Obj_t *p)
Definition: gia.h:380
Definition: gia.h:95
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Definition: gia.h:400
#define assert(ex)
Definition: util_old.h:213
unsigned Value
Definition: gia.h:87
static Gia_Obj_t * Gia_Lit2Obj(Gia_Man_t *p, int iLit)
Definition: gia.h:434
void Gia_ManIncrementTravId(Gia_Man_t *p)
Definition: giaUtil.c:149
int Gia_SweeperProbeLit(Gia_Man_t *p, int ProbeId)
Definition: giaSweeper.c:276
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
Definition: giaScl.c:84
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static Vec_Ptr_t * Vec_PtrDupStr(Vec_Ptr_t *pVec)
Definition: vecPtr.h:179
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
void Gia_ManHashStop(Gia_Man_t *p)
Definition: giaHash.c:142
int Gia_SweeperFraig ( Gia_Man_t p,
Vec_Int_t vProbeIds,
char *  pCommLime,
int  nWords,
int  nConfs,
int  fVerify,
int  fVerbose 
)

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

Synopsis [Procedure to perform conditional fraig sweeping on separate logic cones.]

Description [The procedure takes GIA with the sweeper defined. The sweeper is assumed to have some conditions currently pushed, which will be used as constraints for fraig sweeping. The second argument (vProbes) contains the array of probe IDs pointing to the user's logic cones to be SAT swept. Finally, the optional command line (pCommLine) is an ABC command line to be applied to the resulting GIA after SAT sweeping before it is grafted back into the original GIA manager. The return value is the status (success/failure) and the array of original probes possibly pointing to the new literals in the original GIA manager, corresponding to the user's logic cones after sweeping, synthesis and grafting.]

SideEffects []

SeeAlso []

Definition at line 1064 of file giaSweeper.c.

1065 {
1066  Gia_Man_t * pNew;
1067  Vec_Int_t * vLits;
1068  int ProbeId, i;
1069  // sweeper is running
1071  // sweep the logic
1072  pNew = Gia_SweeperSweep( p, vProbeIds, nWords, nConfs, fVerify, fVerbose );
1073  if ( pNew == NULL )
1074  return 0;
1075  // execute command line
1076  if ( pCommLime )
1077  {
1078  // set pNew to be current GIA in ABC
1080  // execute command line pCommLine using Abc_CmdCommandExecute()
1082  // get pNew to be current GIA in ABC
1084  }
1085  // return logic back into the main manager
1086  vLits = Gia_SweeperGraft( p, NULL, pNew );
1087  Gia_ManStop( pNew );
1088  // update the array of probes
1089  Vec_IntForEachEntry( vProbeIds, ProbeId, i )
1090  Gia_SweeperProbeUpdate( p, ProbeId, Vec_IntEntry(vLits, i) );
1091  Vec_IntFree( vLits );
1092  return 1;
1093 }
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int Cmd_CommandExecute(void *pAbc, char *pCommandLine)
int Gia_SweeperProbeUpdate(Gia_Man_t *p, int ProbeId, int iLitNew)
Definition: giaSweeper.c:267
int nWords
Definition: abcNpn.c:127
Vec_Int_t * Gia_SweeperGraft(Gia_Man_t *pDst, Vec_Int_t *vProbes, Gia_Man_t *pSrc)
Definition: giaSweeper.c:985
Gia_Man_t * Gia_SweeperSweep(Gia_Man_t *p, Vec_Int_t *vProbeOuts, int nWords, int nConfs, int fVerify, int fVerbose)
Definition: giaSweeper.c:1017
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
void * Abc_FrameGetGlobalFrame()
Definition: mainFrame.c:593
int Gia_SweeperIsRunning(Gia_Man_t *pGia)
Definition: giaSweeper.c:164
Definition: gia.h:95
void Abc_FrameUpdateGia(Abc_Frame_t *pAbc, Gia_Man_t *pNew)
Definition: abc.c:616
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Gia_Man_t * Abc_FrameGetGia(Abc_Frame_t *pAbc)
Definition: abc.c:656
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
Gia_Man_t* Gia_SweeperFraigTest ( Gia_Man_t pInit,
int  nWords,
int  nConfs,
int  fVerbose 
)

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

Synopsis [Sweeper sweeper test.]

Description []

SideEffects []

SeeAlso []

Definition at line 1152 of file giaSweeper.c.

1153 {
1154  Gia_Man_t * p, * pGia;
1155  Gia_Obj_t * pObj;
1156  Vec_Int_t * vOuts;
1157  int i;
1158  // add one-hotness constraints
1159  p = Gia_ManDupOneHot( pInit );
1160  // create sweeper
1161  Gia_SweeperStart( p );
1162  // collect outputs and create conditions
1163  vOuts = Vec_IntAlloc( Gia_ManPoNum(p) );
1164  Gia_ManForEachPo( p, pObj, i )
1165  if ( i < Gia_ManPoNum(p) - p->nConstrs ) // this is the user's output
1166  Vec_IntPush( vOuts, Gia_SweeperProbeCreate( p, Gia_ObjFaninLit0p(p, pObj) ) );
1167  else // this is a constraint
1169  // perform the sweeping
1170  pGia = Gia_SweeperSweep( p, vOuts, nWords, nConfs, fVerbose, 0 );
1171 // pGia = Gia_ManDup( p );
1172  Vec_IntFree( vOuts );
1173  // sop the sweeper
1174  Gia_SweeperStop( p );
1175  Gia_ManStop( p );
1176  return pGia;
1177 }
Gia_Man_t * Gia_SweeperStart(Gia_Man_t *pGia)
Definition: giaSweeper.c:145
void Gia_SweeperCondPush(Gia_Man_t *p, int ProbeId)
Definition: giaSweeper.c:319
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
Gia_Man_t * Gia_ManDupOneHot(Gia_Man_t *p)
Definition: giaDup.c:2785
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Gia_ObjFaninLit0p(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:469
int Gia_SweeperProbeCreate(Gia_Man_t *p, int iLit)
Definition: giaSweeper.c:249
int nWords
Definition: abcNpn.c:127
Definition: gia.h:75
Gia_Man_t * Gia_SweeperSweep(Gia_Man_t *p, Vec_Int_t *vProbeOuts, int nWords, int nConfs, int fVerify, int fVerbose)
Definition: giaSweeper.c:1017
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
void Gia_SweeperStop(Gia_Man_t *pGia)
Definition: giaSweeper.c:157
Definition: gia.h:95
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Gia_ManForEachPo(p, pObj, i)
Definition: gia.h:1036
Vec_Int_t* Gia_SweeperGetCex ( Gia_Man_t p)

Definition at line 230 of file giaSweeper.c.

231 {
232  Swp_Man_t * pSwp = (Swp_Man_t *)p->pData;
233  assert( pSwp->vCexUser == NULL || Vec_IntSize(pSwp->vCexUser) == Gia_ManPiNum(p) );
234  return pSwp->vCexUser;
235 }
void * pData
Definition: gia.h:169
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
typedefABC_NAMESPACE_IMPL_START struct Swp_Man_t_ Swp_Man_t
DECLARATIONS ///.
Definition: giaSweeper.c:56
#define assert(ex)
Definition: util_old.h:213
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
Vec_Int_t* Gia_SweeperGraft ( Gia_Man_t pDst,
Vec_Int_t vProbes,
Gia_Man_t pSrc 
)

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

Synopsis [Performs grafting from another manager.]

Description [Returns the array of resulting literals in the destination manager.]

SideEffects []

SeeAlso []

Definition at line 985 of file giaSweeper.c.

986 {
987  Vec_Int_t * vOutLits;
988  Gia_Obj_t * pObj;
989  int i;
990  assert( Gia_SweeperIsRunning(pDst) );
991  if ( vProbes )
992  assert( Vec_IntSize(vProbes) == Gia_ManPiNum(pSrc) );
993  else
994  assert( Gia_ManPiNum(pDst) == Gia_ManPiNum(pSrc) );
995  Gia_ManForEachPi( pSrc, pObj, i )
996  pObj->Value = vProbes ? Gia_SweeperProbeLit(pDst, Vec_IntEntry(vProbes, i)) : Gia_Obj2Lit(pDst,Gia_ManPi(pDst, i));
997  Gia_ManForEachAnd( pSrc, pObj, i )
998  pObj->Value = Gia_ManHashAnd( pDst, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) );
999  vOutLits = Vec_IntAlloc( Gia_ManPoNum(pSrc) );
1000  Gia_ManForEachPo( pSrc, pObj, i )
1001  Vec_IntPush( vOutLits, Gia_ObjFanin0Copy(pObj) );
1002  return vOutLits;
1003 }
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Definition: gia.h:75
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
static int Gia_ObjFanin1Copy(Gia_Obj_t *pObj)
Definition: gia.h:482
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define Gia_ManForEachAnd(p, pObj, i)
Definition: gia.h:1002
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define Gia_ManForEachPi(p, pObj, i)
Definition: gia.h:1034
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
Definition: gia.h:481
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
int Gia_SweeperIsRunning(Gia_Man_t *pGia)
Definition: giaSweeper.c:164
#define assert(ex)
Definition: util_old.h:213
int Gia_SweeperProbeLit(Gia_Man_t *p, int ProbeId)
Definition: giaSweeper.c:276
static int Gia_ManPiNum(Gia_Man_t *p)
Definition: gia.h:385
#define Gia_ManForEachPo(p, pObj, i)
Definition: gia.h:1036
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
static int Gia_Obj2Lit(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:433
int Gia_SweeperIsRunning ( Gia_Man_t pGia)

Definition at line 164 of file giaSweeper.c.

165 {
166  return (pGia->pData != NULL);
167 }
void * pData
Definition: gia.h:169
void Gia_SweeperLogicDump ( Gia_Man_t p,
Vec_Int_t vProbeIds,
int  fDumpConds,
char *  pFileName 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 428 of file giaSweeper.c.

429 {
430  Gia_Man_t * pGiaOuts = Gia_SweeperExtractUserLogic( p, vProbeIds, NULL, NULL );
431  Vec_Int_t * vProbeConds = Gia_SweeperCondVector( p );
432  printf( "Dumping logic cones" );
433  if ( fDumpConds && Vec_IntSize(vProbeConds) > 0 )
434  {
435  Gia_Man_t * pGiaCond = Gia_SweeperExtractUserLogic( p, vProbeConds, NULL, NULL );
436  Gia_ManDupAppendShare( pGiaOuts, pGiaCond );
437  pGiaOuts->nConstrs = Gia_ManPoNum(pGiaCond);
438  Gia_ManHashStop( pGiaOuts );
439  Gia_ManStop( pGiaCond );
440  printf( " and conditions" );
441  }
442  Gia_AigerWrite( pGiaOuts, pFileName, 0, 0 );
443  Gia_ManStop( pGiaOuts );
444  printf( " into file \"%s\".\n", pFileName );
445 }
Vec_Int_t * Gia_SweeperCondVector(Gia_Man_t *p)
Definition: giaSweeper.c:329
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Gia_Man_t * Gia_SweeperExtractUserLogic(Gia_Man_t *p, Vec_Int_t *vProbeIds, Vec_Ptr_t *vInNames, Vec_Ptr_t *vOutNames)
Definition: giaSweeper.c:358
int nConstrs
Definition: gia.h:117
void Gia_AigerWrite(Gia_Man_t *p, char *pFileName, int fWriteSymbols, int fCompact)
Definition: giaAiger.c:1024
void Gia_ManDupAppendShare(Gia_Man_t *p, Gia_Man_t *pTwo)
Definition: giaDup.c:765
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Definition: gia.h:95
void Gia_ManHashStop(Gia_Man_t *p)
Definition: giaHash.c:142
double Gia_SweeperMemUsage ( Gia_Man_t pGia)

Definition at line 168 of file giaSweeper.c.

169 {
170  Swp_Man_t * p = (Swp_Man_t *)pGia->pData;
171  double nMem = sizeof(Swp_Man_t);
172  nMem += Vec_IntCap(p->vProbes);
173  nMem += Vec_IntCap(p->vCondProbes);
174  nMem += Vec_IntCap(p->vCondAssump);
175  nMem += Vec_IntCap(p->vId2Lit);
176  nMem += Vec_IntCap(p->vFront);
177  nMem += Vec_IntCap(p->vFanins);
178  nMem += Vec_IntCap(p->vCexSwp);
179  return 4.0 * nMem;
180 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void * pData
Definition: gia.h:169
static int Vec_IntCap(Vec_Int_t *p)
Definition: vecInt.h:368
typedefABC_NAMESPACE_IMPL_START struct Swp_Man_t_ Swp_Man_t
DECLARATIONS ///.
Definition: giaSweeper.c:56
void Gia_SweeperPrintStats ( Gia_Man_t pGia)

Definition at line 181 of file giaSweeper.c.

182 {
183  Swp_Man_t * p = (Swp_Man_t *)pGia->pData;
184  double nMemSwp = Gia_SweeperMemUsage(pGia);
185  double nMemGia = (double)Gia_ManObjNum(pGia)*(sizeof(Gia_Obj_t) + sizeof(int));
186  double nMemSat = sat_solver_memory(p->pSat);
187  double nMemTot = nMemSwp + nMemGia + nMemSat;
188  printf( "SAT sweeper statistics:\n" );
189  printf( "Memory usage:\n" );
190  ABC_PRMP( "Sweeper ", nMemSwp, nMemTot );
191  ABC_PRMP( "AIG manager ", nMemGia, nMemTot );
192  ABC_PRMP( "SAT solver ", nMemSat, nMemTot );
193  ABC_PRMP( "TOTAL ", nMemTot, nMemTot );
194  printf( "Runtime usage:\n" );
195  p->timeTotal = Abc_Clock() - p->timeStart;
196  ABC_PRTP( "CNF construction", p->timeCnf, p->timeTotal );
197  ABC_PRTP( "SAT solving ", p->timeSat, p->timeTotal );
198  ABC_PRTP( " Sat ", p->timeSatSat, p->timeTotal );
199  ABC_PRTP( " Unsat ", p->timeSatUnsat, p->timeTotal );
200  ABC_PRTP( " Undecided ", p->timeSatUndec, p->timeTotal );
201  ABC_PRTP( "TOTAL RUNTIME ", p->timeTotal, p->timeTotal );
202  printf( "GIA: " );
203  Gia_ManPrintStats( pGia, NULL );
204  printf( "SAT calls = %d. Sat = %d. Unsat = %d. Undecided = %d. Proofs = %d.\n",
205  p->nSatCalls, p->nSatCallsSat, p->nSatCallsUnsat, p->nSatCallsUndec, p->nSatProofs );
206  Sat_SolverPrintStats( stdout, p->pSat );
207 }
double Gia_SweeperMemUsage(Gia_Man_t *pGia)
Definition: giaSweeper.c:168
void Gia_ManPrintStats(Gia_Man_t *p, Gps_Par_t *pPars)
Definition: giaMan.c:389
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static abctime Abc_Clock()
Definition: abc_global.h:279
double sat_solver_memory(sat_solver *s)
Definition: satSolver.c:1236
#define ABC_PRTP(a, t, T)
Definition: abc_global.h:223
struct Gia_Obj_t_ Gia_Obj_t
Definition: gia.h:74
void * pData
Definition: gia.h:169
#define ABC_PRMP(a, f, F)
Definition: abc_global.h:227
typedefABC_NAMESPACE_IMPL_START struct Swp_Man_t_ Swp_Man_t
DECLARATIONS ///.
Definition: giaSweeper.c:56
void Sat_SolverPrintStats(FILE *pFile, sat_solver *p)
Definition: satUtil.c:188
static int Gia_ManObjNum(Gia_Man_t *p)
Definition: gia.h:388
int Gia_SweeperProbeCreate ( Gia_Man_t p,
int  iLit 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 249 of file giaSweeper.c.

250 {
251  Swp_Man_t * pSwp = (Swp_Man_t *)p->pData;
252  int ProbeId = Vec_IntSize(pSwp->vProbes);
253  assert( iLit >= 0 );
254  Vec_IntPush( pSwp->vProbes, iLit );
255  return ProbeId;
256 }
void * pData
Definition: gia.h:169
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
typedefABC_NAMESPACE_IMPL_START struct Swp_Man_t_ Swp_Man_t
DECLARATIONS ///.
Definition: giaSweeper.c:56
#define assert(ex)
Definition: util_old.h:213
int Gia_SweeperProbeDelete ( Gia_Man_t p,
int  ProbeId 
)

Definition at line 258 of file giaSweeper.c.

259 {
260  Swp_Man_t * pSwp = (Swp_Man_t *)p->pData;
261  int iLit = Vec_IntEntry(pSwp->vProbes, ProbeId);
262  assert( iLit >= 0 );
263  Vec_IntWriteEntry(pSwp->vProbes, ProbeId, -1);
264  return iLit;
265 }
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
void * pData
Definition: gia.h:169
typedefABC_NAMESPACE_IMPL_START struct Swp_Man_t_ Swp_Man_t
DECLARATIONS ///.
Definition: giaSweeper.c:56
#define assert(ex)
Definition: util_old.h:213
int Gia_SweeperProbeLit ( Gia_Man_t p,
int  ProbeId 
)

Definition at line 276 of file giaSweeper.c.

277 {
278  Swp_Man_t * pSwp = (Swp_Man_t *)p->pData;
279  int iLit = Vec_IntEntry(pSwp->vProbes, ProbeId);
280  assert( iLit >= 0 );
281  return iLit;
282 }
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
void * pData
Definition: gia.h:169
typedefABC_NAMESPACE_IMPL_START struct Swp_Man_t_ Swp_Man_t
DECLARATIONS ///.
Definition: giaSweeper.c:56
#define assert(ex)
Definition: util_old.h:213
int Gia_SweeperProbeUpdate ( Gia_Man_t p,
int  ProbeId,
int  iLitNew 
)

Definition at line 267 of file giaSweeper.c.

268 {
269  Swp_Man_t * pSwp = (Swp_Man_t *)p->pData;
270  int iLit = Vec_IntEntry(pSwp->vProbes, ProbeId);
271  assert( iLit >= 0 );
272  Vec_IntWriteEntry(pSwp->vProbes, ProbeId, iLitNew);
273  return iLit;
274 }
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
void * pData
Definition: gia.h:169
typedefABC_NAMESPACE_IMPL_START struct Swp_Man_t_ Swp_Man_t
DECLARATIONS ///.
Definition: giaSweeper.c:56
#define assert(ex)
Definition: util_old.h:213
int Gia_SweeperRun ( Gia_Man_t p,
Vec_Int_t vProbeIds,
char *  pCommLime,
int  fVerbose 
)

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

Synopsis [Executes given command line for the logic defined by the probes.]

Description [ ]

SideEffects []

SeeAlso []

Definition at line 1106 of file giaSweeper.c.

1107 {
1108  Gia_Man_t * pNew;
1109  Vec_Int_t * vLits;
1110  int ProbeId, i;
1111  // sweeper is running
1113  // sweep the logic
1114  pNew = Gia_SweeperExtractUserLogic( p, vProbeIds, NULL, NULL );
1115  // execute command line
1116  if ( pCommLime )
1117  {
1118  if ( fVerbose )
1119  printf( "GIA manager statistics before and after applying \"%s\":\n", pCommLime );
1120  if ( fVerbose )
1121  Gia_ManPrintStats( pNew, NULL );
1122  // set pNew to be current GIA in ABC
1124  // execute command line pCommLine using Abc_CmdCommandExecute()
1126  // get pNew to be current GIA in ABC
1128  if ( fVerbose )
1129  Gia_ManPrintStats( pNew, NULL );
1130  }
1131  // return logic back into the main manager
1132  vLits = Gia_SweeperGraft( p, NULL, pNew );
1133  Gia_ManStop( pNew );
1134  // update the array of probes
1135  Vec_IntForEachEntry( vProbeIds, ProbeId, i )
1136  Gia_SweeperProbeUpdate( p, ProbeId, Vec_IntEntry(vLits, i) );
1137  Vec_IntFree( vLits );
1138  return 1;
1139 }
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
void Gia_ManPrintStats(Gia_Man_t *p, Gps_Par_t *pPars)
Definition: giaMan.c:389
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int Cmd_CommandExecute(void *pAbc, char *pCommandLine)
Gia_Man_t * Gia_SweeperExtractUserLogic(Gia_Man_t *p, Vec_Int_t *vProbeIds, Vec_Ptr_t *vInNames, Vec_Ptr_t *vOutNames)
Definition: giaSweeper.c:358
int Gia_SweeperProbeUpdate(Gia_Man_t *p, int ProbeId, int iLitNew)
Definition: giaSweeper.c:267
Vec_Int_t * Gia_SweeperGraft(Gia_Man_t *pDst, Vec_Int_t *vProbes, Gia_Man_t *pSrc)
Definition: giaSweeper.c:985
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
void * Abc_FrameGetGlobalFrame()
Definition: mainFrame.c:593
int Gia_SweeperIsRunning(Gia_Man_t *pGia)
Definition: giaSweeper.c:164
Definition: gia.h:95
void Abc_FrameUpdateGia(Abc_Frame_t *pAbc, Gia_Man_t *pNew)
Definition: abc.c:616
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Gia_Man_t * Abc_FrameGetGia(Abc_Frame_t *pAbc)
Definition: abc.c:656
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
void Gia_SweeperSetConflictLimit ( Gia_Man_t p,
int  nConfMax 
)

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

Synopsis [Setting resource limits.]

Description []

SideEffects []

SeeAlso []

Definition at line 220 of file giaSweeper.c.

221 {
222  Swp_Man_t * pSwp = (Swp_Man_t *)p->pData;
223  pSwp->nConfMax = nConfMax;
224 }
void * pData
Definition: gia.h:169
typedefABC_NAMESPACE_IMPL_START struct Swp_Man_t_ Swp_Man_t
DECLARATIONS ///.
Definition: giaSweeper.c:56
void Gia_SweeperSetRuntimeLimit ( Gia_Man_t p,
int  nSeconds 
)

Definition at line 225 of file giaSweeper.c.

226 {
227  Swp_Man_t * pSwp = (Swp_Man_t *)p->pData;
228  pSwp->nTimeOut = nSeconds;
229 }
void * pData
Definition: gia.h:169
typedefABC_NAMESPACE_IMPL_START struct Swp_Man_t_ Swp_Man_t
DECLARATIONS ///.
Definition: giaSweeper.c:56
Gia_Man_t* Gia_SweeperStart ( Gia_Man_t pGia)

Definition at line 145 of file giaSweeper.c.

146 {
147  if ( pGia == NULL )
148  pGia = Gia_ManStart( 10000 );
149  if ( pGia->pHTable == NULL )
150  Gia_ManHashStart( pGia );
151  // recompute fPhase and fMark1 to mark multiple fanout nodes if AIG is already defined!!!
152 
153  Swp_ManStart( pGia );
154  pGia->fSweeper = 1;
155  return pGia;
156 }
static Swp_Man_t * Swp_ManStart(Gia_Man_t *pGia)
FUNCTION DEFINITIONS ///.
Definition: giaSweeper.c:107
int * pHTable
Definition: gia.h:110
int fSweeper
Definition: gia.h:113
void Gia_ManHashStart(Gia_Man_t *p)
Definition: giaHash.c:117
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Definition: giaMan.c:52
void Gia_SweeperStop ( Gia_Man_t pGia)

Definition at line 157 of file giaSweeper.c.

158 {
159  pGia->fSweeper = 0;
160  Swp_ManStop( pGia );
161  Gia_ManHashStop( pGia );
162 // Gia_ManStop( pGia );
163 }
static void Swp_ManStop(Gia_Man_t *pGia)
Definition: giaSweeper.c:131
int fSweeper
Definition: gia.h:113
void Gia_ManHashStop(Gia_Man_t *p)
Definition: giaHash.c:142
Gia_Man_t* Gia_SweeperSweep ( Gia_Man_t p,
Vec_Int_t vProbeOuts,
int  nWords,
int  nConfs,
int  fVerify,
int  fVerbose 
)

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

Synopsis [Performs conditional sweeping of the cone.]

Description [Returns the result as a new GIA manager with as many inputs as the original manager and as many outputs as there are logic cones.]

SideEffects []

SeeAlso []

Definition at line 1017 of file giaSweeper.c.

1018 {
1019  Vec_Int_t * vProbeConds;
1020  Gia_Man_t * pGiaCond, * pGiaOuts, * pGiaRes;
1021  Ssc_Pars_t Pars, * pPars = &Pars;
1022  Ssc_ManSetDefaultParams( pPars );
1023  pPars->nWords = nWords;
1024  pPars->nBTLimit = nConfs;
1025  pPars->fVerify = fVerify;
1026  pPars->fVerbose = fVerbose;
1027  // sweeper is running
1029  // extract conditions and logic cones
1030  vProbeConds = Gia_SweeperCondVector( p );
1031  pGiaCond = Gia_SweeperExtractUserLogic( p, vProbeConds, NULL, NULL );
1032  pGiaOuts = Gia_SweeperExtractUserLogic( p, vProbeOuts, NULL, NULL );
1033  Gia_ManSetPhase( pGiaOuts );
1034  // if there is no conditions, define constant true constraint (constant 0 output)
1035  if ( Gia_ManPoNum(pGiaCond) == 0 )
1036  Gia_ManAppendCo( pGiaCond, Gia_ManConst0Lit() );
1037  // perform sweeping under constraints
1038  pGiaRes = Ssc_PerformSweeping( pGiaOuts, pGiaCond, pPars );
1039  Gia_ManStop( pGiaCond );
1040  Gia_ManStop( pGiaOuts );
1041  return pGiaRes;
1042 }
Vec_Int_t * Gia_SweeperCondVector(Gia_Man_t *p)
Definition: giaSweeper.c:329
void Ssc_ManSetDefaultParams(Ssc_Pars_t *p)
MACRO DEFINITIONS ///.
Definition: sscCore.c:46
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
static int Gia_ManPoNum(Gia_Man_t *p)
Definition: gia.h:386
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
Definition: gia.h:703
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Gia_Man_t * Gia_SweeperExtractUserLogic(Gia_Man_t *p, Vec_Int_t *vProbeIds, Vec_Ptr_t *vInNames, Vec_Ptr_t *vOutNames)
Definition: giaSweeper.c:358
typedefABC_NAMESPACE_HEADER_START struct Ssc_Pars_t_ Ssc_Pars_t
INCLUDES ///.
Definition: ssc.h:43
int nWords
Definition: abcNpn.c:127
static int Gia_ManConst0Lit()
Definition: gia.h:371
Gia_Man_t * Ssc_PerformSweeping(Gia_Man_t *pAig, Gia_Man_t *pCare, Ssc_Pars_t *pPars)
Definition: sscCore.c:413
int Gia_SweeperIsRunning(Gia_Man_t *pGia)
Definition: giaSweeper.c:164
Definition: gia.h:95
#define assert(ex)
Definition: util_old.h:213
void Gia_ManSetPhase(Gia_Man_t *p)
Definition: giaUtil.c:379
static int Swp_ManLit2Lit ( Swp_Man_t p,
int  Lit 
)
inlinestatic

Definition at line 89 of file giaSweeper.c.

89 { assert( Vec_IntEntry(p->vId2Lit, Abc_Lit2Var(Lit)) ); return Abc_Lit2LitL( Vec_IntArray(p->vId2Lit), Lit ); }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_Lit2LitL(int *pMap, int Lit)
Definition: abc_global.h:270
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define assert(ex)
Definition: util_old.h:213
static int Swp_ManObj2Lit ( Swp_Man_t p,
int  Id 
)
inlinestatic

Definition at line 88 of file giaSweeper.c.

88 { return Vec_IntGetEntry( p->vId2Lit, Id ); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_IntGetEntry(Vec_Int_t *p, int i)
Definition: bblif.c:401
static void Swp_ManSetObj2Lit ( Swp_Man_t p,
int  Id,
int  Lit 
)
inlinestatic

Definition at line 90 of file giaSweeper.c.

90 { assert( Lit > 0 ); Vec_IntSetEntry( p->vId2Lit, Id, Lit ); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_IntSetEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:418
#define assert(ex)
Definition: util_old.h:213
static Swp_Man_t* Swp_ManStart ( Gia_Man_t pGia)
inlinestatic

FUNCTION DEFINITIONS ///.

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

Synopsis [Creating/deleting the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 107 of file giaSweeper.c.

108 {
109  Swp_Man_t * p;
110  int Lit;
111  assert( pGia->pHTable != NULL );
112  pGia->pData = p = ABC_CALLOC( Swp_Man_t, 1 );
113  p->pGia = pGia;
114  p->nConfMax = 1000;
115  p->vProbes = Vec_IntAlloc( 100 );
116  p->vCondProbes = Vec_IntAlloc( 100 );
117  p->vCondAssump = Vec_IntAlloc( 100 );
118  p->vId2Lit = Vec_IntAlloc( 10000 );
119  p->vFront = Vec_IntAlloc( 100 );
120  p->vFanins = Vec_IntAlloc( 100 );
121  p->vCexSwp = Vec_IntAlloc( 100 );
122  p->pSat = sat_solver_new();
123  p->nSatVars = 1;
124  sat_solver_setnvars( p->pSat, 1000 );
125  Swp_ManSetObj2Lit( p, 0, (Lit = Abc_Var2Lit(p->nSatVars++, 0)) );
126  Lit = Abc_LitNot(Lit);
127  sat_solver_addclause( p->pSat, &Lit, &Lit + 1 );
128  p->timeStart = Abc_Clock();
129  return p;
130 }
int * pHTable
Definition: gia.h:110
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
static abctime Abc_Clock()
Definition: abc_global.h:279
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
void sat_solver_setnvars(sat_solver *s, int n)
Definition: satSolver.c:1072
void * pData
Definition: gia.h:169
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
sat_solver * sat_solver_new(void)
Definition: satSolver.c:1001
typedefABC_NAMESPACE_IMPL_START struct Swp_Man_t_ Swp_Man_t
DECLARATIONS ///.
Definition: giaSweeper.c:56
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
#define assert(ex)
Definition: util_old.h:213
static void Swp_ManSetObj2Lit(Swp_Man_t *p, int Id, int Lit)
Definition: giaSweeper.c:90
static void Swp_ManStop ( Gia_Man_t pGia)
inlinestatic

Definition at line 131 of file giaSweeper.c.

132 {
133  Swp_Man_t * p = (Swp_Man_t *)pGia->pData;
134  sat_solver_delete( p->pSat );
135  Vec_IntFree( p->vFanins );
136  Vec_IntFree( p->vCexSwp );
137  Vec_IntFree( p->vId2Lit );
138  Vec_IntFree( p->vFront );
139  Vec_IntFree( p->vProbes );
140  Vec_IntFree( p->vCondProbes );
141  Vec_IntFree( p->vCondAssump );
142  ABC_FREE( p );
143  pGia->pData = NULL;
144 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
void * pData
Definition: gia.h:169
#define ABC_FREE(obj)
Definition: abc_global.h:232
typedefABC_NAMESPACE_IMPL_START struct Swp_Man_t_ Swp_Man_t
DECLARATIONS ///.
Definition: giaSweeper.c:56
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235