📄 espresso.h
字号:
/* * Revision Control Information * * $Source: /projects/mvsis/Repository/mvsis-1.3/src/sis/espresso/espresso.h,v $ * $Author: wjiang $ * $Revision: 1.1.1.1 $ * $Date: 2003/02/24 22:24:07 $ * *//* * espresso.h -- header file for Espresso-mv */#ifndef _ESPRESSO_INCLUDE#define _ESPRESSO_INCLUDE/*#include "ansi.h"*/#include <stdio.h>#include "sparse.h"#include "mincov.h"#include "util.h"#ifdef IBM_WATC#define void int#include "short.h"#endif#ifdef IBMPC /* set default options for IBM/PC */#define NO_INLINE#define BPI 16#endif/*-----THIS USED TO BE set.h----- *//* * set.h -- definitions for packed arrays of bits * * This header file describes the data structures which comprise a * facility for efficiently implementing packed arrays of bits * (otherwise known as sets, cf. Pascal). * * A set is a vector of bits and is implemented here as an array of * unsigned integers. The low order bits of set[0] give the index of * the last word of set data. The higher order bits of set[0] are * used to store data associated with the set. The set data is * contained in elements set[1] ... set[LOOP(set)] as a packed bit * array. * * A family of sets is a two-dimensional matrix of bits and is * implemented with the data type "set_family". * * BPI == 32 and BPI == 16 have been tested and work. *//* Define host machine characteristics of "unsigned int" */#ifndef BPI#define BPI 32 /* # bits per integer */#endif#if BPI == 32#define LOGBPI 5 /* log(BPI)/log(2) */#else#define LOGBPI 4 /* log(BPI)/log(2) */#endif/* Define the set type */typedef unsigned int *pset;/* Define the set family type -- an array of sets */typedef struct set_family { int wsize; /* Size of each set in 'ints' */ int sf_size; /* User declared set size */ int capacity; /* Number of sets allocated */ int count; /* The number of sets in the family */ int active_count; /* Number of "active" sets */ pset data; /* Pointer to the set data */ struct set_family *next; /* For garbage collection */} set_family_t, *pset_family;/* Macros to set and test single elements */#define WHICH_WORD(element) (((element) >> LOGBPI) + 1)#define WHICH_BIT(element) ((element) & (BPI-1))/* # of ints needed to allocate a set with "size" elements */#if BPI == 32#define SET_SIZE(size) ((size) <= BPI ? 2 : (WHICH_WORD((size)-1) + 1))#else#define SET_SIZE(size) ((size) <= BPI ? 3 : (WHICH_WORD((size)-1) + 2))#endif/* * Three fields are maintained in the first word of the set * LOOP is the index of the last word used for set data * LOOPCOPY is the index of the last word in the set * SIZE is available for general use (e.g., recording # elements in set) * NELEM retrieves the number of elements in the set */#define LOOP(set) (set[0] & 0x03ff)#define PUTLOOP(set, i) (set[0] &= ~0x03ff, set[0] |= (i))#if BPI == 32#define LOOPCOPY(set) LOOP(set)#define SIZE(set) (set[0] >> 16)#define PUTSIZE(set, size) (set[0] &= 0xffff, set[0] |= ((size) << 16))#else#define LOOPCOPY(set) (LOOP(set) + 1)#define SIZE(set) (set[LOOP(set)+1])#define PUTSIZE(set, size) ((set[LOOP(set)+1]) = (size))#endif#define NELEM(set) (BPI * LOOP(set))#define LOOPINIT(size) ((size <= BPI) ? 1 : WHICH_WORD((size)-1))/* * FLAGS store general information about the set */#define SET(set, flag) (set[0] |= (flag))#define RESET(set, flag) (set[0] &= ~ (flag))#define TESTP(set, flag) (set[0] & (flag))/* Flag definitions are ... */#define PRIME 0x8000 /* cube is prime */#define NONESSEN 0x4000 /* cube cannot be essential prime */#define ACTIVE 0x2000 /* cube is still active */#define REDUND 0x1000 /* cube is redundant(at this point) */#define COVERED 0x0800 /* cube has been covered */#define RELESSEN 0x0400 /* cube is relatively essential *//* Most efficient way to look at all members of a set family */#define foreach_set(R, last, p)\ for(p=R->data,last=p+R->count*R->wsize;p<last;p+=R->wsize)#define foreach_remaining_set(R, last, pfirst, p)\ for(p=pfirst+R->wsize,last=R->data+R->count*R->wsize;p<last;p+=R->wsize)#define foreach_active_set(R, last, p)\ foreach_set(R,last,p) if (TESTP(p, ACTIVE))/* Another way that also keeps the index of the current set member in i */#define foreachi_set(R, i, p)\ for(p=R->data,i=0;i<R->count;p+=R->wsize,i++)#define foreachi_active_set(R, i, p)\ foreachi_set(R,i,p) if (TESTP(p, ACTIVE))/* Looping over all elements in a set: * foreach_set_element(pset p, int i, unsigned val, int base) { * . * . * . * } */#define foreach_set_element(p, i, val, base) \ for(i = LOOP(p); i > 0; ) \ for(val = p[i], base = --i << LOGBPI; val != 0; base++, val >>= 1) \ if (val & 1)/* Return a pointer to a given member of a set family */#define GETSET(family, index) ((family)->data + (family)->wsize * (index))/* Allocate and deallocate sets */#define set_new(size) set_clear(ALLOC(unsigned int, SET_SIZE(size)), size)#define set_full(size) set_fill(ALLOC(unsigned int, SET_SIZE(size)), size)#define set_save(r) set_copy(ALLOC(unsigned int, SET_SIZE(NELEM(r))), r)#define set_free(r) FREE(r)/* Check for set membership, remove set element and insert set element */#define is_in_set(set, e) (set[WHICH_WORD(e)] & (1 << WHICH_BIT(e)))#define set_remove(set, e) (set[WHICH_WORD(e)] &= ~ (1 << WHICH_BIT(e)))#define set_insert(set, e) (set[WHICH_WORD(e)] |= 1 << WHICH_BIT(e))/* Inline code substitution for those places that REALLY need it on a VAX */#ifdef NO_INLINE#define INLINEset_copy(r, a) (void) set_copy(r,a)#define INLINEset_clear(r, size) (void) set_clear(r, size)#define INLINEset_fill(r, size) (void) set_fill(r, size)#define INLINEset_and(r, a, b) (void) set_and(r, a, b)#define INLINEset_or(r, a, b) (void) set_or(r, a, b)#define INLINEset_diff(r, a, b) (void) set_diff(r, a, b)#define INLINEset_ndiff(r, a, b, f) (void) set_ndiff(r, a, b, f)#define INLINEset_xor(r, a, b) (void) set_xor(r, a, b)#define INLINEset_xnor(r, a, b, f) (void) set_xnor(r, a, b, f)#define INLINEset_merge(r, a, b, mask) (void) set_merge(r, a, b, mask)#define INLINEsetp_implies(a, b, when_false) \ if (! setp_implies(a,b)) when_false#define INLINEsetp_disjoint(a, b, when_false) \ if (! setp_disjoint(a,b)) when_false#define INLINEsetp_equal(a, b, when_false) \ if (! setp_equal(a,b)) when_false#else#define INLINEset_copy(r, a)\ {register int i_=LOOPCOPY(a); do r[i_]=a[i_]; while (--i_>=0);}#define INLINEset_clear(r, size)\ {register int i_=LOOPINIT(size); *r=i_; do r[i_] = 0; while (--i_ > 0);}#define INLINEset_fill(r, size)\ {register int i_=LOOPINIT(size); *r=i_; \ r[i_]=((unsigned int)(~0))>>(i_*BPI-size); while(--i_>0) r[i_]=~0;}#define INLINEset_and(r, a, b)\ {register int i_=LOOP(a); PUTLOOP(r,i_);\ do r[i_] = a[i_] & b[i_]; while (--i_>0);}#define INLINEset_or(r, a, b)\ {register int i_=LOOP(a); PUTLOOP(r,i_);\ do r[i_] = a[i_] | b[i_]; while (--i_>0);}#define INLINEset_diff(r, a, b)\ {register int i_=LOOP(a); PUTLOOP(r,i_);\ do r[i_] = a[i_] & ~ b[i_]; while (--i_>0);}#define INLINEset_ndiff(r, a, b, fullset)\ {register int i_=LOOP(a); PUTLOOP(r,i_);\ do r[i_] = fullset[i_] & (a[i_] | ~ b[i_]); while (--i_>0);}#ifdef IBM_WATC#define INLINEset_xor(r, a, b) (void) set_xor(r, a, b)#define INLINEset_xnor(r, a, b, f) (void) set_xnor(r, a, b, f)#else#define INLINEset_xor(r, a, b)\ {register int i_=LOOP(a); PUTLOOP(r,i_);\ do r[i_] = a[i_] ^ b[i_]; while (--i_>0);}#define INLINEset_xnor(r, a, b, fullset)\ {register int i_=LOOP(a); PUTLOOP(r,i_);\ do r[i_] = fullset[i_] & ~ (a[i_] ^ b[i_]); while (--i_>0);}#endif#define INLINEset_merge(r, a, b, mask)\ {register int i_=LOOP(a); PUTLOOP(r,i_);\ do r[i_] = (a[i_]&mask[i_]) | (b[i_]&~mask[i_]); while (--i_>0);}#define INLINEsetp_implies(a, b, when_false)\ {register int i_=LOOP(a); do if (a[i_]&~b[i_]) break; while (--i_>0);\ if (i_ != 0) when_false;}#define INLINEsetp_disjoint(a, b, when_false)\ {register int i_=LOOP(a); do if (a[i_]&b[i_]) break; while (--i_>0);\ if (i_ != 0) when_false;}#define INLINEsetp_equal(a, b, when_false)\ {register int i_=LOOP(a); do if (a[i_]!=b[i_]) break; while (--i_>0);\ if (i_ != 0) when_false;}#endif /* NO_INLINE */#if BPI == 32#define count_ones(v)\ (bit_count[v & 255] + bit_count[(v >> 8) & 255]\ + bit_count[(v >> 16) & 255] + bit_count[(v >> 24) & 255])#else#define count_ones(v) (bit_count[v & 255] + bit_count[(v >> 8) & 255])#endif/* Table for efficient bit counting */extern int bit_count[256];/*----- END OF set.h ----- *//* Define a boolean type */#define bool int#ifndef FALSE#define FALSE 0#endif#ifndef TRUE#define TRUE 1#endif#define MAYBE 2#define print_bool(x) ((x) == 0 ? "FALSE" : ((x) == 1 ? "TRUE" : "MAYBE"))/* Map many cube/cover types/routines into equivalent set types/routines */#define pcube pset#define new_cube() set_new(cube.size)#define free_cube(r) set_free(r)#define pcover pset_family#define new_cover(i) sf_new(i, cube.size)#define free_cover(r) sf_free(r)#define free_cubelist(T) FREE(T[0]); FREE(T);/* cost_t describes the cost of a cover */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -