abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
bdcInt.h
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [bdcInt.h]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Truth-table-based bi-decomposition engine.]
8 
9  Synopsis [Internal declarations.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - January 15, 2007.]
16 
17  Revision [$Id: resInt.h,v 1.00 2007/01/15 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #ifndef ABC__aig__bdc__bdcInt_h
22 #define ABC__aig__bdc__bdcInt_h
23 
24 
25 ////////////////////////////////////////////////////////////////////////
26 /// INCLUDES ///
27 ////////////////////////////////////////////////////////////////////////
28 
29 #include "bool/kit/kit.h"
30 #include "bdc.h"
31 
32 ////////////////////////////////////////////////////////////////////////
33 /// PARAMETERS ///
34 ////////////////////////////////////////////////////////////////////////
35 
36 
37 
39 
40 
41 #define BDC_SCALE 1000 // value used to compute the cost
42 
43 ////////////////////////////////////////////////////////////////////////
44 /// BASIC TYPES ///
45 ////////////////////////////////////////////////////////////////////////
46 
47 // network types
48 typedef enum {
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;
58 
59 struct Bdc_Fun_t_
60 {
61  int Type; // Const1, PI, AND, XOR, MUX
62  Bdc_Fun_t * pFan0; // fanin of the given node
63  Bdc_Fun_t * pFan1; // fanin of the given node
64  unsigned uSupp; // bit mask of current support
65  unsigned * puFunc; // the function of the node
66  Bdc_Fun_t * pNext; // next function with same support
67  union { int iCopy; // the literal of the node (AIG)
68  void * pCopy; }; // the function of the node (BDD or AIG)
69 
70 };
71 
72 typedef struct Bdc_Isf_t_ Bdc_Isf_t;
73 struct Bdc_Isf_t_
74 {
75  unsigned uSupp; // the complete support of this component
76  unsigned uUniq; // the unique variables of this component
77  unsigned * puOn; // on-set
78  unsigned * puOff; // off-set
79 };
80 
81 struct Bdc_Man_t_
82 {
83  // external parameters
84  Bdc_Par_t * pPars; // parameter set
85  int nVars; // the number of variables
86  int nWords; // the number of words
87  int nNodesMax; // the limit on the number of new nodes
88  int nDivsLimit; // the limit on the number of divisors
89  // internal nodes
90  Bdc_Fun_t * pNodes; // storage for decomposition nodes
91  int nNodesAlloc; // the number of nodes allocated
92  int nNodes; // the number of all nodes created so far
93  int nNodesNew; // the number of new AND nodes created so far
94  Bdc_Fun_t * pRoot; // the root node
95  // resub candidates
96  Bdc_Fun_t ** pTable; // hash table of candidates
97  int nTableSize; // hash table size (1 << nVarsMax)
98  Vec_Int_t * vSpots; // the occupied spots in the table
99  // elementary truth tables
100  Vec_Ptr_t * vTruths; // for const 1 and elementary variables
101  unsigned * puTemp1; // temporary truth table
102  unsigned * puTemp2; // temporary truth table
103  unsigned * puTemp3; // temporary truth table
104  unsigned * puTemp4; // temporary truth table
105  // temporary ISFs
110  // internal memory manager
111  Vec_Int_t * vMemory; // memory for internal truth tables
112  // statistics
113  int numCalls;
114  int numNodes;
115  int numMuxes;
116  int numAnds;
117  int numOrs;
118  int numWeaks;
119  int numReuse;
120  // runtime
126 };
127 
128 static inline Bdc_Fun_t * Bdc_FunNew( Bdc_Man_t * p ) { 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; }
129 static inline Bdc_Fun_t * Bdc_FunWithId( Bdc_Man_t * p, int Id ) { assert( Id < p->nNodes ); return p->pNodes + Id; }
130 static inline int Bdc_FunId( Bdc_Man_t * p, Bdc_Fun_t * pFun ) { return pFun - p->pNodes; }
131 static inline void Bdc_IsfStart( Bdc_Man_t * p, Bdc_Isf_t * pF ) { 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 ); }
132 static inline void Bdc_IsfClean( Bdc_Isf_t * p ) { p->uSupp = 0; p->uUniq = 0; }
133 static inline void Bdc_IsfCopy( Bdc_Isf_t * p, Bdc_Isf_t * q ) { Bdc_Isf_t T = *p; *p = *q; *q = T; }
134 static inline void Bdc_IsfNot( Bdc_Isf_t * p ) { unsigned * puT = p->puOn; p->puOn = p->puOff; p->puOff = puT; }
135 
136 ////////////////////////////////////////////////////////////////////////
137 /// MACRO DEFINITIONS ///
138 ////////////////////////////////////////////////////////////////////////
139 
140 ////////////////////////////////////////////////////////////////////////
141 /// FUNCTION DECLARATIONS ///
142 ////////////////////////////////////////////////////////////////////////
143 
144 /*=== bdcDec.c ==========================================================*/
145 extern Bdc_Fun_t * Bdc_ManDecompose_rec( Bdc_Man_t * p, Bdc_Isf_t * pIsf );
146 extern void Bdc_SuppMinimize( Bdc_Man_t * p, Bdc_Isf_t * pIsf );
147 extern int Bdc_ManNodeVerify( Bdc_Man_t * p, Bdc_Isf_t * pIsf, Bdc_Fun_t * pFunc );
148 /*=== bdcTable.c ==========================================================*/
149 extern Bdc_Fun_t * Bdc_TableLookup( Bdc_Man_t * p, Bdc_Isf_t * pIsf );
150 extern void Bdc_TableAdd( Bdc_Man_t * p, Bdc_Fun_t * pFunc );
151 extern void Bdc_TableClear( Bdc_Man_t * p );
152 extern int Bdc_TableCheckContainment( Bdc_Man_t * p, Bdc_Isf_t * pIsf, unsigned * puTruth );
153 
154 
155 
157 
158 
159 
160 #endif
161 
162 ////////////////////////////////////////////////////////////////////////
163 /// END OF FILE ///
164 ////////////////////////////////////////////////////////////////////////
165 
char * memset()
Bdc_Isf_t IsfOR
Definition: bdcInt.h:107
Vec_Ptr_t * vTruths
Definition: bdcInt.h:100
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
void Bdc_SuppMinimize(Bdc_Man_t *p, Bdc_Isf_t *pIsf)
Definition: bdcDec.c:87
unsigned uSupp
Definition: bdcInt.h:75
abctime timeCache
Definition: bdcInt.h:121
Vec_Int_t * vMemory
Definition: bdcInt.h:111
void Bdc_TableClear(Bdc_Man_t *p)
Definition: bdcTable.c:120
Bdc_Fun_t * pNext
Definition: bdcInt.h:66
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
abctime timeCheck
Definition: bdcInt.h:122
unsigned * puTemp2
Definition: bdcInt.h:102
void Bdc_TableAdd(Bdc_Man_t *p, Bdc_Fun_t *pFunc)
Definition: bdcTable.c:101
Bdc_Type_t
BASIC TYPES ///.
Definition: bdcInt.h:48
int nVars
Definition: bdcInt.h:85
abctime timeMuxes
Definition: bdcInt.h:123
unsigned * puTemp4
Definition: bdcInt.h:104
int numReuse
Definition: bdcInt.h:119
Bdc_Isf_t * pIsfAR
Definition: bdcInt.h:109
int nNodesNew
Definition: bdcInt.h:93
Bdc_Isf_t IsfAR
Definition: bdcInt.h:109
Bdc_Fun_t * pFan0
Definition: bdcInt.h:62
Bdc_Par_t * pPars
Definition: bdcInt.h:84
int numCalls
Definition: bdcInt.h:113
static unsigned * Vec_IntFetch(Vec_Int_t *p, int nWords)
Definition: vecInt.h:853
int Bdc_TableCheckContainment(Bdc_Man_t *p, Bdc_Isf_t *pIsf, unsigned *puTruth)
DECLARATIONS ///.
Definition: bdcTable.c:45
unsigned * puTemp3
Definition: bdcInt.h:103
unsigned * puOff
Definition: bdcInt.h:78
Vec_Int_t * vSpots
Definition: bdcInt.h:98
abctime timeSupps
Definition: bdcInt.h:124
Bdc_Fun_t * Bdc_ManDecompose_rec(Bdc_Man_t *p, Bdc_Isf_t *pIsf)
MACRO DEFINITIONS ///.
Definition: bdcDec.c:675
Bdc_Fun_t * pFan1
Definition: bdcInt.h:63
typedefABC_NAMESPACE_HEADER_START struct Bdc_Fun_t_ Bdc_Fun_t
INCLUDES ///.
Definition: bdc.h:42
unsigned * puTemp1
Definition: bdcInt.h:101
unsigned * puFunc
Definition: bdcInt.h:65
Bdc_Fun_t * pRoot
Definition: bdcInt.h:94
static void Bdc_IsfClean(Bdc_Isf_t *p)
Definition: bdcInt.h:132
int numWeaks
Definition: bdcInt.h:118
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
Definition: abc_global.h:105
static int Bdc_FunId(Bdc_Man_t *p, Bdc_Fun_t *pFun)
Definition: bdcInt.h:130
int Type
Definition: bdcInt.h:61
#define ABC_NAMESPACE_HEADER_END
Definition: abc_global.h:106
int nNodesMax
Definition: bdcInt.h:87
int numOrs
Definition: bdcInt.h:117
Bdc_Isf_t * pIsfOL
Definition: bdcInt.h:106
Bdc_Fun_t ** pTable
Definition: bdcInt.h:96
int numAnds
Definition: bdcInt.h:116
unsigned * puOn
Definition: bdcInt.h:77
void * pCopy
Definition: bdcInt.h:68
Bdc_Fun_t * pNodes
Definition: bdcInt.h:90
static Bdc_Fun_t * Bdc_FunNew(Bdc_Man_t *p)
Definition: bdcInt.h:128
Definition: bdc.h:45
unsigned uSupp
Definition: bdcInt.h:64
unsigned uUniq
Definition: bdcInt.h:76
static Bdc_Fun_t * Bdc_FunWithId(Bdc_Man_t *p, int Id)
Definition: bdcInt.h:129
Bdc_Isf_t * pIsfOR
Definition: bdcInt.h:107
int nNodesAlloc
Definition: bdcInt.h:91
Bdc_Isf_t * pIsfAL
Definition: bdcInt.h:108
int nNodes
Definition: bdcInt.h:92
#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
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
int iCopy
Definition: bdcInt.h:67
ABC_INT64_T abctime
Definition: abc_global.h:278
abctime timeTotal
Definition: bdcInt.h:125
int numMuxes
Definition: bdcInt.h:115
static void Bdc_IsfNot(Bdc_Isf_t *p)
Definition: bdcInt.h:134
static void Bdc_IsfCopy(Bdc_Isf_t *p, Bdc_Isf_t *q)
Definition: bdcInt.h:133
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