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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START Aig_Man_tDar_ManRwsat (Aig_Man_t *pAig, int fBalance, int fVerbose)
 DECLARATIONS ///.
 
Vec_Int_tAig_ManPartitionMonolithic (Aig_Man_t *p)
 FUNCTION DEFINITIONS ///.
 
Vec_Int_tAig_ManPartitionLevelized (Aig_Man_t *p, int nPartSize)
 
Vec_Int_tAig_ManPartitionDfs (Aig_Man_t *p, int nPartSize, int fPreorder)
 
void Aig_ManPartSplitOne_rec (Aig_Man_t *pNew, Aig_Man_t *p, Aig_Obj_t *pObj, Vec_Int_t *vPio2Id)
 
Aig_Man_tAig_ManPartSplitOne (Aig_Man_t *p, Vec_Ptr_t *vNodes, Vec_Int_t **pvPio2Id)
 
Vec_Ptr_tAig_ManPartSplit (Aig_Man_t *p, Vec_Int_t *vNode2Part, Vec_Ptr_t **pvPio2Id, Vec_Ptr_t **pvPart2Pos)
 
void Aig_ManPartResetNodePolarity (Aig_Man_t *pPart)
 
void Aig_ManPartSetNodePolarity (Aig_Man_t *p, Aig_Man_t *pPart, Vec_Int_t *vPio2Id)
 
void Aig_ManDeriveCounterExample (Aig_Man_t *p, Vec_Int_t *vNode2Var, sat_solver *pSat)
 
int Aig_ManAddNewCnfToSolver (sat_solver *pSat, Aig_Man_t *pAig, Vec_Int_t *vNode2Var, Vec_Int_t *vPioIds, Vec_Ptr_t *vPartPos, int fAlignPol)
 
int Aig_ManPartitionedSat (Aig_Man_t *p, int nAlgo, int nPartSize, int nConfPart, int nConfTotal, int fAlignPol, int fSynthesize, int fVerbose)
 

Function Documentation

◆ Aig_ManAddNewCnfToSolver()

int Aig_ManAddNewCnfToSolver ( sat_solver * pSat,
Aig_Man_t * pAig,
Vec_Int_t * vNode2Var,
Vec_Int_t * vPioIds,
Vec_Ptr_t * vPartPos,
int fAlignPol )

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

Synopsis [Derives CNF for the partition (pAig) and adds it to solver.]

Description [Array vPio2Id contains mapping of the PI/PO terminal of pAig into the IDs of the corresponding original nodes. Array vNode2Var contains mapping of the original nodes into their SAT variable numbers.]

SideEffects []

SeeAlso []

Definition at line 378 of file aigPartSat.c.

380{
381 Cnf_Dat_t * pCnf;
382 Aig_Obj_t * pObj;
383 int * pBeg, * pEnd;
384 int i, Lits[2], iSatVarOld, iNodeIdOld;
385 // derive CNF and express it using new SAT variables
386 pCnf = Cnf_Derive( pAig, Aig_ManCoNum(pAig) );
387 Cnf_DataTranformPolarity( pCnf, 1 );
388 Cnf_DataLift( pCnf, sat_solver_nvars(pSat) );
389 // create new variables in the SAT solver
390 sat_solver_setnvars( pSat, sat_solver_nvars(pSat) + pCnf->nVars );
391 // add clauses for this CNF
392 Cnf_CnfForClause( pCnf, pBeg, pEnd, i )
393 if ( !sat_solver_addclause( pSat, pBeg, pEnd ) )
394 {
395 assert( 0 ); // if it happens, can return 1 (unsatisfiable)
396 return 1;
397 }
398 // derive the connector clauses
399 Aig_ManForEachCi( pAig, pObj, i )
400 {
401 iNodeIdOld = Vec_IntEntry( vPioIds, i );
402 iSatVarOld = Vec_IntEntry( vNode2Var, iNodeIdOld );
403 if ( iSatVarOld == 0 ) // iNodeIdOld in the original AIG has no SAT var
404 {
405 // map the corresponding original AIG node into this SAT var
406 Vec_IntWriteEntry( vNode2Var, iNodeIdOld, pCnf->pVarNums[Aig_ObjId(pObj)] );
407 continue;
408 }
409 // add connector clauses
410 Lits[0] = toLitCond( iSatVarOld, 0 );
411 Lits[1] = toLitCond( pCnf->pVarNums[Aig_ObjId(pObj)], 1 );
412 if ( !sat_solver_addclause( pSat, Lits, Lits+2 ) )
413 assert( 0 );
414 Lits[0] = toLitCond( iSatVarOld, 1 );
415 Lits[1] = toLitCond( pCnf->pVarNums[Aig_ObjId(pObj)], 0 );
416 if ( !sat_solver_addclause( pSat, Lits, Lits+2 ) )
417 assert( 0 );
418 }
419 // derive the connector clauses
420 Aig_ManForEachCo( pAig, pObj, i )
421 {
422 iNodeIdOld = Vec_IntEntry( vPioIds, Aig_ManCiNum(pAig) + i );
423 iSatVarOld = Vec_IntEntry( vNode2Var, iNodeIdOld );
424 if ( iSatVarOld == 0 ) // iNodeIdOld in the original AIG has no SAT var
425 {
426 // map the corresponding original AIG node into this SAT var
427 Vec_IntWriteEntry( vNode2Var, iNodeIdOld, pCnf->pVarNums[Aig_ObjId(pObj)] );
428 continue;
429 }
430 // add connector clauses
431 Lits[0] = toLitCond( iSatVarOld, 0 );
432 Lits[1] = toLitCond( pCnf->pVarNums[Aig_ObjId(pObj)], 1 );
433 if ( !sat_solver_addclause( pSat, Lits, Lits+2 ) )
434 assert( 0 );
435 Lits[0] = toLitCond( iSatVarOld, 1 );
436 Lits[1] = toLitCond( pCnf->pVarNums[Aig_ObjId(pObj)], 0 );
437 if ( !sat_solver_addclause( pSat, Lits, Lits+2 ) )
438 assert( 0 );
439 }
440 // transfer the ID of constant 1 node
441 if ( Vec_IntEntry( vNode2Var, 0 ) == 0 )
442 Vec_IntWriteEntry( vNode2Var, 0, pCnf->pVarNums[0] );
443 // remove the CNF
444 Cnf_DataFree( pCnf );
445 // constrain the solver with the literals corresponding to the original POs
446 Vec_PtrForEachEntry( Aig_Obj_t *, vPartPos, pObj, i )
447 {
448 iNodeIdOld = Aig_ObjFaninId0( pObj );
449 iSatVarOld = Vec_IntEntry( vNode2Var, iNodeIdOld );
450 assert( iSatVarOld != 0 );
451 // assert the original PO to be 1
452 Lits[0] = toLitCond( iSatVarOld, Aig_ObjFaninC0(pObj) );
453 // correct the polarity if polarity alignment is enabled
454 if ( fAlignPol && Aig_ObjFanin0(pObj)->fPhase )
455 Lits[0] = lit_neg( Lits[0] );
456 if ( !sat_solver_addclause( pSat, Lits, Lits+1 ) )
457 {
458 assert( 0 ); // if it happens, can return 1 (unsatisfiable)
459 return 1;
460 }
461 }
462 // constrain some the primary inputs to constant values
463 Aig_ManForEachCi( pAig, pObj, i )
464 {
465 if ( !pObj->fMarkA && !pObj->fMarkB )
466 continue;
467 iNodeIdOld = Vec_IntEntry( vPioIds, i );
468 iSatVarOld = Vec_IntEntry( vNode2Var, iNodeIdOld );
469 Lits[0] = toLitCond( iSatVarOld, pObj->fMarkA );
470 if ( !sat_solver_addclause( pSat, Lits, Lits+1 ) )
471 {
472 assert( 0 ); // if it happens, can return 1 (unsatisfiable)
473 return 1;
474 }
475 pObj->fMarkA = pObj->fMarkB = 0;
476 }
477 return 0;
478}
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition aig.h:393
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
#define Aig_ManForEachCo(p, pObj, i)
Definition aig.h:398
#define sat_solver_addclause
Definition cecSatG2.c:37
Cnf_Dat_t * Cnf_Derive(Aig_Man_t *pAig, int nOutputs)
Definition cnfCore.c:165
void Cnf_DataTranformPolarity(Cnf_Dat_t *pCnf, int fTransformPos)
Definition cnfMan.c:768
#define Cnf_CnfForClause(p, pBeg, pEnd, i)
MACRO DEFINITIONS ///.
Definition cnf.h:117
struct Cnf_Dat_t_ Cnf_Dat_t
Definition cnf.h:52
void Cnf_DataFree(Cnf_Dat_t *p)
Definition cnfMan.c:207
void Cnf_DataLift(Cnf_Dat_t *p, int nVarsPlus)
Definition cnfMan.c:232
void sat_solver_setnvars(sat_solver *s, int n)
Definition satSolver.c:1272
int sat_solver_nvars(sat_solver *s)
Definition satSolver.c:2369
unsigned int fMarkB
Definition aig.h:80
unsigned int fMarkA
Definition aig.h:79
int nVars
Definition cnf.h:59
int * pVarNums
Definition cnf.h:63
#define assert(ex)
Definition util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition vecPtr.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ManDeriveCounterExample()

void Aig_ManDeriveCounterExample ( Aig_Man_t * p,
Vec_Int_t * vNode2Var,
sat_solver * pSat )

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

Synopsis [Sets polarity according to the original nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 350 of file aigPartSat.c.

351{
352 Vec_Int_t * vPisIds;
353 Aig_Obj_t * pObj;
354 int i;
355 // collect IDs of PI variables
356 // (fanoutless PIs have SAT var 0, which is an unused in the SAT solver -> has value 0)
357 vPisIds = Vec_IntAlloc( Aig_ManCiNum(p) );
358 Aig_ManForEachCi( p, pObj, i )
359 Vec_IntPush( vPisIds, Vec_IntEntry(vNode2Var, Aig_ObjId(pObj)) );
360 // derive the SAT assignment
361 p->pData = Sat_SolverGetModel( pSat, vPisIds->pArray, vPisIds->nSize );
362 Vec_IntFree( vPisIds );
363}
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
int * Sat_SolverGetModel(sat_solver *p, int *pVars, int nVars)
Definition satUtil.c:270
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ManPartitionDfs()

Vec_Int_t * Aig_ManPartitionDfs ( Aig_Man_t * p,
int nPartSize,
int fPreorder )

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

Synopsis [Partitioning using DFS order.]

Description []

SideEffects []

SeeAlso []

Definition at line 103 of file aigPartSat.c.

104{
105 Vec_Int_t * vId2Part;
106 Vec_Ptr_t * vNodes;
107 Aig_Obj_t * pObj;
108 int i, Counter = 0;
109 vId2Part = Vec_IntStart( Aig_ManObjNumMax(p) );
110 if ( fPreorder )
111 {
112 vNodes = Aig_ManDfsPreorder( p, 1 );
113 Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
114 Vec_IntWriteEntry( vId2Part, Aig_ObjId(pObj), Counter++/nPartSize );
115 }
116 else
117 {
118 vNodes = Aig_ManDfs( p, 1 );
119 Vec_PtrForEachEntryReverse( Aig_Obj_t *, vNodes, pObj, i )
120 Vec_IntWriteEntry( vId2Part, Aig_ObjId(pObj), Counter++/nPartSize );
121 }
122 Vec_PtrFree( vNodes );
123 return vId2Part;
124}
Vec_Ptr_t * Aig_ManDfs(Aig_Man_t *p, int fNodesOnly)
Definition aigDfs.c:145
Vec_Ptr_t * Aig_ManDfsPreorder(Aig_Man_t *p, int fNodesOnly)
Definition aigDfs.c:285
#define Vec_PtrForEachEntryReverse(Type, vVec, pEntry, i)
Definition vecPtr.h:63
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ManPartitionedSat()

int Aig_ManPartitionedSat ( Aig_Man_t * p,
int nAlgo,
int nPartSize,
int nConfPart,
int nConfTotal,
int fAlignPol,
int fSynthesize,
int fVerbose )

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

Synopsis [Performs partitioned SAT solving.]

Description []

SideEffects []

SeeAlso []

Definition at line 491 of file aigPartSat.c.

493{
494 sat_solver * pSat;
495 Vec_Ptr_t * vAigs;
496 Vec_Vec_t * vPio2Id, * vPart2Pos;
497 Aig_Man_t * pAig, * pTemp;
498 Vec_Int_t * vNode2Part, * vNode2Var;
499 int nConfRemaining = nConfTotal, nNodes = 0;
500 int i, status, RetValue = -1;
501 abctime clk;
502
503 // perform partitioning according to the selected algorithm
504 clk = Abc_Clock();
505 switch ( nAlgo )
506 {
507 case 0:
508 vNode2Part = Aig_ManPartitionMonolithic( p );
509 break;
510 case 1:
511 vNode2Part = Aig_ManPartitionLevelized( p, nPartSize );
512 break;
513 case 2:
514 vNode2Part = Aig_ManPartitionDfs( p, nPartSize, 0 );
515 break;
516 case 3:
517 vNode2Part = Aig_ManPartitionDfs( p, nPartSize, 1 );
518 break;
519 default:
520 printf( "Unknown partitioning algorithm.\n" );
521 return -1;
522 }
523
524 if ( fVerbose )
525 {
526 printf( "Partitioning derived %d partitions. ", Vec_IntFindMax(vNode2Part) + 1 );
527 ABC_PRT( "Time", Abc_Clock() - clk );
528 }
529
530 // split the original AIG into partition AIGs (vAigs)
531 // also, derives mapping of PIs/POs of partition AIGs into original nodes
532 // also, derives mapping of POs of the original AIG into partitions
533 vAigs = Aig_ManPartSplit( p, vNode2Part, (Vec_Ptr_t **)&vPio2Id, (Vec_Ptr_t **)&vPart2Pos );
534 Vec_IntFree( vNode2Part );
535
536 if ( fVerbose )
537 {
538 printf( "Partions were transformed into AIGs. " );
539 ABC_PRT( "Time", Abc_Clock() - clk );
540 }
541
542 // synthesize partitions
543 if ( fSynthesize )
544 Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pAig, i )
545 {
546 pAig = Dar_ManRwsat( pTemp = pAig, 0, 0 );
547 Vec_PtrWriteEntry( vAigs, i, pAig );
548 Aig_ManStop( pTemp );
549 }
550
551 // start the SAT solver
552 pSat = sat_solver_new();
553// pSat->verbosity = fVerbose;
554 // start mapping of the original AIG IDs into their SAT variable numbers
555 vNode2Var = Vec_IntStart( Aig_ManObjNumMax(p) );
556
557 // add partitions, one at a time, and run the SAT solver
558 Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pAig, i )
559 {
560clk = Abc_Clock();
561 // transform polarity of the AIG
562 if ( fAlignPol )
563 Aig_ManPartSetNodePolarity( p, pAig, Vec_VecEntryInt(vPio2Id,i) );
564 else
566 // add CNF of this partition to the SAT solver
567 if ( Aig_ManAddNewCnfToSolver( pSat, pAig, vNode2Var,
568 Vec_VecEntryInt(vPio2Id,i), Vec_VecEntry(vPart2Pos,i), fAlignPol ) )
569 {
570 RetValue = 1;
571 break;
572 }
573 // call the SAT solver
574 status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)nConfRemaining, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
575 if ( fVerbose )
576 {
577 printf( "%4d : Aig = %6d. Vs = %7d. RootCs = %7d. LearnCs = %6d. ",
578 i, nNodes += Aig_ManNodeNum(pAig), sat_solver_nvars(pSat),
579 (int)pSat->stats.clauses, (int)pSat->stats.learnts );
580ABC_PRT( "Time", Abc_Clock() - clk );
581 }
582 // analize the result
583 if ( status == l_False )
584 {
585 RetValue = 1;
586 break;
587 }
588 else if ( status == l_True )
589 RetValue = 0;
590 else
591 RetValue = -1;
592 nConfRemaining -= pSat->stats.conflicts;
593 if ( nConfRemaining <= 0 )
594 {
595 printf( "Exceeded the limit on the total number of conflicts (%d).\n", nConfTotal );
596 break;
597 }
598 }
599 if ( RetValue == 0 )
600 Aig_ManDeriveCounterExample( p, vNode2Var, pSat );
601 // cleanup
602 sat_solver_delete( pSat );
603 Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pTemp, i )
604 Aig_ManStop( pTemp );
605 Vec_PtrFree( vAigs );
606 Vec_VecFree( vPio2Id );
607 Vec_VecFree( vPart2Pos );
608 Vec_IntFree( vNode2Var );
609 return RetValue;
610}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
ABC_NAMESPACE_IMPL_START Aig_Man_t * Dar_ManRwsat(Aig_Man_t *pAig, int fBalance, int fVerbose)
DECLARATIONS ///.
Definition darScript.c:71
Vec_Int_t * Aig_ManPartitionLevelized(Aig_Man_t *p, int nPartSize)
Definition aigPartSat.c:78
void Aig_ManPartSetNodePolarity(Aig_Man_t *p, Aig_Man_t *pPart, Vec_Int_t *vPio2Id)
Definition aigPartSat.c:319
Vec_Ptr_t * Aig_ManPartSplit(Aig_Man_t *p, Vec_Int_t *vNode2Part, Vec_Ptr_t **pvPio2Id, Vec_Ptr_t **pvPart2Pos)
Definition aigPartSat.c:225
void Aig_ManPartResetNodePolarity(Aig_Man_t *pPart)
Definition aigPartSat.c:300
int Aig_ManAddNewCnfToSolver(sat_solver *pSat, Aig_Man_t *pAig, Vec_Int_t *vNode2Var, Vec_Int_t *vPioIds, Vec_Ptr_t *vPartPos, int fAlignPol)
Definition aigPartSat.c:378
void Aig_ManDeriveCounterExample(Aig_Man_t *p, Vec_Int_t *vNode2Var, sat_solver *pSat)
Definition aigPartSat.c:350
Vec_Int_t * Aig_ManPartitionDfs(Aig_Man_t *p, int nPartSize, int fPreorder)
Definition aigPartSat.c:103
Vec_Int_t * Aig_ManPartitionMonolithic(Aig_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition aigPartSat.c:60
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
#define l_True
Definition bmcBmcS.c:35
#define l_False
Definition bmcBmcS.c:36
#define sat_solver
Definition cecSatG2.c:34
#define sat_solver_solve
Definition cecSatG2.c:45
sat_solver * sat_solver_new(void)
Definition satSolver.c:1137
void sat_solver_delete(sat_solver *s)
Definition satSolver.c:1341
stats_t stats
Definition satSolver.h:163
ABC_INT64_T conflicts
Definition satVec.h:156
unsigned clauses
Definition satVec.h:155
unsigned learnts
Definition satVec.h:155
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition vecVec.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ManPartitionLevelized()

Vec_Int_t * Aig_ManPartitionLevelized ( Aig_Man_t * p,
int nPartSize )

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

Synopsis [Partitioning using levelized order.]

Description []

SideEffects []

SeeAlso []

Definition at line 78 of file aigPartSat.c.

79{
80 Vec_Int_t * vId2Part;
81 Vec_Vec_t * vNodes;
82 Aig_Obj_t * pObj;
83 int i, k, Counter = 0;
84 vNodes = Aig_ManLevelize( p );
85 vId2Part = Vec_IntStart( Aig_ManObjNumMax(p) );
86 Vec_VecForEachEntryReverseReverse( Aig_Obj_t *, vNodes, pObj, i, k )
87 Vec_IntWriteEntry( vId2Part, Aig_ObjId(pObj), Counter++/nPartSize );
88 Vec_VecFree( vNodes );
89 return vId2Part;
90}
Vec_Vec_t * Aig_ManLevelize(Aig_Man_t *p)
Definition aigDfs.c:321
#define Vec_VecForEachEntryReverseReverse(Type, vGlob, pEntry, i, k)
Definition vecVec.h:101
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ManPartitionMonolithic()

Vec_Int_t * Aig_ManPartitionMonolithic ( Aig_Man_t * p)

FUNCTION DEFINITIONS ///.

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

Synopsis [No partitioning.]

Description [The partitioner ]

SideEffects []

SeeAlso []

Definition at line 60 of file aigPartSat.c.

61{
62 Vec_Int_t * vId2Part;
63 vId2Part = Vec_IntStart( Aig_ManObjNumMax(p) );
64 return vId2Part;
65}
Here is the caller graph for this function:

◆ Aig_ManPartResetNodePolarity()

void Aig_ManPartResetNodePolarity ( Aig_Man_t * pPart)

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

Synopsis [Resets node polarity to unbias the polarity of CNF variables.]

Description []

SideEffects []

SeeAlso []

Definition at line 300 of file aigPartSat.c.

301{
302 Aig_Obj_t * pObj;
303 int i;
304 Aig_ManForEachObj( pPart, pObj, i )
305 pObj->fPhase = 0;
306}
#define Aig_ManForEachObj(p, pObj, i)
Definition aig.h:403
unsigned int fPhase
Definition aig.h:78
Here is the caller graph for this function:

◆ Aig_ManPartSetNodePolarity()

void Aig_ManPartSetNodePolarity ( Aig_Man_t * p,
Aig_Man_t * pPart,
Vec_Int_t * vPio2Id )

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

Synopsis [Sets polarity according to the original nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 319 of file aigPartSat.c.

320{
321 Aig_Obj_t * pObj, * pObjInit;
322 int i;
323 Aig_ManConst1(pPart)->fPhase = 1;
324 Aig_ManForEachCi( pPart, pObj, i )
325 {
326 pObjInit = Aig_ManObj( p, Vec_IntEntry(vPio2Id, i) );
327 pObj->fPhase = pObjInit->fPhase;
328 }
329 Aig_ManForEachNode( pPart, pObj, i )
330 pObj->fPhase = (Aig_ObjFanin0(pObj)->fPhase ^ Aig_ObjFaninC0(pObj)) & (Aig_ObjFanin1(pObj)->fPhase ^ Aig_ObjFaninC1(pObj));
331 Aig_ManForEachCo( pPart, pObj, i )
332 {
333 pObjInit = Aig_ManObj( p, Vec_IntEntry(vPio2Id, Aig_ManCiNum(pPart) + i) );
334 pObj->fPhase = (Aig_ObjFanin0(pObj)->fPhase ^ Aig_ObjFaninC0(pObj));
335 assert( pObj->fPhase == pObjInit->fPhase );
336 }
337}
#define Aig_ManForEachNode(p, pObj, i)
Definition aig.h:413
Here is the caller graph for this function:

◆ Aig_ManPartSplit()

Vec_Ptr_t * Aig_ManPartSplit ( Aig_Man_t * p,
Vec_Int_t * vNode2Part,
Vec_Ptr_t ** pvPio2Id,
Vec_Ptr_t ** pvPart2Pos )

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

Synopsis [Derives AIGs for each partition.]

Description [The first argument is a original AIG. The second argument is the array mapping each AND-node's ID into the 0-based number of its partition. The last argument is the array of arrays (one for each new AIG) mapping the index of each terminal in the new AIG (the index of each terminal is derived by ordering PIs followed by POs in their natural order) into the ID of the corresponding node in the original AIG. The returned value is the array of AIGs representing the partitions.]

SideEffects []

SeeAlso []

Definition at line 225 of file aigPartSat.c.

226{
227 Vec_Vec_t * vGroups, * vPart2Pos;
228 Vec_Ptr_t * vAigs, * vPio2Id, * vNodes;
229 Vec_Int_t * vPio2IdOne;
230 Aig_Man_t * pAig;
231 Aig_Obj_t * pObj, * pDriver;
232 int i, nodePart, nParts;
233 vAigs = Vec_PtrAlloc( 100 );
234 vPio2Id = Vec_PtrAlloc( 100 );
235 // put all nodes into levels according to their partition
236 nParts = Vec_IntFindMax(vNode2Part) + 1;
237 assert( nParts > 0 );
238 vGroups = Vec_VecAlloc( nParts );
239 Vec_IntForEachEntry( vNode2Part, nodePart, i )
240 {
241 pObj = Aig_ManObj( p, i );
242 if ( Aig_ObjIsNode(pObj) )
243 Vec_VecPush( vGroups, nodePart, pObj );
244 }
245
246 // label PIs that should be restricted to some values
247 Aig_ManForEachCo( p, pObj, i )
248 {
249 pDriver = Aig_ObjFanin0(pObj);
250 if ( Aig_ObjIsCi(pDriver) )
251 {
252 if ( Aig_ObjFaninC0(pObj) )
253 pDriver->fMarkA = 1; // const0 PI
254 else
255 pDriver->fMarkB = 1; // const1 PI
256 }
257 }
258
259 // create partitions
260 Vec_VecForEachLevel( vGroups, vNodes, i )
261 {
262 if ( Vec_PtrSize(vNodes) == 0 )
263 {
264 printf( "Aig_ManPartSplit(): Skipping partition # %d without nodes (warning).\n", i );
265 continue;
266 }
267 pAig = Aig_ManPartSplitOne( p, vNodes, &vPio2IdOne );
268 Vec_PtrPush( vPio2Id, vPio2IdOne );
269 Vec_PtrPush( vAigs, pAig );
270 }
271 Vec_VecFree( vGroups );
272
273 // divide POs according to their partitions
274 vPart2Pos = Vec_VecStart( Vec_PtrSize(vAigs) );
275 Aig_ManForEachCo( p, pObj, i )
276 {
277 pDriver = Aig_ObjFanin0(pObj);
278 if ( Aig_ObjIsCi(pDriver) )
279 pDriver->fMarkA = pDriver->fMarkB = 0;
280 else
281 Vec_VecPush( vPart2Pos, Vec_IntEntry(vNode2Part, Aig_ObjFaninId0(pObj)), pObj );
282 }
283
284 *pvPio2Id = vPio2Id;
285 *pvPart2Pos = (Vec_Ptr_t *)vPart2Pos;
286 return vAigs;
287}
Aig_Man_t * Aig_ManPartSplitOne(Aig_Man_t *p, Vec_Ptr_t *vNodes, Vec_Int_t **pvPio2Id)
Definition aigPartSat.c:177
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
#define Vec_VecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition vecVec.h:55
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ManPartSplitOne()

Aig_Man_t * Aig_ManPartSplitOne ( Aig_Man_t * p,
Vec_Ptr_t * vNodes,
Vec_Int_t ** pvPio2Id )

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

Synopsis [Carves out one partition of the AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 177 of file aigPartSat.c.

178{
179 Vec_Int_t * vPio2Id;
180 Aig_Man_t * pNew;
181 Aig_Obj_t * pObj;
182 int i;
183 // mark these nodes
185 Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
186 {
187 Aig_ObjSetTravIdCurrent( p, pObj );
188 pObj->pData = NULL;
189 }
190 // add these nodes in a DFS order
191 pNew = Aig_ManStart( Vec_PtrSize(vNodes) );
192 vPio2Id = Vec_IntAlloc( 100 );
193 Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
194 Aig_ManPartSplitOne_rec( pNew, p, pObj, vPio2Id );
195 // add the POs
196 Vec_PtrForEachEntry( Aig_Obj_t *, vNodes, pObj, i )
197 if ( Aig_ObjRefs((Aig_Obj_t *)pObj->pData) != Aig_ObjRefs(pObj) )
198 {
199 assert( Aig_ObjRefs((Aig_Obj_t *)pObj->pData) < Aig_ObjRefs(pObj) );
200 Aig_ObjCreateCo( pNew, (Aig_Obj_t *)pObj->pData );
201 Vec_IntPush( vPio2Id, Aig_ObjId(pObj) );
202 }
203 assert( Aig_ManNodeNum(pNew) == Vec_PtrSize(vNodes) );
204 *pvPio2Id = vPio2Id;
205 return pNew;
206}
void Aig_ManPartSplitOne_rec(Aig_Man_t *pNew, Aig_Man_t *p, Aig_Obj_t *pObj, Vec_Int_t *vPio2Id)
Definition aigPartSat.c:137
void Aig_ManIncrementTravId(Aig_Man_t *p)
DECLARATIONS ///.
Definition aigUtil.c:44
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition aigObj.c:66
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition aigMan.c:47
void * pData
Definition aig.h:87
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Aig_ManPartSplitOne_rec()

void Aig_ManPartSplitOne_rec ( Aig_Man_t * pNew,
Aig_Man_t * p,
Aig_Obj_t * pObj,
Vec_Int_t * vPio2Id )

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

Synopsis [Recursively constructs the partition.]

Description []

SideEffects []

SeeAlso []

Definition at line 137 of file aigPartSat.c.

138{
139 if ( !Aig_ObjIsTravIdCurrent( p, pObj ) )
140 { // new PI
141 Aig_ObjSetTravIdCurrent( p, pObj );
142/*
143 if ( pObj->fMarkA ) // const0
144 pObj->pData = Aig_ManConst0( pNew );
145 else if ( pObj->fMarkB ) // const1
146 pObj->pData = Aig_ManConst1( pNew );
147 else
148*/
149 {
150 pObj->pData = Aig_ObjCreateCi( pNew );
151 if ( pObj->fMarkA ) // const0
152 ((Aig_Obj_t *)pObj->pData)->fMarkA = 1;
153 else if ( pObj->fMarkB ) // const1
154 ((Aig_Obj_t *)pObj->pData)->fMarkB = 1;
155 Vec_IntPush( vPio2Id, Aig_ObjId(pObj) );
156 }
157 return;
158 }
159 if ( pObj->pData )
160 return;
161 Aig_ManPartSplitOne_rec( pNew, p, Aig_ObjFanin0(pObj), vPio2Id );
162 Aig_ManPartSplitOne_rec( pNew, p, Aig_ObjFanin1(pObj), vPio2Id );
163 pObj->pData = Aig_And( pNew, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
164}
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition aigOper.c:104
Aig_Obj_t * Aig_ObjCreateCi(Aig_Man_t *p)
DECLARATIONS ///.
Definition aigObj.c:45
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dar_ManRwsat()

ABC_NAMESPACE_IMPL_START Aig_Man_t * Dar_ManRwsat ( Aig_Man_t * pAig,
int fBalance,
int fVerbose )
extern

DECLARATIONS ///.

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

FileName [aigPartSat.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [AIG package.]

Synopsis [Partitioning for SAT solving.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - April 28, 2007.]

Revision [

Id
aigPartSat.c,v 1.00 2007/04/28 00:00:00 alanmi Exp

]

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

Synopsis [Reproduces script "rwsat".]

Description []

SideEffects [This procedure does not tighten level during restructuring.]

SeeAlso []

Definition at line 71 of file darScript.c.

73{
74 Aig_Man_t * pTemp;
75 abctime Time = pAig->Time2Quit;
76
77 Dar_RwrPar_t ParsRwr, * pParsRwr = &ParsRwr;
78 Dar_RefPar_t ParsRef, * pParsRef = &ParsRef;
79
80 Dar_ManDefaultRwrParams( pParsRwr );
81 Dar_ManDefaultRefParams( pParsRef );
82
83 pParsRwr->fUpdateLevel = 0;
84 pParsRef->fUpdateLevel = 0;
85
86 pParsRwr->fVerbose = fVerbose;
87 pParsRef->fVerbose = fVerbose;
88//printf( "1" );
89 pAig = Aig_ManDupDfs( pAig );
90 if ( fVerbose ) printf( "Starting: " ), Aig_ManPrintStats( pAig );
91
92//printf( "2" );
93 // balance
94 if ( fBalance )
95 {
96 pAig->Time2Quit = Time;
97 pAig = Dar_ManBalance( pTemp = pAig, 0 );
98 Aig_ManStop( pTemp );
99 if ( fVerbose ) printf( "Balance: " ), Aig_ManPrintStats( pAig );
100 if ( Time && Abc_Clock() > Time )
101 { if ( pAig ) Aig_ManStop( pAig ); return NULL; }
102 }
103
104//Aig_ManDumpBlif( pAig, "inter.blif", NULL, NULL );
105//printf( "3" );
106 // rewrite
107 pAig->Time2Quit = Time;
108 Dar_ManRewrite( pAig, pParsRwr );
109 pAig = Aig_ManDupDfs( pTemp = pAig );
110 Aig_ManStop( pTemp );
111 if ( fVerbose ) printf( "Rewrite: " ), Aig_ManPrintStats( pAig );
112 if ( Time && Abc_Clock() > Time )
113 { if ( pAig ) Aig_ManStop( pAig ); return NULL; }
114
115//printf( "4" );
116 // refactor
117 pAig->Time2Quit = Time;
118 Dar_ManRefactor( pAig, pParsRef );
119 pAig = Aig_ManDupDfs( pTemp = pAig );
120 Aig_ManStop( pTemp );
121 if ( fVerbose ) printf( "Refactor: " ), Aig_ManPrintStats( pAig );
122 if ( Time && Abc_Clock() > Time )
123 { if ( pAig ) Aig_ManStop( pAig ); return NULL; }
124
125//printf( "5" );
126 // balance
127 if ( fBalance )
128 {
129 pAig->Time2Quit = Time;
130 pAig = Dar_ManBalance( pTemp = pAig, 0 );
131 Aig_ManStop( pTemp );
132 if ( fVerbose ) printf( "Balance: " ), Aig_ManPrintStats( pAig );
133 if ( Time && Abc_Clock() > Time )
134 { if ( pAig ) Aig_ManStop( pAig ); return NULL; }
135 }
136
137//printf( "6" );
138 // rewrite
139 pAig->Time2Quit = Time;
140 Dar_ManRewrite( pAig, pParsRwr );
141 pAig = Aig_ManDupDfs( pTemp = pAig );
142 Aig_ManStop( pTemp );
143 if ( fVerbose ) printf( "Rewrite: " ), Aig_ManPrintStats( pAig );
144 if ( Time && Abc_Clock() > Time )
145 { if ( pAig ) Aig_ManStop( pAig ); return NULL; }
146
147//printf( "7" );
148 return pAig;
149}
Aig_Man_t * Aig_ManDupDfs(Aig_Man_t *p)
Definition aigDup.c:563
void Aig_ManPrintStats(Aig_Man_t *p)
Definition aigMan.c:379
int Dar_ManRefactor(Aig_Man_t *pAig, Dar_RefPar_t *pPars)
Definition darRefact.c:496
typedefABC_NAMESPACE_HEADER_START struct Dar_RwrPar_t_ Dar_RwrPar_t
INCLUDES ///.
Definition dar.h:42
void Dar_ManDefaultRwrParams(Dar_RwrPar_t *pPars)
FUNCTION DEFINITIONS ///.
Definition darCore.c:51
Aig_Man_t * Dar_ManBalance(Aig_Man_t *p, int fUpdateLevel)
Definition darBalance.c:554
struct Dar_RefPar_t_ Dar_RefPar_t
Definition dar.h:43
int Dar_ManRewrite(Aig_Man_t *pAig, Dar_RwrPar_t *pPars)
Definition darCore.c:79
void Dar_ManDefaultRefParams(Dar_RefPar_t *pPars)
FUNCTION DEFINITIONS ///.
Definition darRefact.c:85
int fVerbose
Definition dar.h:67
int fUpdateLevel
Definition dar.h:65
Here is the call graph for this function:
Here is the caller graph for this function: