abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cswInt.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "aig/aig/aig.h"
#include "opt/dar/dar.h"
#include "bool/kit/kit.h"
#include "csw.h"

Go to the source code of this file.

Data Structures

struct  Csw_Cut_t_
 
struct  Csw_Man_t_
 

Macros

#define Csw_ObjForEachCut(p, pObj, pCut, i)   for ( i = 0, pCut = Csw_ObjCuts(p, pObj); i < p->nCutsMax; i++, pCut = Csw_CutNext(pCut) )
 MACRO DEFINITIONS ///. More...
 
#define Csw_CutForEachLeaf(p, pCut, pLeaf, i)   for ( i = 0; (i < (int)(pCut)->nFanins) && ((pLeaf) = Aig_ManObj(p, (pCut)->pFanins[i])); i++ )
 

Typedefs

typedef
typedefABC_NAMESPACE_HEADER_START
struct Csw_Man_t_ 
Csw_Man_t
 INCLUDES ///. More...
 
typedef struct Csw_Cut_t_ Csw_Cut_t
 

Functions

static int Csw_CutLeaveNum (Csw_Cut_t *pCut)
 
static int * Csw_CutLeaves (Csw_Cut_t *pCut)
 
static unsigned * Csw_CutTruth (Csw_Cut_t *pCut)
 
static Csw_Cut_tCsw_CutNext (Csw_Cut_t *pCut)
 
static int Csw_ObjRefs (Csw_Man_t *p, Aig_Obj_t *pObj)
 
static void Csw_ObjAddRefs (Csw_Man_t *p, Aig_Obj_t *pObj, int nRefs)
 
static Csw_Cut_tCsw_ObjCuts (Csw_Man_t *p, Aig_Obj_t *pObj)
 
static void Csw_ObjSetCuts (Csw_Man_t *p, Aig_Obj_t *pObj, Csw_Cut_t *pCuts)
 
static Aig_Obj_tCsw_ObjEquiv (Csw_Man_t *p, Aig_Obj_t *pObj)
 
static void Csw_ObjSetEquiv (Csw_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pEquiv)
 
static Aig_Obj_tCsw_ObjChild0Equiv (Csw_Man_t *p, Aig_Obj_t *pObj)
 
static Aig_Obj_tCsw_ObjChild1Equiv (Csw_Man_t *p, Aig_Obj_t *pObj)
 
Csw_Cut_tCsw_ObjPrepareCuts (Csw_Man_t *p, Aig_Obj_t *pObj, int fTriv)
 FUNCTION DECLARATIONS ///. More...
 
Aig_Obj_tCsw_ObjSweep (Csw_Man_t *p, Aig_Obj_t *pObj, int fTriv)
 
Csw_Man_tCsw_ManStart (Aig_Man_t *pMan, int nCutsMax, int nLeafMax, int fVerbose)
 DECLARATIONS ///. More...
 
void Csw_ManStop (Csw_Man_t *p)
 
int Csw_TableCountCuts (Csw_Man_t *p)
 
void Csw_TableCutInsert (Csw_Man_t *p, Csw_Cut_t *pCut)
 
Aig_Obj_tCsw_TableCutLookup (Csw_Man_t *p, Csw_Cut_t *pCut)
 

Macro Definition Documentation

#define Csw_CutForEachLeaf (   p,
  pCut,
  pLeaf,
 
)    for ( i = 0; (i < (int)(pCut)->nFanins) && ((pLeaf) = Aig_ManObj(p, (pCut)->pFanins[i])); i++ )

Definition at line 131 of file cswInt.h.

#define Csw_ObjForEachCut (   p,
  pObj,
  pCut,
 
)    for ( i = 0, pCut = Csw_ObjCuts(p, pObj); i < p->nCutsMax; i++, pCut = Csw_CutNext(pCut) )

MACRO DEFINITIONS ///.

ITERATORS ///

Definition at line 128 of file cswInt.h.

Typedef Documentation

typedef struct Csw_Cut_t_ Csw_Cut_t

Definition at line 53 of file cswInt.h.

typedef typedefABC_NAMESPACE_HEADER_START struct Csw_Man_t_ Csw_Man_t

INCLUDES ///.

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

FileName [cswInt.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Cut sweeping.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - July 11, 2007.]

Revision [

Id:
cswInt.h,v 1.00 2007/07/11 00:00:00 alanmi Exp

]PARAMETERS ///BASIC TYPES ///

Definition at line 52 of file cswInt.h.

Function Documentation

static int Csw_CutLeaveNum ( Csw_Cut_t pCut)
inlinestatic

Definition at line 102 of file cswInt.h.

102 { return pCut->nFanins; }
char nFanins
Definition: cswInt.h:65
static int* Csw_CutLeaves ( Csw_Cut_t pCut)
inlinestatic

Definition at line 103 of file cswInt.h.

103 { return pCut->pFanins; }
int pFanins[0]
Definition: cswInt.h:66
static Csw_Cut_t* Csw_CutNext ( Csw_Cut_t pCut)
inlinestatic

Definition at line 105 of file cswInt.h.

105 { return (Csw_Cut_t *)(((char *)pCut) + pCut->nCutSize); }
short nCutSize
Definition: cswInt.h:63
static unsigned* Csw_CutTruth ( Csw_Cut_t pCut)
inlinestatic

Definition at line 104 of file cswInt.h.

104 { return (unsigned *)(pCut->pFanins + pCut->nLeafMax); }
char nLeafMax
Definition: cswInt.h:64
int pFanins[0]
Definition: cswInt.h:66
Csw_Man_t* Csw_ManStart ( Aig_Man_t pMan,
int  nCutsMax,
int  nLeafMax,
int  fVerbose 
)

DECLARATIONS ///.

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

FileName [cswMan.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Cut sweeping.]

Synopsis []

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - July 11, 2007.]

Revision [

Id:
cswMan.c,v 1.00 2007/07/11 00:00:00 alanmi Exp

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

Synopsis [Starts the cut sweeping manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file cswMan.c.

46 {
47  Csw_Man_t * p;
48  Aig_Obj_t * pObj;
49  int i;
50  assert( nCutsMax >= 2 );
51  assert( nLeafMax <= 16 );
52  // allocate the fraiging manager
53  p = ABC_ALLOC( Csw_Man_t, 1 );
54  memset( p, 0, sizeof(Csw_Man_t) );
55  p->nCutsMax = nCutsMax;
56  p->nLeafMax = nLeafMax;
57  p->fVerbose = fVerbose;
58  p->pManAig = pMan;
59  // create the new manager
60  p->pManRes = Aig_ManStartFrom( pMan );
61  assert( Aig_ManCiNum(p->pManAig) == Aig_ManCiNum(p->pManRes) );
62  // allocate room for cuts and equivalent nodes
63  p->pnRefs = ABC_ALLOC( int, Aig_ManObjNumMax(pMan) );
64  p->pEquiv = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pMan) );
65  p->pCuts = ABC_ALLOC( Csw_Cut_t *, Aig_ManObjNumMax(pMan) );
66  memset( p->pCuts, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(pMan) );
67  memset( p->pnRefs, 0, sizeof(int) * Aig_ManObjNumMax(pMan) );
68  // allocate memory manager
69  p->nTruthWords = Abc_TruthWordNum(nLeafMax);
70  p->nCutSize = sizeof(Csw_Cut_t) + sizeof(int) * nLeafMax + sizeof(unsigned) * p->nTruthWords;
71  p->pMemCuts = Aig_MmFixedStart( p->nCutSize * p->nCutsMax, 512 );
72  // allocate hash table for cuts
73  p->nTableSize = Abc_PrimeCudd( Aig_ManNodeNum(pMan) * p->nCutsMax / 2 );
74  p->pTable = ABC_ALLOC( Csw_Cut_t *, p->nTableSize );
75  memset( p->pTable, 0, sizeof(Aig_Obj_t *) * p->nTableSize );
76  // set the pointers to the available fraig nodes
77  Csw_ObjSetEquiv( p, Aig_ManConst1(p->pManAig), Aig_ManConst1(p->pManRes) );
78  Aig_ManForEachCi( p->pManAig, pObj, i )
79  Csw_ObjSetEquiv( p, pObj, Aig_ManCi(p->pManRes, i) );
80  // room for temporary truth tables
81  p->puTemp[0] = ABC_ALLOC( unsigned, 4 * p->nTruthWords );
82  p->puTemp[1] = p->puTemp[0] + p->nTruthWords;
83  p->puTemp[2] = p->puTemp[1] + p->nTruthWords;
84  p->puTemp[3] = p->puTemp[2] + p->nTruthWords;
85  return p;
86 }
char * memset()
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
typedefABC_NAMESPACE_HEADER_START struct Csw_Man_t_ Csw_Man_t
INCLUDES ///.
Definition: cswInt.h:52
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
#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
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
static Aig_Obj_t * Aig_ManCi(Aig_Man_t *p, int i)
Definition: aig.h:266
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
Definition: aig.h:69
Aig_Man_t * Aig_ManStartFrom(Aig_Man_t *p)
Definition: aigMan.c:92
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
static void Csw_ObjSetEquiv(Csw_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pEquiv)
Definition: cswInt.h:114
#define assert(ex)
Definition: util_old.h:213
struct Csw_Cut_t_ Csw_Cut_t
Definition: cswInt.h:53
void Csw_ManStop ( Csw_Man_t p)

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

Synopsis [Stops the fraiging manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 99 of file cswMan.c.

100 {
101  if ( p->fVerbose )
102  {
103  int nNodesBeg = Aig_ManNodeNum(p->pManAig);
104  int nNodesEnd = Aig_ManNodeNum(p->pManRes);
105  printf( "Beg = %7d. End = %7d. (%6.2f %%) Try = %7d. Cuts = %8d.\n",
106  nNodesBeg, nNodesEnd, 100.0*(nNodesBeg-nNodesEnd)/nNodesBeg,
107  p->nNodesTried, Csw_TableCountCuts( p ) );
108  printf( "Triv0 = %6d. Triv1 = %6d. Triv2 = %6d. Cut-replace = %6d.\n",
109  p->nNodesTriv0, p->nNodesTriv1, p->nNodesTriv2, p->nNodesCuts );
110  ABC_PRTP( "Cuts ", p->timeCuts, p->timeTotal );
111  ABC_PRTP( "Hashing ", p->timeHash, p->timeTotal );
112  ABC_PRTP( "Other ", p->timeOther, p->timeTotal );
113  ABC_PRTP( "TOTAL ", p->timeTotal, p->timeTotal );
114  }
115  ABC_FREE( p->puTemp[0] );
116  Aig_MmFixedStop( p->pMemCuts, 0 );
117  ABC_FREE( p->pnRefs );
118  ABC_FREE( p->pEquiv );
119  ABC_FREE( p->pCuts );
120  ABC_FREE( p->pTable );
121  ABC_FREE( p );
122 }
int Csw_TableCountCuts(Csw_Man_t *p)
Definition: cswTable.c:82
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Aig_MmFixedStop(Aig_MmFixed_t *p, int fVerbose)
Definition: aigMem.c:132
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
#define ABC_PRTP(a, t, T)
Definition: abc_global.h:223
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Csw_ObjAddRefs ( Csw_Man_t p,
Aig_Obj_t pObj,
int  nRefs 
)
inlinestatic

Definition at line 108 of file cswInt.h.

108 { p->pnRefs[pObj->Id] += nRefs; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Id
Definition: aig.h:85
static Aig_Obj_t* Csw_ObjChild0Equiv ( Csw_Man_t p,
Aig_Obj_t pObj 
)
inlinestatic

Definition at line 116 of file cswInt.h.

116 { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin0(pObj)? Aig_NotCond(Csw_ObjEquiv(p, Aig_ObjFanin0(pObj)), Aig_ObjFaninC0(pObj)) : NULL; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Csw_ObjEquiv(Csw_Man_t *p, Aig_Obj_t *pObj)
Definition: cswInt.h:113
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
#define assert(ex)
Definition: util_old.h:213
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
static Aig_Obj_t* Csw_ObjChild1Equiv ( Csw_Man_t p,
Aig_Obj_t pObj 
)
inlinestatic

Definition at line 117 of file cswInt.h.

117 { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin1(pObj)? Aig_NotCond(Csw_ObjEquiv(p, Aig_ObjFanin1(pObj)), Aig_ObjFaninC1(pObj)) : NULL; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Csw_ObjEquiv(Csw_Man_t *p, Aig_Obj_t *pObj)
Definition: cswInt.h:113
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
#define assert(ex)
Definition: util_old.h:213
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
static Csw_Cut_t* Csw_ObjCuts ( Csw_Man_t p,
Aig_Obj_t pObj 
)
inlinestatic

Definition at line 110 of file cswInt.h.

110 { return p->pCuts[pObj->Id]; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Id
Definition: aig.h:85
static Aig_Obj_t* Csw_ObjEquiv ( Csw_Man_t p,
Aig_Obj_t pObj 
)
inlinestatic

Definition at line 113 of file cswInt.h.

113 { return p->pEquiv[pObj->Id]; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Id
Definition: aig.h:85
Csw_Cut_t* Csw_ObjPrepareCuts ( Csw_Man_t p,
Aig_Obj_t pObj,
int  fTriv 
)

FUNCTION DECLARATIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 453 of file cswCut.c.

454 {
455  Csw_Cut_t * pCutSet, * pCut;
456  int i;
457  // create the cutset of the node
458  pCutSet = (Csw_Cut_t *)Aig_MmFixedEntryFetch( p->pMemCuts );
459  Csw_ObjSetCuts( p, pObj, pCutSet );
460  Csw_ObjForEachCut( p, pObj, pCut, i )
461  {
462  pCut->nFanins = 0;
463  pCut->iNode = pObj->Id;
464  pCut->nCutSize = p->nCutSize;
465  pCut->nLeafMax = p->nLeafMax;
466  }
467  // add unit cut if needed
468  if ( fTriv )
469  {
470  pCut = pCutSet;
471  pCut->Cost = 0;
472  pCut->iNode = pObj->Id;
473  pCut->nFanins = 1;
474  pCut->pFanins[0] = pObj->Id;
475  pCut->uSign = Aig_ObjCutSign( pObj->Id );
476  memset( Csw_CutTruth(pCut), 0xAA, sizeof(unsigned) * p->nTruthWords );
477  }
478  return pCutSet;
479 }
char * memset()
int iNode
Definition: cswInt.h:62
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Cost
Definition: cswInt.h:59
short nCutSize
Definition: cswInt.h:63
static unsigned Aig_ObjCutSign(unsigned ObjId)
MACRO DEFINITIONS ///.
Definition: aig.h:228
static unsigned * Csw_CutTruth(Csw_Cut_t *pCut)
Definition: cswInt.h:104
static void Csw_ObjSetCuts(Csw_Man_t *p, Aig_Obj_t *pObj, Csw_Cut_t *pCuts)
Definition: cswInt.h:111
#define Csw_ObjForEachCut(p, pObj, pCut, i)
MACRO DEFINITIONS ///.
Definition: cswInt.h:128
char * Aig_MmFixedEntryFetch(Aig_MmFixed_t *p)
Definition: aigMem.c:161
char nLeafMax
Definition: cswInt.h:64
int pFanins[0]
Definition: cswInt.h:66
unsigned uSign
Definition: cswInt.h:61
int Id
Definition: aig.h:85
char nFanins
Definition: cswInt.h:65
static int Csw_ObjRefs ( Csw_Man_t p,
Aig_Obj_t pObj 
)
inlinestatic

Definition at line 107 of file cswInt.h.

107 { return p->pnRefs[pObj->Id]; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Id
Definition: aig.h:85
static void Csw_ObjSetCuts ( Csw_Man_t p,
Aig_Obj_t pObj,
Csw_Cut_t pCuts 
)
inlinestatic

Definition at line 111 of file cswInt.h.

111 { p->pCuts[pObj->Id] = pCuts; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Id
Definition: aig.h:85
static void Csw_ObjSetEquiv ( Csw_Man_t p,
Aig_Obj_t pObj,
Aig_Obj_t pEquiv 
)
inlinestatic

Definition at line 114 of file cswInt.h.

114 { p->pEquiv[pObj->Id] = pEquiv; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Id
Definition: aig.h:85
Aig_Obj_t* Csw_ObjSweep ( Csw_Man_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 492 of file cswCut.c.

493 {
494  int fUseResub = 1;
495  Csw_Cut_t * pCut0, * pCut1, * pCut, * pCutSet;
496  Aig_Obj_t * pFanin0 = Aig_ObjFanin0(pObj);
497  Aig_Obj_t * pFanin1 = Aig_ObjFanin1(pObj);
498  Aig_Obj_t * pObjNew;
499  unsigned * pTruth;
500  int i, k, nVars, nFanins, iVar;
501  abctime clk;
502 
503  assert( !Aig_IsComplement(pObj) );
504  if ( !Aig_ObjIsNode(pObj) )
505  return pObj;
506  if ( Csw_ObjCuts(p, pObj) )
507  return pObj;
508  // the node is not processed yet
509  assert( Csw_ObjCuts(p, pObj) == NULL );
510  assert( Aig_ObjIsNode(pObj) );
511 
512  // set up the first cut
513  pCutSet = Csw_ObjPrepareCuts( p, pObj, fTriv );
514 
515  // compute pair-wise cut combinations while checking table
516  Csw_ObjForEachCut( p, pFanin0, pCut0, i )
517  if ( pCut0->nFanins > 0 )
518  Csw_ObjForEachCut( p, pFanin1, pCut1, k )
519  if ( pCut1->nFanins > 0 )
520  {
521  // make sure K-feasible cut exists
522  if ( Kit_WordCountOnes(pCut0->uSign | pCut1->uSign) > p->nLeafMax )
523  continue;
524  // get the next cut of this node
525  pCut = Csw_CutFindFree( p, pObj );
526 clk = Abc_Clock();
527  // assemble the new cut
528  if ( !Csw_CutMerge( p, pCut0, pCut1, pCut ) )
529  {
530  assert( pCut->nFanins == 0 );
531  continue;
532  }
533  // check containment
534  if ( Csw_CutFilter( p, pObj, pCut ) )
535  {
536  assert( pCut->nFanins == 0 );
537  continue;
538  }
539  // create its truth table
540  pTruth = Csw_CutComputeTruth( p, pCut, pCut0, pCut1, Aig_ObjFaninC0(pObj), Aig_ObjFaninC1(pObj) );
541  // support minimize the truth table
542  nFanins = pCut->nFanins;
543 // nVars = Csw_CutSupportMinimize( p, pCut ); // leads to quality degradation
544  nVars = Kit_TruthSupportSize( pTruth, p->nLeafMax );
545 p->timeCuts += Abc_Clock() - clk;
546 
547  // check for trivial truth tables
548  if ( nVars == 0 )
549  {
550  p->nNodesTriv0++;
551  return Aig_NotCond( Aig_ManConst1(p->pManRes), !(pTruth[0] & 1) );
552  }
553  if ( nVars == 1 )
554  {
555  p->nNodesTriv1++;
556  iVar = Kit_WordFindFirstBit( Kit_TruthSupport(pTruth, p->nLeafMax) );
557  assert( iVar < pCut->nFanins );
558  return Aig_NotCond( Aig_ManObj(p->pManRes, pCut->pFanins[iVar]), (pTruth[0] & 1) );
559  }
560  if ( nVars == 2 && nFanins > 2 && fUseResub )
561  {
562  if ( (pObjNew = Csw_ObjTwoVarCut( p, pCut )) )
563  {
564  p->nNodesTriv2++;
565  return pObjNew;
566  }
567  }
568 
569  // check if an equivalent node with the same cut exists
570 clk = Abc_Clock();
571  pObjNew = pCut->nFanins > 2 ? Csw_TableCutLookup( p, pCut ) : NULL;
572 p->timeHash += Abc_Clock() - clk;
573  if ( pObjNew )
574  {
575  p->nNodesCuts++;
576  return pObjNew;
577  }
578 
579  // assign the cost
580  pCut->Cost = Csw_CutFindCost( p, pCut );
581  assert( pCut->nFanins > 0 );
582  assert( pCut->Cost > 0 );
583  }
584  p->nNodesTried++;
585 
586  // load the resulting cuts into the table
587 clk = Abc_Clock();
588  Csw_ObjForEachCut( p, pObj, pCut, i )
589  {
590  if ( pCut->nFanins > 2 )
591  {
592  assert( pCut->Cost > 0 );
593  Csw_TableCutInsert( p, pCut );
594  }
595  }
596 p->timeHash += Abc_Clock() - clk;
597 
598  // return the node if could not replace it
599  return pObj;
600 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Cost
Definition: cswInt.h:59
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
static Aig_Obj_t * Aig_ManObj(Aig_Man_t *p, int i)
Definition: aig.h:270
int Csw_CutMerge(Csw_Man_t *p, Csw_Cut_t *pCut0, Csw_Cut_t *pCut1, Csw_Cut_t *pCut)
Definition: cswCut.c:380
static abctime Abc_Clock()
Definition: abc_global.h:279
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
Csw_Cut_t * Csw_ObjPrepareCuts(Csw_Man_t *p, Aig_Obj_t *pObj, int fTriv)
FUNCTION DECLARATIONS ///.
Definition: cswCut.c:453
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
#define Csw_ObjForEachCut(p, pObj, pCut, i)
MACRO DEFINITIONS ///.
Definition: cswInt.h:128
if(last==0)
Definition: sparse_int.h:34
Definition: aig.h:69
static Csw_Cut_t * Csw_ObjCuts(Csw_Man_t *p, Aig_Obj_t *pObj)
Definition: cswInt.h:110
Aig_Obj_t * Csw_TableCutLookup(Csw_Man_t *p, Csw_Cut_t *pCut)
Definition: cswTable.c:121
int pFanins[0]
Definition: cswInt.h:66
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 ABC_NAMESPACE_IMPL_START int Csw_CutFindCost(Csw_Man_t *p, Csw_Cut_t *pCut)
DECLARATIONS ///.
Definition: cswCut.c:45
static int Kit_WordFindFirstBit(unsigned uWord)
Definition: kit.h:231
int Csw_CutFilter(Csw_Man_t *p, Aig_Obj_t *pObj, Csw_Cut_t *pCut)
Definition: cswCut.c:243
unsigned uSign
Definition: cswInt.h:61
void Csw_TableCutInsert(Csw_Man_t *p, Csw_Cut_t *pCut)
Definition: cswTable.c:103
unsigned Kit_TruthSupport(unsigned *pTruth, int nVars)
Definition: kitTruth.c:346
static Csw_Cut_t * Csw_CutFindFree(Csw_Man_t *p, Aig_Obj_t *pObj)
Definition: cswCut.c:93
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
Aig_Obj_t * Csw_ObjTwoVarCut(Csw_Man_t *p, Csw_Cut_t *pCut)
Definition: cswCut.c:409
#define assert(ex)
Definition: util_old.h:213
static int Kit_WordCountOnes(unsigned uWord)
Definition: kit.h:243
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
unsigned * Csw_CutComputeTruth(Csw_Man_t *p, Csw_Cut_t *pCut, Csw_Cut_t *pCut0, Csw_Cut_t *pCut1, int fCompl0, int fCompl1)
Definition: cswCut.c:149
ABC_INT64_T abctime
Definition: abc_global.h:278
int Kit_TruthSupportSize(unsigned *pTruth, int nVars)
Definition: kitTruth.c:327
char nFanins
Definition: cswInt.h:65
int Csw_TableCountCuts ( Csw_Man_t p)

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

Synopsis [Returns the total number of cuts in the table.]

Description []

SideEffects []

SeeAlso []

Definition at line 82 of file cswTable.c.

83 {
84  Csw_Cut_t * pEnt;
85  int i, Counter = 0;
86  for ( i = 0; i < p->nTableSize; i++ )
87  for ( pEnt = p->pTable[i]; pEnt; pEnt = pEnt->pNext )
88  Counter++;
89  return Counter;
90 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Counter
Csw_Cut_t * pNext
Definition: cswInt.h:58
void Csw_TableCutInsert ( Csw_Man_t p,
Csw_Cut_t pCut 
)

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

Synopsis [Adds the cut to the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 103 of file cswTable.c.

104 {
105  int iEntry = Csw_CutHash(pCut) % p->nTableSize;
106  pCut->pNext = p->pTable[iEntry];
107  p->pTable[iEntry] = pCut;
108 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
ABC_NAMESPACE_IMPL_START unsigned Csw_CutHash(Csw_Cut_t *pCut)
DECLARATIONS ///.
Definition: cswTable.c:45
Csw_Cut_t * pNext
Definition: cswInt.h:58
Aig_Obj_t* Csw_TableCutLookup ( Csw_Man_t p,
Csw_Cut_t pCut 
)

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

Synopsis [Returns an equivalent node if it exists.]

Description []

SideEffects []

SeeAlso []

Definition at line 121 of file cswTable.c.

122 {
123  Aig_Obj_t * pRes = NULL;
124  Csw_Cut_t * pEnt;
125  unsigned * pTruthNew, * pTruthOld;
126  int iEntry = Csw_CutHash(pCut) % p->nTableSize;
127  for ( pEnt = p->pTable[iEntry]; pEnt; pEnt = pEnt->pNext )
128  {
129  if ( pEnt->nFanins != pCut->nFanins )
130  continue;
131  if ( pEnt->uSign != pCut->uSign )
132  continue;
133  if ( memcmp( pEnt->pFanins, pCut->pFanins, sizeof(int) * pCut->nFanins ) )
134  continue;
135  pTruthOld = Csw_CutTruth(pEnt);
136  pTruthNew = Csw_CutTruth(pCut);
137  if ( (pTruthOld[0] & 1) == (pTruthNew[0] & 1) )
138  {
139  if ( Kit_TruthIsEqual( pTruthOld, pTruthNew, pCut->nFanins ) )
140  {
141  pRes = Aig_ManObj( p->pManRes, pEnt->iNode );
142  assert( pRes->fPhase == Aig_ManObj( p->pManRes, pCut->iNode )->fPhase );
143  break;
144  }
145  }
146  else
147  {
148  if ( Kit_TruthIsOpposite( pTruthOld, pTruthNew, pCut->nFanins ) )
149  {
150  pRes = Aig_Not( Aig_ManObj( p->pManRes, pEnt->iNode ) );
151  assert( Aig_Regular(pRes)->fPhase != Aig_ManObj( p->pManRes, pCut->iNode )->fPhase );
152  break;
153  }
154  }
155  }
156  return pRes;
157 }
int iNode
Definition: cswInt.h:62
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
static Aig_Obj_t * Aig_ManObj(Aig_Man_t *p, int i)
Definition: aig.h:270
static int Kit_TruthIsEqual(unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:274
static Aig_Obj_t * Aig_Not(Aig_Obj_t *p)
Definition: aig.h:247
static unsigned * Csw_CutTruth(Csw_Cut_t *pCut)
Definition: cswInt.h:104
ABC_NAMESPACE_IMPL_START unsigned Csw_CutHash(Csw_Cut_t *pCut)
DECLARATIONS ///.
Definition: cswTable.c:45
int memcmp()
Definition: aig.h:69
int pFanins[0]
Definition: cswInt.h:66
unsigned int fPhase
Definition: aig.h:78
static int Kit_TruthIsOpposite(unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:290
unsigned uSign
Definition: cswInt.h:61
#define assert(ex)
Definition: util_old.h:213
Csw_Cut_t * pNext
Definition: cswInt.h:58
char nFanins
Definition: cswInt.h:65