abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mfsInt.h File Reference
#include "base/abc/abc.h"
#include "mfs.h"
#include "aig/aig/aig.h"
#include "sat/cnf/cnf.h"
#include "sat/bsat/satSolver.h"
#include "sat/bsat/satStore.h"
#include "bool/bdc/bdc.h"
#include "aig/gia/gia.h"

Go to the source code of this file.

Data Structures

struct  Mfs_Man_t_
 

Macros

#define MFS_FANIN_MAX   12
 INCLUDES ///. More...
 

Typedefs

typedef struct Mfs_Man_t_ Mfs_Man_t
 

Functions

static float Abc_MfsObjProb (Mfs_Man_t *p, Abc_Obj_t *pObj)
 
Vec_Ptr_tAbc_MfsComputeDivisors (Mfs_Man_t *p, Abc_Obj_t *pNode, int nLevDivMax)
 BASIC TYPES ///. More...
 
sat_solverAbc_MfsCreateSolverResub (Mfs_Man_t *p, int *pCands, int nCands, int fInvert)
 
Hop_Obj_tAbc_NtkMfsInterplate (Mfs_Man_t *p, int *pCands, int nCands)
 
int Abc_NtkMfsInterplateEval (Mfs_Man_t *p, int *pCands, int nCands)
 
Mfs_Man_tMfs_ManAlloc (Mfs_Par_t *pPars)
 DECLARATIONS ///. More...
 
void Mfs_ManStop (Mfs_Man_t *p)
 
void Mfs_ManClean (Mfs_Man_t *p)
 
void Abc_NtkMfsPrintResubStats (Mfs_Man_t *p)
 
int Abc_NtkMfsEdgeSwapEval (Mfs_Man_t *p, Abc_Obj_t *pNode)
 
int Abc_NtkMfsEdgePower (Mfs_Man_t *p, Abc_Obj_t *pNode)
 
int Abc_NtkMfsResubNode (Mfs_Man_t *p, Abc_Obj_t *pNode)
 
int Abc_NtkMfsResubNode2 (Mfs_Man_t *p, Abc_Obj_t *pNode)
 
int Abc_NtkMfsSolveSat (Mfs_Man_t *p, Abc_Obj_t *pNode)
 
int Abc_NtkAddOneHotness (Mfs_Man_t *p)
 
Aig_Man_tAbc_NtkConstructAig (Mfs_Man_t *p, Abc_Obj_t *pNode)
 
double Abc_NtkConstraintRatio (Mfs_Man_t *p, Abc_Obj_t *pNode)
 
Vec_Ptr_tAbc_MfsComputeRoots (Abc_Obj_t *pNode, int nWinTfoMax, int nFanoutLimit)
 
void Abc_NtkMfsConstructGia (Mfs_Man_t *p)
 
void Abc_NtkMfsDeconstructGia (Mfs_Man_t *p)
 
int Abc_NtkMfsTryResubOnceGia (Mfs_Man_t *p, int *pCands, int nCands)
 

Macro Definition Documentation

#define MFS_FANIN_MAX   12

INCLUDES ///.

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

FileName [mfsInt.h]

SystemName [ABC: Logic synthesis and verification system.]

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

Synopsis [Internal declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id:
mfsInt.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

]PARAMETERS ///

Definition at line 47 of file mfsInt.h.

Typedef Documentation

typedef struct Mfs_Man_t_ Mfs_Man_t

Definition at line 49 of file mfsInt.h.

Function Documentation

Vec_Ptr_t* Abc_MfsComputeDivisors ( Mfs_Man_t p,
Abc_Obj_t pNode,
int  nLevDivMax 
)

BASIC TYPES ///.

MACRO DEFINITIONS ///FUNCTION DECLARATIONS ///

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

Synopsis [Computes divisors and add them to nodes in the window.]

Description []

SideEffects []

SeeAlso []

Definition at line 193 of file mfsDiv.c.

194 {
195  Vec_Ptr_t * vCone, * vDivs;
196  Abc_Obj_t * pObj, * pFanout, * pFanin;
197  int k, f, m;
198  int nDivsPlus = 0, nTrueSupp;
199  assert( p->vDivs == NULL );
200 
201  // mark the TFI with the current trav ID
202  Abc_NtkIncrementTravId( pNode->pNtk );
203  vCone = Abc_MfsWinMarkTfi( pNode );
204 
205  // count the number of PIs
206  nTrueSupp = 0;
207  Vec_PtrForEachEntry( Abc_Obj_t *, vCone, pObj, k )
208  nTrueSupp += Abc_ObjIsCi(pObj);
209 // printf( "%d(%d) ", Vec_PtrSize(p->vSupp), m );
210 
211  // mark with the current trav ID those nodes that should not be divisors:
212  // (1) the node and its TFO
213  // (2) the MFFC of the node
214  // (3) the node's fanins (these are treated as a special case)
215  Abc_NtkIncrementTravId( pNode->pNtk );
216  Abc_MfsWinSweepLeafTfo_rec( pNode, nLevDivMax );
217 // Abc_MfsWinVisitMffc( pNode );
218  Abc_ObjForEachFanin( pNode, pObj, k )
219  Abc_NodeSetTravIdCurrent( pObj );
220 
221  // at this point the nodes are marked with two trav IDs:
222  // nodes to be collected as divisors are marked with previous trav ID
223  // nodes to be avoided as divisors are marked with current trav ID
224 
225  // start collecting the divisors
226  vDivs = Vec_PtrAlloc( p->pPars->nWinMax );
227  Vec_PtrForEachEntry( Abc_Obj_t *, vCone, pObj, k )
228  {
229  if ( !Abc_NodeIsTravIdPrevious(pObj) )
230  continue;
231  if ( (int)pObj->Level > nLevDivMax )
232  continue;
233  Vec_PtrPush( vDivs, pObj );
234  if ( Vec_PtrSize(vDivs) >= p->pPars->nWinMax )
235  break;
236  }
237  Vec_PtrFree( vCone );
238 
239  // explore the fanouts of already collected divisors
240  if ( Vec_PtrSize(vDivs) < p->pPars->nWinMax )
241  Vec_PtrForEachEntry( Abc_Obj_t *, vDivs, pObj, k )
242  {
243  // consider fanouts of this node
244  Abc_ObjForEachFanout( pObj, pFanout, f )
245  {
246  // stop if there are too many fanouts
247  if ( p->pPars->nFanoutsMax && f > p->pPars->nFanoutsMax )
248  break;
249  // skip nodes that are already added
250  if ( Abc_NodeIsTravIdPrevious(pFanout) )
251  continue;
252  // skip nodes in the TFO or in the MFFC of node
253  if ( Abc_NodeIsTravIdCurrent(pFanout) )
254  continue;
255  // skip COs
256  if ( !Abc_ObjIsNode(pFanout) )
257  continue;
258  // skip nodes with large level
259  if ( (int)pFanout->Level > nLevDivMax )
260  continue;
261  // skip nodes whose fanins are not divisors -- here we skip more than we need to skip!!! (revise later) August 7, 2009
262  Abc_ObjForEachFanin( pFanout, pFanin, m )
263  if ( !Abc_NodeIsTravIdPrevious(pFanin) )
264  break;
265  if ( m < Abc_ObjFaninNum(pFanout) )
266  continue;
267  // make sure this divisor in not among the nodes
268 // Vec_PtrForEachEntry( Abc_Obj_t *, p->vNodes, pFanin, m )
269 // assert( pFanout != pFanin );
270  // add the node to the divisors
271  Vec_PtrPush( vDivs, pFanout );
272 // Vec_PtrPush( p->vNodes, pFanout );
273  Vec_PtrPushUnique( p->vNodes, pFanout );
274  Abc_NodeSetTravIdPrevious( pFanout );
275  nDivsPlus++;
276  if ( Vec_PtrSize(vDivs) >= p->pPars->nWinMax )
277  break;
278  }
279  if ( Vec_PtrSize(vDivs) >= p->pPars->nWinMax )
280  break;
281  }
282  p->nMaxDivs += (Vec_PtrSize(vDivs) >= p->pPars->nWinMax);
283 
284  // sort the divisors by level in the increasing order
285  Vec_PtrSort( vDivs, (int (*)(void))Abc_NodeCompareLevelsIncrease );
286 
287  // add the fanins of the node
288  Abc_ObjForEachFanin( pNode, pFanin, k )
289  Vec_PtrPush( vDivs, pFanin );
290 
291 /*
292  printf( "Node level = %d. ", Abc_ObjLevel(p->pNode) );
293  Vec_PtrForEachEntryStart( Abc_Obj_t *, vDivs, pObj, k, Vec_PtrSize(vDivs)-p->nDivsPlus )
294  printf( "%d ", Abc_ObjLevel(pObj) );
295  printf( "\n" );
296 */
297 //printf( "%d ", p->nDivsPlus );
298 // printf( "(%d+%d)(%d+%d+%d) ", Vec_PtrSize(p->vSupp), Vec_PtrSize(p->vNodes),
299 // nTrueSupp, Vec_PtrSize(vDivs)-nTrueSupp-nDivsPlus, nDivsPlus );
300  return vDivs;
301 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Abc_MfsWinSweepLeafTfo_rec(Abc_Obj_t *pObj, int nLevelLimit)
Definition: mfsDiv.c:94
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
static int Vec_PtrPushUnique(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:656
Mfs_Par_t * pPars
Definition: mfsInt.h:53
static void Abc_NodeSetTravIdPrevious(Abc_Obj_t *p)
Definition: abc.h:410
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static void Vec_PtrSort(Vec_Ptr_t *p, int(*Vec_PtrSortCompare)()) ___unused
Definition: vecPtr.h:851
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Abc_NodeIsTravIdPrevious(Abc_Obj_t *p)
Definition: abc.h:412
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Vec_Ptr_t * vDivs
Definition: mfsInt.h:62
unsigned Level
Definition: abc.h:142
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
ABC_DLL int Abc_NodeCompareLevelsIncrease(Abc_Obj_t **pp1, Abc_Obj_t **pp2)
Definition: abcUtil.c:1649
Vec_Ptr_t * Abc_MfsWinMarkTfi(Abc_Obj_t *pNode)
Definition: mfsDiv.c:75
if(last==0)
Definition: sparse_int.h:34
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
Abc_Ntk_t * pNtk
Definition: abc.h:130
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
#define assert(ex)
Definition: util_old.h:213
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Vec_Ptr_t* Abc_MfsComputeRoots ( Abc_Obj_t pNode,
int  nWinTfoMax,
int  nFanoutLimit 
)

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

Synopsis [Recursively collects the root candidates.]

Description [Returns 1 if the only root is this node.]

SideEffects []

SeeAlso []

Definition at line 99 of file mfsWin.c.

100 {
101  Vec_Ptr_t * vRoots;
102  vRoots = Vec_PtrAlloc( 10 );
103  Abc_NtkIncrementTravId( pNode->pNtk );
104  Abc_MfsComputeRoots_rec( pNode, pNode->Level + nWinTfoMax, nFanoutLimit, vRoots );
105  assert( Vec_PtrSize(vRoots) > 0 );
106 // if ( Vec_PtrSize(vRoots) == 1 && Vec_PtrEntry(vRoots, 0) == pNode )
107 // return 0;
108  return vRoots;
109 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
unsigned Level
Definition: abc.h:142
Abc_Ntk_t * pNtk
Definition: abc.h:130
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
void Abc_MfsComputeRoots_rec(Abc_Obj_t *pNode, int nLevelMax, int nFanoutLimit, Vec_Ptr_t *vRoots)
Definition: mfsWin.c:72
#define assert(ex)
Definition: util_old.h:213
sat_solver* Abc_MfsCreateSolverResub ( Mfs_Man_t p,
int *  pCands,
int  nCands,
int  fInvert 
)

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

Synopsis [Creates miter for checking resubsitution.]

Description []

SideEffects []

SeeAlso []

Definition at line 88 of file mfsInter.c.

89 {
90  sat_solver * pSat;
91  Aig_Obj_t * pObjPo;
92  int Lits[2], status, iVar, i, c;
93 
94  // get the literal for the output of F
95  pObjPo = Aig_ManCo( p->pAigWin, Aig_ManCoNum(p->pAigWin) - Vec_PtrSize(p->vDivs) - 1 );
96  Lits[0] = toLitCond( p->pCnf->pVarNums[pObjPo->Id], fInvert );
97 
98  // collect the outputs of the divisors
100  Vec_PtrForEachEntryStart( Aig_Obj_t *, p->pAigWin->vCos, pObjPo, i, Aig_ManCoNum(p->pAigWin) - Vec_PtrSize(p->vDivs) )
101  {
102  assert( p->pCnf->pVarNums[pObjPo->Id] >= 0 );
103  Vec_IntPush( p->vProjVarsCnf, p->pCnf->pVarNums[pObjPo->Id] );
104  }
106 
107  // start the solver
108  pSat = sat_solver_new();
109  sat_solver_setnvars( pSat, 2 * p->pCnf->nVars + Vec_PtrSize(p->vDivs) );
110  if ( pCands )
111  sat_solver_store_alloc( pSat );
112 
113  // load the first copy of the clauses
114  for ( i = 0; i < p->pCnf->nClauses; i++ )
115  {
116  if ( !sat_solver_addclause( pSat, p->pCnf->pClauses[i], p->pCnf->pClauses[i+1] ) )
117  {
118  sat_solver_delete( pSat );
119  return NULL;
120  }
121  }
122  // add the clause for the first output of F
123  if ( !sat_solver_addclause( pSat, Lits, Lits+1 ) )
124  {
125  sat_solver_delete( pSat );
126  return NULL;
127  }
128 
129  // add one-hotness constraints
130  if ( p->pPars->fOneHotness )
131  {
132  p->pSat = pSat;
133  if ( !Abc_NtkAddOneHotness( p ) )
134  return NULL;
135  p->pSat = NULL;
136  }
137 
138  // bookmark the clauses of A
139  if ( pCands )
141 
142  // transform the literals
143  for ( i = 0; i < p->pCnf->nLiterals; i++ )
144  p->pCnf->pClauses[0][i] += 2 * p->pCnf->nVars;
145  // load the second copy of the clauses
146  for ( i = 0; i < p->pCnf->nClauses; i++ )
147  {
148  if ( !sat_solver_addclause( pSat, p->pCnf->pClauses[i], p->pCnf->pClauses[i+1] ) )
149  {
150  sat_solver_delete( pSat );
151  return NULL;
152  }
153  }
154  // add one-hotness constraints
155  if ( p->pPars->fOneHotness )
156  {
157  p->pSat = pSat;
158  if ( !Abc_NtkAddOneHotness( p ) )
159  return NULL;
160  p->pSat = NULL;
161  }
162  // transform the literals
163  for ( i = 0; i < p->pCnf->nLiterals; i++ )
164  p->pCnf->pClauses[0][i] -= 2 * p->pCnf->nVars;
165  // add the clause for the second output of F
166  Lits[0] = 2 * p->pCnf->nVars + lit_neg( Lits[0] );
167  if ( !sat_solver_addclause( pSat, Lits, Lits+1 ) )
168  {
169  sat_solver_delete( pSat );
170  return NULL;
171  }
172 
173  if ( pCands )
174  {
175  // add relevant clauses for EXOR gates
176  for ( c = 0; c < nCands; c++ )
177  {
178  // get the variable number of this divisor
179  i = lit_var( pCands[c] ) - 2 * p->pCnf->nVars;
180  // get the corresponding SAT variable
181  iVar = Vec_IntEntry( p->vProjVarsCnf, i );
182  // add the corresponding EXOR gate
183  if ( !Abc_MfsSatAddXor( pSat, iVar, iVar + p->pCnf->nVars, 2 * p->pCnf->nVars + i ) )
184  {
185  sat_solver_delete( pSat );
186  return NULL;
187  }
188  // add the corresponding clause
189  if ( !sat_solver_addclause( pSat, pCands + c, pCands + c + 1 ) )
190  {
191  sat_solver_delete( pSat );
192  return NULL;
193  }
194  }
195  // bookmark the roots
197  }
198  else
199  {
200  // add the clauses for the EXOR gates - and remember their outputs
202  Vec_IntForEachEntry( p->vProjVarsCnf, iVar, i )
203  {
204  if ( !Abc_MfsSatAddXor( pSat, iVar, iVar + p->pCnf->nVars, 2 * p->pCnf->nVars + i ) )
205  {
206  sat_solver_delete( pSat );
207  return NULL;
208  }
209  Vec_IntPush( p->vProjVarsSat, 2 * p->pCnf->nVars + i );
210  }
212  // simplify the solver
213  status = sat_solver_simplify(pSat);
214  if ( status == 0 )
215  {
216 // printf( "Abc_MfsCreateSolverResub(): SAT solver construction has failed. Skipping node.\n" );
217  sat_solver_delete( pSat );
218  return NULL;
219  }
220  }
221  return pSat;
222 }
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition: vecPtr.h:57
Vec_Int_t * vProjVarsSat
Definition: mfsInt.h:65
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
int nClauses
Definition: cnf.h:61
Mfs_Par_t * pPars
Definition: mfsInt.h:53
static int lit_var(lit l)
Definition: satVec.h:145
ABC_NAMESPACE_IMPL_START int Abc_MfsSatAddXor(sat_solver *pSat, int iVarA, int iVarB, int iVarC)
DECLARATIONS ///.
Definition: mfsInter.c:46
int nVars
Definition: cnf.h:59
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
int * pVarNums
Definition: cnf.h:63
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
for(p=first;p->value< newval;p=p->next)
Vec_Ptr_t * vDivs
Definition: mfsInt.h:62
Aig_Man_t * pAigWin
Definition: mfsInt.h:87
int Abc_NtkAddOneHotness(Mfs_Man_t *p)
Definition: mfsSat.c:155
static lit lit_neg(lit l)
Definition: satVec.h:144
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
int ** pClauses
Definition: cnf.h:62
void sat_solver_store_alloc(sat_solver *s)
Definition: satSolver.c:1916
static lit toLitCond(int v, int c)
Definition: satVec.h:143
void sat_solver_setnvars(sat_solver *s, int n)
Definition: satSolver.c:1072
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
Definition: aig.h:69
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
void sat_solver_store_mark_clauses_a(sat_solver *s)
Definition: satSolver.c:1944
static Aig_Obj_t * Aig_ManCo(Aig_Man_t *p, int i)
Definition: aig.h:267
void sat_solver_store_mark_roots(sat_solver *s)
Definition: satSolver.c:1939
int sat_solver_simplify(sat_solver *s)
Definition: satSolver.c:1276
sat_solver * sat_solver_new(void)
Definition: satSolver.c:1001
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
Vec_Int_t * vProjVarsCnf
Definition: mfsInt.h:64
sat_solver * pSat
Definition: mfsInt.h:89
Cnf_Dat_t * pCnf
Definition: mfsInt.h:88
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int nLiterals
Definition: cnf.h:60
int Id
Definition: aig.h:85
static float Abc_MfsObjProb ( Mfs_Man_t p,
Abc_Obj_t pObj 
)
inlinestatic

Definition at line 137 of file mfsInt.h.

137 { return (p->vProbs && pObj->Id < Vec_IntSize(p->vProbs))? Abc_Int2Float(Vec_IntEntry(p->vProbs,pObj->Id)) : 0.0; }
Vec_Int_t * vProbs
Definition: mfsInt.h:97
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
int Id
Definition: abc.h:132
static float Abc_Int2Float(int Num)
Definition: abc_global.h:250
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 }
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
int * pVarNums
Definition: cnf.h:63
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
Aig_Man_t * pAigWin
Definition: mfsInt.h:87
static Aig_Obj_t * Aig_ManCi(Aig_Man_t *p, int i)
Definition: aig.h:266
static lit toLitCond(int v, int c)
Definition: satVec.h:143
Definition: aig.h:69
sat_solver * pSat
Definition: mfsInt.h:89
Cnf_Dat_t * pCnf
Definition: mfsInt.h:88
int Id
Definition: aig.h:85
double Abc_NtkConstraintRatio ( Mfs_Man_t p,
Abc_Obj_t pNode 
)

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

Synopsis [Compute the ratio of don't-cares.]

Description []

SideEffects []

SeeAlso []

Definition at line 386 of file mfsStrash.c.

387 {
388  int nSimWords = 256;
389  Aig_Man_t * pMan;
390  Fra_Sml_t * pSim;
391  int Counter;
392  pMan = Abc_NtkAigForConstraints( p, pNode );
393  pSim = Fra_SmlSimulateComb( pMan, nSimWords, 0 );
394  Counter = Fra_SmlNodeCountOnes( pSim, Aig_ManCo(pMan, 0) );
395  Aig_ManStop( pMan );
396  Fra_SmlStop( pSim );
397  return 1.0 * Counter / (32 * nSimWords);
398 }
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
int Fra_SmlNodeCountOnes(Fra_Sml_t *p, Aig_Obj_t *pObj)
Definition: fraSim.c:177
Aig_Man_t * Abc_NtkAigForConstraints(Mfs_Man_t *p, Abc_Obj_t *pNode)
Definition: mfsStrash.c:325
Fra_Sml_t * Fra_SmlSimulateComb(Aig_Man_t *pAig, int nWords, int fCheckMiter)
Definition: fraSim.c:856
static int Counter
static Aig_Obj_t * Aig_ManCo(Aig_Man_t *p, int i)
Definition: aig.h:267
void Fra_SmlStop(Fra_Sml_t *p)
Definition: fraSim.c:839
Aig_Man_t* Abc_NtkConstructAig ( Mfs_Man_t p,
Abc_Obj_t pNode 
)

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

Synopsis [Creates AIG for the window with constraints.]

Description []

SideEffects []

SeeAlso []

Definition at line 233 of file mfsStrash.c.

234 {
235  Aig_Man_t * pMan;
236  Abc_Obj_t * pFanin;
237  Aig_Obj_t * pObjAig, * pPi, * pPo;
238  Vec_Int_t * vOuts;
239  int i, k, iOut;
240  // start the new manager
241  pMan = Aig_ManStart( 1000 );
242  // construct the root node's AIG cone
243  pObjAig = Abc_NtkConstructAig_rec( p, pNode, pMan );
244 // assert( Aig_ManConst1(pMan) == pObjAig );
245  Aig_ObjCreateCo( pMan, pObjAig );
246  if ( p->pCare )
247  {
248  // mark the care set
250  Vec_PtrForEachEntry( Abc_Obj_t *, p->vSupp, pFanin, i )
251  {
252  pPi = Aig_ManCi( p->pCare, (int)(ABC_PTRUINT_T)pFanin->pData );
253  Aig_ObjSetTravIdCurrent( p->pCare, pPi );
254  pPi->pData = pFanin->pCopy;
255  }
256  // construct the constraints
257  Vec_PtrForEachEntry( Abc_Obj_t *, p->vSupp, pFanin, i )
258  {
259  vOuts = (Vec_Int_t *)Vec_PtrEntry( p->vSuppsInv, (int)(ABC_PTRUINT_T)pFanin->pData );
260  Vec_IntForEachEntry( vOuts, iOut, k )
261  {
262  pPo = Aig_ManCo( p->pCare, iOut );
263  if ( Aig_ObjIsTravIdCurrent( p->pCare, pPo ) )
264  continue;
265  Aig_ObjSetTravIdCurrent( p->pCare, pPo );
266  if ( Aig_ObjFanin0(pPo) == Aig_ManConst1(p->pCare) )
267  continue;
268  pObjAig = Abc_NtkConstructCare_rec( p->pCare, Aig_ObjFanin0(pPo), pMan );
269  if ( pObjAig == NULL )
270  continue;
271  pObjAig = Aig_NotCond( pObjAig, Aig_ObjFaninC0(pPo) );
272  Aig_ObjCreateCo( pMan, pObjAig );
273  }
274  }
275 /*
276  Aig_ManForEachCo( p->pCare, pPo, i )
277  {
278 // assert( Aig_ObjFanin0(pPo) != Aig_ManConst1(p->pCare) );
279  if ( Aig_ObjFanin0(pPo) == Aig_ManConst1(p->pCare) )
280  continue;
281  pObjAig = Abc_NtkConstructCare_rec( p->pCare, Aig_ObjFanin0(pPo), pMan );
282  if ( pObjAig == NULL )
283  continue;
284  pObjAig = Aig_NotCond( pObjAig, Aig_ObjFaninC0(pPo) );
285  Aig_ObjCreateCo( pMan, pObjAig );
286  }
287 */
288  }
289  if ( p->pPars->fResub )
290  {
291  // construct the node
292  pObjAig = (Aig_Obj_t *)pNode->pCopy;
293  Aig_ObjCreateCo( pMan, pObjAig );
294  // construct the divisors
295  Vec_PtrForEachEntry( Abc_Obj_t *, p->vDivs, pFanin, i )
296  {
297  pObjAig = (Aig_Obj_t *)pFanin->pCopy;
298  Aig_ObjCreateCo( pMan, pObjAig );
299  }
300  }
301  else
302  {
303  // construct the fanins
304  Abc_ObjForEachFanin( pNode, pFanin, i )
305  {
306  pObjAig = (Aig_Obj_t *)pFanin->pCopy;
307  Aig_ObjCreateCo( pMan, pObjAig );
308  }
309  }
310  Aig_ManCleanup( pMan );
311  return pMan;
312 }
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
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
static int Aig_ObjIsTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:295
Vec_Ptr_t * vSupp
Definition: mfsInt.h:60
void * pData
Definition: aig.h:87
Mfs_Par_t * pPars
Definition: mfsInt.h:53
Aig_Obj_t * Abc_NtkConstructAig_rec(Mfs_Man_t *p, Abc_Obj_t *pNode, Aig_Man_t *pMan)
Definition: mfsStrash.c:166
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
Aig_Man_t * Aig_ManStart(int nNodesMax)
DECLARATIONS ///.
Definition: aigMan.c:47
Aig_Obj_t * Abc_NtkConstructCare_rec(Aig_Man_t *pCare, Aig_Obj_t *pObj, Aig_Man_t *pMan)
Definition: mfsStrash.c:203
static void Aig_ObjSetTravIdCurrent(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:293
Vec_Ptr_t * vDivs
Definition: mfsInt.h:62
Vec_Ptr_t * vSuppsInv
Definition: mfsInt.h:56
void Aig_ManIncrementTravId(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigUtil.c:44
Abc_Obj_t * pCopy
Definition: abc.h:148
static Aig_Obj_t * Aig_ManCi(Aig_Man_t *p, int i)
Definition: aig.h:266
Definition: aig.h:69
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static Aig_Obj_t * Aig_ManCo(Aig_Man_t *p, int i)
Definition: aig.h:267
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
void * pData
Definition: abc.h:145
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
Aig_Man_t * pCare
Definition: mfsInt.h:55
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265
void Abc_NtkMfsConstructGia ( Mfs_Man_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 120 of file mfsGia.c.

121 {
122  int nBTLimit = 500;
123  // prepare AIG
124  assert( p->pGia == NULL );
125  p->pGia = Gia_ManCreateResubMiter( p->pAigWin );
126  // prepare AIG
127  Gia_ManCreateRefs( p->pGia );
128  Gia_ManCleanMark0( p->pGia );
129  Gia_ManCleanMark1( p->pGia );
130  Gia_ManFillValue ( p->pGia ); // maps nodes into trail ids
131  Gia_ManCleanPhase( p->pGia );
132  // prepare solver
133  p->pTas = Tas_ManAlloc( p->pGia, nBTLimit );
134  p->vCex = Tas_ReadModel( p->pTas );
135  p->vGiaLits = Vec_PtrAlloc( 100 );
136 }
Tas_Man_t * Tas_ManAlloc(Gia_Man_t *pAig, int nBTLimit)
Definition: giaCTas.c:187
void Gia_ManCreateRefs(Gia_Man_t *p)
Definition: giaUtil.c:715
void Gia_ManCleanPhase(Gia_Man_t *p)
Definition: giaUtil.c:431
void Gia_ManCleanMark0(Gia_Man_t *p)
Definition: giaUtil.c:215
void Gia_ManCleanMark1(Gia_Man_t *p)
Definition: giaUtil.c:272
Aig_Man_t * pAigWin
Definition: mfsInt.h:87
void Gia_ManFillValue(Gia_Man_t *p)
Definition: giaUtil.c:328
Vec_Int_t * Tas_ReadModel(Tas_Man_t *p)
Definition: giaCTas.c:250
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define assert(ex)
Definition: util_old.h:213
Gia_Man_t * Gia_ManCreateResubMiter(Aig_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition: mfsGia.c:53
void Abc_NtkMfsDeconstructGia ( Mfs_Man_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 150 of file mfsGia.c.

151 {
152  assert( p->pGia != NULL );
153  Gia_ManStop( p->pGia ); p->pGia = NULL;
154  Tas_ManStop( p->pTas ); p->pTas = NULL;
155  Vec_PtrFree( p->vGiaLits );
156 }
void Gia_ManStop(Gia_Man_t *p)
Definition: giaMan.c:77
void Tas_ManStop(Tas_Man_t *p)
Definition: giaCTas.c:223
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
int Abc_NtkMfsEdgePower ( Mfs_Man_t p,
Abc_Obj_t pNode 
)

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

Synopsis [Evaluates the possibility of replacing given edge by another edge.]

Description []

SideEffects []

SeeAlso []

Definition at line 508 of file mfsResub.c.

509 {
510  Abc_Obj_t * pFanin;
511  int i;
512  // try replacing area critical fanins
513  Abc_ObjForEachFanin( pNode, pFanin, i )
514  {
515  if ( Abc_MfsObjProb(p, pFanin) >= 0.35 )
516  {
517  if ( Abc_NtkMfsSolveSatResub( p, pNode, i, 0, 0 ) )
518  return 1;
519  } else if ( Abc_MfsObjProb(p, pFanin) >= 0.25 ) // sjang
520  {
521  if ( Abc_NtkMfsSolveSatResub( p, pNode, i, 1, 0 ) )
522  return 1;
523  }
524  }
525  return 0;
526 }
static float Abc_MfsObjProb(Mfs_Man_t *p, Abc_Obj_t *pObj)
Definition: mfsInt.h:137
int Abc_NtkMfsSolveSatResub(Mfs_Man_t *p, Abc_Obj_t *pNode, int iFanin, int fOnlyRemove, int fSkipUpdate)
DECLARATIONS ///.
Definition: mfsResub.c:165
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
int Abc_NtkMfsEdgeSwapEval ( Mfs_Man_t p,
Abc_Obj_t pNode 
)

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

Synopsis [Evaluates the possibility of replacing given edge by another edge.]

Description []

SideEffects []

SeeAlso []

Definition at line 488 of file mfsResub.c.

489 {
490  Abc_Obj_t * pFanin;
491  int i;
492  Abc_ObjForEachFanin( pNode, pFanin, i )
493  Abc_NtkMfsSolveSatResub( p, pNode, i, 0, 1 );
494  return 0;
495 }
int Abc_NtkMfsSolveSatResub(Mfs_Man_t *p, Abc_Obj_t *pNode, int iFanin, int fOnlyRemove, int fSkipUpdate)
DECLARATIONS ///.
Definition: mfsResub.c:165
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
Hop_Obj_t* Abc_NtkMfsInterplate ( Mfs_Man_t p,
int *  pCands,
int  nCands 
)

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

Synopsis [Performs interpolation.]

Description [Derives the new function of the node.]

SideEffects []

SeeAlso []

Definition at line 329 of file mfsInter.c.

330 {
331  extern Hop_Obj_t * Kit_GraphToHop( Hop_Man_t * pMan, Kit_Graph_t * pGraph );
332  int fDumpFile = 0;
333  char FileName[32];
334  sat_solver * pSat;
335  Sto_Man_t * pCnf = NULL;
336  unsigned * puTruth;
337  Kit_Graph_t * pGraph;
338  Hop_Obj_t * pFunc;
339  int nFanins, status;
340  int c, i, * pGloVars;
341 // abctime clk = Abc_Clock();
342 // p->nDcMints += Abc_NtkMfsInterplateEval( p, pCands, nCands );
343 
344  // derive the SAT solver for interpolation
345  pSat = Abc_MfsCreateSolverResub( p, pCands, nCands, 0 );
346 
347  // dump CNF file (remember to uncomment two-lit clases in clause_create_new() in 'satSolver.c')
348  if ( fDumpFile )
349  {
350  static int Counter = 0;
351  sprintf( FileName, "cnf\\pj1_if6_mfs%03d.cnf", Counter++ );
352  Sat_SolverWriteDimacs( pSat, FileName, NULL, NULL, 1 );
353  }
354 
355  // solve the problem
356  status = sat_solver_solve( pSat, NULL, NULL, (ABC_INT64_T)p->pPars->nBTLimit, (ABC_INT64_T)0, (ABC_INT64_T)0, (ABC_INT64_T)0 );
357  if ( fDumpFile )
358  printf( "File %s has UNSAT problem with %d conflicts.\n", FileName, (int)pSat->stats.conflicts );
359  if ( status != l_False )
360  {
361  p->nTimeOuts++;
362  return NULL;
363  }
364 //printf( "%d\n", pSat->stats.conflicts );
365 // ABC_PRT( "S", Abc_Clock() - clk );
366  // get the learned clauses
367  pCnf = (Sto_Man_t *)sat_solver_store_release( pSat );
368  sat_solver_delete( pSat );
369 
370  // set the global variables
371  pGloVars = Int_ManSetGlobalVars( p->pMan, nCands );
372  for ( c = 0; c < nCands; c++ )
373  {
374  // get the variable number of this divisor
375  i = lit_var( pCands[c] ) - 2 * p->pCnf->nVars;
376  // get the corresponding SAT variable
377  pGloVars[c] = Vec_IntEntry( p->vProjVarsCnf, i );
378  }
379 
380  // derive the interpolant
381  nFanins = Int_ManInterpolate( p->pMan, pCnf, 0, &puTruth );
382  Sto_ManFree( pCnf );
383  assert( nFanins == nCands );
384 
385  // transform interpolant into AIG
386  pGraph = Kit_TruthToGraph( puTruth, nFanins, p->vMem );
387  pFunc = Kit_GraphToHop( (Hop_Man_t *)p->pNtk->pManFunc, pGraph );
388  Kit_GraphFree( pGraph );
389  return pFunc;
390 }
int Int_ManInterpolate(Int_Man_t *p, Sto_Man_t *pCnf, int fVerbose, unsigned **ppResult)
Definition: satInter.c:1005
sat_solver * Abc_MfsCreateSolverResub(Mfs_Man_t *p, int *pCands, int nCands, int fInvert)
Definition: mfsInter.c:88
int sat_solver_solve(sat_solver *s, lit *begin, lit *end, ABC_INT64_T nConfLimit, ABC_INT64_T nInsLimit, ABC_INT64_T nConfLimitGlobal, ABC_INT64_T nInsLimitGlobal)
Definition: satSolver.c:1700
Mfs_Par_t * pPars
Definition: mfsInt.h:53
static int lit_var(lit l)
Definition: satVec.h:145
int nVars
Definition: cnf.h:59
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
Int_Man_t * pMan
Definition: mfsInt.h:90
void * sat_solver_store_release(sat_solver *s)
Definition: satSolver.c:1949
Vec_Int_t * vMem
Definition: mfsInt.h:91
stats_t stats
Definition: satSolver.h:156
Definition: hop.h:65
void * pManFunc
Definition: abc.h:191
Hop_Obj_t * Kit_GraphToHop(Hop_Man_t *pMan, Kit_Graph_t *pGraph)
Definition: kitHop.c:136
void Kit_GraphFree(Kit_Graph_t *pGraph)
Definition: kitGraph.c:131
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
char * sprintf()
void Sat_SolverWriteDimacs(sat_solver *p, char *pFileName, lit *assumptionsBegin, lit *assumptionsEnd, int incrementVars)
Definition: satUtil.c:71
static int Counter
ABC_INT64_T conflicts
Definition: satVec.h:154
int * Int_ManSetGlobalVars(Int_Man_t *p, int nGloVars)
Definition: satInter.c:133
void Sto_ManFree(Sto_Man_t *p)
Definition: satStore.c:143
Abc_Ntk_t * pNtk
Definition: mfsInt.h:54
#define l_False
Definition: SolverTypes.h:85
#define assert(ex)
Definition: util_old.h:213
Vec_Int_t * vProjVarsCnf
Definition: mfsInt.h:64
Cnf_Dat_t * pCnf
Definition: mfsInt.h:88
Kit_Graph_t * Kit_TruthToGraph(unsigned *pTruth, int nVars, Vec_Int_t *vMemory)
Definition: kitGraph.c:355
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition: hop.h:49
int nTimeOuts
Definition: mfsInt.h:114
int Abc_NtkMfsInterplateEval ( Mfs_Man_t p,
int *  pCands,
int  nCands 
)

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

Synopsis [Performs interpolation.]

Description [Derives the new function of the node.]

SideEffects []

SeeAlso []

Definition at line 285 of file mfsInter.c.

286 {
287  unsigned * pTruth, uTruth0[2], uTruth1[2];
288  int nCounter;
289  pTruth = Abc_NtkMfsInterplateTruth( p, pCands, nCands, 0 );
290  if ( nCands == 6 )
291  {
292  uTruth1[0] = pTruth[0];
293  uTruth1[1] = pTruth[1];
294  }
295  else
296  {
297  uTruth1[0] = pTruth[0];
298  uTruth1[1] = pTruth[0];
299  }
300  pTruth = Abc_NtkMfsInterplateTruth( p, pCands, nCands, 1 );
301  if ( nCands == 6 )
302  {
303  uTruth0[0] = ~pTruth[0];
304  uTruth0[1] = ~pTruth[1];
305  }
306  else
307  {
308  uTruth0[0] = ~pTruth[0];
309  uTruth0[1] = ~pTruth[0];
310  }
311  nCounter = Extra_WordCountOnes( uTruth0[0] ^ uTruth1[0] );
312  nCounter += Extra_WordCountOnes( uTruth0[1] ^ uTruth1[1] );
313 // printf( "%d ", nCounter );
314  return nCounter;
315 }
unsigned * Abc_NtkMfsInterplateTruth(Mfs_Man_t *p, int *pCands, int nCands, int fInvert)
Definition: mfsInter.c:235
static int Extra_WordCountOnes(unsigned uWord)
Definition: extra.h:255
void Abc_NtkMfsPrintResubStats ( Mfs_Man_t p)

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

Synopsis [Prints resub candidate stats.]

Description []

SideEffects []

SeeAlso []

Definition at line 72 of file mfsResub.c.

73 {
74  Abc_Obj_t * pFanin, * pNode;
75  int i, k, nAreaCrits = 0, nAreaExpanse = 0;
76  int nFaninMax = Abc_NtkGetFaninMax(p->pNtk);
77  Abc_NtkForEachNode( p->pNtk, pNode, i )
78  Abc_ObjForEachFanin( pNode, pFanin, k )
79  {
80  if ( !Abc_ObjIsCi(pFanin) && Abc_ObjFanoutNum(pFanin) == 1 )
81  {
82  nAreaCrits++;
83  nAreaExpanse += (int)(Abc_ObjFaninNum(pNode) < nFaninMax);
84  }
85  }
86 // printf( "Total area-critical fanins = %d. Belonging to expandable nodes = %d.\n",
87 // nAreaCrits, nAreaExpanse );
88 }
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
ABC_DLL int Abc_NtkGetFaninMax(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:453
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
Abc_Ntk_t * pNtk
Definition: mfsInt.h:54
int Abc_NtkMfsResubNode ( Mfs_Man_t p,
Abc_Obj_t pNode 
)

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

Synopsis [Performs resubstitution for the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 539 of file mfsResub.c.

540 {
541  Abc_Obj_t * pFanin;
542  int i;
543  // try replacing area critical fanins
544  Abc_ObjForEachFanin( pNode, pFanin, i )
545  if ( !Abc_ObjIsCi(pFanin) && Abc_ObjFanoutNum(pFanin) == 1 )
546  {
547  if ( Abc_NtkMfsSolveSatResub( p, pNode, i, 0, 0 ) )
548  return 1;
549  }
550  // try removing redundant edges
551  if ( !p->pPars->fArea )
552  {
553  Abc_ObjForEachFanin( pNode, pFanin, i )
554  if ( Abc_ObjIsCi(pFanin) || Abc_ObjFanoutNum(pFanin) != 1 )
555  {
556  if ( Abc_NtkMfsSolveSatResub( p, pNode, i, 1, 0 ) )
557  return 1;
558  }
559  }
560  if ( Abc_ObjFaninNum(pNode) == p->nFaninMax )
561  return 0;
562 /*
563  // try replacing area critical fanins while adding two new fanins
564  Abc_ObjForEachFanin( pNode, pFanin, i )
565  if ( !Abc_ObjIsCi(pFanin) && Abc_ObjFanoutNum(pFanin) == 1 )
566  {
567  if ( Abc_NtkMfsSolveSatResub2( p, pNode, i, -1 ) )
568  return 1;
569  }
570 */
571  return 0;
572 }
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
Mfs_Par_t * pPars
Definition: mfsInt.h:53
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
if(last==0)
Definition: sparse_int.h:34
int nFaninMax
Definition: mfsInt.h:57
int Abc_NtkMfsSolveSatResub(Mfs_Man_t *p, Abc_Obj_t *pNode, int iFanin, int fOnlyRemove, int fSkipUpdate)
DECLARATIONS ///.
Definition: mfsResub.c:165
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
int Abc_NtkMfsResubNode2 ( Mfs_Man_t p,
Abc_Obj_t pNode 
)

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

Synopsis [Performs resubstitution for the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 585 of file mfsResub.c.

586 {
587  Abc_Obj_t * pFanin, * pFanin2;
588  int i, k;
589 /*
590  Abc_ObjForEachFanin( pNode, pFanin, i )
591  if ( !Abc_ObjIsCi(pFanin) && Abc_ObjFanoutNum(pFanin) == 1 )
592  {
593  if ( Abc_NtkMfsSolveSatResub( p, pNode, i, 0, 0 ) )
594  return 1;
595  }
596 */
597  if ( Abc_ObjFaninNum(pNode) < 2 )
598  return 0;
599  // try replacing one area critical fanin and one other fanin while adding two new fanins
600  Abc_ObjForEachFanin( pNode, pFanin, i )
601  {
602  if ( !Abc_ObjIsCi(pFanin) && Abc_ObjFanoutNum(pFanin) == 1 )
603  {
604  // consider second fanin to remove at the same time
605  Abc_ObjForEachFanin( pNode, pFanin2, k )
606  {
607  if ( i != k && Abc_NtkMfsSolveSatResub2( p, pNode, i, k ) )
608  return 1;
609  }
610  }
611  }
612  return 0;
613 }
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
int Abc_NtkMfsSolveSatResub2(Mfs_Man_t *p, Abc_Obj_t *pNode, int iFanin, int iFanin2)
Definition: mfsResub.c:319
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
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 }
char * memset()
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition: vecPtr.h:57
Vec_Int_t * vProjVarsSat
Definition: mfsInt.h:65
Mfs_Par_t * pPars
Definition: mfsInt.h:53
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
int * pVarNums
Definition: cnf.h:63
int nMintsCare
Definition: mfsInt.h:110
int nTotConfLim
Definition: mfsInt.h:94
static int Abc_TruthWordNum(int nVars)
Definition: abc_global.h:256
Aig_Man_t * pAigWin
Definition: mfsInt.h:87
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
ABC_NAMESPACE_IMPL_START int Abc_NtkMfsSolveSat_iter(Mfs_Man_t *p)
DECLARATIONS ///.
Definition: mfsSat.c:45
unsigned uCare[(MFS_FANIN_MAX<=5)?1:1<<(MFS_FANIN_MAX-5)]
Definition: mfsInt.h:102
Definition: aig.h:69
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
int nFanins
Definition: mfsInt.h:99
int nWords
Definition: mfsInt.h:100
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
int Id
Definition: abc.h:132
#define assert(ex)
Definition: util_old.h:213
int nCares
Definition: mfsInt.h:101
Cnf_Dat_t * pCnf
Definition: mfsInt.h:88
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
int Id
Definition: aig.h:85
int nMintsTotal
Definition: mfsInt.h:111
int Abc_NtkMfsTryResubOnceGia ( Mfs_Man_t p,
int *  pCands,
int  nCands 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 204 of file mfsGia.c.

205 {
206  int fVeryVerbose = 0;
207  int fUseGia = 1;
208  unsigned * pData;
209  int i, iVar, status, iOut;
210  clock_t clk = clock();
211  p->nSatCalls++;
212 // return -1;
213  assert( p->pGia != NULL );
214  assert( p->pTas != NULL );
215  // convert to literals
216  Vec_PtrClear( p->vGiaLits );
217  // create the first four literals
218  Vec_PtrPush( p->vGiaLits, Gia_ObjChild0(Gia_ManPo(p->pGia, 0)) );
219  Vec_PtrPush( p->vGiaLits, Gia_ObjChild0(Gia_ManPo(p->pGia, 1)) );
220  Vec_PtrPush( p->vGiaLits, Gia_ObjChild0(Gia_ManPo(p->pGia, 2)) );
221  Vec_PtrPush( p->vGiaLits, Gia_ObjChild0(Gia_ManPo(p->pGia, 3)) );
222  for ( i = 0; i < nCands; i++ )
223  {
224  // get the output number
225  iOut = Gia_Lit2Var(pCands[i]) - 2 * p->pCnf->nVars;
226  // write the literal
227  Vec_PtrPush( p->vGiaLits, Gia_ObjChild0(Gia_ManPo(p->pGia, 4 + iOut)) );
228  }
229  // perform SAT solving
230  status = Tas_ManSolveArray( p->pTas, p->vGiaLits );
231  if ( status == -1 )
232  {
233  p->nTimeOuts++;
234  if ( fVeryVerbose )
235  printf( "t" );
236 // p->nSatUndec++;
237 // p->nConfUndec += p->Pars.nBTThis;
238 // Cec_ManSatAddToStore( vCexStore, NULL, i ); // timeout
239 // p->timeSatUndec += clock() - clk;
240  }
241  else if ( status == 1 )
242  {
243  if ( fVeryVerbose )
244  printf( "u" );
245 // p->nSatUnsat++;
246 // p->nConfUnsat += p->Pars.nBTThis;
247 // p->timeSatUnsat += clock() - clk;
248  }
249  else
250  {
251  p->nSatCexes++;
252  if ( fVeryVerbose )
253  printf( "s" );
254 // p->nSatSat++;
255 // p->nConfSat += p->Pars.nBTThis;
256 // Gia_SatVerifyPattern( pAig, pRoot, vCex, vVisit );
257 // Cec_ManSatAddToStore( vCexStore, vCex, i );
258 // p->timeSatSat += clock() - clk;
259 
260  // resimulate the counter-example
261  Abc_NtkMfsResimulate( p->pGia, Tas_ReadModel(p->pTas) );
262 
263  if ( fUseGia )
264  {
265 /*
266  int Val0 = Gia_ManPo(p->pGia, 0)->fMark1;
267  int Val1 = Gia_ManPo(p->pGia, 1)->fMark1;
268  int Val2 = Gia_ManPo(p->pGia, 2)->fMark1;
269  int Val3 = Gia_ManPo(p->pGia, 3)->fMark1;
270  assert( Val0 == 1 );
271  assert( Val1 == 1 );
272  assert( Val2 == 1 );
273  assert( Val3 == 1 );
274 */
275  // store the counter-example
276  Vec_IntForEachEntry( p->vProjVarsSat, iVar, i )
277  {
278  pData = (unsigned *)Vec_PtrEntry( p->vDivCexes, i );
279  iOut = iVar - 2 * p->pCnf->nVars;
280 // if ( !Gia_ManPo( p->pGia, 4 + iOut )->fMark1 ) // remove 0s!!!
281  if ( Gia_ManPo( p->pGia, 4 + iOut )->fMark1 ) // remove 0s!!! - rememeber complemented attribute
282  {
283  assert( Aig_InfoHasBit(pData, p->nCexes) );
284  Aig_InfoXorBit( pData, p->nCexes );
285  }
286  }
287  p->nCexes++;
288  }
289 
290  }
291  return status;
292 }
int Tas_ManSolveArray(Tas_Man_t *p, Vec_Ptr_t *vObjs)
Definition: giaCTas.c:1423
static Gia_Obj_t * Gia_ObjChild0(Gia_Obj_t *pObj)
Definition: gia.h:457
Vec_Int_t * vProjVarsSat
Definition: mfsInt.h:65
static Gia_Obj_t * Gia_ManPo(Gia_Man_t *p, int v)
Definition: gia.h:406
int nVars
Definition: cnf.h:59
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
unsigned fMark1
Definition: gia.h:84
void Abc_NtkMfsResimulate(Gia_Man_t *p, Vec_Int_t *vCex)
Definition: mfsGia.c:169
Vec_Int_t * Tas_ReadModel(Tas_Man_t *p)
Definition: giaCTas.c:250
int nSatCalls
Definition: mfsInt.h:70
Vec_Ptr_t * vDivCexes
Definition: mfsInt.h:67
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
int nCexes
Definition: mfsInt.h:69
int nSatCexes
Definition: mfsInt.h:71
#define assert(ex)
Definition: util_old.h:213
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
Cnf_Dat_t * pCnf
Definition: mfsInt.h:88
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int nTimeOuts
Definition: mfsInt.h:114
Mfs_Man_t* Mfs_ManAlloc ( Mfs_Par_t pPars)

DECLARATIONS ///.

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

FileName [mfsMan.c]

SystemName [ABC: Logic synthesis and verification system.]

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

Synopsis [Procedures working with the manager.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file mfsMan.c.

46 {
47  Mfs_Man_t * p;
48  // start the manager
49  p = ABC_ALLOC( Mfs_Man_t, 1 );
50  memset( p, 0, sizeof(Mfs_Man_t) );
51  p->pPars = pPars;
52  p->vProjVarsCnf = Vec_IntAlloc( 100 );
53  p->vProjVarsSat = Vec_IntAlloc( 100 );
54  p->vDivLits = Vec_IntAlloc( 100 );
55  p->nDivWords = Abc_BitWordNum(p->pPars->nWinMax + MFS_FANIN_MAX);
56  p->vDivCexes = Vec_PtrAllocSimInfo( p->pPars->nWinMax + MFS_FANIN_MAX + 1, p->nDivWords );
57  p->pMan = Int_ManAlloc();
58  p->vMem = Vec_IntAlloc( 0 );
59  p->vLevels = Vec_VecStart( 32 );
60  p->vMfsFanins= Vec_PtrAlloc( 32 );
61  return p;
62 }
char * memset()
Vec_Int_t * vProjVarsSat
Definition: mfsInt.h:65
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Mfs_Par_t * pPars
Definition: mfsInt.h:53
Int_Man_t * pMan
Definition: mfsInt.h:90
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Vec_Int_t * vMem
Definition: mfsInt.h:91
Int_Man_t * Int_ManAlloc()
FUNCTION DEFINITIONS ///.
Definition: satInter.c:107
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
static Vec_Vec_t * Vec_VecStart(int nSize)
Definition: vecVec.h:168
int nDivWords
Definition: mfsInt.h:68
Vec_Ptr_t * vDivCexes
Definition: mfsInt.h:67
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
Vec_Ptr_t * vMfsFanins
Definition: mfsInt.h:93
static int Abc_BitWordNum(int nBits)
Definition: abc_global.h:255
Vec_Int_t * vProjVarsCnf
Definition: mfsInt.h:64
Vec_Vec_t * vLevels
Definition: mfsInt.h:92
Vec_Int_t * vDivLits
Definition: mfsInt.h:63
static Vec_Ptr_t * Vec_PtrAllocSimInfo(int nEntries, int nWords)
Definition: vecPtr.h:929
#define MFS_FANIN_MAX
INCLUDES ///.
Definition: mfsInt.h:47
void Mfs_ManClean ( Mfs_Man_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 75 of file mfsMan.c.

76 {
77  if ( p->pAigWin )
78  Aig_ManStop( p->pAigWin );
79  if ( p->pCnf )
80  Cnf_DataFree( p->pCnf );
81  if ( p->pSat )
82  sat_solver_delete( p->pSat );
83  if ( p->vRoots )
84  Vec_PtrFree( p->vRoots );
85  if ( p->vSupp )
86  Vec_PtrFree( p->vSupp );
87  if ( p->vNodes )
88  Vec_PtrFree( p->vNodes );
89  if ( p->vDivs )
90  Vec_PtrFree( p->vDivs );
91  p->pAigWin = NULL;
92  p->pCnf = NULL;
93  p->pSat = NULL;
94  p->vRoots = NULL;
95  p->vSupp = NULL;
96  p->vNodes = NULL;
97  p->vDivs = NULL;
98 }
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
Vec_Ptr_t * vSupp
Definition: mfsInt.h:60
Vec_Ptr_t * vRoots
Definition: mfsInt.h:59
void sat_solver_delete(sat_solver *s)
Definition: satSolver.c:1141
Vec_Ptr_t * vNodes
Definition: mfsInt.h:61
Vec_Ptr_t * vDivs
Definition: mfsInt.h:62
Aig_Man_t * pAigWin
Definition: mfsInt.h:87
void Cnf_DataFree(Cnf_Dat_t *p)
Definition: cnfMan.c:180
sat_solver * pSat
Definition: mfsInt.h:89
Cnf_Dat_t * pCnf
Definition: mfsInt.h:88
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Mfs_ManStop ( Mfs_Man_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 170 of file mfsMan.c.

171 {
172  if ( p->pPars->fVerbose )
173  Mfs_ManPrint( p );
174  if ( p->vTruth )
175  Vec_IntFree( p->vTruth );
176  if ( p->pManDec )
177  Bdc_ManFree( p->pManDec );
178  if ( p->pCare )
179  Aig_ManStop( p->pCare );
180  if ( p->vSuppsInv )
182  if ( p->vProbs )
183  Vec_IntFree( p->vProbs );
184  Mfs_ManClean( p );
185  Int_ManFree( p->pMan );
186  Vec_IntFree( p->vMem );
187  Vec_VecFree( p->vLevels );
188  Vec_PtrFree( p->vMfsFanins );
191  Vec_IntFree( p->vDivLits );
192  Vec_PtrFree( p->vDivCexes );
193  ABC_FREE( p );
194 }
Vec_Int_t * vProbs
Definition: mfsInt.h:97
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
Vec_Int_t * vProjVarsSat
Definition: mfsInt.h:65
void Aig_ManStop(Aig_Man_t *p)
Definition: aigMan.c:187
Mfs_Par_t * pPars
Definition: mfsInt.h:53
Int_Man_t * pMan
Definition: mfsInt.h:90
Bdc_Man_t * pManDec
Definition: mfsInt.h:82
Vec_Int_t * vMem
Definition: mfsInt.h:91
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
Vec_Ptr_t * vSuppsInv
Definition: mfsInt.h:56
void Mfs_ManPrint(Mfs_Man_t *p)
Definition: mfsMan.c:111
void Mfs_ManClean(Mfs_Man_t *p)
Definition: mfsMan.c:75
Vec_Ptr_t * vDivCexes
Definition: mfsInt.h:67
void Int_ManFree(Int_Man_t *p)
Definition: satInter.c:273
#define ABC_FREE(obj)
Definition: abc_global.h:232
Vec_Ptr_t * vMfsFanins
Definition: mfsInt.h:93
Vec_Int_t * vProjVarsCnf
Definition: mfsInt.h:64
void Bdc_ManFree(Bdc_Man_t *p)
Definition: bdcCore.c:113
Aig_Man_t * pCare
Definition: mfsInt.h:55
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Vec_Vec_t * vLevels
Definition: mfsInt.h:92
Vec_Int_t * vTruth
Definition: mfsInt.h:81
Vec_Int_t * vDivLits
Definition: mfsInt.h:63
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223