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

Go to the source code of this file.

Data Structures

struct  Bdc_Fun_t_
 
struct  Bdc_Isf_t_
 
struct  Bdc_Man_t_
 

Macros

#define BDC_SCALE   1000
 INCLUDES ///. More...
 

Typedefs

typedef struct Bdc_Isf_t_ Bdc_Isf_t
 

Enumerations

enum  Bdc_Type_t {
  BDC_TYPE_NONE = 0, BDC_TYPE_CONST1, BDC_TYPE_PI, BDC_TYPE_AND,
  BDC_TYPE_OR, BDC_TYPE_XOR, BDC_TYPE_MUX, BDC_TYPE_OTHER
}
 BASIC TYPES ///. More...
 

Functions

static Bdc_Fun_tBdc_FunNew (Bdc_Man_t *p)
 
static Bdc_Fun_tBdc_FunWithId (Bdc_Man_t *p, int Id)
 
static int Bdc_FunId (Bdc_Man_t *p, Bdc_Fun_t *pFun)
 
static void Bdc_IsfStart (Bdc_Man_t *p, Bdc_Isf_t *pF)
 
static void Bdc_IsfClean (Bdc_Isf_t *p)
 
static void Bdc_IsfCopy (Bdc_Isf_t *p, Bdc_Isf_t *q)
 
static void Bdc_IsfNot (Bdc_Isf_t *p)
 
Bdc_Fun_tBdc_ManDecompose_rec (Bdc_Man_t *p, Bdc_Isf_t *pIsf)
 MACRO DEFINITIONS ///. More...
 
void Bdc_SuppMinimize (Bdc_Man_t *p, Bdc_Isf_t *pIsf)
 
int Bdc_ManNodeVerify (Bdc_Man_t *p, Bdc_Isf_t *pIsf, Bdc_Fun_t *pFunc)
 
Bdc_Fun_tBdc_TableLookup (Bdc_Man_t *p, Bdc_Isf_t *pIsf)
 
void Bdc_TableAdd (Bdc_Man_t *p, Bdc_Fun_t *pFunc)
 
void Bdc_TableClear (Bdc_Man_t *p)
 
int Bdc_TableCheckContainment (Bdc_Man_t *p, Bdc_Isf_t *pIsf, unsigned *puTruth)
 DECLARATIONS ///. More...
 

Macro Definition Documentation

#define BDC_SCALE   1000

INCLUDES ///.

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

FileName [bdcInt.h]

SystemName [ABC: Logic synthesis and verification system.]

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

Synopsis [Internal declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id:
resInt.h,v 1.00 2007/01/15 00:00:00 alanmi Exp

]PARAMETERS ///

Definition at line 41 of file bdcInt.h.

Typedef Documentation

typedef struct Bdc_Isf_t_ Bdc_Isf_t

Definition at line 72 of file bdcInt.h.

Enumeration Type Documentation

enum Bdc_Type_t

BASIC TYPES ///.

Enumerator
BDC_TYPE_NONE 
BDC_TYPE_CONST1 
BDC_TYPE_PI 
BDC_TYPE_AND 
BDC_TYPE_OR 
BDC_TYPE_XOR 
BDC_TYPE_MUX 
BDC_TYPE_OTHER 

Definition at line 48 of file bdcInt.h.

48  {
49  BDC_TYPE_NONE = 0, // 0: unknown
50  BDC_TYPE_CONST1, // 1: constant 1
51  BDC_TYPE_PI, // 2: primary input
52  BDC_TYPE_AND, // 3: AND-gate
53  BDC_TYPE_OR, // 4: OR-gate (temporary)
54  BDC_TYPE_XOR, // 5: XOR-gate
55  BDC_TYPE_MUX, // 6: MUX-gate
56  BDC_TYPE_OTHER // 7: unused
57 } Bdc_Type_t;
Bdc_Type_t
BASIC TYPES ///.
Definition: bdcInt.h:48

Function Documentation

static int Bdc_FunId ( Bdc_Man_t p,
Bdc_Fun_t pFun 
)
inlinestatic

Definition at line 130 of file bdcInt.h.

130 { return pFun - p->pNodes; }
Bdc_Fun_t * pNodes
Definition: bdcInt.h:90
static Bdc_Fun_t* Bdc_FunNew ( Bdc_Man_t p)
inlinestatic

Definition at line 128 of file bdcInt.h.

128 { Bdc_Fun_t * pRes; if ( p->nNodes >= p->nNodesAlloc || p->nNodesNew >= p->nNodesMax ) return NULL; pRes = p->pNodes + p->nNodes++; p->nNodesNew++; memset( pRes, 0, sizeof(Bdc_Fun_t) ); return pRes; }
char * memset()
int nNodesNew
Definition: bdcInt.h:93
typedefABC_NAMESPACE_HEADER_START struct Bdc_Fun_t_ Bdc_Fun_t
INCLUDES ///.
Definition: bdc.h:42
int nNodesMax
Definition: bdcInt.h:87
Bdc_Fun_t * pNodes
Definition: bdcInt.h:90
int nNodesAlloc
Definition: bdcInt.h:91
int nNodes
Definition: bdcInt.h:92
static Bdc_Fun_t* Bdc_FunWithId ( Bdc_Man_t p,
int  Id 
)
inlinestatic

Definition at line 129 of file bdcInt.h.

129 { assert( Id < p->nNodes ); return p->pNodes + Id; }
Bdc_Fun_t * pNodes
Definition: bdcInt.h:90
#define assert(ex)
Definition: util_old.h:213
static void Bdc_IsfClean ( Bdc_Isf_t p)
inlinestatic

Definition at line 132 of file bdcInt.h.

132 { p->uSupp = 0; p->uUniq = 0; }
unsigned uSupp
Definition: bdcInt.h:75
unsigned uUniq
Definition: bdcInt.h:76
static void Bdc_IsfCopy ( Bdc_Isf_t p,
Bdc_Isf_t q 
)
inlinestatic

Definition at line 133 of file bdcInt.h.

133 { Bdc_Isf_t T = *p; *p = *q; *q = T; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static void Bdc_IsfNot ( Bdc_Isf_t p)
inlinestatic

Definition at line 134 of file bdcInt.h.

134 { unsigned * puT = p->puOn; p->puOn = p->puOff; p->puOff = puT; }
unsigned * puOff
Definition: bdcInt.h:78
unsigned * puOn
Definition: bdcInt.h:77
static void Bdc_IsfStart ( Bdc_Man_t p,
Bdc_Isf_t pF 
)
inlinestatic

Definition at line 131 of file bdcInt.h.

131 { pF->uSupp = 0; pF->uUniq = 0; pF->puOn = Vec_IntFetch( p->vMemory, p->nWords ); pF->puOff = Vec_IntFetch( p->vMemory, p->nWords ); assert( pF->puOff && pF->puOn ); }
unsigned uSupp
Definition: bdcInt.h:75
Vec_Int_t * vMemory
Definition: bdcInt.h:111
static unsigned * Vec_IntFetch(Vec_Int_t *p, int nWords)
Definition: vecInt.h:853
unsigned * puOff
Definition: bdcInt.h:78
unsigned * puOn
Definition: bdcInt.h:77
unsigned uUniq
Definition: bdcInt.h:76
#define assert(ex)
Definition: util_old.h:213
int nWords
Definition: bdcInt.h:86
Bdc_Fun_t* Bdc_ManDecompose_rec ( Bdc_Man_t p,
Bdc_Isf_t pIsf 
)

MACRO DEFINITIONS ///.

FUNCTION DECLARATIONS ///

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

Synopsis [Performs one step of bi-decomposition.]

Description []

SideEffects []

SeeAlso []

Definition at line 675 of file bdcDec.c.

676 {
677 // int static Counter = 0;
678 // int LocalCounter = Counter++;
679  Bdc_Type_t Type;
680  Bdc_Fun_t * pFunc, * pFunc0, * pFunc1;
681  Bdc_Isf_t IsfL, * pIsfL = &IsfL;
682  Bdc_Isf_t IsfB, * pIsfR = &IsfB;
683  int iVar;
684  abctime clk = 0; // Suppress "might be used uninitialized"
685 /*
686 printf( "Init function (%d):\n", LocalCounter );
687 Extra_PrintBinary( stdout, pIsf->puOn, 1<<4 );printf("\n");
688 Extra_PrintBinary( stdout, pIsf->puOff, 1<<4 );printf("\n");
689 */
690  // check computed results
691  assert( Kit_TruthIsDisjoint(pIsf->puOn, pIsf->puOff, p->nVars) );
692  if ( p->pPars->fVerbose )
693  clk = Abc_Clock();
694  pFunc = Bdc_TableLookup( p, pIsf );
695  if ( p->pPars->fVerbose )
696  p->timeCache += Abc_Clock() - clk;
697  if ( pFunc )
698  return pFunc;
699  // decide on the decomposition type
700  if ( p->pPars->fVerbose )
701  clk = Abc_Clock();
702  Type = Bdc_DecomposeStep( p, pIsf, pIsfL, pIsfR );
703  if ( p->pPars->fVerbose )
704  p->timeCheck += Abc_Clock() - clk;
705  if ( Type == BDC_TYPE_MUX )
706  {
707  if ( p->pPars->fVerbose )
708  clk = Abc_Clock();
709  iVar = Bdc_DecomposeStepMux( p, pIsf, pIsfL, pIsfR );
710  if ( p->pPars->fVerbose )
711  p->timeMuxes += Abc_Clock() - clk;
712  p->numMuxes++;
713  pFunc0 = Bdc_ManDecompose_rec( p, pIsfL );
714  pFunc1 = Bdc_ManDecompose_rec( p, pIsfR );
715  if ( pFunc0 == NULL || pFunc1 == NULL )
716  return NULL;
717  pFunc = Bdc_FunWithId( p, iVar + 1 );
718  pFunc0 = Bdc_ManCreateGate( p, Bdc_Not(pFunc), pFunc0, BDC_TYPE_AND );
719  pFunc1 = Bdc_ManCreateGate( p, pFunc, pFunc1, BDC_TYPE_AND );
720  if ( pFunc0 == NULL || pFunc1 == NULL )
721  return NULL;
722  pFunc = Bdc_ManCreateGate( p, pFunc0, pFunc1, BDC_TYPE_OR );
723  }
724  else
725  {
726  pFunc0 = Bdc_ManDecompose_rec( p, pIsfL );
727  if ( pFunc0 == NULL )
728  return NULL;
729  // decompose the right branch
730  if ( Bdc_DecomposeUpdateRight( p, pIsf, pIsfL, pIsfR, pFunc0, Type ) )
731  {
732  p->nNodesNew--;
733  return pFunc0;
734  }
735  Bdc_SuppMinimize( p, pIsfR );
736  pFunc1 = Bdc_ManDecompose_rec( p, pIsfR );
737  if ( pFunc1 == NULL )
738  return NULL;
739  // create new gate
740  pFunc = Bdc_ManCreateGate( p, pFunc0, pFunc1, Type );
741  }
742  return pFunc;
743 }
int Bdc_DecomposeStepMux(Bdc_Man_t *p, Bdc_Isf_t *pIsf, Bdc_Isf_t *pIsfL, Bdc_Isf_t *pIsfR)
Definition: bdcDec.c:548
abctime timeCache
Definition: bdcInt.h:121
int fVerbose
Definition: bdc.h:49
abctime timeCheck
Definition: bdcInt.h:122
Bdc_Type_t
BASIC TYPES ///.
Definition: bdcInt.h:48
int nVars
Definition: bdcInt.h:85
abctime timeMuxes
Definition: bdcInt.h:123
int nNodesNew
Definition: bdcInt.h:93
Bdc_Fun_t * Bdc_ManCreateGate(Bdc_Man_t *p, Bdc_Fun_t *pFunc0, Bdc_Fun_t *pFunc1, Bdc_Type_t Type)
Definition: bdcDec.c:621
Bdc_Par_t * pPars
Definition: bdcInt.h:84
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
typedefABC_NAMESPACE_HEADER_START struct Bdc_Fun_t_ Bdc_Fun_t
INCLUDES ///.
Definition: bdc.h:42
void Bdc_SuppMinimize(Bdc_Man_t *p, Bdc_Isf_t *pIsf)
Definition: bdcDec.c:87
static int Kit_TruthIsDisjoint(unsigned *pIn1, unsigned *pIn2, int nVars)
Definition: kit.h:339
unsigned * puOn
Definition: bdcInt.h:77
int Bdc_DecomposeUpdateRight(Bdc_Man_t *p, Bdc_Isf_t *pIsf, Bdc_Isf_t *pIsfL, Bdc_Isf_t *pIsfR, Bdc_Fun_t *pFunc0, Bdc_Type_t Type)
Definition: bdcDec.c:123
static Bdc_Fun_t * Bdc_FunWithId(Bdc_Man_t *p, int Id)
Definition: bdcInt.h:129
static Bdc_Fun_t * Bdc_Not(Bdc_Fun_t *p)
Definition: bdc.h:56
#define assert(ex)
Definition: util_old.h:213
Bdc_Fun_t * Bdc_TableLookup(Bdc_Man_t *p, Bdc_Isf_t *pIsf)
Definition: bdcTable.c:62
ABC_INT64_T abctime
Definition: abc_global.h:278
int numMuxes
Definition: bdcInt.h:115
Bdc_Type_t Bdc_DecomposeStep(Bdc_Man_t *p, Bdc_Isf_t *pIsf, Bdc_Isf_t *pIsfL, Bdc_Isf_t *pIsfR)
Definition: bdcDec.c:444
int Bdc_ManNodeVerify ( Bdc_Man_t p,
Bdc_Isf_t pIsf,
Bdc_Fun_t pFunc 
)

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

Synopsis [Creates gates.]

Description []

SideEffects []

SeeAlso []

Definition at line 600 of file bdcDec.c.

601 {
602  unsigned * puTruth = p->puTemp1;
603  if ( Bdc_IsComplement(pFunc) )
604  Kit_TruthNot( puTruth, Bdc_Regular(pFunc)->puFunc, p->nVars );
605  else
606  Kit_TruthCopy( puTruth, pFunc->puFunc, p->nVars );
607  return Bdc_TableCheckContainment( p, pIsf, puTruth );
608 }
int nVars
Definition: bdcInt.h:85
int Bdc_TableCheckContainment(Bdc_Man_t *p, Bdc_Isf_t *pIsf, unsigned *puTruth)
DECLARATIONS ///.
Definition: bdcTable.c:45
unsigned * puTemp1
Definition: bdcInt.h:101
static void Kit_TruthNot(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:373
static int Bdc_IsComplement(Bdc_Fun_t *p)
Definition: bdc.h:54
static void Kit_TruthCopy(unsigned *pOut, unsigned *pIn, int nVars)
Definition: kit.h:355
static Bdc_Fun_t * Bdc_Regular(Bdc_Fun_t *p)
Definition: bdc.h:55
void Bdc_SuppMinimize ( Bdc_Man_t p,
Bdc_Isf_t pIsf 
)

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

Synopsis [Minimizes the support of the ISF.]

Description []

SideEffects []

SeeAlso []

Definition at line 87 of file bdcDec.c.

88 {
89  int v;
90  abctime clk = 0; // Suppress "might be used uninitialized"
91  if ( p->pPars->fVerbose )
92  clk = Abc_Clock();
93  // go through the support variables
94  pIsf->uSupp = 0;
95  for ( v = 0; v < p->nVars; v++ )
96  {
97  if ( !Kit_TruthVarInSupport( pIsf->puOn, p->nVars, v ) &&
98  !Kit_TruthVarInSupport( pIsf->puOff, p->nVars, v ) )
99  continue;
100  if ( Kit_TruthVarIsVacuous( pIsf->puOn, pIsf->puOff, p->nVars, v ) )
101  {
102  Kit_TruthExist( pIsf->puOn, p->nVars, v );
103  Kit_TruthExist( pIsf->puOff, p->nVars, v );
104  continue;
105  }
106  pIsf->uSupp |= (1 << v);
107  }
108  if ( p->pPars->fVerbose )
109  p->timeSupps += Abc_Clock() - clk;
110 }
unsigned uSupp
Definition: bdcInt.h:75
int fVerbose
Definition: bdc.h:49
int nVars
Definition: bdcInt.h:85
int Kit_TruthVarIsVacuous(unsigned *pOnset, unsigned *pOffset, int nVars, int iVar)
Definition: kitTruth.c:625
Bdc_Par_t * pPars
Definition: bdcInt.h:84
static abctime Abc_Clock()
Definition: abc_global.h:279
void Kit_TruthExist(unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:684
unsigned * puOff
Definition: bdcInt.h:78
abctime timeSupps
Definition: bdcInt.h:124
unsigned * puOn
Definition: bdcInt.h:77
int Kit_TruthVarInSupport(unsigned *pTruth, int nVars, int iVar)
Definition: kitTruth.c:270
ABC_INT64_T abctime
Definition: abc_global.h:278
void Bdc_TableAdd ( Bdc_Man_t p,
Bdc_Fun_t pFunc 
)

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

Synopsis [Adds the new entry to the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 101 of file bdcTable.c.

102 {
103  if ( p->pTable[pFunc->uSupp] == NULL )
104  Vec_IntPush( p->vSpots, pFunc->uSupp );
105  pFunc->pNext = p->pTable[pFunc->uSupp];
106  p->pTable[pFunc->uSupp] = pFunc;
107 }
Vec_Int_t * vSpots
Definition: bdcInt.h:98
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
Bdc_Fun_t ** pTable
Definition: bdcInt.h:96
int Bdc_TableCheckContainment ( Bdc_Man_t p,
Bdc_Isf_t pIsf,
unsigned *  puTruth 
)

DECLARATIONS ///.

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

FileName [bdcTable.c]

SystemName [ABC: Logic synthesis and verification system.]

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

Synopsis [Hash table for intermediate nodes.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

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

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

Synopsis [Checks containment of the function in the ISF.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file bdcTable.c.

46 {
47  return Kit_TruthIsImply( pIsf->puOn, puTruth, p->nVars ) &&
48  Kit_TruthIsDisjoint( puTruth, pIsf->puOff, p->nVars );
49 }
int nVars
Definition: bdcInt.h:85
static int Kit_TruthIsImply(unsigned *pIn1, unsigned *pIn2, int nVars)
Definition: kit.h:331
unsigned * puOff
Definition: bdcInt.h:78
static int Kit_TruthIsDisjoint(unsigned *pIn1, unsigned *pIn2, int nVars)
Definition: kit.h:339
unsigned * puOn
Definition: bdcInt.h:77
void Bdc_TableClear ( Bdc_Man_t p)

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

Synopsis [Adds the new entry to the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 120 of file bdcTable.c.

121 {
122  int Spot, i;
123  Vec_IntForEachEntry( p->vSpots, Spot, i )
124  p->pTable[Spot] = NULL;
125  Vec_IntClear( p->vSpots );
126 }
Vec_Int_t * vSpots
Definition: bdcInt.h:98
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
Bdc_Fun_t* Bdc_TableLookup ( Bdc_Man_t p,
Bdc_Isf_t pIsf 
)

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

Synopsis [Adds the new entry to the hash table.]

Description []

SideEffects []

SeeAlso []

Definition at line 62 of file bdcTable.c.

63 {
64  int fDisableCache = 0;
65  Bdc_Fun_t * pFunc;
66  if ( fDisableCache && Kit_WordCountOnes(pIsf->uSupp) > 1 )
67  return NULL;
68  if ( pIsf->uSupp == 0 )
69  {
70  assert( p->pTable[pIsf->uSupp] == p->pNodes );
71  if ( Kit_TruthIsConst1( pIsf->puOn, p->nVars ) )
72  return p->pNodes;
73  assert( Kit_TruthIsConst1( pIsf->puOff, p->nVars ) );
74  return Bdc_Not(p->pNodes);
75  }
76  for ( pFunc = p->pTable[pIsf->uSupp]; pFunc; pFunc = pFunc->pNext )
77  if ( Bdc_TableCheckContainment( p, pIsf, pFunc->puFunc ) )
78  return pFunc;
79  Bdc_IsfNot( pIsf );
80  for ( pFunc = p->pTable[pIsf->uSupp]; pFunc; pFunc = pFunc->pNext )
81  if ( Bdc_TableCheckContainment( p, pIsf, pFunc->puFunc ) )
82  {
83  Bdc_IsfNot( pIsf );
84  return Bdc_Not(pFunc);
85  }
86  Bdc_IsfNot( pIsf );
87  return NULL;
88 }
unsigned uSupp
Definition: bdcInt.h:75
int nVars
Definition: bdcInt.h:85
unsigned * puOff
Definition: bdcInt.h:78
static int Kit_TruthIsConst1(unsigned *pIn, int nVars)
Definition: kit.h:323
typedefABC_NAMESPACE_HEADER_START struct Bdc_Fun_t_ Bdc_Fun_t
INCLUDES ///.
Definition: bdc.h:42
ABC_NAMESPACE_IMPL_START int Bdc_TableCheckContainment(Bdc_Man_t *p, Bdc_Isf_t *pIsf, unsigned *puTruth)
DECLARATIONS ///.
Definition: bdcTable.c:45
Bdc_Fun_t ** pTable
Definition: bdcInt.h:96
unsigned * puOn
Definition: bdcInt.h:77
Bdc_Fun_t * pNodes
Definition: bdcInt.h:90
static Bdc_Fun_t * Bdc_Not(Bdc_Fun_t *p)
Definition: bdc.h:56
#define assert(ex)
Definition: util_old.h:213
static int Kit_WordCountOnes(unsigned uWord)
Definition: kit.h:243
static void Bdc_IsfNot(Bdc_Isf_t *p)
Definition: bdcInt.h:134