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

  Synopsis    [Performs the recursive step of Cudd_DumpBlif.]

  Description [Performs the recursive step of Cudd_DumpBlif. Traverses
  the BDD f and writes a multiplexer-network description to the file
  pointed by fp in blif format. f is assumed to be a regular pointer
  and ddDoDumpBlif guarantees this assumption in the recursive calls.]

  SideEffects [None]

  SeeAlso     []

******************************************************************************/
Function
Synopsis    [Performs the recursive step of Cudd_DumpBlif.]

Description [Performs the recursive step of Cudd_DumpBlif. Traverses
the BDD f and writes a multiplexer-network description to the file
pointed by fp in blif format. f is assumed to be a regular pointer
and ddDoDumpBlif guarantees this assumption in the recursive calls.]




Function Synopsis [ Performs the recursive step of Cudd_DumpBlif . ] Description [ Performs the recursive step of Cudd_DumpBlif . Traverses the BDD f and writes a multiplexer - network description to the file pointed by fp in blif format . f is assumed to be a regular pointer and ddDoDumpBlif guarantees this assumption in the recursive calls . ]
static int
ddDoDumpBlif(
  DdManager * dd,
  DdNode * f,
  FILE * fp,
  st__table * visited,
  char ** names,
  int mv)
{
    DdNode      *T, *E;
    int         retval;
#ifdef DD_DEBUG
    assert(!Cudd_IsComplement(f));
#endif
    if ( st__is_member(visited, (char *) f) == 1)
        return(1);
    if (f == NULL)
        return(0);
    if ( st__insert(visited, (char *) f, NULL) == st__OUT_OF_MEM)
        return(0);
    if (f == DD_ONE(dd)) {
#if SIZEOF_VOID_P == 8
        retval = fprintf(fp, ".names %lx\n1\n",(ptruint) f / (ptruint) sizeof(DdNode));
#else
        retval = fprintf(fp, ".names %x\n1\n",(ptruint) f / (ptruint) sizeof(DdNode));
#endif
        if (retval == EOF) {
            return(0);
        } else {
            return(1);
        }
    }
    if (f == DD_ZERO(dd)) {
#if SIZEOF_VOID_P == 8
        retval = fprintf(fp, ".names %lx\n%s",
                         (ptruint) f / (ptruint) sizeof(DdNode),
                         mv ? "0\n" : "");
#else
        retval = fprintf(fp, ".names %x\n%s",
                         (ptruint) f / (ptruint) sizeof(DdNode),
                         mv ? "0\n" : "");
#endif
        if (retval == EOF) {
            return(0);
        } else {
            return(1);
        }
    }
    if (cuddIsConstant(f))
        return(0);
    T = cuddT(f);
    retval = ddDoDumpBlif(dd,T,fp,visited,names,mv);
    if (retval != 1) return(retval);
    E = Cudd_Regular(cuddE(f));
    retval = ddDoDumpBlif(dd,E,fp,visited,names,mv);
    if (retval != 1) return(retval);
    if (names != NULL) {
        retval = fprintf(fp,".names %s", names[f->index]);
    } else {
#if SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
        retval = fprintf(fp,".names %u", f->index);
#else
        retval = fprintf(fp,".names %hu", f->index);
#endif
    }
    if (retval == EOF)
        return(0);
#if SIZEOF_VOID_P == 8
    if (mv) {
        if (Cudd_IsComplement(cuddE(f))) {
            retval = fprintf(fp," %lx %lx %lx\n.def 0\n1 1 - 1\n0 - 0 1\n",
                (ptruint) T / (ptruint) sizeof(DdNode),
                (ptruint) E / (ptruint) sizeof(DdNode),
                (ptruint) f / (ptruint) sizeof(DdNode));
        } else {
            retval = fprintf(fp," %lx %lx %lx\n.def 0\n1 1 - 1\n0 - 1 1\n",
                (ptruint) T / (ptruint) sizeof(DdNode),
                (ptruint) E / (ptruint) sizeof(DdNode),
                (ptruint) f / (ptruint) sizeof(DdNode));
        }
    } else {
        if (Cudd_IsComplement(cuddE(f))) {
            retval = fprintf(fp," %lx %lx %lx\n11- 1\n0-0 1\n",
                (ptruint) T / (ptruint) sizeof(DdNode),
                (ptruint) E / (ptruint) sizeof(DdNode),
                (ptruint) f / (ptruint) sizeof(DdNode));
        } else {
            retval = fprintf(fp," %lx %lx %lx\n11- 1\n0-1 1\n",
                (ptruint) T / (ptruint) sizeof(DdNode),
                (ptruint) E / (ptruint) sizeof(DdNode),
                (ptruint) f / (ptruint) sizeof(DdNode));
        }
    }
#else
    if (mv) {
        if (Cudd_IsComplement(cuddE(f))) {
            retval = fprintf(fp," %x %x %x\n.def 0\n1 1 - 1\n0 - 0 1\n",
                (ptruint) T / (ptruint) sizeof(DdNode),
                (ptruint) E / (ptruint) sizeof(DdNode),
                (ptruint) f / (ptruint) sizeof(DdNode));
        } else {
            retval = fprintf(fp," %x %x %x\n.def 0\n1 1 - 1\n0 - 1 1\n",
                (ptruint) T / (ptruint) sizeof(DdNode),
                (ptruint) E / (ptruint) sizeof(DdNode),
                (ptruint) f / (ptruint) sizeof(DdNode));
        }
    } else {
        if (Cudd_IsComplement(cuddE(f))) {
            retval = fprintf(fp," %x %x %x\n11- 1\n0-0 1\n",
                (ptruint) T / (ptruint) sizeof(DdNode),
                (ptruint) E / (ptruint) sizeof(DdNode),
                (ptruint) f / (ptruint) sizeof(DdNode));
        } else {
            retval = fprintf(fp," %x %x %x\n11- 1\n0-1 1\n",
                (ptruint) T / (ptruint) sizeof(DdNode),
                (ptruint) E / (ptruint) sizeof(DdNode),
                (ptruint) f / (ptruint) sizeof(DdNode));
        }
    }
#endif
    if (retval == EOF) {
        return(0);
    } else {
        return(1);
    }
}
static int ddDoDumpBlif ( DdManager * dd , DdNode * f , FILE * fp , st__table * visited , char * * names , int mv ) { DdNode * T , * E ; int retval ; #ifdef DD_DEBUG assert ( ! Cudd_IsComplement ( f ) ) ; #endif if ( st__is_member ( visited , ( char * ) f ) == 1 ) return ( 1 ) ; if ( f == NULL ) return ( 0 ) ; if ( st__insert ( visited , ( char * ) f , NULL ) == st__OUT_OF_MEM ) return ( 0 ) ; if ( f == DD_ONE ( dd ) ) { #if SIZEOF_VOID_P == 8 retval = fprintf ( fp , " \n \n " , ( ptruint ) f / ( ptruint ) sizeof ( DdNode ) ) ; #else retval = fprintf ( fp , " \n \n " , ( ptruint ) f / ( ptruint ) sizeof ( DdNode ) ) ; #endif if ( retval == EOF ) { return ( 0 ) ; } else { return ( 1 ) ; } } if ( f == DD_ZERO ( dd ) ) { #if SIZEOF_VOID_P == 8 retval = fprintf ( fp , " \n " , ( ptruint ) f / ( ptruint ) sizeof ( DdNode ) , mv ? " \n " : " " ) ; #else retval = fprintf ( fp , " \n " , ( ptruint ) f / ( ptruint ) sizeof ( DdNode ) , mv ? " \n " : " " ) ; #endif if ( retval == EOF ) { return ( 0 ) ; } else { return ( 1 ) ; } } if ( cuddIsConstant ( f ) ) return ( 0 ) ; T = cuddT ( f ) ; retval = ddDoDumpBlif ( dd , T , fp , visited , names , mv ) ; if ( retval != 1 ) return ( retval ) ; E = Cudd_Regular ( cuddE ( f ) ) ; retval = ddDoDumpBlif ( dd , E , fp , visited , names , mv ) ; if ( retval != 1 ) return ( retval ) ; if ( names != NULL ) { retval = fprintf ( fp , " " , names [ f -> index ] ) ; } else { #if SIZEOF_VOID_P == 8 && SIZEOF_INT == 4 retval = fprintf ( fp , " " , f -> index ) ; #else retval = fprintf ( fp , " " , f -> index ) ; #endif } if ( retval == EOF ) return ( 0 ) ; #if SIZEOF_VOID_P == 8 if ( mv ) { if ( Cudd_IsComplement ( cuddE ( f ) ) ) { retval = fprintf ( fp , " \n \n \n \n " , ( ptruint ) T / ( ptruint ) sizeof ( DdNode ) , ( ptruint ) E / ( ptruint ) sizeof ( DdNode ) , ( ptruint ) f / ( ptruint ) sizeof ( DdNode ) ) ; } else { retval = fprintf ( fp , " \n \n \n \n " , ( ptruint ) T / ( ptruint ) sizeof ( DdNode ) , ( ptruint ) E / ( ptruint ) sizeof ( DdNode ) , ( ptruint ) f / ( ptruint ) sizeof ( DdNode ) ) ; } } else { if ( Cudd_IsComplement ( cuddE ( f ) ) ) { retval = fprintf ( fp , " \n \n \n " , ( ptruint ) T / ( ptruint ) sizeof ( DdNode ) , ( ptruint ) E / ( ptruint ) sizeof ( DdNode ) , ( ptruint ) f / ( ptruint ) sizeof ( DdNode ) ) ; } else { retval = fprintf ( fp , " \n \n \n " , ( ptruint ) T / ( ptruint ) sizeof ( DdNode ) , ( ptruint ) E / ( ptruint ) sizeof ( DdNode ) , ( ptruint ) f / ( ptruint ) sizeof ( DdNode ) ) ; } } #else if ( mv ) { if ( Cudd_IsComplement ( cuddE ( f ) ) ) { retval = fprintf ( fp , " \n \n \n \n " , ( ptruint ) T / ( ptruint ) sizeof ( DdNode ) , ( ptruint ) E / ( ptruint ) sizeof ( DdNode ) , ( ptruint ) f / ( ptruint ) sizeof ( DdNode ) ) ; } else { retval = fprintf ( fp , " \n \n \n \n " , ( ptruint ) T / ( ptruint ) sizeof ( DdNode ) , ( ptruint ) E / ( ptruint ) sizeof ( DdNode ) , ( ptruint ) f / ( ptruint ) sizeof ( DdNode ) ) ; } } else { if ( Cudd_IsComplement ( cuddE ( f ) ) ) { retval = fprintf ( fp , " \n \n \n " , ( ptruint ) T / ( ptruint ) sizeof ( DdNode ) , ( ptruint ) E / ( ptruint ) sizeof ( DdNode ) , ( ptruint ) f / ( ptruint ) sizeof ( DdNode ) ) ; } else { retval = fprintf ( fp , " \n \n \n " , ( ptruint ) T / ( ptruint ) sizeof ( DdNode ) , ( ptruint ) E / ( ptruint ) sizeof ( DdNode ) , ( ptruint ) f / ( ptruint ) sizeof ( DdNode ) ) ; } } #endif if ( retval == EOF ) { return ( 0 ) ; } else { return ( 1 ) ; } }
Function
Synopsis    [Performs the recursive step of Cudd_DumpBlif.]
Function Synopsis [ Performs the recursive step of Cudd_DumpBlif . ]
/* If already visited, nothing to do. */ /* Check for abnormal condition that should never happen. */ /* Mark node as visited. */ /* Check for special case: If constant node, generate constant 1. */ /* Check whether this is an ADD. We deal with 0-1 ADDs, but not
    ** with the general case.
    */ /* Recursive calls. */ /* Write multiplexer taking complement arc into account. */