abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
dsdTree.c File Reference
#include "dsdInt.h"
#include "misc/util/utilTruth.h"
#include "opt/dau/dau.h"

Go to the source code of this file.

Functions

static
ABC_NAMESPACE_IMPL_START void 
Dsd_TreeUnmark_rec (Dsd_Node_t *pNode)
 FUNCTION DECLARATIONS ///. More...
 
static void Dsd_TreeGetInfo_rec (Dsd_Node_t *pNode, int RankCur)
 
static int Dsd_TreeCountNonTerminalNodes_rec (Dsd_Node_t *pNode)
 
static int Dsd_TreeCountPrimeNodes_rec (Dsd_Node_t *pNode)
 
static int Dsd_TreeCollectDecomposableVars_rec (DdManager *dd, Dsd_Node_t *pNode, int *pVars, int *nVars)
 
static void Dsd_TreeCollectNodesDfs_rec (Dsd_Node_t *pNode, Dsd_Node_t *ppNodes[], int *pnNodes)
 
static void Dsd_TreePrint_rec (FILE *pFile, Dsd_Node_t *pNode, int fCcmp, char *pInputNames[], char *pOutputName, int nOffset, int *pSigCounter, int fShortNames)
 
static void Dsd_NodePrint_rec (FILE *pFile, Dsd_Node_t *pNode, int fComp, char *pOutputName, int nOffset, int *pSigCounter)
 
Dsd_Node_tDsd_TreeNodeCreate (int Type, int nDecs, int BlockNum)
 FUNCTION DEFINITIONS ///. More...
 
void Dsd_TreeNodeDelete (DdManager *dd, Dsd_Node_t *pNode)
 
void Dsd_TreeUnmark (Dsd_Manager_t *pDsdMan)
 
void Dsd_TreeNodeGetInfo (Dsd_Manager_t *pDsdMan, int *DepthMax, int *GateSizeMax)
 
void Dsd_TreeNodeGetInfoOne (Dsd_Node_t *pNode, int *DepthMax, int *GateSizeMax)
 
int Dsd_TreeGetAigCost_rec (Dsd_Node_t *pNode)
 
int Dsd_TreeGetAigCost (Dsd_Node_t *pNode)
 
int Dsd_TreeCountNonTerminalNodes (Dsd_Manager_t *pDsdMan)
 
int Dsd_TreeCountNonTerminalNodesOne (Dsd_Node_t *pRoot)
 
int Dsd_TreeCountPrimeNodes (Dsd_Manager_t *pDsdMan)
 
int Dsd_TreeCountPrimeNodesOne (Dsd_Node_t *pRoot)
 
int Dsd_TreeCollectDecomposableVars (Dsd_Manager_t *pDsdMan, int *pVars)
 
Dsd_Node_t ** Dsd_TreeCollectNodesDfs (Dsd_Manager_t *pDsdMan, int *pnNodes)
 
Dsd_Node_t ** Dsd_TreeCollectNodesDfsOne (Dsd_Manager_t *pDsdMan, Dsd_Node_t *pNode, int *pnNodes)
 
void Dsd_TreePrint (FILE *pFile, Dsd_Manager_t *pDsdMan, char *pInputNames[], char *pOutputNames[], int fShortNames, int Output)
 
word Dsd_TreeFunc2Truth_rec (DdManager *dd, DdNode *bFunc)
 
void Dsd_TreePrint2_rec (FILE *pFile, DdManager *dd, Dsd_Node_t *pNode, int fComp, char *pInputNames[])
 
void Dsd_TreePrint2 (FILE *pFile, Dsd_Manager_t *pDsdMan, char *pInputNames[], char *pOutputNames[], int Output)
 
void Dsd_NodePrint (FILE *pFile, Dsd_Node_t *pNode)
 
DdNodeDsd_TreeGetPrimeFunctionOld (DdManager *dd, Dsd_Node_t *pNode, int fRemap)
 

Variables

static int s_DepthMax
 STATIC VARIABLES ///. More...
 
static int s_GateSizeMax
 

Function Documentation

void Dsd_NodePrint ( FILE *  pFile,
Dsd_Node_t pNode 
)

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

Synopsis [Prints the decompostion tree into file.]

Description []

SideEffects []

SeeAlso []

Definition at line 949 of file dsdTree.c.

950 {
951  Dsd_Node_t * pNodeR;
952  int SigCounter = 1;
953  pNodeR = Dsd_Regular(pNode);
954  Dsd_NodePrint_rec( pFile, pNodeR, pNodeR != pNode, "F", 0, &SigCounter );
955 }
static void Dsd_NodePrint_rec(FILE *pFile, Dsd_Node_t *pNode, int fComp, char *pOutputName, int nOffset, int *pSigCounter)
Definition: dsdTree.c:968
#define Dsd_Regular(p)
Definition: dsd.h:69
void Dsd_NodePrint_rec ( FILE *  pFile,
Dsd_Node_t pNode,
int  fComp,
char *  pOutputName,
int  nOffset,
int *  pSigCounter 
)
static

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

Synopsis [Prints one node of the decomposition tree.]

Description []

SideEffects []

SeeAlso []

Definition at line 968 of file dsdTree.c.

969 {
970  char Buffer[100];
971  Dsd_Node_t * pInput;
972  int * pInputNums;
973  int fCompNew, i;
974 
975  assert( pNode->Type == DSD_NODE_BUF || pNode->Type == DSD_NODE_CONST1 ||
976  pNode->Type == DSD_NODE_PRIME || pNode->Type == DSD_NODE_OR || pNode->Type == DSD_NODE_EXOR );
977 
978  Extra_PrintSymbols( pFile, ' ', nOffset, 0 );
979  if ( !fComp )
980  fprintf( pFile, "%s = ", pOutputName );
981  else
982  fprintf( pFile, "NOT(%s) = ", pOutputName );
983  pInputNums = ABC_ALLOC( int, pNode->nDecs );
984  if ( pNode->Type == DSD_NODE_CONST1 )
985  {
986  fprintf( pFile, " Constant 1.\n" );
987  }
988  else if ( pNode->Type == DSD_NODE_BUF )
989  {
990  fprintf( pFile, " " );
991  fprintf( pFile, "%c", 'a' + pNode->S->index );
992  fprintf( pFile, "\n" );
993  }
994  else if ( pNode->Type == DSD_NODE_PRIME )
995  {
996  // print the line
997  fprintf( pFile, "PRIME(" );
998  for ( i = 0; i < pNode->nDecs; i++ )
999  {
1000  pInput = Dsd_Regular( pNode->pDecs[i] );
1001  fCompNew = (int)( pInput != pNode->pDecs[i] );
1002  assert( fCompNew == 0 );
1003  if ( i )
1004  fprintf( pFile, "," );
1005  if ( pInput->Type == DSD_NODE_BUF )
1006  {
1007  pInputNums[i] = 0;
1008  fprintf( pFile, " %c", 'a' + pInput->S->index );
1009  }
1010  else
1011  {
1012  pInputNums[i] = (*pSigCounter)++;
1013  fprintf( pFile, " <%d>", pInputNums[i] );
1014  }
1015  if ( fCompNew )
1016  fprintf( pFile, "\'" );
1017  }
1018  fprintf( pFile, " )\n" );
1019 /*
1020  fprintf( pFile, " ) " );
1021  {
1022  DdNode * bLocal;
1023  bLocal = Dsd_TreeGetPrimeFunction( dd, pNodeDsd ); Cudd_Ref( bLocal );
1024  Extra_bddPrint( dd, bLocal );
1025  Cudd_RecursiveDeref( dd, bLocal );
1026  }
1027 */
1028  // call recursively for the following blocks
1029  for ( i = 0; i < pNode->nDecs; i++ )
1030  if ( pInputNums[i] )
1031  {
1032  pInput = Dsd_Regular( pNode->pDecs[i] );
1033  sprintf( Buffer, "<%d>", pInputNums[i] );
1034  Dsd_NodePrint_rec( pFile, Dsd_Regular( pNode->pDecs[i] ), 0, Buffer, nOffset + 6, pSigCounter );
1035  }
1036  }
1037  else if ( pNode->Type == DSD_NODE_OR )
1038  {
1039  // print the line
1040  fprintf( pFile, "OR(" );
1041  for ( i = 0; i < pNode->nDecs; i++ )
1042  {
1043  pInput = Dsd_Regular( pNode->pDecs[i] );
1044  fCompNew = (int)( pInput != pNode->pDecs[i] );
1045  if ( i )
1046  fprintf( pFile, "," );
1047  if ( pInput->Type == DSD_NODE_BUF )
1048  {
1049  pInputNums[i] = 0;
1050  fprintf( pFile, " %c", 'a' + pInput->S->index );
1051  }
1052  else
1053  {
1054  pInputNums[i] = (*pSigCounter)++;
1055  fprintf( pFile, " <%d>", pInputNums[i] );
1056  }
1057  if ( fCompNew )
1058  fprintf( pFile, "\'" );
1059  }
1060  fprintf( pFile, " )\n" );
1061  // call recursively for the following blocks
1062  for ( i = 0; i < pNode->nDecs; i++ )
1063  if ( pInputNums[i] )
1064  {
1065  pInput = Dsd_Regular( pNode->pDecs[i] );
1066  sprintf( Buffer, "<%d>", pInputNums[i] );
1067  Dsd_NodePrint_rec( pFile, Dsd_Regular( pNode->pDecs[i] ), 0, Buffer, nOffset + 6, pSigCounter );
1068  }
1069  }
1070  else if ( pNode->Type == DSD_NODE_EXOR )
1071  {
1072  // print the line
1073  fprintf( pFile, "EXOR(" );
1074  for ( i = 0; i < pNode->nDecs; i++ )
1075  {
1076  pInput = Dsd_Regular( pNode->pDecs[i] );
1077  fCompNew = (int)( pInput != pNode->pDecs[i] );
1078  assert( fCompNew == 0 );
1079  if ( i )
1080  fprintf( pFile, "," );
1081  if ( pInput->Type == DSD_NODE_BUF )
1082  {
1083  pInputNums[i] = 0;
1084  fprintf( pFile, " %c", 'a' + pInput->S->index );
1085  }
1086  else
1087  {
1088  pInputNums[i] = (*pSigCounter)++;
1089  fprintf( pFile, " <%d>", pInputNums[i] );
1090  }
1091  if ( fCompNew )
1092  fprintf( pFile, "\'" );
1093  }
1094  fprintf( pFile, " )\n" );
1095  // call recursively for the following blocks
1096  for ( i = 0; i < pNode->nDecs; i++ )
1097  if ( pInputNums[i] )
1098  {
1099  pInput = Dsd_Regular( pNode->pDecs[i] );
1100  sprintf( Buffer, "<%d>", pInputNums[i] );
1101  Dsd_NodePrint_rec( pFile, Dsd_Regular( pNode->pDecs[i] ), 0, Buffer, nOffset + 6, pSigCounter );
1102  }
1103  }
1104  ABC_FREE( pInputNums );
1105 }
DdNode * S
Definition: dsdInt.h:58
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Dsd_Node_t ** pDecs
Definition: dsdInt.h:59
void Extra_PrintSymbols(FILE *pFile, char Char, int nTimes, int fPrintNewLine)
static void Dsd_NodePrint_rec(FILE *pFile, Dsd_Node_t *pNode, int fComp, char *pOutputName, int nOffset, int *pSigCounter)
Definition: dsdTree.c:968
char * sprintf()
#define Dsd_Regular(p)
Definition: dsd.h:69
Dsd_Type_t Type
Definition: dsdInt.h:56
DdHalfWord index
Definition: cudd.h:279
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define assert(ex)
Definition: util_old.h:213
short nDecs
Definition: dsdInt.h:61
int Dsd_TreeCollectDecomposableVars ( Dsd_Manager_t pDsdMan,
int *  pVars 
)

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

Synopsis [Collects the decomposable vars on the PI side.]

Description []

SideEffects []

SeeAlso []

Definition at line 470 of file dsdTree.c.

471 {
472  int nVars;
473 
474  // set the vars collected to 0
475  nVars = 0;
476  Dsd_TreeCollectDecomposableVars_rec( pDsdMan->dd, Dsd_Regular(pDsdMan->pRoots[0]), pVars, &nVars );
477  // return the number of collected vars
478  return nVars;
479 }
DdManager * dd
Definition: dsdInt.h:42
static int Dsd_TreeCollectDecomposableVars_rec(DdManager *dd, Dsd_Node_t *pNode, int *pVars, int *nVars)
Definition: dsdTree.c:494
#define Dsd_Regular(p)
Definition: dsd.h:69
Dsd_Node_t ** pRoots
Definition: dsdInt.h:48
int Dsd_TreeCollectDecomposableVars_rec ( DdManager dd,
Dsd_Node_t pNode,
int *  pVars,
int *  nVars 
)
static

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

Synopsis [Implements the recursive part of Dsd_TreeCollectDecomposableVars().]

Description [Adds decomposable variables as they are found to pVars and increments nVars. Returns 1 if a non-dec node with more than 4 inputs was encountered in the processed subtree. Returns 0, otherwise. ]

SideEffects []

SeeAlso []

Definition at line 494 of file dsdTree.c.

495 {
496  int fSkipThisNode, i;
497  Dsd_Node_t * pTemp;
498  int fVerbose = 0;
499 
500  assert( pNode );
501  assert( !Dsd_IsComplement( pNode ) );
502 
503  if ( pNode->nDecs <= 1 )
504  return 0;
505 
506  // go through the list of successors and call recursively
507  fSkipThisNode = 0;
508  for ( i = 0; i < pNode->nDecs; i++ )
509  if ( Dsd_TreeCollectDecomposableVars_rec(dd, Dsd_Regular(pNode->pDecs[i]), pVars, nVars) )
510  fSkipThisNode = 1;
511 
512  if ( !fSkipThisNode && (pNode->Type == DSD_NODE_OR || pNode->Type == DSD_NODE_EXOR || pNode->nDecs <= 4) )
513  {
514 if ( fVerbose )
515 printf( "Node of type <%d> (OR=6,EXOR=8,RAND=1): ", pNode->Type );
516 
517  for ( i = 0; i < pNode->nDecs; i++ )
518  {
519  pTemp = Dsd_Regular(pNode->pDecs[i]);
520  if ( pTemp->Type == DSD_NODE_BUF )
521  {
522  if ( pVars )
523  pVars[ (*nVars)++ ] = pTemp->S->index;
524  else
525  (*nVars)++;
526 
527 if ( fVerbose )
528 printf( "%d ", pTemp->S->index );
529  }
530  }
531 if ( fVerbose )
532 printf( "\n" );
533  }
534  else
535  fSkipThisNode = 1;
536 
537 
538  return fSkipThisNode;
539 }
DdNode * S
Definition: dsdInt.h:58
Dsd_Node_t ** pDecs
Definition: dsdInt.h:59
static int Dsd_TreeCollectDecomposableVars_rec(DdManager *dd, Dsd_Node_t *pNode, int *pVars, int *nVars)
Definition: dsdTree.c:494
#define Dsd_Regular(p)
Definition: dsd.h:69
Dsd_Type_t Type
Definition: dsdInt.h:56
#define Dsd_IsComplement(p)
MACRO DEFINITIONS ///.
Definition: dsd.h:68
DdHalfWord index
Definition: cudd.h:279
#define assert(ex)
Definition: util_old.h:213
short nDecs
Definition: dsdInt.h:61
Dsd_Node_t** Dsd_TreeCollectNodesDfs ( Dsd_Manager_t pDsdMan,
int *  pnNodes 
)

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

Synopsis [Creates the DFS ordered array of DSD nodes in the tree.]

Description [The collected nodes do not include the terminal nodes and the constant 1 node. The array of nodes is returned. The number of entries in the array is returned in the variale pnNodes.]

SideEffects []

SeeAlso []

Definition at line 555 of file dsdTree.c.

556 {
557  Dsd_Node_t ** ppNodes;
558  int nNodes, nNodesAlloc;
559  int i;
560 
561  nNodesAlloc = Dsd_TreeCountNonTerminalNodes(pDsdMan);
562  nNodes = 0;
563  ppNodes = ABC_ALLOC( Dsd_Node_t *, nNodesAlloc );
564  for ( i = 0; i < pDsdMan->nRoots; i++ )
565  Dsd_TreeCollectNodesDfs_rec( Dsd_Regular(pDsdMan->pRoots[i]), ppNodes, &nNodes );
566  Dsd_TreeUnmark( pDsdMan );
567  assert( nNodesAlloc == nNodes );
568  *pnNodes = nNodes;
569  return ppNodes;
570 }
void Dsd_TreeUnmark(Dsd_Manager_t *pDsdMan)
Definition: dsdTree.c:107
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void Dsd_TreeCollectNodesDfs_rec(Dsd_Node_t *pNode, Dsd_Node_t *ppNodes[], int *pnNodes)
Definition: dsdTree.c:611
int Dsd_TreeCountNonTerminalNodes(Dsd_Manager_t *pDsdMan)
Definition: dsdTree.c:310
#define Dsd_Regular(p)
Definition: dsd.h:69
#define assert(ex)
Definition: util_old.h:213
int nRoots
Definition: dsdInt.h:45
Dsd_Node_t ** pRoots
Definition: dsdInt.h:48
void Dsd_TreeCollectNodesDfs_rec ( Dsd_Node_t pNode,
Dsd_Node_t ppNodes[],
int *  pnNodes 
)
static

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 611 of file dsdTree.c.

612 {
613  int i;
614  assert( pNode );
615  assert( !Dsd_IsComplement(pNode) );
616  assert( pNode->nVisits >= 0 );
617 
618  if ( pNode->nVisits++ ) // if this is not the first visit, return zero
619  return;
620  if ( pNode->nDecs <= 1 )
621  return;
622 
623  // upon the first visit, go through the list of successors and call recursively
624  for ( i = 0; i < pNode->nDecs; i++ )
625  Dsd_TreeCollectNodesDfs_rec( Dsd_Regular(pNode->pDecs[i]), ppNodes, pnNodes );
626 
627  ppNodes[ (*pnNodes)++ ] = pNode;
628 }
Dsd_Node_t ** pDecs
Definition: dsdInt.h:59
static void Dsd_TreeCollectNodesDfs_rec(Dsd_Node_t *pNode, Dsd_Node_t *ppNodes[], int *pnNodes)
Definition: dsdTree.c:611
#define Dsd_Regular(p)
Definition: dsd.h:69
#define Dsd_IsComplement(p)
MACRO DEFINITIONS ///.
Definition: dsd.h:68
#define assert(ex)
Definition: util_old.h:213
short nVisits
Definition: dsdInt.h:62
short nDecs
Definition: dsdInt.h:61
Dsd_Node_t** Dsd_TreeCollectNodesDfsOne ( Dsd_Manager_t pDsdMan,
Dsd_Node_t pNode,
int *  pnNodes 
)

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

Synopsis [Creates the DFS ordered array of DSD nodes in the tree.]

Description [The collected nodes do not include the terminal nodes and the constant 1 node. The array of nodes is returned. The number of entries in the array is returned in the variale pnNodes.]

SideEffects []

SeeAlso []

Definition at line 585 of file dsdTree.c.

586 {
587  Dsd_Node_t ** ppNodes;
588  int nNodes, nNodesAlloc;
589  nNodesAlloc = Dsd_TreeCountNonTerminalNodesOne(pNode);
590  nNodes = 0;
591  ppNodes = ABC_ALLOC( Dsd_Node_t *, nNodesAlloc );
592  Dsd_TreeCollectNodesDfs_rec( Dsd_Regular(pNode), ppNodes, &nNodes );
594  assert( nNodesAlloc == nNodes );
595  *pnNodes = nNodes;
596  return ppNodes;
597 }
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void Dsd_TreeCollectNodesDfs_rec(Dsd_Node_t *pNode, Dsd_Node_t *ppNodes[], int *pnNodes)
Definition: dsdTree.c:611
#define Dsd_Regular(p)
Definition: dsd.h:69
static ABC_NAMESPACE_IMPL_START void Dsd_TreeUnmark_rec(Dsd_Node_t *pNode)
FUNCTION DECLARATIONS ///.
Definition: dsdTree.c:127
int Dsd_TreeCountNonTerminalNodesOne(Dsd_Node_t *pRoot)
Definition: dsdTree.c:331
#define assert(ex)
Definition: util_old.h:213
int Dsd_TreeCountNonTerminalNodes ( Dsd_Manager_t pDsdMan)

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

Synopsis [Counts non-terminal nodes of the DSD tree.]

Description [Nonterminal nodes include all the nodes with the support more than 1. These are OR, EXOR, and PRIME nodes. They do not include the elementary variable nodes and the constant 1 node.]

SideEffects []

SeeAlso []

Definition at line 310 of file dsdTree.c.

311 {
312  int Counter, i;
313  Counter = 0;
314  for ( i = 0; i < pDsdMan->nRoots; i++ )
315  Counter += Dsd_TreeCountNonTerminalNodes_rec( Dsd_Regular( pDsdMan->pRoots[i] ) );
316  Dsd_TreeUnmark( pDsdMan );
317  return Counter;
318 }
static int Dsd_TreeCountNonTerminalNodes_rec(Dsd_Node_t *pNode)
Definition: dsdTree.c:354
void Dsd_TreeUnmark(Dsd_Manager_t *pDsdMan)
Definition: dsdTree.c:107
static int Counter
#define Dsd_Regular(p)
Definition: dsd.h:69
int nRoots
Definition: dsdInt.h:45
Dsd_Node_t ** pRoots
Definition: dsdInt.h:48
int Dsd_TreeCountNonTerminalNodes_rec ( Dsd_Node_t pNode)
static

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

Synopsis [Counts non-terminal nodes for one root.]

Description []

SideEffects []

SeeAlso []

Definition at line 354 of file dsdTree.c.

355 {
356  int i;
357  int Counter = 0;
358 
359  assert( pNode );
360  assert( !Dsd_IsComplement( pNode ) );
361  assert( pNode->nVisits >= 0 );
362 
363  if ( pNode->nVisits++ ) // if this is not the first visit, return zero
364  return 0;
365 
366  if ( pNode->nDecs <= 1 )
367  return 0;
368 
369  // upon the first visit, go through the list of successors and call recursively
370  for ( i = 0; i < pNode->nDecs; i++ )
371  Counter += Dsd_TreeCountNonTerminalNodes_rec( Dsd_Regular(pNode->pDecs[i]) );
372 
373  return Counter + 1;
374 }
static int Dsd_TreeCountNonTerminalNodes_rec(Dsd_Node_t *pNode)
Definition: dsdTree.c:354
Dsd_Node_t ** pDecs
Definition: dsdInt.h:59
static int Counter
#define Dsd_Regular(p)
Definition: dsd.h:69
#define Dsd_IsComplement(p)
MACRO DEFINITIONS ///.
Definition: dsd.h:68
#define assert(ex)
Definition: util_old.h:213
short nVisits
Definition: dsdInt.h:62
short nDecs
Definition: dsdInt.h:61
int Dsd_TreeCountNonTerminalNodesOne ( Dsd_Node_t pRoot)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 331 of file dsdTree.c.

332 {
333  int Counter = 0;
334 
335  // go through the list of successors and call recursively
337 
339  return Counter;
340 }
static int Dsd_TreeCountNonTerminalNodes_rec(Dsd_Node_t *pNode)
Definition: dsdTree.c:354
static int Counter
#define Dsd_Regular(p)
Definition: dsd.h:69
static ABC_NAMESPACE_IMPL_START void Dsd_TreeUnmark_rec(Dsd_Node_t *pNode)
FUNCTION DECLARATIONS ///.
Definition: dsdTree.c:127
int Dsd_TreeCountPrimeNodes ( Dsd_Manager_t pDsdMan)

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

Synopsis [Counts prime nodes of the DSD tree.]

Description [Prime nodes are nodes with the support more than 2, that is not an OR or EXOR gate.]

SideEffects []

SeeAlso []

Definition at line 389 of file dsdTree.c.

390 {
391  int Counter, i;
392  Counter = 0;
393  for ( i = 0; i < pDsdMan->nRoots; i++ )
394  Counter += Dsd_TreeCountPrimeNodes_rec( Dsd_Regular( pDsdMan->pRoots[i] ) );
395  Dsd_TreeUnmark( pDsdMan );
396  return Counter;
397 }
void Dsd_TreeUnmark(Dsd_Manager_t *pDsdMan)
Definition: dsdTree.c:107
static int Dsd_TreeCountPrimeNodes_rec(Dsd_Node_t *pNode)
Definition: dsdTree.c:433
static int Counter
#define Dsd_Regular(p)
Definition: dsd.h:69
int nRoots
Definition: dsdInt.h:45
Dsd_Node_t ** pRoots
Definition: dsdInt.h:48
int Dsd_TreeCountPrimeNodes_rec ( Dsd_Node_t pNode)
static

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 433 of file dsdTree.c.

434 {
435  int i;
436  int Counter = 0;
437 
438  assert( pNode );
439  assert( !Dsd_IsComplement( pNode ) );
440  assert( pNode->nVisits >= 0 );
441 
442  if ( pNode->nVisits++ ) // if this is not the first visit, return zero
443  return 0;
444 
445  if ( pNode->nDecs <= 1 )
446  return 0;
447 
448  // upon the first visit, go through the list of successors and call recursively
449  for ( i = 0; i < pNode->nDecs; i++ )
450  Counter += Dsd_TreeCountPrimeNodes_rec( Dsd_Regular(pNode->pDecs[i]) );
451 
452  if ( pNode->Type == DSD_NODE_PRIME )
453  Counter++;
454 
455  return Counter;
456 }
Dsd_Node_t ** pDecs
Definition: dsdInt.h:59
static int Dsd_TreeCountPrimeNodes_rec(Dsd_Node_t *pNode)
Definition: dsdTree.c:433
static int Counter
#define Dsd_Regular(p)
Definition: dsd.h:69
Dsd_Type_t Type
Definition: dsdInt.h:56
#define Dsd_IsComplement(p)
MACRO DEFINITIONS ///.
Definition: dsd.h:68
#define assert(ex)
Definition: util_old.h:213
short nVisits
Definition: dsdInt.h:62
short nDecs
Definition: dsdInt.h:61
int Dsd_TreeCountPrimeNodesOne ( Dsd_Node_t pRoot)

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

Synopsis [Counts prime nodes for one root.]

Description []

SideEffects []

SeeAlso []

Definition at line 410 of file dsdTree.c.

411 {
412  int Counter = 0;
413 
414  // go through the list of successors and call recursively
415  Counter = Dsd_TreeCountPrimeNodes_rec( Dsd_Regular(pRoot) );
416 
418  return Counter;
419 }
static int Dsd_TreeCountPrimeNodes_rec(Dsd_Node_t *pNode)
Definition: dsdTree.c:433
static int Counter
#define Dsd_Regular(p)
Definition: dsd.h:69
static ABC_NAMESPACE_IMPL_START void Dsd_TreeUnmark_rec(Dsd_Node_t *pNode)
FUNCTION DECLARATIONS ///.
Definition: dsdTree.c:127
word Dsd_TreeFunc2Truth_rec ( DdManager dd,
DdNode bFunc 
)

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

Synopsis [Prints the decompostion tree into file.]

Description []

SideEffects []

SeeAlso []

Definition at line 837 of file dsdTree.c.

838 {
839  word Cof0, Cof1;
840  int Level;
841  if ( bFunc == b0 )
842  return 0;
843  if ( bFunc == b1 )
844  return ~(word)0;
845  if ( Cudd_IsComplement(bFunc) )
846  return ~Dsd_TreeFunc2Truth_rec( dd, Cudd_Not(bFunc) );
847  Level = dd->perm[bFunc->index];
848  assert( Level >= 0 && Level < 6 );
849  Cof0 = Dsd_TreeFunc2Truth_rec( dd, cuddE(bFunc) );
850  Cof1 = Dsd_TreeFunc2Truth_rec( dd, cuddT(bFunc) );
851  return (s_Truths6[Level] & Cof1) | (~s_Truths6[Level] & Cof0);
852 }
#define Cudd_Not(node)
Definition: cudd.h:367
#define b1
Definition: extraBdd.h:76
#define Cudd_IsComplement(node)
Definition: cudd.h:425
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
#define cuddT(node)
Definition: cuddInt.h:636
static word s_Truths6[6]
#define b0
Definition: extraBdd.h:75
DdHalfWord index
Definition: cudd.h:279
#define cuddE(node)
Definition: cuddInt.h:652
#define assert(ex)
Definition: util_old.h:213
word Dsd_TreeFunc2Truth_rec(DdManager *dd, DdNode *bFunc)
Definition: dsdTree.c:837
int * perm
Definition: cuddInt.h:386
int Dsd_TreeGetAigCost ( Dsd_Node_t pNode)

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

Synopsis [Counts AIG nodes needed to implement this node.]

Description [Assumes that the only primes of the DSD tree are MUXes.]

SideEffects []

SeeAlso []

Definition at line 291 of file dsdTree.c.

292 {
293  return Dsd_TreeGetAigCost_rec( Dsd_Regular(pNode) );
294 }
#define Dsd_Regular(p)
Definition: dsd.h:69
int Dsd_TreeGetAigCost_rec(Dsd_Node_t *pNode)
Definition: dsdTree.c:255
int Dsd_TreeGetAigCost_rec ( Dsd_Node_t pNode)

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

Synopsis [Counts AIG nodes needed to implement this node.]

Description []

SideEffects []

SeeAlso []

Definition at line 255 of file dsdTree.c.

256 {
257  int i, Counter = 0;
258 
259  assert( pNode );
260  assert( !Dsd_IsComplement( pNode ) );
261  assert( pNode->nVisits >= 0 );
262 
263  if ( pNode->nDecs < 2 )
264  return 0;
265 
266  // we don't want the two-input gates to count for non-decomposable blocks
267  if ( pNode->Type == DSD_NODE_OR )
268  Counter += pNode->nDecs - 1;
269  else if ( pNode->Type == DSD_NODE_EXOR )
270  Counter += 3*(pNode->nDecs - 1);
271  else if ( pNode->Type == DSD_NODE_PRIME && pNode->nDecs == 3 )
272  Counter += 3;
273 
274  // call recursively
275  for ( i = 0; i < pNode->nDecs; i++ )
276  Counter += Dsd_TreeGetAigCost_rec( Dsd_Regular(pNode->pDecs[i]) );
277  return Counter;
278 }
Dsd_Node_t ** pDecs
Definition: dsdInt.h:59
static int Counter
#define Dsd_Regular(p)
Definition: dsd.h:69
Dsd_Type_t Type
Definition: dsdInt.h:56
#define Dsd_IsComplement(p)
MACRO DEFINITIONS ///.
Definition: dsd.h:68
int Dsd_TreeGetAigCost_rec(Dsd_Node_t *pNode)
Definition: dsdTree.c:255
#define assert(ex)
Definition: util_old.h:213
short nVisits
Definition: dsdInt.h:62
short nDecs
Definition: dsdInt.h:61
void Dsd_TreeGetInfo_rec ( Dsd_Node_t pNode,
int  RankCur 
)
static

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

Synopsis [Performs the recursive step of Dsd_TreeNodeGetInfo().]

Description [pNode is the node, for the tree rooted in which we are determining info. RankCur is the current rank to assign to the node. fSetRank is the flag saying whether the rank will be written in the node. s_DepthMax is the maximum depths of the tree. s_GateSizeMax is the maximum gate size.]

SideEffects []

SeeAlso []

Definition at line 212 of file dsdTree.c.

213 {
214  int i;
215  int GateSize;
216 
217  assert( pNode );
218  assert( !Dsd_IsComplement( pNode ) );
219  assert( pNode->nVisits >= 0 );
220 
221  // we don't want the two-input gates to count for non-decomposable blocks
222  if ( pNode->Type == DSD_NODE_OR ||
223  pNode->Type == DSD_NODE_EXOR )
224  GateSize = 2;
225  else
226  GateSize = pNode->nDecs;
227 
228  // update the max size of the node
229  if ( s_GateSizeMax < GateSize )
230  s_GateSizeMax = GateSize;
231 
232  if ( pNode->nDecs < 2 )
233  return;
234 
235  // update the max rank
236  if ( s_DepthMax < RankCur+1 )
237  s_DepthMax = RankCur+1;
238 
239  // call recursively
240  for ( i = 0; i < pNode->nDecs; i++ )
241  Dsd_TreeGetInfo_rec( Dsd_Regular(pNode->pDecs[i]), RankCur+1 );
242 }
static int s_DepthMax
STATIC VARIABLES ///.
Definition: dsdTree.c:43
static int s_GateSizeMax
Definition: dsdTree.c:44
Dsd_Node_t ** pDecs
Definition: dsdInt.h:59
#define Dsd_Regular(p)
Definition: dsd.h:69
Dsd_Type_t Type
Definition: dsdInt.h:56
#define Dsd_IsComplement(p)
MACRO DEFINITIONS ///.
Definition: dsd.h:68
#define assert(ex)
Definition: util_old.h:213
static void Dsd_TreeGetInfo_rec(Dsd_Node_t *pNode, int RankCur)
Definition: dsdTree.c:212
short nVisits
Definition: dsdInt.h:62
short nDecs
Definition: dsdInt.h:61
DdNode* Dsd_TreeGetPrimeFunctionOld ( DdManager dd,
Dsd_Node_t pNode,
int  fRemap 
)

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

Synopsis [Retuns the function of one node of the decomposition tree.]

Description [This is the old procedure. It is now superceded by the procedure Dsd_TreeGetPrimeFunction() found in "dsdLocal.c".]

SideEffects []

SeeAlso []

Definition at line 1120 of file dsdTree.c.

1121 {
1122  DdNode * bCof0, * bCof1, * bCube0, * bCube1, * bNewFunc, * bTemp;
1123  int i;
1124  static int Permute[MAXINPUTS];
1125 
1126  assert( pNode );
1127  assert( !Dsd_IsComplement( pNode ) );
1128  assert( pNode->Type == DSD_NODE_PRIME );
1129 
1130  // transform the function of this block to depend on inputs
1131  // corresponding to the formal inputs
1132 
1133  // first, substitute those inputs that have some blocks associated with them
1134  // second, remap the inputs to the top of the manager (then, it is easy to output them)
1135 
1136  // start the function
1137  bNewFunc = pNode->G; Cudd_Ref( bNewFunc );
1138  // go over all primary inputs
1139  for ( i = 0; i < pNode->nDecs; i++ )
1140  if ( pNode->pDecs[i]->Type != DSD_NODE_BUF ) // remap only if it is not the buffer
1141  {
1142  bCube0 = Extra_bddFindOneCube( dd, Cudd_Not(pNode->pDecs[i]->G) ); Cudd_Ref( bCube0 );
1143  bCof0 = Cudd_Cofactor( dd, bNewFunc, bCube0 ); Cudd_Ref( bCof0 );
1144  Cudd_RecursiveDeref( dd, bCube0 );
1145 
1146  bCube1 = Extra_bddFindOneCube( dd, pNode->pDecs[i]->G ); Cudd_Ref( bCube1 );
1147  bCof1 = Cudd_Cofactor( dd, bNewFunc, bCube1 ); Cudd_Ref( bCof1 );
1148  Cudd_RecursiveDeref( dd, bCube1 );
1149 
1150  Cudd_RecursiveDeref( dd, bNewFunc );
1151 
1152  // use the variable in the i-th level of the manager
1153 // bNewFunc = Cudd_bddIte( dd, dd->vars[dd->invperm[i]],bCof1,bCof0 ); Cudd_Ref( bNewFunc );
1154  // use the first variale in the support of the component
1155  bNewFunc = Cudd_bddIte( dd, dd->vars[pNode->pDecs[i]->S->index],bCof1,bCof0 ); Cudd_Ref( bNewFunc );
1156  Cudd_RecursiveDeref( dd, bCof0 );
1157  Cudd_RecursiveDeref( dd, bCof1 );
1158  }
1159 
1160  if ( fRemap )
1161  {
1162  // remap the function to the top of the manager
1163  // remap the function to the first variables of the manager
1164  for ( i = 0; i < pNode->nDecs; i++ )
1165  // Permute[ pNode->pDecs[i]->S->index ] = dd->invperm[i];
1166  Permute[ pNode->pDecs[i]->S->index ] = i;
1167 
1168  bNewFunc = Cudd_bddPermute( dd, bTemp = bNewFunc, Permute ); Cudd_Ref( bNewFunc );
1169  Cudd_RecursiveDeref( dd, bTemp );
1170  }
1171 
1172  Cudd_Deref( bNewFunc );
1173  return bNewFunc;
1174 }
DdNode * S
Definition: dsdInt.h:58
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
DdNode * G
Definition: dsdInt.h:57
void Cudd_Deref(DdNode *node)
Definition: cuddRef.c:438
#define MAXINPUTS
INCLUDES ///.
Definition: cas.h:38
DdNode * Cudd_bddIte(DdManager *dd, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddBddIte.c:143
Dsd_Node_t ** pDecs
Definition: dsdInt.h:59
DdNode * Cudd_Cofactor(DdManager *dd, DdNode *f, DdNode *g)
Definition: cuddCof.c:123
DdNode * Cudd_bddPermute(DdManager *manager, DdNode *node, int *permut)
Definition: cuddCompose.c:332
Dsd_Type_t Type
Definition: dsdInt.h:56
DdNode * Extra_bddFindOneCube(DdManager *dd, DdNode *bF)
Definition: extraBddMisc.c:605
#define Dsd_IsComplement(p)
MACRO DEFINITIONS ///.
Definition: dsd.h:68
DdHalfWord index
Definition: cudd.h:279
DdNode ** vars
Definition: cuddInt.h:390
#define assert(ex)
Definition: util_old.h:213
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
short nDecs
Definition: dsdInt.h:61
Dsd_Node_t* Dsd_TreeNodeCreate ( int  Type,
int  nDecs,
int  BlockNum 
)

FUNCTION DEFINITIONS ///.

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

Synopsis [Create the DSD node.]

Description []

SideEffects []

SeeAlso []

Definition at line 61 of file dsdTree.c.

62 {
63  // allocate memory for this node
64  Dsd_Node_t * p = (Dsd_Node_t *) ABC_ALLOC( char, sizeof(Dsd_Node_t) );
65  memset( p, 0, sizeof(Dsd_Node_t) );
66  p->Type = (Dsd_Type_t)Type; // the type of this block
67  p->nDecs = nDecs; // the number of decompositions
68  if ( p->nDecs )
69  {
70  p->pDecs = (Dsd_Node_t **) ABC_ALLOC( char, p->nDecs * sizeof(Dsd_Node_t *) );
71  p->pDecs[0] = NULL;
72  }
73  return p;
74 }
char * memset()
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Dsd_Node_t ** pDecs
Definition: dsdInt.h:59
Dsd_Type_t Type
Definition: dsdInt.h:56
enum Dsd_Type_t_ Dsd_Type_t
Definition: dsd.h:61
short nDecs
Definition: dsdInt.h:61
void Dsd_TreeNodeDelete ( DdManager dd,
Dsd_Node_t pNode 
)

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

Synopsis [Frees the DSD node.]

Description []

SideEffects []

SeeAlso []

Definition at line 87 of file dsdTree.c.

88 {
89  if ( pNode->G ) Cudd_RecursiveDeref( dd, pNode->G );
90  if ( pNode->S ) Cudd_RecursiveDeref( dd, pNode->S );
91  ABC_FREE( pNode->pDecs );
92  ABC_FREE( pNode );
93 }
DdNode * S
Definition: dsdInt.h:58
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
DdNode * G
Definition: dsdInt.h:57
Dsd_Node_t ** pDecs
Definition: dsdInt.h:59
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Dsd_TreeNodeGetInfo ( Dsd_Manager_t pDsdMan,
int *  DepthMax,
int *  GateSizeMax 
)

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

Synopsis [Getting information about the node.]

Description [This function computes the max depth and the max gate size of the tree rooted at the node.]

SideEffects []

SeeAlso []

Definition at line 156 of file dsdTree.c.

157 {
158  int i;
159  s_DepthMax = 0;
160  s_GateSizeMax = 0;
161 
162  for ( i = 0; i < pDsdMan->nRoots; i++ )
163  Dsd_TreeGetInfo_rec( Dsd_Regular( pDsdMan->pRoots[i] ), 0 );
164 
165  if ( DepthMax )
166  *DepthMax = s_DepthMax;
167  if ( GateSizeMax )
168  *GateSizeMax = s_GateSizeMax;
169 }
static int s_DepthMax
STATIC VARIABLES ///.
Definition: dsdTree.c:43
static int s_GateSizeMax
Definition: dsdTree.c:44
#define Dsd_Regular(p)
Definition: dsd.h:69
static void Dsd_TreeGetInfo_rec(Dsd_Node_t *pNode, int RankCur)
Definition: dsdTree.c:212
int nRoots
Definition: dsdInt.h:45
Dsd_Node_t ** pRoots
Definition: dsdInt.h:48
void Dsd_TreeNodeGetInfoOne ( Dsd_Node_t pNode,
int *  DepthMax,
int *  GateSizeMax 
)

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

Synopsis [Getting information about the node.]

Description [This function computes the max depth and the max gate size of the tree rooted at the node.]

SideEffects []

SeeAlso []

Definition at line 183 of file dsdTree.c.

184 {
185  s_DepthMax = 0;
186  s_GateSizeMax = 0;
187 
188  Dsd_TreeGetInfo_rec( Dsd_Regular(pNode), 0 );
189 
190  if ( DepthMax )
191  *DepthMax = s_DepthMax;
192  if ( GateSizeMax )
193  *GateSizeMax = s_GateSizeMax;
194 }
static int s_DepthMax
STATIC VARIABLES ///.
Definition: dsdTree.c:43
static int s_GateSizeMax
Definition: dsdTree.c:44
#define Dsd_Regular(p)
Definition: dsd.h:69
static void Dsd_TreeGetInfo_rec(Dsd_Node_t *pNode, int RankCur)
Definition: dsdTree.c:212
void Dsd_TreePrint ( FILE *  pFile,
Dsd_Manager_t pDsdMan,
char *  pInputNames[],
char *  pOutputNames[],
int  fShortNames,
int  Output 
)

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

Synopsis [Prints the decompostion tree into file.]

Description []

SideEffects []

SeeAlso []

Definition at line 641 of file dsdTree.c.

642 {
643  Dsd_Node_t * pNode;
644  int SigCounter;
645  int i;
646  SigCounter = 1;
647 
648  if ( Output == -1 )
649  {
650  for ( i = 0; i < pDsdMan->nRoots; i++ )
651  {
652  pNode = Dsd_Regular( pDsdMan->pRoots[i] );
653  Dsd_TreePrint_rec( pFile, pNode, (pNode != pDsdMan->pRoots[i]), pInputNames, pOutputNames[i], 0, &SigCounter, fShortNames );
654  }
655  }
656  else
657  {
658  assert( Output >= 0 && Output < pDsdMan->nRoots );
659  pNode = Dsd_Regular( pDsdMan->pRoots[Output] );
660  Dsd_TreePrint_rec( pFile, pNode, (pNode != pDsdMan->pRoots[Output]), pInputNames, pOutputNames[Output], 0, &SigCounter, fShortNames );
661  }
662 }
static void Dsd_TreePrint_rec(FILE *pFile, Dsd_Node_t *pNode, int fCcmp, char *pInputNames[], char *pOutputName, int nOffset, int *pSigCounter, int fShortNames)
Definition: dsdTree.c:675
#define Dsd_Regular(p)
Definition: dsd.h:69
#define assert(ex)
Definition: util_old.h:213
int nRoots
Definition: dsdInt.h:45
Dsd_Node_t ** pRoots
Definition: dsdInt.h:48
void Dsd_TreePrint2 ( FILE *  pFile,
Dsd_Manager_t pDsdMan,
char *  pInputNames[],
char *  pOutputNames[],
int  Output 
)

Definition at line 917 of file dsdTree.c.

918 {
919  if ( Output == -1 )
920  {
921  int i;
922  for ( i = 0; i < pDsdMan->nRoots; i++ )
923  {
924  fprintf( pFile, "%8s = ", pOutputNames[i] );
925  Dsd_TreePrint2_rec( pFile, pDsdMan->dd, Dsd_Regular(pDsdMan->pRoots[i]), Dsd_IsComplement(pDsdMan->pRoots[i]), pInputNames );
926  fprintf( pFile, "\n" );
927  }
928  }
929  else
930  {
931  assert( Output >= 0 && Output < pDsdMan->nRoots );
932  fprintf( pFile, "%8s = ", pOutputNames[Output] );
933  Dsd_TreePrint2_rec( pFile, pDsdMan->dd, Dsd_Regular(pDsdMan->pRoots[Output]), Dsd_IsComplement(pDsdMan->pRoots[Output]), pInputNames );
934  fprintf( pFile, "\n" );
935  }
936 }
DdManager * dd
Definition: dsdInt.h:42
#define Dsd_Regular(p)
Definition: dsd.h:69
#define Dsd_IsComplement(p)
MACRO DEFINITIONS ///.
Definition: dsd.h:68
#define assert(ex)
Definition: util_old.h:213
int nRoots
Definition: dsdInt.h:45
void Dsd_TreePrint2_rec(FILE *pFile, DdManager *dd, Dsd_Node_t *pNode, int fComp, char *pInputNames[])
Definition: dsdTree.c:853
Dsd_Node_t ** pRoots
Definition: dsdInt.h:48
void Dsd_TreePrint2_rec ( FILE *  pFile,
DdManager dd,
Dsd_Node_t pNode,
int  fComp,
char *  pInputNames[] 
)

Definition at line 853 of file dsdTree.c.

854 {
855  int i;
856  if ( pNode->Type == DSD_NODE_CONST1 )
857  {
858  fprintf( pFile, "Const%d", !fComp );
859  return;
860  }
861  assert( pNode->Type == DSD_NODE_BUF || pNode->Type == DSD_NODE_PRIME || pNode->Type == DSD_NODE_OR || pNode->Type == DSD_NODE_EXOR );
862 // fprintf( pFile, "%s", (fComp ^ (pNode->Type == DSD_NODE_OR))? "!" : "" );
863  if ( pNode->Type == DSD_NODE_BUF )
864  {
865  fprintf( pFile, "%s", fComp? "!" : "" );
866  fprintf( pFile, "%s", pInputNames[pNode->S->index] );
867  }
868  else if ( pNode->Type == DSD_NODE_PRIME )
869  {
870  fprintf( pFile, " " );
871  if ( pNode->nDecs <= 6 )
872  {
873  char pCanonPerm[6]; int uCanonPhase;
874  // compute truth table
875  DdNode * bFunc = Dsd_TreeGetPrimeFunction( dd, pNode );
876  word uTruth = Dsd_TreeFunc2Truth_rec( dd, bFunc );
877  Cudd_Ref( bFunc );
878  Cudd_RecursiveDeref( dd, bFunc );
879  // canonicize truth table
880  uCanonPhase = Abc_TtCanonicize( &uTruth, pNode->nDecs, pCanonPerm );
881  fprintf( pFile, "%s", (fComp ^ ((uCanonPhase >> pNode->nDecs) & 1)) ? "!" : "" );
882  Abc_TtPrintHexRev( pFile, &uTruth, pNode->nDecs );
883  fprintf( pFile, "{" );
884  for ( i = 0; i < pNode->nDecs; i++ )
885  {
886  Dsd_Node_t * pInput = pNode->pDecs[(int)pCanonPerm[i]];
887  Dsd_TreePrint2_rec( pFile, dd, Dsd_Regular(pInput), Dsd_IsComplement(pInput) ^ ((uCanonPhase>>i)&1), pInputNames );
888  }
889  fprintf( pFile, "} " );
890  }
891  else
892  {
893  fprintf( pFile, "|%d|", pNode->nDecs );
894  fprintf( pFile, "{" );
895  for ( i = 0; i < pNode->nDecs; i++ )
896  Dsd_TreePrint2_rec( pFile, dd, Dsd_Regular(pNode->pDecs[i]), Dsd_IsComplement(pNode->pDecs[i]), pInputNames );
897  fprintf( pFile, "} " );
898  }
899  }
900  else if ( pNode->Type == DSD_NODE_OR )
901  {
902  fprintf( pFile, "%s", !fComp? "!" : "" );
903  fprintf( pFile, "(" );
904  for ( i = 0; i < pNode->nDecs; i++ )
905  Dsd_TreePrint2_rec( pFile, dd, Dsd_Regular(pNode->pDecs[i]), !Dsd_IsComplement(pNode->pDecs[i]), pInputNames );
906  fprintf( pFile, ")" );
907  }
908  else if ( pNode->Type == DSD_NODE_EXOR )
909  {
910  fprintf( pFile, "%s", fComp? "!" : "" );
911  fprintf( pFile, "[" );
912  for ( i = 0; i < pNode->nDecs; i++ )
913  Dsd_TreePrint2_rec( pFile, dd, Dsd_Regular(pNode->pDecs[i]), Dsd_IsComplement(pNode->pDecs[i]), pInputNames );
914  fprintf( pFile, "]" );
915  }
916 }
DdNode * S
Definition: dsdInt.h:58
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
static void Abc_TtPrintHexRev(FILE *pFile, word *pTruth, int nVars)
Definition: utilTruth.h:789
Dsd_Node_t ** pDecs
Definition: dsdInt.h:59
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
#define Dsd_Regular(p)
Definition: dsd.h:69
Dsd_Type_t Type
Definition: dsdInt.h:56
#define Dsd_IsComplement(p)
MACRO DEFINITIONS ///.
Definition: dsd.h:68
DdNode * Dsd_TreeGetPrimeFunction(DdManager *dd, Dsd_Node_t *pNode)
FUNCTION DEFINITIONS ///.
Definition: dsdLocal.c:54
DdHalfWord index
Definition: cudd.h:279
unsigned Abc_TtCanonicize(word *pTruth, int nVars, char *pCanonPerm)
FUNCTION DECLARATIONS ///.
Definition: dauCanon.c:895
#define assert(ex)
Definition: util_old.h:213
void Cudd_Ref(DdNode *n)
Definition: cuddRef.c:129
word Dsd_TreeFunc2Truth_rec(DdManager *dd, DdNode *bFunc)
Definition: dsdTree.c:837
void Dsd_TreePrint2_rec(FILE *pFile, DdManager *dd, Dsd_Node_t *pNode, int fComp, char *pInputNames[])
Definition: dsdTree.c:853
short nDecs
Definition: dsdInt.h:61
void Dsd_TreePrint_rec ( FILE *  pFile,
Dsd_Node_t pNode,
int  fComp,
char *  pInputNames[],
char *  pOutputName,
int  nOffset,
int *  pSigCounter,
int  fShortNames 
)
static

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

Synopsis [Prints the decompostion tree into file.]

Description []

SideEffects []

SeeAlso []

Definition at line 675 of file dsdTree.c.

676 {
677  char Buffer[100];
678  Dsd_Node_t * pInput;
679  int * pInputNums;
680  int fCompNew, i;
681 
682  assert( pNode->Type == DSD_NODE_BUF || pNode->Type == DSD_NODE_CONST1 ||
683  pNode->Type == DSD_NODE_PRIME || pNode->Type == DSD_NODE_OR || pNode->Type == DSD_NODE_EXOR );
684 
685  Extra_PrintSymbols( pFile, ' ', nOffset, 0 );
686  if ( !fComp )
687  fprintf( pFile, "%s = ", pOutputName );
688  else
689  fprintf( pFile, "NOT(%s) = ", pOutputName );
690  pInputNums = ABC_ALLOC( int, pNode->nDecs );
691  if ( pNode->Type == DSD_NODE_CONST1 )
692  {
693  fprintf( pFile, " Constant 1.\n" );
694  }
695  else if ( pNode->Type == DSD_NODE_BUF )
696  {
697  if ( fShortNames )
698  fprintf( pFile, "%d", 'a' + pNode->S->index );
699  else
700  fprintf( pFile, "%s", pInputNames[pNode->S->index] );
701  fprintf( pFile, "\n" );
702  }
703  else if ( pNode->Type == DSD_NODE_PRIME )
704  {
705  // print the line
706  fprintf( pFile, "PRIME(" );
707  for ( i = 0; i < pNode->nDecs; i++ )
708  {
709  pInput = Dsd_Regular( pNode->pDecs[i] );
710  fCompNew = (int)( pInput != pNode->pDecs[i] );
711  if ( i )
712  fprintf( pFile, "," );
713  if ( fCompNew )
714  fprintf( pFile, " NOT(" );
715  else
716  fprintf( pFile, " " );
717  if ( pInput->Type == DSD_NODE_BUF )
718  {
719  pInputNums[i] = 0;
720  if ( fShortNames )
721  fprintf( pFile, "%d", pInput->S->index );
722  else
723  fprintf( pFile, "%s", pInputNames[pInput->S->index] );
724  }
725  else
726  {
727  pInputNums[i] = (*pSigCounter)++;
728  fprintf( pFile, "<%d>", pInputNums[i] );
729  }
730  if ( fCompNew )
731  fprintf( pFile, ")" );
732  }
733  fprintf( pFile, " )\n" );
734  // call recursively for the following blocks
735  for ( i = 0; i < pNode->nDecs; i++ )
736  if ( pInputNums[i] )
737  {
738  pInput = Dsd_Regular( pNode->pDecs[i] );
739  sprintf( Buffer, "<%d>", pInputNums[i] );
740  Dsd_TreePrint_rec( pFile, Dsd_Regular( pNode->pDecs[i] ), 0, pInputNames, Buffer, nOffset + 6, pSigCounter, fShortNames );
741  }
742  }
743  else if ( pNode->Type == DSD_NODE_OR )
744  {
745  // print the line
746  fprintf( pFile, "OR(" );
747  for ( i = 0; i < pNode->nDecs; i++ )
748  {
749  pInput = Dsd_Regular( pNode->pDecs[i] );
750  fCompNew = (int)( pInput != pNode->pDecs[i] );
751  if ( i )
752  fprintf( pFile, "," );
753  if ( fCompNew )
754  fprintf( pFile, " NOT(" );
755  else
756  fprintf( pFile, " " );
757  if ( pInput->Type == DSD_NODE_BUF )
758  {
759  pInputNums[i] = 0;
760  if ( fShortNames )
761  fprintf( pFile, "%c", 'a' + pInput->S->index );
762  else
763  fprintf( pFile, "%s", pInputNames[pInput->S->index] );
764  }
765  else
766  {
767  pInputNums[i] = (*pSigCounter)++;
768  fprintf( pFile, "<%d>", pInputNums[i] );
769  }
770  if ( fCompNew )
771  fprintf( pFile, ")" );
772  }
773  fprintf( pFile, " )\n" );
774  // call recursively for the following blocks
775  for ( i = 0; i < pNode->nDecs; i++ )
776  if ( pInputNums[i] )
777  {
778  pInput = Dsd_Regular( pNode->pDecs[i] );
779  sprintf( Buffer, "<%d>", pInputNums[i] );
780  Dsd_TreePrint_rec( pFile, Dsd_Regular( pNode->pDecs[i] ), 0, pInputNames, Buffer, nOffset + 6, pSigCounter, fShortNames );
781  }
782  }
783  else if ( pNode->Type == DSD_NODE_EXOR )
784  {
785  // print the line
786  fprintf( pFile, "EXOR(" );
787  for ( i = 0; i < pNode->nDecs; i++ )
788  {
789  pInput = Dsd_Regular( pNode->pDecs[i] );
790  fCompNew = (int)( pInput != pNode->pDecs[i] );
791  if ( i )
792  fprintf( pFile, "," );
793  if ( fCompNew )
794  fprintf( pFile, " NOT(" );
795  else
796  fprintf( pFile, " " );
797  if ( pInput->Type == DSD_NODE_BUF )
798  {
799  pInputNums[i] = 0;
800  if ( fShortNames )
801  fprintf( pFile, "%c", 'a' + pInput->S->index );
802  else
803  fprintf( pFile, "%s", pInputNames[pInput->S->index] );
804  }
805  else
806  {
807  pInputNums[i] = (*pSigCounter)++;
808  fprintf( pFile, "<%d>", pInputNums[i] );
809  }
810  if ( fCompNew )
811  fprintf( pFile, ")" );
812  }
813  fprintf( pFile, " )\n" );
814  // call recursively for the following blocks
815  for ( i = 0; i < pNode->nDecs; i++ )
816  if ( pInputNums[i] )
817  {
818  pInput = Dsd_Regular( pNode->pDecs[i] );
819  sprintf( Buffer, "<%d>", pInputNums[i] );
820  Dsd_TreePrint_rec( pFile, Dsd_Regular( pNode->pDecs[i] ), 0, pInputNames, Buffer, nOffset + 6, pSigCounter, fShortNames );
821  }
822  }
823  ABC_FREE( pInputNums );
824 }
DdNode * S
Definition: dsdInt.h:58
static void Dsd_TreePrint_rec(FILE *pFile, Dsd_Node_t *pNode, int fCcmp, char *pInputNames[], char *pOutputName, int nOffset, int *pSigCounter, int fShortNames)
Definition: dsdTree.c:675
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Dsd_Node_t ** pDecs
Definition: dsdInt.h:59
void Extra_PrintSymbols(FILE *pFile, char Char, int nTimes, int fPrintNewLine)
char * sprintf()
#define Dsd_Regular(p)
Definition: dsd.h:69
Dsd_Type_t Type
Definition: dsdInt.h:56
DdHalfWord index
Definition: cudd.h:279
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define assert(ex)
Definition: util_old.h:213
short nDecs
Definition: dsdInt.h:61
void Dsd_TreeUnmark ( Dsd_Manager_t pDsdMan)

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

Synopsis [Unmarks the decomposition tree.]

Description [This function assumes that originally pNode->nVisits are set to zero!]

SideEffects []

SeeAlso []

Definition at line 107 of file dsdTree.c.

108 {
109  int i;
110  for ( i = 0; i < pDsdMan->nRoots; i++ )
111  Dsd_TreeUnmark_rec( Dsd_Regular( pDsdMan->pRoots[i] ) );
112 }
#define Dsd_Regular(p)
Definition: dsd.h:69
static ABC_NAMESPACE_IMPL_START void Dsd_TreeUnmark_rec(Dsd_Node_t *pNode)
FUNCTION DECLARATIONS ///.
Definition: dsdTree.c:127
int nRoots
Definition: dsdInt.h:45
Dsd_Node_t ** pRoots
Definition: dsdInt.h:48
void Dsd_TreeUnmark_rec ( Dsd_Node_t pNode)
static

FUNCTION DECLARATIONS ///.

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

FileName [dsdTree.c]

PackageName [DSD: Disjoint-support decomposition package.]

Synopsis [Managing the decomposition tree.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 8.0. Started - September 22, 2003.]

Revision [

Id:
dsdTree.c,v 1.0 2002/22/09 00:00:00 alanmi Exp

]

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

Synopsis [Recursive unmarking.]

Description [This function should be called with a non-complemented pointer.]

SideEffects []

SeeAlso []

Definition at line 127 of file dsdTree.c.

128 {
129  int i;
130 
131  assert( pNode );
132  assert( !Dsd_IsComplement( pNode ) );
133  assert( pNode->nVisits > 0 );
134 
135  if ( --pNode->nVisits ) // if this is not the last visit, return
136  return;
137 
138  // upon the last visit, go through the list of successors and call recursively
139  if ( pNode->Type != DSD_NODE_BUF && pNode->Type != DSD_NODE_CONST1 )
140  for ( i = 0; i < pNode->nDecs; i++ )
141  Dsd_TreeUnmark_rec( Dsd_Regular(pNode->pDecs[i]) );
142 }
Dsd_Node_t ** pDecs
Definition: dsdInt.h:59
#define Dsd_Regular(p)
Definition: dsd.h:69
Dsd_Type_t Type
Definition: dsdInt.h:56
#define Dsd_IsComplement(p)
MACRO DEFINITIONS ///.
Definition: dsd.h:68
static ABC_NAMESPACE_IMPL_START void Dsd_TreeUnmark_rec(Dsd_Node_t *pNode)
FUNCTION DECLARATIONS ///.
Definition: dsdTree.c:127
#define assert(ex)
Definition: util_old.h:213
short nVisits
Definition: dsdInt.h:62
short nDecs
Definition: dsdInt.h:61

Variable Documentation

int s_DepthMax
static

STATIC VARIABLES ///.

Definition at line 43 of file dsdTree.c.

int s_GateSizeMax
static

Definition at line 44 of file dsdTree.c.