ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
giaSatEdge.c File Reference
#include "gia.h"
#include "misc/tim/tim.h"
#include "sat/bsat/satStore.h"
Include dependency graph for giaSatEdge.c:

Go to the source code of this file.

Classes

struct  Seg_Man_t_
 

Typedefs

typedef typedefABC_NAMESPACE_IMPL_START struct Seg_Man_t_ Seg_Man_t
 DECLARATIONS ///.
 

Functions

sat_solverSbm_AddCardinSolver (int LogN, Vec_Int_t **pvVars)
 
Vec_Int_tSeg_ManCountIntEdges (Gia_Man_t *p, Vec_Int_t *vPolars, Vec_Int_t *vToSkip, int nFanouts)
 FUNCTION DEFINITIONS ///.
 
Vec_Wec_tSeg_ManCollectObjEdges (Vec_Int_t *vEdges, int nObjs)
 
int Seg_ManCountIntLevels (Seg_Man_t *p, int iStartVar)
 
Seg_Man_tSeg_ManAlloc (Gia_Man_t *pGia, int nFanouts)
 
void Seg_ManClean (Seg_Man_t *p)
 
void Seg_ManStop (Seg_Man_t *p)
 
void Seg_ManCreateCnf (Seg_Man_t *p, int fTwo, int fVerbose)
 
Vec_Int_tSeg_ManConvertResult (Seg_Man_t *p)
 
void Seg_ManComputeDelay (Gia_Man_t *pGia, int DelayInit, int nFanouts, int fTwo, int fVerbose)
 

Typedef Documentation

◆ Seg_Man_t

typedef typedefABC_NAMESPACE_IMPL_START struct Seg_Man_t_ Seg_Man_t

DECLARATIONS ///.

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

FileName [giaSatEdge.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis []

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]

Definition at line 32 of file giaSatEdge.c.

Function Documentation

◆ Sbm_AddCardinSolver()

sat_solver * Sbm_AddCardinSolver ( int LogN,
Vec_Int_t ** pvVars )
extern

Definition at line 456 of file giaSatMap.c.

457{
458 int nVars = 1 << LogN;
459 int nVarsAlloc = nVars + 2 * (nVars * LogN * (LogN-1) / 4 + nVars - 1), nVarsReal;
460 Vec_Int_t * vVars = Vec_IntStartNatural( nVars );
461 sat_solver * pSat = sat_solver_new();
462 sat_solver_setnvars( pSat, nVarsAlloc );
463 nVarsReal = Sbm_AddCardinConstrPairWise( pSat, vVars, 2 );
464 assert( nVarsReal == nVarsAlloc );
465 *pvVars = vVars;
466 return pSat;
467}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
#define sat_solver
Definition cecSatG2.c:34
int Sbm_AddCardinConstrPairWise(sat_solver *p, Vec_Int_t *vVars, int K)
Definition giaSatMap.c:449
sat_solver * sat_solver_new(void)
Definition satSolver.c:1137
void sat_solver_setnvars(sat_solver *s, int n)
Definition satSolver.c:1272
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ Seg_ManAlloc()

Seg_Man_t * Seg_ManAlloc ( Gia_Man_t * pGia,
int nFanouts )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 155 of file giaSatEdge.c.

