abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
kitHop.c File Reference
#include "kit.h"
#include "aig/hop/hop.h"
#include "aig/gia/gia.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START int Kit_GraphToGiaInternal (Gia_Man_t *pMan, Kit_Graph_t *pGraph, int fHash)
 DECLARATIONS ///. More...
 
int Kit_GraphToGia (Gia_Man_t *pMan, Kit_Graph_t *pGraph, Vec_Int_t *vLeaves, int fHash)
 
int Kit_TruthToGia (Gia_Man_t *pMan, unsigned *pTruth, int nVars, Vec_Int_t *vMemory, Vec_Int_t *vLeaves, int fHash)
 DECLARATIONS ///. More...
 
Hop_Obj_tKit_GraphToHopInternal (Hop_Man_t *pMan, Kit_Graph_t *pGraph)
 
Hop_Obj_tKit_GraphToHop (Hop_Man_t *pMan, Kit_Graph_t *pGraph)
 
Hop_Obj_tKit_TruthToHop (Hop_Man_t *pMan, unsigned *pTruth, int nVars, Vec_Int_t *vMemory)
 
Hop_Obj_tKit_CoverToHop (Hop_Man_t *pMan, Vec_Int_t *vCover, int nVars, Vec_Int_t *vMemory)
 

Function Documentation

Hop_Obj_t* Kit_CoverToHop ( Hop_Man_t pMan,
Vec_Int_t vCover,
int  nVars,
Vec_Int_t vMemory 
)

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

Synopsis [Strashes one logic node using its SOP.]

Description []

SideEffects []

SeeAlso []

Definition at line 181 of file kitHop.c.

182 {
183  Kit_Graph_t * pGraph;
184  Hop_Obj_t * pFunc;
185  // perform factoring
186  Vec_IntClear( vMemory );
187  pGraph = Kit_SopFactor( vCover, 0, nVars, vMemory );
188  // convert graph to the AIG
189  pFunc = Kit_GraphToHop( pMan, pGraph );
190  Kit_GraphFree( pGraph );
191  return pFunc;
192 }
Definition: hop.h:65
Hop_Obj_t * Kit_GraphToHop(Hop_Man_t *pMan, Kit_Graph_t *pGraph)
Definition: kitHop.c:136
void Kit_GraphFree(Kit_Graph_t *pGraph)
Definition: kitGraph.c:131
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
Kit_Graph_t * Kit_SopFactor(Vec_Int_t *vCover, int fCompl, int nVars, Vec_Int_t *vMemory)
FUNCTION DEFINITIONS ///.
Definition: kitFactor.c:55
int Kit_GraphToGia ( Gia_Man_t pMan,
Kit_Graph_t pGraph,
Vec_Int_t vLeaves,
int  fHash 
)

Definition at line 70 of file kitHop.c.

71 {
72  Kit_Node_t * pNode = NULL;
73  int i;
74  // collect the fanins
75  Kit_GraphForEachLeaf( pGraph, pNode, i )
76  pNode->iFunc = vLeaves ? Vec_IntEntry(vLeaves, i) : Gia_Obj2Lit(pMan, Gia_ManPi(pMan, i));
77  // perform strashing
78  return Kit_GraphToGiaInternal( pMan, pGraph, fHash );
79 }
#define Kit_GraphForEachLeaf(pGraph, pLeaf, i)
Definition: kit.h:502
static Gia_Obj_t * Gia_ManPi(Gia_Man_t *p, int v)
Definition: gia.h:405
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
ABC_NAMESPACE_IMPL_START int Kit_GraphToGiaInternal(Gia_Man_t *pMan, Kit_Graph_t *pGraph, int fHash)
DECLARATIONS ///.
Definition: kitHop.c:47
static int Gia_Obj2Lit(Gia_Man_t *p, Gia_Obj_t *pObj)
Definition: gia.h:433
ABC_NAMESPACE_IMPL_START int Kit_GraphToGiaInternal ( Gia_Man_t pMan,
Kit_Graph_t pGraph,
int  fHash 
)

DECLARATIONS ///.

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

FileName [kitHop.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Computation kit.]

Synopsis [Procedures involving AIGs.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - Dec 6, 2006.]

