abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
decPrint.c File Reference
#include "base/abc/abc.h"
#include "dec.h"

Go to the source code of this file.

Functions

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 ///. More...
 
static int Dec_GraphPrintGetLeafName (FILE *pFile, int iLeaf, int fCompl, char *pNamesIn[])
 
static void Dec_GraphPrintUpdatePos (FILE *pFile, int *pPos, int LitSizeMax)
 
static int Dec_GraphPrintOutputName (FILE *pFile, char *pNameOut)
 
void Dec_GraphPrint (FILE *pFile, Dec_Graph_t *pGraph, char *pNamesIn[], char *pNameOut)
 FUNCTION DEFINITIONS ///. More...
 
void Dec_GraphPrint2_rec (FILE *pFile, Dec_Graph_t *pGraph, Dec_Node_t *pNode, int fCompl, char *pNamesIn[], int *pPos, int LitSizeMax)
 

Function Documentation

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
void Dec_GraphPrint2_rec ( FILE *  pFile,
Dec_Graph_t pGraph,
Dec_Node_t pNode,
int  fCompl,
char *  pNamesIn[],
int *  pPos,
int  LitSizeMax 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 107 of file decPrint.c.

108 {
109  Dec_Node_t * pNode0, * pNode1;
110  pNode0 = Dec_GraphNode(pGraph, pNode->eEdge0.Node);
111  pNode1 = Dec_GraphNode(pGraph, pNode->eEdge1.Node);
112  if ( Dec_GraphNodeIsVar(pGraph, pNode) ) // FT_NODE_LEAF )
113  {
114  (*pPos) += Dec_GraphPrintGetLeafName( pFile, Dec_GraphNodeInt(pGraph,pNode), fCompl, pNamesIn );
115  return;
116  }
117  if ( !pNode->fNodeOr ) // FT_NODE_AND )
118  {
119  if ( !pNode0->fNodeOr ) // != FT_NODE_OR )
120  Dec_GraphPrint_rec( pFile, pGraph, pNode0, pNode->fCompl0, pNamesIn, pPos, LitSizeMax );
121  else
122  {
123  fprintf( pFile, "(" );
124  (*pPos)++;
125  Dec_GraphPrint_rec( pFile, pGraph, pNode0, pNode->fCompl0, pNamesIn, pPos, LitSizeMax );
126  fprintf( pFile, ")" );
127  (*pPos)++;
128  }
129  fprintf( pFile, " " );
130  (*pPos)++;
131 
132  Dec_GraphPrintUpdatePos( pFile, pPos, LitSizeMax );
133 
134  if ( !pNode1->fNodeOr ) // != FT_NODE_OR )
135  Dec_GraphPrint_rec( pFile, pGraph, pNode1, pNode->fCompl1, pNamesIn, pPos, LitSizeMax );
136  else
137  {
138  fprintf( pFile, "(" );
139  (*pPos)++;
140  Dec_GraphPrint_rec( pFile, pGraph, pNode1, pNode->fCompl1, pNamesIn, pPos, LitSizeMax );
141  fprintf( pFile, ")" );
142  (*pPos)++;
143  }
144  return;
145  }
146  if ( pNode->fNodeOr ) // FT_NODE_OR )
147  {
148  Dec_GraphPrint_rec( pFile, pGraph, pNode0, pNode->fCompl0, pNamesIn, pPos, LitSizeMax );
149  fprintf( pFile, " + " );
150  (*pPos) += 3;
151 
152  Dec_GraphPrintUpdatePos( pFile, pPos, LitSizeMax );
153 
154  Dec_GraphPrint_rec( pFile, pGraph, pNode1, pNode->fCompl1, pNamesIn, pPos, LitSizeMax );
155  return;
156  }
157  assert( 0 );
158 }
static int Dec_GraphNodeInt(Dec_Graph_t *pGraph, Dec_Node_t *pNode)
Definition: dec.h:469
static void Dec_GraphPrintUpdatePos(FILE *pFile, int *pPos, int LitSizeMax)
Definition: decPrint.c:253
unsigned fCompl1
Definition: dec.h:61
Dec_Edge_t eEdge0
Definition: dec.h:52
static int Dec_GraphPrintGetLeafName(FILE *pFile, int iLeaf, int fCompl, char *pNamesIn[])
Definition: decPrint.c:234
unsigned fCompl0
Definition: dec.h:60
#define assert(ex)
Definition: util_old.h:213
static int Dec_GraphNodeIsVar(Dec_Graph_t *pGraph, Dec_Node_t *pNode)
Definition: dec.h:501
static Dec_Node_t * Dec_GraphNode(Dec_Graph_t *pGraph, int i)
Definition: dec.h:437
unsigned fNodeOr
Definition: dec.h:59
Dec_Edge_t eEdge1
Definition: dec.h:53
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
void Dec_GraphPrint_rec ( FILE *  pFile,
Dec_Graph_t pGraph,
Dec_Node_t pNode,
int  fCompl,
char *  pNamesIn[],
int *  pPos,
int  LitSizeMax 
)
static

DECLARATIONS ///.

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

FileName [decPrint.c]

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

Synopsis [Procedures to print the decomposition graphs (factored forms).]

Author [MVSIS Group]

Affiliation [UC Berkeley]

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

Revision [

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

]

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 171 of file decPrint.c.

172 {
173  Dec_Node_t * pNode0, * pNode1;
174  Dec_Node_t * pNode00, * pNode01, * pNode10, * pNode11;
175  pNode0 = Dec_GraphNode(pGraph, pNode->eEdge0.Node);
176  pNode1 = Dec_GraphNode(pGraph, pNode->eEdge1.Node);
177  if ( Dec_GraphNodeIsVar(pGraph, pNode) ) // FT_NODE_LEAF )
178  {
179  (*pPos) += Dec_GraphPrintGetLeafName( pFile, Dec_GraphNodeInt(pGraph,pNode), fCompl, pNamesIn );
180  return;
181  }
182  if ( !Dec_GraphNodeIsVar(pGraph, pNode0) && !Dec_GraphNodeIsVar(pGraph, pNode1) )
183  {
184  pNode00 = Dec_GraphNode(pGraph, pNode0->eEdge0.Node);
185  pNode01 = Dec_GraphNode(pGraph, pNode0->eEdge1.Node);
186  pNode10 = Dec_GraphNode(pGraph, pNode1->eEdge0.Node);
187  pNode11 = Dec_GraphNode(pGraph, pNode1->eEdge1.Node);
188  if ( (pNode00 == pNode10 || pNode00 == pNode11) && (pNode01 == pNode10 || pNode01 == pNode11) )
189  {
190  fprintf( pFile, "(" );
191  (*pPos)++;
192  Dec_GraphPrint_rec( pFile, pGraph, pNode00, pNode00->fCompl0, pNamesIn, pPos, LitSizeMax );
193  fprintf( pFile, " # " );
194  (*pPos) += 3;
195  Dec_GraphPrint_rec( pFile, pGraph, pNode01, pNode01->fCompl1, pNamesIn, pPos, LitSizeMax );
196  fprintf( pFile, ")" );
197  (*pPos)++;
198  return;
199  }
200  }
201  if ( fCompl )
202  {
203  fprintf( pFile, "(" );
204  (*pPos)++;
205  Dec_GraphPrint_rec( pFile, pGraph, pNode0, !pNode->eEdge0.fCompl, pNamesIn, pPos, LitSizeMax );
206  fprintf( pFile, " + " );
207  (*pPos) += 3;
208  Dec_GraphPrint_rec( pFile, pGraph, pNode1, !pNode->eEdge1.fCompl, pNamesIn, pPos, LitSizeMax );
209  fprintf( pFile, ")" );
210  (*pPos)++;
211  }
212  else
213  {
214  fprintf( pFile, "(" );
215  (*pPos)++;
216  Dec_GraphPrint_rec( pFile, pGraph, pNode0, pNode->eEdge0.fCompl, pNamesIn, pPos, LitSizeMax );
217  Dec_GraphPrint_rec( pFile, pGraph, pNode1, pNode->eEdge1.fCompl, pNamesIn, pPos, LitSizeMax );
218  fprintf( pFile, ")" );
219  (*pPos)++;
220  }
221 }
static int Dec_GraphNodeInt(Dec_Graph_t *pGraph, Dec_Node_t *pNode)
Definition: dec.h:469
unsigned fCompl1
Definition: dec.h:61
Dec_Edge_t eEdge0
Definition: dec.h:52
static int Dec_GraphPrintGetLeafName(FILE *pFile, int iLeaf, int fCompl, char *pNamesIn[])
Definition: decPrint.c:234
unsigned fCompl0
Definition: dec.h:60
static int Dec_GraphNodeIsVar(Dec_Graph_t *pGraph, Dec_Node_t *pNode)
Definition: dec.h:501
static Dec_Node_t * Dec_GraphNode(Dec_Graph_t *pGraph, int i)
Definition: dec.h:437
Dec_Edge_t eEdge1
Definition: dec.h:53
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
int Dec_GraphPrintGetLeafName ( FILE *  pFile,
int  iLeaf,
int  fCompl,
char *  pNamesIn[] 
)
static

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 234 of file decPrint.c.

235 {
236  static char Buffer[100];
237  sprintf( Buffer, "%s%s", fCompl? "!" : "", pNamesIn[iLeaf] );
238  fprintf( pFile, "%s", Buffer );
239  return strlen( Buffer );
240 }
char * sprintf()
int strlen()
int Dec_GraphPrintOutputName ( FILE *  pFile,
char *  pNameOut 
)
static

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

Synopsis [Starts the printout for a decomposition graph.]

Description []

SideEffects []

SeeAlso []

Definition at line 275 of file decPrint.c.

276 {
277  if ( pNameOut == NULL )
278  return 0;
279  fprintf( pFile, "%6s = ", pNameOut );
280  return 10;
281 }
void Dec_GraphPrintUpdatePos ( FILE *  pFile,
int *  pPos,
int  LitSizeMax 
)
static

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 253 of file decPrint.c.

254 {
255  int i;
256  if ( *pPos + LitSizeMax < 77 )
257  return;
258  fprintf( pFile, "\n" );
259  for ( i = 0; i < 10; i++ )
260  fprintf( pFile, " " );
261  *pPos = 10;
262 }