abc/src/bdd/cudd/cuddExport.c
/**Function********************************************************************

  Synopsis    [Writes factored forms representing the argument BDDs.]

  Description [Writes factored forms representing the argument BDDs.
  The format of the factored form is the one used in the genlib files
  for technology mapping in sis.  It returns 1 in case of success; 0
  otherwise (e.g., file system full).  Cudd_DumpFactoredForm does not
  close the file: This is the caller responsibility. Caution must be
  exercised because a factored form may be exponentially larger than
  the argument BDD.  If the argument inames is non-null, it is assumed
  to hold the pointers to the names of the inputs. Similarly for
  onames.]

  SideEffects [None]

  SeeAlso     [Cudd_DumpDot Cudd_PrintDebug Cudd_DumpBlif Cudd_DumpDaVinci
  Cudd_DumpDDcal]

******************************************************************************/
Function
Synopsis    [Writes factored forms representing the argument BDDs.]

Description [Writes factored forms representing the argument BDDs.
The format of the factored form is the one used in the genlib files
for technology mapping in sis.  It returns 1 in case of success; 0
otherwise .  Cudd_DumpFactoredForm does not
close the file: This is the caller responsibility. Caution must be
exercised because a factored form may be exponentially larger than
the argument BDD.  If the argument inames is non-null, it is assumed
to hold the pointers to the names of the inputs. Similarly for
onames.]




Function Synopsis [ Writes factored forms representing the argument BDDs . ] Description [ Writes factored forms representing the argument BDDs . The format of the factored form is the one used in the genlib files for technology mapping in sis . It returns 1 in case of success ; 0 otherwise . Cudd_DumpFactoredForm does not close the file : This is the caller responsibility . Caution must be exercised because a factored form may be exponentially larger than the argument BDD . If the argument inames is non - null it is assumed to hold the pointers to the names of the inputs . Similarly for onames . ]
int
Cudd_DumpFactoredForm(
  DdManager * dd ,
  int  n ,
  DdNode ** f ,
  char ** inames ,
  char ** onames ,
  FILE * fp )
{
    int         retval;
    int         i;
    for (i = 0; i < n; i++) {
        if (onames == NULL) {
            retval = fprintf(fp, "f%d = ", i);
        } else {
            retval = fprintf(fp, "%s = ", onames[i]);
        }
        if (retval == EOF) return(0);
        if (f[i] == DD_ONE(dd)) {
            retval = fprintf(fp, "CONST1");
            if (retval == EOF) return(0);
        } else if (f[i] == Cudd_Not(DD_ONE(dd)) || f[i] == DD_ZERO(dd)) {
            retval = fprintf(fp, "CONST0");
            if (retval == EOF) return(0);
        } else {
            retval = fprintf(fp, "%s", Cudd_IsComplement(f[i]) ? "!(" : "");
            if (retval == EOF) return(0);
            retval = ddDoDumpFactoredForm(dd,Cudd_Regular(f[i]),fp,inames);
            if (retval == 0) return(0);
            retval = fprintf(fp, "%s", Cudd_IsComplement(f[i]) ? ")" : "");
            if (retval == EOF) return(0);
        }
        retval = fprintf(fp, "%s", i == n-1 ? "" : "\n");
        if (retval == EOF) return(0);
    }
    return(1);
}
int Cudd_DumpFactoredForm ( DdManager * dd , int n , DdNode * * f , char * * inames , char * * onames , FILE * fp ) { int retval ; int i ; for ( i = 0 ; i < n ; i ++ ) { if ( onames == NULL ) { retval = fprintf ( fp , " " , i ) ; } else { retval = fprintf ( fp , " " , onames [ i ] ) ; } if ( retval == EOF ) return ( 0 ) ; if ( f [ i ] == DD_ONE ( dd ) ) { retval = fprintf ( fp , " " ) ; if ( retval == EOF ) return ( 0 ) ; } else if ( f [ i ] == Cudd_Not ( DD_ONE ( dd ) ) || f [ i ] == DD_ZERO ( dd ) ) { retval = fprintf ( fp , " " ) ; if ( retval == EOF ) return ( 0 ) ; } else { retval = fprintf ( fp , " " , Cudd_IsComplement ( f [ i ] ) ? " " : " " ) ; if ( retval == EOF ) return ( 0 ) ; retval = ddDoDumpFactoredForm ( dd , Cudd_Regular ( f [ i ] ) , fp , inames ) ; if ( retval == 0 ) return ( 0 ) ; retval = fprintf ( fp , " " , Cudd_IsComplement ( f [ i ] ) ? " " : " " ) ; if ( retval == EOF ) return ( 0 ) ; } retval = fprintf ( fp , " " , i == n - 1 ? " " : " \n " ) ; if ( retval == EOF ) return ( 0 ) ; } return ( 1 ) ; }
Function
Synopsis    [Writes factored forms representing the argument BDDs.]
Function Synopsis [ Writes factored forms representing the argument BDDs . ]
/* manager */ /* number of output nodes to be dumped */ /* array of output nodes to be dumped */ /* array of input names (or NULL) */ /* array of output names (or NULL) */ /* pointer to the dump file */ /* Call the function that really gets the job done. */