21#ifndef ABC__opt__dec__dec_h
22#define ABC__opt__dec__dec_h
98#define Dec_GraphForEachLeaf( pGraph, pLeaf, i ) \
99 for ( i = 0; (i < (pGraph)->nLeaves) && (((pLeaf) = Dec_GraphNode(pGraph, i)), 1); i++ )
101#define Dec_GraphForEachNode( pGraph, pAnd, i ) \
102 for ( i = (pGraph)->nLeaves; (i < (pGraph)->nSize) && (((pAnd) = Dec_GraphNode(pGraph, i)), 1); i++ )
134static inline Dec_Edge_t Dec_EdgeCreate(
int Node,
int fCompl )
136 Dec_Edge_t eEdge = { (unsigned)fCompl, (
unsigned)Node };
151static inline unsigned Dec_EdgeToInt(
Dec_Edge_t eEdge )
153 return (eEdge.Node << 1) | eEdge.fCompl;
167static inline Dec_Edge_t Dec_IntToEdge(
unsigned Edge )
169 return Dec_EdgeCreate( Edge >> 1, Edge & 1 );
183static inline unsigned Dec_EdgeToInt_(
Dec_Edge_t m ) {
union {
Dec_Edge_t x;
unsigned y; } v; v.x = m;
return v.y; }
202static inline Dec_Edge_t Dec_IntToEdge_(
unsigned m ) {
union {
Dec_Edge_t x;
unsigned y; } v; v.y = m;
return v.x; }
221static inline Dec_Graph_t * Dec_GraphCreate(
int nLeaves )
227 pGraph->
nSize = nLeaves;
228 pGraph->
nCap = 2 * nLeaves + 50;
251 pGraph->
eRoot.fCompl = 1;
286static inline Dec_Graph_t * Dec_GraphCreateLeaf(
int iLeaf,
int nLeaves,
int fCompl )
289 assert( 0 <= iLeaf && iLeaf < nLeaves );
290 pGraph = Dec_GraphCreate( nLeaves );
291 pGraph->
eRoot.Node = iLeaf;
292 pGraph->
eRoot.fCompl = fCompl;
307static inline void Dec_GraphFree(
Dec_Graph_t * pGraph )
324static inline int Dec_GraphIsConst(
Dec_Graph_t * pGraph )
340static inline int Dec_GraphIsConst0(
Dec_Graph_t * pGraph )
356static inline int Dec_GraphIsConst1(
Dec_Graph_t * pGraph )
372static inline int Dec_GraphIsComplement(
Dec_Graph_t * pGraph )
374 return pGraph->
eRoot.fCompl;
388static inline void Dec_GraphComplement(
Dec_Graph_t * pGraph )
390 pGraph->
eRoot.fCompl ^= 1;
405static inline int Dec_GraphLeaveNum(
Dec_Graph_t * pGraph )
421static inline int Dec_GraphNodeNum(
Dec_Graph_t * pGraph )
439 return pGraph->
pNodes + i;
471 return pNode - pGraph->
pNodes;
485static inline int Dec_GraphIsVar(
Dec_Graph_t * pGraph )
503 return Dec_GraphNodeInt(pGraph,pNode) < pGraph->
nLeaves;
519 assert( Dec_GraphIsVar( pGraph ) );
520 return Dec_GraphNode( pGraph, pGraph->
eRoot.Node );
534static inline int Dec_GraphVarInt(
Dec_Graph_t * pGraph )
536 assert( Dec_GraphIsVar( pGraph ) );
537 return Dec_GraphNodeInt( pGraph, Dec_GraphVar(pGraph) );
553 pGraph->
eRoot = eRoot;
595 pNode = Dec_GraphAppendNode( pGraph );
599 pNode->
fCompl0 = eEdge0.fCompl;
600 pNode->
fCompl1 = eEdge1.fCompl;
601 return Dec_EdgeCreate( pGraph->
nSize - 1, 0 );
619 pNode = Dec_GraphAppendNode( pGraph );
623 pNode->
fCompl0 = eEdge0.fCompl;
624 pNode->
fCompl1 = eEdge1.fCompl;
629 return Dec_EdgeCreate( pGraph->
nSize - 1, 1 );
650 eNode0 = Dec_GraphAddNodeAnd( pGraph, eEdge0, eEdge1 );
654 eNode1 = Dec_GraphAddNodeAnd( pGraph, eEdge0, eEdge1 );
656 eNode = Dec_GraphAddNodeOr( pGraph, eNode0, eNode1 );
661 eNode0 = Dec_GraphAddNodeAnd( pGraph, eEdge0, eEdge1 );
665 eNode1 = Dec_GraphAddNodeAnd( pGraph, eEdge0, eEdge1 );
667 eNode = Dec_GraphAddNodeOr( pGraph, eNode0, eNode1 );
690 eNode0 = Dec_GraphAddNodeAnd( pGraph, eEdgeC, eEdgeT );
693 eNode1 = Dec_GraphAddNodeAnd( pGraph, eEdgeC, eEdgeE );
695 eNode = Dec_GraphAddNodeOr( pGraph, eNode0, eNode1 );
703 eNode0 = Dec_GraphAddNodeAnd( pGraph, eEdgeC, eEdgeT );
706 eNode1 = Dec_GraphAddNodeAnd( pGraph, eEdgeC, eEdgeE );
708 eNode = Dec_GraphAddNodeOr( pGraph, eNode0, eNode1 );
#define ABC_ALLOC(type, num)
#define ABC_REALLOC(type, obj, num)
#define ABC_NAMESPACE_HEADER_END
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
struct Dec_Man_t_ Dec_Man_t
struct Dec_Node_t_ Dec_Node_t
Dec_Man_t * Dec_ManStart()
DECLARATIONS ///.
unsigned Dec_GraphDeriveTruth(Dec_Graph_t *pGraph)
DECLARATIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Dec_Edge_t_ Dec_Edge_t
INCLUDES ///.
void Dec_ManStop(Dec_Man_t *p)
void Dec_GraphPrint(FILE *pFile, Dec_Graph_t *pGraph, char *pNamesIn[], char *pNameOut)
FUNCTION DEFINITIONS ///.
Dec_Graph_t * Dec_Factor(char *pSop)
FUNCTION DECLARATIONS ///.
struct Dec_Graph_t_ Dec_Graph_t
unsigned short * puCanons