diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2010-11-01 01:35:04 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2010-11-01 01:35:04 -0700 |
commit | 6130e39b18b5f53902e4eab14f6d5cdde5219563 (patch) | |
tree | 0db0628479a1b750e9af1f66cb8379ebd0913d31 /src/opt/dec | |
parent | f0e77f6797c0504b0da25a56152b707d3357f386 (diff) | |
download | abc-6130e39b18b5f53902e4eab14f6d5cdde5219563.tar.gz abc-6130e39b18b5f53902e4eab14f6d5cdde5219563.tar.bz2 abc-6130e39b18b5f53902e4eab14f6d5cdde5219563.zip |
initial commit of public abc
Diffstat (limited to 'src/opt/dec')
-rw-r--r-- | src/opt/dec/dec.h | 25 | ||||
-rw-r--r-- | src/opt/dec/decAbc.c | 53 | ||||
-rw-r--r-- | src/opt/dec/decFactor.c | 17 | ||||
-rw-r--r-- | src/opt/dec/decMan.c | 7 | ||||
-rw-r--r-- | src/opt/dec/decPrint.c | 5 | ||||
-rw-r--r-- | src/opt/dec/decUtil.c | 11 |
6 files changed, 77 insertions, 41 deletions
diff --git a/src/opt/dec/dec.h b/src/opt/dec/dec.h index 4042ac65..543fabf1 100644 --- a/src/opt/dec/dec.h +++ b/src/opt/dec/dec.h @@ -21,6 +21,7 @@ #ifndef __DEC_H__ #define __DEC_H__ + //////////////////////////////////////////////////////////////////////// /// INCLUDES /// //////////////////////////////////////////////////////////////////////// @@ -29,9 +30,10 @@ /// PARAMETERS /// //////////////////////////////////////////////////////////////////////// -#ifdef __cplusplus -extern "C" { -#endif + + +ABC_NAMESPACE_HEADER_START + //////////////////////////////////////////////////////////////////////// /// BASIC TYPES /// @@ -50,7 +52,8 @@ struct Dec_Node_t_ Dec_Edge_t eEdge0; // the left child of the node Dec_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 literal of the node (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 @@ -177,10 +180,13 @@ static inline Dec_Edge_t Dec_IntToEdge( unsigned Edge ) SeeAlso [] ***********************************************************************/ +static inline unsigned Dec_EdgeToInt_( Dec_Edge_t m ) { union { Dec_Edge_t x; unsigned y; } v; v.x = m; return v.y; } +/* static inline unsigned Dec_EdgeToInt_( Dec_Edge_t eEdge ) { return *(unsigned *)&eEdge; } +*/ /**Function************************************************************* @@ -193,10 +199,13 @@ static inline unsigned Dec_EdgeToInt_( Dec_Edge_t eEdge ) SeeAlso [] ***********************************************************************/ +static inline Dec_Edge_t Dec_IntToEdge_( unsigned m ) { union { Dec_Edge_t x; unsigned y; } v; v.y = m; return v.x; } +/* static inline Dec_Edge_t Dec_IntToEdge_( unsigned Edge ) { return *(Dec_Edge_t *)&Edge; } +*/ /**Function************************************************************* @@ -702,9 +711,11 @@ static inline Dec_Edge_t Dec_GraphAddNodeMux( Dec_Graph_t * pGraph, Dec_Edge_t e return eNode; } -#ifdef __cplusplus -} -#endif + + +ABC_NAMESPACE_HEADER_END + + #endif diff --git a/src/opt/dec/decAbc.c b/src/opt/dec/decAbc.c index 158dc70a..24bfc9a8 100644 --- a/src/opt/dec/decAbc.c +++ b/src/opt/dec/decAbc.c @@ -20,6 +20,9 @@ #include "dec.h" #include "ivy.h" +ABC_NAMESPACE_IMPL_START + + //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// @@ -50,16 +53,16 @@ Abc_Obj_t * Dec_GraphToNetwork( Abc_Ntk_t * pNtk, Dec_Graph_t * pGraph ) return Abc_ObjNotCond( Abc_AigConst1(pNtk), Dec_GraphIsComplement(pGraph) ); // check for a literal if ( Dec_GraphIsVar(pGraph) ) - return Abc_ObjNotCond( Dec_GraphVar(pGraph)->pFunc, Dec_GraphIsComplement(pGraph) ); + return Abc_ObjNotCond( (Abc_Obj_t *)Dec_GraphVar(pGraph)->pFunc, Dec_GraphIsComplement(pGraph) ); // build the AIG nodes corresponding to the AND gates of the graph Dec_GraphForEachNode( pGraph, pNode, i ) { - pAnd0 = Abc_ObjNotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl ); - pAnd1 = Abc_ObjNotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl ); - pNode->pFunc = Abc_AigAnd( pNtk->pManFunc, pAnd0, pAnd1 ); + pAnd0 = Abc_ObjNotCond( (Abc_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl ); + pAnd1 = Abc_ObjNotCond( (Abc_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl ); + pNode->pFunc = Abc_AigAnd( (Abc_Aig_t *)pNtk->pManFunc, pAnd0, pAnd1 ); } // complement the result if necessary - return Abc_ObjNotCond( pNode->pFunc, Dec_GraphIsComplement(pGraph) ); + return Abc_ObjNotCond( (Abc_Obj_t *)pNode->pFunc, Dec_GraphIsComplement(pGraph) ); } /**Function************************************************************* @@ -131,20 +134,20 @@ Abc_Obj_t * Dec_GraphToNetworkNoStrash( Abc_Ntk_t * pNtk, Dec_Graph_t * pGraph ) return Abc_ObjNotCond( Abc_AigConst1(pNtk), Dec_GraphIsComplement(pGraph) ); // check for a literal if ( Dec_GraphIsVar(pGraph) ) - return Abc_ObjNotCond( Dec_GraphVar(pGraph)->pFunc, Dec_GraphIsComplement(pGraph) ); + return Abc_ObjNotCond( (Abc_Obj_t *)Dec_GraphVar(pGraph)->pFunc, Dec_GraphIsComplement(pGraph) ); // build the AIG nodes corresponding to the AND gates of the graph Dec_GraphForEachNode( pGraph, pNode, i ) { - pAnd0 = Abc_ObjNotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl ); - pAnd1 = Abc_ObjNotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl ); -// pNode->pFunc = Abc_AigAnd( pNtk->pManFunc, pAnd0, pAnd1 ); + pAnd0 = Abc_ObjNotCond( (Abc_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl ); + pAnd1 = Abc_ObjNotCond( (Abc_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl ); +// pNode->pFunc = Abc_AigAnd( (Abc_Aig_t *)pNtk->pManFunc, pAnd0, pAnd1 ); pAnd = Abc_NtkCreateNode( pNtk ); Abc_ObjAddFanin( pAnd, pAnd0 ); Abc_ObjAddFanin( pAnd, pAnd1 ); pNode->pFunc = pAnd; } // complement the result if necessary - return Abc_ObjNotCond( pNode->pFunc, Dec_GraphIsComplement(pGraph) ); + return Abc_ObjNotCond( (Abc_Obj_t *)pNode->pFunc, Dec_GraphIsComplement(pGraph) ); } /**Function************************************************************* @@ -163,7 +166,7 @@ Abc_Obj_t * Dec_GraphToNetworkNoStrash( Abc_Ntk_t * pNtk, Dec_Graph_t * pGraph ) ***********************************************************************/ int Dec_GraphToNetworkCount( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, int NodeMax, int LevelMax ) { - Abc_Aig_t * pMan = pRoot->pNtk->pManFunc; + Abc_Aig_t * pMan = (Abc_Aig_t *)pRoot->pNtk->pManFunc; Dec_Node_t * pNode, * pNode0, * pNode1; Abc_Obj_t * pAnd, * pAnd0, * pAnd1; int i, Counter, LevelNew, LevelOld; @@ -172,7 +175,7 @@ int Dec_GraphToNetworkCount( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, int NodeMa return 0; // set the levels of the leaves Dec_GraphForEachLeaf( pGraph, pNode, i ) - pNode->Level = Abc_ObjRegular(pNode->pFunc)->Level; + pNode->Level = Abc_ObjRegular((Abc_Obj_t *)pNode->pFunc)->Level; // compute the AIG size after adding the internal nodes Counter = 0; Dec_GraphForEachNode( pGraph, pNode, i ) @@ -181,8 +184,8 @@ int Dec_GraphToNetworkCount( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, int NodeMa pNode0 = Dec_GraphNode( pGraph, pNode->eEdge0.Node ); pNode1 = Dec_GraphNode( pGraph, pNode->eEdge1.Node ); // get the AIG nodes corresponding to the children - pAnd0 = pNode0->pFunc; - pAnd1 = pNode1->pFunc; + pAnd0 = (Abc_Obj_t *)pNode0->pFunc; + pAnd1 = (Abc_Obj_t *)pNode1->pFunc; if ( pAnd0 && pAnd1 ) { // if they are both present, find the resulting node @@ -234,7 +237,7 @@ int Dec_GraphToNetworkCount( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, int NodeMa SeeAlso [] ***********************************************************************/ -void Dec_GraphUpdateNetwork( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, bool fUpdateLevel, int nGain ) +void Dec_GraphUpdateNetwork( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, int fUpdateLevel, int nGain ) { extern Abc_Obj_t * Dec_GraphToNetwork( Abc_Ntk_t * pNtk, Dec_Graph_t * pGraph ); Abc_Obj_t * pRootNew; @@ -244,7 +247,7 @@ void Dec_GraphUpdateNetwork( Abc_Obj_t * pRoot, Dec_Graph_t * pGraph, bool fUpda // create the new structure of nodes pRootNew = Dec_GraphToNetwork( pNtk, pGraph ); // remove the old nodes - Abc_AigReplace( pNtk->pManFunc, pRoot, pRootNew, fUpdateLevel ); + Abc_AigReplace( (Abc_Aig_t *)pNtk->pManFunc, pRoot, pRootNew, fUpdateLevel ); // compare the gains nNodesNew = Abc_NtkNodeNum(pNtk); assert( nGain <= nNodesOld - nNodesNew ); @@ -272,16 +275,16 @@ Hop_Obj_t * Dec_GraphToNetworkAig( Hop_Man_t * pMan, Dec_Graph_t * pGraph ) return Hop_NotCond( Hop_ManConst1(pMan), Dec_GraphIsComplement(pGraph) ); // check for a literal if ( Dec_GraphIsVar(pGraph) ) - return Hop_NotCond( Dec_GraphVar(pGraph)->pFunc, Dec_GraphIsComplement(pGraph) ); + return Hop_NotCond( (Hop_Obj_t *)Dec_GraphVar(pGraph)->pFunc, Dec_GraphIsComplement(pGraph) ); // build the AIG nodes corresponding to the AND gates of the graph Dec_GraphForEachNode( pGraph, pNode, i ) { - pAnd0 = Hop_NotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl ); - pAnd1 = Hop_NotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl ); + pAnd0 = Hop_NotCond( (Hop_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl ); + pAnd1 = Hop_NotCond( (Hop_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl ); pNode->pFunc = Hop_And( pMan, pAnd0, pAnd1 ); } // complement the result if necessary - return Hop_NotCond( pNode->pFunc, Dec_GraphIsComplement(pGraph) ); + return Hop_NotCond( (Hop_Obj_t *)pNode->pFunc, Dec_GraphIsComplement(pGraph) ); } /**Function************************************************************* @@ -333,16 +336,16 @@ Ivy_Obj_t * Dec_GraphToNetworkIvy( Ivy_Man_t * pMan, Dec_Graph_t * pGraph ) return Ivy_NotCond( Ivy_ManConst1(pMan), Dec_GraphIsComplement(pGraph) ); // check for a literal if ( Dec_GraphIsVar(pGraph) ) - return Ivy_NotCond( Dec_GraphVar(pGraph)->pFunc, Dec_GraphIsComplement(pGraph) ); + return Ivy_NotCond( (Ivy_Obj_t *)Dec_GraphVar(pGraph)->pFunc, Dec_GraphIsComplement(pGraph) ); // build the AIG nodes corresponding to the AND gates of the graph Dec_GraphForEachNode( pGraph, pNode, i ) { - pAnd0 = Ivy_NotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl ); - pAnd1 = Ivy_NotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl ); + pAnd0 = Ivy_NotCond( (Ivy_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl ); + pAnd1 = Ivy_NotCond( (Ivy_Obj_t *)Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl ); pNode->pFunc = Ivy_And( pMan, pAnd0, pAnd1 ); } // complement the result if necessary - return Ivy_NotCond( pNode->pFunc, Dec_GraphIsComplement(pGraph) ); + return Ivy_NotCond( (Ivy_Obj_t *)pNode->pFunc, Dec_GraphIsComplement(pGraph) ); } @@ -351,3 +354,5 @@ Ivy_Obj_t * Dec_GraphToNetworkIvy( Ivy_Man_t * pMan, Dec_Graph_t * pGraph ) //////////////////////////////////////////////////////////////////////// +ABC_NAMESPACE_IMPL_END + diff --git a/src/opt/dec/decFactor.c b/src/opt/dec/decFactor.c index 16e65b79..aa9d9c8a 100644 --- a/src/opt/dec/decFactor.c +++ b/src/opt/dec/decFactor.c @@ -21,6 +21,9 @@ #include "mvc.h" #include "dec.h" +ABC_NAMESPACE_IMPL_START + + //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// @@ -57,7 +60,7 @@ Dec_Graph_t * Dec_Factor( char * pSop ) // derive the cover from the SOP representation pCover = Dec_ConvertSopToMvc( pSop ); - // make sure the cover is CCS ABC_FREE (should be done before CST) + // make sure the cover is CCS free (should be done before CST) Mvc_CoverContain( pCover ); // check for trivial functions if ( Mvc_CoverIsEmpty(pCover) ) @@ -183,7 +186,7 @@ Dec_Edge_t Dec_Factor_rec( Dec_Graph_t * pFForm, Mvc_Cover_t * pCover ) ***********************************************************************/ Dec_Edge_t Dec_FactorLF_rec( Dec_Graph_t * pFForm, Mvc_Cover_t * pCover, Mvc_Cover_t * pSimple ) { - Dec_Man_t * pManDec = Abc_FrameReadManDec(); + Dec_Man_t * pManDec = (Dec_Man_t *)Abc_FrameReadManDec(); Vec_Int_t * vEdgeLits = pManDec->vLits; Mvc_Cover_t * pDiv, * pQuo, * pRem; Dec_Edge_t eNodeDiv, eNodeQuo, eNodeRem; @@ -228,7 +231,7 @@ Dec_Edge_t Dec_FactorLF_rec( Dec_Graph_t * pFForm, Mvc_Cover_t * pCover, Mvc_Cov ***********************************************************************/ Dec_Edge_t Dec_FactorTrivial( Dec_Graph_t * pFForm, Mvc_Cover_t * pCover ) { - Dec_Man_t * pManDec = Abc_FrameReadManDec(); + Dec_Man_t * pManDec = (Dec_Man_t *)Abc_FrameReadManDec(); Vec_Int_t * vEdgeCubes = pManDec->vCubes; Vec_Int_t * vEdgeLits = pManDec->vLits; Dec_Edge_t eNode; @@ -321,8 +324,8 @@ Dec_Edge_t Dec_FactorTrivialTree_rec( Dec_Graph_t * pFForm, Dec_Edge_t * peNodes ***********************************************************************/ Mvc_Cover_t * Dec_ConvertSopToMvc( char * pSop ) { - Dec_Man_t * pManDec = Abc_FrameReadManDec(); - Mvc_Manager_t * pMem = pManDec->pMvcMem; + Dec_Man_t * pManDec = (Dec_Man_t *)Abc_FrameReadManDec(); + Mvc_Manager_t * pMem = (Mvc_Manager_t *)pManDec->pMvcMem; Mvc_Cover_t * pMvc; Mvc_Cube_t * pMvcCube; char * pCube; @@ -364,7 +367,7 @@ Mvc_Cover_t * Dec_ConvertSopToMvc( char * pSop ) int Dec_FactorVerify( char * pSop, Dec_Graph_t * pFForm ) { extern DdNode * Dec_GraphDeriveBdd( DdManager * dd, Dec_Graph_t * pGraph ); - DdManager * dd = Abc_FrameReadManDd(); + DdManager * dd = (DdManager *)Abc_FrameReadManDd(); DdNode * bFunc1, * bFunc2; int RetValue; bFunc1 = Abc_ConvertSopToBdd( dd, pSop ); Cudd_Ref( bFunc1 ); @@ -390,3 +393,5 @@ int Dec_FactorVerify( char * pSop, Dec_Graph_t * pFForm ) //////////////////////////////////////////////////////////////////////// +ABC_NAMESPACE_IMPL_END + diff --git a/src/opt/dec/decMan.c b/src/opt/dec/decMan.c index 63a96966..8b6fae65 100644 --- a/src/opt/dec/decMan.c +++ b/src/opt/dec/decMan.c @@ -20,6 +20,9 @@ #include "mvc.h" #include "dec.h" +ABC_NAMESPACE_IMPL_START + + //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// @@ -66,7 +69,7 @@ Dec_Man_t * Dec_ManStart() ***********************************************************************/ void Dec_ManStop( Dec_Man_t * p ) { - Mvc_ManagerFree( p->pMvcMem ); + Mvc_ManagerFree( (Mvc_Manager_t *)p->pMvcMem ); Vec_IntFree( p->vCubes ); Vec_IntFree( p->vLits ); ABC_FREE( p->puCanons ); @@ -81,3 +84,5 @@ void Dec_ManStop( Dec_Man_t * p ) //////////////////////////////////////////////////////////////////////// +ABC_NAMESPACE_IMPL_END + diff --git a/src/opt/dec/decPrint.c b/src/opt/dec/decPrint.c index 2d8f09b3..3cc0f811 100644 --- a/src/opt/dec/decPrint.c +++ b/src/opt/dec/decPrint.c @@ -19,6 +19,9 @@ #include "abc.h" #include "dec.h" +ABC_NAMESPACE_IMPL_START + + //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// @@ -282,3 +285,5 @@ int Dec_GraphPrintOutputName( FILE * pFile, char * pNameOut, int fCompl ) //////////////////////////////////////////////////////////////////////// +ABC_NAMESPACE_IMPL_END + diff --git a/src/opt/dec/decUtil.c b/src/opt/dec/decUtil.c index b8ae4b8a..adf216f6 100644 --- a/src/opt/dec/decUtil.c +++ b/src/opt/dec/decUtil.c @@ -19,6 +19,9 @@ #include "abc.h" #include "dec.h" +ABC_NAMESPACE_IMPL_START + + //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// @@ -64,13 +67,13 @@ DdNode * Dec_GraphDeriveBdd( DdManager * dd, Dec_Graph_t * pGraph ) { bFunc0 = Cudd_NotCond( Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl ); bFunc1 = Cudd_NotCond( Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl ); - pNode->pFunc = Cudd_bddAnd( dd, bFunc0, bFunc1 ); Cudd_Ref( pNode->pFunc ); + pNode->pFunc = Cudd_bddAnd( dd, bFunc0, bFunc1 ); Cudd_Ref( (DdNode *)pNode->pFunc ); } // deref the intermediate results - bFunc = pNode->pFunc; Cudd_Ref( bFunc ); + bFunc = (DdNode *)pNode->pFunc; Cudd_Ref( bFunc ); Dec_GraphForEachNode( pGraph, pNode, i ) - Cudd_RecursiveDeref( dd, pNode->pFunc ); + Cudd_RecursiveDeref( dd, (DdNode *)pNode->pFunc ); Cudd_Deref( bFunc ); // complement the result if necessary @@ -133,3 +136,5 @@ unsigned Dec_GraphDeriveTruth( Dec_Graph_t * pGraph ) //////////////////////////////////////////////////////////////////////// +ABC_NAMESPACE_IMPL_END + |