abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
darInt.h
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [darInt.h]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [DAG-aware AIG rewriting.]
8 
9  Synopsis [Internal declarations.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - April 28, 2007.]
16 
17  Revision [$Id: darInt.h,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #ifndef ABC__aig__dar__darInt_h
22 #define ABC__aig__dar__darInt_h
23 
24 
25 ////////////////////////////////////////////////////////////////////////
26 /// INCLUDES ///
27 ////////////////////////////////////////////////////////////////////////
28 
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <assert.h>
33 
34 #include "misc/vec/vec.h"
35 #include "aig/aig/aig.h"
36 #include "dar.h"
37 
38 ////////////////////////////////////////////////////////////////////////
39 /// PARAMETERS ///
40 ////////////////////////////////////////////////////////////////////////
41 
42 
43 
45 
46 
47 ////////////////////////////////////////////////////////////////////////
48 /// BASIC TYPES ///
49 ////////////////////////////////////////////////////////////////////////
50 
51 typedef struct Dar_Man_t_ Dar_Man_t;
52 typedef struct Dar_Cut_t_ Dar_Cut_t;
53 
54 // the AIG 4-cut
55 struct Dar_Cut_t_ // 6 words
56 {
57  unsigned uSign; // cut signature
58  unsigned uTruth : 16; // the truth table of the cut function
59  unsigned Value : 11; // the value of the cut
60  unsigned fBest : 1; // marks the best cut
61  unsigned fUsed : 1; // marks the cut currently in use
62  unsigned nLeaves : 3; // the number of leaves
63  int pLeaves[4]; // the array of leaves
64 };
65 
66 // the AIG manager
67 struct Dar_Man_t_
68 {
69  // input data
70  Dar_RwrPar_t * pPars; // rewriting parameters
71  Aig_Man_t * pAig; // AIG manager
72  // various data members
73  Aig_MmFixed_t * pMemCuts; // memory manager for cuts
74  void * pManCnf; // CNF managers
75  Vec_Ptr_t * vCutNodes; // the nodes with cuts allocated
76  // current rewriting step
77  Vec_Ptr_t * vLeavesBest; // the best set of leaves
78  int OutBest; // the best output (in the library)
79  int OutNumBest; // the best number of the output
80  int GainBest; // the best gain
81  int LevelBest; // the level of node with the best gain
82  int ClassBest; // the equivalence class of the best replacement
83  // function statistics
84  int nTotalSubgs; // the total number of subgraphs tried
85  int ClassTimes[222];// the runtimes for each class
86  int ClassGains[222];// the gains for each class
87  int ClassSubgs[222];// the graphs for each class
88  int nCutMemUsed; // memory used for cuts
89  // rewriting statistics
90  int nNodesInit; // the original number of nodes
91  int nNodesTried; // the number of nodes attempted
92  int nCutsAll; // all cut pairs
93  int nCutsTried; // computed cuts
94  int nCutsUsed; // used cuts
95  int nCutsBad; // bad cuts due to absent fanin
96  int nCutsGood; // good cuts
97  int nCutsSkipped; // skipped bad cuts
98  // timing statistics
105 };
106 
107 static inline Dar_Cut_t * Dar_ObjCuts( Aig_Obj_t * pObj ) { return (Dar_Cut_t *)pObj->pData; }
108 static inline void Dar_ObjSetCuts( Aig_Obj_t * pObj, Dar_Cut_t * pCuts ) { assert( !Aig_ObjIsNone(pObj) ); pObj->pData = pCuts; }
109 
110 ////////////////////////////////////////////////////////////////////////
111 /// MACRO DEFINITIONS ///
112 ////////////////////////////////////////////////////////////////////////
113 
114 ////////////////////////////////////////////////////////////////////////
115 /// ITERATORS ///
116 ////////////////////////////////////////////////////////////////////////
117 
118 // iterator over all cuts of the node
119 #define Dar_ObjForEachCutAll( pObj, pCut, i ) \
120  for ( (pCut) = Dar_ObjCuts(pObj), i = 0; i < (int)(pObj)->nCuts; i++, pCut++ )
121 #define Dar_ObjForEachCut( pObj, pCut, i ) \
122  for ( (pCut) = Dar_ObjCuts(pObj), i = 0; i < (int)(pObj)->nCuts; i++, pCut++ ) if ( (pCut)->fUsed==0 ) {} else
123 // iterator over leaves of the cut
124 #define Dar_CutForEachLeaf( p, pCut, pLeaf, i ) \
125  for ( i = 0; (i < (int)(pCut)->nLeaves) && (((pLeaf) = Aig_ManObj(p, (pCut)->pLeaves[i])), 1); i++ )
126 
127 ////////////////////////////////////////////////////////////////////////
128 /// FUNCTION DECLARATIONS ///
129 ////////////////////////////////////////////////////////////////////////
130 
131 /*=== darBalance.c ========================================================*/
132 /*=== darCore.c ===========================================================*/
133 /*=== darCut.c ============================================================*/
134 extern void Dar_ManCutsRestart( Dar_Man_t * p, Aig_Obj_t * pRoot );
135 extern void Dar_ManCutsFree( Dar_Man_t * p );
136 extern Dar_Cut_t * Dar_ObjPrepareCuts( Dar_Man_t * p, Aig_Obj_t * pObj );
138 extern Dar_Cut_t * Dar_ObjComputeCuts( Dar_Man_t * p, Aig_Obj_t * pObj, int fSkipTtMin );
139 extern void Dar_ObjCutPrint( Aig_Man_t * p, Aig_Obj_t * pObj );
140 /*=== darData.c ===========================================================*/
141 extern Vec_Int_t * Dar_LibReadNodes();
142 extern Vec_Int_t * Dar_LibReadOuts();
143 extern Vec_Int_t * Dar_LibReadPrios();
144 /*=== darLib.c ============================================================*/
145 extern void Dar_LibStart();
146 extern void Dar_LibStop();
147 extern void Dar_LibReturnCanonicals( unsigned * pCanons );
148 extern void Dar_LibEval( Dar_Man_t * p, Aig_Obj_t * pRoot, Dar_Cut_t * pCut, int Required, int * pnMffcSize );
149 extern Aig_Obj_t * Dar_LibBuildBest( Dar_Man_t * p );
150 /*=== darMan.c ============================================================*/
151 extern Dar_Man_t * Dar_ManStart( Aig_Man_t * pAig, Dar_RwrPar_t * pPars );
152 extern void Dar_ManStop( Dar_Man_t * p );
153 extern void Dar_ManPrintStats( Dar_Man_t * p );
154 /*=== darPrec.c ============================================================*/
155 extern char ** Dar_Permutations( int n );
156 extern void Dar_Truth4VarNPN( unsigned short ** puCanons, char ** puPhases, char ** puPerms, unsigned char ** puMap );
157 
158 
159 
161 
162 
163 
164 #endif
165 
166 ////////////////////////////////////////////////////////////////////////
167 /// END OF FILE ///
168 ////////////////////////////////////////////////////////////////////////
169 
int ClassBest
Definition: darInt.h:82
static Dar_Cut_t * Dar_ObjCuts(Aig_Obj_t *pObj)
Definition: darInt.h:107
abctime timeEval
Definition: darInt.h:100
Aig_MmFixed_t * pMemCuts
Definition: darInt.h:73
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
int ClassGains[222]
Definition: darInt.h:86
int OutNumBest
Definition: darInt.h:79
void Dar_ManStop(Dar_Man_t *p)
Definition: darMan.c:69
int GainBest
Definition: darInt.h:80
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
void Dar_Truth4VarNPN(unsigned short **puCanons, char **puPhases, char **puPerms, unsigned char **puMap)
Definition: darPrec.c:293
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int nCutMemUsed
Definition: darInt.h:88
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
abctime timeCuts
Definition: darInt.h:99
Dar_Cut_t * Dar_ObjComputeCuts_rec(Dar_Man_t *p, Aig_Obj_t *pObj)
Definition: darCut.c:818
abctime time1
Definition: darInt.h:103
int nCutsGood
Definition: darInt.h:96
unsigned fBest
Definition: darInt.h:60
void * pData
Definition: aig.h:87
unsigned uTruth
Definition: darInt.h:58
static void Dar_ObjSetCuts(Aig_Obj_t *pObj, Dar_Cut_t *pCuts)
Definition: darInt.h:108
void Dar_ManCutsRestart(Dar_Man_t *p, Aig_Obj_t *pRoot)
FUNCTION DECLARATIONS ///.
Definition: darCut.c:714
int nCutsTried
Definition: darInt.h:93
Aig_Man_t * pAig
Definition: darInt.h:71
unsigned fUsed
Definition: darInt.h:61
int nCutsSkipped
Definition: darInt.h:97
DECLARATIONS ///.
Definition: aigMem.c:30
int nNodesInit
Definition: darInt.h:90
typedefABC_NAMESPACE_HEADER_START struct Dar_Man_t_ Dar_Man_t
INCLUDES ///.
Definition: darInt.h:51
int pLeaves[4]
Definition: darInt.h:63
int nCutsBad
Definition: darInt.h:95
int nCutsUsed
Definition: darInt.h:94
static int Aig_ObjIsNone(Aig_Obj_t *pObj)
Definition: aig.h:273
int LevelBest
Definition: darInt.h:81
void Dar_LibEval(Dar_Man_t *p, Aig_Obj_t *pRoot, Dar_Cut_t *pCut, int Required, int *pnMffcSize)
Definition: darLib.c:920
int nTotalSubgs
Definition: darInt.h:84
Definition: aig.h:69
void Dar_LibStart()
MACRO DEFINITIONS ///.
Definition: darLib.c:593
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
Definition: abc_global.h:105
void Dar_LibReturnCanonicals(unsigned *pCanons)
Definition: darLib.c:211
unsigned nLeaves
Definition: darInt.h:62
#define ABC_NAMESPACE_HEADER_END
Definition: abc_global.h:106
void * pManCnf
Definition: darInt.h:74
abctime timeOther
Definition: darInt.h:101
char ** Dar_Permutations(int n)
Definition: darPrec.c:144
Vec_Int_t * Dar_LibReadNodes()
Definition: darData.c:11094
Dar_Cut_t * Dar_ObjComputeCuts(Dar_Man_t *p, Aig_Obj_t *pObj, int fSkipTtMin)
Definition: darCut.c:738
void Dar_ManPrintStats(Dar_Man_t *p)
Definition: darMan.c:93
int nNodesTried
Definition: darInt.h:91
int OutBest
Definition: darInt.h:78
Dar_Man_t * Dar_ManStart(Aig_Man_t *pAig, Dar_RwrPar_t *pPars)
DECLARATIONS ///.
Definition: darMan.c:44
int ClassTimes[222]
Definition: darInt.h:85
Dar_RwrPar_t * pPars
Definition: darInt.h:70
typedefABC_NAMESPACE_HEADER_START struct Dar_RwrPar_t_ Dar_RwrPar_t
INCLUDES ///.
Definition: dar.h:42
abctime time2
Definition: darInt.h:104
abctime timeTotal
Definition: darInt.h:102
Vec_Int_t * Dar_LibReadPrios()
Definition: darData.c:11136
Vec_Ptr_t * vCutNodes
Definition: darInt.h:75
void Dar_ManCutsFree(Dar_Man_t *p)
Definition: darCut.c:648
unsigned uSign
Definition: darInt.h:57
#define assert(ex)
Definition: util_old.h:213
Vec_Ptr_t * vLeavesBest
Definition: darInt.h:77
Vec_Int_t * Dar_LibReadOuts()
Definition: darData.c:11115
int ClassSubgs[222]
Definition: darInt.h:87
ABC_INT64_T abctime
Definition: abc_global.h:278
void Dar_LibStop()
Definition: darLib.c:615
unsigned Value
Definition: darInt.h:59
void Dar_ObjCutPrint(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: darCut.c:65
int nCutsAll
Definition: darInt.h:92
Aig_Obj_t * Dar_LibBuildBest(Dar_Man_t *p)
Definition: darLib.c:1031
Dar_Cut_t * Dar_ObjPrepareCuts(Dar_Man_t *p, Aig_Obj_t *pObj)
Definition: darCut.c:668