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

Go to the source code of this file.

Classes

struct  Cbs0_Par_t_
 
struct  Cbs0_Que_t_
 
struct  Cbs0_Man_t_
 

Macros

#define Cbs0_QueForEachEntry(Que, pObj, i)
 

Typedefs

typedef typedefABC_NAMESPACE_IMPL_START struct Cbs0_Par_t_ Cbs0_Par_t
 DECLARATIONS ///.
 
typedef struct Cbs0_Que_t_ Cbs0_Que_t
 
typedef struct Cbs0_Man_t_ Cbs0_Man_t
 

Functions

void Cbs0_SetDefaultParams (Cbs0_Par_t *pPars)
 FUNCTION DEFINITIONS ///.
 
Cbs0_Man_tCbs0_ManAlloc ()
 
void Cbs0_ManStop (Cbs0_Man_t *p)
 
Vec_Int_tCbs0_ReadModel (Cbs0_Man_t *p)
 
int Cbs0_ManPropagate (Cbs0_Man_t *p)
 
int Cbs0_ManSolve_rec (Cbs0_Man_t *p)
 
int Cbs0_ManSolve (Cbs0_Man_t *p, Gia_Obj_t *pObj)
 
void Cbs0_ManSatPrintStats (Cbs0_Man_t *p)
 
Vec_Int_tCbs_ManSolveMiter (Gia_Man_t *pAig, int nConfs, Vec_Str_t **pvStatus, int fVerbose)
 

Macro Definition Documentation

◆ Cbs0_QueForEachEntry

#define Cbs0_QueForEachEntry ( Que,
pObj,
i )
Value:
for ( i = (Que).iHead; (i < (Que).iTail) && ((pObj) = (Que).pData[i]); i++ )

Definition at line 91 of file giaCSatOld.c.

91#define Cbs0_QueForEachEntry( Que, pObj, i ) \
92 for ( i = (Que).iHead; (i < (Que).iTail) && ((pObj) = (Que).pData[i]); i++ )

Typedef Documentation

◆ Cbs0_Man_t

typedef struct Cbs0_Man_t_ Cbs0_Man_t

Definition at line 58 of file giaCSatOld.c.

◆ Cbs0_Par_t

typedef typedefABC_NAMESPACE_IMPL_START struct Cbs0_Par_t_ Cbs0_Par_t

DECLARATIONS ///.

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

FileName [giaCSat.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [A simple circuit-based solver.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 30 of file giaCSatOld.c.

◆ Cbs0_Que_t

typedef struct Cbs0_Que_t_ Cbs0_Que_t

Definition at line 49 of file giaCSatOld.c.

Function Documentation

◆ Cbs0_ManAlloc()

Cbs0_Man_t * Cbs0_ManAlloc ( )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 131 of file giaCSatOld.c.

132{
133 Cbs0_Man_t * p;
134 p = ABC_CALLOC( Cbs0_Man_t, 1 );
135 p->pProp.nSize = p->pJust.nSize = 10000;
136 p->pProp.pData = ABC_ALLOC( Gia_Obj_t *, p->pProp.nSize );
137 p->pJust.pData = ABC_ALLOC( Gia_Obj_t *, p->pJust.nSize );
138 p->vModel = Vec_IntAlloc( 1000 );
139 Cbs0_SetDefaultParams( &p->Pars );
140 return p;
141}
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
Cube * p
Definition exorList.c:222
void Cbs0_SetDefaultParams(Cbs0_Par_t *pPars)
FUNCTION DEFINITIONS ///.
Definition giaCSatOld.c:109
struct Cbs0_Man_t_ Cbs0_Man_t
Definition giaCSatOld.c:58
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cbs0_ManPropagate()

int Cbs0_ManPropagate ( Cbs0_Man_t * p)

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

Synopsis [Propagates all variables.]

Description [Returns 1 if conflict; 0 if no conflict.]

SideEffects []

SeeAlso []

Definition at line 548 of file giaCSatOld.c.

549{
550 Gia_Obj_t * pVar;
551 int i, k;
552 while ( 1 )
553 {
554 Cbs0_QueForEachEntry( p->pProp, pVar, i )
555 {
556 if ( Cbs0_ManPropagateOne( p, pVar ) )
557 return 1;
558 }
559 p->pProp.iHead = p->pProp.iTail;
560 k = p->pJust.iHead;
561 Cbs0_QueForEachEntry( p->pJust, pVar, i )
562 {
563 if ( Cbs0_VarIsJust( pVar ) )
564 p->pJust.pData[k++] = pVar;
565 else if ( Cbs0_ManPropagateTwo( p, pVar ) )
566 return 1;
567 }
568 if ( k == p->pJust.iTail )
569 break;
570 p->pJust.iTail = k;
571 }
572 return 0;
573}
#define Cbs0_QueForEachEntry(Que, pObj, i)
Definition giaCSatOld.c:91
Here is the caller graph for this function:

◆ Cbs0_ManSatPrintStats()

void Cbs0_ManSatPrintStats ( Cbs0_Man_t * p)

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

Synopsis [Prints statistics of the manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 678 of file giaCSatOld.c.

679{
680 printf( "CO = %8d ", Gia_ManCoNum(p->pAig) );
681 printf( "AND = %8d ", Gia_ManAndNum(p->pAig) );
682 printf( "Conf = %6d ", p->Pars.nBTLimit );
683 printf( "JustMax = %5d ", p->Pars.nJustLimit );
684 printf( "\n" );
685 printf( "Unsat calls %6d (%6.2f %%) Ave conf = %8.1f ",
686 p->nSatUnsat, p->nSatTotal? 100.0*p->nSatUnsat/p->nSatTotal :0.0, p->nSatUnsat? 1.0*p->nConfUnsat/p->nSatUnsat :0.0 );
687 ABC_PRTP( "Time", p->timeSatUnsat, p->timeTotal );
688 printf( "Sat calls %6d (%6.2f %%) Ave conf = %8.1f ",
689 p->nSatSat, p->nSatTotal? 100.0*p->nSatSat/p->nSatTotal :0.0, p->nSatSat? 1.0*p->nConfSat/p->nSatSat : 0.0 );
690 ABC_PRTP( "Time", p->timeSatSat, p->timeTotal );
691 printf( "Undef calls %6d (%6.2f %%) Ave conf = %8.1f ",
692 p->nSatUndec, p->nSatTotal? 100.0*p->nSatUndec/p->nSatTotal :0.0, p->nSatUndec? 1.0*p->nConfUndec/p->nSatUndec : 0.0 );
693 ABC_PRTP( "Time", p->timeSatUndec, p->timeTotal );
694 ABC_PRT( "Total time", p->timeTotal );
695}
#define ABC_PRT(a, t)
Definition abc_global.h:255
#define ABC_PRTP(a, t, T)
Definition abc_global.h:258
Here is the caller graph for this function:

◆ Cbs0_ManSolve()

int Cbs0_ManSolve ( Cbs0_Man_t * p,
Gia_Obj_t * pObj )

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

Synopsis [Looking for a satisfying assignment of the node.]

Description [Assumes that each node has flag pObj->fMark0 set to 0. Returns 1 if unsatisfiable, 0 if satisfiable, and -1 if undecided. The node may be complemented. ]

SideEffects []

SeeAlso []

Definition at line 646 of file giaCSatOld.c.

647{
648 int RetValue;
649 assert( !p->pProp.iHead && !p->pProp.iTail );
650 assert( !p->pJust.iHead && !p->pJust.iTail );
651 p->Pars.nBTThis = p->Pars.nJustThis = 0;
652 Cbs0_ManAssign( p, pObj );
653 RetValue = Cbs0_ManSolve_rec( p );
654 if ( RetValue == 0 && !Cbs0_ManCheckLimits(p) )
655 Cbs0_ManSaveModel( p, p->vModel );
656 Cbs0_ManCancelUntil( p, 0 );
657 p->pJust.iHead = p->pJust.iTail = 0;
658 p->Pars.nBTTotal += p->Pars.nBTThis;
659 p->Pars.nJustTotal = Abc_MaxInt( p->Pars.nJustTotal, p->Pars.nJustThis );
660 if ( Cbs0_ManCheckLimits( p ) )
661 RetValue = -1;
662// printf( "Outcome = %2d. Confs = %6d. Decision level max = %3d.\n",
663// RetValue, p->Pars.nBTThis, p->DecLevelMax );
664 return RetValue;
665}
int Cbs0_ManSolve_rec(Cbs0_Man_t *p)
Definition giaCSatOld.c:586
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cbs0_ManSolve_rec()

int Cbs0_ManSolve_rec ( Cbs0_Man_t * p)

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

Synopsis [Solve the problem recursively.]

Description [Returns 1 if unsat or undecided; 0 if satisfiable.]

SideEffects []

SeeAlso []

Definition at line 586 of file giaCSatOld.c.

587{
588 Gia_Obj_t * pVar = NULL, * pDecVar;
589 int iPropHead, iJustHead, iJustTail;
590 // propagate assignments
591 assert( !Cbs0_QueIsEmpty(&p->pProp) );
592 if ( Cbs0_ManPropagate( p ) )
593 return 1;
594 // check for satisfying assignment
595 assert( Cbs0_QueIsEmpty(&p->pProp) );
596 if ( Cbs0_QueIsEmpty(&p->pJust) )
597 return 0;
598 // quit using resource limits
599 p->Pars.nJustThis = Abc_MaxInt( p->Pars.nJustThis, p->pJust.iTail - p->pJust.iHead );
600 if ( Cbs0_ManCheckLimits( p ) )
601 return 0;
602 // remember the state before branching
603 iPropHead = p->pProp.iHead;
604 Cbs0_QueStore( &p->pJust, &iJustHead, &iJustTail );
605 // find the decision variable
606 if ( p->Pars.fUseHighest )
607 pVar = Cbs0_ManDecideHighest( p );
608 else if ( p->Pars.fUseLowest )
609 pVar = Cbs0_ManDecideLowest( p );
610 else if ( p->Pars.fUseMaxFF )
611 pVar = Cbs0_ManDecideMaxFF( p );
612 else assert( 0 );
613 assert( Cbs0_VarIsJust( pVar ) );
614 // chose decision variable using fanout count
615 if ( Gia_ObjRefNum(p->pAig, Gia_ObjFanin0(pVar)) > Gia_ObjRefNum(p->pAig, Gia_ObjFanin1(pVar)) )
616 pDecVar = Gia_Not(Gia_ObjChild0(pVar));
617 else
618 pDecVar = Gia_Not(Gia_ObjChild1(pVar));
619 // decide on first fanin
620 Cbs0_ManAssign( p, pDecVar );
621 if ( !Cbs0_ManSolve_rec( p ) )
622 return 0;
623 Cbs0_ManCancelUntil( p, iPropHead );
624 Cbs0_QueRestore( &p->pJust, iJustHead, iJustTail );
625 // decide on second fanin
626 Cbs0_ManAssign( p, Gia_Not(pDecVar) );
627 if ( !Cbs0_ManSolve_rec( p ) )
628 return 0;
629 p->Pars.nBTThis++;
630 return 1;
631}
int Cbs0_ManPropagate(Cbs0_Man_t *p)
Definition giaCSatOld.c:548
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cbs0_ManStop()

void Cbs0_ManStop ( Cbs0_Man_t * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 154 of file giaCSatOld.c.

155{
156 Vec_IntFree( p->vModel );
157 ABC_FREE( p->pProp.pData );
158 ABC_FREE( p->pJust.pData );
159 ABC_FREE( p );
160}
#define ABC_FREE(obj)
Definition abc_global.h:267
Here is the caller graph for this function:

◆ Cbs0_ReadModel()

Vec_Int_t * Cbs0_ReadModel ( Cbs0_Man_t * p)

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

Synopsis [Returns satisfying assignment.]

Description []

SideEffects []

SeeAlso []

Definition at line 173 of file giaCSatOld.c.

174{
175 return p->vModel;
176}
Here is the caller graph for this function:

◆ Cbs0_SetDefaultParams()

void Cbs0_SetDefaultParams ( Cbs0_Par_t * pPars)

FUNCTION DEFINITIONS ///.

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

Synopsis [Sets default values of the parameters.]

Description []

SideEffects []

SeeAlso []

Definition at line 109 of file giaCSatOld.c.

110{
111 memset( pPars, 0, sizeof(Cbs0_Par_t) );
112 pPars->nBTLimit = 1000; // limit on the number of conflicts
113 pPars->nJustLimit = 100; // limit on the size of justification queue
114 pPars->fUseHighest = 1; // use node with the highest ID
115 pPars->fUseLowest = 0; // use node with the highest ID
116 pPars->fUseMaxFF = 0; // use node with the largest fanin fanout
117 pPars->fVerbose = 1; // print detailed statistics
118}
typedefABC_NAMESPACE_IMPL_START struct Cbs0_Par_t_ Cbs0_Par_t
DECLARATIONS ///.
Definition giaCSatOld.c:30
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Cbs_ManSolveMiter()

Vec_Int_t * Cbs_ManSolveMiter ( Gia_Man_t * pAig,
int nConfs,
Vec_Str_t ** pvStatus,
int fVerbose )

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

Synopsis [Procedure to test the new SAT solver.]

Description []

SideEffects []

SeeAlso []

Definition at line 708 of file giaCSatOld.c.

709{
710 extern void Cec_ManSatAddToStore( Vec_Int_t * vCexStore, Vec_Int_t * vCex, int Out );
711 Cbs0_Man_t * p;
712 Vec_Int_t * vCex, * vVisit, * vCexStore;
713 Vec_Str_t * vStatus;
714 Gia_Obj_t * pRoot;
715 int i, status;
716 abctime clk, clkTotal = Abc_Clock();
717 assert( Gia_ManRegNum(pAig) == 0 );
718 // prepare AIG
719 Gia_ManCreateRefs( pAig );
720 Gia_ManCleanMark0( pAig );
721 Gia_ManCleanMark1( pAig );
722 // create logic network
723 p = Cbs0_ManAlloc();
724 p->Pars.nBTLimit = nConfs;
725 p->pAig = pAig;
726 // create resulting data-structures
727 vStatus = Vec_StrAlloc( Gia_ManPoNum(pAig) );
728 vCexStore = Vec_IntAlloc( 10000 );
729 vVisit = Vec_IntAlloc( 100 );
730 vCex = Cbs0_ReadModel( p );
731 // solve for each output
732 Gia_ManForEachCo( pAig, pRoot, i )
733 {
734 Vec_IntClear( vCex );
735 if ( Gia_ObjIsConst0(Gia_ObjFanin0(pRoot)) )
736 {
737 if ( Gia_ObjFaninC0(pRoot) )
738 {
739 printf( "Constant 1 output of SRM!!!\n" );
740 Cec_ManSatAddToStore( vCexStore, vCex, i ); // trivial counter-example
741 Vec_StrPush( vStatus, 0 );
742 }
743 else
744 {
745// printf( "Constant 0 output of SRM!!!\n" );
746 Vec_StrPush( vStatus, 1 );
747 }
748 continue;
749 }
750 clk = Abc_Clock();
751 p->Pars.fUseHighest = 1;
752 p->Pars.fUseLowest = 0;
753 status = Cbs0_ManSolve( p, Gia_ObjChild0(pRoot) );
754/*
755 if ( status == -1 )
756 {
757 p->Pars.fUseHighest = 0;
758 p->Pars.fUseLowest = 1;
759 status = Cbs0_ManSolve( p, Gia_ObjChild0(pRoot) );
760 }
761*/
762 Vec_StrPush( vStatus, (char)status );
763 if ( status == -1 )
764 {
765 p->nSatUndec++;
766 p->nConfUndec += p->Pars.nBTThis;
767 Cec_ManSatAddToStore( vCexStore, NULL, i ); // timeout
768 p->timeSatUndec += Abc_Clock() - clk;
769 continue;
770 }
771 if ( status == 1 )
772 {
773 p->nSatUnsat++;
774 p->nConfUnsat += p->Pars.nBTThis;
775 p->timeSatUnsat += Abc_Clock() - clk;
776 continue;
777 }
778 p->nSatSat++;
779 p->nConfSat += p->Pars.nBTThis;
780// Gia_SatVerifyPattern( pAig, pRoot, vCex, vVisit );
781 Cec_ManSatAddToStore( vCexStore, vCex, i );
782 p->timeSatSat += Abc_Clock() - clk;
783 }
784 Vec_IntFree( vVisit );
785 p->nSatTotal = Gia_ManPoNum(pAig);
786 p->timeTotal = Abc_Clock() - clkTotal;
787 if ( fVerbose )
789 Cbs0_ManStop( p );
790 *pvStatus = vStatus;
791// printf( "Total number of cex literals = %d. (Ave = %d)\n",
792// Vec_IntSize(vCexStore)-2*p->nSatUndec-2*p->nSatSat,
793// (Vec_IntSize(vCexStore)-2*p->nSatUndec-2*p->nSatSat)/p->nSatSat );
794 return vCexStore;
795}
ABC_INT64_T abctime
Definition abc_global.h:332
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
struct Vec_Str_t_ Vec_Str_t
Definition bblif.c:46
void Cec_ManSatAddToStore(Vec_Int_t *vCexStore, Vec_Int_t *vCex, int Out)
Definition cecSolve.c:996
int Cbs0_ManSolve(Cbs0_Man_t *p, Gia_Obj_t *pObj)
Definition giaCSatOld.c:646
void Cbs0_ManStop(Cbs0_Man_t *p)
Definition giaCSatOld.c:154
Vec_Int_t * Cbs0_ReadModel(Cbs0_Man_t *p)
Definition giaCSatOld.c:173
void Cbs0_ManSatPrintStats(Cbs0_Man_t *p)
Definition giaCSatOld.c:678
Cbs0_Man_t * Cbs0_ManAlloc()
Definition giaCSatOld.c:131
void Gia_ManCleanMark0(Gia_Man_t *p)
Definition giaUtil.c:256
void Gia_ManCreateRefs(Gia_Man_t *p)
Definition giaUtil.c:779
#define Gia_ManForEachCo(p, pObj, i)
Definition gia.h:1236
void Gia_ManCleanMark1(Gia_Man_t *p)
Definition giaUtil.c:313
Here is the call graph for this function: