abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
bdc.h File Reference

Go to the source code of this file.

Data Structures

struct  Bdc_Par_t_
 

Typedefs

typedef
typedefABC_NAMESPACE_HEADER_START
struct Bdc_Fun_t_ 
Bdc_Fun_t
 INCLUDES ///. More...
 
typedef struct Bdc_Man_t_ Bdc_Man_t
 
typedef struct Bdc_Par_t_ Bdc_Par_t
 

Functions

static int Bdc_IsComplement (Bdc_Fun_t *p)
 
static Bdc_Fun_tBdc_Regular (Bdc_Fun_t *p)
 
static Bdc_Fun_tBdc_Not (Bdc_Fun_t *p)
 
static Bdc_Fun_tBdc_NotCond (Bdc_Fun_t *p, int c)
 
Bdc_Man_tBdc_ManAlloc (Bdc_Par_t *pPars)
 MACRO DEFINITIONS ///. More...
 
void Bdc_ManFree (Bdc_Man_t *p)
 
void Bdc_ManDecPrint (Bdc_Man_t *p)
 
int Bdc_ManDecompose (Bdc_Man_t *p, unsigned *puFunc, unsigned *puCare, int nVars, Vec_Ptr_t *vDivs, int nNodesMax)
 
Bdc_Fun_tBdc_ManFunc (Bdc_Man_t *p, int i)
 DECLARATIONS ///. More...
 
Bdc_Fun_tBdc_ManRoot (Bdc_Man_t *p)
 
int Bdc_ManNodeNum (Bdc_Man_t *p)
 
int Bdc_ManAndNum (Bdc_Man_t *p)
 
Bdc_Fun_tBdc_FuncFanin0 (Bdc_Fun_t *p)
 
Bdc_Fun_tBdc_FuncFanin1 (Bdc_Fun_t *p)
 
void * Bdc_FuncCopy (Bdc_Fun_t *p)
 
int Bdc_FuncCopyInt (Bdc_Fun_t *p)
 
void Bdc_FuncSetCopy (Bdc_Fun_t *p, void *pCopy)
 
void Bdc_FuncSetCopyInt (Bdc_Fun_t *p, int iCopy)
 
static int Bdc_FunObjCopy (Bdc_Fun_t *pObj)
 
static int Bdc_FunFanin0Copy (Bdc_Fun_t *pObj)
 
static int Bdc_FunFanin1Copy (Bdc_Fun_t *pObj)
 

Typedef Documentation

typedef typedefABC_NAMESPACE_HEADER_START struct Bdc_Fun_t_ Bdc_Fun_t

INCLUDES ///.

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

FileName [bdc.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Truth-table-based bi-decomposition engine.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - January 30, 2007.]

Revision [

Id:
bdc.h,v 1.00 2007/01/30 00:00:00 alanmi Exp

]PARAMETERS ///BASIC TYPES ///

Definition at line 42 of file bdc.h.

typedef struct Bdc_Man_t_ Bdc_Man_t

Definition at line 43 of file bdc.h.

typedef struct Bdc_Par_t_ Bdc_Par_t

Definition at line 44 of file bdc.h.

Function Documentation

void* Bdc_FuncCopy ( Bdc_Fun_t p)

Definition at line 52 of file bdcCore.c.

52 { return p->pCopy; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Bdc_FuncCopyInt ( Bdc_Fun_t p)

Definition at line 53 of file bdcCore.c.

53 { return p->iCopy; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Bdc_Fun_t* Bdc_FuncFanin0 ( Bdc_Fun_t p)

Definition at line 50 of file bdcCore.c.

50 { return p->pFan0; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Bdc_Fun_t* Bdc_FuncFanin1 ( Bdc_Fun_t p)

Definition at line 51 of file bdcCore.c.

51 { return p->pFan1; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Bdc_FuncSetCopy ( Bdc_Fun_t p,
void *  pCopy 
)

Definition at line 54 of file bdcCore.c.

54 { p->pCopy = pCopy; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Bdc_FuncSetCopyInt ( Bdc_Fun_t p,
int  iCopy 
)

Definition at line 55 of file bdcCore.c.

55 { p->iCopy = iCopy; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Bdc_FunFanin0Copy ( Bdc_Fun_t pObj)
inlinestatic

Definition at line 85 of file bdc.h.

85 { return Bdc_FunObjCopy( Bdc_FuncFanin0(pObj) ); }
Bdc_Fun_t * Bdc_FuncFanin0(Bdc_Fun_t *p)
Definition: bdcCore.c:50
static int Bdc_FunObjCopy(Bdc_Fun_t *pObj)
Definition: bdc.h:84
static int Bdc_FunFanin1Copy ( Bdc_Fun_t pObj)
inlinestatic

Definition at line 86 of file bdc.h.

86 { return Bdc_FunObjCopy( Bdc_FuncFanin1(pObj) ); }
static int Bdc_FunObjCopy(Bdc_Fun_t *pObj)
Definition: bdc.h:84
Bdc_Fun_t * Bdc_FuncFanin1(Bdc_Fun_t *p)
Definition: bdcCore.c:51
static int Bdc_FunObjCopy ( Bdc_Fun_t pObj)
inlinestatic

Definition at line 84 of file bdc.h.

static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
int Bdc_FuncCopyInt(Bdc_Fun_t *p)
Definition: bdcCore.c:53
static int Bdc_IsComplement(Bdc_Fun_t *p)
Definition: bdc.h:54
static Bdc_Fun_t * Bdc_Regular(Bdc_Fun_t *p)
Definition: bdc.h:55
static int Bdc_IsComplement ( Bdc_Fun_t p)
inlinestatic

Definition at line 54 of file bdc.h.

54 { return (int)((ABC_PTRUINT_T)p & (ABC_PTRUINT_T)01); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Bdc_Man_t* Bdc_ManAlloc ( Bdc_Par_t pPars)

MACRO DEFINITIONS ///.

FUNCTION DECLARATIONS ///

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

Synopsis [Allocate resynthesis manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 68 of file bdcCore.c.

69 {
70  Bdc_Man_t * p;
71  p = ABC_ALLOC( Bdc_Man_t, 1 );
72  memset( p, 0, sizeof(Bdc_Man_t) );
73  assert( pPars->nVarsMax > 1 && pPars->nVarsMax < 16 );
74  p->pPars = pPars;
75  p->nWords = Kit_TruthWordNum( pPars->nVarsMax );
76  p->nDivsLimit = 200;
77  // internal nodes
78  p->nNodesAlloc = 512;
80  // memory
81  p->vMemory = Vec_IntStart( 8 * p->nWords * p->nNodesAlloc );
83  // set up hash table
84  p->nTableSize = (1 << p->pPars->nVarsMax);
85  p->pTable = ABC_ALLOC( Bdc_Fun_t *, p->nTableSize );
86  memset( p->pTable, 0, sizeof(Bdc_Fun_t *) * p->nTableSize );
87  p->vSpots = Vec_IntAlloc( 256 );
88  // truth tables
90  p->puTemp1 = ABC_ALLOC( unsigned, 4 * p->nWords );
91  p->puTemp2 = p->puTemp1 + p->nWords;
92  p->puTemp3 = p->puTemp2 + p->nWords;
93  p->puTemp4 = p->puTemp3 + p->nWords;
94  // start the internal ISFs
95  p->pIsfOL = &p->IsfOL; Bdc_IsfStart( p, p->pIsfOL );
96  p->pIsfOR = &p->IsfOR; Bdc_IsfStart( p, p->pIsfOR );
97  p->pIsfAL = &p->IsfAL; Bdc_IsfStart( p, p->pIsfAL );
98  p->pIsfAR = &p->IsfAR; Bdc_IsfStart( p, p->pIsfAR );
99  return p;
100 }
char * memset()
Bdc_Isf_t IsfOR
Definition: bdcInt.h:107
Vec_Ptr_t * vTruths
Definition: bdcInt.h:100
Vec_Int_t * vMemory
Definition: bdcInt.h:111
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int nVarsMax
Definition: bdc.h:48
unsigned * puTemp2
Definition: bdcInt.h:102
unsigned * puTemp4
Definition: bdcInt.h:104
Bdc_Isf_t * pIsfAR
Definition: bdcInt.h:109
Bdc_Isf_t IsfAR
Definition: bdcInt.h:109
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Bdc_Par_t * pPars
Definition: bdcInt.h:84
unsigned * puTemp3
Definition: bdcInt.h:103
Vec_Int_t * vSpots
Definition: bdcInt.h:98
static Vec_Ptr_t * Vec_PtrAllocTruthTables(int nVars)
Definition: vecPtr.h:1065
static Vec_Int_t * Vec_IntStart(int nSize)
Definition: bblif.c:172
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
typedefABC_NAMESPACE_HEADER_START struct Bdc_Fun_t_ Bdc_Fun_t
INCLUDES ///.
Definition: bdc.h:42
unsigned * puTemp1
Definition: bdcInt.h:101
Bdc_Isf_t * pIsfOL
Definition: bdcInt.h:106
Bdc_Fun_t ** pTable
Definition: bdcInt.h:96
Bdc_Fun_t * pNodes
Definition: bdcInt.h:90
Bdc_Isf_t * pIsfOR
Definition: bdcInt.h:107
int nNodesAlloc
Definition: bdcInt.h:91
Bdc_Isf_t * pIsfAL
Definition: bdcInt.h:108
#define assert(ex)
Definition: util_old.h:213
int nTableSize
Definition: bdcInt.h:97
Bdc_Isf_t IsfOL
Definition: bdcInt.h:106
Bdc_Isf_t IsfAL
Definition: bdcInt.h:108
int nDivsLimit
Definition: bdcInt.h:88
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
int nWords
Definition: bdcInt.h:86
static void Bdc_IsfStart(Bdc_Man_t *p, Bdc_Isf_t *pF)
Definition: bdcInt.h:131
int Bdc_ManAndNum ( Bdc_Man_t p)

Definition at line 49 of file bdcCore.c.

49 { return p->nNodes-p->nVars-1;}
int nVars
Definition: bdcInt.h:85
int nNodes
Definition: bdcInt.h:92
int Bdc_ManDecompose ( Bdc_Man_t p,
unsigned *  puFunc,
unsigned *  puCare,
int  nVars,
Vec_Ptr_t vDivs,
int  nNodesMax 
)

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

Synopsis [Performs decomposition of one function.]

Description []

SideEffects []

SeeAlso []

Definition at line 291 of file bdcCore.c.

292 {
293  Bdc_Isf_t Isf, * pIsf = &Isf;
294  abctime clk = Abc_Clock();
295  assert( nVars <= p->pPars->nVarsMax );
296  // set current manager parameters
297  p->nVars = nVars;
298  p->nWords = Kit_TruthWordNum( nVars );
299  p->nNodesMax = nNodesMax;
300  Bdc_ManPrepare( p, vDivs );
301  if ( puCare && Kit_TruthIsConst0( puCare, nVars ) )
302  {
303  p->pRoot = Bdc_Not(p->pNodes);
304  return 0;
305  }
306  // copy the function
307  Bdc_IsfStart( p, pIsf );
308  if ( puCare )
309  {
310  Kit_TruthAnd( pIsf->puOn, puCare, puFunc, p->nVars );
311  Kit_TruthSharp( pIsf->puOff, puCare, puFunc, p->nVars );
312  }
313  else
314  {
315  Kit_TruthCopy( pIsf->puOn, puFunc, p->nVars );
316  Kit_TruthNot( pIsf->puOff, puFunc, p->nVars );
317  }
318  Bdc_SuppMinimize( p, pIsf );
319  // call decomposition
320  p->pRoot = Bdc_ManDecompose_rec( p, pIsf );
321  p->timeTotal += Abc_Clock() - clk;
322  p->numCalls++;
323  p->numNodes += p->nNodesNew;
324  if ( p->pRoot == NULL )
325  return -1;
326  if ( !Bdc_ManNodeVerify( p, pIsf, p->pRoot ) )
327  printf( "Bdc_ManDecompose(): Internal verification failed.\n" );
328 // assert( Bdc_ManNodeVerify( p, pIsf, p->pRoot ) );
329  return p->nNodesNew;
330 }
static int Kit_TruthWordNum(int nVars)
Definition: kit.h:224
int nVars
Definition: bdcInt.h:85
int nNodesNew
Definition: bdcInt.h:93
int numCalls
Definition: bdcInt.h:113
static int Kit_TruthIsConst0(unsigned *pIn, int nVars)
Definition: kit.h:315
void Bdc_ManPrepare(Bdc_Man_t *p, Vec_Ptr_t *vDivs)
Definition: bdcCore.c:147
static abctime Abc_Clock()
Definition: abc_global.h:279
unsigned * puOff
Definition: bdcInt.h:78
Bdc_Fun_t * Bdc_ManDecompose_rec(Bdc_Man_t *p, Bdc_Isf_t *pIsf)
MACRO DEFINITIONS ///.
Definition: bdcDec.c:675
static void Kit_TruthAnd(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:379
Bdc_Fun_t * pRoot
Definition: bdcInt.h:94
void Bdc_SuppMinimize(Bdc_Man_t *p, Bdc_Isf_t *pIsf)
Definition: bdcDec.c:87
static void Kit_TruthNot(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:373
int nNodesMax
Definition: bdcInt.h:87
static void Kit_TruthSharp(unsigned *pOut, unsigned *pIn0, unsigned *pIn1, int nVars)
Definition: kit.h:397
unsigned * puOn
Definition: bdcInt.h:77
Bdc_Fun_t * pNodes
Definition: bdcInt.h:90
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
static Bdc_Fun_t * Bdc_Not(Bdc_Fun_t *p)
Definition: bdc.h:56
#define assert(ex)
Definition: util_old.h:213
ABC_INT64_T abctime
Definition: abc_global.h:278
abctime timeTotal
Definition: bdcInt.h:125
int Bdc_ManNodeVerify(Bdc_Man_t *p, Bdc_Isf_t *pIsf, Bdc_Fun_t *pFunc)
Definition: bdcDec.c:600
int nWords
Definition: bdcInt.h:86
int numNodes
Definition: bdcInt.h:114
static void Bdc_IsfStart(Bdc_Man_t *p, Bdc_Isf_t *pF)
Definition: bdcInt.h:131
void Bdc_ManDecPrint ( Bdc_Man_t p)

Definition at line 260 of file bdcCore.c.

261 {
262  Bdc_Fun_t * pRoot = Bdc_Regular(p->pRoot);
263 
264  printf( "F = " );
265  if ( pRoot->Type == BDC_TYPE_CONST1 ) // constant 0
266  printf( "Constant %d", !Bdc_IsComplement(p->pRoot) );
267  else if ( pRoot->Type == BDC_TYPE_PI ) // literal
268  printf( "%s%d", Bdc_IsComplement(p->pRoot) ? "!" : "", Bdc_FunId(p,pRoot)-1 );
269  else
270  {
271  if ( Bdc_IsComplement(p->pRoot) )
272  printf( "!(" );
273  Bdc_ManDecPrint_rec( p, pRoot );
274  if ( Bdc_IsComplement(p->pRoot) )
275  printf( ")" );
276  }
277  printf( "\n" );
278 }
void Bdc_ManDecPrint_rec(Bdc_Man_t *p, Bdc_Fun_t *pNode)
Definition: bdcCore.c:233
typedefABC_NAMESPACE_HEADER_START struct Bdc_Fun_t_ Bdc_Fun_t
INCLUDES ///.
Definition: bdc.h:42
Bdc_Fun_t * pRoot
Definition: bdcInt.h:94
static int Bdc_FunId(Bdc_Man_t *p, Bdc_Fun_t *pFun)
Definition: bdcInt.h:130
static int Bdc_IsComplement(Bdc_Fun_t *p)
Definition: bdc.h:54
static Bdc_Fun_t * Bdc_Regular(Bdc_Fun_t *p)
Definition: bdc.h:55
void Bdc_ManFree ( Bdc_Man_t p)

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

Synopsis [Deallocate resynthesis manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 113 of file bdcCore.c.

114 {
115  if ( p->pPars->fVerbose )
116  {
117  printf( "Bi-decomposition stats: Calls = %d. Nodes = %d. Reuse = %d.\n",
118  p->numCalls, p->numNodes, p->numReuse );
119  printf( "ANDs = %d. ORs = %d. Weak = %d. Muxes = %d. Memory = %.2f K\n",
120  p->numAnds, p->numOrs, p->numWeaks, p->numMuxes, 4.0 * Vec_IntSize(p->vMemory) / (1<<10) );
121  ABC_PRT( "Cache", p->timeCache );
122  ABC_PRT( "Check", p->timeCheck );
123  ABC_PRT( "Muxes", p->timeMuxes );
124  ABC_PRT( "Supps", p->timeSupps );
125  ABC_PRT( "TOTAL", p->timeTotal );
126  }
127  Vec_IntFree( p->vMemory );
128  Vec_IntFree( p->vSpots );
129  Vec_PtrFree( p->vTruths );
130  ABC_FREE( p->puTemp1 );
131  ABC_FREE( p->pNodes );
132  ABC_FREE( p->pTable );
133  ABC_FREE( p );
134 }
Vec_Ptr_t * vTruths
Definition: bdcInt.h:100
abctime timeCache
Definition: bdcInt.h:121
Vec_Int_t * vMemory
Definition: bdcInt.h:111
int fVerbose
Definition: bdc.h:49
abctime timeCheck
Definition: bdcInt.h:122
abctime timeMuxes
Definition: bdcInt.h:123
int numReuse
Definition: bdcInt.h:119
Bdc_Par_t * pPars
Definition: bdcInt.h:84
int numCalls
Definition: bdcInt.h:113
Vec_Int_t * vSpots
Definition: bdcInt.h:98
abctime timeSupps
Definition: bdcInt.h:124
unsigned * puTemp1
Definition: bdcInt.h:101
int numWeaks
Definition: bdcInt.h:118
int numOrs
Definition: bdcInt.h:117
Bdc_Fun_t ** pTable
Definition: bdcInt.h:96
int numAnds
Definition: bdcInt.h:116
Bdc_Fun_t * pNodes
Definition: bdcInt.h:90
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_PRT(a, t)
Definition: abc_global.h:220
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
abctime timeTotal
Definition: bdcInt.h:125
int numMuxes
Definition: bdcInt.h:115
int numNodes
Definition: bdcInt.h:114
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Bdc_Fun_t* Bdc_ManFunc ( Bdc_Man_t p,
int  i 
)

DECLARATIONS ///.

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

FileName [bdcCore.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Truth-table-based bi-decomposition engine.]

Synopsis [The gateway to bi-decomposition.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - January 30, 2007.]

Revision [

Id:
bdcCore.c,v 1.00 2007/01/30 00:00:00 alanmi Exp

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

Synopsis [Accessing contents of the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 46 of file bdcCore.c.

46 { return Bdc_FunWithId(p, i); }
static Bdc_Fun_t * Bdc_FunWithId(Bdc_Man_t *p, int Id)
Definition: bdcInt.h:129
int Bdc_ManNodeNum ( Bdc_Man_t p)

Definition at line 48 of file bdcCore.c.

48 { return p->nNodes; }
int nNodes
Definition: bdcInt.h:92
Bdc_Fun_t* Bdc_ManRoot ( Bdc_Man_t p)

Definition at line 47 of file bdcCore.c.

47 { return p->pRoot; }
Bdc_Fun_t * pRoot
Definition: bdcInt.h:94
static Bdc_Fun_t* Bdc_Not ( Bdc_Fun_t p)
inlinestatic

Definition at line 56 of file bdc.h.

56 { return (Bdc_Fun_t *)((ABC_PTRUINT_T)p ^ (ABC_PTRUINT_T)01); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_HEADER_START struct Bdc_Fun_t_ Bdc_Fun_t
INCLUDES ///.
Definition: bdc.h:42
static Bdc_Fun_t* Bdc_NotCond ( Bdc_Fun_t p,
int  c 
)
inlinestatic

Definition at line 57 of file bdc.h.

57 { return (Bdc_Fun_t *)((ABC_PTRUINT_T)p ^ (ABC_PTRUINT_T)(c!=0)); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_HEADER_START struct Bdc_Fun_t_ Bdc_Fun_t
INCLUDES ///.
Definition: bdc.h:42
static Bdc_Fun_t* Bdc_Regular ( Bdc_Fun_t p)
inlinestatic

Definition at line 55 of file bdc.h.

55 { return (Bdc_Fun_t *)((ABC_PTRUINT_T)p & ~(ABC_PTRUINT_T)01); }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_HEADER_START struct Bdc_Fun_t_ Bdc_Fun_t
INCLUDES ///.
Definition: bdc.h:42