156{
157 int nVarsAll;
159 p->vPolars = Vec_IntAlloc( 1000 );
160 p->vToSkip = Vec_IntAlloc( 1000 );
161 p->vEdges = Seg_ManCountIntEdges( pGia, p->vPolars, p->vToSkip, nFanouts );
162 p->nVars = Vec_IntSize(p->vEdges)/2;
163 p->LogN = Abc_Base2Log(p->nVars);
164 p->Power2 = 1 << p->LogN;
165 //p->pSat = Sbm_AddCardinSolver( p->LogN, &p->vCardVars );
166 p->pSat = sat_solver_new();
167 sat_solver_setnvars( p->pSat, p->nVars );
168 p->FirstVar = sat_solver_nvars( p->pSat );
169 sat_solver_bookmark( p->pSat );
170 p->pGia = pGia;
171 // internal
172 p->vFirsts = Vec_IntAlloc( 0 );
173 p->vNvars = Vec_IntAlloc( 0 );
174 p->vLits = Vec_IntAlloc( 0 );
175 nVarsAll = Seg_ManCountIntLevels( p, p->FirstVar );
176 sat_solver_setnvars( p->pSat, nVarsAll );
177 // other
178 Gia_ManFillValue( pGia );
179 return p;
180}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
Cube * p
Definition exorList.c:222
Vec_Int_t * Seg_ManCountIntEdges(Gia_Man_t *p, Vec_Int_t *vPolars, Vec_Int_t *vToSkip, int nFanouts)
FUNCTION DEFINITIONS ///.
Definition giaSatEdge.c:79
typedefABC_NAMESPACE_IMPL_START struct Seg_Man_t_ Seg_Man_t
DECLARATIONS ///.
Definition giaSatEdge.c:32
int Seg_ManCountIntLevels(Seg_Man_t *p, int iStartVar)
Definition giaSatEdge.c:113
void Gia_ManFillValue(Gia_Man_t *p)
Definition giaUtil.c:369
int sat_solver_nvars(sat_solver *s)
Definition satSolver.c:2369
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Seg_ManClean()

void Seg_ManClean ( Seg_Man_t * p)

Definition at line 181 of file giaSatEdge.c.

182{
183 p->timeStart = Abc_Clock();
184 sat_solver_rollback( p->pSat );
185 sat_solver_bookmark( p->pSat );
186 // internal
187 Vec_IntClear( p->vEdges );
188 Vec_IntClear( p->vFirsts );
189 Vec_IntClear( p->vNvars );
190 Vec_IntClear( p->vLits );
191 Vec_IntClear( p->vPolars );
192 Vec_IntClear( p->vToSkip );
193 // other
194 Gia_ManFillValue( p->pGia );
195}
void sat_solver_rollback(sat_solver *s)
Definition satSolver.c:1643
Here is the call graph for this function:

◆ Seg_ManCollectObjEdges()

Vec_Wec_t * Seg_ManCollectObjEdges ( Vec_Int_t * vEdges,
int nObjs )

Definition at line 102 of file giaSatEdge.c.

103{
104 int iFanin, iObj, i;
105 Vec_Wec_t * vRes = Vec_WecStart( nObjs );
106 Vec_IntForEachEntryDouble( vEdges, iFanin, iObj, i )
107 {
108 Vec_WecPush( vRes, iFanin, i/2 );
109 Vec_WecPush( vRes, iObj, i/2 );
110 }
111 return vRes;
112}
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition vecInt.h:72
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition vecWec.h:42
Here is the caller graph for this function:

◆ Seg_ManComputeDelay()

void Seg_ManComputeDelay ( Gia_Man_t * pGia,
int DelayInit,
int nFanouts,
int fTwo,
int fVerbose )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 439 of file giaSatEdge.c.

