diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2012-10-24 20:00:20 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2012-10-24 20:00:20 -0700 |
commit | e9e8f17942388c4c9c53853b028b621091dd37d7 (patch) | |
tree | 4f96bfc6ab7c42bc97d0a8d89b77f2a5229f0a74 /src/bool | |
parent | 6b96d9a84e1356295c8c25588915701bd9160001 (diff) | |
download | abc-e9e8f17942388c4c9c53853b028b621091dd37d7.tar.gz abc-e9e8f17942388c4c9c53853b028b621091dd37d7.tar.bz2 abc-e9e8f17942388c4c9c53853b028b621091dd37d7.zip |
Integrating GIA with LUT mapping.
Diffstat (limited to 'src/bool')
-rw-r--r-- | src/bool/kit/kit.h | 4 | ||||
-rw-r--r-- | src/bool/kit/kitHop.c | 89 |
2 files changed, 70 insertions, 23 deletions
diff --git a/src/bool/kit/kit.h b/src/bool/kit/kit.h index 5ecb5581..cb1c1eb0 100644 --- a/src/bool/kit/kit.h +++ b/src/bool/kit/kit.h @@ -68,7 +68,8 @@ struct Kit_Node_t_ Kit_Edge_t eEdge0; // the left child of the node Kit_Edge_t eEdge1; // the right child of the node // other info - void * pFunc; // the function of the node (BDD or AIG) + union { int iFunc; // the function of the node (BDD or AIG) + void * pFunc; }; // the function of the node (BDD or AIG) unsigned Level : 14; // the level of this node in the global AIG // printing info unsigned fNodeOr : 1; // marks the original OR node @@ -561,6 +562,7 @@ extern unsigned Kit_GraphToTruth( Kit_Graph_t * pGraph ); extern Kit_Graph_t * Kit_TruthToGraph( unsigned * pTruth, int nVars, Vec_Int_t * vMemory ); extern int Kit_GraphLeafDepth_rec( Kit_Graph_t * pGraph, Kit_Node_t * pNode, Kit_Node_t * pLeaf ); /*=== kitHop.c ==========================================================*/ +//extern int Kit_TruthToGia( Gia_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory, Vec_Int_t * vLeaves, int fHash ); //extern Hop_Obj_t * Kit_GraphToHop( Hop_Man_t * pMan, Kit_Graph_t * pGraph ); //extern Hop_Obj_t * Kit_TruthToHop( Hop_Man_t * pMan, unsigned * pTruth, int nVars, Vec_Int_t * vMemory ); //extern Hop_Obj_t * Kit_CoverToHop( Hop_Man_t * pMan, Vec_Int_t * vCover, int nVars, Vec_Int_t * vMemory ); 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; |