abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
dec.h File Reference

Go to the source code of this file.

Data Structures

struct  Dec_Edge_t_
 
struct  Dec_Node_t_
 
struct  Dec_Graph_t_
 
struct  Dec_Man_t_
 

Macros

#define Dec_GraphForEachLeaf(pGraph, pLeaf, i)   for ( i = 0; (i < (pGraph)->nLeaves) && (((pLeaf) = Dec_GraphNode(pGraph, i)), 1); i++ )
 ITERATORS ///. More...
 
#define Dec_GraphForEachNode(pGraph, pAnd, i)   for ( i = (pGraph)->nLeaves; (i < (pGraph)->nSize) && (((pAnd) = Dec_GraphNode(pGraph, i)), 1); i++ )
 

Typedefs

typedef
typedefABC_NAMESPACE_HEADER_START
struct Dec_Edge_t_ 
Dec_Edge_t
 INCLUDES ///. More...
 
typedef struct Dec_Node_t_ Dec_Node_t
 
typedef struct Dec_Graph_t_ Dec_Graph_t
 
typedef struct Dec_Man_t_ Dec_Man_t
 

Functions

Dec_Graph_tDec_Factor (char *pSop)
 FUNCTION DECLARATIONS ///. More...
 
Dec_Man_tDec_ManStart ()
 DECLARATIONS ///. More...
 
void Dec_ManStop (Dec_Man_t *p)
 
void Dec_GraphPrint (FILE *pFile, Dec_Graph_t *pGraph, char *pNamesIn[], char *pNameOut)
 FUNCTION DEFINITIONS ///. More...
 
unsigned Dec_GraphDeriveTruth (Dec_Graph_t *pGraph)
 
static Dec_Edge_t Dec_EdgeCreate (int Node, int fCompl)
 FUNCTION DEFINITIONS ///. More...
 
static unsigned Dec_EdgeToInt (Dec_Edge_t eEdge)
 
static Dec_Edge_t Dec_IntToEdge (unsigned Edge)
 
static unsigned Dec_EdgeToInt_ (Dec_Edge_t m)
 
static Dec_Edge_t Dec_IntToEdge_ (unsigned m)
 
static Dec_Graph_tDec_GraphCreate (int nLeaves)
 
static Dec_Graph_tDec_GraphCreateConst0 ()
 
static Dec_Graph_tDec_GraphCreateConst1 ()
 
static Dec_Graph_tDec_GraphCreateLeaf (int iLeaf, int nLeaves, int fCompl)
 
static void Dec_GraphFree (Dec_Graph_t *pGraph)
 
static int Dec_GraphIsConst (Dec_Graph_t *pGraph)
 
static int Dec_GraphIsConst0 (Dec_Graph_t *pGraph)
 
static int Dec_GraphIsConst1 (Dec_Graph_t *pGraph)
 
static int Dec_GraphIsComplement (Dec_Graph_t *pGraph)
 
static void Dec_GraphComplement (Dec_Graph_t *pGraph)
 
static int Dec_GraphLeaveNum (Dec_Graph_t *pGraph)
 
static int Dec_GraphNodeNum (Dec_Graph_t *pGraph)
 
static Dec_Node_tDec_GraphNode (Dec_Graph_t *pGraph, int i)
 
static Dec_Node_tDec_GraphNodeLast (Dec_Graph_t *pGraph)
 
static int Dec_GraphNodeInt (Dec_Graph_t *pGraph, Dec_Node_t *pNode)
 
static int Dec_GraphIsVar (Dec_Graph_t *pGraph)
 
static int Dec_GraphNodeIsVar (Dec_Graph_t *pGraph, Dec_Node_t *pNode)
 
static Dec_Node_tDec_GraphVar (Dec_Graph_t *pGraph)
 
static int Dec_GraphVarInt (Dec_Graph_t *pGraph)
 
static void Dec_GraphSetRoot (Dec_Graph_t *pGraph, Dec_Edge_t eRoot)
 
static Dec_Node_tDec_GraphAppendNode (Dec_Graph_t *pGraph)
 
static Dec_Edge_t Dec_GraphAddNodeAnd (Dec_Graph_t *pGraph, Dec_Edge_t eEdge0, Dec_Edge_t eEdge1)
 
static Dec_Edge_t Dec_GraphAddNodeOr (Dec_Graph_t *pGraph, Dec_Edge_t eEdge0, Dec_Edge_t eEdge1)
 
static Dec_Edge_t Dec_GraphAddNodeXor (Dec_Graph_t *pGraph, Dec_Edge_t eEdge0, Dec_Edge_t eEdge1, int Type)
 
static Dec_Edge_t Dec_GraphAddNodeMux (Dec_Graph_t *pGraph, Dec_Edge_t eEdgeC, Dec_Edge_t eEdgeT, Dec_Edge_t eEdgeE, int Type)
 

Macro Definition Documentation

#define Dec_GraphForEachLeaf (   pGraph,
  pLeaf,
 
)    for ( i = 0; (i < (pGraph)->nLeaves) && (((pLeaf) = Dec_GraphNode(pGraph, i)), 1); i++ )

ITERATORS ///.

Definition at line 98 of file dec.h.

#define Dec_GraphForEachNode (   pGraph,
  pAnd,
 
)    for ( i = (pGraph)->nLeaves; (i < (pGraph)->nSize) && (((pAnd) = Dec_GraphNode(pGraph, i)), 1); i++ )

Definition at line 101 of file dec.h.

Typedef Documentation

typedef typedefABC_NAMESPACE_HEADER_START struct Dec_Edge_t_ Dec_Edge_t

INCLUDES ///.

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

FileName [dec.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [A simple decomposition tree/node data structure and its APIs.]

Synopsis [External declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id:
dec.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

]PARAMETERS ///BASIC TYPES ///

Definition at line 42 of file dec.h.

typedef struct Dec_Graph_t_ Dec_Graph_t

Definition at line 68 of file dec.h.

typedef struct Dec_Man_t_ Dec_Man_t

Definition at line 79 of file dec.h.

typedef struct Dec_Node_t_ Dec_Node_t

Definition at line 49 of file dec.h.

Function Documentation

static Dec_Edge_t Dec_EdgeCreate ( int  Node,
int  fCompl 
)
inlinestatic

FUNCTION DEFINITIONS ///.

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

Synopsis [Creates an edge pointing to the node in the given polarity.]

Description []

SideEffects []

SeeAlso []

Definition at line 134 of file dec.h.

135 {
136  Dec_Edge_t eEdge = { fCompl, Node };
137  return eEdge;
138 }
typedefABC_NAMESPACE_HEADER_START struct Dec_Edge_t_ Dec_Edge_t
INCLUDES ///.
Definition: dec.h:42
static unsigned Dec_EdgeToInt ( Dec_Edge_t  eEdge)
inlinestatic

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

Synopsis [Converts the edge into unsigned integer.]

Description []

SideEffects []

SeeAlso []

Definition at line 151 of file dec.h.

152 {
153  return (eEdge.Node << 1) | eEdge.fCompl;
154 }
static unsigned Dec_EdgeToInt_ ( Dec_Edge_t  m)
inlinestatic

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

Synopsis [Converts the edge into unsigned integer.]

Description []

SideEffects []

SeeAlso []

Definition at line 183 of file dec.h.

183 { union { Dec_Edge_t x; unsigned y; } v; v.x = m; return v.y; }
typedefABC_NAMESPACE_HEADER_START struct Dec_Edge_t_ Dec_Edge_t
INCLUDES ///.
Definition: dec.h:42
Dec_Graph_t* Dec_Factor ( char *  pSop)

FUNCTION DECLARATIONS ///.

FUNCTION DECLARATIONS ///.

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

Synopsis [Factors the cover.]

Description []

SideEffects []

SeeAlso []

Definition at line 55 of file decFactor.c.

56 {
57  Mvc_Cover_t * pCover;
58  Dec_Graph_t * pFForm;
59  Dec_Edge_t eRoot;
60 
61  // derive the cover from the SOP representation
62  pCover = Dec_ConvertSopToMvc( pSop );
63 
64  // make sure the cover is CCS free (should be done before CST)
65  Mvc_CoverContain( pCover );
66  // check for trivial functions
67  if ( Mvc_CoverIsEmpty(pCover) )
68  {
69  Mvc_CoverFree( pCover );
70  return Dec_GraphCreateConst0();
71  }
72  if ( Mvc_CoverIsTautology(pCover) )
73  {
74  Mvc_CoverFree( pCover );
75  return Dec_GraphCreateConst1();
76  }
77 
78  // perform CST
79  Mvc_CoverInverse( pCover ); // CST
80  // start the factored form
81  pFForm = Dec_GraphCreate( Abc_SopGetVarNum(pSop) );
82  // factor the cover
83  eRoot = Dec_Factor_rec( pFForm, pCover );
84  // finalize the factored form
85  Dec_GraphSetRoot( pFForm, eRoot );
86  // complement the factored form if SOP is complemented
87  if ( Abc_SopIsComplement(pSop) )
88  Dec_GraphComplement( pFForm );
89  // verify the factored form
90 // if ( !Dec_FactorVerify( pSop, pFForm ) )
91 // printf( "Verification has failed.\n" );
92 // Mvc_CoverInverse( pCover ); // undo CST
93  Mvc_CoverFree( pCover );
94  return pFForm;
95 }
int Mvc_CoverContain(Mvc_Cover_t *pCover)
FUNCTION DEFINITIONS ///.
Definition: mvcContain.c:47
void Mvc_CoverFree(Mvc_Cover_t *pCover)
Definition: mvcCover.c:138
static ABC_NAMESPACE_IMPL_START Dec_Edge_t Dec_Factor_rec(Dec_Graph_t *pFForm, Mvc_Cover_t *pCover)
DECLARATIONS ///.
Definition: decFactor.c:108
static Mvc_Cover_t * Dec_ConvertSopToMvc(char *pSop)
Definition: decFactor.c:326
typedefABC_NAMESPACE_HEADER_START struct Dec_Edge_t_ Dec_Edge_t
INCLUDES ///.
Definition: dec.h:42
static Dec_Graph_t * Dec_GraphCreateConst1()
Definition: dec.h:266
void Mvc_CoverInverse(Mvc_Cover_t *pCover)
Definition: mvcUtils.c:477
int Mvc_CoverIsTautology(Mvc_Cover_t *pCover)
Definition: mvcApi.c:109
static Dec_Graph_t * Dec_GraphCreateConst0()
Definition: dec.h:245
static void Dec_GraphSetRoot(Dec_Graph_t *pGraph, Dec_Edge_t eRoot)
Definition: dec.h:551
static Dec_Graph_t * Dec_GraphCreate(int nLeaves)
Definition: dec.h:221
ABC_DLL int Abc_SopGetVarNum(char *pSop)
Definition: abcSop.c:536
ABC_DLL int Abc_SopIsComplement(char *pSop)
Definition: abcSop.c:655
int Mvc_CoverIsEmpty(Mvc_Cover_t *pCover)
Definition: mvcApi.c:93
static void Dec_GraphComplement(Dec_Graph_t *pGraph)
Definition: dec.h:388
static Dec_Edge_t Dec_GraphAddNodeAnd ( Dec_Graph_t pGraph,
Dec_Edge_t  eEdge0,
Dec_Edge_t  eEdge1 
)
inlinestatic

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

Synopsis [Creates an AND node.]

Description []

SideEffects []

SeeAlso []

Definition at line 591 of file dec.h.

592 {
593  Dec_Node_t * pNode;
594  // get the new node
595  pNode = Dec_GraphAppendNode( pGraph );
596  // set the inputs and other info
597  pNode->eEdge0 = eEdge0;
598  pNode->eEdge1 = eEdge1;
599  pNode->fCompl0 = eEdge0.fCompl;
600  pNode->fCompl1 = eEdge1.fCompl;
601  return Dec_EdgeCreate( pGraph->nSize - 1, 0 );
602 }
static Dec_Edge_t Dec_EdgeCreate(int Node, int fCompl)
FUNCTION DEFINITIONS ///.
Definition: dec.h:134
int nSize
Definition: dec.h:73
static Dec_Node_t * Dec_GraphAppendNode(Dec_Graph_t *pGraph)
Definition: dec.h:567
unsigned fCompl1
Definition: dec.h:61
Dec_Edge_t eEdge0
Definition: dec.h:52
unsigned fCompl0
Definition: dec.h:60
Dec_Edge_t eEdge1
Definition: dec.h:53
static Dec_Edge_t Dec_GraphAddNodeMux ( Dec_Graph_t pGraph,
Dec_Edge_t  eEdgeC,
Dec_Edge_t  eEdgeT,
Dec_Edge_t  eEdgeE,
int  Type 
)
inlinestatic

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

Synopsis [Creates an XOR node.]

Description []

SideEffects []

SeeAlso []

Definition at line 684 of file dec.h.

685 {
686  Dec_Edge_t eNode0, eNode1, eNode;
687  if ( Type == 0 )
688  {
689  // derive the first AND
690  eNode0 = Dec_GraphAddNodeAnd( pGraph, eEdgeC, eEdgeT );
691  // derive the second AND
692  eEdgeC.fCompl ^= 1;
693  eNode1 = Dec_GraphAddNodeAnd( pGraph, eEdgeC, eEdgeE );
694  // derive the final OR
695  eNode = Dec_GraphAddNodeOr( pGraph, eNode0, eNode1 );
696  }
697  else
698  {
699  // complement the arguments
700  eEdgeT.fCompl ^= 1;
701  eEdgeE.fCompl ^= 1;
702  // derive the first AND
703  eNode0 = Dec_GraphAddNodeAnd( pGraph, eEdgeC, eEdgeT );
704  // derive the second AND
705  eEdgeC.fCompl ^= 1;
706  eNode1 = Dec_GraphAddNodeAnd( pGraph, eEdgeC, eEdgeE );
707  // derive the final OR
708  eNode = Dec_GraphAddNodeOr( pGraph, eNode0, eNode1 );
709  eNode.fCompl ^= 1;
710  }
711  return eNode;
712 }
typedefABC_NAMESPACE_HEADER_START struct Dec_Edge_t_ Dec_Edge_t
INCLUDES ///.
Definition: dec.h:42
static Dec_Edge_t Dec_GraphAddNodeAnd(Dec_Graph_t *pGraph, Dec_Edge_t eEdge0, Dec_Edge_t eEdge1)
Definition: dec.h:591
static Dec_Edge_t Dec_GraphAddNodeOr(Dec_Graph_t *pGraph, Dec_Edge_t eEdge0, Dec_Edge_t eEdge1)
Definition: dec.h:615
static Dec_Edge_t Dec_GraphAddNodeOr ( Dec_Graph_t pGraph,
Dec_Edge_t  eEdge0,
Dec_Edge_t  eEdge1 
)
inlinestatic

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

Synopsis [Creates an OR node.]

Description []

SideEffects []

SeeAlso []

Definition at line 615 of file dec.h.

616 {
617  Dec_Node_t * pNode;
618  // get the new node
619  pNode = Dec_GraphAppendNode( pGraph );
620  // set the inputs and other info
621  pNode->eEdge0 = eEdge0;
622  pNode->eEdge1 = eEdge1;
623  pNode->fCompl0 = eEdge0.fCompl;
624  pNode->fCompl1 = eEdge1.fCompl;
625  // make adjustments for the OR gate
626  pNode->fNodeOr = 1;
627  pNode->eEdge0.fCompl = !pNode->eEdge0.fCompl;
628  pNode->eEdge1.fCompl = !pNode->eEdge1.fCompl;
629  return Dec_EdgeCreate( pGraph->nSize - 1, 1 );
630 }
static Dec_Edge_t Dec_EdgeCreate(int Node, int fCompl)
FUNCTION DEFINITIONS ///.
Definition: dec.h:134
int nSize
Definition: dec.h:73
static Dec_Node_t * Dec_GraphAppendNode(Dec_Graph_t *pGraph)
Definition: dec.h:567
unsigned fCompl1
Definition: dec.h:61
Dec_Edge_t eEdge0
Definition: dec.h:52
unsigned fCompl0
Definition: dec.h:60
unsigned fNodeOr
Definition: dec.h:59
Dec_Edge_t eEdge1
Definition: dec.h:53
static Dec_Edge_t Dec_GraphAddNodeXor ( Dec_Graph_t pGraph,
Dec_Edge_t  eEdge0,
Dec_Edge_t  eEdge1,
int  Type 
)
inlinestatic

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

Synopsis [Creates an XOR node.]

Description []

SideEffects []

SeeAlso []

Definition at line 643 of file dec.h.

644 {
645  Dec_Edge_t eNode0, eNode1, eNode;
646  if ( Type == 0 )
647  {
648  // derive the first AND
649  eEdge0.fCompl ^= 1;
650  eNode0 = Dec_GraphAddNodeAnd( pGraph, eEdge0, eEdge1 );
651  eEdge0.fCompl ^= 1;
652  // derive the second AND
653  eEdge1.fCompl ^= 1;
654  eNode1 = Dec_GraphAddNodeAnd( pGraph, eEdge0, eEdge1 );
655  // derive the final OR
656  eNode = Dec_GraphAddNodeOr( pGraph, eNode0, eNode1 );
657  }
658  else
659  {
660  // derive the first AND
661  eNode0 = Dec_GraphAddNodeAnd( pGraph, eEdge0, eEdge1 );
662  // derive the second AND
663  eEdge0.fCompl ^= 1;
664  eEdge1.fCompl ^= 1;
665  eNode1 = Dec_GraphAddNodeAnd( pGraph, eEdge0, eEdge1 );
666  // derive the final OR
667  eNode = Dec_GraphAddNodeOr( pGraph, eNode0, eNode1 );
668  eNode.fCompl ^= 1;
669  }
670  return eNode;
671 }
typedefABC_NAMESPACE_HEADER_START struct Dec_Edge_t_ Dec_Edge_t
INCLUDES ///.
Definition: dec.h:42
static Dec_Edge_t Dec_GraphAddNodeAnd(Dec_Graph_t *pGraph, Dec_Edge_t eEdge0, Dec_Edge_t eEdge1)
Definition: dec.h:591
static Dec_Edge_t Dec_GraphAddNodeOr(Dec_Graph_t *pGraph, Dec_Edge_t eEdge0, Dec_Edge_t eEdge1)
Definition: dec.h:615
static Dec_Node_t* Dec_GraphAppendNode ( Dec_Graph_t pGraph)
inlinestatic

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

Synopsis [Appends a new node to the graph.]

Description [This procedure is meant for internal use.]

SideEffects []

SeeAlso []

Definition at line 567 of file dec.h.

568 {
569  Dec_Node_t * pNode;
570  if ( pGraph->nSize == pGraph->nCap )
571  {
572  pGraph->pNodes = ABC_REALLOC( Dec_Node_t, pGraph->pNodes, 2 * pGraph->nCap );
573  pGraph->nCap = 2 * pGraph->nCap;
574  }
575  pNode = pGraph->pNodes + pGraph->nSize++;
576  memset( pNode, 0, sizeof(Dec_Node_t) );
577  return pNode;
578 }
char * memset()
#define ABC_REALLOC(type, obj, num)
Definition: abc_global.h:233
int nCap
Definition: dec.h:74
int nSize
Definition: dec.h:73
Dec_Node_t * pNodes
Definition: dec.h:75
static void Dec_GraphComplement ( Dec_Graph_t pGraph)
inlinestatic

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

Synopsis [Checks if the graph is complemented.]

Description []

SideEffects []

SeeAlso []

Definition at line 388 of file dec.h.

389 {
390  pGraph->eRoot.fCompl ^= 1;
391 }
Dec_Edge_t eRoot
Definition: dec.h:76
static Dec_Graph_t* Dec_GraphCreate ( int  nLeaves)
inlinestatic

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

Synopsis [Creates a graph with the given number of leaves.]

Description []

SideEffects []

SeeAlso []

Definition at line 221 of file dec.h.

222 {
223  Dec_Graph_t * pGraph;
224  pGraph = ABC_ALLOC( Dec_Graph_t, 1 );
225  memset( pGraph, 0, sizeof(Dec_Graph_t) );
226  pGraph->nLeaves = nLeaves;
227  pGraph->nSize = nLeaves;
228  pGraph->nCap = 2 * nLeaves + 50;
229  pGraph->pNodes = ABC_ALLOC( Dec_Node_t, pGraph->nCap );
230  memset( pGraph->pNodes, 0, sizeof(Dec_Node_t) * pGraph->nSize );
231  return pGraph;
232 }
char * memset()
int nCap
Definition: dec.h:74
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int nSize
Definition: dec.h:73
int nLeaves
Definition: dec.h:72
Dec_Node_t * pNodes
Definition: dec.h:75
static Dec_Graph_t* Dec_GraphCreateConst0 ( )
inlinestatic

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

Synopsis [Creates constant 0 graph.]

Description []

SideEffects []

SeeAlso []

Definition at line 245 of file dec.h.

246 {
247  Dec_Graph_t * pGraph;
248  pGraph = ABC_ALLOC( Dec_Graph_t, 1 );
249  memset( pGraph, 0, sizeof(Dec_Graph_t) );
250  pGraph->fConst = 1;
251  pGraph->eRoot.fCompl = 1;
252  return pGraph;
253 }
Dec_Edge_t eRoot
Definition: dec.h:76
char * memset()
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int fConst
Definition: dec.h:71
static Dec_Graph_t* Dec_GraphCreateConst1 ( )
inlinestatic

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

Synopsis [Creates constant 1 graph.]

Description []

SideEffects []

SeeAlso []

Definition at line 266 of file dec.h.

267 {
268  Dec_Graph_t * pGraph;
269  pGraph = ABC_ALLOC( Dec_Graph_t, 1 );
270  memset( pGraph, 0, sizeof(Dec_Graph_t) );
271  pGraph->fConst = 1;
272  return pGraph;
273 }
char * memset()
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int fConst
Definition: dec.h:71
static Dec_Graph_t* Dec_GraphCreateLeaf ( int  iLeaf,
int  nLeaves,
int  fCompl 
)
inlinestatic

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

Synopsis [Creates the literal graph.]

Description []

SideEffects []

SeeAlso []

Definition at line 286 of file dec.h.

287 {
288  Dec_Graph_t * pGraph;
289  assert( 0 <= iLeaf && iLeaf < nLeaves );
290  pGraph = Dec_GraphCreate( nLeaves );
291  pGraph->eRoot.Node = iLeaf;
292  pGraph->eRoot.fCompl = fCompl;
293  return pGraph;
294 }
Dec_Edge_t eRoot
Definition: dec.h:76
static Dec_Graph_t * Dec_GraphCreate(int nLeaves)
Definition: dec.h:221
#define assert(ex)
Definition: util_old.h:213
unsigned Dec_GraphDeriveTruth ( Dec_Graph_t pGraph)

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

Synopsis [Derives the truth table.]

Description []

SideEffects []

SeeAlso []

Definition at line 95 of file decUtil.c.

96 {
97  unsigned uTruths[5] = { 0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0, 0xFF00FF00, 0xFFFF0000 };
98  unsigned uTruth = 0; // Suppress "might be used uninitialized"
99  unsigned uTruth0, uTruth1;
100  Dec_Node_t * pNode;
101  int i;
102 
103  // sanity checks
104  assert( Dec_GraphLeaveNum(pGraph) >= 0 );
105  assert( Dec_GraphLeaveNum(pGraph) <= pGraph->nSize );
106  assert( Dec_GraphLeaveNum(pGraph) <= 5 );
107 
108  // check for constant function
109  if ( Dec_GraphIsConst(pGraph) )
110  return Dec_GraphIsComplement(pGraph)? 0 : ~((unsigned)0);
111  // check for a literal
112  if ( Dec_GraphIsVar(pGraph) )
113  return Dec_GraphIsComplement(pGraph)? ~uTruths[Dec_GraphVarInt(pGraph)] : uTruths[Dec_GraphVarInt(pGraph)];
114 
115  // assign the elementary variables
116  Dec_GraphForEachLeaf( pGraph, pNode, i )
117  pNode->pFunc = (void *)(ABC_PTRUINT_T)uTruths[i];
118 
119  // compute the function for each internal node
120  Dec_GraphForEachNode( pGraph, pNode, i )
121  {
122  uTruth0 = (unsigned)(ABC_PTRUINT_T)Dec_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc;
123  uTruth1 = (unsigned)(ABC_PTRUINT_T)Dec_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc;
124  uTruth0 = pNode->eEdge0.fCompl? ~uTruth0 : uTruth0;
125  uTruth1 = pNode->eEdge1.fCompl? ~uTruth1 : uTruth1;
126  uTruth = uTruth0 & uTruth1;
127  pNode->pFunc = (void *)(ABC_PTRUINT_T)uTruth;
128  }
129 
130  // complement the result if necessary
131  return Dec_GraphIsComplement(pGraph)? ~uTruth : uTruth;
132 }
static int Dec_GraphVarInt(Dec_Graph_t *pGraph)
Definition: dec.h:534
static int Dec_GraphIsConst(Dec_Graph_t *pGraph)
Definition: dec.h:324
int nSize
Definition: dec.h:73
static int Dec_GraphIsComplement(Dec_Graph_t *pGraph)
Definition: dec.h:372
#define Dec_GraphForEachNode(pGraph, pAnd, i)
Definition: dec.h:101
void * pFunc
Definition: dec.h:56
#define Dec_GraphForEachLeaf(pGraph, pLeaf, i)
ITERATORS ///.
Definition: dec.h:98
static int Dec_GraphLeaveNum(Dec_Graph_t *pGraph)
Definition: dec.h:405
static int Dec_GraphIsVar(Dec_Graph_t *pGraph)
Definition: dec.h:485
#define assert(ex)
Definition: util_old.h:213
static Dec_Node_t * Dec_GraphNode(Dec_Graph_t *pGraph, int i)
Definition: dec.h:437
static void Dec_GraphFree ( Dec_Graph_t pGraph)
inlinestatic

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

Synopsis [Creates a graph with the given number of leaves.]

Description []

SideEffects []

SeeAlso []

Definition at line 307 of file dec.h.

308 {
309  ABC_FREE( pGraph->pNodes );
310  ABC_FREE( pGraph );
311 }
#define ABC_FREE(obj)
Definition: abc_global.h:232
Dec_Node_t * pNodes
Definition: dec.h:75
static int Dec_GraphIsComplement ( Dec_Graph_t pGraph)
inlinestatic

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

Synopsis [Returns 1 if the graph is complemented.]

Description []

SideEffects []

SeeAlso []

Definition at line 372 of file dec.h.

373 {
374  return pGraph->eRoot.fCompl;
375 }
Dec_Edge_t eRoot
Definition: dec.h:76
static int Dec_GraphIsConst ( Dec_Graph_t pGraph)
inlinestatic

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

Synopsis [Returns 1 if the graph is a constant.]

Description []

SideEffects []

SeeAlso []

Definition at line 324 of file dec.h.

325 {
326  return pGraph->fConst;
327 }
int fConst
Definition: dec.h:71
static int Dec_GraphIsConst0 ( Dec_Graph_t pGraph)
inlinestatic

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

Synopsis [Returns 1 if the graph is constant 0.]

Description []

SideEffects []

SeeAlso []

Definition at line 340 of file dec.h.

341 {
342  return pGraph->fConst && pGraph->eRoot.fCompl;
343 }
Dec_Edge_t eRoot
Definition: dec.h:76
int fConst
Definition: dec.h:71
static int Dec_GraphIsConst1 ( Dec_Graph_t pGraph)
inlinestatic

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

Synopsis [Returns 1 if the graph is constant 1.]

Description []

SideEffects []

SeeAlso []

Definition at line 356 of file dec.h.

357 {
358  return pGraph->fConst && !pGraph->eRoot.fCompl;
359 }
Dec_Edge_t eRoot
Definition: dec.h:76
int fConst
Definition: dec.h:71
static int Dec_GraphIsVar ( Dec_Graph_t pGraph)
inlinestatic

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

Synopsis [Check if the graph represents elementary variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 485 of file dec.h.

486 {
487  return pGraph->eRoot.Node < (unsigned)pGraph->nLeaves;
488 }
Dec_Edge_t eRoot
Definition: dec.h:76
int nLeaves
Definition: dec.h:72
static int Dec_GraphLeaveNum ( Dec_Graph_t pGraph)
inlinestatic

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

Synopsis [Returns the number of leaves.]

Description []

SideEffects []

SeeAlso []

Definition at line 405 of file dec.h.

406 {
407  return pGraph->nLeaves;
408 }
int nLeaves
Definition: dec.h:72
static Dec_Node_t* Dec_GraphNode ( Dec_Graph_t pGraph,
int  i 
)
inlinestatic

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

Synopsis [Returns the pointer to the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 437 of file dec.h.

438 {
439  return pGraph->pNodes + i;
440 }
Dec_Node_t * pNodes
Definition: dec.h:75
static int Dec_GraphNodeInt ( Dec_Graph_t pGraph,
Dec_Node_t pNode 
)
inlinestatic

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

Synopsis [Returns the number of the given node.]

Description []

SideEffects []

SeeAlso []

Definition at line 469 of file dec.h.

470 {
471  return pNode - pGraph->pNodes;
472 }
Dec_Node_t * pNodes
Definition: dec.h:75
static int Dec_GraphNodeIsVar ( Dec_Graph_t pGraph,
Dec_Node_t pNode 
)
inlinestatic

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

Synopsis [Check if the graph represents elementary variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 501 of file dec.h.

502 {
503  return Dec_GraphNodeInt(pGraph,pNode) < pGraph->nLeaves;
504 }
static int Dec_GraphNodeInt(Dec_Graph_t *pGraph, Dec_Node_t *pNode)
Definition: dec.h:469
int nLeaves
Definition: dec.h:72
static Dec_Node_t* Dec_GraphNodeLast ( Dec_Graph_t pGraph)
inlinestatic

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

Synopsis [Returns the pointer to the node.]

Description []

SideEffects []

SeeAlso []

Definition at line 453 of file dec.h.

454 {
455  return pGraph->pNodes + pGraph->nSize - 1;
456 }
int nSize
Definition: dec.h:73
Dec_Node_t * pNodes
Definition: dec.h:75
static int Dec_GraphNodeNum ( Dec_Graph_t pGraph)
inlinestatic

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

Synopsis [Returns the number of internal nodes.]

Description []

SideEffects []

SeeAlso []

Definition at line 421 of file dec.h.

422 {
423  return pGraph->nSize - pGraph->nLeaves;
424 }
int nSize
Definition: dec.h:73
int nLeaves
Definition: dec.h:72
void Dec_GraphPrint ( FILE *  pFile,
Dec_Graph_t pGraph,
char *  pNamesIn[],
char *  pNameOut 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Prints the decomposition graph.]

Description []

SideEffects []

SeeAlso []

Definition at line 49 of file decPrint.c.

50 {
51  Vec_Ptr_t * vNamesIn = NULL;
52  int LitSizeMax, LitSizeCur, Pos, i;
53 
54  // create the names if not given by the user
55  if ( pNamesIn == NULL )
56  {
57  vNamesIn = Abc_NodeGetFakeNames( Dec_GraphLeaveNum(pGraph) );
58  pNamesIn = (char **)vNamesIn->pArray;
59  }
60  if ( pNameOut == NULL )
61  pNameOut = "F";
62 
63  // get the size of the longest literal
64  LitSizeMax = 0;
65  for ( i = 0; i < Dec_GraphLeaveNum(pGraph); i++ )
66  {
67  LitSizeCur = strlen(pNamesIn[i]);
68  if ( LitSizeMax < LitSizeCur )
69  LitSizeMax = LitSizeCur;
70  }
71  if ( LitSizeMax > 50 )
72  LitSizeMax = 20;
73 
74  // write the decomposition graph (factored form)
75  if ( Dec_GraphIsConst(pGraph) ) // constant
76  {
77  Pos = Dec_GraphPrintOutputName( pFile, pNameOut );
78  fprintf( pFile, "Constant %d", !Dec_GraphIsComplement(pGraph) );
79  }
80  else if ( Dec_GraphIsVar(pGraph) ) // literal
81  {
82  Pos = Dec_GraphPrintOutputName( pFile, pNameOut );
83  Dec_GraphPrintGetLeafName( pFile, Dec_GraphVarInt(pGraph), Dec_GraphIsComplement(pGraph), pNamesIn );
84  }
85  else
86  {
87  Pos = Dec_GraphPrintOutputName( pFile, pNameOut );
88  Dec_GraphPrint_rec( pFile, pGraph, Dec_GraphNodeLast(pGraph), Dec_GraphIsComplement(pGraph), pNamesIn, &Pos, LitSizeMax );
89  }
90  fprintf( pFile, "\n" );
91 
92  if ( vNamesIn )
93  Abc_NodeFreeNames( vNamesIn );
94 }
static int Dec_GraphVarInt(Dec_Graph_t *pGraph)
Definition: dec.h:534
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
ush Pos
Definition: deflate.h:88
static int Dec_GraphIsConst(Dec_Graph_t *pGraph)
Definition: dec.h:324
static int Dec_GraphPrintOutputName(FILE *pFile, char *pNameOut)
Definition: decPrint.c:275
ABC_DLL void Abc_NodeFreeNames(Vec_Ptr_t *vNames)
Definition: abcNames.c:257
static int Dec_GraphIsComplement(Dec_Graph_t *pGraph)
Definition: dec.h:372
ABC_DLL Vec_Ptr_t * Abc_NodeGetFakeNames(int nNames)
Definition: abcNames.c:221
static int Dec_GraphPrintGetLeafName(FILE *pFile, int iLeaf, int fCompl, char *pNamesIn[])
Definition: decPrint.c:234
static Dec_Node_t * Dec_GraphNodeLast(Dec_Graph_t *pGraph)
Definition: dec.h:453
static int Dec_GraphLeaveNum(Dec_Graph_t *pGraph)
Definition: dec.h:405
static int Dec_GraphIsVar(Dec_Graph_t *pGraph)
Definition: dec.h:485
int strlen()
static ABC_NAMESPACE_IMPL_START void Dec_GraphPrint_rec(FILE *pFile, Dec_Graph_t *pGraph, Dec_Node_t *pNode, int fCompl, char *pNamesIn[], int *pPos, int LitSizeMax)
DECLARATIONS ///.
Definition: decPrint.c:171
static void Dec_GraphSetRoot ( Dec_Graph_t pGraph,
Dec_Edge_t  eRoot 
)
inlinestatic

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

Synopsis [Sets the root of the graph.]

Description []

SideEffects []

SeeAlso []

Definition at line 551 of file dec.h.

552 {
553  pGraph->eRoot = eRoot;
554 }
Dec_Edge_t eRoot
Definition: dec.h:76
static Dec_Node_t* Dec_GraphVar ( Dec_Graph_t pGraph)
inlinestatic

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

Synopsis [Returns the elementary variable elementary variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 517 of file dec.h.

518 {
519  assert( Dec_GraphIsVar( pGraph ) );
520  return Dec_GraphNode( pGraph, pGraph->eRoot.Node );
521 }
Dec_Edge_t eRoot
Definition: dec.h:76
static int Dec_GraphIsVar(Dec_Graph_t *pGraph)
Definition: dec.h:485
#define assert(ex)
Definition: util_old.h:213
static Dec_Node_t * Dec_GraphNode(Dec_Graph_t *pGraph, int i)
Definition: dec.h:437
static int Dec_GraphVarInt ( Dec_Graph_t pGraph)
inlinestatic

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

Synopsis [Returns the number of the elementary variable.]

Description []

SideEffects []

SeeAlso []

Definition at line 534 of file dec.h.

535 {
536  assert( Dec_GraphIsVar( pGraph ) );
537  return Dec_GraphNodeInt( pGraph, Dec_GraphVar(pGraph) );
538 }
static int Dec_GraphNodeInt(Dec_Graph_t *pGraph, Dec_Node_t *pNode)
Definition: dec.h:469
static Dec_Node_t * Dec_GraphVar(Dec_Graph_t *pGraph)
Definition: dec.h:517
static int Dec_GraphIsVar(Dec_Graph_t *pGraph)
Definition: dec.h:485
#define assert(ex)
Definition: util_old.h:213
static Dec_Edge_t Dec_IntToEdge ( unsigned  Edge)
inlinestatic

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

Synopsis [Converts unsigned integer into the edge.]

Description []

SideEffects []

SeeAlso []

Definition at line 167 of file dec.h.

168 {
169  return Dec_EdgeCreate( Edge >> 1, Edge & 1 );
170 }
static Dec_Edge_t Dec_EdgeCreate(int Node, int fCompl)
FUNCTION DEFINITIONS ///.
Definition: dec.h:134
static Dec_Edge_t Dec_IntToEdge_ ( unsigned  m)
inlinestatic

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

Synopsis [Converts unsigned integer into the edge.]

Description []

SideEffects []

SeeAlso []

Definition at line 202 of file dec.h.

202 { union { Dec_Edge_t x; unsigned y; } v; v.y = m; return v.x; }
typedefABC_NAMESPACE_HEADER_START struct Dec_Edge_t_ Dec_Edge_t
INCLUDES ///.
Definition: dec.h:42
Dec_Man_t* Dec_ManStart ( )

DECLARATIONS ///.

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

FileName [decMan.c]

PackageName [MVSIS 2.0: Multi-valued logic synthesis system.]

Synopsis [Decomposition manager.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - February 1, 2003.]

Revision [

Id:
decMan.c,v 1.1 2003/05/22 19:20:05 alanmi Exp

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

Synopsis [Start the MVC manager used in the factoring package.]

Description []

SideEffects []

SeeAlso []

Definition at line 45 of file decMan.c.

46 {
47  Dec_Man_t * p;
48 // abctime clk = Abc_Clock();
49  p = ABC_ALLOC( Dec_Man_t, 1 );
51  p->vCubes = Vec_IntAlloc( 8 );
52  p->vLits = Vec_IntAlloc( 8 );
53  // canonical forms, phases, perms
54  Extra_Truth4VarNPN( &p->puCanons, &p->pPhases, &p->pPerms, &p->pMap );
55 //ABC_PRT( "NPN classes precomputation time", Abc_Clock() - clk );
56  return p;
57 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void * pMvcMem
Definition: dec.h:82
Vec_Int_t * vCubes
Definition: dec.h:83
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
char * pPhases
Definition: dec.h:87
unsigned char * pMap
Definition: dec.h:89
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
Vec_Int_t * vLits
Definition: dec.h:84
Mvc_Manager_t * Mvc_ManagerStart()
DECLARATIONS ///.
Definition: mvcMan.c:44
unsigned short * puCanons
Definition: dec.h:86
void Extra_Truth4VarNPN(unsigned short **puCanons, char **puPhases, char **puPerms, unsigned char **puMap)
Definition: dec.h:80
char * pPerms
Definition: dec.h:88
void Dec_ManStop ( Dec_Man_t p)

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

Synopsis [Stops the MVC maanager used in the factoring package.]

Description []

SideEffects []

SeeAlso []

Definition at line 70 of file decMan.c.

71 {
73  Vec_IntFree( p->vCubes );
74  Vec_IntFree( p->vLits );
75  ABC_FREE( p->puCanons );
76  ABC_FREE( p->pPhases );
77  ABC_FREE( p->pPerms );
78  ABC_FREE( p->pMap );
79  ABC_FREE( p );
80 }
void * pMvcMem
Definition: dec.h:82
Vec_Int_t * vCubes
Definition: dec.h:83
char * pPhases
Definition: dec.h:87
unsigned char * pMap
Definition: dec.h:89
void Mvc_ManagerFree(Mvc_Manager_t *p)
Definition: mvcMan.c:67
Vec_Int_t * vLits
Definition: dec.h:84
unsigned short * puCanons
Definition: dec.h:86
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
char * pPerms
Definition: dec.h:88