440{
441 int nBTLimit = 0;
442 int nTimeOut = 0;
443 int fVeryVerbose = 0;
444
445 Gia_Obj_t * pObj;
446 abctime clk = Abc_Clock();
447 Vec_Int_t * vEdges2 = NULL;
448 int i, iLut, iFirst, nVars, status, Delay, nConfs;
449 Seg_Man_t * p = Seg_ManAlloc( pGia, nFanouts );
450 int DelayStart = DelayInit ? DelayInit : p->DelayMax;
451
452 if ( fVerbose )
453 printf( "Running SatEdge with starting delay %d and edge %d (edge vars %d, total vars %d)\n",
454 DelayStart, fTwo+1, p->FirstVar, sat_solver_nvars(p->pSat) );
455 Seg_ManCreateCnf( p, fTwo, fVerbose );
456 //Sat_SolverWriteDimacs( p->pSat, "test_edge.cnf", NULL, NULL, 0 );
457 // set resource limits
458 sat_solver_set_resource_limits( p->pSat, nBTLimit, 0, 0, 0 );
459 sat_solver_set_runtime_limit( p->pSat, nTimeOut ? nTimeOut * CLOCKS_PER_SEC + Abc_Clock(): 0 );
460 sat_solver_set_random( p->pSat, 1 );
461 sat_solver_set_polarity( p->pSat, Vec_IntArray(p->vPolars), Vec_IntSize(p->vPolars) );
462 //sat_solver_set_var_activity( p->pSat, NULL, p->nVars );
463 // increment delay gradually
464 for ( Delay = p->DelayMax; Delay >= 0; Delay-- )
465 {
466 // we constrain COs, although it would be fine to constrain only POs
467 Gia_ManForEachCoDriver( p->pGia, pObj, i )
468 {
469 iLut = Gia_ObjId( p->pGia, pObj );
470 iFirst = Vec_IntEntry( p->vFirsts, iLut );
471 nVars = Vec_IntEntry( p->vNvars, iLut );
472 if ( Delay < nVars && !sat_solver_push(p->pSat, Abc_Var2Lit(iFirst + Delay, 1)) )
473 break;
474 }
475 if ( i < Gia_ManCoNum(p->pGia) )
476 {
477 printf( "Proved UNSAT for delay %d. ", Delay );
478 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
479 break;
480 }
481 if ( Delay > DelayStart )
482 continue;
483 // solve with assumptions
484 //clk = Abc_Clock();
485 nConfs = sat_solver_nconflicts( p->pSat );
486 status = sat_solver_solve_internal( p->pSat );
487 nConfs = sat_solver_nconflicts( p->pSat ) - nConfs;
488 if ( status == l_True )
489 {
490 if ( fVerbose )
491 {
492 int Count = 0;
493 for ( i = 0; i < p->nVars; i++ )
494 Count += sat_solver_var_value(p->pSat, i);
495 printf( "Solution with delay %2d and %5d edges exists. Conf = %8d. ", Delay, Count, nConfs );
496 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
497 }
498 // save the result
499 Vec_IntFreeP( &vEdges2 );
500 vEdges2 = Seg_ManConvertResult( p );
501 if ( fVeryVerbose )
502 {
503 for ( i = 0; i < p->nVars; i++ )
504 printf( "%d=%d ", i, sat_solver_var_value(p->pSat, i) );
505 printf( " " );
506
507 for ( i = p->nVars; i < sat_solver_nvars(p->pSat); i++ )
508 printf( "%d=%d ", i, sat_solver_var_value(p->pSat, i) );
509 printf( "\n" );
510 }
511 }
512 else
513 {
514 if ( fVerbose )
515 {
516 if ( status == l_False )
517 printf( "Proved UNSAT for delay %d. ", Delay );
518 else
519 printf( "Resource limit reached for delay %d. ", Delay );
520 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
521 }
522 break;
523 }
524 }
525 Gia_ManEdgeFromArray( p->pGia, vEdges2 );
526 Vec_IntFreeP( &vEdges2 );
527 Seg_ManStop( p );
528}
ABC_INT64_T abctime
Definition abc_global.h:332
#define l_True
Definition bmcBmcS.c:35
#define l_False
Definition bmcBmcS.c:36
Vec_Int_t * Seg_ManConvertResult(Seg_Man_t *p)
Definition giaSatEdge.c:418
Seg_Man_t * Seg_ManAlloc(Gia_Man_t *pGia, int nFanouts)
Definition giaSatEdge.c:155
void Seg_ManCreateCnf(Seg_Man_t *p, int fTwo, int fVerbose)
Definition giaSatEdge.c:223
void Seg_ManStop(Seg_Man_t *p)
Definition giaSatEdge.c:196
struct Gia_Obj_t_ Gia_Obj_t
Definition gia.h:76
void Gia_ManEdgeFromArray(Gia_Man_t *p, Vec_Int_t *vArray)
FUNCTION DEFINITIONS ///.
Definition giaEdge.c:72
#define Gia_ManForEachCoDriver(p, pObj, i)
Definition gia.h:1244
int sat_solver_solve_internal(sat_solver *s)
Definition satSolver.c:1942
int sat_solver_nconflicts(sat_solver *s)
Definition satSolver.c:2381
int sat_solver_push(sat_solver *s, int p)
Definition satSolver.c:2002
void sat_solver_set_resource_limits(sat_solver *s, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
Definition satSolver.c:2051
Here is the call graph for this function:

◆ Seg_ManConvertResult()

Vec_Int_t * Seg_ManConvertResult ( Seg_Man_t * p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 418 of file giaSatEdge.c.

419{
420 int iFanin, iObj, i;
421 Vec_Int_t * vEdges2 = Vec_IntAlloc( 1000 );
422 Vec_IntForEachEntryDouble( p->vEdges, iFanin, iObj, i )
423 if ( sat_solver_var_value(p->pSat, i/2) )
424 Vec_IntPushTwo( vEdges2, iFanin, iObj );
425 return vEdges2;
426}
Here is the caller graph for this function:

◆ Seg_ManCountIntEdges()

Vec_Int_t * Seg_ManCountIntEdges ( Gia_Man_t * p,
Vec_Int_t * vPolars,
Vec_Int_t * vToSkip,
int nFanouts )

FUNCTION DEFINITIONS ///.

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

Synopsis [Count the number of edges between internal nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 79 of file giaSatEdge.c.

80{
81 int i, iLut, iFanin;
82 Vec_Int_t * vEdges = Vec_IntAlloc( 1000 );
83 assert( Gia_ManHasMapping(p) );
84 Vec_IntClear( vPolars );
85 Vec_IntClear( vToSkip );
86 if ( nFanouts )
88 Gia_ManForEachLut( p, iLut )
89 Gia_LutForEachFanin( p, iLut, iFanin, i )
90 if ( Gia_ObjIsAnd(Gia_ManObj(p, iFanin)) )
91 {
92 if ( p->vEdge1 && Gia_ObjCheckEdge(p, iFanin, iLut) )
93 Vec_IntPush( vPolars, Vec_IntSize(vEdges)/2 );
94 if ( nFanouts && Gia_ObjLutRefNumId(p, iFanin) >= nFanouts )
95 Vec_IntPush( vToSkip, Vec_IntSize(vEdges)/2 );
96 Vec_IntPushTwo( vEdges, iFanin, iLut );
97 }
98 if ( nFanouts )
99 ABC_FREE( p->pLutRefs );
100 return vEdges;
101}
#define ABC_FREE(obj)
Definition abc_global.h:267
#define Gia_ManForEachLut(p, i)
Definition gia.h:1157
#define Gia_LutForEachFanin(p, i, iFan, k)
Definition gia.h:1161
int Gia_ObjCheckEdge(Gia_Man_t *p, int iObj, int iNext)
Definition giaEdge.c:172
void Gia_ManSetLutRefs(Gia_Man_t *p)
Definition giaIf.c:295
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Seg_ManCountIntLevels()

int Seg_ManCountIntLevels ( Seg_Man_t * p,
int iStartVar )

Definition at line 113 of file giaSatEdge.c.

114{
115 Gia_Obj_t * pObj;
116 int iLut, nVars;
117 Vec_IntFill( p->vFirsts, Gia_ManObjNum(p->pGia), -1 );
118 Vec_IntFill( p->vNvars, Gia_ManObjNum(p->pGia), 0 );
119 ABC_FREE( p->pLevels );
120 if ( p->pGia->pManTime )
121 {
122 p->DelayMax = Gia_ManLutLevelWithBoxes( p->pGia );
123 p->pLevels = Vec_IntReleaseArray( p->pGia->vLevels );
124 Vec_IntFreeP( &p->pGia->vLevels );
125 }
126 else
127 p->DelayMax = Gia_ManLutLevel( p->pGia, &p->pLevels );
128 Gia_ManForEachObj1( p->pGia, pObj, iLut )
129 {
130 if ( Gia_ObjIsCo(pObj) )
131 continue;
132 if ( Gia_ObjIsAnd(pObj) && !Gia_ObjIsLut(p->pGia, iLut) )
133 continue;
134 assert( Gia_ObjIsCi(pObj) || Gia_ObjIsLut(p->pGia, iLut) );
135 Vec_IntWriteEntry( p->vFirsts, iLut, iStartVar );
136 //assert( p->pLevels[iLut] > 0 );
137 nVars = p->pLevels[iLut] < 2 ? 0 : p->pLevels[iLut];
138 Vec_IntWriteEntry( p->vNvars, iLut, nVars );
139 iStartVar += nVars;
140 }
141 return iStartVar;
142}
int Gia_ManLutLevel(Gia_Man_t *p, int **ppLevels)
Definition giaIf.c:165
#define Gia_ManForEachObj1(p, pObj, i)
Definition gia.h:1192
int Gia_ManLutLevelWithBoxes(Gia_Man_t *p)
Definition giaTim.c:581
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Seg_ManCreateCnf()

void Seg_ManCreateCnf ( Seg_Man_t * p,
int fTwo,
int fVerbose )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 223 of file giaSatEdge.c.

224{
225 Tim_Man_t * pTim = (Tim_Man_t *)p->pGia->pManTime;
226 Gia_Obj_t * pObj;
227 Vec_Wec_t * vObjEdges;
228 Vec_Int_t * vLevel;
229 int iLut, iFanin, iFirst;
230 int pLits[3], Count = 0;
231 int i, k, nVars, Edge, value;
232 abctime clk = Abc_Clock();
233 // edge delay constraints
234 int nConstr = sat_solver_nclauses(p->pSat);
235 Gia_ManForEachObj( p->pGia, pObj, iLut )
236 {
237 int iFirstLut = Vec_IntEntry( p->vFirsts, iLut );
238 int nVarsLut = Vec_IntEntry( p->vNvars, iLut );
239 if ( pTim && Gia_ObjIsCi(pObj) )
240 {
241 int iBox = Tim_ManBoxForCi( pTim, Gia_ObjCioId(pObj) );
242 if ( nVarsLut > 0 && iBox >= 0 )
243 {
244 int iCiId = Tim_ManBoxOutputFirst( pTim, iBox );
245 if ( iCiId == Gia_ObjCioId(pObj) ) // first input
246 {
247 int nIns = Tim_ManBoxInputNum( pTim, iBox );
248 int iIn0 = Tim_ManBoxInputFirst( pTim, iBox );
249 for ( i = 0; i < nIns-1; i++ ) // skip carry-in pin
250 {
251 Gia_Obj_t * pOut = Gia_ManCo( p->pGia, iIn0+i );
252 int iDriverId = Gia_ObjFaninId0p( p->pGia, pOut );
253 int AddOn;
254
255 iFirst = Vec_IntEntry( p->vFirsts, iDriverId );
256 nVars = Vec_IntEntry( p->vNvars, iDriverId );
257 assert( nVars < nVarsLut );
258 AddOn = (int)(nVars < nVarsLut);
259 for ( k = 0; k < nVars; k++ )
260 {
261 pLits[0] = Abc_Var2Lit( iFirst+k, 1 );
262 pLits[1] = Abc_Var2Lit( iFirstLut+k+AddOn, 0 );
263 value = sat_solver_addclause( p->pSat, pLits, pLits+2 );
264 assert( value );
265 }
266 }
267 }
268 else // intermediate input
269 {
270 Gia_Obj_t * pIn = Gia_ManCi( p->pGia, iCiId );
271 int iObjId = Gia_ObjId( p->pGia, pIn );
272
273 iFirst = Vec_IntEntry( p->vFirsts, iObjId );
274 nVars = Vec_IntEntry( p->vNvars, iObjId );
275 if ( nVars > 0 )
276 {
277 for ( k = 0; k < nVars; k++ )
278 {
279 pLits[0] = Abc_Var2Lit( iFirst+k, 1 );
280 pLits[1] = Abc_Var2Lit( iFirstLut+k, 0 );
281 value = sat_solver_addclause( p->pSat, pLits, pLits+2 );
282 assert( value );
283 }
284 }
285 }
286 }
287 continue;
288 }
289 if ( !Gia_ObjIsLut(p->pGia, iLut) )
290 continue;
291 Gia_LutForEachFanin( p->pGia, iLut, iFanin, i )
292 if ( pTim && Gia_ObjIsCi(Gia_ManObj(p->pGia, iFanin)) )
293 {
294 iFirst = Vec_IntEntry( p->vFirsts, iFanin );
295 nVars = Vec_IntEntry( p->vNvars, iFanin );
296 assert( nVars <= nVarsLut );
297 if ( nVars > 0 )
298 {
299 for ( k = 0; k < nVars; k++ )
300 {
301 pLits[0] = Abc_Var2Lit( iFirst+k, 1 );
302 pLits[1] = Abc_Var2Lit( iFirstLut+k, 0 );
303 value = sat_solver_addclause( p->pSat, pLits, pLits+2 );
304 assert( value );
305 }
306 }
307 }
308 else if ( Gia_ObjIsAnd(Gia_ManObj(p->pGia, iFanin)) )
309 {
310 iFirst = Vec_IntEntry( p->vFirsts, iFanin );
311 nVars = Vec_IntEntry( p->vNvars, iFanin );
312 assert( nVars != 1 && nVars < nVarsLut );
313 // add initial
314 if ( nVars == 0 )
315 {
316 pLits[0] = Abc_Var2Lit( Count, 1 );
317 pLits[1] = Abc_Var2Lit( iFirstLut, 0 );
318 value = sat_solver_addclause( p->pSat, pLits, pLits+2 );
319 assert( value );
320
321 pLits[0] = Abc_Var2Lit( Count, 0 );
322 pLits[1] = Abc_Var2Lit( iFirstLut+1, 0 );
323 value = sat_solver_addclause( p->pSat, pLits, pLits+2 );
324 assert( value );
325 }
326 // add others
327 for ( k = 0; k < nVars; k++ )
328 {
329 pLits[0] = Abc_Var2Lit( iFirst+k, 1 );
330 pLits[1] = Abc_Var2Lit( Count, 1 );
331 pLits[2] = Abc_Var2Lit( iFirstLut+k, 0 );
332 value = sat_solver_addclause( p->pSat, pLits, pLits+3 );
333 assert( value );
334
335 pLits[0] = Abc_Var2Lit( iFirst+k, 1 );
336 pLits[1] = Abc_Var2Lit( Count, 0 );
337 pLits[2] = Abc_Var2Lit( iFirstLut+k+1, 0 );
338 value = sat_solver_addclause( p->pSat, pLits, pLits+3 );
339 assert( value );
340 }
341 Count++;
342 }
343 }
344 assert( Count == p->nVars );
345 if ( fVerbose )
346 printf( "Delay constraints = %d. ", sat_solver_nclauses(p->pSat) - nConstr );
347 nConstr = sat_solver_nclauses(p->pSat);
348/*
349 // delay relationship constraints
350 Vec_IntForEachEntryTwo( p->vFirsts, p->vNvars, iFirst, nVars, iLut )
351 {
352 if ( nVars < 2 )
353 continue;
354 for ( i = 1; i < nVars; i++ )
355 {
356 pLits[0] = Abc_Var2Lit( iFirst + i - 1, 1 );
357 pLits[1] = Abc_Var2Lit( iFirst + i, 0 );
358 value = sat_solver_addclause( p->pSat, pLits, pLits+2 );
359 assert( value );
360 }
361 }
362*/
363 // edge compatibility constraint
364 vObjEdges = Seg_ManCollectObjEdges( p->vEdges, Gia_ManObjNum(p->pGia) );
365 Vec_WecForEachLevel( vObjEdges, vLevel, i )
366 {
367 int v1, v2, v3, Var1, Var2, Var3;
368 if ( (!fTwo && Vec_IntSize(vLevel) >= 2) || (fTwo && Vec_IntSize(vLevel) > 10) )
369 {
370 Vec_IntForEachEntry( vLevel, Var1, v1 )
371 Vec_IntForEachEntryStart( vLevel, Var2, v2, v1 + 1 )
372 {
373 pLits[0] = Abc_Var2Lit( Var1, 1 );
374 pLits[1] = Abc_Var2Lit( Var2, 1 );
375 value = sat_solver_addclause( p->pSat, pLits, pLits+2 );
376 assert( value );
377 }
378 }
379 else if ( fTwo && Vec_IntSize(vLevel) >= 3 )
380 {
381 Vec_IntForEachEntry( vLevel, Var1, v1 )
382 Vec_IntForEachEntryStart( vLevel, Var2, v2, v1 + 1 )
383 Vec_IntForEachEntryStart( vLevel, Var3, v3, v2 + 1 )
384 {
385 pLits[0] = Abc_Var2Lit( Var1, 1 );
386 pLits[1] = Abc_Var2Lit( Var2, 1 );
387 pLits[2] = Abc_Var2Lit( Var3, 1 );
388 value = sat_solver_addclause( p->pSat, pLits, pLits+3 );
389 assert( value );
390 }
391 }
392 }
393 Vec_WecFree( vObjEdges );
394 // block forbidden edges
395 Vec_IntForEachEntry( p->vToSkip, Edge, i )
396 {
397 pLits[0] = Abc_Var2Lit( Edge, 1 );
398 value = sat_solver_addclause( p->pSat, pLits, pLits+1 );
399 assert( value );
400 }
401 if ( fVerbose )
402 printf( "Edge constraints = %d. ", sat_solver_nclauses(p->pSat) - nConstr );
403 if ( fVerbose )
404 Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
405}
ABC_NAMESPACE_IMPL_START typedef signed char value
#define sat_solver_addclause
Definition cecSatG2.c:37
Vec_Wec_t * Seg_ManCollectObjEdges(Vec_Int_t *vEdges, int nObjs)
Definition giaSatEdge.c:102
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition gia.h:1190
int sat_solver_nclauses(sat_solver *s)
Definition satSolver.c:2375
typedefABC_NAMESPACE_HEADER_START struct Tim_Man_t_ Tim_Man_t
INCLUDES ///.
Definition tim.h:92
int Tim_ManBoxForCi(Tim_Man_t *p, int iCo)
Definition timBox.c:87
int Tim_ManBoxInputFirst(Tim_Man_t *p, int iBox)
Definition timBox.c:123
int Tim_ManBoxInputNum(Tim_Man_t *p, int iBox)
Definition timBox.c:187
int Tim_ManBoxOutputFirst(Tim_Man_t *p, int iBox)
Definition timBox.c:155
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
Definition vecInt.h:56
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition vecWec.h:55
@ Var1
Definition xsatSolver.h:56
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Seg_ManStop()

void Seg_ManStop ( Seg_Man_t * p)

Definition at line 196 of file giaSatEdge.c.

197{
198 sat_solver_delete( p->pSat );
199 //Vec_IntFree( p->vCardVars );
200 // internal
201 Vec_IntFree( p->vEdges );
202 Vec_IntFree( p->vFirsts );
203 Vec_IntFree( p->vNvars );
204 Vec_IntFree( p->vLits );
205 Vec_IntFree( p->vPolars );
206 Vec_IntFree( p->vToSkip );
207 ABC_FREE( p->pLevels );
208 // other
209 ABC_FREE( p );
210}
void sat_solver_delete(sat_solver *s)
Definition satSolver.c:1341
Here is the call graph for this function:
Here is the caller graph for this function: