ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
decPrint.c File Reference
#include "base/abc/abc.h"
#include "dec.h"
Include dependency graph for decPrint.c:

Go to the source code of this file.

Functions

void Dec_GraphPrint (FILE *pFile, Dec_Graph_t *pGraph, char *pNamesIn[], char *pNameOut)
 FUNCTION DEFINITIONS ///.
 
void Dec_GraphPrint2_rec (FILE *pFile, Dec_Graph_t *pGraph, Dec_Node_t *pNode, int fCompl, char *pNamesIn[], int *pPos, int LitSizeMax)
 

Function Documentation

◆ Dec_GraphPrint()

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}
ABC_DLL void Abc_NodeFreeNames(Vec_Ptr_t *vNames)
Definition abcNames.c:264
ABC_DLL Vec_Ptr_t * Abc_NodeGetFakeNames(int nNames)
Definition abcNames.c:228
ush Pos
Definition deflate.h:88
int strlen()
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition vecPtr.h:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dec_GraphPrint2_rec()

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}
struct Dec_Node_t_ Dec_Node_t
Definition dec.h:49
unsigned fCompl1
Definition dec.h:61
Dec_Edge_t eEdge1
Definition dec.h:53
unsigned fNodeOr
Definition dec.h:59
Dec_Edge_t eEdge0
Definition dec.h:52
unsigned fCompl0
Definition dec.h:60
#define assert(ex)
Definition util_old.h:213