abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
kitAig.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [kitAig.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Computation kit.]
8 
9  Synopsis [Procedures involving AIGs.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - Dec 6, 2006.]
16 
17  Revision [$Id: kitAig.c,v 1.00 2006/12/06 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "kit.h"
22 #include "aig/aig/aig.h"
23 
25 
26 
27 ////////////////////////////////////////////////////////////////////////
28 /// DECLARATIONS ///
29 ////////////////////////////////////////////////////////////////////////
30 
31 ////////////////////////////////////////////////////////////////////////
32 /// FUNCTION DEFINITIONS ///
33 ////////////////////////////////////////////////////////////////////////
34 
35 /**Function*************************************************************
36 
37  Synopsis [Transforms the decomposition graph into the AIG.]
38 
39  Description []
40 
41  SideEffects []
42 
43  SeeAlso []
44 
45 ***********************************************************************/
47 {
48  Kit_Node_t * pNode = NULL;
49  Aig_Obj_t * pAnd0, * pAnd1;
50  int i;
51  // check for constant function
52  if ( Kit_GraphIsConst(pGraph) )
53  return Aig_NotCond( Aig_ManConst1(pMan), Kit_GraphIsComplement(pGraph) );
54  // check for a literal
55  if ( Kit_GraphIsVar(pGraph) )
56  return Aig_NotCond( (Aig_Obj_t *)Kit_GraphVar(pGraph)->pFunc, Kit_GraphIsComplement(pGraph) );
57  // build the AIG nodes corresponding to the AND gates of the graph
58  Kit_GraphForEachNode( pGraph, pNode, i )
59  {
60  pAnd0 = Aig_NotCond( (Aig_Obj_t *)Kit_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
61  pAnd1 = Aig_NotCond( (Aig_Obj_t *)Kit_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
62  pNode->pFunc = Aig_And( pMan, pAnd0, pAnd1 );
63  }
64  // complement the result if necessary
65  return Aig_NotCond( (Aig_Obj_t *)pNode->pFunc, Kit_GraphIsComplement(pGraph) );
66 }
67 
68 /**Function*************************************************************
69 
70  Synopsis [Strashes one logic node using its SOP.]
71 
72  Description []
73 
74  SideEffects []
75 
76  SeeAlso []
77 
78 ***********************************************************************/
79 Aig_Obj_t * Kit_GraphToAig( Aig_Man_t * pMan, Aig_Obj_t ** pFanins, Kit_Graph_t * pGraph )
80 {
81  Kit_Node_t * pNode = NULL;
82  int i;
83  // collect the fanins
84  Kit_GraphForEachLeaf( pGraph, pNode, i )
85  pNode->pFunc = pFanins[i];
86  // perform strashing
87  return Kit_GraphToAigInternal( pMan, pGraph );
88 }
89 
90 /**Function*************************************************************
91 
92  Synopsis [Strashed onen logic nodes using its truth table.]
93 
94  Description []
95 
96  SideEffects []
97 
98  SeeAlso []
99 
100 ***********************************************************************/
101 Aig_Obj_t * Kit_TruthToAig( Aig_Man_t * pMan, Aig_Obj_t ** pFanins, unsigned * pTruth, int nVars, Vec_Int_t * vMemory )
102 {
103  Aig_Obj_t * pObj;
104  Kit_Graph_t * pGraph;
105  // transform truth table into the decomposition tree
106  if ( vMemory == NULL )
107  {
108  vMemory = Vec_IntAlloc( 0 );
109  pGraph = Kit_TruthToGraph( pTruth, nVars, vMemory );
110  Vec_IntFree( vMemory );
111  }
112  else
113  pGraph = Kit_TruthToGraph( pTruth, nVars, vMemory );
114  // derive the AIG for the decomposition tree
115  pObj = Kit_GraphToAig( pMan, pFanins, pGraph );
116  Kit_GraphFree( pGraph );
117  return pObj;
118 }
119 
120 ////////////////////////////////////////////////////////////////////////
121 /// END OF FILE ///
122 ////////////////////////////////////////////////////////////////////////
123 
124 
126 
Kit_Edge_t eEdge0
Definition: kit.h:69
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static Kit_Node_t * Kit_GraphNode(Kit_Graph_t *pGraph, int i)
Definition: kit.h:211
Kit_Edge_t eEdge1
Definition: kit.h:70
static int Kit_GraphIsComplement(Kit_Graph_t *pGraph)
Definition: kit.h:205
static int Kit_GraphIsVar(Kit_Graph_t *pGraph)
Definition: kit.h:206
#define Kit_GraphForEachLeaf(pGraph, pLeaf, i)
Definition: kit.h:502
Aig_Obj_t * Kit_GraphToAig(Aig_Man_t *pMan, Aig_Obj_t **pFanins, Kit_Graph_t *pGraph)
Definition: kitAig.c:79
void * pFunc
Definition: kit.h:73
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
static int Kit_GraphIsConst(Kit_Graph_t *pGraph)
Definition: kit.h:202
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
ABC_NAMESPACE_IMPL_START Aig_Obj_t * Kit_GraphToAigInternal(Aig_Man_t *pMan, Kit_Graph_t *pGraph)
DECLARATIONS ///.
Definition: kitAig.c:46
unsigned fCompl
Definition: kit.h:62
void Kit_GraphFree(Kit_Graph_t *pGraph)
Definition: kitGraph.c:131
#define Kit_GraphForEachNode(pGraph, pAnd, i)
Definition: kit.h:504
unsigned Node
Definition: kit.h:63
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
Definition: aig.h:69
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
Aig_Obj_t * Kit_TruthToAig(Aig_Man_t *pMan, Aig_Obj_t **pFanins, unsigned *pTruth, int nVars, Vec_Int_t *vMemory)
Definition: kitAig.c:101
static Kit_Node_t * Kit_GraphVar(Kit_Graph_t *pGraph)
Definition: kit.h:215
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
Kit_Graph_t * Kit_TruthToGraph(unsigned *pTruth, int nVars, Vec_Int_t *vMemory)
Definition: kitGraph.c:355