Revision [

Id:
kitHop.c,v 1.00 2006/12/06 00:00:00 alanmi Exp

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

Synopsis [Transforms the decomposition graph into the AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file kitHop.c.

48 {
49  Kit_Node_t * pNode = NULL;
50  int i, pAnd0, pAnd1;
51  // check for constant function
52  if ( Kit_GraphIsConst(pGraph) )
53  return Abc_LitNotCond( 1, Kit_GraphIsComplement(pGraph) );
54  // check for a literal
55  if ( Kit_GraphIsVar(pGraph) )
56  return Abc_LitNotCond( Kit_GraphVar(pGraph)->iFunc, 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 = Abc_LitNotCond( Kit_GraphNode(pGraph, pNode->eEdge0.Node)->iFunc, pNode->eEdge0.fCompl );
61  pAnd1 = Abc_LitNotCond( Kit_GraphNode(pGraph, pNode->eEdge1.Node)->iFunc, pNode->eEdge1.fCompl );
62  if ( fHash )
63  pNode->iFunc = Gia_ManHashAnd( pMan, pAnd0, pAnd1 );
64  else
65  pNode->iFunc = Gia_ManAppendAnd( pMan, pAnd0, pAnd1 );
66  }
67  // complement the result if necessary
68  return Abc_LitNotCond( pNode->iFunc, Kit_GraphIsComplement(pGraph) );
69 }
static int Gia_ManAppendAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: gia.h:592
Kit_Edge_t eEdge0
Definition: kit.h:69
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
static int Abc_LitNotCond(int Lit, int c)
Definition: abc_global.h:267
static int Kit_GraphIsConst(Kit_Graph_t *pGraph)
Definition: kit.h:202
unsigned fCompl
Definition: kit.h:62
#define Kit_GraphForEachNode(pGraph, pAnd, i)
Definition: kit.h:504
unsigned Node
Definition: kit.h:63
static Kit_Node_t * Kit_GraphVar(Kit_Graph_t *pGraph)
Definition: kit.h:215
int iFunc
Definition: kit.h:72
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
Definition: giaHash.c:572
Hop_Obj_t* Kit_GraphToHop ( Hop_Man_t pMan,
Kit_Graph_t pGraph 
)

Definition at line 136 of file kitHop.c.

137 {
138  Kit_Node_t * pNode = NULL;
139  int i;
140  // collect the fanins
141  Kit_GraphForEachLeaf( pGraph, pNode, i )
142  pNode->pFunc = Hop_IthVar( pMan, i );
143  // perform strashing
144  return Kit_GraphToHopInternal( pMan, pGraph );
145 }
Hop_Obj_t * Kit_GraphToHopInternal(Hop_Man_t *pMan, Kit_Graph_t *pGraph)
Definition: kitHop.c:115
#define Kit_GraphForEachLeaf(pGraph, pLeaf, i)
Definition: kit.h:502
Hop_Obj_t * Hop_IthVar(Hop_Man_t *p, int i)
FUNCTION DEFINITIONS ///.
Definition: hopOper.c:63
Hop_Obj_t* Kit_GraphToHopInternal ( Hop_Man_t pMan,
Kit_Graph_t pGraph 
)

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

Synopsis [Transforms the decomposition graph into the AIG.]

Description []

SideEffects []

SeeAlso []

Definition at line 115 of file kitHop.c.

116 {
117  Kit_Node_t * pNode = NULL;
118  Hop_Obj_t * pAnd0, * pAnd1;
119  int i;
120  // check for constant function
121  if ( Kit_GraphIsConst(pGraph) )
122  return Hop_NotCond( Hop_ManConst1(pMan), Kit_GraphIsComplement(pGraph) );
123  // check for a literal
124  if ( Kit_GraphIsVar(pGraph) )
125  return Hop_NotCond( (Hop_Obj_t *)Kit_GraphVar(pGraph)->pFunc, Kit_GraphIsComplement(pGraph) );
126  // build the AIG nodes corresponding to the AND gates of the graph
127  Kit_GraphForEachNode( pGraph, pNode, i )
128  {
129  pAnd0 = Hop_NotCond( (Hop_Obj_t *)Kit_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
130  pAnd1 = Hop_NotCond( (Hop_Obj_t *)Kit_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
131  pNode->pFunc = Hop_And( pMan, pAnd0, pAnd1 );
132  }
133  // complement the result if necessary
134  return Hop_NotCond( (Hop_Obj_t *)pNode->pFunc, Kit_GraphIsComplement(pGraph) );
135 }
Kit_Edge_t eEdge0
Definition: kit.h:69
static Hop_Obj_t * Hop_ManConst1(Hop_Man_t *p)
Definition: hop.h:132
Hop_Obj_t * Hop_And(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition: hopOper.c:104
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
void * pFunc
Definition: kit.h:73
Definition: hop.h:65
static int Kit_GraphIsConst(Kit_Graph_t *pGraph)
Definition: kit.h:202
unsigned fCompl
Definition: kit.h:62
#define Kit_GraphForEachNode(pGraph, pAnd, i)
Definition: kit.h:504
unsigned Node
Definition: kit.h:63
static Hop_Obj_t * Hop_NotCond(Hop_Obj_t *p, int c)
Definition: hop.h:128
static Kit_Node_t * Kit_GraphVar(Kit_Graph_t *pGraph)
Definition: kit.h:215
int Kit_TruthToGia ( Gia_Man_t pMan,
unsigned *  pTruth,
int  nVars,
Vec_Int_t vMemory,
Vec_Int_t vLeaves,
int  fHash 
)

DECLARATIONS ///.

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

FileName [giaMap.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Scalable AIG package.]

Synopsis [Manipulation of mapping associated with the AIG.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
giaMap.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 80 of file kitHop.c.

81 {
82  int iLit;
83  Kit_Graph_t * pGraph;
84  // transform truth table into the decomposition tree
85  if ( vMemory == NULL )
86  {
87  vMemory = Vec_IntAlloc( 0 );
88  pGraph = Kit_TruthToGraph( pTruth, nVars, vMemory );
89  Vec_IntFree( vMemory );
90  }
91  else
92  pGraph = Kit_TruthToGraph( pTruth, nVars, vMemory );
93  if ( pGraph == NULL )
94  {
95  printf( "Kit_TruthToGia(): Converting truth table to AIG has failed for function:\n" );
96  Kit_DsdPrintFromTruth( pTruth, nVars ); printf( "\n" );
97  }
98  // derive the AIG for the decomposition tree
99  iLit = Kit_GraphToGia( pMan, pGraph, vLeaves, fHash );
100  Kit_GraphFree( pGraph );
101  return iLit;
102 }
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
Definition: kitDsd.c:490
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
void Kit_GraphFree(Kit_Graph_t *pGraph)
Definition: kitGraph.c:131
int Kit_GraphToGia(Gia_Man_t *pMan, Kit_Graph_t *pGraph, Vec_Int_t *vLeaves, int fHash)
Definition: kitHop.c:70
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
Hop_Obj_t* Kit_TruthToHop ( Hop_Man_t pMan,
unsigned *  pTruth,
int  nVars,
Vec_Int_t vMemory 
)

Definition at line 146 of file kitHop.c.

147 {
148  Hop_Obj_t * pObj;
149  Kit_Graph_t * pGraph;
150  // transform truth table into the decomposition tree
151  if ( vMemory == NULL )
152  {
153  vMemory = Vec_IntAlloc( 0 );
154  pGraph = Kit_TruthToGraph( pTruth, nVars, vMemory );
155  Vec_IntFree( vMemory );
156  }
157  else
158  pGraph = Kit_TruthToGraph( pTruth, nVars, vMemory );
159  if ( pGraph == NULL )
160  {
161  printf( "Kit_TruthToHop(): Converting truth table to AIG has failed for function:\n" );
162  Kit_DsdPrintFromTruth( pTruth, nVars ); printf( "\n" );
163  }
164  // derive the AIG for the decomposition tree
165  pObj = Kit_GraphToHop( pMan, pGraph );
166  Kit_GraphFree( pGraph );
167  return pObj;
168 }
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
Definition: kitDsd.c:490
Definition: hop.h:65
Hop_Obj_t * Kit_GraphToHop(Hop_Man_t *pMan, Kit_Graph_t *pGraph)
Definition: kitHop.c:136
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
void Kit_GraphFree(Kit_Graph_t *pGraph)
Definition: kitGraph.c:131
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