abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
aigCuts.c File Reference
#include "aig.h"
#include "bool/kit/kit.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START
Aig_ManCut_t
Aig_ManCutStart (Aig_Man_t *pMan, int nCutsMax, int nLeafMax, int fTruth, int fVerbose)
 DECLARATIONS ///. More...
 
void Aig_ManCutStop (Aig_ManCut_t *p)
 
void Aig_CutPrint (Aig_Cut_t *pCut)
 
void Aig_ObjCutPrint (Aig_ManCut_t *p, Aig_Obj_t *pObj)
 
int Aig_ManCutCount (Aig_ManCut_t *p, int *pnCutsK)
 
static int Aig_CutFindCost (Aig_ManCut_t *p, Aig_Cut_t *pCut)
 
static float Aig_CutFindCost2 (Aig_ManCut_t *p, Aig_Cut_t *pCut)
 
static Aig_Cut_tAig_CutFindFree (Aig_ManCut_t *p, Aig_Obj_t *pObj)
 
static unsigned Aig_CutTruthPhase (Aig_Cut_t *pCut, Aig_Cut_t *pCut1)
 
unsigned * Aig_CutComputeTruth (Aig_ManCut_t *p, Aig_Cut_t *pCut, Aig_Cut_t *pCut0, Aig_Cut_t *pCut1, int fCompl0, int fCompl1)
 
int Aig_CutSupportMinimize (Aig_ManCut_t *p, Aig_Cut_t *pCut)
 
static int Aig_CutCheckDominance (Aig_Cut_t *pDom, Aig_Cut_t *pCut)
 
int Aig_CutFilter (Aig_ManCut_t *p, Aig_Obj_t *pObj, Aig_Cut_t *pCut)
 
static int Aig_CutMergeOrdered (Aig_ManCut_t *p, Aig_Cut_t *pC0, Aig_Cut_t *pC1, Aig_Cut_t *pC)
 
int Aig_CutMerge (Aig_ManCut_t *p, Aig_Cut_t *pCut0, Aig_Cut_t *pCut1, Aig_Cut_t *pCut)
 
Aig_Cut_tAig_ObjPrepareCuts (Aig_ManCut_t *p, Aig_Obj_t *pObj, int fTriv)
 
void Aig_ObjComputeCuts (Aig_ManCut_t *p, Aig_Obj_t *pObj, int fTriv)
 
Aig_ManCut_tAig_ComputeCuts (Aig_Man_t *pAig, int nCutsMax, int nLeafMax, int fTruth, int fVerbose)
 

Function Documentation

Aig_ManCut_t* Aig_ComputeCuts ( Aig_Man_t pAig,
int  nCutsMax,
int  nLeafMax,
int  fTruth,
int  fVerbose 
)

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

Synopsis [Computes the cuts for all nodes in the static AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 631 of file aigCuts.c.

632 {
633  Aig_ManCut_t * p;
634  Aig_Obj_t * pObj;
635  int i;
636  abctime clk = Abc_Clock();
637  assert( pAig->pManCuts == NULL );
638  // start the manager
639  p = Aig_ManCutStart( pAig, nCutsMax, nLeafMax, fTruth, fVerbose );
640  // set elementary cuts at the PIs
641  Aig_ManForEachCi( pAig, pObj, i )
642  Aig_ObjPrepareCuts( p, pObj, 1 );
643  // process the nodes
644  Aig_ManForEachNode( pAig, pObj, i )
645  Aig_ObjComputeCuts( p, pObj, 1 );
646  // print stats
647  if ( fVerbose )
648  {
649  int nCuts, nCutsK;
650  nCuts = Aig_ManCutCount( p, &nCutsK );
651  printf( "Nodes = %6d. Total cuts = %6d. %d-input cuts = %6d.\n",
652  Aig_ManObjNum(pAig), nCuts, nLeafMax, nCutsK );
653  printf( "Cut size = %2d. Truth size = %2d. Total mem = %5.2f MB ",
654  p->nCutSize, 4*p->nTruthWords, 1.0*Aig_MmFixedReadMemUsage(p->pMemCuts)/(1<<20) );
655  ABC_PRT( "Runtime", Abc_Clock() - clk );
656 /*
657  Aig_ManForEachNode( pAig, pObj, i )
658  if ( i % 300 == 0 )
659  Aig_ObjCutPrint( p, pObj );
660 */
661  }
662  // remember the cut manager
663  pAig->pManCuts = p;
664  return p;
665 }
void Aig_ObjComputeCuts(Aig_ManCut_t *p, Aig_Obj_t *pObj, int fTriv)
Definition: aigCuts.c:576
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Aig_ManObjNum(Aig_Man_t *p)
Definition: aig.h:258
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
static abctime Abc_Clock()
Definition: abc_global.h:279
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
Aig_Cut_t * Aig_ObjPrepareCuts(Aig_ManCut_t *p, Aig_Obj_t *pObj, int fTriv)
Definition: aigCuts.c:536
if(last==0)
Definition: sparse_int.h:34
ABC_NAMESPACE_IMPL_START Aig_ManCut_t * Aig_ManCutStart(Aig_Man_t *pMan, int nCutsMax, int nLeafMax, int fTruth, int fVerbose)
DECLARATIONS ///.
Definition: aigCuts.c:46
Definition: aig.h:69
int Aig_ManCutCount(Aig_ManCut_t *p, int *pnCutsK)
Definition: aigCuts.c:147
int Aig_MmFixedReadMemUsage(Aig_MmFixed_t *p)
Definition: aigMem.c:271
#define ABC_PRT(a, t)
Definition: abc_global.h:220
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
static int Aig_CutCheckDominance ( Aig_Cut_t pDom,
Aig_Cut_t pCut 
)
inlinestatic

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

Synopsis [Returns 1 if pDom is contained in pCut.]

Description []

SideEffects []

SeeAlso []

Definition at line 344 of file aigCuts.c.

345 {
346  int i, k;
347  for ( i = 0; i < (int)pDom->nFanins; i++ )
348  {
349  for ( k = 0; k < (int)pCut->nFanins; k++ )
350  if ( pDom->pFanins[i] == pCut->pFanins[k] )
351  break;
352  if ( k == (int)pCut->nFanins ) // node i in pDom is not contained in pCut
353  return 0;
354  }
355  // every node in pDom is contained in pCut
356  return 1;
357 }
char nFanins
Definition: aig.h:187
int pFanins[0]
Definition: aig.h:188
unsigned* Aig_CutComputeTruth ( Aig_ManCut_t p,
Aig_Cut_t pCut,
Aig_Cut_t pCut0,
Aig_Cut_t pCut1,
int  fCompl0,
int  fCompl1 
)

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

Synopsis [Performs truth table computation.]

Description []

SideEffects []

SeeAlso []

Definition at line 276 of file aigCuts.c.

277 {
278  // permute the first table
279  if ( fCompl0 )
280  Kit_TruthNot( p->puTemp[0], Aig_CutTruth(pCut0), p->nLeafMax );
281  else
282  Kit_TruthCopy( p->puTemp[0], Aig_CutTruth(pCut0), p->nLeafMax );
283  Kit_TruthStretch( p->puTemp[2], p->puTemp[0], pCut0->nFanins, p->nLeafMax, Aig_CutTruthPhase(pCut, pCut0), 0 );
284  // permute the second table
285  if ( fCompl1 )
286  Kit_TruthNot( p->puTemp[1], Aig_CutTruth(pCut1), p->nLeafMax );
287  else
288  Kit_TruthCopy( p->puTemp[1], Aig_CutTruth(pCut1), p->nLeafMax );
289  Kit_TruthStretch( p->puTemp[3], p->puTemp[1], pCut1->nFanins, p->nLeafMax, Aig_CutTruthPhase(pCut, pCut1), 0 );
290  // produce the resulting table
291  Kit_TruthAnd( Aig_CutTruth(pCut), p->puTemp[2], p->puTemp[3], p->nLeafMax );
292 // assert( pCut->nFanins >= Kit_TruthSupportSize( Aig_CutTruth(pCut), p->nLeafMax ) );
293  return Aig_CutTruth(pCut);
294 }
unsigned * puTemp[4]
Definition: aig.h:206
int nLeafMax
Definition: aig.h:199
static unsigned * Aig_CutTruth(Aig_Cut_t *pCut)
Definition: aig.h:214
void Kit_TruthStretch(unsigned *pOut, unsigned *pIn, int nVars, int nVarsAll, unsigned Phase, int fReturnIn)
Definition: kitTruth.c:166
static void Kit_TruthAnd(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:379
char nFanins
Definition: aig.h:187
static void Kit_TruthNot(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:373
static unsigned Aig_CutTruthPhase(Aig_Cut_t *pCut, Aig_Cut_t *pCut1)
Definition: aigCuts.c:248
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
int Aig_CutFilter ( Aig_ManCut_t p,
Aig_Obj_t pObj,
Aig_Cut_t pCut 
)

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

Synopsis [Returns 1 if the cut is contained.]

Description []

SideEffects []

SeeAlso []

Definition at line 370 of file aigCuts.c.

371 {
372  Aig_Cut_t * pTemp;
373  int i;
374  // go through the cuts of the node
375  Aig_ObjForEachCut( p, pObj, pTemp, i )
376  {
377  if ( pTemp->nFanins < 2 )
378  continue;
379  if ( pTemp == pCut )
380  continue;
381  if ( pTemp->nFanins > pCut->nFanins )
382  {
383  // skip the non-contained cuts
384  if ( (pTemp->uSign & pCut->uSign) != pCut->uSign )
385  continue;
386  // check containment seriously
387  if ( Aig_CutCheckDominance( pCut, pTemp ) )
388  {
389  // remove contained cut
390  pTemp->nFanins = 0;
391  }
392  }
393  else
394  {
395  // skip the non-contained cuts
396  if ( (pTemp->uSign & pCut->uSign) != pTemp->uSign )
397  continue;
398  // check containment seriously
399  if ( Aig_CutCheckDominance( pTemp, pCut ) )
400  {
401  // remove the given
402  pCut->nFanins = 0;
403  return 1;
404  }
405  }
406  }
407  return 0;
408 }
static int Aig_CutCheckDominance(Aig_Cut_t *pDom, Aig_Cut_t *pCut)
Definition: aigCuts.c:344
unsigned uSign
Definition: aig.h:183
char nFanins
Definition: aig.h:187
#define Aig_ObjForEachCut(p, pObj, pCut, i)
Definition: aig.h:218
static int Aig_CutFindCost ( Aig_ManCut_t p,
Aig_Cut_t pCut 
)
inlinestatic

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

Synopsis [Compute the cost of the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 177 of file aigCuts.c.

178 {
179  Aig_Obj_t * pLeaf;
180  int i, Cost = 0;
181  assert( pCut->nFanins > 0 );
182  Aig_CutForEachLeaf( p->pAig, pCut, pLeaf, i )
183  Cost += pLeaf->nRefs;
184  return Cost * 1000 / pCut->nFanins;
185 }
Aig_Man_t * pAig
Definition: aig.h:195
Definition: aig.h:69
char nFanins
Definition: aig.h:187
#define Aig_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: aig.h:221
#define assert(ex)
Definition: util_old.h:213
static float Aig_CutFindCost2 ( Aig_ManCut_t p,
Aig_Cut_t pCut 
)
inlinestatic

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

Synopsis [Compute the cost of the cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 198 of file aigCuts.c.

199 {
200  Aig_Obj_t * pLeaf;
201  float Cost = 0.0;
202  int i;
203  assert( pCut->nFanins > 0 );
204  Aig_CutForEachLeaf( p->pAig, pCut, pLeaf, i )
205  Cost += (float)1.0/pLeaf->nRefs;
206  return 1/Cost;
207 }
Aig_Man_t * pAig
Definition: aig.h:195
Definition: aig.h:69
char nFanins
Definition: aig.h:187
#define Aig_CutForEachLeaf(p, pCut, pLeaf, i)
Definition: aig.h:221
#define assert(ex)
Definition: util_old.h:213
static Aig_Cut_t* Aig_CutFindFree ( Aig_ManCut_t p,
Aig_Obj_t pObj 
)
inlinestatic

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

Synopsis [Returns the next free cut to use.]

Description []

SideEffects []

SeeAlso []

Definition at line 220 of file aigCuts.c.

221 {
222  Aig_Cut_t * pCut, * pCutMax;
223  int i;
224  pCutMax = NULL;
225  Aig_ObjForEachCut( p, pObj, pCut, i )
226  {
227  if ( pCut->nFanins == 0 )
228  return pCut;
229  if ( pCutMax == NULL || pCutMax->Cost < pCut->Cost )
230  pCutMax = pCut;
231  }
232  assert( pCutMax != NULL );
233  pCutMax->nFanins = 0;
234  return pCutMax;
235 }
int Cost
Definition: aig.h:182
char nFanins
Definition: aig.h:187
#define assert(ex)
Definition: util_old.h:213
#define Aig_ObjForEachCut(p, pObj, pCut, i)
Definition: aig.h:218
int Aig_CutMerge ( Aig_ManCut_t p,
Aig_Cut_t pCut0,
Aig_Cut_t pCut1,
Aig_Cut_t pCut 
)

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

Synopsis [Prepares the object for FPGA mapping.]

Description []

SideEffects []

SeeAlso []

Definition at line 507 of file aigCuts.c.

508 {
509  assert( p->nLeafMax > 0 );
510  // merge the nodes
511  if ( pCut0->nFanins < pCut1->nFanins )
512  {
513  if ( !Aig_CutMergeOrdered( p, pCut1, pCut0, pCut ) )
514  return 0;
515  }
516  else
517  {
518  if ( !Aig_CutMergeOrdered( p, pCut0, pCut1, pCut ) )
519  return 0;
520  }
521  pCut->uSign = pCut0->uSign | pCut1->uSign;
522  return 1;
523 }
int nLeafMax
Definition: aig.h:199
unsigned uSign
Definition: aig.h:183
char nFanins
Definition: aig.h:187
static int Aig_CutMergeOrdered(Aig_ManCut_t *p, Aig_Cut_t *pC0, Aig_Cut_t *pC1, Aig_Cut_t *pC)
Definition: aigCuts.c:421
#define assert(ex)
Definition: util_old.h:213
static int Aig_CutMergeOrdered ( Aig_ManCut_t p,
Aig_Cut_t pC0,
Aig_Cut_t pC1,
Aig_Cut_t pC 
)
inlinestatic

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

Synopsis [Merges two cuts.]

Description []

SideEffects []

SeeAlso []

Definition at line 421 of file aigCuts.c.

422 {
423  int i, k, c;
424  assert( pC0->nFanins >= pC1->nFanins );
425  // the case of the largest cut sizes
426  if ( pC0->nFanins == p->nLeafMax && pC1->nFanins == p->nLeafMax )
427  {
428  for ( i = 0; i < pC0->nFanins; i++ )
429  if ( pC0->pFanins[i] != pC1->pFanins[i] )
430  return 0;
431  for ( i = 0; i < pC0->nFanins; i++ )
432  pC->pFanins[i] = pC0->pFanins[i];
433  pC->nFanins = pC0->nFanins;
434  return 1;
435  }
436  // the case when one of the cuts is the largest
437  if ( pC0->nFanins == p->nLeafMax )
438  {
439  for ( i = 0; i < pC1->nFanins; i++ )
440  {
441  for ( k = pC0->nFanins - 1; k >= 0; k-- )
442  if ( pC0->pFanins[k] == pC1->pFanins[i] )
443  break;
444  if ( k == -1 ) // did not find
445  return 0;
446  }
447  for ( i = 0; i < pC0->nFanins; i++ )
448  pC->pFanins[i] = pC0->pFanins[i];
449  pC->nFanins = pC0->nFanins;
450  return 1;
451  }
452 
453  // compare two cuts with different numbers
454  i = k = 0;
455  for ( c = 0; c < p->nLeafMax; c++ )
456  {
457  if ( k == pC1->nFanins )
458  {
459  if ( i == pC0->nFanins )
460  {
461  pC->nFanins = c;
462  return 1;
463  }
464  pC->pFanins[c] = pC0->pFanins[i++];
465  continue;
466  }
467  if ( i == pC0->nFanins )
468  {
469  if ( k == pC1->nFanins )
470  {
471  pC->nFanins = c;
472  return 1;
473  }
474  pC->pFanins[c] = pC1->pFanins[k++];
475  continue;
476  }
477  if ( pC0->pFanins[i] < pC1->pFanins[k] )
478  {
479  pC->pFanins[c] = pC0->pFanins[i++];
480  continue;
481  }
482  if ( pC0->pFanins[i] > pC1->pFanins[k] )
483  {
484  pC->pFanins[c] = pC1->pFanins[k++];
485  continue;
486  }
487  pC->pFanins[c] = pC0->pFanins[i++];
488  k++;
489  }
490  if ( i < pC0->nFanins || k < pC1->nFanins )
491  return 0;
492  pC->nFanins = c;
493  return 1;
494 }
int nLeafMax
Definition: aig.h:199
char nFanins
Definition: aig.h:187
int pFanins[0]
Definition: aig.h:188
#define assert(ex)
Definition: util_old.h:213
void Aig_CutPrint ( Aig_Cut_t pCut)

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

Synopsis [Prints one cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 105 of file aigCuts.c.

106 {
107  int i;
108  printf( "{" );
109  for ( i = 0; i < pCut->nFanins; i++ )
110  printf( " %d", pCut->pFanins[i] );
111  printf( " }\n" );
112 }
char nFanins
Definition: aig.h:187
int pFanins[0]
Definition: aig.h:188
int Aig_CutSupportMinimize ( Aig_ManCut_t p,
Aig_Cut_t pCut 
)

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

Synopsis [Performs support minimization for the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 307 of file aigCuts.c.

308 {
309  unsigned * pTruth;
310  int uSupp, nFansNew, i, k;
311  // get truth table
312  pTruth = Aig_CutTruth( pCut );
313  // get support
314  uSupp = Kit_TruthSupport( pTruth, p->nLeafMax );
315  // get the new support size
316  nFansNew = Kit_WordCountOnes( uSupp );
317  // check if there are redundant variables
318  if ( nFansNew == pCut->nFanins )
319  return nFansNew;
320  assert( nFansNew < pCut->nFanins );
321  // minimize support
322  Kit_TruthShrink( p->puTemp[0], pTruth, nFansNew, p->nLeafMax, uSupp, 1 );
323  for ( i = k = 0; i < pCut->nFanins; i++ )
324  if ( uSupp & (1 << i) )
325  pCut->pFanins[k++] = pCut->pFanins[i];
326  assert( k == nFansNew );
327  pCut->nFanins = nFansNew;
328 // assert( nFansNew == Kit_TruthSupportSize( pTruth, p->nLeafMax ) );
329 //Extra_PrintBinary( stdout, pTruth, (1<<p->nLeafMax) ); printf( "\n" );
330  return nFansNew;
331 }
unsigned * puTemp[4]
Definition: aig.h:206
int nLeafMax
Definition: aig.h:199
static unsigned * Aig_CutTruth(Aig_Cut_t *pCut)
Definition: aig.h:214
char nFanins
Definition: aig.h:187
int pFanins[0]
Definition: aig.h:188
void Kit_TruthShrink(unsigned *pOut, unsigned *pIn, int nVars, int nVarsAll, unsigned Phase, int fReturnIn)
Definition: kitTruth.c:200
unsigned Kit_TruthSupport(unsigned *pTruth, int nVars)
Definition: kitTruth.c:346
#define assert(ex)
Definition: util_old.h:213
static int Kit_WordCountOnes(unsigned uWord)
Definition: kit.h:243
static unsigned Aig_CutTruthPhase ( Aig_Cut_t pCut,
Aig_Cut_t pCut1 
)
inlinestatic

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

Synopsis [Computes the stretching phase of the cut w.r.t. the merged cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 248 of file aigCuts.c.

249 {
250  unsigned uPhase = 0;
251  int i, k;
252  for ( i = k = 0; i < pCut->nFanins; i++ )
253  {
254  if ( k == pCut1->nFanins )
255  break;
256  if ( pCut->pFanins[i] < pCut1->pFanins[k] )
257  continue;
258  assert( pCut->pFanins[i] == pCut1->pFanins[k] );
259  uPhase |= (1 << i);
260  k++;
261  }
262  return uPhase;
263 }
char nFanins
Definition: aig.h:187
int pFanins[0]
Definition: aig.h:188
#define assert(ex)
Definition: util_old.h:213
int Aig_ManCutCount ( Aig_ManCut_t p,
int *  pnCutsK 
)

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

Synopsis [Computes the total number of cuts.]

Description []

SideEffects []

SeeAlso []

Definition at line 147 of file aigCuts.c.

148 {
149  Aig_Cut_t * pCut;
150  Aig_Obj_t * pObj;
151  int i, k, nCuts = 0, nCutsK = 0;
152  Aig_ManForEachNode( p->pAig, pObj, i )
153  Aig_ObjForEachCut( p, pObj, pCut, k )
154  {
155  if ( pCut->nFanins == 0 )
156  continue;
157  nCuts++;
158  if ( pCut->nFanins == p->nLeafMax )
159  nCutsK++;
160  }
161  if ( pnCutsK )
162  *pnCutsK = nCutsK;
163  return nCuts;
164 }
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
Aig_Man_t * pAig
Definition: aig.h:195
Definition: aig.h:69
#define Aig_ObjForEachCut(p, pObj, pCut, i)
Definition: aig.h:218
ABC_NAMESPACE_IMPL_START Aig_ManCut_t* Aig_ManCutStart ( Aig_Man_t pMan,
int  nCutsMax,
int  nLeafMax,
int  fTruth,
int  fVerbose 
)

DECLARATIONS ///.

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

FileName [aigCuts.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [AIG package.]

Synopsis [Computation of K-feasible priority cuts.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Starts the cut sweeping manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file aigCuts.c.

47 {
48  Aig_ManCut_t * p;
49  assert( nCutsMax >= 2 );
50  assert( nLeafMax <= 16 );
51  // allocate the fraiging manager
52  p = ABC_ALLOC( Aig_ManCut_t, 1 );
53  memset( p, 0, sizeof(Aig_ManCut_t) );
54  p->nCutsMax = nCutsMax;
55  p->nLeafMax = nLeafMax;
56  p->fTruth = fTruth;
57  p->fVerbose = fVerbose;
58  p->pAig = pMan;
59  p->pCuts = ABC_CALLOC( Aig_Cut_t *, Aig_ManObjNumMax(pMan) );
60  // allocate memory manager
61  p->nTruthWords = Abc_TruthWordNum(nLeafMax);
62  p->nCutSize = sizeof(Aig_Cut_t) + sizeof(int) * nLeafMax + fTruth * sizeof(unsigned) * p->nTruthWords;
63  p->pMemCuts = Aig_MmFixedStart( p->nCutSize * p->nCutsMax, 512 );
64  // room for temporary truth tables
65  if ( fTruth )
66  {
67  p->puTemp[0] = ABC_ALLOC( unsigned, 4 * p->nTruthWords );
68  p->puTemp[1] = p->puTemp[0] + p->nTruthWords;
69  p->puTemp[2] = p->puTemp[1] + p->nTruthWords;
70  p->puTemp[3] = p->puTemp[2] + p->nTruthWords;
71  }
72  return p;
73 }
char * memset()
unsigned * puTemp[4]
Definition: aig.h:206
int fTruth
Definition: aig.h:200
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int nLeafMax
Definition: aig.h:199
Aig_MmFixed_t * pMemCuts
Definition: aig.h:205
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Abc_TruthWordNum(int nVars)
Definition: abc_global.h:256
Aig_MmFixed_t * Aig_MmFixedStart(int nEntrySize, int nEntriesMax)
FUNCTION DEFINITIONS ///.
Definition: aigMem.c:96
int fVerbose
Definition: aig.h:201
int nTruthWords
Definition: aig.h:204
Aig_Man_t * pAig
Definition: aig.h:195
Aig_Cut_t ** pCuts
Definition: aig.h:196
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
struct Aig_Cut_t_ Aig_Cut_t
Definition: aig.h:176
int nCutSize
Definition: aig.h:203
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
int nCutsMax
Definition: aig.h:198
#define assert(ex)
Definition: util_old.h:213
void Aig_ManCutStop ( Aig_ManCut_t p)

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

Synopsis [Stops the fraiging manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 86 of file aigCuts.c.

87 {
88  Aig_MmFixedStop( p->pMemCuts, 0 );
89  ABC_FREE( p->puTemp[0] );
90  ABC_FREE( p->pCuts );
91  ABC_FREE( p );
92 }
unsigned * puTemp[4]
Definition: aig.h:206
void Aig_MmFixedStop(Aig_MmFixed_t *p, int fVerbose)
Definition: aigMem.c:132
Aig_MmFixed_t * pMemCuts
Definition: aig.h:205
Aig_Cut_t ** pCuts
Definition: aig.h:196
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Aig_ObjComputeCuts ( Aig_ManCut_t p,
Aig_Obj_t pObj,
int  fTriv 
)

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

Synopsis [Derives cuts for one node and sweeps this node.]

Description []

SideEffects []

SeeAlso []

Definition at line 576 of file aigCuts.c.

577 {
578  Aig_Cut_t * pCut0, * pCut1, * pCut, * pCutSet;
579  Aig_Obj_t * pFanin0 = Aig_ObjFanin0(pObj);
580  Aig_Obj_t * pFanin1 = Aig_ObjFanin1(pObj);
581  int i, k;
582  // the node is not processed yet
583  assert( Aig_ObjIsNode(pObj) );
584  assert( Aig_ObjCuts(p, pObj) == NULL );
585  // set up the first cut
586  pCutSet = Aig_ObjPrepareCuts( p, pObj, fTriv );
587  // compute pair-wise cut combinations while checking table
588  Aig_ObjForEachCut( p, pFanin0, pCut0, i )
589  if ( pCut0->nFanins > 0 )
590  Aig_ObjForEachCut( p, pFanin1, pCut1, k )
591  if ( pCut1->nFanins > 0 )
592  {
593  // make sure K-feasible cut exists
594  if ( Kit_WordCountOnes(pCut0->uSign | pCut1->uSign) > p->nLeafMax )
595  continue;
596  // get the next cut of this node
597  pCut = Aig_CutFindFree( p, pObj );
598  // assemble the new cut
599  if ( !Aig_CutMerge( p, pCut0, pCut1, pCut ) )
600  {
601  assert( pCut->nFanins == 0 );
602  continue;
603  }
604  // check containment
605  if ( Aig_CutFilter( p, pObj, pCut ) )
606  {
607  assert( pCut->nFanins == 0 );
608  continue;
609  }
610  // create its truth table
611  if ( p->fTruth )
612  Aig_CutComputeTruth( p, pCut, pCut0, pCut1, Aig_ObjFaninC0(pObj), Aig_ObjFaninC1(pObj) );
613  // assign the cost
614  pCut->Cost = Aig_CutFindCost( p, pCut );
615  assert( pCut->nFanins > 0 );
616  assert( pCut->Cost > 0 );
617  }
618 }
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
int Cost
Definition: aig.h:182
unsigned * Aig_CutComputeTruth(Aig_ManCut_t *p, Aig_Cut_t *pCut, Aig_Cut_t *pCut0, Aig_Cut_t *pCut1, int fCompl0, int fCompl1)
Definition: aigCuts.c:276
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static Aig_Cut_t * Aig_CutFindFree(Aig_ManCut_t *p, Aig_Obj_t *pObj)
Definition: aigCuts.c:220
static int Aig_CutFindCost(Aig_ManCut_t *p, Aig_Cut_t *pCut)
Definition: aigCuts.c:177
unsigned uSign
Definition: aig.h:183
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
Aig_Cut_t * Aig_ObjPrepareCuts(Aig_ManCut_t *p, Aig_Obj_t *pObj, int fTriv)
Definition: aigCuts.c:536
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
char nFanins
Definition: aig.h:187
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
int Aig_CutMerge(Aig_ManCut_t *p, Aig_Cut_t *pCut0, Aig_Cut_t *pCut1, Aig_Cut_t *pCut)
Definition: aigCuts.c:507
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
#define assert(ex)
Definition: util_old.h:213
static int Kit_WordCountOnes(unsigned uWord)
Definition: kit.h:243
int Aig_CutFilter(Aig_ManCut_t *p, Aig_Obj_t *pObj, Aig_Cut_t *pCut)
Definition: aigCuts.c:370
static Aig_Cut_t * Aig_ObjCuts(Aig_ManCut_t *p, Aig_Obj_t *pObj)
Definition: aig.h:209
#define Aig_ObjForEachCut(p, pObj, pCut, i)
Definition: aig.h:218
void Aig_ObjCutPrint ( Aig_ManCut_t p,
Aig_Obj_t pObj 
)

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

Synopsis [Prints one cut.]

Description []

SideEffects []

SeeAlso []

Definition at line 125 of file aigCuts.c.

126 {
127  Aig_Cut_t * pCut;
128  int i;
129  printf( "Cuts for node %d:\n", pObj->Id );
130  Aig_ObjForEachCut( p, pObj, pCut, i )
131  if ( pCut->nFanins )
132  Aig_CutPrint( pCut );
133 // printf( "\n" );
134 }
void Aig_CutPrint(Aig_Cut_t *pCut)
Definition: aigCuts.c:105
if(last==0)
Definition: sparse_int.h:34
int Id
Definition: aig.h:85
#define Aig_ObjForEachCut(p, pObj, pCut, i)
Definition: aig.h:218
Aig_Cut_t* Aig_ObjPrepareCuts ( Aig_ManCut_t p,
Aig_Obj_t pObj,
int  fTriv 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 536 of file aigCuts.c.

537 {
538  Aig_Cut_t * pCutSet, * pCut;
539  int i;
540  // create the cutset of the node
541  pCutSet = (Aig_Cut_t *)Aig_MmFixedEntryFetch( p->pMemCuts );
542  Aig_ObjSetCuts( p, pObj, pCutSet );
543  Aig_ObjForEachCut( p, pObj, pCut, i )
544  {
545  pCut->nFanins = 0;
546  pCut->iNode = pObj->Id;
547  pCut->nCutSize = p->nCutSize;
548  pCut->nLeafMax = p->nLeafMax;
549  }
550  // add unit cut if needed
551  if ( fTriv )
552  {
553  pCut = pCutSet;
554  pCut->Cost = 0;
555  pCut->iNode = pObj->Id;
556  pCut->nFanins = 1;
557  pCut->pFanins[0] = pObj->Id;
558  pCut->uSign = Aig_ObjCutSign( pObj->Id );
559  if ( p->fTruth )
560  memset( Aig_CutTruth(pCut), 0xAA, sizeof(unsigned) * p->nTruthWords );
561  }
562  return pCutSet;
563 }
char * memset()
int iNode
Definition: aig.h:184
int fTruth
Definition: aig.h:200
int nLeafMax
Definition: aig.h:199
Aig_MmFixed_t * pMemCuts
Definition: aig.h:205
short nCutSize
Definition: aig.h:185
int Cost
Definition: aig.h:182
static unsigned * Aig_CutTruth(Aig_Cut_t *pCut)
Definition: aig.h:214
static unsigned Aig_ObjCutSign(unsigned ObjId)
MACRO DEFINITIONS ///.
Definition: aig.h:228
static void Aig_ObjSetCuts(Aig_ManCut_t *p, Aig_Obj_t *pObj, Aig_Cut_t *pCuts)
Definition: aig.h:210
char nLeafMax
Definition: aig.h:186
unsigned uSign
Definition: aig.h:183
int nTruthWords
Definition: aig.h:204
char * Aig_MmFixedEntryFetch(Aig_MmFixed_t *p)
Definition: aigMem.c:161
char nFanins
Definition: aig.h:187
int pFanins[0]
Definition: aig.h:188
int nCutSize
Definition: aig.h:203
int Id
Definition: aig.h:85
#define Aig_ObjForEachCut(p, pObj, pCut, i)
Definition: aig.h:218