src/opt/dec/decPrint.c File Reference

#include "abc.h"
#include "dec.h"
Include dependency graph for decPrint.c:

Go to the source code of this file.

Functions

static void Dec_GraphPrint_rec (FILE *pFile, Dec_Graph_t *pGraph, Dec_Node_t *pNode, int fCompl, char *pNamesIn[], int *pPos, int LitSizeMax)
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, int fCompl)
void Dec_GraphPrint (FILE *pFile, Dec_Graph_t *pGraph, char *pNamesIn[], char *pNameOut)
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 46 of file decPrint.c.

00047 {
00048     Vec_Ptr_t * vNamesIn = NULL;
00049     int LitSizeMax, LitSizeCur, Pos, i;
00050 
00051     // create the names if not given by the user
00052     if ( pNamesIn == NULL )
00053     {
00054         vNamesIn = Abc_NodeGetFakeNames( Dec_GraphLeaveNum(pGraph) );
00055         pNamesIn = (char **)vNamesIn->pArray;
00056     }
00057     if ( pNameOut == NULL )
00058         pNameOut = "F";
00059 
00060     // get the size of the longest literal
00061     LitSizeMax = 0;
00062     for ( i = 0; i < Dec_GraphLeaveNum(pGraph); i++ )
00063     {
00064         LitSizeCur = strlen(pNamesIn[i]);
00065         if ( LitSizeMax < LitSizeCur )
00066             LitSizeMax = LitSizeCur;
00067     }
00068     if ( LitSizeMax > 50 )
00069         LitSizeMax = 20;
00070 
00071     // write the decomposition graph (factored form)
00072     if ( Dec_GraphIsConst(pGraph) ) // constant
00073     {
00074         Pos = Dec_GraphPrintOutputName( pFile, pNameOut, 0 );
00075         fprintf( pFile, "Constant %d", !Dec_GraphIsComplement(pGraph) );
00076     }
00077     else if ( Dec_GraphIsVar(pGraph) ) // literal
00078     {
00079         Pos = Dec_GraphPrintOutputName( pFile, pNameOut, 0 );
00080         Dec_GraphPrintGetLeafName( pFile, Dec_GraphVarInt(pGraph), Dec_GraphIsComplement(pGraph), pNamesIn );
00081     }
00082     else
00083     {
00084         Pos = Dec_GraphPrintOutputName( pFile, pNameOut, Dec_GraphIsComplement(pGraph) );
00085         Dec_GraphPrint_rec( pFile, pGraph, Dec_GraphNodeLast(pGraph), 0, pNamesIn, &Pos, LitSizeMax );
00086     }
00087     fprintf( pFile, "\n" );
00088 
00089     if ( vNamesIn )
00090         Abc_NodeFreeNames( vNamesIn );
00091 }

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 104 of file decPrint.c.

00105 {
00106     Dec_Node_t * pNode0, * pNode1;
00107     pNode0 = Dec_GraphNode(pGraph, pNode->eEdge0.Node);
00108     pNode1 = Dec_GraphNode(pGraph, pNode->eEdge1.Node);
00109     if ( Dec_GraphNodeIsVar(pGraph, pNode) ) // FT_NODE_LEAF )
00110     {
00111         (*pPos) += Dec_GraphPrintGetLeafName( pFile, Dec_GraphNodeInt(pGraph,pNode), fCompl, pNamesIn );
00112         return;
00113     }
00114     if ( !pNode->fNodeOr ) // FT_NODE_AND )
00115     {
00116         if ( !pNode0->fNodeOr ) // != FT_NODE_OR )
00117             Dec_GraphPrint_rec( pFile, pGraph, pNode0, pNode->fCompl0, pNamesIn, pPos, LitSizeMax );
00118         else
00119         {
00120             fprintf( pFile, "(" );
00121             (*pPos)++;
00122             Dec_GraphPrint_rec( pFile, pGraph, pNode0, pNode->fCompl0, pNamesIn, pPos, LitSizeMax );
00123             fprintf( pFile, ")" );
00124             (*pPos)++;
00125         }
00126         fprintf( pFile, " " );
00127         (*pPos)++;
00128 
00129         Dec_GraphPrintUpdatePos( pFile, pPos, LitSizeMax );
00130 
00131         if ( !pNode1->fNodeOr ) // != FT_NODE_OR )
00132             Dec_GraphPrint_rec( pFile, pGraph, pNode1, pNode->fCompl1, pNamesIn, pPos, LitSizeMax );
00133         else
00134         {
00135             fprintf( pFile, "(" );
00136             (*pPos)++;
00137             Dec_GraphPrint_rec( pFile, pGraph, pNode1, pNode->fCompl1, pNamesIn, pPos, LitSizeMax );
00138             fprintf( pFile, ")" );
00139             (*pPos)++;
00140         }
00141         return;
00142     }
00143     if ( pNode->fNodeOr ) // FT_NODE_OR )
00144     {
00145         Dec_GraphPrint_rec( pFile, pGraph, pNode0, pNode->fCompl0, pNamesIn, pPos, LitSizeMax );
00146         fprintf( pFile, " + " );
00147         (*pPos) += 3;
00148 
00149         Dec_GraphPrintUpdatePos( pFile, pPos, LitSizeMax );
00150 
00151         Dec_GraphPrint_rec( pFile, pGraph, pNode1, pNode->fCompl1, pNamesIn, pPos, LitSizeMax );
00152         return;
00153     }
00154     assert( 0 );
00155 }

void Dec_GraphPrint_rec ( FILE *  pFile,
Dec_Graph_t pGraph,
Dec_Node_t pNode,
int  fCompl,
char *  pNamesIn[],
int *  pPos,
int  LitSizeMax 
) [static]

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

] DECLARATIONS ///

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 168 of file decPrint.c.

00169 {
00170     Dec_Node_t * pNode0, * pNode1;
00171     Dec_Node_t * pNode00, * pNode01, * pNode10, * pNode11;
00172     pNode0 = Dec_GraphNode(pGraph, pNode->eEdge0.Node);
00173     pNode1 = Dec_GraphNode(pGraph, pNode->eEdge1.Node);
00174     if ( Dec_GraphNodeIsVar(pGraph, pNode) ) // FT_NODE_LEAF )
00175     {
00176         (*pPos) += Dec_GraphPrintGetLeafName( pFile, Dec_GraphNodeInt(pGraph,pNode), fCompl, pNamesIn );
00177         return;
00178     }
00179     if ( !Dec_GraphNodeIsVar(pGraph, pNode0) && !Dec_GraphNodeIsVar(pGraph, pNode1) )
00180     {
00181         pNode00 = Dec_GraphNode(pGraph, pNode0->eEdge0.Node);
00182         pNode01 = Dec_GraphNode(pGraph, pNode0->eEdge1.Node);
00183         pNode10 = Dec_GraphNode(pGraph, pNode1->eEdge0.Node);
00184         pNode11 = Dec_GraphNode(pGraph, pNode1->eEdge1.Node);
00185         if ( (pNode00 == pNode10 || pNode00 == pNode11) && (pNode01 == pNode10 || pNode01 == pNode11) )
00186         {
00187             fprintf( pFile, "(" );
00188             (*pPos)++;
00189             Dec_GraphPrint_rec( pFile, pGraph, pNode00, pNode00->fCompl0, pNamesIn, pPos, LitSizeMax );
00190             fprintf( pFile, " # " );
00191             (*pPos) += 3;
00192             Dec_GraphPrint_rec( pFile, pGraph, pNode01, pNode01->fCompl1, pNamesIn, pPos, LitSizeMax );
00193             fprintf( pFile, ")" );
00194             (*pPos)++;
00195             return;
00196         }
00197     }
00198     if ( fCompl )
00199     {
00200         fprintf( pFile, "(" );
00201         (*pPos)++;
00202         Dec_GraphPrint_rec( pFile, pGraph, pNode0, !pNode->fCompl0, pNamesIn, pPos, LitSizeMax );
00203         fprintf( pFile, " + " );
00204         (*pPos) += 3;
00205         Dec_GraphPrint_rec( pFile, pGraph, pNode1, !pNode->fCompl1, pNamesIn, pPos, LitSizeMax );
00206         fprintf( pFile, ")" );
00207         (*pPos)++;
00208     }
00209     else
00210     {
00211         fprintf( pFile, "(" );
00212         (*pPos)++;
00213         Dec_GraphPrint_rec( pFile, pGraph, pNode0, pNode->fCompl0, pNamesIn, pPos, LitSizeMax );
00214         Dec_GraphPrint_rec( pFile, pGraph, pNode1, pNode->fCompl1, pNamesIn, pPos, LitSizeMax );
00215         fprintf( pFile, ")" );
00216         (*pPos)++;
00217     }
00218 }

int Dec_GraphPrintGetLeafName ( FILE *  pFile,
int  iLeaf,
int  fCompl,
char *  pNamesIn[] 
) [static]

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 231 of file decPrint.c.

00232 {
00233     static char Buffer[100];
00234     sprintf( Buffer, "%s%s", pNamesIn[iLeaf], fCompl? "\'" : "" );
00235     fprintf( pFile, "%s", Buffer );
00236     return strlen( Buffer );
00237 }

int Dec_GraphPrintOutputName ( FILE *  pFile,
char *  pNameOut,
int  fCompl 
) [static]

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

Synopsis [Starts the printout for a decomposition graph.]

Description []

SideEffects []

SeeAlso []

Definition at line 272 of file decPrint.c.

00273 {
00274     if ( pNameOut == NULL )
00275         return 0;
00276     fprintf( pFile, "%6s%s = ", pNameOut, fCompl? "\'" : " " );
00277     return 10;
00278 }

void Dec_GraphPrintUpdatePos ( FILE *  pFile,
int *  pPos,
int  LitSizeMax 
) [static]

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 250 of file decPrint.c.

00251 {
00252     int i;
00253     if ( *pPos + LitSizeMax < 77 )
00254         return;
00255     fprintf( pFile, "\n" );
00256     for ( i = 0; i < 10; i++ )
00257         fprintf( pFile, " " );
00258     *pPos = 10;
00259 }


Generated on Tue Jan 5 12:19:25 2010 for abc70930 by  doxygen 1.6.1