[13] | 1 | #include "mdd.h" |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | * MDD Package |
---|
| 5 | * |
---|
| 6 | * $Id: mdd_func1c.c,v 1.11 2002/08/25 05:30:12 fabio Exp $ |
---|
| 7 | * |
---|
| 8 | * Author: Timothy Kam |
---|
| 9 | * |
---|
| 10 | * Copyright 1992 by the Regents of the University of California. |
---|
| 11 | * |
---|
| 12 | * All rights reserved. Permission to use, copy, modify and distribute |
---|
| 13 | * this software is hereby granted, provided that the above copyright |
---|
| 14 | * notice and this permission notice appear in all copies. This software |
---|
| 15 | * is made available as is, with no warranties. |
---|
| 16 | */ |
---|
| 17 | |
---|
| 18 | mdd_t * |
---|
| 19 | mdd_func1c( |
---|
| 20 | mdd_manager *mgr, |
---|
| 21 | int mvar1, |
---|
| 22 | int constant, |
---|
| 23 | boolean (*func2)(int, int)) |
---|
| 24 | { |
---|
| 25 | mvar_type x; |
---|
| 26 | array_t *child_list_x; |
---|
| 27 | int i; |
---|
| 28 | mdd_t *tx; |
---|
| 29 | array_t *mvar_list = mdd_ret_mvar_list(mgr); |
---|
| 30 | mdd_t *zero, *one; |
---|
| 31 | |
---|
| 32 | zero = mdd_zero(mgr); |
---|
| 33 | one = mdd_one(mgr); |
---|
| 34 | x = array_fetch(mvar_type, mvar_list, mvar1); |
---|
| 35 | if (x.status == MDD_BUNDLED) |
---|
| 36 | printf("\nWarning: mdd_func1c, bundled variable %s is used\n", x.name); |
---|
| 37 | |
---|
| 38 | child_list_x = array_alloc(mdd_t *, x.values); |
---|
| 39 | for (i=0; i<x.values; i++) { |
---|
| 40 | if (func2(i,constant)) |
---|
| 41 | array_insert_last(mdd_t *, child_list_x, one); |
---|
| 42 | else |
---|
| 43 | array_insert_last(mdd_t *, child_list_x, zero); |
---|
| 44 | } |
---|
| 45 | tx = mdd_case(mgr, mvar1, child_list_x); |
---|
| 46 | array_free(child_list_x); |
---|
| 47 | |
---|
| 48 | mdd_free(one); |
---|
| 49 | mdd_free(zero); |
---|
| 50 | |
---|
| 51 | return tx; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | |
---|
| 55 | /*---------------------------------------------------------------------------*/ |
---|
| 56 | /* Static function prototypes */ |
---|
| 57 | /*---------------------------------------------------------------------------*/ |
---|
| 58 | |
---|
| 59 | |
---|