ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
sscUtil.c File Reference
#include "sscInt.h"
#include "sat/cnf/cnf.h"
#include "aig/gia/giaAig.h"
Include dependency graph for sscUtil.c:

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START Gia_Man_tGia_ManDropContained (Gia_Man_t *p)
 DECLARATIONS ///.
 
Gia_Man_tGia_ManOptimizeRing (Gia_Man_t *p)
 

Function Documentation

◆ Gia_ManDropContained()

ABC_NAMESPACE_IMPL_START Gia_Man_t * Gia_ManDropContained ( Gia_Man_t * p)

DECLARATIONS ///.

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

FileName [sscUtil.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [SAT sweeping under constraints.]

Synopsis [Various utilities.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 29, 2008.]

Revision [

Id
sscUtil.c,v 1.00 2008/07/29 00:00:00 alanmi Exp

] FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file sscUtil.c.

48{
49 Gia_Man_t * pNew;
50 Aig_Man_t * pMan = Gia_ManToAigSimple( p );
51 Cnf_Dat_t * pDat = Cnf_Derive( pMan, Gia_ManPoNum(p) );
52 Gia_Obj_t * pObj;
53 Vec_Int_t * vLits, * vKeep;
54 sat_solver * pSat;
55 int ConstLit = Abc_Var2Lit(pDat->pVarNums[0], 0);
56 int i, status;//, Count = 0;
57 Aig_ManStop( pMan );
58
59 vLits = Vec_IntAlloc( Gia_ManPoNum(p) );
60 Gia_ManForEachPo( p, pObj, i )
61 {
62 int iObj = Gia_ObjId( p, pObj );
63 Vec_IntPush( vLits, Abc_Var2Lit(pDat->pVarNums[iObj], 1) );
64 }
65
66 // start the SAT solver
67 pSat = sat_solver_new();
68 sat_solver_setnvars( pSat, pDat->nVars );
69 for ( i = 0; i < pDat->nClauses; i++ )
70 {
71 if ( !sat_solver_addclause( pSat, pDat->pClauses[i], pDat->pClauses[i+1] ) )
72 {
73 Cnf_DataFree( pDat );
74 sat_solver_delete( pSat );
75 Vec_IntFree( vLits );
76 return NULL;
77 }
78 }
79 Cnf_DataFree( pDat );
80 status = sat_solver_simplify( pSat );
81 if ( status == 0 )
82 {
83 sat_solver_delete( pSat );
84 Vec_IntFree( vLits );
85 return NULL;
86 }
87
88 // iterate over POs
89 vKeep = Vec_IntAlloc( Gia_ManPoNum(p) );
90 Gia_ManForEachPo( p, pObj, i )
91 {
92 Vec_IntWriteEntry( vLits, i, Abc_LitNot(Vec_IntEntry(vLits,i)) );
93 status = sat_solver_solve( pSat, Vec_IntArray(vLits), Vec_IntArray(vLits) + Vec_IntSize(vLits), 0, 0, 0, 0 );
94 Vec_IntWriteEntry( vLits, i, Abc_LitNot(Vec_IntEntry(vLits,i)) );
95 if ( status == l_False )
96 Vec_IntWriteEntry( vLits, i, ConstLit ); // const1 SAT var is always true
97 else
98 {
99 assert( status == l_True );
100 Vec_IntPush( vKeep, i );
101 }
102 }
103 sat_solver_delete( pSat );
104 Vec_IntFree( vLits );
105 if ( Vec_IntSize(vKeep) == Gia_ManPoNum(p) )
106 {
107 Vec_IntFree( vKeep );
108 return Gia_ManDup(p);
109 }
110 pNew = Gia_ManDupCones( p, Vec_IntArray(vKeep), Vec_IntSize(vKeep), 0 );
111 Vec_IntFree( vKeep );
112 return pNew;
113}
void Aig_ManStop(Aig_Man_t *p)
Definition aigMan.c:187
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition aig.h:50
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
#define l_True
Definition bmcBmcS.c:35
#define l_False
Definition bmcBmcS.c:36
#define sat_solver_addclause
Definition cecSatG2.c:37
#define sat_solver
Definition cecSatG2.c:34
#define sat_solver_solve
Definition cecSatG2.c:45
Cnf_Dat_t * Cnf_Derive(Aig_Man_t *pAig, int nOutputs)
Definition cnfCore.c:165
struct Cnf_Dat_t_ Cnf_Dat_t
Definition cnf.h:52
void Cnf_DataFree(Cnf_Dat_t *p)
Definition cnfMan.c:207
Cube * p
Definition exorList.c:222
Aig_Man_t * Gia_ManToAigSimple(Gia_Man_t *p)
Definition giaAig.c:408
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
Definition giaDup.c:720
#define Gia_ManForEachPo(p, pObj, i)
Definition gia.h:1250
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
struct Gia_Man_t_ Gia_Man_t
Definition gia.h:96
Gia_Man_t * Gia_ManDupCones(Gia_Man_t *p, int *pPos, int nPos, int fTrimPis)
Definition giaDup.c:3880
sat_solver * sat_solver_new(void)
Definition satSolver.c:1137
int sat_solver_simplify(sat_solver *s)
Definition satSolver.c:1515
void sat_solver_setnvars(sat_solver *s, int n)
Definition satSolver.c:1272
void sat_solver_delete(sat_solver *s)
Definition satSolver.c:1341
int nVars
Definition cnf.h:59
int * pVarNums
Definition cnf.h:63
int ** pClauses
Definition cnf.h:62
int nClauses
Definition cnf.h:61
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Gia_ManOptimizeRing()

Gia_Man_t * Gia_ManOptimizeRing ( Gia_Man_t * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 126 of file sscUtil.c.

127{
128 Ssc_Pars_t Pars, * pPars = &Pars;
129 Gia_Man_t * pTemp, * pAux;
130 int i;
131 assert( p->nConstrs == 0 );
132 printf( "User AIG: " );
133 Gia_ManPrintStats( p, NULL );
134 pTemp = Gia_ManDropContained( p );
135 printf( "Drop AIG: " );
136 Gia_ManPrintStats( pTemp, NULL );
137// return pTemp;
138 if ( Gia_ManPoNum(pTemp) == 1 )
139 return pTemp;
141 pPars->fAppend = 1;
142 pPars->fVerbose = 0;
143 pTemp->nConstrs = Gia_ManPoNum(pTemp) - 1;
144 for ( i = 0; i < Gia_ManPoNum(pTemp); i++ )
145 {
146 // move i-th PO forward
147 Gia_ManSwapPos( pTemp, i );
148 pTemp = Gia_ManDupDfs( pAux = pTemp );
149 Gia_ManStop( pAux );
150 // minimize this PO
151 pTemp = Ssc_PerformSweepingConstr( pAux = pTemp, pPars );
152 Gia_ManStop( pAux );
153 pTemp = Gia_ManDupDfs( pAux = pTemp );
154 Gia_ManStop( pAux );
155 // move i-th PO back
156 Gia_ManSwapPos( pTemp, i );
157 pTemp = Gia_ManDupDfs( pAux = pTemp );
158 Gia_ManStop( pAux );
159 // report results
160 printf( "AIG%3d : ", i );
161 Gia_ManPrintStats( pTemp, NULL );
162 }
163 pTemp->nConstrs = 0;
164 return pTemp;
165}
void Gia_ManStop(Gia_Man_t *p)
Definition giaMan.c:82
void Gia_ManSwapPos(Gia_Man_t *p, int i)
Definition giaUtil.c:1808
Gia_Man_t * Gia_ManDupDfs(Gia_Man_t *p)
Definition giaDup.c:1748
void Gia_ManPrintStats(Gia_Man_t *p, Gps_Par_t *pPars)
Definition giaMan.c:495
ABC_NAMESPACE_IMPL_START Gia_Man_t * Gia_ManDropContained(Gia_Man_t *p)
DECLARATIONS ///.
Definition sscUtil.c:47
typedefABC_NAMESPACE_HEADER_START struct Ssc_Pars_t_ Ssc_Pars_t
INCLUDES ///.
Definition ssc.h:43
Gia_Man_t * Ssc_PerformSweepingConstr(Gia_Man_t *p, Ssc_Pars_t *pPars)
Definition sscCore.c:420
void Ssc_ManSetDefaultParams(Ssc_Pars_t *p)
MACRO DEFINITIONS ///.
Definition sscCore.c:46
int nConstrs
Definition gia.h:122
Here is the call graph for this function: