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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Abc_NtkMfsSolveSat_iter (Mfs_Man_t *p)
 DECLARATIONS ///.
 
int Abc_NtkMfsSolveSat (Mfs_Man_t *p, Abc_Obj_t *pNode)
 
int Abc_NtkAddOneHotness (Mfs_Man_t *p)
 

Function Documentation

◆ Abc_NtkAddOneHotness()

int Abc_NtkAddOneHotness ( Mfs_Man_t * p)

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

Synopsis [Adds one-hotness constraints for the window inputs.]

Description []

SideEffects []

SeeAlso []

Definition at line 155 of file mfsSat.c.

156{
157 Aig_Obj_t * pObj1, * pObj2;
158 int i, k, Lits[2];
159 for ( i = 0; i < Vec_PtrSize(p->pAigWin->vCis); i++ )
160 for ( k = i+1; k < Vec_PtrSize(p->pAigWin->vCis); k++ )
161 {
162 pObj1 = Aig_ManCi( p->pAigWin, i );
163 pObj2 = Aig_ManCi( p->pAigWin, k );
164 Lits[0] = toLitCond( p->pCnf->pVarNums[pObj1->Id], 1 );
165 Lits[1] = toLitCond( p->pCnf->pVarNums[pObj2->Id], 1 );
166 if ( !sat_solver_addclause( p->pSat, Lits, Lits+2 ) )
167 {
168 sat_solver_delete( p->pSat );
169 p->pSat = NULL;
170 return 0;
171 }
172 }
173 return 1;
174}
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
#define sat_solver_addclause
Definition cecSatG2.c:37
Cube * p
Definition exorList.c:222
void sat_solver_delete(sat_solver *s)
Definition satSolver.c:1341
int Id
Definition aig.h:85
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkMfsSolveSat()

int Abc_NtkMfsSolveSat ( Mfs_Man_t * p,
Abc_Obj_t * pNode )

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

Synopsis [Enumerates through the SAT assignments.]

Description []

SideEffects []

SeeAlso []

Definition at line 95 of file mfsSat.c.

96{
97 Aig_Obj_t * pObjPo;
98 int RetValue, i;
99 // collect projection variables
100 Vec_IntClear( p->vProjVarsSat );
101 Vec_PtrForEachEntryStart( Aig_Obj_t *, p->pAigWin->vCos, pObjPo, i, Aig_ManCoNum(p->pAigWin) - Abc_ObjFaninNum(pNode) )
102 {
103 assert( p->pCnf->pVarNums[pObjPo->Id] >= 0 );
104 Vec_IntPush( p->vProjVarsSat, p->pCnf->pVarNums[pObjPo->Id] );
105 }
106
107 // prepare the truth table of care set
108 p->nFanins = Vec_IntSize( p->vProjVarsSat );
109 p->nWords = Abc_TruthWordNum( p->nFanins );
110 memset( p->uCare, 0, sizeof(unsigned) * p->nWords );
111
112 // iterate through the SAT assignments
113 p->nCares = 0;
114 p->nTotConfLim = p->pPars->nBTLimit;
115 while ( (RetValue = Abc_NtkMfsSolveSat_iter(p)) == 1 );
116 if ( RetValue == -1 )
117 return 0;
118
119 // write statistics
120 p->nMintsCare += p->nCares;
121 p->nMintsTotal += (1<<p->nFanins);
122
123 if ( p->pPars->fVeryVerbose )
124 {
125 printf( "Node %4d : Care = %2d. Total = %2d. ", pNode->Id, p->nCares, (1<<p->nFanins) );
126 Extra_PrintBinary( stdout, p->uCare, (1<<p->nFanins) );
127 printf( "\n" );
128 }
129
130 // map the care
131 if ( p->nFanins > 4 )
132 return 1;
133 if ( p->nFanins == 4 )
134 p->uCare[0] = p->uCare[0] | (p->uCare[0] << 16);
135 if ( p->nFanins == 3 )
136 p->uCare[0] = p->uCare[0] | (p->uCare[0] << 8) | (p->uCare[0] << 16) | (p->uCare[0] << 24);
137 if ( p->nFanins == 2 )
138 p->uCare[0] = p->uCare[0] | (p->uCare[0] << 4) | (p->uCare[0] << 8) | (p->uCare[0] << 12) |
139 (p->uCare[0] << 16) | (p->uCare[0] << 20) | (p->uCare[0] << 24) | (p->uCare[0] << 28);
140 assert( p->nFanins != 1 );
141 return 1;
142}
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
ABC_NAMESPACE_IMPL_START int Abc_NtkMfsSolveSat_iter(Mfs_Man_t *p)
DECLARATIONS ///.
Definition mfsSat.c:45
int Id
Definition abc.h:132
#define assert(ex)
Definition util_old.h:213
char * memset()
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition vecPtr.h:57
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Abc_NtkMfsSolveSat_iter()

ABC_NAMESPACE_IMPL_START int Abc_NtkMfsSolveSat_iter ( Mfs_Man_t * p)

DECLARATIONS ///.

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

FileName [mfsSat.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [The good old minimization with complete don't-cares.]

Synopsis [Procedures to compute don't-cares using SAT.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Enumerates through the SAT assignments.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file mfsSat.c.

46{
47 int Lits[MFS_FANIN_MAX];
48 int RetValue, nBTLimit, iVar, b, Mint;
49// int nConfs = p->pSat->stats.conflicts;
50 if ( p->nTotConfLim && p->nTotConfLim <= p->pSat->stats.conflicts )
51 return -1;
52 nBTLimit = p->nTotConfLim? p->nTotConfLim - p->pSat->stats.conflicts : 0;
53 RetValue = sat_solver_solve( p->pSat, NULL, NULL, (ABC_INT64_T)nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
54 assert( RetValue == l_Undef || RetValue == l_True || RetValue == l_False );
55//printf( "%c", RetValue==l_Undef ? '?' : (RetValue==l_False ? '-' : '+') );
56//printf( "%d ", p->pSat->stats.conflicts-nConfs );
57//if ( RetValue==l_False )
58//printf( "\n" );
59 if ( RetValue == l_Undef )
60 return -1;
61 if ( RetValue == l_False )
62 return 0;
63 p->nCares++;
64 // add SAT assignment to the solver
65 Mint = 0;
66 Vec_IntForEachEntry( p->vProjVarsSat, iVar, b )
67 {
68 Lits[b] = toLit( iVar );
69 if ( sat_solver_var_value( p->pSat, iVar ) )
70 {
71 Mint |= (1 << b);
72 Lits[b] = lit_neg( Lits[b] );
73 }
74 }
75 assert( !Abc_InfoHasBit(p->uCare, Mint) );
76 Abc_InfoSetBit( p->uCare, Mint );
77 // add the blocking clause
78 RetValue = sat_solver_addclause( p->pSat, Lits, Lits + Vec_IntSize(p->vProjVarsSat) );
79 if ( RetValue == 0 )
80 return 0;
81 return 1;
82}
#define l_True
Definition bmcBmcS.c:35
#define l_Undef
Definition bmcBmcS.c:34
#define l_False
Definition bmcBmcS.c:36
#define sat_solver_solve
Definition cecSatG2.c:45
#define MFS_FANIN_MAX
INCLUDES ///.
Definition mfsInt.h:47
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition vecInt.h:54
Here is the caller graph for this function: