summaryrefslogtreecommitdiffstats
path: root/src/misc/espresso/cubehack.c
blob: 58935716748257282b38a19089f1b3af83080734 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
 * Revision Control Information
 *
 * $Source: /vol/opua/opua2/sis/sis-1.1/common/src/sis/node/RCS/cubehack.c,v $
 * $Author: sis $
 * $Revision: 1.2 $
 * $Date: 1992/05/06 18:57:41 $
 *
 */
/*
#include "sis.h"
#include "node_int.h"

#ifdef lint
struct cube_struct cube;
bool summary;
bool trace;
bool remove_essential;
bool force_irredundant;
bool unwrap_onset;
bool single_expand;
bool pos;
bool recompute_onset;
bool use_super_gasp;
bool use_random_order;
#endif
*/
#include "espresso.h"

ABC_NAMESPACE_IMPL_START



void 
cautious_define_cube_size(n)
int n;
{
    if (cube.fullset != 0 && cube.num_binary_vars == n)
    return;
    if (cube.fullset != 0) {
    setdown_cube();
    FREE(cube.part_size);
    }
    cube.num_binary_vars = cube.num_vars = n;
    cube.part_size = ALLOC(int, n);
    cube_setup();
}


void
define_cube_size(n)
int n;
{
    register int q, i;
    static int called_before = 0;

    /* check if the cube is already just the right size */
    if (cube.fullset != 0 && cube.num_binary_vars == n && cube.num_vars == n)
    return;

    /* We can't handle more than 100 inputs */
    if (n > 100) {
    cautious_define_cube_size(n);
    called_before = 0;
    return;
    }

    if (cube.fullset == 0 || ! called_before) {
    cautious_define_cube_size(100);
    called_before = 1;
    }

    cube.num_vars = n;
    cube.num_binary_vars = n;
    cube.num_mv_vars = 0;
    cube.output = -1;
    cube.size = n * 2;

    /* first_part, last_part, first_word, last_word, part_size OKAY */
    /* cube.sparse is OKAY */

    /* need to completely re-make cube.fullset and cube.binary_mask */
    (void) set_fill(cube.fullset, n*2);
    (void) set_fill(cube.binary_mask, n*2);

    /* need to resize each set in cube.var_mask and cube.temp */
    q = cube.fullset[0];
    for(i = 0; i < cube.num_vars; i++)
    cube.var_mask[i][0] = q;
    for(i = 0; i < CUBE_TEMP; i++)
    cube.temp[i][0] = q;

    /* need to resize cube.emptyset and cube.mv_mask */
    cube.emptyset[0] = q;
    cube.mv_mask[0] = q;

    /* need to reset the inword and inmask */
    if (cube.num_binary_vars != 0) {
    cube.inword = cube.last_word[cube.num_binary_vars - 1];
    cube.inmask = cube.binary_mask[cube.inword] & DISJOINT;
    } else {
    cube.inword = -1;
    cube.inmask = 0;
    }

    /* cdata (entire structure) is OKAY */
}


void
undefine_cube_size()
{
    if (cube.num_binary_vars > 100) {
    if (cube.fullset != 0) {
        setdown_cube();
        FREE(cube.part_size);
    }
    } else {
    cube.num_vars = cube.num_binary_vars = 100;
    if (cube.fullset != 0) {
        setdown_cube();
        FREE(cube.part_size);
    }
    }
}


void
set_espresso_flags()
{
    summary = FALSE;
    trace = FALSE;
    remove_essential = TRUE;
    force_irredundant = TRUE;
    unwrap_onset = TRUE;
    single_expand = FALSE;
    pos = FALSE;
    recompute_onset = FALSE;
    use_super_gasp = FALSE;
    use_random_order = FALSE;
}
ABC_NAMESPACE_IMPL_END
pan> // is meant as a lightweight alternative to NOPRINT. Use it when you only want to do // a spot of debugging but lack flash resources for allowing all of the codebase to // print (and store their wasteful strings). // // !!! DO NOT USE USER PRINT CALLS IN THE BODY OF QMK/TMK !!! // #ifdef USER_PRINT // Disable normal print #define print_dec(data) #define print_decs(data) #define print_hex4(data) #define print_hex8(data) #define print_hex16(data) #define print_hex32(data) #define print_bin4(data) #define print_bin8(data) #define print_bin16(data) #define print_bin32(data) #define print_bin_reverse8(data) #define print_bin_reverse16(data) #define print_bin_reverse32(data) #define print_val_dec(v) #define print_val_decs(v) #define print_val_hex8(v) #define print_val_hex16(v) #define print_val_hex32(v) #define print_val_bin8(v) #define print_val_bin16(v) #define print_val_bin32(v) #define print_val_bin_reverse8(v) #define print_val_bin_reverse16(v) #define print_val_bin_reverse32(v) #else /* NORMAL_PRINT */ //Enable normal print /* decimal */ #define print_dec(i) xprintf("%u", i) #define print_decs(i) xprintf("%d", i) /* hex */ #define print_hex4(i) xprintf("%X", i) #define print_hex8(i) xprintf("%02X", i) #define print_hex16(i) xprintf("%04X", i) #define print_hex32(i) xprintf("%08lX", i) /* binary */ #define print_bin4(i) xprintf("%04b", i) #define print_bin8(i) xprintf("%08b", i) #define print_bin16(i) xprintf("%016b", i) #define print_bin32(i) xprintf("%032lb", i) #define print_bin_reverse8(i) xprintf("%08b", bitrev(i)) #define print_bin_reverse16(i) xprintf("%016b", bitrev16(i)) #define print_bin_reverse32(i) xprintf("%032lb", bitrev32(i)) /* print value utility */ #define print_val_dec(v) xprintf(#v ": %u\n", v) #define print_val_decs(v) xprintf(#v ": %d\n", v) #define print_val_hex8(v) xprintf(#v ": %X\n", v) #define print_val_hex16(v) xprintf(#v ": %02X\n", v) #define print_val_hex32(v) xprintf(#v ": %04lX\n", v) #define print_val_bin8(v) xprintf(#v ": %08b\n", v) #define print_val_bin16(v) xprintf(#v ": %016b\n", v) #define print_val_bin32(v) xprintf(#v ": %032lb\n", v) #define print_val_bin_reverse8(v) xprintf(#v ": %08b\n", bitrev(v)) #define print_val_bin_reverse16(v) xprintf(#v ": %016b\n", bitrev16(v)) #define print_val_bin_reverse32(v) xprintf(#v ": %032lb\n", bitrev32(v)) #endif /* USER_PRINT / NORMAL_PRINT */ // User Print /* decimal */ #define uprint_dec(i) uprintf("%u", i) #define uprint_decs(i) uprintf("%d", i) /* hex */ #define uprint_hex4(i) uprintf("%X", i) #define uprint_hex8(i) uprintf("%02X", i) #define uprint_hex16(i) uprintf("%04X", i) #define uprint_hex32(i) uprintf("%08lX", i) /* binary */ #define uprint_bin4(i) uprintf("%04b", i) #define uprint_bin8(i) uprintf("%08b", i) #define uprint_bin16(i) uprintf("%016b", i) #define uprint_bin32(i) uprintf("%032lb", i) #define uprint_bin_reverse8(i) uprintf("%08b", bitrev(i)) #define uprint_bin_reverse16(i) uprintf("%016b", bitrev16(i)) #define uprint_bin_reverse32(i) uprintf("%032lb", bitrev32(i)) /* print value utility */ #define uprint_val_dec(v) uprintf(#v ": %u\n", v) #define uprint_val_decs(v) uprintf(#v ": %d\n", v) #define uprint_val_hex8(v) uprintf(#v ": %X\n", v) #define uprint_val_hex16(v) uprintf(#v ": %02X\n", v) #define uprint_val_hex32(v) uprintf(#v ": %04lX\n", v) #define uprint_val_bin8(v) uprintf(#v ": %08b\n", v) #define uprint_val_bin16(v) uprintf(#v ": %016b\n", v) #define uprint_val_bin32(v) uprintf(#v ": %032lb\n", v) #define uprint_val_bin_reverse8(v) uprintf(#v ": %08b\n", bitrev(v)) #define uprint_val_bin_reverse16(v) uprintf(#v ": %016b\n", bitrev16(v)) #define uprint_val_bin_reverse32(v) uprintf(#v ": %032lb\n", bitrev32(v)) #else /* NO_PRINT */ #define xprintf(fmt, ...) #define print(s) #define println(s) #define print_set_sendchar(func) #define print_dec(data) #define print_decs(data) #define print_hex4(data) #define print_hex8(data) #define print_hex16(data) #define print_hex32(data) #define print_bin4(data) #define print_bin8(data) #define print_bin16(data) #define print_bin32(data) #define print_bin_reverse8(data) #define print_bin_reverse16(data) #define print_bin_reverse32(data) #define print_val_dec(v) #define print_val_decs(v) #define print_val_hex8(v) #define print_val_hex16(v) #define print_val_hex32(v) #define print_val_bin8(v) #define print_val_bin16(v) #define print_val_bin32(v) #define print_val_bin_reverse8(v) #define print_val_bin_reverse16(v) #define print_val_bin_reverse32(v) #endif /* NO_PRINT */ /* Backward compatiblitly for old name */ #define pdec(data) print_dec(data) #define pdec16(data) print_dec(data) #define phex(data) print_hex8(data) #define phex16(data) print_hex16(data) #define pbin(data) print_bin8(data) #define pbin16(data) print_bin16(data) #define pbin_reverse(data) print_bin_reverse8(data) #define pbin_reverse16(data) print_bin_reverse16(data) #endif