abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sfmInt.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "misc/vec/vec.h"
#include "sat/bsat/satSolver.h"
#include "sfm.h"

Go to the source code of this file.

Data Structures

struct  Sfm_Ntk_t_
 BASIC TYPES ///. More...
 

Macros

#define SFM_FANIN_MAX   6
 INCLUDES ///. More...
 
#define SFM_SAT_UNDEC   0x1234567812345678
 
#define SFM_SAT_SAT   0x8765432187654321
 
#define Sfm_NtkForEachPi(p, i)   for ( i = 0; i < p->nPis; i++ )
 MACRO DEFINITIONS ///. More...
 
#define Sfm_NtkForEachPo(p, i)   for ( i = p->nObjs - p->nPos; i < p->nObjs; i++ )
 
#define Sfm_NtkForEachNode(p, i)   for ( i = p->nPis; i + p->nPos < p->nObjs; i++ )
 
#define Sfm_NtkForEachNodeReverse(p, i)   for ( i = p->nObjs - p->nPos - 1; i >= p->nPis; i-- )
 
#define Sfm_ObjForEachFanin(p, Node, Fan, i)   for ( i = 0; i < Sfm_ObjFaninNum(p, Node) && ((Fan = Sfm_ObjFanin(p, Node, i)), 1); i++ )
 
#define Sfm_ObjForEachFanout(p, Node, Fan, i)   for ( i = 0; i < Sfm_ObjFanoutNum(p, Node) && ((Fan = Sfm_ObjFanout(p, Node, i)), 1); i++ )
 

Functions

static int Sfm_NtkPiNum (Sfm_Ntk_t *p)
 
static int Sfm_NtkPoNum (Sfm_Ntk_t *p)
 
static int Sfm_NtkNodeNum (Sfm_Ntk_t *p)
 
static int Sfm_ObjIsPi (Sfm_Ntk_t *p, int i)
 
static int Sfm_ObjIsPo (Sfm_Ntk_t *p, int i)
 
static int Sfm_ObjIsNode (Sfm_Ntk_t *p, int i)
 
static int Sfm_ObjIsFixed (Sfm_Ntk_t *p, int i)
 
static int Sfm_ObjAddsLevelArray (Vec_Str_t *p, int i)
 
static int Sfm_ObjAddsLevel (Sfm_Ntk_t *p, int i)
 
static Vec_Int_tSfm_ObjFiArray (Sfm_Ntk_t *p, int i)
 
static Vec_Int_tSfm_ObjFoArray (Sfm_Ntk_t *p, int i)
 
static int Sfm_ObjFaninNum (Sfm_Ntk_t *p, int i)
 
static int Sfm_ObjFanoutNum (Sfm_Ntk_t *p, int i)
 
static int Sfm_ObjRefIncrement (Sfm_Ntk_t *p, int iObj)
 
static int Sfm_ObjRefDecrement (Sfm_Ntk_t *p, int iObj)
 
static int Sfm_ObjFanin (Sfm_Ntk_t *p, int i, int k)
 
static int Sfm_ObjFanout (Sfm_Ntk_t *p, int i, int k)
 
static int Sfm_ObjSatVar (Sfm_Ntk_t *p, int iObj)
 
static void Sfm_ObjSetSatVar (Sfm_Ntk_t *p, int iObj, int Num)
 
static void Sfm_ObjCleanSatVar (Sfm_Ntk_t *p, int Num)
 
static void Sfm_NtkCleanVars (Sfm_Ntk_t *p)
 
static int Sfm_ObjLevel (Sfm_Ntk_t *p, int iObj)
 
static void Sfm_ObjSetLevel (Sfm_Ntk_t *p, int iObj, int Lev)
 
static int Sfm_ObjLevelR (Sfm_Ntk_t *p, int iObj)
 
static void Sfm_ObjSetLevelR (Sfm_Ntk_t *p, int iObj, int Lev)
 
static int Sfm_ObjUpdateFaninCount (Sfm_Ntk_t *p, int iObj)
 
static void Sfm_ObjResetFaninCount (Sfm_Ntk_t *p, int iObj)
 
void Kit_DsdPrintFromTruth (unsigned *pTruth, int nVars)
 
void Sfm_PrintCnf (Vec_Str_t *vCnf)
 FUNCTION DECLARATIONS ///. More...
 
int Sfm_TruthToCnf (word Truth, int nVars, Vec_Int_t *vCover, Vec_Str_t *vCnf)
 
Vec_Wec_tSfm_CreateCnf (Sfm_Ntk_t *p)
 
void Sfm_TranslateCnf (Vec_Wec_t *vRes, Vec_Str_t *vCnf, Vec_Int_t *vFaninMap, int iPivotVar)
 
Sfm_Ntk_tSfm_ConstructNetwork (Vec_Wec_t *vFanins, int nPis, int nPos)
 
void Sfm_NtkPrepare (Sfm_Ntk_t *p)
 
void Sfm_NtkUpdate (Sfm_Ntk_t *p, int iNode, int f, int iFaninNew, word uTruth)
 
int Sfm_NtkWindowToSolver (Sfm_Ntk_t *p)
 FUNCTION DEFINITIONS ///. More...
 
word Sfm_ComputeInterpolant (Sfm_Ntk_t *p)
 
int Sfm_ObjMffcSize (Sfm_Ntk_t *p, int iObj)
 
int Sfm_NtkCreateWindow (Sfm_Ntk_t *p, int iNode, int fVerbose)
 

Macro Definition Documentation

#define SFM_FANIN_MAX   6

INCLUDES ///.

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

FileName [rsbInt.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [SAT-based optimization using internal don't-cares.]

Synopsis [Internal declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

]PARAMETERS ///

Definition at line 44 of file sfmInt.h.

#define Sfm_NtkForEachNode (   p,
 
)    for ( i = p->nPis; i + p->nPos < p->nObjs; i++ )

Definition at line 170 of file sfmInt.h.

#define Sfm_NtkForEachNodeReverse (   p,
 
)    for ( i = p->nObjs - p->nPos - 1; i >= p->nPis; i-- )

Definition at line 171 of file sfmInt.h.

#define Sfm_NtkForEachPi (   p,
 
)    for ( i = 0; i < p->nPis; i++ )

MACRO DEFINITIONS ///.

Definition at line 168 of file sfmInt.h.

#define Sfm_NtkForEachPo (   p,
 
)    for ( i = p->nObjs - p->nPos; i < p->nObjs; i++ )

Definition at line 169 of file sfmInt.h.

#define Sfm_ObjForEachFanin (   p,
  Node,
  Fan,
 
)    for ( i = 0; i < Sfm_ObjFaninNum(p, Node) && ((Fan = Sfm_ObjFanin(p, Node, i)), 1); i++ )

Definition at line 172 of file sfmInt.h.

#define Sfm_ObjForEachFanout (   p,
  Node,
  Fan,
 
)    for ( i = 0; i < Sfm_ObjFanoutNum(p, Node) && ((Fan = Sfm_ObjFanout(p, Node, i)), 1); i++ )

Definition at line 173 of file sfmInt.h.

#define SFM_SAT_SAT   0x8765432187654321

Definition at line 46 of file sfmInt.h.

#define SFM_SAT_UNDEC   0x1234567812345678

Definition at line 45 of file sfmInt.h.

Function Documentation

void Kit_DsdPrintFromTruth ( unsigned *  pTruth,
int  nVars 
)

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

Synopsis [Print the DSD formula.]

Description []

SideEffects []

SeeAlso []

Definition at line 490 of file kitDsd.c.

491 {
492  Kit_DsdNtk_t * pTemp, * pTemp2;
493 // pTemp = Kit_DsdDecomposeMux( pTruth, nVars, 5 );
494  pTemp = Kit_DsdDecomposeMux( pTruth, nVars, 8 );
495 // Kit_DsdPrintExpanded( pTemp );
496  pTemp2 = Kit_DsdExpand( pTemp );
497  Kit_DsdPrint( stdout, pTemp2 );
498  Kit_DsdVerify( pTemp2, pTruth, nVars );
499  Kit_DsdNtkFree( pTemp2 );
500  Kit_DsdNtkFree( pTemp );
501 }
Kit_DsdNtk_t * Kit_DsdExpand(Kit_DsdNtk_t *p)
Definition: kitDsd.c:1451
void Kit_DsdVerify(Kit_DsdNtk_t *pNtk, unsigned *pTruth, int nVars)
Definition: kitDsd.c:2492
void Kit_DsdPrint(FILE *pFile, Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:374
void Kit_DsdNtkFree(Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:163
Kit_DsdNtk_t * Kit_DsdDecomposeMux(unsigned *pTruth, int nVars, int nDecMux)
Definition: kitDsd.c:2350
word Sfm_ComputeInterpolant ( Sfm_Ntk_t p)

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

Synopsis [Takes SAT solver and returns interpolant.]

Description [If interpolant does not exist, records difference variables.]

SideEffects []

SeeAlso []

Definition at line 162 of file sfmSat.c.

163 {
164  word * pSign, uCube, uTruth = 0;
165  int status, i, Div, iVar, nFinal, * pFinal, nIter = 0;
166  int pLits[2], nVars = sat_solver_nvars( p->pSat );
167  sat_solver_setnvars( p->pSat, nVars + 1 );
168  pLits[0] = Abc_Var2Lit( Sfm_ObjSatVar(p, p->iPivotNode), 0 ); // F = 1
169  pLits[1] = Abc_Var2Lit( nVars, 0 ); // iNewLit
170  while ( 1 )
171  {
172  // find onset minterm
173  p->nSatCalls++;
174  status = sat_solver_solve( p->pSat, pLits, pLits + 2, p->pPars->nBTLimit, 0, 0, 0 );
175  if ( status == l_Undef )
176  return SFM_SAT_UNDEC;
177  if ( status == l_False )
178  return uTruth;
179  assert( status == l_True );
180  // remember variable values
181  Vec_IntClear( p->vValues );
182  Vec_IntForEachEntry( p->vDivVars, iVar, i )
183  Vec_IntPush( p->vValues, sat_solver_var_value(p->pSat, iVar) );
184  // collect divisor literals
185  Vec_IntClear( p->vLits );
186  Vec_IntPush( p->vLits, Abc_LitNot(pLits[0]) ); // F = 0
187  Vec_IntForEachEntry( p->vDivIds, Div, i )
188  Vec_IntPush( p->vLits, sat_solver_var_literal(p->pSat, Div) );
189  // check against offset
190  p->nSatCalls++;
191  status = sat_solver_solve( p->pSat, Vec_IntArray(p->vLits), Vec_IntArray(p->vLits) + Vec_IntSize(p->vLits), p->pPars->nBTLimit, 0, 0, 0 );
192  if ( status == l_Undef )
193  return SFM_SAT_UNDEC;
194  if ( status == l_True )
195  break;
196  assert( status == l_False );
197  // compute cube and add clause
198  nFinal = sat_solver_final( p->pSat, &pFinal );
199  uCube = ~(word)0;
200  Vec_IntClear( p->vLits );
201  Vec_IntPush( p->vLits, Abc_LitNot(pLits[1]) ); // NOT(iNewLit)
202  for ( i = 0; i < nFinal; i++ )
203  {
204  if ( pFinal[i] == pLits[0] )
205  continue;
206  Vec_IntPush( p->vLits, pFinal[i] );
207  iVar = Vec_IntFind( p->vDivIds, Abc_Lit2Var(pFinal[i]) ); assert( iVar >= 0 );
208  uCube &= Abc_LitIsCompl(pFinal[i]) ? s_Truths6[iVar] : ~s_Truths6[iVar];
209  }
210  uTruth |= uCube;
211  status = sat_solver_addclause( p->pSat, Vec_IntArray(p->vLits), Vec_IntArray(p->vLits) + Vec_IntSize(p->vLits) );
212  assert( status );
213  nIter++;
214  }
215  assert( status == l_True );
216  // store the counter-example
217  Vec_IntForEachEntry( p->vDivVars, iVar, i )
218  if ( Vec_IntEntry(p->vValues, i) ^ sat_solver_var_value(p->pSat, iVar) ) // insert 1
219  {
220  pSign = Vec_WrdEntryP( p->vDivCexes, i );
221  assert( !Abc_InfoHasBit( (unsigned *)pSign, p->nCexes) );
222  Abc_InfoXorBit( (unsigned *)pSign, p->nCexes );
223  }
224  p->nCexes++;
225  return SFM_SAT_SAT;
226 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
static ABC_NAMESPACE_IMPL_START word s_Truths6[6]
DECLARATIONS ///.
Definition: sfmSat.c:30
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
static int Abc_InfoHasBit(unsigned *p, int i)
Definition: abc_global.h:258
#define l_Undef
Definition: SolverTypes.h:86
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
static void Abc_InfoXorBit(unsigned *p, int i)
Definition: abc_global.h:260
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
static int Vec_IntFind(Vec_Int_t *p, int Entry)
Definition: vecInt.h:895
#define l_True
Definition: SolverTypes.h:84
for(p=first;p->value< newval;p=p->next)
static int sat_solver_var_value(sat_solver *s, int v)
Definition: satSolver.h:200
static int sat_solver_final(sat_solver *s, int **ppArray)
Definition: satSolver.h:227
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static int Sfm_ObjSatVar(Sfm_Ntk_t *p, int iObj)
Definition: sfmInt.h:148
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
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
int sat_solver_nvars(sat_solver *s)
Definition: satSolver.c:1896
if(last==0)
Definition: sparse_int.h:34
#define SFM_SAT_SAT
Definition: sfmInt.h:46
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Abc_LitNot(int Lit)
Definition: abc_global.h:266
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int sat_solver_var_literal(sat_solver *s, int v)
Definition: satSolver.h:205
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
#define l_False
Definition: SolverTypes.h:85
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
#define SFM_SAT_UNDEC
Definition: sfmInt.h:45
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static word * Vec_WrdEntryP(Vec_Wrd_t *p, int i)
Definition: vecWrd.h:401
Sfm_Ntk_t* Sfm_ConstructNetwork ( Vec_Wec_t vFanins,
int  nPis,
int  nPos 
)
Vec_Wec_t* Sfm_CreateCnf ( Sfm_Ntk_t p)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 122 of file sfmCnf.c.

123 {
124  Vec_Wec_t * vCnfs;
125  Vec_Str_t * vCnf, * vCnfBase;
126  word uTruth;
127  int i, nCubes;
128  vCnf = Vec_StrAlloc( 100 );
129  vCnfs = Vec_WecStart( p->nObjs );
130  Vec_WrdForEachEntryStartStop( p->vTruths, uTruth, i, p->nPis, Vec_WrdSize(p->vTruths)-p->nPos )
131  {
132  nCubes = Sfm_TruthToCnf( uTruth, Sfm_ObjFaninNum(p, i), p->vCover, vCnf );
133  vCnfBase = (Vec_Str_t *)Vec_WecEntry( vCnfs, i );
134  Vec_StrGrow( vCnfBase, Vec_StrSize(vCnf) );
135  memcpy( Vec_StrArray(vCnfBase), Vec_StrArray(vCnf), Vec_StrSize(vCnf) );
136  vCnfBase->nSize = Vec_StrSize(vCnf);
137  }
138  Vec_StrFree( vCnf );
139  return vCnfs;
140 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
Definition: vecWec.h:42
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static char * Vec_StrArray(Vec_Str_t *p)
Definition: vecStr.h:272
static Vec_Wec_t * Vec_WecStart(int nSize)
Definition: vecWec.h:98
static int Sfm_ObjFaninNum(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:139
char * memcpy()
static Vec_Str_t * Vec_StrAlloc(int nCap)
Definition: bblif.c:495
static int Vec_WrdSize(Vec_Wrd_t *p)
Definition: vecWrd.h:336
static void Vec_StrGrow(Vec_Str_t *p, int nCapMin)
Definition: vecStr.h:404
#define Vec_WrdForEachEntryStartStop(vVec, Entry, i, Start, Stop)
Definition: vecWrd.h:60
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
static Vec_Int_t * Vec_WecEntry(Vec_Wec_t *p, int i)
Definition: vecWec.h:142
static int Vec_StrSize(Vec_Str_t *p)
Definition: bblif.c:600
int Sfm_TruthToCnf(word Truth, int nVars, Vec_Int_t *vCover, Vec_Str_t *vCnf)
Definition: sfmCnf.c:71
int nSize
Definition: bblif.c:50
static void Sfm_NtkCleanVars ( Sfm_Ntk_t p)
inlinestatic

Definition at line 151 of file sfmInt.h.

151 { int i; for ( i = 1; i < p->nSatVars; i++ ) if ( Vec_IntEntry(&p->vVar2Id, i) != -1 ) Sfm_ObjCleanSatVar( p, i ); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Sfm_ObjCleanSatVar(Sfm_Ntk_t *p, int Num)
Definition: sfmInt.h:150
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
int Sfm_NtkCreateWindow ( Sfm_Ntk_t p,
int  iNode,
int  fVerbose 
)

Definition at line 334 of file sfmWin.c.

335 {
336  int i, k, iTemp;
337  abctime clkDiv, clkWin = Abc_Clock();
338 
339  assert( Sfm_ObjIsNode( p, iNode ) );
340  p->iPivotNode = iNode;
341  Vec_IntClear( p->vNodes ); // internal
342  Vec_IntClear( p->vDivs ); // divisors
343  Vec_IntClear( p->vRoots ); // roots
344  Vec_IntClear( p->vTfo ); // roots
345  Vec_IntClear( p->vOrder ); // variable order
346 
347  // collect transitive fanin
349  if ( Sfm_NtkCollectTfi_rec( p, iNode, p->vNodes ) )
350  {
351  p->nMaxDivs++;
352  p->timeWin += Abc_Clock() - clkWin;
353  return 0;
354  }
355 
356  // create divisors
357  clkDiv = Abc_Clock();
358  Vec_IntClear( p->vDivs );
359  Vec_IntAppend( p->vDivs, p->vNodes );
360  Vec_IntPop( p->vDivs );
361  // add non-topological divisors
362  if ( Vec_IntSize(p->vDivs) < p->pPars->nWinSizeMax + 0 )
363  {
365  Vec_IntForEachEntry( p->vDivs, iTemp, i )
366  if ( Vec_IntSize(p->vDivs) < p->pPars->nWinSizeMax + 0 )
367 // Sfm_NtkAddDivisors( p, iTemp, Sfm_ObjLevel(p, iNode) - 1 );
368  Sfm_NtkAddDivisors( p, iTemp, p->nLevelMax - Sfm_ObjLevelR(p, iNode) );
369  }
370  if ( Vec_IntSize(p->vDivs) > p->pPars->nWinSizeMax )
371  {
372 /*
373  k = 0;
374  Vec_IntForEachEntryStart( p->vDivs, iTemp, i, Vec_IntSize(p->vDivs) - p->pPars->nWinSizeMax )
375  Vec_IntWriteEntry( p->vDivs, k++, iTemp );
376  assert( k == p->pPars->nWinSizeMax );
377 */
378  Vec_IntShrink( p->vDivs, p->pPars->nWinSizeMax );
379  }
380  assert( Vec_IntSize(p->vDivs) <= p->pPars->nWinSizeMax );
381  p->nMaxDivs += (int)(Vec_IntSize(p->vDivs) == p->pPars->nWinSizeMax);
382  // remove node/fanins from divisors
383  // mark fanins
385  Sfm_ObjSetTravIdCurrent2( p, iNode );
386  Sfm_ObjForEachFanin( p, iNode, iTemp, i )
387  Sfm_ObjSetTravIdCurrent2( p, iTemp );
388  // compact divisors
389  k = 0;
390  Vec_IntForEachEntry( p->vDivs, iTemp, i )
391  if ( !Sfm_ObjIsTravIdCurrent2(p, iTemp) && Sfm_ObjIsUseful(p, iTemp) )
392  Vec_IntWriteEntry( p->vDivs, k++, iTemp );
393  Vec_IntShrink( p->vDivs, k );
394  assert( Vec_IntSize(p->vDivs) <= p->pPars->nWinSizeMax );
395  clkDiv = Abc_Clock() - clkDiv;
396  p->timeDiv += clkDiv;
397  p->nTotalDivs += Vec_IntSize(p->vDivs);
398 
399  // collect TFO and window roots
400  if ( p->pPars->nTfoLevMax > 0 && !Sfm_NtkCheckRoot(p, iNode, Sfm_ObjLevel(p, iNode) + p->pPars->nTfoLevMax) )
401  {
402  // explore transitive fanout
404  Sfm_NtkComputeRoots_rec( p, iNode, Sfm_ObjLevel(p, iNode) + p->pPars->nTfoLevMax, p->vRoots, p->vTfo );
405  assert( Vec_IntSize(p->vRoots) > 0 );
406  assert( Vec_IntSize(p->vTfo) > 0 );
407  // compute new leaves and nodes
409  Vec_IntForEachEntry( p->vRoots, iTemp, i )
410  if ( Sfm_NtkCollectTfi_rec( p, iTemp, p->vOrder ) )
411  {
412  Vec_IntClear( p->vRoots );
413  Vec_IntClear( p->vTfo );
414  Vec_IntClear( p->vOrder );
415  break;
416  }
417  if ( Vec_IntSize(p->vRoots) > 0 )
418  Vec_IntForEachEntry( p->vTfo, iTemp, i )
419  if ( Sfm_NtkCollectTfi_rec( p, iTemp, p->vOrder ) )
420  {
421  Vec_IntClear( p->vRoots );
422  Vec_IntClear( p->vTfo );
423  Vec_IntClear( p->vOrder );
424  break;
425  }
426  if ( Vec_IntSize(p->vRoots) > 0 )
427  Vec_IntForEachEntry( p->vDivs, iTemp, i )
428  if ( Sfm_NtkCollectTfi_rec( p, iTemp, p->vOrder ) )
429  {
430  Vec_IntClear( p->vRoots );
431  Vec_IntClear( p->vTfo );
432  Vec_IntClear( p->vOrder );
433  break;
434  }
435  }
436 
437  if ( Vec_IntSize(p->vOrder) == 0 )
438  {
439  int Temp = p->pPars->nWinSizeMax;
440  p->pPars->nWinSizeMax = 0;
442  Sfm_NtkCollectTfi_rec( p, iNode, p->vOrder );
443  Vec_IntForEachEntry( p->vDivs, iTemp, i )
444  Sfm_NtkCollectTfi_rec( p, iTemp, p->vOrder );
445  p->pPars->nWinSizeMax = Temp;
446  }
447 
448  // statistics
449  p->timeWin += Abc_Clock() - clkWin - clkDiv;
450  if ( !fVerbose )
451  return 1;
452 
453  // print stats about the window
454  printf( "%6d : ", iNode );
455  printf( "Leaves = %5d. ", 0 );
456  printf( "Nodes = %5d. ", Vec_IntSize(p->vNodes) );
457  printf( "Roots = %5d. ", Vec_IntSize(p->vRoots) );
458  printf( "Divs = %5d. ", Vec_IntSize(p->vDivs) );
459  printf( "\n" );
460  return 1;
461 }
static int Sfm_ObjIsUseful(Sfm_Ntk_t *p, int iNode)
Definition: sfmWin.c:300
#define Sfm_ObjForEachFanin(p, Node, Fan, i)
Definition: sfmInt.h:172
void Sfm_NtkComputeRoots_rec(Sfm_Ntk_t *p, int iNode, int nLevelMax, Vec_Int_t *vRoots, Vec_Int_t *vTfo)
Definition: sfmWin.c:234
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Sfm_ObjIsTravIdCurrent2(Sfm_Ntk_t *p, int Id)
Definition: sfmWin.c:121
Vec_Ptr_t * vRoots
Definition: llb3Image.c:51
void Sfm_NtkAddDivisors(Sfm_Ntk_t *p, int iNode, int nLevelMax)
Definition: sfmWin.c:262
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Sfm_ObjIsNode(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:131
static void Sfm_NtkIncrementTravId2(Sfm_Ntk_t *p)
Definition: sfmWin.c:119
static int Sfm_ObjLevel(Sfm_Ntk_t *p, int iObj)
Definition: sfmInt.h:153
static int Sfm_NtkCheckRoot(Sfm_Ntk_t *p, int iNode, int nLevelMax)
Definition: sfmWin.c:220
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
if(last==0)
Definition: sparse_int.h:34
static int Vec_IntPop(Vec_Int_t *p)
static void Vec_IntAppend(Vec_Int_t *vVec1, Vec_Int_t *vVec2)
static void Sfm_NtkIncrementTravId(Sfm_Ntk_t *p)
Definition: sfmWin.c:114
static int Sfm_ObjLevelR(Sfm_Ntk_t *p, int iObj)
Definition: sfmInt.h:156
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static void Vec_IntShrink(Vec_Int_t *p, int nSizeNew)
Definition: bblif.c:435
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
ABC_INT64_T abctime
Definition: abc_global.h:278
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
int Sfm_NtkCollectTfi_rec(Sfm_Ntk_t *p, int iNode, Vec_Int_t *vNodes)
Definition: sfmWin.c:322
static void Sfm_ObjSetTravIdCurrent2(Sfm_Ntk_t *p, int Id)
Definition: sfmWin.c:120
static int Sfm_NtkNodeNum ( Sfm_Ntk_t p)
inlinestatic

Definition at line 127 of file sfmInt.h.

127 { return p->nObjs - p->nPis - p->nPos; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Sfm_NtkPiNum ( Sfm_Ntk_t p)
inlinestatic

Definition at line 125 of file sfmInt.h.

125 { return p->nPis; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Sfm_NtkPoNum ( Sfm_Ntk_t p)
inlinestatic

Definition at line 126 of file sfmInt.h.

126 { return p->nPos; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Sfm_NtkPrepare ( Sfm_Ntk_t p)

Definition at line 195 of file sfmNtk.c.

196 {
197  p->nLevelMax = Vec_IntFindMax(&p->vLevels) + p->pPars->nGrowthLevel;
198  p->vNodes = Vec_IntAlloc( 1000 );
199  p->vDivs = Vec_IntAlloc( 100 );
200  p->vRoots = Vec_IntAlloc( 1000 );
201  p->vTfo = Vec_IntAlloc( 1000 );
202  p->vDivCexes = Vec_WrdStart( p->pPars->nWinSizeMax );
203  p->vOrder = Vec_IntAlloc( 100 );
204  p->vDivVars = Vec_IntAlloc( 100 );
205  p->vDivIds = Vec_IntAlloc( 1000 );
206  p->vLits = Vec_IntAlloc( 100 );
207  p->vValues = Vec_IntAlloc( 100 );
208  p->vClauses = Vec_WecAlloc( 100 );
209  p->vFaninMap = Vec_IntAlloc( 10 );
210  p->pSat = sat_solver_new();
211  sat_solver_setnvars( p->pSat, p->pPars->nWinSizeMax );
212 }
static Vec_Wec_t * Vec_WecAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecWec.h:87
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Vec_Ptr_t * vRoots
Definition: llb3Image.c:51
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
void sat_solver_setnvars(sat_solver *s, int n)
Definition: satSolver.c:1072
static int Vec_IntFindMax(Vec_Int_t *p)
Definition: vecInt.h:996
static Vec_Wrd_t * Vec_WrdStart(int nSize)
Definition: vecWrd.h:103
sat_solver * sat_solver_new(void)
Definition: satSolver.c:1001
void Sfm_NtkUpdate ( Sfm_Ntk_t p,
int  iNode,
int  f,
int  iFaninNew,
word  uTruth 
)

Definition at line 314 of file sfmNtk.c.

315 {
316  int iFanin = Sfm_ObjFanin( p, iNode, f );
317  assert( Sfm_ObjIsNode(p, iNode) );
318  assert( iFanin != iFaninNew );
319  if ( uTruth == 0 || ~uTruth == 0 )
320  {
321  Sfm_ObjForEachFanin( p, iNode, iFanin, f )
322  {
323  int RetValue = Vec_IntRemove( Sfm_ObjFoArray(p, iFanin), iNode ); assert( RetValue );
324  Sfm_NtkDeleteObj_rec( p, iFanin );
325  }
326  Vec_IntClear( Sfm_ObjFiArray(p, iNode) );
327  }
328  else
329  {
330  // replace old fanin by new fanin
331  Sfm_NtkRemoveFanin( p, iNode, iFanin );
332  Sfm_NtkAddFanin( p, iNode, iFaninNew );
333  // recursively remove MFFC
334  Sfm_NtkDeleteObj_rec( p, iFanin );
335  }
336  // update logic level
337  Sfm_NtkUpdateLevel_rec( p, iNode );
338  if ( iFaninNew != -1 )
339  Sfm_NtkUpdateLevelR_rec( p, iFaninNew );
340  if ( Sfm_ObjFanoutNum(p, iFanin) > 0 )
341  Sfm_NtkUpdateLevelR_rec( p, iFanin );
342  // update truth table
343  Vec_WrdWriteEntry( p->vTruths, iNode, uTruth );
344  Sfm_TruthToCnf( uTruth, Sfm_ObjFaninNum(p, iNode), p->vCover, (Vec_Str_t *)Vec_WecEntry(p->vCnfs, iNode) );
345 }
void Sfm_NtkUpdateLevelR_rec(Sfm_Ntk_t *p, int iNode)
Definition: sfmNtk.c:304
#define Sfm_ObjForEachFanin(p, Node, Fan, i)
Definition: sfmInt.h:172
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Sfm_NtkRemoveFanin(Sfm_Ntk_t *p, int iNode, int iFanin)
Definition: sfmNtk.c:259
static int Sfm_ObjFaninNum(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:139
static int Sfm_ObjIsNode(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:131
static int Sfm_ObjFanin(Sfm_Ntk_t *p, int i, int k)
Definition: sfmInt.h:145
static void Vec_WrdWriteEntry(Vec_Wrd_t *p, int i, word Entry)
Definition: vecWrd.h:418
void Sfm_NtkDeleteObj_rec(Sfm_Ntk_t *p, int iNode)
Definition: sfmNtk.c:280
static Vec_Int_t * Sfm_ObjFiArray(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:136
static int Vec_IntRemove(Vec_Int_t *p, int Entry)
Definition: vecInt.h:915
static Vec_Int_t * Vec_WecEntry(Vec_Wec_t *p, int i)
Definition: vecWec.h:142
int Sfm_TruthToCnf(word Truth, int nVars, Vec_Int_t *vCover, Vec_Str_t *vCnf)
Definition: sfmCnf.c:71
static int Sfm_ObjFanoutNum(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:140
static Vec_Int_t * Sfm_ObjFoArray(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:137
#define assert(ex)
Definition: util_old.h:213
void Sfm_NtkAddFanin(Sfm_Ntk_t *p, int iNode, int iFanin)
Definition: sfmNtk.c:269
void Sfm_NtkUpdateLevel_rec(Sfm_Ntk_t *p, int iNode)
Definition: sfmNtk.c:294
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
int Sfm_NtkWindowToSolver ( Sfm_Ntk_t p)

FUNCTION DEFINITIONS ///.

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

Synopsis [Converts a window into a SAT solver.]

Description []

SideEffects []

SeeAlso []

Definition at line 54 of file sfmSat.c.

55 {
56  // p->vOrder contains all variables in the window in a good order
57  // p->vDivs is a subset of nodes in p->vOrder used as divisor candidates
58  // p->vTfo contains TFO of the node (does not include node)
59  // p->vRoots contains roots of the TFO of the node (may include node)
60  Vec_Int_t * vClause;
61  int RetValue, iNode = -1, iFanin, i, k;
62  abctime clk = Abc_Clock();
63 // if ( p->pSat )
64 // printf( "%d ", p->pSat->stats.learnts );
65  sat_solver_restart( p->pSat );
66  sat_solver_setnvars( p->pSat, 1 + Vec_IntSize(p->vOrder) + Vec_IntSize(p->vTfo) + Vec_IntSize(p->vRoots) + 10 );
67  // create SAT variables
69  p->nSatVars = 1;
70  Vec_IntForEachEntry( p->vOrder, iNode, i )
71  Sfm_ObjSetSatVar( p, iNode, p->nSatVars++ );
72  // collect divisor variables
73  Vec_IntClear( p->vDivVars );
74  Vec_IntForEachEntry( p->vDivs, iNode, i )
75  Vec_IntPush( p->vDivVars, Sfm_ObjSatVar(p, iNode) );
76  // add CNF clauses for the TFI
77  Vec_IntForEachEntry( p->vOrder, iNode, i )
78  {
79  if ( Sfm_ObjIsPi(p, iNode) )
80  continue;
81  // collect fanin variables
82  Vec_IntClear( p->vFaninMap );
83  Sfm_ObjForEachFanin( p, iNode, iFanin, k )
84  Vec_IntPush( p->vFaninMap, Sfm_ObjSatVar(p, iFanin) );
85  Vec_IntPush( p->vFaninMap, Sfm_ObjSatVar(p, iNode) );
86  // generate CNF
87  Sfm_TranslateCnf( p->vClauses, (Vec_Str_t *)Vec_WecEntry(p->vCnfs, iNode), p->vFaninMap, -1 );
88  // add clauses
89  Vec_WecForEachLevel( p->vClauses, vClause, k )
90  {
91  if ( Vec_IntSize(vClause) == 0 )
92  break;
93  RetValue = sat_solver_addclause( p->pSat, Vec_IntArray(vClause), Vec_IntArray(vClause) + Vec_IntSize(vClause) );
94  if ( RetValue == 0 )
95  return 0;
96  }
97  }
98  if ( Vec_IntSize(p->vTfo) > 0 )
99  {
100  assert( p->pPars->nTfoLevMax > 0 );
101  assert( Vec_IntSize(p->vRoots) > 0 );
102  assert( Vec_IntEntry(p->vTfo, 0) != p->iPivotNode );
103  // collect variables of root nodes
104  Vec_IntClear( p->vLits );
105  Vec_IntForEachEntry( p->vRoots, iNode, i )
106  Vec_IntPush( p->vLits, Sfm_ObjSatVar(p, iNode) );
107  // assign new variables to the TFO nodes
108  Vec_IntForEachEntry( p->vTfo, iNode, i )
109  {
110  Sfm_ObjCleanSatVar( p, Sfm_ObjSatVar(p, iNode) );
111  Sfm_ObjSetSatVar( p, iNode, p->nSatVars++ );
112  }
113  // add CNF clauses for the TFO
114  Vec_IntForEachEntry( p->vTfo, iNode, i )
115  {
116  assert( Sfm_ObjIsNode(p, iNode) );
117  // collect fanin variables
118  Vec_IntClear( p->vFaninMap );
119  Sfm_ObjForEachFanin( p, iNode, iFanin, k )
120  Vec_IntPush( p->vFaninMap, Sfm_ObjSatVar(p, iFanin) );
121  Vec_IntPush( p->vFaninMap, Sfm_ObjSatVar(p, iNode) );
122  // generate CNF
123  Sfm_TranslateCnf( p->vClauses, (Vec_Str_t *)Vec_WecEntry(p->vCnfs, iNode), p->vFaninMap, Sfm_ObjSatVar(p, p->iPivotNode) );
124  // add clauses
125  Vec_WecForEachLevel( p->vClauses, vClause, k )
126  {
127  if ( Vec_IntSize(vClause) == 0 )
128  break;
129  RetValue = sat_solver_addclause( p->pSat, Vec_IntArray(vClause), Vec_IntArray(vClause) + Vec_IntSize(vClause) );
130  if ( RetValue == 0 )
131  return 0;
132  }
133  }
134  // create XOR clauses for the roots
135  Vec_IntForEachEntry( p->vRoots, iNode, i )
136  {
137  sat_solver_add_xor( p->pSat, Vec_IntEntry(p->vLits, i), Sfm_ObjSatVar(p, iNode), p->nSatVars++, 0 );
138  Vec_IntWriteEntry( p->vLits, i, Abc_Var2Lit(p->nSatVars-1, 0) );
139  }
140  // make OR clause for the last nRoots variables
141  RetValue = sat_solver_addclause( p->pSat, Vec_IntArray(p->vLits), Vec_IntArray(p->vLits) + Vec_IntSize(p->vLits) );
142  if ( RetValue == 0 )
143  return 0;
144  }
145  // finalize
146  RetValue = sat_solver_simplify( p->pSat );
147  p->timeCnf += Abc_Clock() - clk;
148  return RetValue;
149 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
#define Sfm_ObjForEachFanin(p, Node, Fan, i)
Definition: sfmInt.h:172
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int sat_solver_addclause(sat_solver *s, lit *begin, lit *end)
Definition: satSolver.c:1492
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
Vec_Ptr_t * vRoots
Definition: llb3Image.c:51
static void Sfm_NtkCleanVars(Sfm_Ntk_t *p)
Definition: sfmInt.h:151
static int sat_solver_add_xor(sat_solver *pSat, int iVarA, int iVarB, int iVarC, int fCompl)
Definition: satSolver.h:346
static void Sfm_ObjCleanSatVar(Sfm_Ntk_t *p, int Num)
Definition: sfmInt.h:150
static abctime Abc_Clock()
Definition: abc_global.h:279
static int Sfm_ObjIsNode(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:131
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Sfm_ObjIsPi(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:129
#define Vec_WecForEachLevel(vGlob, vVec, i)
MACRO DEFINITIONS ///.
Definition: vecWec.h:55
static int Sfm_ObjSatVar(Sfm_Ntk_t *p, int iObj)
Definition: sfmInt.h:148
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
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static Vec_Int_t * Vec_WecEntry(Vec_Wec_t *p, int i)
Definition: vecWec.h:142
int sat_solver_simplify(sat_solver *s)
Definition: satSolver.c:1276
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static void Sfm_ObjSetSatVar(Sfm_Ntk_t *p, int iObj, int Num)
Definition: sfmInt.h:149
void Sfm_TranslateCnf(Vec_Wec_t *vRes, Vec_Str_t *vCnf, Vec_Int_t *vFaninMap, int iPivotVar)
Definition: sfmCnf.c:153
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
ABC_INT64_T abctime
Definition: abc_global.h:278
void sat_solver_restart(sat_solver *s)
Definition: satSolver.c:1186
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
static int Sfm_ObjAddsLevel ( Sfm_Ntk_t p,
int  i 
)
inlinestatic

Definition at line 134 of file sfmInt.h.

134 { return Sfm_ObjAddsLevelArray(p->vEmpty, i); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Sfm_ObjAddsLevelArray(Vec_Str_t *p, int i)
Definition: sfmInt.h:133
static int Sfm_ObjAddsLevelArray ( Vec_Str_t p,
int  i 
)
inlinestatic

Definition at line 133 of file sfmInt.h.

133 { return p == NULL || Vec_StrEntry(p, i) == 0; }
static char Vec_StrEntry(Vec_Str_t *p, int i)
Definition: vecStr.h:336
static void Sfm_ObjCleanSatVar ( Sfm_Ntk_t p,
int  Num 
)
inlinestatic

Definition at line 150 of file sfmInt.h.

150 { int iObj = Vec_IntEntry(&p->vVar2Id, Num); assert(Vec_IntEntry(&p->vId2Var, iObj) > 0); Vec_IntWriteEntry(&p->vId2Var, iObj, -1); Vec_IntWriteEntry(&p->vVar2Id, Num, -1); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define assert(ex)
Definition: util_old.h:213
static int Sfm_ObjFanin ( Sfm_Ntk_t p,
int  i,
int  k 
)
inlinestatic

Definition at line 145 of file sfmInt.h.

145 { return Vec_IntEntry(Sfm_ObjFiArray(p, i), k); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static Vec_Int_t * Sfm_ObjFiArray(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:136
static int Sfm_ObjFaninNum ( Sfm_Ntk_t p,
int  i 
)
inlinestatic

Definition at line 139 of file sfmInt.h.

139 { return Vec_IntSize(Sfm_ObjFiArray(p, i)); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Vec_Int_t * Sfm_ObjFiArray(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:136
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Sfm_ObjFanout ( Sfm_Ntk_t p,
int  i,
int  k 
)
inlinestatic

Definition at line 146 of file sfmInt.h.

146 { return Vec_IntEntry(Sfm_ObjFoArray(p, i), k); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static Vec_Int_t * Sfm_ObjFoArray(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:137
static int Sfm_ObjFanoutNum ( Sfm_Ntk_t p,
int  i 
)
inlinestatic

Definition at line 140 of file sfmInt.h.

140 { return Vec_IntSize(Sfm_ObjFoArray(p, i)); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static Vec_Int_t * Sfm_ObjFoArray(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:137
static Vec_Int_t* Sfm_ObjFiArray ( Sfm_Ntk_t p,
int  i 
)
inlinestatic

Definition at line 136 of file sfmInt.h.

136 { return Vec_WecEntry(&p->vFanins, i); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Vec_Int_t * Vec_WecEntry(Vec_Wec_t *p, int i)
Definition: vecWec.h:142
static Vec_Int_t* Sfm_ObjFoArray ( Sfm_Ntk_t p,
int  i 
)
inlinestatic

Definition at line 137 of file sfmInt.h.

137 { return Vec_WecEntry(&p->vFanouts, i); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Vec_Int_t * Vec_WecEntry(Vec_Wec_t *p, int i)
Definition: vecWec.h:142
static int Sfm_ObjIsFixed ( Sfm_Ntk_t p,
int  i 
)
inlinestatic

Definition at line 132 of file sfmInt.h.

132 { return Vec_StrEntry(p->vFixed, i); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static char Vec_StrEntry(Vec_Str_t *p, int i)
Definition: vecStr.h:336
static int Sfm_ObjIsNode ( Sfm_Ntk_t p,
int  i 
)
inlinestatic

Definition at line 131 of file sfmInt.h.

131 { return i >= p->nPis && i + p->nPos < p->nObjs; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Sfm_ObjIsPi ( Sfm_Ntk_t p,
int  i 
)
inlinestatic

Definition at line 129 of file sfmInt.h.

129 { return i < p->nPis; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Sfm_ObjIsPo ( Sfm_Ntk_t p,
int  i 
)
inlinestatic

Definition at line 130 of file sfmInt.h.

130 { return i + p->nPos >= p->nObjs; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Sfm_ObjLevel ( Sfm_Ntk_t p,
int  iObj 
)
inlinestatic

Definition at line 153 of file sfmInt.h.

153 { return Vec_IntEntry( &p->vLevels, iObj ); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Sfm_ObjLevelR ( Sfm_Ntk_t p,
int  iObj 
)
inlinestatic

Definition at line 156 of file sfmInt.h.

156 { return Vec_IntEntry( &p->vLevelsR, iObj ); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
int Sfm_ObjMffcSize ( Sfm_Ntk_t p,
int  iObj 
)

Definition at line 89 of file sfmWin.c.

90 {
91  int Count1, Count2;
92  if ( Sfm_ObjIsPi(p, iObj) )
93  return 0;
94  if ( Sfm_ObjFanoutNum(p, iObj) != 1 )
95  return 0;
96  assert( Sfm_ObjIsNode( p, iObj ) );
97  Count1 = Sfm_ObjDeref( p, iObj );
98  Count2 = Sfm_ObjRef( p, iObj );
99  assert( Count1 == Count2 );
100  return Count1;
101 }
int Sfm_ObjDeref(Sfm_Ntk_t *p, int iObj)
Definition: sfmWin.c:82
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Sfm_ObjIsNode(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:131
static int Sfm_ObjIsPi(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:129
int Sfm_ObjRef(Sfm_Ntk_t *p, int iObj)
Definition: sfmWin.c:60
static int Sfm_ObjFanoutNum(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:140
#define assert(ex)
Definition: util_old.h:213
static int Sfm_ObjRefDecrement ( Sfm_Ntk_t p,
int  iObj 
)
inlinestatic

Definition at line 143 of file sfmInt.h.

143 { return --Sfm_ObjFoArray(p, iObj)->nSize; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Vec_Int_t * Sfm_ObjFoArray(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:137
static int Sfm_ObjRefIncrement ( Sfm_Ntk_t p,
int  iObj 
)
inlinestatic

Definition at line 142 of file sfmInt.h.

142 { return ++Sfm_ObjFoArray(p, iObj)->nSize; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Vec_Int_t * Sfm_ObjFoArray(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:137
static void Sfm_ObjResetFaninCount ( Sfm_Ntk_t p,
int  iObj 
)
inlinestatic

Definition at line 160 of file sfmInt.h.

160 { Vec_IntWriteEntry(&p->vCounts, iObj, Sfm_ObjFaninNum(p, iObj)-1); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Sfm_ObjFaninNum(Sfm_Ntk_t *p, int i)
Definition: sfmInt.h:139
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Sfm_ObjSatVar ( Sfm_Ntk_t p,
int  iObj 
)
inlinestatic

Definition at line 148 of file sfmInt.h.

148 { assert(Vec_IntEntry(&p->vId2Var, iObj) > 0); return Vec_IntEntry(&p->vId2Var, iObj); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define assert(ex)
Definition: util_old.h:213
static void Sfm_ObjSetLevel ( Sfm_Ntk_t p,
int  iObj,
int  Lev 
)
inlinestatic

Definition at line 154 of file sfmInt.h.

154 { Vec_IntWriteEntry( &p->vLevels, iObj, Lev ); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static void Sfm_ObjSetLevelR ( Sfm_Ntk_t p,
int  iObj,
int  Lev 
)
inlinestatic

Definition at line 157 of file sfmInt.h.

157 { Vec_IntWriteEntry( &p->vLevelsR, iObj, Lev ); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static void Sfm_ObjSetSatVar ( Sfm_Ntk_t p,
int  iObj,
int  Num 
)
inlinestatic

Definition at line 149 of file sfmInt.h.

149 { assert(Vec_IntEntry(&p->vId2Var, iObj) == -1); Vec_IntWriteEntry(&p->vId2Var, iObj, Num); Vec_IntWriteEntry(&p->vVar2Id, Num, iObj); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
#define assert(ex)
Definition: util_old.h:213
static int Sfm_ObjUpdateFaninCount ( Sfm_Ntk_t p,
int  iObj 
)
inlinestatic

Definition at line 159 of file sfmInt.h.

159 { return Vec_IntAddToEntry(&p->vCounts, iObj, -1); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
Definition: bblif.c:302
void Sfm_PrintCnf ( Vec_Str_t vCnf)

FUNCTION DECLARATIONS ///.

FUNCTION DECLARATIONS ///.

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

FileName [sfmCnf.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [SAT-based optimization using internal don't-cares.]

Synopsis [CNF computation.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file sfmCnf.c.

47 {
48  char Entry;
49  int i, Lit;
50  Vec_StrForEachEntry( vCnf, Entry, i )
51  {
52  Lit = (int)Entry;
53  if ( Lit == -1 )
54  printf( "\n" );
55  else
56  printf( "%s%d ", Abc_LitIsCompl(Lit) ? "-":"", Abc_Lit2Var(Lit) );
57  }
58 }
#define Vec_StrForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecStr.h:54
static int Abc_LitIsCompl(int Lit)
Definition: abc_global.h:265
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
void Sfm_TranslateCnf ( Vec_Wec_t vRes,
Vec_Str_t vCnf,
Vec_Int_t vFaninMap,
int  iPivotVar 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 153 of file sfmCnf.c.

154 {
155  Vec_Int_t * vClause;
156  char Entry;
157  int i, Lit;
158  Vec_WecClear( vRes );
159  vClause = Vec_WecPushLevel( vRes );
160  Vec_StrForEachEntry( vCnf, Entry, i )
161  {
162  if ( (int)Entry == -1 )
163  {
164  vClause = Vec_WecPushLevel( vRes );
165  continue;
166  }
167  Lit = Abc_Lit2LitV( Vec_IntArray(vFaninMap), (int)Entry );
168  Lit = Abc_LitNotCond( Lit, Abc_Lit2Var(Lit) == iPivotVar );
169  Vec_IntPush( vClause, Lit );
170  }
171 }
static int * Vec_IntArray(Vec_Int_t *p)
Definition: vecInt.h:328
static int Abc_Lit2LitV(int *pMap, int Lit)
Definition: abc_global.h:269
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
#define Vec_StrForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecStr.h:54
static Vec_Int_t * Vec_WecPushLevel(Vec_Wec_t *p)
Definition: vecWec.h:284
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
static void Vec_WecClear(Vec_Wec_t *p)
Definition: vecWec.h:255
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Abc_Lit2Var(int Lit)
Definition: abc_global.h:264
int Sfm_TruthToCnf ( word  Truth,
int  nVars,
Vec_Int_t vCover,
Vec_Str_t vCnf 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 71 of file sfmCnf.c.

72 {
73  Vec_StrClear( vCnf );
74  if ( Truth == 0 || ~Truth == 0 )
75  {
76 // assert( nVars == 0 );
77  Vec_StrPush( vCnf, (char)(Truth == 0) );
78  Vec_StrPush( vCnf, (char)-1 );
79  return 1;
80  }
81  else
82  {
83  int i, k, c, RetValue, Literal, Cube, nCubes = 0;
84  assert( nVars > 0 );
85  for ( c = 0; c < 2; c ++ )
86  {
87  Truth = c ? ~Truth : Truth;
88  RetValue = Kit_TruthIsop( (unsigned *)&Truth, nVars, vCover, 0 );
89  assert( RetValue == 0 );
90  nCubes += Vec_IntSize( vCover );
91  Vec_IntForEachEntry( vCover, Cube, i )
92  {
93  for ( k = 0; k < nVars; k++ )
94  {
95  Literal = 3 & (Cube >> (k << 1));
96  if ( Literal == 1 ) // '0' -> pos lit
97  Vec_StrPush( vCnf, (char)Abc_Var2Lit(k, 0) );
98  else if ( Literal == 2 ) // '1' -> neg lit
99  Vec_StrPush( vCnf, (char)Abc_Var2Lit(k, 1) );
100  else if ( Literal != 0 )
101  assert( 0 );
102  }
103  Vec_StrPush( vCnf, (char)Abc_Var2Lit(nVars, c) );
104  Vec_StrPush( vCnf, (char)-1 );
105  }
106  }
107  return nCubes;
108  }
109 }
static int Abc_Var2Lit(int Var, int fCompl)
Definition: abc_global.h:263
static void Vec_StrClear(Vec_Str_t *p)
Definition: vecStr.h:519
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
int Kit_TruthIsop(unsigned *puTruth, int nVars, Vec_Int_t *vMemory, int fTryBoth)
FUNCTION DEFINITIONS ///.
Definition: kitIsop.c:55
static ABC_NAMESPACE_IMPL_START word Truth[8]
DECLARATIONS ///.
Definition: giaShrink6.c:32
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54