summaryrefslogtreecommitdiffstats
path: root/src/bool/kit/kitHop.c
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2012-10-24 20:00:20 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2012-10-24 20:00:20 -0700
commite9e8f17942388c4c9c53853b028b621091dd37d7 (patch)
tree4f96bfc6ab7c42bc97d0a8d89b77f2a5229f0a74 /src/bool/kit/kitHop.c
parent6b96d9a84e1356295c8c25588915701bd9160001 (diff)
downloadabc-e9e8f17942388c4c9c53853b028b621091dd37d7.tar.gz
abc-e9e8f17942388c4c9c53853b028b621091dd37d7.tar.bz2
abc-e9e8f17942388c4c9c53853b028b621091dd37d7.zip
Integrating GIA with LUT mapping.
Diffstat (limited to 'src/bool/kit/kitHop.c')
-rw-r--r--src/bool/kit/kitHop.c89
1 files changed, 67 insertions, 22 deletions
diff --git a/src/bool/kit/kitHop.c b/src/bool/kit/kitHop.c
index c7c855af..a4ce79f3 100644
--- a/src/bool/kit/kitHop.c
+++ b/src/bool/kit/kitHop.c
@@ -20,6 +20,7 @@
#include "kit.h"
#include "aig/hop/hop.h"
+#include "aig/gia/gia.h"
ABC_NAMESPACE_IMPL_START
@@ -43,31 +44,66 @@ ABC_NAMESPACE_IMPL_START
SeeAlso []
***********************************************************************/
-Hop_Obj_t * Kit_GraphToHopInternal( Hop_Man_t * pMan, Kit_Graph_t * pGraph )
+int Kit_GraphToGiaInternal( Gia_Man_t * pMan, Kit_Graph_t * pGraph, int fHash )
{
Kit_Node_t * pNode = NULL;
- Hop_Obj_t * pAnd0, * pAnd1;
- int i;
+ int i, pAnd0, pAnd1;
// check for constant function
if ( Kit_GraphIsConst(pGraph) )
- return Hop_NotCond( Hop_ManConst1(pMan), Kit_GraphIsComplement(pGraph) );
+ return Abc_LitNotCond( 1, Kit_GraphIsComplement(pGraph) );
// check for a literal
if ( Kit_GraphIsVar(pGraph) )
- return Hop_NotCond( (Hop_Obj_t *)Kit_GraphVar(pGraph)->pFunc, Kit_GraphIsComplement(pGraph) );
+ return Abc_LitNotCond( Kit_GraphVar(pGraph)->iFunc, Kit_GraphIsComplement(pGraph) );
// build the AIG nodes corresponding to the AND gates of the graph
Kit_GraphForEachNode( pGraph, pNode, i )
{
- pAnd0 = Hop_NotCond( (Hop_Obj_t *)Kit_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
- pAnd1 = Hop_NotCond( (Hop_Obj_t *)Kit_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
- pNode->pFunc = Hop_And( pMan, pAnd0, pAnd1 );
+ pAnd0 = Abc_LitNotCond( Kit_GraphNode(pGraph, pNode->eEdge0.Node)->iFunc, pNode->eEdge0.fCompl );
+ pAnd1 = Abc_LitNotCond( Kit_GraphNode(pGraph, pNode->eEdge1.Node)->iFunc, pNode->eEdge1.fCompl );
+ if ( fHash )
+ pNode->iFunc = Gia_ManHashAnd( pMan, pAnd0, pAnd1 );
+ else
+ pNode->iFunc = Gia_ManAppendAnd( pMan, pAnd0, pAnd1 );
}
// complement the result if necessary
- return Hop_NotCond( (Hop_Obj_t *)pNode->pFunc, Kit_GraphIsComplement(pGraph) );
+ return Abc_LitNotCond( pNode->iFunc, Kit_GraphIsComplement(pGraph) );
+}
+int Kit_GraphToGia( Gia_Man_t * pMan, Kit_Graph_t * pGraph, Vec_Int_t * vLeaves, int fHash )
+{
+ Kit_Node_t * pNode = NULL;
+ int i;
+ // collect the fanins
+ Kit_GraphForEachLeaf( pGraph, pNode, i )
+ pNode->iFunc = Vec_IntEntry( vLeaves, i );
+ // perform strashing
+ return Kit_GraphToGiaInternal( pMan, pGraph, fHash );
+}
+int Kit_TruthToGia( Gia_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory, Vec_Int_t * vLeaves, int fHash )
+{
+ int iLit;
+ Kit_Graph_t * pGraph;
+ // transform truth table into the decomposition tree
+ if ( vMemory == NULL )
+ {
+ vMemory = Vec_IntAlloc( 0 );
+ pGraph = Kit_TruthToGraph( pTruth, nVars, vMemory );
+ Vec_IntFree( vMemory );
+ }
+ else
+ pGraph = Kit_TruthToGraph( pTruth, nVars, vMemory );
+ if ( pGraph == NULL )
+ {
+ printf( "Kit_TruthToGia(): Converting truth table to AIG has failed for function:\n" );
+ Kit_DsdPrintFromTruth( pTruth, nVars ); printf( "\n" );
+ }
+ // derive the AIG for the decomposition tree
+ iLit = Kit_GraphToGia( pMan, pGraph, vLeaves, fHash );
+ Kit_GraphFree( pGraph );
+ return iLit;
}
/**Function*************************************************************
- Synopsis [Strashes one logic node using its SOP.]
+ Synopsis [Transforms the decomposition graph into the AIG.]
Description []
@@ -76,6 +112,27 @@ Hop_Obj_t * Kit_GraphToHopInternal( Hop_Man_t * pMan, Kit_Graph_t * pGraph )
SeeAlso []
***********************************************************************/
+Hop_Obj_t * Kit_GraphToHopInternal( Hop_Man_t * pMan, Kit_Graph_t * pGraph )
+{
+ Kit_Node_t * pNode = NULL;
+ Hop_Obj_t * pAnd0, * pAnd1;
+ int i;
+ // check for constant function
+ if ( Kit_GraphIsConst(pGraph) )
+ return Hop_NotCond( Hop_ManConst1(pMan), Kit_GraphIsComplement(pGraph) );
+ // check for a literal
+ if ( Kit_GraphIsVar(pGraph) )
+ return Hop_NotCond( (Hop_Obj_t *)Kit_GraphVar(pGraph)->pFunc, Kit_GraphIsComplement(pGraph) );
+ // build the AIG nodes corresponding to the AND gates of the graph
+ Kit_GraphForEachNode( pGraph, pNode, i )
+ {
+ pAnd0 = Hop_NotCond( (Hop_Obj_t *)Kit_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
+ pAnd1 = Hop_NotCond( (Hop_Obj_t *)Kit_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
+ pNode->pFunc = Hop_And( pMan, pAnd0, pAnd1 );
+ }
+ // complement the result if necessary
+ return Hop_NotCond( (Hop_Obj_t *)pNode->pFunc, Kit_GraphIsComplement(pGraph) );
+}
Hop_Obj_t * Kit_GraphToHop( Hop_Man_t * pMan, Kit_Graph_t * pGraph )
{
Kit_Node_t * pNode = NULL;
@@ -86,18 +143,6 @@ Hop_Obj_t * Kit_GraphToHop( Hop_Man_t * pMan, Kit_Graph_t * pGraph )
// perform strashing
return Kit_GraphToHopInternal( pMan, pGraph );
}
-
-/**Function*************************************************************
-
- Synopsis [Strashed onen logic nodes using its truth table.]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
Hop_Obj_t * Kit_TruthToHop( Hop_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory )
{
Hop_Obj_t * pObj;