├── examples ├── tcheck ├── mytest ├── mytest2 ├── mytest3 ├── check ├── check2 ├── check~ ├── newtag ├── newtpla1 ├── dc1 ├── newbyte ├── newill ├── wim ├── newcwp ├── newapla2 ├── dekoder ├── newtpla2 ├── clpl ├── alu1 ├── newapla1 ├── p82 ├── sex ├── newcpla2 ├── inc ├── newapla ├── m1 ├── newcond ├── max46 ├── newtpla ├── br1 ├── br2 ├── tms ├── luc ├── dc2 ├── dk27 ├── newcpla1 ├── sqr6 ├── sqn ├── alu3 ├── newxcpla1 ├── alu2 ├── dk17 ├── misj ├── ryy6 ├── alcom ├── in5 ├── exp ├── m2 ├── b11 ├── b4 ├── b7 ├── risc ├── in6 ├── b9 ├── ex7 ├── in7 ├── pope.rom ├── apla ├── m3 ├── t3 ├── shift ├── mp2d ├── b2 ├── vg2 └── vtx1 ├── tlex ├── mytest.pla ├── con1.pla ├── xor5.pla ├── rd53.pla ├── squar5.pla ├── inc.pla ├── misex1.pla ├── sao2.pla ├── 9sym.pla ├── misex2.pla ├── 5xp1.pla ├── rd73.pla ├── Z5xp1.pla ├── bw.pla ├── clip.pla └── vg2.pla ├── espresso-src ├── mincov.h ├── strdup.h ├── Makefile ├── README ├── strdup.c ├── prtime.c ├── sminterf.c ├── COPYING ├── copyright.h ├── utility.h ├── canonical.c ├── mincov_int.h ├── cpu_time.c ├── solution.c ├── sigma.c ├── signature_exact.c ├── equiv.c ├── gimpel.c ├── dominate.c ├── part.c ├── globals.c ├── signature.h ├── sparse_int.h ├── util_signature.c ├── indep.c ├── map.c ├── cvrmisc.c ├── sparse.c ├── espresso.c ├── signature.c └── primes.c ├── .gitignore ├── README.md ├── .travis.yml ├── LICENSE └── hard_examples ├── misj └── shift /examples/tcheck: -------------------------------------------------------------------------------- 1 | .i 3 2 | .o 3 3 | 000 110 4 | 001 011 5 | 010 101 6 | -------------------------------------------------------------------------------- /examples/mytest: -------------------------------------------------------------------------------- 1 | .i 2 2 | .o 2 3 | .p 4 4 | 00 10 5 | 01 01 6 | 11 -1 7 | 10 1- 8 | .e 9 | -------------------------------------------------------------------------------- /examples/mytest2: -------------------------------------------------------------------------------- 1 | .i 2 2 | .o 2 3 | .p 4 4 | 00 10 5 | 01 01 6 | 10 11 7 | 11 -- 8 | .e 9 | -------------------------------------------------------------------------------- /examples/mytest3: -------------------------------------------------------------------------------- 1 | .i 2 2 | .o 3 3 | .p 4 4 | 00 101 5 | 01 010 6 | 10 110 7 | 11 --- 8 | .e 9 | -------------------------------------------------------------------------------- /tlex/mytest.pla: -------------------------------------------------------------------------------- 1 | .i 2 2 | .o 1 3 | .type fdr 4 | 5 | 00|1 6 | 11|1 7 | 01|- 8 | 10|0 9 | .e 10 | -------------------------------------------------------------------------------- /espresso-src/mincov.h: -------------------------------------------------------------------------------- 1 | /* exported */ 2 | extern sm_row *sm_minimum_cover(sm_matrix *A, int *weight, int heuristic, int debug_level); 3 | -------------------------------------------------------------------------------- /espresso-src/strdup.h: -------------------------------------------------------------------------------- 1 | #ifndef __H_STRDUP 2 | #define __H_STRDUP 3 | 4 | #ifndef strdup 5 | char * strdup(const char *str); 6 | #endif 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /tlex/con1.pla: -------------------------------------------------------------------------------- 1 | 2 | .i 7 3 | .o 2 4 | .ilb f b c d a h g 5 | .ob f0 f1 6 | .p 9 7 | -1--1-- 10 8 | 1-11--- 10 9 | -001--- 10 10 | 01---1- 10 11 | -0--0-- 01 12 | 1---0-- 01 13 | 0-----0 01 14 | 01--1-- 01 15 | 10-0--- 01 16 | .e 17 | -------------------------------------------------------------------------------- /examples/check: -------------------------------------------------------------------------------- 1 | .i 4 2 | .o 1 3 | .p 16 4 | 0000 0 5 | 0001 0 6 | 0010 0 7 | 0011 0 8 | 0100 0 9 | 0101 - 10 | 0111 - 11 | 0110 0 12 | 1100 0 13 | 1101 - 14 | 1111 1 15 | 1110 1 16 | 1000 0 17 | 1001 0 18 | 1011 1 19 | 1010 1 20 | .e 21 | -------------------------------------------------------------------------------- /examples/check2: -------------------------------------------------------------------------------- 1 | .i 4 2 | .o 1 3 | .p 16 4 | 0000 0 5 | 0001 0 6 | 0010 0 7 | 0011 0 8 | 0100 1 9 | 0101 1 10 | 0111 - 11 | 0110 - 12 | 1100 1 13 | 1101 1 14 | 1111 - 15 | 1110 - 16 | 1000 - 17 | 1001 - 18 | 1011 0 19 | 1010 0 20 | .e 21 | -------------------------------------------------------------------------------- /examples/check~: -------------------------------------------------------------------------------- 1 | .i 4 2 | .o 1 3 | .p 16 4 | 0000 - 5 | 0001 - 6 | 0010 0 7 | 0011 0 8 | 0100 - 9 | 0101 - 10 | 0111 0 11 | 0110 0 12 | 1100 0 13 | 1101 0 14 | 1111 1 15 | 1110 1 16 | 1000 0 17 | 1001 0 18 | 1011 1 19 | 1010 1 20 | .e 21 | -------------------------------------------------------------------------------- /examples/newtag: -------------------------------------------------------------------------------- 1 | .i 8 2 | .o 1 3 | .ilb busB<31> busA<31> busA<30> busB<30> busB<29> busA<29> busB<28> busA<28> 4 | .ob ptagcompare 5 | .p 8 6 | -0------ 1 7 | ---1-00- 1 8 | ---10-0- 1 9 | ---1-0-0 1 10 | ---10--0 1 11 | ---100-- 1 12 | --1----- 1 13 | 1------- 1 14 | .e 15 | -------------------------------------------------------------------------------- /examples/newtpla1: -------------------------------------------------------------------------------- 1 | .i 10 2 | .o 2 3 | .ilb CPIPE1s<6> CPIPE1s<0> CPIPE1s<1> CPIPE1s<2> CPIPE1s<3> CPIPE1s<4> CPIPE1s<5> CPIPE1s<7> AIprocessed<31> AIprocessed<30> 4 | .ob shiftAbus31 shiftAbus30 5 | .p 4 6 | -01000111- 10 7 | 00-000111- 01 8 | 10100011-1 01 9 | 10-000111- 10 10 | .e 11 | -------------------------------------------------------------------------------- /tlex/xor5.pla: -------------------------------------------------------------------------------- 1 | .i 5 2 | .o 1 3 | .ilb d c b a e 4 | .ob xor5 5 | .p 16 6 | 11111 1 7 | 01110 1 8 | 10110 1 9 | 00111 1 10 | 11010 1 11 | 01011 1 12 | 10011 1 13 | 00010 1 14 | 11100 1 15 | 01101 1 16 | 10101 1 17 | 00100 1 18 | 11001 1 19 | 01000 1 20 | 10000 1 21 | 00001 1 22 | .e 23 | -------------------------------------------------------------------------------- /examples/dc1: -------------------------------------------------------------------------------- 1 | .i 4 2 | .o 7 3 | 0100 0000010 4 | 0101 0000100 5 | 0111 0000010 6 | 01-1 0010000 7 | 001- 0011100 8 | 0-00 1000000 9 | 100- 1011000 10 | 010- 1001000 11 | 01-0 1000000 12 | -000 0110100 13 | 0-10 0101100 14 | 0--1 0000001 15 | 01-- 0000001 16 | 00-- 0000010 17 | -00- 0000011 18 | -------------------------------------------------------------------------------- /examples/newbyte: -------------------------------------------------------------------------------- 1 | .i 5 2 | .o 8 3 | .ilb EX_INSpass byteEX s1 s0 phi3 4 | .ob ex3 ex2 ex1 ex0 ins3 ins2 ins1 ins0 5 | .p 8 6 | 00001 00000001 7 | 00011 00000010 8 | 00101 00000100 9 | 00111 00001000 10 | 01001 00010000 11 | 01011 00100000 12 | 01101 01000000 13 | 01111 10000000 14 | .e 15 | -------------------------------------------------------------------------------- /examples/newill: -------------------------------------------------------------------------------- 1 | .i 8 2 | .o 1 3 | .ilb CPIPE1s<9> CPIPE1s<0> CPIPE1s<1> CPIPE1s<2> CPIPE1s<3> CPIPE1s<4> CPIPE1s<5> CPIPE1s<7> 4 | .ob pillegalopc 5 | .p 8 6 | -1-11011 1 7 | -110-011 1 8 | -10-0011 1 9 | 1------- 1 10 | ---00001 1 11 | -11-1101 1 12 | -1-01101 1 13 | -11-0001 1 14 | .e 15 | -------------------------------------------------------------------------------- /examples/wim: -------------------------------------------------------------------------------- 1 | .i 4 2 | .o 7 3 | 0000 1111011 4 | 0001 0010010 5 | 0010 1011101 6 | 0011 1010111 7 | 0100 1110110 8 | 0101 1100111 9 | 0110 1101111 10 | 0111 1010110 11 | 1000 1111111 12 | 1001 1110111 13 | 1010 2222222 14 | 1011 2222222 15 | 1100 2222222 16 | 1101 2222222 17 | 1110 2222222 18 | 1111 2222222 19 | -------------------------------------------------------------------------------- /examples/newcwp: -------------------------------------------------------------------------------- 1 | .i 4 2 | .o 5 3 | .ilb CWP<6> CWP<5> CWP<4> changeCWP2 4 | .ob CWP+1<2> CWP+1<1> CWP+1<0> CWPm1<1> CWPm1<2> 5 | .p 11 6 | 101- 10001 7 | 110- 10001 8 | 111- 00011 9 | -001 10010 10 | --0- 00100 11 | -011 01000 12 | 000- 10001 13 | -101 01000 14 | -000 01010 15 | -110 11000 16 | 011- 10010 17 | .e 18 | -------------------------------------------------------------------------------- /examples/newapla2: -------------------------------------------------------------------------------- 1 | .i 6 2 | .o 7 3 | .ilb DST2s<0> DST2s<1> DST2s<2> DST2s<3> DST2s<4> DSTvalid 4 | .ob writetoSHA1 writetoSHB1 writetoPSW1 writetoCWP1 pwritetoTB pwritetoSWP pwritetoPC 5 | .p 7 6 | 001011 0000010 7 | 111011 0010000 8 | 110011 1000000 9 | 101011 0000100 10 | 100011 0000001 11 | 011011 0001000 12 | 010011 0100000 13 | .e 14 | -------------------------------------------------------------------------------- /examples/dekoder: -------------------------------------------------------------------------------- 1 | .i 4 2 | .o 7 3 | .p 16 4 | 0000 1111 110 5 | 0001 0110 000 6 | 0010 1101 101 7 | 0011 1111 001 8 | 0100 0110 011 9 | 0101 1011 011 10 | 0110 1011 111 11 | 0111 1110 000 12 | 1000 1111 111 13 | 1001 1111 011 14 | 1010 ---- --- 15 | 1011 ---- --- 16 | 1100 ---- --- 17 | 1101 ---- --- 18 | 1110 ---- --- 19 | 1111 ---- --- 20 | .e 21 | -------------------------------------------------------------------------------- /espresso-src/Makefile: -------------------------------------------------------------------------------- 1 | SRC := $(wildcard *.c) 2 | 3 | OBJ := ${SRC:.c=.o} 4 | 5 | TARGETDIR := ../bin 6 | TARGET := $(TARGETDIR)/espresso 7 | 8 | all: prepare $(TARGET) 9 | 10 | prepare: 11 | mkdir -p $(TARGETDIR) 12 | 13 | $(TARGET): $(OBJ) 14 | $(LINK.c) $(OBJ) -o $(TARGET) 15 | 16 | clean: 17 | @- $(RM) -r $(TARGETDIR) 18 | @- $(RM) $(OBJ) 19 | 20 | -------------------------------------------------------------------------------- /espresso-src/README: -------------------------------------------------------------------------------- 1 | 2 | The original Espresso code comes from the 1989 Berkeley code (https://embedded.eecs.berkeley.edu/pubs/downloads/espresso/index.htm). See the COPYING file for original code license. 3 | 4 | This distribution is just a C99 port of the excellent work made by Andrew to simplify and port to C89 standards (https://github.com/Rupan/espresso/tree/master/jni/espresso). 5 | -------------------------------------------------------------------------------- /espresso-src/strdup.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #ifndef strdup 5 | char *strdup(const char * src) { 6 | char * dup; 7 | unsigned int len; 8 | 9 | if (!src) return NULL; 10 | 11 | len = strlen(src); 12 | 13 | if (len == 0) return NULL; 14 | 15 | dup = malloc(len+1); 16 | 17 | if (dup) 18 | strcpy(dup, src); 19 | 20 | return dup; 21 | } 22 | #endif 23 | -------------------------------------------------------------------------------- /examples/newtpla2: -------------------------------------------------------------------------------- 1 | .i 10 2 | .o 4 3 | .ilb GStrap trapinstr datapagefINT winunderflow winoverflow SWI intTAGtrap illegalopc instrpagefINT IOINT 4 | .ob TRAPreason3 TRAPreason2 TRAPreason1 TRAPreason0 5 | .p 9 6 | 10000000-- 0111 7 | --100000-- 0101 8 | -1000000-- 0110 9 | 0000000001 1001 10 | ----1000-- 0011 11 | ------10-- 0001 12 | -----100-- 0010 13 | 000000001- 1000 14 | ---10000-- 0100 15 | .e 16 | -------------------------------------------------------------------------------- /examples/clpl: -------------------------------------------------------------------------------- 1 | .i 11 2 | .o 5 3 | -1--------- 10000 4 | ---1--1---- 10000 5 | --1--11---- 10000 6 | 1---111---- 10000 7 | ---1------- 01000 8 | --1--1----- 01000 9 | 1---11----- 01000 10 | --1-------- 00100 11 | 1---1------ 00100 12 | ----------1 00010 13 | -------1-1- 00010 14 | -1------11- 00010 15 | ---1--1-11- 00010 16 | --1--11-11- 00010 17 | 1---111-11- 00010 18 | -------1--- 00001 19 | -1------1-- 00001 20 | ---1--1-1-- 00001 21 | --1--11-1-- 00001 22 | 1---111-1-- 00001 23 | -------------------------------------------------------------------------------- /espresso-src/prtime.c: -------------------------------------------------------------------------------- 1 | /* LINTLIBRARY */ 2 | #include "port.h" 3 | #include "utility.h" 4 | 5 | /* 6 | * util_print_time -- massage a long which represents a time interval in 7 | * milliseconds, into a string suitable for output 8 | * 9 | * Hack for IBM/PC -- avoids using floating point 10 | */ 11 | 12 | char * 13 | util_print_time(long int t) 14 | { 15 | static char s[40]; 16 | 17 | (void) sprintf(s, "%ld.%02ld sec", t/1000, (t%1000)/10); 18 | return s; 19 | } 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | *.obj 5 | *.elf 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Libraries 12 | *.lib 13 | *.a 14 | *.la 15 | *.lo 16 | 17 | # Shared objects (inc. Windows DLLs) 18 | *.dll 19 | *.so 20 | *.so.* 21 | *.dylib 22 | 23 | # Executables 24 | *.exe 25 | *.out 26 | *.app 27 | *.i*86 28 | *.x86_64 29 | *.hex 30 | 31 | # Debug files 32 | *.dSYM/ 33 | *.su 34 | *.log 35 | 36 | # Deployment directories 37 | build/ 38 | bin/ 39 | 40 | # Dependencies 41 | node_modules/ 42 | -------------------------------------------------------------------------------- /tlex/rd53.pla: -------------------------------------------------------------------------------- 1 | 2 | .i 5 3 | .o 3 4 | .p 32 5 | 1-111 1~~ 6 | 11-11 1~~ 7 | 1111- 1~~ 8 | 111-1 1~~ 9 | -1111 1~~ 10 | 01-01 ~~1 11 | -0110 ~~1 12 | 001-1 ~~1 13 | 1-001 ~~1 14 | 1-100 ~~1 15 | 110-0 ~~1 16 | 011-0 ~~1 17 | 1001- ~~1 18 | 0-011 ~~1 19 | -1010 ~~1 20 | -0101 ~~1 21 | 01110 ~1~ 22 | 00010 ~1~ 23 | 01000 ~1~ 24 | 11111 ~1~ 25 | 00100 ~1~ 26 | 00111 ~1~ 27 | 11100 ~1~ 28 | 11010 ~1~ 29 | 01101 ~1~ 30 | 01011 ~1~ 31 | 10110 ~1~ 32 | 10000 ~1~ 33 | 11001 ~1~ 34 | 00001 ~1~ 35 | 10101 ~1~ 36 | 10011 ~1~ 37 | .e 38 | -------------------------------------------------------------------------------- /examples/alu1: -------------------------------------------------------------------------------- 1 | .i 12 2 | .o 8 3 | ----1------0 10000000 4 | ----0-----0- 10000000 5 | 0----------- 10000000 6 | -----1-----0 01000000 7 | -----0----0- 01000000 8 | -0---------- 01000000 9 | ------1----0 00100000 10 | ------0---0- 00100000 11 | --0--------- 00100000 12 | -------1---0 00010000 13 | -------0--0- 00010000 14 | ---0-------- 00010000 15 | 0---1---0--- 00001000 16 | 0---0----0-- 00001000 17 | -0---1--0--- 00000100 18 | -0---0---0-- 00000100 19 | --0---1-0--- 00000010 20 | --0---0--0-- 00000010 21 | ---0---10--- 00000001 22 | -------------------------------------------------------------------------------- /examples/newapla1: -------------------------------------------------------------------------------- 1 | .i 12 2 | .o 7 3 | .ilb SRC1s<0> SRC1s<1> SRC1s<2> SRC1s<3> SRC1s<4> CPIPE1s<7> pbusDtoINA SRC2equal16 SRC2equalDST2 opc2load DSTvalid SRC1equalDST2 4 | .ob pbusStobusA pSHAtobusA pSHBtobusA preadPSWtoA preadCWPtoA LoadforwtoINB1 LoadforwtoINA1 5 | .p 10 6 | 0110110----- 1000100 7 | 1110110----- 1001000 8 | ----010--111 0000001 9 | 1100110----- 0100000 10 | 0100110----- 0010000 11 | -1---10--111 0000001 12 | 1----10--111 0000001 13 | -----100111- 0000010 14 | --1--10--111 0000001 15 | ---1-10--111 0000001 16 | .e 17 | -------------------------------------------------------------------------------- /examples/p82: -------------------------------------------------------------------------------- 1 | .i 5 2 | .o 14 3 | 00000|10000011000111 4 | 00001|00000011001110 5 | 00010|00000000011001 6 | 00011|00001101100000 7 | 00100|00000001000000 8 | 00101|00000011100010 9 | 00110|00000000000001 10 | 00111|00001111100000 11 | 01000|00000011100111 12 | 01001|00000011110010 13 | 01010|00101101000000 14 | 01011|01001000100000 15 | 01100|00000001100011 16 | 01101|00000010000010 17 | 01110|00000010100010 18 | 01111|00000000000001 19 | 10000|00001110100000 20 | 10001|00000010100111 21 | 10010|00000000010010 22 | 10011|00001110000000 23 | 10100|00000001000000 24 | 10101|00000011000010 25 | 10110|00000000000001 26 | 10111|00011111000000 27 | -------------------------------------------------------------------------------- /tlex/squar5.pla: -------------------------------------------------------------------------------- 1 | .i 5 2 | .o 8 3 | 00000 00000000 4 | 00001 00000000 5 | 00010 00000001 6 | 00011 00000010 7 | 00100 00000100 8 | 00101 00000110 9 | 00110 00001001 10 | 00111 00001100 11 | 01000 00010000 12 | 01001 00010100 13 | 01010 00011001 14 | 01011 00011110 15 | 01100 00100100 16 | 01101 00101010 17 | 01110 00110001 18 | 01111 00111000 19 | 10000 01000000 20 | 10001 01001000 21 | 10010 01010001 22 | 10011 01011010 23 | 10100 01100100 24 | 10101 01101110 25 | 10110 01111001 26 | 10111 10000100 27 | 11000 10010000 28 | 11001 10011100 29 | 11010 10101001 30 | 11011 10110110 31 | 11100 11000100 32 | 11101 11010010 33 | 11110 11100001 34 | 11111 11110000 35 | .e 36 | -------------------------------------------------------------------------------- /examples/sex: -------------------------------------------------------------------------------- 1 | .i 9 2 | .o 14 3 | 1------00|10000011000000 4 | 01----0--|00000010100000 5 | 0-1---0--|00000000010000 6 | 0-10--00-|00001000000000 7 | 01-0--00-|00001000000000 8 | ------100|00000011001001 9 | -----11-0|00100000000000 10 | --1---0-1|00000000010000 11 | -1----0-1|00000010100000 12 | ----1-0--|00000100000000 13 | ----010-1|00100000000000 14 | ----00001|00000000001100 15 | ------01-|00000100000010 16 | -00---0-0|00010000000000 17 | ------11-|00001000000000 18 | -1-----1-|00000010100000 19 | --1----1-|00000000010000 20 | ------1-1|00010000000000 21 | 1-----10-|00000111000000 22 | 01-0----1|00000010100000 23 | 0-10----1|00000000010000 24 | 0-10---01|01000000000000 25 | 01-0---01|01000000000000 26 | -------------------------------------------------------------------------------- /examples/newcpla2: -------------------------------------------------------------------------------- 1 | .i 7 2 | .o 10 3 | .ilb CPIPE2s<0> CPIPE2s<1> CPIPE2s<2> CPIPE2s<3> CPIPE2s<4> CPIPE2s<5> CPIPE2s<7> 4 | .ob writeRFaccess2 lastPCtobusD1 busDtobusB2 busDtobusA2 DSTtobusD2 nillonreturn pLOADwrite opc2load DSTvalid pbusDtoINA 5 | .p 19 6 | ---0111 1000001010 7 | -1--111 0000000001 8 | --000-1 1000000010 9 | --1-111 0000000001 10 | 1-01101 1000000010 11 | -----00 1111000000 12 | 101000- 1111000000 13 | -001011 0011100000 14 | -110011 0011100000 15 | 11--0-1 1000000010 16 | ----011 1000000010 17 | 0000111 0000000100 18 | -0111-1 0000000001 19 | 11-1-01 1000000010 20 | 1---111 0000000001 21 | -1-1001 1011110000 22 | ---10-1 0000000010 23 | 0---011 0011100000 24 | 0--1101 0000000001 25 | .e 26 | -------------------------------------------------------------------------------- /examples/inc: -------------------------------------------------------------------------------- 1 | .i 7 2 | .o 9 3 | 00000--|000001000 4 | 00001--|0001--010 5 | 0001-0-|000110000 6 | 0001-1-|001010--0 7 | 0010-00|001010100 8 | 0010-1-|0110101-0 9 | 0010001|001110-00 10 | 0010101|001010100 11 | 0011-0-|001110000 12 | 0011-10|0100100-0 13 | 0011-11|0101100-0 14 | 0100--1|1010--011 15 | 0100-10|001010--1 16 | 0100-00|010010001 17 | 0101-01|010110001 18 | 0101-1-|1001-00-1 19 | 0101-00|010010001 20 | 0110-10|0111-0--1 21 | 0110-00|011010101 22 | 01100-1|010110-01 23 | 0110101|011010101 24 | 0110111|0111-0--1 25 | 0111--1|0111000-0 26 | 0111--0|1000000-0 27 | 1000--0|1000000-0 28 | 10000-1|1001000-0 29 | 10001-1|10100-010 30 | 1001--1|1001000-0 31 | 1001--0|0010-0-10 32 | 1010-0-|101001000 33 | 1010-1-|1011010-0 34 | 1011-0-|101101000 35 | 1011-1-|11000-0-0 36 | 1100---|1100000-0 37 | -------------------------------------------------------------------------------- /tlex/inc.pla: -------------------------------------------------------------------------------- 1 | .i 7 2 | .o 9 3 | 00000--|000001000 4 | 00001--|0001--010 5 | 0001-0-|000110000 6 | 0001-1-|001010--0 7 | 0010-00|001010100 8 | 0010-1-|0110101-0 9 | 0010001|001110-00 10 | 0010101|001010100 11 | 0011-0-|001110000 12 | 0011-10|0100100-0 13 | 0011-11|0101100-0 14 | 0100--1|1010--011 15 | 0100-10|001010--1 16 | 0100-00|010010001 17 | 0101-01|010110001 18 | 0101-1-|1001-00-1 19 | 0101-00|010010001 20 | 0110-10|0111-0--1 21 | 0110-00|011010101 22 | 01100-1|010110-01 23 | 0110101|011010101 24 | 0110111|0111-0--1 25 | 0111--1|0111000-0 26 | 0111--0|1000000-0 27 | 1000--0|1000000-0 28 | 10000-1|1001000-0 29 | 10001-1|10100-010 30 | 1001--1|1001000-0 31 | 1001--0|0010-0-10 32 | 1010-0-|101001000 33 | 1010-1-|1011010-0 34 | 1011-0-|101101000 35 | 1011-1-|11000-0-0 36 | 1100---|1100000-0 37 | -------------------------------------------------------------------------------- /examples/newapla: -------------------------------------------------------------------------------- 1 | .i 12 2 | .o 10 3 | .ilb CPIPE1s<7> SRC1s<0> SRC1s<1> SRC1s<2> SRC1s<3> SRC1s<4> SRC1equalDST2 DSTvalid pbusDtoINA SRC2equal16 SRC2equalDST2 opc2load 4 | .ob readRFaccessA1 readRFaccessB1 AIzero1 AIzeroforce busDtobusAa DSTtobusDa2 preadTBtoA preadSWPtoA pForwardtoINB preadPCtoA 5 | .p 17 6 | --------1--- 0000010000 7 | 1-------1--- 1100010000 8 | 1------10010 0000010010 9 | 1---1-110--0 0000110000 10 | 11----11---0 0000010000 11 | 1-1---110--0 0000110000 12 | 1--1--11---0 0000010000 13 | 1----0110--0 0000110000 14 | 100001--0--- 1010000000 15 | 110101--0--- 0000101000 16 | 110001--0--- 0000100001 17 | 100101--0--- 0000100100 18 | 1------0---- 1100000000 19 | 0----------- 0011000000 20 | 1---------0- 0100000000 21 | 1--------1-- 0100000000 22 | 1-----0----- 1000000000 23 | .e 24 | -------------------------------------------------------------------------------- /examples/m1: -------------------------------------------------------------------------------- 1 | .i 6 2 | .o 12 3 | 000000 111001111111 4 | 000001 111001011001 5 | 000010 111010010010 6 | 000011 111010001110 7 | 000100 111011001100 8 | 000101 111011001010 9 | 000110 111011001001 10 | 000111 111100000111 11 | 001000 111100000110 12 | 001001 111100000110 13 | 001010 111101000101 14 | 001011 111101000100 15 | 001100 111101000100 16 | 001101 111101000011 17 | 001110 111110000011 18 | 001111 111110000011 19 | 010000 111110000010 20 | 010001 111110000010 21 | 010010 111110000010 22 | 010011 111110000010 23 | 010100 111111000010 24 | 010101 111111000001 25 | 010110 111111000001 26 | 010111 111111000001 27 | 011000 111111000001 28 | 011001 111111000001 29 | 011010 111111000001 30 | 011011 111111000001 31 | 011100 111111000001 32 | 011101 111111000001 33 | 011110 111111000001 34 | 011111 111111000001 35 | -------------------------------------------------------------------------------- /examples/newcond: -------------------------------------------------------------------------------- 1 | .i 11 2 | .o 2 3 | .ilb cAin0 cselaluSUM caluZout cBIprocessedMSB cAIprocessedMSB cALUmsb cDST1s<0> cDST1s<1> cDST1s<2> cDST1s<3> cDST1s<4> 4 | .ob pCONDvalid aluVout 5 | .p 31 6 | ---01101--0 10 7 | ---10101--0 10 8 | -1-11-01-00 10 9 | -1-00-1-000 10 10 | -1001011--0 10 11 | -1010011--0 10 12 | -1-010110-0 10 13 | -1-100110-0 10 14 | -1000-1--00 10 15 | 0--1010100- 10 16 | 0--0110100- 10 17 | -100101100- 10 18 | -101001100- 10 19 | -1-001----- 01 20 | -1-110----- 01 21 | -1011-11001 10 22 | -0---101--0 10 23 | 0--00-01001 10 24 | ------10000 10 25 | -00--01--00 10 26 | --1---0-100 10 27 | -0----01-10 10 28 | -1011-11-10 10 29 | --0---10-00 10 30 | 1-----11001 10 31 | --1---011-0 10 32 | 0-1---01001 10 33 | -0---01-000 10 34 | ---00-01-10 10 35 | 00----01001 10 36 | -1-11-11010 10 37 | .e 38 | -------------------------------------------------------------------------------- /examples/max46: -------------------------------------------------------------------------------- 1 | .i 9 2 | .o 1 3 | .p 46 4 | -10000000 1 5 | 101111001 1 6 | 011111001 1 7 | 010111000 1 8 | 000111001 1 9 | 100110000 1 10 | 011101000 1 11 | 101011000 1 12 | 110110100 1 13 | 0-1011100 1 14 | 101-10010 1 15 | 01-111110 1 16 | 0-1010001 1 17 | 110101001 1 18 | 1001-0101 1 19 | 011101101 1 20 | 011110011 1 21 | 100111011 1 22 | 110-00000 1 23 | 010110010 1 24 | -01100101 1 25 | 101101011 1 26 | 001110111 1 27 | 11-000000 1 28 | 010100100 1 29 | 1000-0100 1 30 | 101001100 1 31 | 011100010 1 32 | 100101010 1 33 | -00011010 1 34 | 101011110 1 35 | 101000001 1 36 | 100001001 1 37 | 111100011 1 38 | 0-0101011 1 39 | 001101111 1 40 | 01001-110 1 41 | 011000101 1 42 | 011001011 1 43 | 011010111 1 44 | 1000-1111 1 45 | 111001110 1 46 | 1100-0111 1 47 | -01000110 1 48 | -1000-111 1 49 | 00-000110 1 50 | .e 51 | -------------------------------------------------------------------------------- /espresso-src/sminterf.c: -------------------------------------------------------------------------------- 1 | #include "espresso.h" 2 | 3 | 4 | pset 5 | do_sm_minimum_cover(pset_family A) 6 | { 7 | sm_matrix *M; 8 | sm_row *sparse_cover; 9 | sm_element *pe; 10 | pset cover; 11 | register int i, base, rownum; 12 | register unsigned val; 13 | register pset last, p; 14 | 15 | M = sm_alloc(); 16 | rownum = 0; 17 | foreach_set(A, last, p) { 18 | foreach_set_element(p, i, val, base) { 19 | (void) sm_insert(M, rownum, base); 20 | } 21 | rownum++; 22 | } 23 | 24 | sparse_cover = sm_minimum_cover(M, NIL(int), 1, 0); 25 | sm_free(M); 26 | 27 | cover = set_new(A->sf_size); 28 | sm_foreach_row_element(sparse_cover, pe) { 29 | set_insert(cover, pe->col_num); 30 | } 31 | sm_row_free(sparse_cover); 32 | 33 | return cover; 34 | } 35 | -------------------------------------------------------------------------------- /espresso-src/COPYING: -------------------------------------------------------------------------------- 1 | /* Oct Tools Distribution 3.0 2 | * 3 | * Copyright (c) 1988, 1989, Regents of the University of California. 4 | * All rights reserved. 5 | * 6 | * Use and copying of this software and preparation of derivative works 7 | * based upon this software are permitted. However, any distribution of 8 | * this software or derivative works must include the above copyright 9 | * notice. 10 | * 11 | * This software is made available AS IS, and neither the Electronics 12 | * Research Laboratory or the University of California make any 13 | * warranty about the software, its performance or its conformity to 14 | * any specification. 15 | * 16 | * Suggestions, comments, or improvements are welcome and should be 17 | * addressed to: 18 | * 19 | * octtools@eros.berkeley.edu 20 | * ..!ucbvax!eros!octtools 21 | */ 22 | -------------------------------------------------------------------------------- /tlex/misex1.pla: -------------------------------------------------------------------------------- 1 | 2 | .i 8 3 | .o 7 4 | .ilb dmpst3 dmpst2 dmpst1 dmpst0 xskip yskip page rmwB 5 | .ob dmnst3B dmnst2B dmnst1B dmnst0B adctlp2B adctlp1B adctlp0B 6 | .p 32 7 | 0111---- 1000000 8 | 1010---- 1000000 9 | 010----- 0100000 10 | 0011---- 0100000 11 | 1001---- 0100000 12 | 001--1-- 0100000 13 | 0-00--1- 0100000 14 | 01-1---- 0010000 15 | 1001---- 0010000 16 | 010-1--- 0010000 17 | 0010-0-- 0010000 18 | 0000--0- 0010000 19 | 1010---- 0001000 20 | -010-0-- 0001000 21 | 010----0 0001000 22 | 01000--- 0001000 23 | 010----- 0000100 24 | 0-11---- 0000100 25 | -010---- 0000100 26 | 0-00---- 0000100 27 | 1001---- 0000100 28 | 010----- 0000010 29 | 0-11---- 0000010 30 | 1001---- 0000010 31 | 1010---- 0000010 32 | 001--1-- 0000010 33 | 0-00--1- 0000010 34 | 01-1---- 0000001 35 | 1001---- 0000001 36 | 1010---- 0000001 37 | 010-0--- 0000001 38 | -010-0-- 0000001 39 | .e 40 | -------------------------------------------------------------------------------- /examples/newtpla: -------------------------------------------------------------------------------- 1 | .i 15 2 | .o 5 3 | .ilb tagcompare tCPIPE1s<0> tCPIPE1s<1> tCPIPE1s<2> tCPIPE1s<3> tCPIPE1s<4> tCPIPE1s<5> tCPIPE1s<7> tbusA<31> tbusB<31> tbusB<30> tbusB<29> tbusB<28> tCPIPE1s<6> tCPIPE1s<8> 4 | .ob GStrap trapinstr TAGtrap pov_unflow skipCONDenable 5 | .p 23 6 | --001011-0---10 00100 7 | -0-0-011-0---10 00100 8 | --0010111----1- 00100 9 | -0-0-0111----1- 00100 10 | ----0101-0---10 00100 11 | -00011010----1- 00100 12 | -0001101-00001- 10000 13 | 00001101-----1- 10000 14 | --1-0101------- 01000 15 | --0111010----11 00100 16 | --01110101---1- 00100 17 | ----01011----1- 00100 18 | --110011-0---10 00100 19 | ---10101------- 01000 20 | ----10011----1- 10000 21 | --01-10110---10 00100 22 | --1100111----1- 00100 23 | -0--0011-0---10 00100 24 | -1--0101------- 01000 25 | -0--00111----1- 00100 26 | -0000101------- 00001 27 | --001011-----1- 00010 28 | -0-01011-----1- 00010 29 | .e 30 | -------------------------------------------------------------------------------- /examples/br1: -------------------------------------------------------------------------------- 1 | .i 12 2 | .o 8 3 | 110001000100 10101101 4 | 110001000110 10101101 5 | 110001011100 10001110 6 | 110001011101 01000000 7 | 110001011110 10001000 8 | 110001011111 01000100 9 | 110011000100 10101011 10 | 110011000110 10101011 11 | 110011011100 10001100 12 | 110011011101 10110000 13 | 110101000100 10101001 14 | 110101000110 10101001 15 | 110111000100 10100111 16 | 110111000110 10100111 17 | 110111011100 10001100 18 | 110111011101 10110000 19 | 111001000100 10100101 20 | 111001000110 10100101 21 | 111001011100 10000010 22 | 111001011110 10000010 23 | 111010111100 10110000 24 | 111011000100 10100011 25 | 111011000110 10100011 26 | 111101000100 10100000 27 | 111101000100 10100000 28 | 111101011100 10001110 29 | 111101011110 10001110 30 | 111110111100 01000000 31 | 111110111110 01000100 32 | 111111010000 10101111 33 | 111111010010 10101111 34 | 111111010100 10000110 35 | 111111010110 10000110 36 | 111111111100 01000000 37 | -------------------------------------------------------------------------------- /examples/br2: -------------------------------------------------------------------------------- 1 | .i 12 2 | .o 8 3 | 100001001100 11000101 4 | 100001001110 11000101 5 | 100011001100 11000011 6 | 100011001110 11000011 7 | 100101001100 11000001 8 | 100101001110 11000001 9 | 100111001100 11001111 10 | 100111001110 11001111 11 | 101001001100 11001101 12 | 101001001110 11001101 13 | 101001111100 10001010 14 | 101001111101 10001010 15 | 101001111110 10001010 16 | 101001111111 10001010 17 | 101011001100 11001011 18 | 101011001110 11001011 19 | 101101001100 11001001 20 | 101101001110 11001001 21 | 101101111100 10001000 22 | 101101111101 10001000 23 | 101101111110 10001000 24 | 101101111111 10001000 25 | 101110110100 10001110 26 | 101110110101 10001110 27 | 101110110110 10001110 28 | 101110110111 10001110 29 | 101111001100 11001000 30 | 101111001110 11001000 31 | 101111011100 11001000 32 | 101111011110 11001000 33 | 101111011101 10111000 34 | 101111110000 00101000 35 | 101111110001 00101000 36 | 101111111100 10001000 37 | 101111111110 11000111 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # espresso-logic-minimizer 2 | 3 | A modern (2017) compiliable re-host of the [Espresso heuristic logic minimizer](https://en.wikipedia.org/wiki/Espresso_heuristic_logic_minimizer). 4 | 5 | The original source code comes from the [University of California, Berkeley](https://embedded.eecs.berkeley.edu/pubs/downloads/espresso/index.htm). 6 | 7 | ## Install 8 | 9 | ``` 10 | $ cd espresso-src 11 | $ make 12 | ``` 13 | 14 | The espresso executable will be located in the `bin` directory. Manual pages are available in the `man` directory. Copy these files to your desired location. 15 | 16 | ### Package Availability 17 | This package is [available](https://aur.archlinux.org/packages/espresso-logic/) on the Arch User Repository. 18 | 19 | If you would like to package it for your preferred distribution, you can submit a PR to have it listed here. 20 | 21 | ## License 22 | 23 | This is published under the [MIT License](https://opensource.org/licenses/MIT). 24 | -------------------------------------------------------------------------------- /espresso-src/copyright.h: -------------------------------------------------------------------------------- 1 | #ifndef OCTTOOLS_COPYRIGHT_H 2 | #define OCTTOOLS_COPYRIGHT_H 3 | /* 4 | * Oct Tools Distribution 3.0 5 | * 6 | * Copyright (c) 1988, 1989, Regents of the University of California. 7 | * All rights reserved. 8 | * 9 | * Use and copying of this software and preparation of derivative works 10 | * based upon this software are permitted. However, any distribution of 11 | * this software or derivative works must include the above copyright 12 | * notice. 13 | * 14 | * This software is made available AS IS, and neither the Electronics 15 | * Research Laboratory or the University of California make any 16 | * warranty about the software, its performance or its conformity to 17 | * any specification. 18 | * 19 | * Suggestions, comments, or improvements are welcome and should be 20 | * addressed to: 21 | * 22 | * octtools@eros.berkeley.edu 23 | * ..!ucbvax!eros!octtools 24 | */ 25 | 26 | static char octtools_copyright[] = "Copyright (c) 1988, 1989, Regents of the University of California. All rights reserved."; 27 | #endif 28 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '4' 4 | addons: 5 | apt: 6 | sources: 7 | - ubuntu-toolchain-r-test 8 | packages: 9 | - gcc-4.9 10 | - g++-4.9 11 | before_install: 12 | - export CC="gcc-4.9" CXX="g++-4.9" 13 | deploy: 14 | provider: npm 15 | email: seb.cottinet@gmail.com 16 | api_key: 17 | secure: nX8I/CUpjtHv3snTy+GlncOwCdM/vQQm68S+lgPkjOxFzG3XlehPIQbpQjbKfGtkI/l/MT4DbRyhRsRFy1nkAGWqS9ufSB6VzFPstXKgYwyAs15ufXtXF6Zf2qQRA+n6SmnJKMa5wPBKJWIzY29/ud7X9X35DPXbxVqLTBkFxGmpstLkwJx4h7sB/0vU86/lFFWTD+0/oqpxfQtIn9pYRSyFTUwEnUvJAhAcJL/56g3ynn4g/qUMgbGFy7IgYCiLrM7MZItT2FhExQnc32ZKtERdUjYsQH18XD/rEbrcIDJRQHBE9MJQUmyRbF4MBXRokWG8VffIgQMFmauPIW1uu+zuan/fZLXZPp5JHBlAPktT7Ia5XOOnqLtINCwIT6RCeJASLuz0jL/CPVZ3T1z6tVp8owYVVJ8kEj8B14T01yvz3oGd7A6sNRFMLadQ/4q9rjS+GAs59iFdOv/L4WVjsxoX7v+c/SzInkwJRj+tpM/gqYas7+pEUujGJGUwd70sqFBhr4iuCuOY3zdF4CV4RhPgiPFtj5+Vn8JcCZTF/Vx8n8FDJ8RhvwSy8RWy6Ymt6tbOomxrqIdKdxCJBCjtvEPO+pIniz9nrIgnes+HquWbuXks3u0zauno5pohV/WZqSdlpYTudm2Xe0YCMUkQx2suveBIxpjXdwyZaFO28P4= 18 | on: 19 | repo: scottinet/espresso-logic-minimizer 20 | branch: master 21 | -------------------------------------------------------------------------------- /examples/tms: -------------------------------------------------------------------------------- 1 | .i 8 2 | .o 16 3 | 00000010 0010101111101001# ynea 4 | 00000011 1011111111001000# tam 5 | 00000100 1011111111001100# tamza 6 | 00000110 0001101111011100# a6aac 7 | 00000111 0001101111010100# dan 8 | 00000201 0001101111011100# a8/10aac 9 | 00001000 0001111111001100# tka 10 | 00001001 0001111111101000# knez 11 | 00001110 0011101111000100# ia 12 | 00100000 1010111111000010# tamiy 13 | 00100001 0011011111001100# tma 14 | 00100010 0011011111001010# tmy 15 | 00100011 0010111111001100# tya 16 | 00100100 0011101111001010# tay 17 | 00100101 0011001111011100# amaac 18 | 00100110 0011011111101000# mnez 19 | 00100111 0011010111010100# saman 20 | 00101000 0011011111010100# imac 21 | 00101001 0011010111010000# alem 22 | 00101010 0011011101011100# dman 23 | 00101011 0010111111010010# iyc 24 | 00101100 0010111101011010# dyn 25 | 00101101 0011110111010100# cpaiz 26 | 00101110 1011011111001100# xma 27 | 00101111 0011111111001100# cla 28 | 00111022 0001011110101000# tbit1 29 | 01002222 0001111111001010# tcy 30 | 01012222 0010111110101000# ynec 31 | 01102222 0110111111000010# tcmiy 32 | 01112222 0001110111010000# alec 33 | -------------------------------------------------------------------------------- /espresso-src/utility.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILITY_H 2 | #define UTILITY_H 3 | 4 | /* 5 | * assumes the memory manager is libmm.a 6 | * - allows malloc(0) or realloc(obj, 0) 7 | * - catches out of memory (and calls MMout_of_memory()) 8 | * - catch free(0) and realloc(0, size) in the macros 9 | */ 10 | #define NIL(type) ((type *) 0) 11 | #define ALLOC(type, num) \ 12 | ((type *) malloc(sizeof(type) * (num))) 13 | #define REALLOC(type, obj, num) \ 14 | (obj) ? ((type *) realloc((char *) obj, sizeof(type) * (num))) : \ 15 | ((type *) malloc(sizeof(type) * (num))) 16 | #define FREE(obj) \ 17 | if ((obj)) { (void) free((char *) (obj)); (obj) = 0; } 18 | 19 | extern long util_cpu_time(void); 20 | extern char *util_print_time (long t); 21 | 22 | #ifndef NIL_FN 23 | #define NIL_FN(type) ((type (*)()) 0) 24 | #endif /* NIL_FN */ 25 | 26 | #ifndef MAX 27 | #define MAX(a,b) ((a) > (b) ? (a) : (b)) 28 | #endif /* MAX */ 29 | #ifndef MIN 30 | #define MIN(a,b) ((a) < (b) ? (a) : (b)) 31 | #endif /* MIN */ 32 | #ifndef ABS 33 | #define ABS(a) ((a) > 0 ? (a) : -(a)) 34 | #endif /* ABS */ 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /examples/luc: -------------------------------------------------------------------------------- 1 | .i 8 2 | .o 27 3 | 000011-- 000000001111100000011100001 4 | 000010-- 000000000111111011101010001 5 | 000001-- 000000000111011011101010001 6 | 000000-- 000010000111011111101010001 7 | 00011--- 000010001111011111101010001 8 | 000101-- 001101001111111011101010001 9 | 00101--- 000111001101111001101000001 10 | 0011---- 000000101101111101110100001 11 | 0100---- 001100111111111001110100001 12 | 11001--- 010000111110111011111100101 13 | 11000-0- 000010111110111101111000101 14 | 1101--0- 000001111110111101111000001 15 | 1110110- 001111111111111001111000001 16 | 1111---- 000000011011111011001010001 17 | 100011-- 000000011111111011001010001 18 | 100010-- 000000011111101000001000001 19 | 10000--- 000010011111100000010100001 20 | 1001---1 000000001111100000010100001 21 | 11000-11 000010111110111101101000100 22 | 1101--11 000001111110111101101000000 23 | 11101110 101111111111111001101000010 24 | 11000-10 000010111110111101111001100 25 | 1101--10 000001111110111101110001000 26 | 1110111- 101111111111111001110001000 27 | -----0-- 001000000000000000000000000 28 | -----0-- 000100000000000000000000000 29 | ----11-- 000100000000000000000000000 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Sébastien Cottinet 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /tlex/sao2.pla: -------------------------------------------------------------------------------- 1 | 2 | .i 10 3 | .o 4 4 | .p 58 5 | --0-100--0 ~~11 6 | ----001-00 ~~11 7 | -0---00-10 ~~11 8 | 0-1-00---0 ~~11 9 | -1-0-0--00 ~~11 10 | 1-0--0-0-0 ~~11 11 | ---0---0-0 ~~1~ 12 | -000000100 1~~1 13 | 1111000100 ~1~~ 14 | 1101000110 ~1~~ 15 | 1011100100 ~1~~ 16 | 0101001110 ~1~~ 17 | 1111100110 ~1~~ 18 | 1111001110 ~1~~ 19 | 1111101100 ~1~~ 20 | 1101101110 ~1~~ 21 | 1011101110 ~1~~ 22 | 1010000100 ~1~1 23 | 0111101110 ~1~~ 24 | 0101101010 ~1~~ 25 | 1111101010 ~1~~ 26 | 1010101100 ~1~~ 27 | 1110101110 ~1~~ 28 | 01-1101010 1~~~ 29 | 10101011-0 1~~~ 30 | 1001000100 ~1~~ 31 | 0101000100 ~1~~ 32 | 0101000010 ~1~~ 33 | 0-01000000 1~~~ 34 | 0001000000 ~1~~ 35 | 0000000100 ~1~~ 36 | -----1---0 ~~1~ 37 | 0001000-00 1~~~ 38 | 101110-100 1~~~ 39 | 1111-00100 1~~~ 40 | ---0100--0 ~~~1 41 | 0101101-10 1~~~ 42 | -101001110 1~~~ 43 | 11-1000110 1~~~ 44 | --01-0--00 ~~~1 45 | ---100-0-0 ~~~1 46 | 0--1-00--0 ~~~1 47 | -1-0-0-0-0 ~~~1 48 | -0-100---0 ~~~1 49 | --1-00-0-0 ~~11 50 | 0---1-0--0 ~~1~ 51 | -0---0-010 ~~11 52 | 01-0-0---0 ~~11 53 | --0--01-00 ~~11 54 | -----01000 ~~11 55 | -100-0---0 ~~11 56 | 00---0--10 ~~11 57 | -0--00--10 ~~11 58 | ----1000-0 ~~11 59 | -00--0--10 ~~11 60 | 0----01-00 ~~11 61 | -1-000---0 ~~11 62 | -1-0--0--0 ~~1~ 63 | .e 64 | -------------------------------------------------------------------------------- /examples/dc2: -------------------------------------------------------------------------------- 1 | .i 8 2 | .o 7 3 | 0111000- 0000110 4 | 0111010- 0000010 5 | 0111100- 0001110 6 | 1000001- 0000010 7 | 1000011- 0000010 8 | 1001000- 0000010 9 | 1001010- 0011110 10 | 1001100- 0100010 11 | 0000001- 0000010 12 | 0001001- 0000100 13 | 0000011- 0000010 14 | 0010100- 0001100 15 | 0011011- 0000100 16 | 0001000- 0000010 17 | 0101001- 0001100 18 | 0001010- 0001110 19 | 0110100- 1000100 20 | 0111011- 0000100 21 | 0001100- 0010010 22 | 1001001- 0000100 23 | 0000100- 0001000 24 | 0010001- 0000010 25 | 0010011- 0000010 26 | 0011000- 0011110 27 | 0111001- 0001000 28 | 0011010- 0000010 29 | 1000100- 0001000 30 | 0011100- 0100110 31 | 0001011- 0010000 32 | 0100001- 0000010 33 | 0100100- 0010000 34 | 0100011- 0000010 35 | 0101000- 0000010 36 | 0011001- 0100000 37 | 0101010- 0001110 38 | 0101100- 0000010 39 | 1001011- 0100000 40 | 0110001- 0000010 41 | 0110011- 0000010 42 | 011101-- 0001000 43 | 100100-- 0011000 44 | 000001-- 0000100 45 | 001000-- 0000100 46 | 010001-- 0001100 47 | 001101-- 0100000 48 | 011000-- 0111100 49 | 011001-- 1000000 50 | 100001-- 0000100 51 | 000100-- 0001000 52 | 001001-- 0001000 53 | 010000-- 0001000 54 | 1000---- 1010000 55 | 0100---- 0100000 56 | 0111---- 1000000 57 | 1001---- 1000000 58 | 0010---- 0010000 59 | 0101---- 0110000 60 | -------1 0000001 61 | -------------------------------------------------------------------------------- /examples/dk27: -------------------------------------------------------------------------------- 1 | .i 9 2 | .o 9 3 | 001000010 100000000 4 | 000010010 100000000 5 | 100000010 001000000 6 | 000100010 001000000 7 | 010000010 000010000 8 | 000001010 000010000 9 | 000000110 000010000 10 | 100000010 000000000 11 | 010000010 000000000 12 | 000100010 000000000 13 | 000001010 000000000 14 | 000000110 000000000 15 | 001000010 000000001 16 | 000010010 000000010 17 | 001000001 010000000 18 | 000010001 010000000 19 | 000100001 001000000 20 | 000000101 001000000 21 | 100000001 000100000 22 | 010000001 000001000 23 | 000001001 000000100 24 | 100000001 000000000 25 | 010000001 000000000 26 | 000001001 000000000 27 | 001000001 000000001 28 | 000100001 000000010 29 | 000010001 000000010 30 | 000000101 000000010 31 | 11------- 222222222 32 | 1-1------ 222222222 33 | 1--1----- 222222222 34 | 1---1---- 222222222 35 | 1----1--- 222222222 36 | 1-----1-- 222222222 37 | 0000000-- 222222222 38 | -11------ 222222222 39 | -1-1----- 222222222 40 | -1--1---- 222222222 41 | -1---1--- 222222222 42 | -1----1-- 222222222 43 | --11----- 222222222 44 | --1-1---- 222222222 45 | --1--1--- 222222222 46 | --1---1-- 222222222 47 | ---11---- 222222222 48 | ---1-1--- 222222222 49 | ---1--1-- 222222222 50 | ----11--- 222222222 51 | ----1-1-- 222222222 52 | -----11-- 222222222 53 | -------11 222222222 54 | -------00 222222222 55 | -------------------------------------------------------------------------------- /tlex/9sym.pla: -------------------------------------------------------------------------------- 1 | 2 | .i 9 3 | .o 1 4 | .p 87 5 | 0-111-00- 1 6 | 01-110-0- 1 7 | 11-100-0- 1 8 | 01-101-0- 1 9 | 010--11-0 1 10 | 0-01-1-01 1 11 | -111-0-00 1 12 | 0--100-11 1 13 | -0-001-11 1 14 | --101-001 1 15 | 001-1--10 1 16 | 00-1-110- 1 17 | -101-010- 1 18 | --001-101 1 19 | 0-11-1-00 1 20 | 01-010-1- 1 21 | 10-1-010- 1 22 | 00-1-011- 1 23 | 0-11-0-10 1 24 | 1100-0--1 1 25 | 01--100-1 1 26 | 11-010--0 1 27 | 00-101-1- 1 28 | -001--101 1 29 | -110-00-1 1 30 | 10-100-1- 1 31 | 1--11000- 1 32 | -10--0011 1 33 | 11-000-1- 1 34 | 100--0-11 1 35 | 10-101-0- 1 36 | -0-11-001 1 37 | 0100--1-1 1 38 | 01--010-1 1 39 | 1-010--01 1 40 | -010--101 1 41 | -101--010 1 42 | 0--11-010 1 43 | 11--0100- 1 44 | 00-011-1- 1 45 | 010-101-- 1 46 | --0111-00 1 47 | -0-1101-0 1 48 | 1-001-1-0 1 49 | -11--0010 1 50 | 001---011 1 51 | -011--100 1 52 | -11-010-0 1 53 | 1-110--00 1 54 | -0--10011 1 55 | -10--0110 1 56 | -0-0111-0 1 57 | 1010-10-- 1 58 | 101---010 1 59 | 11100---0 1 60 | -10001-1- 1 61 | 100011--- 1 62 | 1--0010-1 1 63 | 1-0-1-001 1 64 | 0-0-011-1 1 65 | 1-0-001-1 1 66 | 01101-0-- 1 67 | 0-0-110-1 1 68 | -010-011- 1 69 | 1--00110- 1 70 | 01100-1-- 1 71 | 1-1-000-1 1 72 | 000-1-11- 1 73 | -100110-- 1 74 | 10--0-110 1 75 | 110-0-1-0 1 76 | 1-1-001-0 1 77 | 100-1-01- 1 78 | --10110-0 1 79 | -01-0101- 1 80 | 0-1-011-0 1 81 | -00-0-111 1 82 | -00--1110 1 83 | --101-100 1 84 | 1-1-1-000 1 85 | 1-0-0101- 1 86 | -110-0-01 1 87 | 01-1-0-01 1 88 | -011-0-01 1 89 | 0-1--1001 1 90 | 01-0-1-10 1 91 | 01-011-0- 1 92 | .e 93 | -------------------------------------------------------------------------------- /examples/newcpla1: -------------------------------------------------------------------------------- 1 | .i 9 2 | .o 16 3 | .ilb WAIT CPIPE1s<0> CPIPE1s<1> CPIPE1s<2> CPIPE1s<3> CPIPE1s<4> CPIPE1s<5> CPIPE1s<7> RESET 4 | .ob changeCWP2t trap lastPCload pDATABUSintoLOADL enableINTS1 changeCWP1 PCtoMAL1 pALUtoMAL pPCIncr pALUtoPC DST2step1 PCstuffoncall1 SRC2smin1 DST1min1 CPIPE1flush CPIPE1load1 5 | .p 38 6 | 0---100-0 0000000001000000 7 | 0-0010110 0000000010000000 8 | 00-100-10 0000000010000000 9 | 00---0110 0000000010000000 10 | 0-1100110 0000000010000000 11 | 0---01010 0000000010000001 12 | 0-1-0111- 0001000100000100 13 | 01--0111- 0001000000000100 14 | 0000--110 0000000010000000 15 | 0--10111- 0011000100100100 16 | 0------00 0000000001000001 17 | 0-010-010 0000000010000000 18 | 0-----00- 0011010100010000 19 | 01--1001- 1000000100000000 20 | 001011-1- 0000000000001000 21 | 0-----10- 0011000100100000 22 | 0--11111- 0010000100101000 23 | 00---011- 0000001000000000 24 | 0000--11- 0001001000000000 25 | 0-001011- 0000001000000000 26 | 0---0101- 0011001000100000 27 | 0-110011- 0000001000000000 28 | 00-100-1- 0010001000100000 29 | 0-1-1111- 0000000100001000 30 | 0-011-01- 0011000100100000 31 | 0-11--01- 0011000000100000 32 | 01---11-- 0000000100000000 33 | 0-----1-- 0010000000100000 34 | 00--1-0-- 0000000100000000 35 | 0----0--0 0000000000000001 36 | 01----0-- 0001000000000000 37 | 0--0---1- 0010000000100000 38 | -101-0010 0000000000000010 39 | 0-----0-0 0000000000000001 40 | ---11001- 0000100000000000 41 | -1010001- 0100000000000000 42 | 0----0--- 0001000000000000 43 | ----10010 0000000000000010 44 | .e 45 | -------------------------------------------------------------------------------- /examples/sqr6: -------------------------------------------------------------------------------- 1 | .i 6 2 | .o 12 3 | 000000 000000000000 4 | 000001 000000000001 5 | 000010 000000000100 6 | 000011 000000001001 7 | 000100 000000010000 8 | 000101 000000011001 9 | 000110 000000100100 10 | 000111 000000110001 11 | 001000 000001000000 12 | 001001 000001010001 13 | 001010 000001100100 14 | 001011 000001111001 15 | 001100 000010010000 16 | 001101 000010101001 17 | 001110 000011000100 18 | 001111 000011100001 19 | 010000 000100000000 20 | 010001 000100100001 21 | 010010 000101000100 22 | 010011 000101101001 23 | 010100 000110010000 24 | 010101 000110111001 25 | 010110 000111100100 26 | 010111 001000010001 27 | 011000 001001000000 28 | 011001 001001110001 29 | 011010 001010100100 30 | 011011 001011011001 31 | 011100 001100010000 32 | 011101 001101001001 33 | 011110 001110000100 34 | 011111 001111000001 35 | 100000 010000000000 36 | 100001 010001000001 37 | 100010 010010000100 38 | 100011 010011001001 39 | 100100 010100010000 40 | 100101 010101011001 41 | 100110 010110100100 42 | 100111 010111110001 43 | 101000 011001000000 44 | 101001 011010010001 45 | 101010 011011100100 46 | 101011 011100111001 47 | 101100 011110010000 48 | 101101 011111101001 49 | 101110 100001000100 50 | 101111 100010100001 51 | 110000 100100000000 52 | 110001 100101100001 53 | 110010 100111000100 54 | 110011 101000101001 55 | 110100 101010010000 56 | 110101 101011111001 57 | 110110 101101100100 58 | 110111 101111010001 59 | 111000 110001000000 60 | 111001 110010110001 61 | 111010 110100100100 62 | 111011 110110011001 63 | 111100 111000010000 64 | 111101 111010001001 65 | 111110 111100000100 66 | 111111 111110000001 67 | -------------------------------------------------------------------------------- /tlex/misex2.pla: -------------------------------------------------------------------------------- 1 | 2 | .i 25 3 | .o 18 4 | .ilb a b c d e f g h i j k l m n o p q r s t u v w x y 5 | .ob z a1 b1 c1 d1 e1 f1 g1 h1 i1 j1 k1 l1 m1 n1 o1 p1 q1 6 | .p 29 7 | 000------01------000----- 100000000000000000 8 | 000------11------000----- 010000000000000000 9 | 000------10------000----- 001000000000000000 10 | 000--------------010----- 000100000000000000 11 | 111------0111------------ 000100000000000000 12 | 111------0100------------ 000010000000000000 13 | 111------11-------------- 000001000000000000 14 | 111------011------------- 000000100000000000 15 | 101---------------------- 000000010000000000 16 | 1-1------0110------------ 000000010000000000 17 | 001010000--------101----- 000000001000000000 18 | 01----------------10000-- 000000000100000000 19 | 001--------010000---100-- 000000000100000000 20 | 01----------------10011-- 000000000010000000 21 | 001--------010011---100-- 000000000010000000 22 | 01----------------10010-- 000000000001000000 23 | 001--------010010---100-- 000000000001000000 24 | 110------1--------------0 000000000000100000 25 | 11-------10-------------0 000000000000100000 26 | 001------1-------------10 000000000000100000 27 | 00-------1---------1---10 000000000000100000 28 | 000------1-------1-0----0 000000000000100000 29 | 000--------------1-0----- 000000000000010000 30 | 000------00------000----- 000000000000001000 31 | 1-0---------------------- 000000000000000100 32 | 11--------0-------------- 000000000000000100 33 | -00----------------1----- 000000000000000100 34 | 01----------------------- 000000000000000010 35 | 001---------------------- 000000000000000001 36 | .e 37 | -------------------------------------------------------------------------------- /espresso-src/canonical.c: -------------------------------------------------------------------------------- 1 | /* Module:canonical.c 2 | * contains routines for finding the canonical cover of the 3 | * incompletely specified logic function. 4 | * Routine: 5 | * pcover find_canonical_cover(): 6 | * Finds canonical cover of the incompletely specified logic function 7 | * by iteratively calling ess_test_and_reduction for each cube in the 8 | * ON-set. 9 | */ 10 | 11 | #include 12 | #include "espresso.h" 13 | #include "signature.h" 14 | 15 | /* 16 | * find_canonical_cover 17 | * Objective: find canonical cover of the essential signature cube 18 | * Input: 19 | * F: ONSET cover; 20 | * D: DC cover; 21 | * R: OFFSET cover; 22 | * Output: 23 | * Return canonical cover of the essential signature cube 24 | */ 25 | pcover find_canonical_cover(pset_family F1, pset_family D, pset_family R) 26 | { 27 | pcover F; 28 | pcover E,ESC; 29 | pcover COVER; 30 | pcube c; 31 | pcube d, *extended_dc; 32 | 33 | F = sf_save(F1); 34 | E = new_cover(D->count); 35 | E->count = D->count; 36 | sf_copy(E,D); 37 | 38 | ESC = new_cover(F->count); 39 | 40 | while(F->count){ 41 | c = GETSET(F,--F->count); 42 | RESET(c,NONESSEN); 43 | extended_dc = cube2list(E,F); 44 | d = reduce_cube(extended_dc,c); 45 | free_cubelist(extended_dc); 46 | if(setp_empty(d)){ 47 | free_cube(d); 48 | continue; 49 | } 50 | c = get_sigma(R,d); 51 | S_EXECUTE(COVER = etr_order(F,E,R,c,d),ETR_TIME); 52 | free_cube(d); 53 | if(TESTP(c,NONESSEN)){ 54 | sf_append(F,COVER); 55 | } 56 | else{ 57 | free_cover(COVER); 58 | sf_addset(E,c); 59 | sf_addset(ESC,c); 60 | } 61 | free_cube(c); 62 | } 63 | free_cover(F); 64 | free_cover(E); 65 | 66 | return ESC; 67 | } 68 | -------------------------------------------------------------------------------- /examples/sqn: -------------------------------------------------------------------------------- 1 | .i 7 2 | .o 3 3 | 0001100 010 4 | 0001101 000 5 | 0001110 000 6 | 0001111 000 7 | 0001000 011 8 | 0001001 001 9 | 0001010 000 10 | 0001011 000 11 | 0011100 100 12 | 0011101 000 13 | 0011110 000 14 | 0011111 001 15 | 0000100 101 16 | 0000101 000 17 | 0000110 001 18 | 0000111 001 19 | 0011000 110 20 | 0011001 001 21 | 0011010 001 22 | 0011011 000 23 | 0010100 111 24 | 0010101 001 25 | 0010110 001 26 | 0010111 001 27 | 0101100 010 28 | 0101101 000 29 | 0101110 010 30 | 0101111 010 31 | 0101000 011 32 | 0101001 001 33 | 0101010 010 34 | 0101011 010 35 | 0111100 010 36 | 0111101 100 37 | 0111110 010 38 | 0111111 011 39 | 0100000 010 40 | 0100001 101 41 | 0100010 011 42 | 0100011 011 43 | 0111000 011 44 | 0111001 110 45 | 0111010 011 46 | 0111011 010 47 | 0110000 011 48 | 0110001 111 49 | 0110010 011 50 | 0110011 011 51 | 1001100 100 52 | 1001101 100 53 | 1001110 000 54 | 1001111 100 55 | 1000100 101 56 | 1000101 100 57 | 1000110 001 58 | 1000111 100 59 | 1011100 100 60 | 1011101 100 61 | 1011110 010 62 | 1011111 101 63 | 1000000 100 64 | 1000001 101 65 | 1000010 011 66 | 1000011 101 67 | 1010100 101 68 | 1010101 101 69 | 1010110 110 70 | 1010111 100 71 | 1010000 101 72 | 1010001 101 73 | 1010010 111 74 | 1010011 101 75 | 1101000 110 76 | 1101001 110 77 | 1101010 110 78 | 1101011 000 79 | 1100100 111 80 | 1100101 110 81 | 1100110 110 82 | 1100111 001 83 | 1111000 110 84 | 1111001 110 85 | 1111010 111 86 | 1111011 010 87 | 1100000 110 88 | 1100001 111 89 | 1100010 111 90 | 1100011 011 91 | 1110100 111 92 | 1110101 111 93 | 1110110 110 94 | 1110111 100 95 | 1110000 111 96 | 1110001 111 97 | 1110010 111 98 | 1110011 101 99 | -------------------------------------------------------------------------------- /examples/alu3: -------------------------------------------------------------------------------- 1 | .i 10 2 | .o 8 3 | 0000-1--10 00010000 4 | 000-11-100 00010000 5 | 00-1111000 00010000 6 | 0-0000---- 00010000 7 | 0-000----1 00010000 8 | 0-0------- 10000000 9 | 0--0--0--- 01000000 10 | 0---1-000- 00100000 11 | 0----10000 00000100 12 | 0-----01-- 01000000 13 | 0-----1--- 10000000 14 | 10110----- 00100000 15 | 101110---- 00000100 16 | 1011110000 00010000 17 | 10111----1 00000100 18 | 1011---0-- 01000000 19 | 1011----1- 00100000 20 | 101---0--- 10000000 21 | 1-1111---- 00001000 22 | -0-10-1--- 00100000 23 | -0-1101--- 00000100 24 | -0-11-1--1 00000100 25 | -0-1--10-- 01000000 26 | -0-1--1-1- 00100000 27 | -0--0--1-- 00100000 28 | -0--10-1-- 00000100 29 | -0--1--1-1 00000100 30 | -0---0--1- 00000100 31 | -0-----11- 00100000 32 | -0------11 00000100 33 | -10000---- 00010000 34 | -1000----1 00010000 35 | -100-0--1- 00010000 36 | -100----11 00010000 37 | -10-00-1-- 00010000 38 | -10-0--1-1 00010000 39 | -10--0-11- 00010000 40 | -10----111 00010000 41 | -10------- 10000000 42 | -1-0001--- 00010000 43 | -1-00-1--1 00010000 44 | -1-0-01-1- 00010000 45 | -1-0--1-11 00010000 46 | -1-0------ 01000000 47 | -1--0011-- 00010000 48 | -1--0-11-1 00010000 49 | -1--1---0- 00100000 50 | -1---0111- 00010000 51 | -1---1---0 00000100 52 | -1----1111 00010000 53 | -1----1--- 10000000 54 | -1-----1-- 01000000 55 | --00------ 01000000 56 | --0-1--00- 00100000 57 | --0--1-000 00000100 58 | --0---1--- 22222222 59 | --0----1-- 01000000 60 | --1111---- 00000001 61 | ---01---0- 00100000 62 | ---0-1--00 00000100 63 | ---0---1-- 22222222 64 | ---0----00 00000010 65 | ---1111--- 00001000 66 | ----01---0 00000100 67 | ----0---1- 22222222 68 | ----0----0 00000010 69 | ----11-1-- 00001000 70 | -----0---1 22222222 71 | -----0---- 00000010 72 | -----1--1- 00001000 73 | ------0000 00000010 74 | ---------1 00001000 75 | -------------------------------------------------------------------------------- /tlex/5xp1.pla: -------------------------------------------------------------------------------- 1 | 2 | .i 7 3 | .o 10 4 | .p 75 5 | ---0--- ~~~~~~~~1~ 6 | ----10- 1~~~~~~~~~ 7 | ----010 ~1~~~~~~~~ 8 | ----101 ~1~~~~~~~~ 9 | 1---010 ~~1~~~~~~~ 10 | 01---01 ~~~1~~~~~~ 11 | -00---1 ~~~~1~~~~~ 12 | -011--0 ~~~~1~~~~~ 13 | -100--0 ~~~~1~~~~~ 14 | 0-10--- ~~~~~1~~~~ 15 | 1-11--- ~~~~~1~~~~ 16 | 0101--- ~~~~~1~~~~ 17 | 1-00--- ~~~~~1~~~~ 18 | 100---- ~~~~~1~~~~ 19 | -001--- ~~~~~~1~~~ 20 | -1-0--- ~~~~~~1~~~ 21 | -11---- ~~~~~~1~~~ 22 | --01--- ~~~~~~~1~~ 23 | --10--- ~~~~~~~1~~ 24 | ----111 ~~~~~~~~~1 25 | 1---11- ~~~~~~~~~1 26 | 00--1-0 1~~~~~~~~~ 27 | 1---011 1~~~~~~~~~ 28 | -1--011 1~~~~~~~~~ 29 | 11---01 ~1~~~~~~~~ 30 | 1-1--01 ~1~~~~~~~~ 31 | 111-10- ~1~~~~~~~~ 32 | 11-110- ~1~~~~~~~~ 33 | 00---10 ~1~~~~~~~~ 34 | 0---001 ~~1~~~~~~~ 35 | -00-001 ~~1~~~~~~~ 36 | 111-0-0 ~~1~~~~~~~ 37 | 11-10-0 ~~1~~~~~~~ 38 | 0---100 ~~1~~~~~~~ 39 | -0--100 ~~1~~~~~~~ 40 | --00100 ~~1~~~~~~~ 41 | -111010 ~~1~~~~~~~ 42 | 00---10 ~~~1~~~~~~ 43 | 100--0- ~~~1~~~~~~ 44 | 0-11-01 ~~~1~~~~~~ 45 | 0111-0- ~~~1~~~~~~ 46 | 1-00-00 ~~~1~~~~~~ 47 | 111--1- ~~~1~~~~~~ 48 | 11-1-1- ~~~1~~~~~~ 49 | 00-0--1 ~~~~1~~~~~ 50 | -111--1 ~~~~1~~~~~ 51 | 111---1 ~~~~1~~~~~ 52 | 11-1--1 ~~~~1~~~~~ 53 | 101---0 ~~~~1~~~~~ 54 | -11111- ~~~~~~~~~1 55 | 0--01-0 1~~~~~~~~~ 56 | 0-0-1-0 1~~~~~~~~~ 57 | --11011 1~~~~~~~~~ 58 | 00-001- ~1~~~~~~~~ 59 | 000-01- ~1~~~~~~~~ 60 | 0--0-10 ~1~~~~~~~~ 61 | 0-0--10 ~1~~~~~~~~ 62 | 00-00-1 ~~1~~~~~~~ 63 | 000-0-1 ~~1~~~~~~~ 64 | 1---111 ~~1~~~~~~~ 65 | -1--111 ~~1~~~~~~~ 66 | 001111- ~~1~~~~~~~ 67 | 0--01-0 ~~1~~~~~~~ 68 | 0-0-1-0 ~~1~~~~~~~ 69 | 11--1-1 ~~1~~~~~~~ 70 | 1-1-1-1 ~~1~~~~~~~ 71 | 0--0-10 ~~~1~~~~~~ 72 | 0-0--10 ~~~1~~~~~~ 73 | 10---00 ~~~1~~~~~~ 74 | 00-0-1- ~~~1~~~~~~ 75 | 000--1- ~~~1~~~~~~ 76 | 11---11 ~~~1~~~~~~ 77 | 1-1--11 ~~~1~~~~~~ 78 | 01-0--0 ~~~~1~~~~~ 79 | 010---0 ~~~~1~~~~~ 80 | .e 81 | -------------------------------------------------------------------------------- /espresso-src/mincov_int.h: -------------------------------------------------------------------------------- 1 | #include "port.h" 2 | #include "utility.h" 3 | #include "sparse.h" 4 | #include "mincov.h" 5 | 6 | 7 | typedef struct stats_struct stats_t; 8 | struct stats_struct { 9 | int debug; /* 1 if debugging is enabled */ 10 | int max_print_depth; /* dump stats for levels up to this level */ 11 | int max_depth; /* deepest the recursion has gone */ 12 | int nodes; /* total nodes visited */ 13 | int component; /* currently solving a component */ 14 | int comp_count; /* number of components detected */ 15 | int gimpel_count; /* number of times Gimpel reduction applied */ 16 | int gimpel; /* currently inside Gimpel reduction */ 17 | long start_time; /* cpu time when the covering started */ 18 | int no_branching; 19 | int lower_bound; 20 | }; 21 | 22 | 23 | 24 | typedef struct solution_struct solution_t; 25 | struct solution_struct { 26 | sm_row *row; 27 | int cost; 28 | }; 29 | 30 | 31 | extern solution_t *solution_alloc(void); 32 | extern void solution_free(solution_t *sol); 33 | extern solution_t *solution_dup(solution_t *sol); 34 | extern void solution_accept(solution_t *sol, sm_matrix *A, int *weight, int col); 35 | extern void solution_reject(solution_t *sol, sm_matrix *A, int *weight, int col); 36 | extern void solution_add(solution_t *sol, int *weight, int col); 37 | extern solution_t *solution_choose_best(solution_t *best1, solution_t *best2); 38 | 39 | extern solution_t *sm_maximal_independent_set(sm_matrix *A, int *weight); 40 | extern solution_t *sm_mincov(sm_matrix *A, solution_t *select, int *weight, int lb, int bound, int depth, stats_t *stats); 41 | extern int gimpel_reduce(sm_matrix *A, solution_t *select, int *weight, int lb, int bound, int depth, stats_t *stats, solution_t **best); 42 | 43 | 44 | #define WEIGHT(weight, col) (weight == NIL(int) ? 1 : weight[col]) 45 | -------------------------------------------------------------------------------- /espresso-src/cpu_time.c: -------------------------------------------------------------------------------- 1 | /* LINTLIBRARY */ 2 | #include "port.h" 3 | #include "utility.h" 4 | 5 | #ifdef IBM_WATC /* IBM Waterloo-C compiler (same as bsd 4.2) */ 6 | #ifndef BSD 7 | #define BSD 8 | #endif 9 | #ifndef void 10 | #define void int 11 | #endif 12 | #endif 13 | 14 | #ifdef ultrix 15 | #ifndef BSD 16 | #define BSD 17 | #endif 18 | #endif 19 | 20 | #ifdef aiws 21 | #ifndef UNIX10 22 | #define UNIX10 23 | #endif 24 | #endif 25 | 26 | #ifdef vms /* VAX/C compiler -- times() with 100 HZ clock */ 27 | #ifndef UNIX100 28 | #define UNIX100 29 | #endif 30 | #endif 31 | 32 | /* default */ 33 | #if !defined(BSD) && !defined(UNIX10) && !defined(UNIX60) && !defined(UNIX100) 34 | #define BSD 35 | #endif 36 | 37 | #ifdef BSD 38 | #include 39 | #include 40 | #endif 41 | 42 | #ifdef UNIX10 43 | #include 44 | #endif 45 | 46 | #ifdef UNIX60 47 | #include 48 | #endif 49 | 50 | #ifdef UNIX100 51 | #include 52 | #endif 53 | 54 | 55 | /* 56 | * util_cpu_time -- return a long which represents the elapsed processor 57 | * time in milliseconds since some constant reference 58 | */ 59 | long util_cpu_time(void) 60 | { 61 | long t = 0; 62 | 63 | #ifdef BSD 64 | struct rusage rusage; 65 | (void) getrusage(RUSAGE_SELF, &rusage); 66 | t = (long) rusage.ru_utime.tv_sec*1000 + rusage.ru_utime.tv_usec/1000; 67 | #endif 68 | 69 | #ifdef UNIX10 /* times() with 10 Hz resolution */ 70 | struct tms buffer; 71 | (void) times(&buffer); 72 | t = buffer.tms_utime * 100; 73 | #endif 74 | 75 | #ifdef UNIX60 /* times() with 60 Hz resolution */ 76 | struct tms buffer; 77 | times(&buffer); 78 | t = buffer.tms_utime * 16.6667; 79 | #endif 80 | 81 | #ifdef UNIX100 82 | struct tms buffer; /* times() with 100 Hz resolution */ 83 | times(&buffer); 84 | t = buffer.tms_utime * 10; 85 | #endif 86 | 87 | return t; 88 | } 89 | -------------------------------------------------------------------------------- /examples/newxcpla1: -------------------------------------------------------------------------------- 1 | .i 9 2 | .o 23 3 | .ilb CPIPE1s<0> CPIPE1s<1> CPIPE1s<2> CPIPE1s<3> CPIPE1s<4> CPIPE1s<5> CPIPE1s<7> CPIPE1s<8> RESET 4 | .ob selaluSUM aluCINbar1 aluselSR selaluAND selaluOR selaluXOR selBIbar storeSXT pbusLtoINB RD_WR predecodeEA pSTOREwrite pLOADLtobusL pSXTtobusL byteEX 5 | .p 43 6 | --------1 00000000000000000010000 7 | ---0--11- 00000000100001000000000 8 | ---1111-- 10000000000010010000000 9 | ---01---- 10000000010000010000000 10 | -----011- 00000000100001000000000 11 | 01--1-1-- 00000010000000000000000 12 | 1---111-- 00000010000000000000000 13 | --1-011-- 01000000010000001110000 14 | 0--0-0--- 00000000000000000010000 15 | 1--1-01-- 01000000000000000000000 16 | ----0-11- 00000000100001000000000 17 | --1-111-- 00000010000000000000000 18 | 000--11-- 01000000000000000010000 19 | 1--10-1-- 11000000000000010000000 20 | 1-000-1-- 11000000010000011110000 21 | -1-0-0--- 00000000000000000010000 22 | 10------- 10000000000000010000000 23 | 11--10--- 00000000000000000010000 24 | 01011-1-0 00000000000000000001000 25 | -----0--- 10000000010000011100000 26 | --0101--- 10000000010000011110000 27 | 0-01101-- 00000001000000000000000 28 | 1-0-10--- 00000000000000000010000 29 | -011101-- 01000000001000000000000 30 | 0101-11-- 00000010000000000000000 31 | 0001101-- 01000001001000000000000 32 | ------0-- 10000000110000011110000 33 | ----001-- 01000000000000000000000 34 | 0111101-0 00000000000000000000010 35 | 0110011-- 00010000000000010000000 36 | 1110011-- 00001000000000010000000 37 | -011101-0 01000000001000000000001 38 | -1-0111-0 00000000000000000000010 39 | ---0101-- 00000010000000000010000 40 | --10111-0 00000000000000000000010 41 | 0011011-- 00000000000000100000000 42 | 0001111-- 00000000000100000000000 43 | 0010011-- 00000100000000010000000 44 | 1--1111-0 00000000000000000001000 45 | 0001101-0 01000001001000000000100 46 | 0-00011-- 01100000010000011110000 47 | 1--0111-0 00000000000000000000010 48 | --11111-0 00000000000000000001000 49 | .e 50 | -------------------------------------------------------------------------------- /espresso-src/solution.c: -------------------------------------------------------------------------------- 1 | #include "mincov_int.h" 2 | 3 | 4 | solution_t * 5 | solution_alloc(void) 6 | { 7 | solution_t *sol; 8 | 9 | sol = ALLOC(solution_t, 1); 10 | sol->cost = 0; 11 | sol->row = sm_row_alloc(); 12 | return sol; 13 | } 14 | 15 | 16 | void 17 | solution_free(solution_t *sol) 18 | { 19 | sm_row_free(sol->row); 20 | FREE(sol); 21 | } 22 | 23 | 24 | solution_t * 25 | solution_dup(solution_t *sol) 26 | { 27 | solution_t *new_sol; 28 | 29 | new_sol = ALLOC(solution_t, 1); 30 | new_sol->cost = sol->cost; 31 | new_sol->row = sm_row_dup(sol->row); 32 | return new_sol; 33 | } 34 | 35 | 36 | void 37 | solution_add(solution_t *sol, int *weight, int col) 38 | { 39 | (void) sm_row_insert(sol->row, col); 40 | sol->cost += WEIGHT(weight, col); 41 | } 42 | 43 | 44 | void 45 | solution_accept(solution_t *sol, sm_matrix *A, int *weight, int col) 46 | { 47 | register sm_element *p, *pnext; 48 | sm_col *pcol; 49 | 50 | solution_add(sol, weight, col); 51 | 52 | /* delete rows covered by this column */ 53 | pcol = sm_get_col(A, col); 54 | for(p = pcol->first_row; p != 0; p = pnext) { 55 | pnext = p->next_row; /* grab it before it disappears */ 56 | sm_delrow(A, p->row_num); 57 | } 58 | } 59 | 60 | 61 | /* ARGSUSED */ 62 | void 63 | solution_reject(solution_t *sol, sm_matrix *A, int *weight, int col) 64 | { 65 | sm_delcol(A, col); 66 | } 67 | 68 | 69 | solution_t * 70 | solution_choose_best(solution_t *best1, solution_t *best2) 71 | { 72 | if (best1 != NIL(solution_t)) { 73 | if (best2 != NIL(solution_t)) { 74 | if (best1->cost <= best2->cost) { 75 | solution_free(best2); 76 | return best1; 77 | } else { 78 | solution_free(best1); 79 | return best2; 80 | } 81 | } else { 82 | return best1; 83 | } 84 | } else { 85 | if (best2 != NIL(solution_t)) { 86 | return best2; 87 | } else { 88 | return NIL(solution_t); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /espresso-src/sigma.c: -------------------------------------------------------------------------------- 1 | /* Module:sigma.c 2 | * Purpose: 3 | * Contains routines for computing the signature cube of the given cube. 4 | * Routines: 5 | * pcube get_sigma(): 6 | * Computes signature cube of the given cube d. 7 | * void set_not(): 8 | */ 9 | 10 | #include 11 | #include "espresso.h" 12 | #include "signature.h" 13 | 14 | /* 15 | * get_sigma: 16 | * Objective: computes signature cube corresponding to the cube c 17 | * Input: 18 | * R: OFFSET cover; 19 | * c: ONSET cube; 20 | * Output: 21 | * signature cube 22 | */ 23 | pcube 24 | get_sigma(pset_family R, register pset c) 25 | { 26 | pcover BB; 27 | pcube out_part_r,s; 28 | register pcube r,b; 29 | register int i; 30 | register int w, last; 31 | register unsigned int x; 32 | 33 | out_part_r = new_cube(); 34 | s = new_cube(); 35 | 36 | BB = new_cover(R->count); 37 | BB->count = R->count; 38 | /* BB = get_blocking_matrix(R,c); */ 39 | foreachi_set(R,i,r){ 40 | b = GETSET(BB,i); 41 | if ((last = cube.inword) != -1) { 42 | /* Check the partial word of binary variables */ 43 | x = r[last] & c[last]; 44 | x = ~(x | x >> 1) & cube.inmask; 45 | b[last] = r[last] & (x | x << 1); 46 | /* Check the full words of binary variables */ 47 | for(w = 1; w < last; w++) { 48 | x = r[w] & c[w]; 49 | x = ~(x | x >> 1) & DISJOINT; 50 | b[w] = r[w] & (x | x << 1); 51 | } 52 | } 53 | PUTLOOP(b,LOOP(r)); 54 | INLINEset_and(b,b,cube.binary_mask); 55 | INLINEset_and(out_part_r,cube.mv_mask,r); 56 | if(!setp_implies(out_part_r,c)){ 57 | INLINEset_or(b,b,out_part_r); 58 | } 59 | } 60 | free_cube(out_part_r); 61 | BB = unate_compl(BB); 62 | 63 | INLINEset_copy(s,cube.emptyset); 64 | foreachi_set(BB, i, b) { 65 | INLINEset_or(s,s,b); 66 | } 67 | free_cover(BB); 68 | set_not(s); 69 | return s; 70 | } 71 | 72 | 73 | /* set_not: flip 0 to 1 and 1 to 0 */ 74 | void 75 | set_not(pset c) 76 | { 77 | INLINEset_diff(c,cube.fullset,c); 78 | } 79 | 80 | -------------------------------------------------------------------------------- /espresso-src/signature_exact.c: -------------------------------------------------------------------------------- 1 | #include "espresso.h" 2 | #include "signature.h" 3 | 4 | 5 | /* 6 | * signature_minimize_exact: 7 | * What does it do: forms and solves the covering table whose rows are 8 | * essential signature cubes (ESCubes) and whose columns are 9 | * union of essential signature sets (ESSet) 10 | * Input: 11 | * ESCubes: essential signature cubes 12 | * ESSet: union of essential signature sets 13 | * Output: 14 | * COVER: exact cover 15 | */ 16 | 17 | pcover 18 | signature_minimize_exact(pset_family ESCubes, pset_family ESSet) 19 | { 20 | pcube p; 21 | sm_matrix *table; 22 | sm_row *cover; 23 | sm_element *pe; 24 | pcover COVER; 25 | int index; 26 | int *weights,heur,level; 27 | 28 | /* number ESCubes, ESSet */ 29 | foreachi_set(ESCubes,index,p){ 30 | PUTSIZE(p,index); 31 | } 32 | foreachi_set(ESSet,index,p){ 33 | PUTSIZE(p,index); 34 | } 35 | 36 | /* form the covering table */ 37 | S_EXECUTE(table = signature_form_table(ESCubes, ESSet), MINCOV_TIME); 38 | 39 | /* solve the covering problem */ 40 | weights = NIL(int); heur = FALSE; level = 0; 41 | S_EXECUTE(cover=sm_minimum_cover(table,weights,heur,level), 42 | MINCOV_TIME); 43 | 44 | /* form the cover */ 45 | COVER = new_cover(100); 46 | sm_foreach_row_element(cover, pe) { 47 | COVER = sf_addset(COVER, GETSET(ESSet, pe->col_num)); 48 | } 49 | 50 | sm_free(table); 51 | sm_row_free(cover); 52 | 53 | return COVER; 54 | } 55 | 56 | sm_matrix * 57 | signature_form_table(pset_family ESCubes, pset_family ESSet) 58 | { 59 | sm_matrix *table; 60 | int row,column; 61 | pcube c,p; 62 | int col_deleted; 63 | 64 | table = sm_alloc(); 65 | 66 | col_deleted = 0; 67 | foreachi_set(ESSet,column,p){ 68 | if(column%1000 == 0){ 69 | col_deleted += sm_col_dominance(table,NULL); 70 | } 71 | foreachi_set(ESCubes,row,c){ 72 | if(setp_implies(c,p)){ 73 | sm_insert(table,row,column); 74 | } 75 | } 76 | } 77 | col_deleted += sm_col_dominance(table,NULL); 78 | 79 | return table; 80 | } 81 | -------------------------------------------------------------------------------- /examples/alu2: -------------------------------------------------------------------------------- 1 | .i 10 2 | .o 8 3 | 0-0---0--- 10000000 4 | -10---0--- 10000000 5 | 0-1---1--- 10000000 6 | -11---1--- 10000000 7 | 101---0--- 10000000 8 | 0--0--00-- 01000000 9 | --00--00-- 01000000 10 | 0--1--01-- 01000000 11 | --01--01-- 01000000 12 | -110---0-- 01000000 13 | -111---1-- 01000000 14 | -011--10-- 01000000 15 | 1011---0-- 01000000 16 | 0---0-000- 00100000 17 | --0-0-000- 00100000 18 | 0---1-001- 00100000 19 | --0-1-001- 00100000 20 | -1110---0- 00100000 21 | -1111---1- 00100000 22 | -1-10-0-0- 00100000 23 | -1-11-0-1- 00100000 24 | --100--00- 00100000 25 | --101--01- 00100000 26 | 10111---0- 00100000 27 | -0111-1-0- 00100000 28 | -0-11-010- 00100000 29 | -100000000 00010000 30 | -101000100 00010000 31 | -110001000 00010000 32 | -111001100 00010000 33 | -100100010 00010000 34 | -101100110 00010000 35 | -110101010 00010000 36 | -111101110 00010000 37 | 0-00000000 00010000 38 | -100010001 00010000 39 | -101010101 00010000 40 | -110011001 00010000 41 | -111011101 00010000 42 | -100110011 00010000 43 | -101110111 00010000 44 | -110111011 00010000 45 | -111111111 00010000 46 | 0-00010001 00010000 47 | 0000110010 00010000 48 | 0001110100 00010000 49 | 0011111000 00010000 50 | 1011110000 00010000 51 | ---------1 00001000 52 | ----0---1- 00001000 53 | -----1--1- 00001000 54 | ---0---1-- 00001000 55 | ----11-1-- 00001000 56 | ---1111--- 00001000 57 | 1-1111---- 00001000 58 | -11110---0 00000100 59 | -11111---1 00000100 60 | -1-1100--0 00000100 61 | -1-1110--1 00000100 62 | -11-10-0-0 00000100 63 | -11-11-0-1 00000100 64 | -1--1000-0 00000100 65 | -1--1100-1 00000100 66 | 0----00000 00000100 67 | --0--00000 00000100 68 | 0----10001 00000100 69 | --0--10001 00000100 70 | --1100--00 00000100 71 | --1101--01 00000100 72 | ---1000-00 00000100 73 | ---1010-01 00000100 74 | --10-0-000 00000100 75 | --10-1-001 00000100 76 | -01-11-010 00000100 77 | -0--110010 00000100 78 | 101111---0 00000100 79 | -011111--0 00000100 80 | -0-11101-0 00000100 81 | ---110---0 00000010 82 | ----10-0-0 00000010 83 | ---0---000 00000010 84 | ------0000 00000010 85 | ---10---00 00000010 86 | --0------- 00000001 87 | ---0------ 00000001 88 | ----0----- 00000001 89 | -----0---- 00000001 90 | --0---1--- 22222222 91 | ---0---1-- 22222222 92 | ----0---1- 22222222 93 | -----0---1 22222222 94 | -------------------------------------------------------------------------------- /espresso-src/equiv.c: -------------------------------------------------------------------------------- 1 | #include "espresso.h" 2 | 3 | 4 | void find_equiv_outputs(pPLA PLA) 5 | { 6 | int i, j, ipart, jpart, some_equiv; 7 | pcover *R, *F; 8 | 9 | some_equiv = FALSE; 10 | 11 | makeup_labels(PLA); 12 | 13 | F = ALLOC(pcover, cube.part_size[cube.output]); 14 | R = ALLOC(pcover, cube.part_size[cube.output]); 15 | 16 | for(i = 0; i < cube.part_size[cube.output]; i++) { 17 | ipart = cube.first_part[cube.output] + i; 18 | R[i] = cof_output(PLA->R, ipart); 19 | F[i] = complement(cube1list(R[i])); 20 | } 21 | 22 | for(i = 0; i < cube.part_size[cube.output]-1; i++) { 23 | for(j = i+1; j < cube.part_size[cube.output]; j++) { 24 | ipart = cube.first_part[cube.output] + i; 25 | jpart = cube.first_part[cube.output] + j; 26 | 27 | if (check_equiv(F[i], F[j])) { 28 | printf("# Outputs %d and %d (%s and %s) are equivalent\n", 29 | i, j, PLA->label[ipart], PLA->label[jpart]); 30 | some_equiv = TRUE; 31 | } else if (check_equiv(F[i], R[j])) { 32 | printf("# Outputs %d and NOT %d (%s and %s) are equivalent\n", 33 | i, j, PLA->label[ipart], PLA->label[jpart]); 34 | some_equiv = TRUE; 35 | } else if (check_equiv(R[i], F[j])) { 36 | printf("# Outputs NOT %d and %d (%s and %s) are equivalent\n", 37 | i, j, PLA->label[ipart], PLA->label[jpart]); 38 | some_equiv = TRUE; 39 | } else if (check_equiv(R[i], R[j])) { 40 | printf("# Outputs NOT %d and NOT %d (%s and %s) are equivalent\n", 41 | i, j, PLA->label[ipart], PLA->label[jpart]); 42 | some_equiv = TRUE; 43 | } 44 | } 45 | } 46 | 47 | if (! some_equiv) { 48 | printf("# No outputs are equivalent\n"); 49 | } 50 | 51 | for(i = 0; i < cube.part_size[cube.output]; i++) { 52 | free_cover(F[i]); 53 | free_cover(R[i]); 54 | } 55 | FREE(F); 56 | FREE(R); 57 | } 58 | 59 | 60 | 61 | int check_equiv(pset_family f1, pset_family f2) 62 | { 63 | register pcube *f1list, *f2list; 64 | register pcube p, last; 65 | 66 | f1list = cube1list(f1); 67 | foreach_set(f2, last, p) { 68 | if (! cube_is_covered(f1list, p)) { 69 | return FALSE; 70 | } 71 | } 72 | free_cubelist(f1list); 73 | 74 | f2list = cube1list(f2); 75 | foreach_set(f1, last, p) { 76 | if (! cube_is_covered(f2list, p)) { 77 | return FALSE; 78 | } 79 | } 80 | free_cubelist(f2list); 81 | 82 | return TRUE; 83 | } 84 | -------------------------------------------------------------------------------- /tlex/rd73.pla: -------------------------------------------------------------------------------- 1 | 2 | .i 7 3 | .o 3 4 | .p 141 5 | 1--11-1 ~~1 6 | -1-11-1 ~~1 7 | 11--1-1 ~~1 8 | 11-11-- ~~1 9 | 11-1--1 ~~1 10 | 11--11- ~~1 11 | -1-111- ~~1 12 | 11---11 ~~1 13 | 11-1-1- ~~1 14 | -1--111 ~~1 15 | 1---111 ~~1 16 | 1-11--1 ~~1 17 | ---1111 ~~1 18 | 1--111- ~~1 19 | -1-1-11 ~~1 20 | 111--1- ~~1 21 | -11--11 ~~1 22 | -11-11- ~~1 23 | --11-11 ~~1 24 | -111-1- ~~1 25 | 1-1-11- ~~1 26 | --1111- ~~1 27 | 111---1 ~~1 28 | --1-111 ~~1 29 | -1111-- ~~1 30 | -11-1-1 ~~1 31 | --111-1 ~~1 32 | 111-1-- ~~1 33 | 1-111-- ~~1 34 | 1111--- ~~1 35 | 1-11-1- ~~1 36 | 1--1-11 ~~1 37 | -111--1 ~~1 38 | 1-1--11 ~~1 39 | 1-1-1-1 ~~1 40 | -000110 1~~ 41 | 100-100 1~~ 42 | 0100-10 1~~ 43 | 10010-0 1~~ 44 | 110-000 1~~ 45 | 000-011 1~~ 46 | 100001- 1~~ 47 | 010-001 1~~ 48 | -100100 1~~ 49 | 10-0001 1~~ 50 | 0101-00 1~~ 51 | 00110-0 1~~ 52 | 0110-00 1~~ 53 | -001001 1~~ 54 | 001-001 1~~ 55 | 101-000 1~~ 56 | 0001-10 1~~ 57 | 1-11111 1~~ 58 | 00-1100 1~~ 59 | 0010-10 1~~ 60 | 000-101 1~~ 61 | -010100 1~~ 62 | 011-000 1~~ 63 | -110000 1~~ 64 | 010001- 1~~ 65 | 1111-11 1~~ 66 | 100010- 1~~ 67 | -010010 1~~ 68 | 010010- 1~~ 69 | 001010- 1~~ 70 | 110000- 1~~ 71 | 000011- 1~~ 72 | 111-111 1~~ 73 | 11-1111 1~~ 74 | 011000- 1~~ 75 | 0-10010 1~~ 76 | -111111 1~~ 77 | 010-010 1~~ 78 | 11111-1 1~~ 79 | 001001- 1~~ 80 | 111111- 1~~ 81 | -100010 1~~ 82 | 0000001 ~1~ 83 | 0001000 ~1~ 84 | 1000000 ~1~ 85 | 1001001 ~1~ 86 | 0000100 ~1~ 87 | 0001101 ~1~ 88 | 1000101 ~1~ 89 | 0101001 ~1~ 90 | 0100000 ~1~ 91 | 0001011 ~1~ 92 | 1100001 ~1~ 93 | 0011001 ~1~ 94 | 0100101 ~1~ 95 | 1000011 ~1~ 96 | 0000010 ~1~ 97 | 1010001 ~1~ 98 | 0000111 ~1~ 99 | 0100011 ~1~ 100 | 0010101 ~1~ 101 | 0010000 ~1~ 102 | 0110001 ~1~ 103 | 0010011 ~1~ 104 | 1001100 ~1~ 105 | 1101000 ~1~ 106 | 1101101 ~1~ 107 | 1001010 ~1~ 108 | 0101100 ~1~ 109 | 1001111 ~1~ 110 | 0001110 ~1~ 111 | 1101011 ~1~ 112 | 0101111 ~1~ 113 | 1011101 ~1~ 114 | 1100100 ~1~ 115 | 0101010 ~1~ 116 | 1000110 ~1~ 117 | 1011000 ~1~ 118 | 1100111 ~1~ 119 | 0011100 ~1~ 120 | 1100010 ~1~ 121 | 1111001 ~1~ 122 | 1010100 ~1~ 123 | 0111000 ~1~ 124 | 1110000 ~1~ 125 | 1011011 ~1~ 126 | 0100110 ~1~ 127 | 0111101 ~1~ 128 | 1110101 ~1~ 129 | 0011010 ~1~ 130 | 0110100 ~1~ 131 | 0011111 ~1~ 132 | 1010010 ~1~ 133 | 0111011 ~1~ 134 | 0010110 ~1~ 135 | 1010111 ~1~ 136 | 0110010 ~1~ 137 | 1110011 ~1~ 138 | 0110111 ~1~ 139 | 1101110 ~1~ 140 | 1111100 ~1~ 141 | 1011110 ~1~ 142 | 1111010 ~1~ 143 | 0111110 ~1~ 144 | 1110110 ~1~ 145 | 1111111 ~1~ 146 | .e 147 | -------------------------------------------------------------------------------- /examples/dk17: -------------------------------------------------------------------------------- 1 | .i 10 2 | .o 11 3 | 1000000000 10000000000 4 | 0010000000 10000000000 5 | 0100000000 00100000000 6 | 0000100000 00100000000 7 | 0001000000 00010000000 8 | 0000001000 00010000000 9 | 0000000100 00010000000 10 | 0000010000 00000010000 11 | 0100000000 00000000000 12 | 0000100000 00000000000 13 | 0000010000 00000000000 14 | 1000000000 00000000001 15 | 0010000000 00000000001 16 | 0000001000 00000000010 17 | 0001000000 00000000100 18 | 0000000100 00000000100 19 | 0010000001 10000000000 20 | 0000001001 10000000000 21 | 1000000001 00010000000 22 | 0100000001 00010000000 23 | 0000100001 00010000000 24 | 0001000001 00001000000 25 | 0000000101 00001000000 26 | 0000010001 00000001000 27 | 0100000001 00000000000 28 | 0000100001 00000000000 29 | 0000010001 00000000000 30 | 1000000001 00000000010 31 | 0001000001 00000000100 32 | 0000000101 00000000100 33 | 0010000001 00000000101 34 | 0000001001 00000000101 35 | 1000000010 01000000000 36 | 0010000010 01000000000 37 | 0100000010 00100000000 38 | 0000100010 00100000000 39 | 0000010010 00100000000 40 | 0000000110 00100000000 41 | 0001000010 00010000000 42 | 0000001010 00001000000 43 | 1000000010 00000000001 44 | 0010000010 00000000001 45 | 0100000010 00000000010 46 | 0001000010 00000000010 47 | 0000100010 00000000010 48 | 0000010010 00000000010 49 | 0000001010 00000000010 50 | 0000000110 00000000010 51 | 0010000011 01000000000 52 | 0000001011 01000000000 53 | 0000100011 00100000000 54 | 0000010011 00100000000 55 | 0000000111 00100000000 56 | 1000000011 00001000000 57 | 0001000011 00001000000 58 | 0100000011 00000100000 59 | 0100000011 00000000000 60 | 1000000011 00000000010 61 | 0001000011 00000000010 62 | 0000100011 00000000100 63 | 0000010011 00000000100 64 | 0000000111 00000000100 65 | 0010000011 00000000101 66 | 0000001011 00000000101 67 | 11-------- 22222222222 68 | 1-1------- 22222222222 69 | 1--1------ 22222222222 70 | 1---1----- 22222222222 71 | 1----1---- 22222222222 72 | 1-----1--- 22222222222 73 | 1------1-- 22222222222 74 | 00000000-- 22222222222 75 | -11------- 22222222222 76 | -1-1------ 22222222222 77 | -1--1----- 22222222222 78 | -1---1---- 22222222222 79 | -1----1--- 22222222222 80 | -1-----1-- 22222222222 81 | --11------ 22222222222 82 | --1-1----- 22222222222 83 | --1--1---- 22222222222 84 | --1---1--- 22222222222 85 | --1----1-- 22222222222 86 | ---11----- 22222222222 87 | ---1-1---- 22222222222 88 | ---1--1--- 22222222222 89 | ---1---1-- 22222222222 90 | ----11---- 22222222222 91 | ----1-1--- 22222222222 92 | ----1--1-- 22222222222 93 | -----11--- 22222222222 94 | -----1-1-- 22222222222 95 | ------11-- 22222222222 96 | -------------------------------------------------------------------------------- /espresso-src/gimpel.c: -------------------------------------------------------------------------------- 1 | #include "mincov_int.h" 2 | 3 | 4 | /* 5 | * check for: 6 | * 7 | * c1 c2 rest 8 | * -- -- --- 9 | * 1 1 0 0 0 0 <-- primary row 10 | * 1 0 S1 <-- secondary row 11 | * 0 1 T1 12 | * 0 1 T2 13 | * 0 1 Tn 14 | * 0 0 R 15 | */ 16 | 17 | int 18 | gimpel_reduce(sm_matrix *A, solution_t *select, int *weight, int lb, int bound, int depth, stats_t *stats, solution_t **best) 19 | { 20 | register sm_row *prow, *save_sec; 21 | register sm_col *c1 = NULL, *c2 = NULL; 22 | register sm_element *p, *p1; 23 | int c1_col_num, c2_col_num, primary_row_num, secondary_row_num; 24 | int reduce_it; 25 | 26 | reduce_it = 0; 27 | for(prow = A->first_row; prow != 0; prow = prow->next_row) { 28 | if (prow->length == 2) { 29 | c1 = sm_get_col(A, prow->first_col->col_num); 30 | c2 = sm_get_col(A, prow->last_col->col_num); 31 | if (c1->length == 2) { 32 | reduce_it = 1; 33 | } else if (c2->length == 2) { 34 | c1 = sm_get_col(A, prow->last_col->col_num); 35 | c2 = sm_get_col(A, prow->first_col->col_num); 36 | reduce_it = 1; 37 | } 38 | if (reduce_it) { 39 | primary_row_num = prow->row_num; 40 | secondary_row_num = c1->first_row->row_num; 41 | if (secondary_row_num == primary_row_num) { 42 | secondary_row_num = c1->last_row->row_num; 43 | } 44 | break; 45 | } 46 | } 47 | } 48 | 49 | if (reduce_it) { 50 | c1_col_num = c1->col_num; 51 | c2_col_num = c2->col_num; 52 | save_sec = sm_row_dup(sm_get_row(A, secondary_row_num)); 53 | sm_row_remove(save_sec, c1_col_num); 54 | 55 | for(p = c2->first_row; p != 0; p = p->next_row) { 56 | if (p->row_num != primary_row_num) { 57 | /* merge rows S1 and T */ 58 | for(p1 = save_sec->first_col; p1 != 0; p1 = p1->next_col) { 59 | (void) sm_insert(A, p->row_num, p1->col_num); 60 | } 61 | } 62 | } 63 | 64 | sm_delcol(A, c1_col_num); 65 | sm_delcol(A, c2_col_num); 66 | sm_delrow(A, primary_row_num); 67 | sm_delrow(A, secondary_row_num); 68 | 69 | stats->gimpel_count++; 70 | stats->gimpel++; 71 | *best = sm_mincov(A, select, weight, lb-1, bound-1, depth, stats); 72 | stats->gimpel--; 73 | 74 | if (*best != NIL(solution_t)) { 75 | /* is secondary row covered ? */ 76 | if (sm_row_intersects(save_sec, (*best)->row)) { 77 | /* yes, actually select c2 */ 78 | solution_add(*best, weight, c2_col_num); 79 | } else { 80 | solution_add(*best, weight, c1_col_num); 81 | } 82 | } 83 | 84 | sm_row_free(save_sec); 85 | return 1; 86 | } else { 87 | return 0; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /espresso-src/dominate.c: -------------------------------------------------------------------------------- 1 | #include "mincov_int.h" 2 | 3 | 4 | int 5 | sm_row_dominance(sm_matrix *A) 6 | { 7 | register sm_row *prow, *prow1; 8 | register sm_col *pcol, *least_col; 9 | register sm_element *p, *pnext; 10 | int rowcnt; 11 | 12 | rowcnt = A->nrows; 13 | 14 | /* Check each row against all other rows */ 15 | for(prow = A->first_row; prow != 0; prow = prow->next_row) { 16 | 17 | /* Among all columns with a 1 in this row, choose smallest */ 18 | least_col = sm_get_col(A, prow->first_col->col_num); 19 | for(p = prow->first_col->next_col; p != 0; p = p->next_col) { 20 | pcol = sm_get_col(A, p->col_num); 21 | if (pcol->length < least_col->length) { 22 | least_col = pcol; 23 | } 24 | } 25 | 26 | /* Only check for containment against rows in this column */ 27 | for(p = least_col->first_row; p != 0; p = pnext) { 28 | pnext = p->next_row; 29 | 30 | prow1 = sm_get_row(A, p->row_num); 31 | if ((prow1->length > prow->length) || 32 | (prow1->length == prow->length && 33 | prow1->row_num > prow->row_num)) { 34 | if (sm_row_contains(prow, prow1)) { 35 | sm_delrow(A, prow1->row_num); 36 | } 37 | } 38 | } 39 | } 40 | 41 | return rowcnt - A->nrows; 42 | } 43 | 44 | int 45 | sm_col_dominance(sm_matrix *A, int *weight) 46 | { 47 | register sm_row *prow; 48 | register sm_col *pcol, *pcol1; 49 | register sm_element *p; 50 | sm_row *least_row; 51 | sm_col *next_col; 52 | int colcnt; 53 | 54 | colcnt = A->ncols; 55 | 56 | /* Check each column against all other columns */ 57 | for(pcol = A->first_col; pcol != 0; pcol = next_col) { 58 | next_col = pcol->next_col; 59 | 60 | /* Check all rows to find the one with fewest elements */ 61 | least_row = sm_get_row(A, pcol->first_row->row_num); 62 | for(p = pcol->first_row->next_row; p != 0; p = p->next_row) { 63 | prow = sm_get_row(A, p->row_num); 64 | if (prow->length < least_row->length) { 65 | least_row = prow; 66 | } 67 | } 68 | 69 | /* Only check for containment against columns in this row */ 70 | for(p = least_row->first_col; p != 0; p = p->next_col) { 71 | pcol1 = sm_get_col(A, p->col_num); 72 | if (weight != 0 && weight[pcol1->col_num] > weight[pcol->col_num]) 73 | continue; 74 | if ((pcol1->length > pcol->length) || 75 | (pcol1->length == pcol->length && 76 | pcol1->col_num > pcol->col_num)) { 77 | if (sm_col_contains(pcol, pcol1)) { 78 | sm_delcol(A, pcol->col_num); 79 | break; 80 | } 81 | } 82 | } 83 | } 84 | 85 | return colcnt - A->ncols; 86 | } 87 | -------------------------------------------------------------------------------- /examples/misj: -------------------------------------------------------------------------------- 1 | .i 35 2 | .o 14 3 | 1111------------------------------- 10000000000000 4 | -----1-1--------------------------- 01000000000000 5 | -0-----11-------------------------- 01000000000000 6 | ---0---11-------------------------- 01000000000000 7 | ----0--11-------------------------- 01000000000000 8 | -------11------0------------------- 01000000000000 9 | -------11-------0------------------ 01000000000000 10 | -----0----------------------------- 00100000000000 11 | -------0--------------------------- 00010000000000 12 | -----0----0------------------------ 00010000000000 13 | -----0-----0----------------------- 00010000000000 14 | -------0--------------------------- 00001000000000 15 | -----0------0---------------------- 00001000000000 16 | -----0-------0--------------------- 00001000000000 17 | -----0--------0-------------------- 00001000000000 18 | -----------------0----------------- 00000100000000 19 | ------------------0---------------- 00000100000000 20 | ---------1------------------------- 00000010000000 21 | -------------------1--------------- 00000010000000 22 | --------------------1-------------- 00000010000000 23 | ---------------0------------------- 00000001000000 24 | ------0---------------------------- 00000000100000 25 | ---------------------0------------- 00000000100000 26 | -----------------------1----------- 00000000010000 27 | -------------------------1--------- 00000000010000 28 | ----------------------0------------ 00000000010000 29 | ---------------------------0------- 00000000010000 30 | ----------------------------0------ 00000000010000 31 | -----------------------------0----- 00000000010000 32 | ------------------------------0---- 00000000010000 33 | -------------------------------0--- 00000000010000 34 | --------------------------------0-- 00000000010000 35 | ---------------------------------0- 00000000010000 36 | --------------------------0-------- 00000000001000 37 | ------------------------0---------- 00000000001000 38 | ----------------------------------0 00000000001000 39 | ----------------------0------------ 00000000001000 40 | ---------------------------0------- 00000000001000 41 | ----------------------------0------ 00000000001000 42 | ------------------------------0---- 00000000001000 43 | -------------------------------0--- 00000000001000 44 | --------------------------------0-- 00000000001000 45 | ---------------------------------0- 00000000001000 46 | -0-----11-------------------------- 00000000000100 47 | ---0---11-------------------------- 00000000000100 48 | ----0--11-------------------------- 00000000000100 49 | -------11------0------------------- 00000000000100 50 | -------11-------0------------------ 00000000000100 51 | -------------------------------------------------------------------------------- /espresso-src/part.c: -------------------------------------------------------------------------------- 1 | #include "mincov_int.h" 2 | 3 | 4 | static void 5 | copy_row(register sm_matrix *A, register sm_row *prow) 6 | { 7 | register sm_element *p; 8 | 9 | for(p = prow->first_col; p != 0; p = p->next_col) { 10 | (void) sm_insert(A, p->row_num, p->col_num); 11 | } 12 | } 13 | 14 | static int visit_row(sm_matrix *A, sm_row *prow, int *rows_visited, int *cols_visited); 15 | 16 | static int 17 | visit_col(sm_matrix *A, sm_col *pcol, int *rows_visited, int *cols_visited) 18 | { 19 | sm_element *p; 20 | sm_row *prow; 21 | 22 | if (! pcol->flag) { 23 | pcol->flag = 1; 24 | (*cols_visited)++; 25 | if (*cols_visited == A->ncols) { 26 | return 1; 27 | } 28 | for(p = pcol->first_row; p != 0; p = p->next_row) { 29 | prow = sm_get_row(A, p->row_num); 30 | if (! prow->flag) { 31 | if (visit_row(A, prow, rows_visited, cols_visited)) { 32 | return 1; 33 | } 34 | } 35 | } 36 | } 37 | return 0; 38 | } 39 | 40 | static int 41 | visit_row(sm_matrix *A, sm_row *prow, int *rows_visited, int *cols_visited) 42 | { 43 | sm_element *p; 44 | sm_col *pcol; 45 | 46 | if (! prow->flag) { 47 | prow->flag = 1; 48 | (*rows_visited)++; 49 | if (*rows_visited == A->nrows) { 50 | return 1; 51 | } 52 | for(p = prow->first_col; p != 0; p = p->next_col) { 53 | pcol = sm_get_col(A, p->col_num); 54 | if (! pcol->flag) { 55 | if (visit_col(A, pcol, rows_visited, cols_visited)) { 56 | return 1; 57 | } 58 | } 59 | } 60 | } 61 | return 0; 62 | } 63 | 64 | 65 | 66 | int 67 | sm_block_partition(sm_matrix *A, sm_matrix **L, sm_matrix **R) 68 | { 69 | int cols_visited, rows_visited; 70 | register sm_row *prow; 71 | register sm_col *pcol; 72 | 73 | /* Avoid the trivial case */ 74 | if (A->nrows == 0) { 75 | return 0; 76 | } 77 | 78 | /* Reset the visited flags for each row and column */ 79 | for(prow = A->first_row; prow != 0; prow = prow->next_row) { 80 | prow->flag = 0; 81 | } 82 | for(pcol = A->first_col; pcol != 0; pcol = pcol->next_col) { 83 | pcol->flag = 0; 84 | } 85 | 86 | cols_visited = rows_visited = 0; 87 | if (visit_row(A, A->first_row, &rows_visited, &cols_visited)) { 88 | /* we found all of the rows */ 89 | return 0; 90 | } else { 91 | *L = sm_alloc(); 92 | *R = sm_alloc(); 93 | for(prow = A->first_row; prow != 0; prow = prow->next_row) { 94 | if (prow->flag) { 95 | copy_row(*L, prow); 96 | } else { 97 | copy_row(*R, prow); 98 | } 99 | } 100 | return 1; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /hard_examples/misj: -------------------------------------------------------------------------------- 1 | .i 35 2 | .o 14 3 | 1111------------------------------- 10000000000000 4 | -----1-1--------------------------- 01000000000000 5 | -0-----11-------------------------- 01000000000000 6 | ---0---11-------------------------- 01000000000000 7 | ----0--11-------------------------- 01000000000000 8 | -------11------0------------------- 01000000000000 9 | -------11-------0------------------ 01000000000000 10 | -----0----------------------------- 00100000000000 11 | -------0--------------------------- 00010000000000 12 | -----0----0------------------------ 00010000000000 13 | -----0-----0----------------------- 00010000000000 14 | -------0--------------------------- 00001000000000 15 | -----0------0---------------------- 00001000000000 16 | -----0-------0--------------------- 00001000000000 17 | -----0--------0-------------------- 00001000000000 18 | -----------------0----------------- 00000100000000 19 | ------------------0---------------- 00000100000000 20 | ---------1------------------------- 00000010000000 21 | -------------------1--------------- 00000010000000 22 | --------------------1-------------- 00000010000000 23 | ---------------0------------------- 00000001000000 24 | ------0---------------------------- 00000000100000 25 | ---------------------0------------- 00000000100000 26 | -----------------------1----------- 00000000010000 27 | -------------------------1--------- 00000000010000 28 | ----------------------0------------ 00000000010000 29 | ---------------------------0------- 00000000010000 30 | ----------------------------0------ 00000000010000 31 | -----------------------------0----- 00000000010000 32 | ------------------------------0---- 00000000010000 33 | -------------------------------0--- 00000000010000 34 | --------------------------------0-- 00000000010000 35 | ---------------------------------0- 00000000010000 36 | --------------------------0-------- 00000000001000 37 | ------------------------0---------- 00000000001000 38 | ----------------------------------0 00000000001000 39 | ----------------------0------------ 00000000001000 40 | ---------------------------0------- 00000000001000 41 | ----------------------------0------ 00000000001000 42 | ------------------------------0---- 00000000001000 43 | -------------------------------0--- 00000000001000 44 | --------------------------------0-- 00000000001000 45 | ---------------------------------0- 00000000001000 46 | -0-----11-------------------------- 00000000000100 47 | ---0---11-------------------------- 00000000000100 48 | ----0--11-------------------------- 00000000000100 49 | -------11------0------------------- 00000000000100 50 | -------11-------0------------------ 00000000000100 51 | -------------------------------------------------------------------------------- /examples/ryy6: -------------------------------------------------------------------------------- 1 | .i 16 2 | .o 1 3 | -000--0-----0--- 1 4 | -000--0------0-- 1 5 | -000--0-------0- 1 6 | -000--0--------0 1 7 | -0-0--0--0--0--- 1 8 | -0-0--0--0---0-- 1 9 | -0-0--0--0----0- 1 10 | -0-0--0--0-----0 1 11 | -000-0------0--- 1 12 | -000-0-------0-- 1 13 | -000-0--------0- 1 14 | -000-0---------0 1 15 | -0-0-0---0--0--- 1 16 | -0-0-0---0---0-- 1 17 | -0-0-0---0----0- 1 18 | -0-0-0---0-----0 1 19 | -00-0-0-----0--- 1 20 | -00-0-0------0-- 1 21 | -00-0-0-------0- 1 22 | -00-0-0--------0 1 23 | -0--0-0--0--0--- 1 24 | -0--0-0--0---0-- 1 25 | -0--0-0--0----0- 1 26 | -0--0-0--0-----0 1 27 | -00-00------0--- 1 28 | -00-00-------0-- 1 29 | -00-00--------0- 1 30 | -00-00---------0 1 31 | -0--00---0--0--- 1 32 | -0--00---0---0-- 1 33 | -0--00---0----0- 1 34 | -0--00---0-----0 1 35 | 0-00--0-----0--- 1 36 | 0-00--0------0-- 1 37 | 0-00--0-------0- 1 38 | 0-00--0--------0 1 39 | 0-00-0------0--- 1 40 | 0-00-0-------0-- 1 41 | 0-00-0--------0- 1 42 | 0-00-0---------0 1 43 | 0-0-0-0-----0--- 1 44 | 0-0-0-0------0-- 1 45 | 0-0-0-0-------0- 1 46 | 0-0-0-0--------0 1 47 | 0-0-00------0--- 1 48 | 0-0-00-------0-- 1 49 | 0-0-00--------0- 1 50 | 0-0-00---------0 1 51 | -0-0--00---00--- 1 52 | -0-0--00---0-0-- 1 53 | -0-0--00---0--0- 1 54 | -0-0--00---0---0 1 55 | -0-0--00--0-0--- 1 56 | -0-0--00--0--0-- 1 57 | -0-0--00--0---0- 1 58 | -0-0--00--0----0 1 59 | -0-0--0-0--00--- 1 60 | -0-0--0-0--0-0-- 1 61 | -0-0--0-0--0--0- 1 62 | -0-0--0-0--0---0 1 63 | -0-0--0-0-0-0--- 1 64 | -0-0--0-0-0--0-- 1 65 | -0-0--0-0-0---0- 1 66 | -0-0--0-0-0----0 1 67 | -0-0-0-0---00--- 1 68 | -0-0-0-0---0-0-- 1 69 | -0-0-0-0---0--0- 1 70 | -0-0-0-0---0---0 1 71 | -0-0-0-0--0-0--- 1 72 | -0-0-0-0--0--0-- 1 73 | -0-0-0-0--0---0- 1 74 | -0-0-0-0--0----0 1 75 | -0-0-0--0--00--- 1 76 | -0-0-0--0--0-0-- 1 77 | -0-0-0--0--0--0- 1 78 | -0-0-0--0--0---0 1 79 | -0-0-0--0-0-0--- 1 80 | -0-0-0--0-0--0-- 1 81 | -0-0-0--0-0---0- 1 82 | -0-0-0--0-0----0 1 83 | -0--0-00---00--- 1 84 | -0--0-00---0-0-- 1 85 | -0--0-00---0--0- 1 86 | -0--0-00---0---0 1 87 | -0--0-00--0-0--- 1 88 | -0--0-00--0--0-- 1 89 | -0--0-00--0---0- 1 90 | -0--0-00--0----0 1 91 | -0--0-0-0--00--- 1 92 | -0--0-0-0--0-0-- 1 93 | -0--0-0-0--0--0- 1 94 | -0--0-0-0--0---0 1 95 | -0--0-0-0-0-0--- 1 96 | -0--0-0-0-0--0-- 1 97 | -0--0-0-0-0---0- 1 98 | -0--0-0-0-0----0 1 99 | -0--00-0---00--- 1 100 | -0--00-0---0-0-- 1 101 | -0--00-0---0--0- 1 102 | -0--00-0---0---0 1 103 | -0--00-0--0-0--- 1 104 | -0--00-0--0--0-- 1 105 | -0--00-0--0---0- 1 106 | -0--00-0--0----0 1 107 | -0--00--0--00--- 1 108 | -0--00--0--0-0-- 1 109 | -0--00--0--0--0- 1 110 | -0--00--0--0---0 1 111 | -0--00--0-0-0--- 1 112 | -0--00--0-0--0-- 1 113 | -0--00--0-0---0- 1 114 | -0--00--0-0----0 1 115 | -------------------------------------------------------------------------------- /examples/alcom: -------------------------------------------------------------------------------- 1 | .i 15 2 | .o 38 3 | 10010----------|10000000000000000000000000000000000000 4 | 10110----------|10100000000000000000000000000000000000 5 | 01010----------|01000000000000000000000000000000000000 6 | 11010----------|01001000000000000000000000000000000000 7 | 00110----------|00100000000000000000000000000000000000 8 | 01110----------|00100000000000000000000000000000000000 9 | 1---0----------|00010000000000000000000000000000000000 10 | 01--0----------|00010100000000000000000000000000000000 11 | 00100----------|00010000000000000000000000000000000000 12 | 00000----------|00010100000000000000000000000000000000 13 | 1----11--------|00010000000000000000000000000000000000 14 | 10--0----------|00000100000000000000000000000000000000 15 | 111-0----------|00000100000000000000000000000000000000 16 | 11000----------|00000100000000000000000000000000000000 17 | 001-0----------|00000100000000000000000000000000000000 18 | -------0000----|00000010000000000000000000000000000000 19 | -------0001----|00000001000000000000000000000000000000 20 | -------0010----|00000000100000000000000000000000000000 21 | -------0011----|00000000010000000000000000000000000000 22 | -------0101----|00000000001000000000000000000000000000 23 | -------0100----|00000000000100000000000000000000000000 24 | -------0111----|00000000000010000000000000000000000000 25 | -------1000----|00000000000001000000000000000000000000 26 | -------1001----|00000000000000100000000000000000000000 27 | -------1010----|00000000000000010000000000000000000000 28 | -------1011----|00000000000000001000000000000000000000 29 | -------1100----|00000000000000000100000000000000000000 30 | -------1101----|00000000000000000010000000000000000000 31 | -------1110----|00000000000000000001000000000000000000 32 | -------1111----|00000000000000000000100000000000000000 33 | ---1-------0000|00000000000000000000010000000000000000 34 | ---1-------0001|00000000000000000000001000000000000000 35 | ---1-------0010|00000000000000000000000100000000000000 36 | ---1-------0011|00000000000000000000000010000000000000 37 | ---1-------0100|00000000000000000000000001000000000000 38 | ---1-------0101|00000000000000000000000000100000000000 39 | ---1-------0110|00000000000000000000000000010000000000 40 | ---1-------0111|00000000000000000000000000001000000000 41 | ---1-------1000|00000000000000000000000000000100000000 42 | ---1-------1001|00000000000000000000000000000010000000 43 | ---1-------1010|00000000000000000000000000000001000000 44 | ---1-------1011|00000000000000000000000000000000100000 45 | ---1-------1100|00000000000000000000000000000000010000 46 | -------0110----|00000000000000000000000000000000001000 47 | ---1-------1101|00000000000000000000000000000000000100 48 | ---1-------1110|00000000000000000000000000000000000010 49 | ---1-------1111|00000000000000000000000000000000000001 50 | -------------------------------------------------------------------------------- /examples/in5: -------------------------------------------------------------------------------- 1 | .i 24 2 | .o 14 3 | 011--1-------1--0-0----1 00000000100000 4 | 101-----1----1---------- 00000000000010 5 | 100010-------10111------ 01001100010000 6 | 0110-1-------1011-0----1 00000000010000 7 | 1000--1------1---------- 01100010100000 8 | 0111-1-------1111-0----1 00000000010000 9 | -------------0-----0100- 00100000000000 10 | 1000----1----1---------- 00000010000000 11 | -------------0-----1110- 00010000000000 12 | -------------0-----0001- 01000000000000 13 | -------------0-----1101- 01000000000000 14 | 1-00----1----1---------- 00000000100010 15 | -------------0-----1011- 00010000000000 16 | -001---1-0---1---------- 11100010100000 17 | -00110---0---11111------ 11001100010000 18 | 011011-------1011------- 01010100010000 19 | 1000-----1---1---------- 01100010000100 20 | 001-10----1--101100----- 01000101011000 21 | 100010-------101100----- 01000101010000 22 | 1011----1--1-1---------- 00010000000000 23 | 010-10----11-111100----- 11000101011000 24 | -00110---0---111100----- 11000101010000 25 | 011111-------1-0-00----- 11110000100000 26 | -----0---------1-00----- 00000000000001 27 | 0111-1-1-----1---00----- 11110000100000 28 | 0110-11------1---00----- 01110000100000 29 | 010-10----11-11111------ 11001100011000 30 | 001-10----1--10111------ 01001100011000 31 | 0111-1-1-----1-1-1------ 11010000010000 32 | 0110-11------1-1-1------ 01010000010000 33 | 011-11-------1-101------ 00100100010000 34 | 010-10----11-1-0--0----- 11101000101000 35 | -00110---0---1-0--0----- 11101000100000 36 | ------------1-----1----- 00001101000000 37 | 0110-11------1-0-1------ 00110000010000 38 | 011111-------101-1------ 10100100010000 39 | 011-11-------100-00----- 01110000100000 40 | 011111-------10--00----- 01110000100000 41 | 011--1-------100--0----1 00000000100000 42 | 011111-------1-1--0----- 10000100000000 43 | 001-10----1--1--0------- 01101000101000 44 | 100010-------1--0------- 01101000100000 45 | 011-11-------1-001------ 00110000010000 46 | 011-11-------100-1------ 00110000010000 47 | 011111-------1-0-1------ 10110000010000 48 | 0111-1-1-----1-0-1------ 10110000010000 49 | -00110---0---1-10-0----- 11101101100000 50 | -00110---0---101--0----- 11101101100000 51 | 011-11-------1-10-0----- 00000100000000 52 | 011-11-------1--000----- 01110000100000 53 | 010-10----11-1-10-0----- 11101101101000 54 | 010-10----11-101--0----- 11101101101000 55 | 100010-------100-------- 01101000100000 56 | 100010-------1-10------- 01101101100000 57 | 001-10----1--100-------- 01101000101000 58 | 001-10----1--1-10------- 01101101101000 59 | -------------0-----001-- 00100000000000 60 | -------------0-----0011- 10100000000000 61 | 011111-------1-101------ 10100100010000 62 | 011111-------1111-0----- 01010000010000 63 | 0111-1-------1-0--0----1 00000000100000 64 | 0111-1-------10---0----1 00000000100000 65 | -------------------------------------------------------------------------------- /examples/exp: -------------------------------------------------------------------------------- 1 | .i 8 2 | .o 18 3 | 00000001 100001101--------0 4 | 00000010 110000101-----1000 5 | 00000011 110000111-----1000 6 | 00000100 --------------1000 7 | 00000101 --------------0100 8 | 00000110 --------------0011 9 | 00100001 100001101--------0 10 | 00100010 110000101-----1000 11 | 00100011 110000101-----1000 12 | 00100100 110000111-----1000 13 | 00100101 --------------1000 14 | 00100110 --------------0100 15 | 00100111 --------------0011 16 | 01100001 100001101--------0 17 | 01100010 110000101-----1000 18 | 01100011 110000101-----1000 19 | 01100100 110000101-----1000 20 | 01100101 110000111-----1000 21 | 01100110 --------------1000 22 | 01100111 --------------0100 23 | 01101000 --------------0011 24 | 01000001 100001101--------0 25 | 01000010 110000101-----1000 26 | 01000011 110000101-----1000 27 | 01000100 110000101-----1000 28 | 01000101 110000101-----1000 29 | 01000110 110000111-----1000 30 | 01000111 --------------1000 31 | 01001000 --------------0100 32 | 01001001 --------------0011 33 | 11000001 000001100--------0 34 | 11000010 010000100-----1000 35 | 11000011 010000110-----1000 36 | 11000100 ---------100000000 37 | 11000101 001001001010001000 38 | 11000110 011000001001001000 39 | 11000111 011000011-----1000 40 | 11001000 --------------0100 41 | 11001001 --------------0001 42 | 11100001 000001100--------0 43 | 11100010 010000100-----1000 44 | 11100011 010000100-----1000 45 | 11100100 010000110100000000 46 | 11100101 000001001100000000 47 | 11100110 010000001010001000 48 | 11100111 010000001001001000 49 | 11101000 010000001-----1000 50 | 11101001 --------------1000 51 | 11101010 --------------0100 52 | 11101011 --------------0011 53 | 10100001 000001100--------0 54 | 10100010 010000100-----1000 55 | 10100011 010000100-----1000 56 | 10100100 010000100100010000 57 | 10100101 010000110100010000 58 | 10100110 000001000100010000 59 | 10100111 010000000010011000 60 | 10101000 010000000001011000 61 | 10101001 010000000100010000 62 | 10101010 010000010100010000 63 | 10101011 001001001100010000 64 | 10101100 011000001010011000 65 | 10101101 011000001001011000 66 | 10101110 011000001-----1000 67 | 10101111 011000011-----1000 68 | 10110000 --------------1000 69 | 10110001 --------------0100 70 | 10110010 --------------0001 71 | 10000001 000001100--------0 72 | 10000010 010000100-----1000 73 | 10000011 010000100-----1000 74 | 10000100 010000100100100000 75 | 10000101 010000100100100000 76 | 10000110 010000110100100000 77 | 10000111 000001000100100000 78 | 10001000 010000000010101000 79 | 10001001 010000000001101000 80 | 10001010 010000000100100000 81 | 10001011 010000000100100000 82 | 10001100 010000010100100000 83 | 10001101 000001001100100000 84 | 10001110 010000001010101000 85 | 10001111 010000001001101000 86 | 10010000 010000001-----1000 87 | 10010001 010000001-----1000 88 | 10010010 010000011-----1000 89 | 10010011 --------------1000 90 | 10010100 --------------0100 91 | 10010101 --------------0011 92 | -------------------------------------------------------------------------------- /espresso-src/globals.c: -------------------------------------------------------------------------------- 1 | #include "espresso.h" 2 | 3 | /* 4 | * Global Variable Declarations 5 | */ 6 | 7 | unsigned int debug; /* debug parameter */ 8 | bool verbose_debug; /* -v: whether to print a lot */ 9 | char *total_name[TIME_COUNT]; /* basic function names */ 10 | long total_time[TIME_COUNT]; /* time spent in basic fcts */ 11 | int total_calls[TIME_COUNT]; /* # calls to each fct */ 12 | 13 | bool echo_comments; /* turned off by -eat option */ 14 | bool echo_unknown_commands; /* always true ?? */ 15 | bool force_irredundant; /* -nirr command line option */ 16 | bool skip_make_sparse; 17 | bool kiss; /* -kiss command line option */ 18 | bool pos; /* -pos command line option */ 19 | bool print_solution; /* -x command line option */ 20 | bool recompute_onset; /* -onset command line option */ 21 | bool remove_essential; /* -ness command line option */ 22 | bool single_expand; /* -fast command line option */ 23 | bool summary; /* -s command line option */ 24 | bool trace; /* -t command line option */ 25 | bool unwrap_onset; /* -nunwrap command line option */ 26 | bool use_random_order; /* -random command line option */ 27 | bool use_super_gasp; /* -strong command line option */ 28 | char *filename; /* filename PLA was read from */ 29 | 30 | struct pla_types_struct pla_types[] = { 31 | {"-f", F_type}, 32 | {"-r", R_type}, 33 | {"-d", D_type}, 34 | {"-fd", FD_type}, 35 | {"-fr", FR_type}, 36 | {"-dr", DR_type}, 37 | {"-fdr", FDR_type}, 38 | {"-fc", F_type | CONSTRAINTS_type}, 39 | {"-rc", R_type | CONSTRAINTS_type}, 40 | {"-dc", D_type | CONSTRAINTS_type}, 41 | {"-fdc", FD_type | CONSTRAINTS_type}, 42 | {"-frc", FR_type | CONSTRAINTS_type}, 43 | {"-drc", DR_type | CONSTRAINTS_type}, 44 | {"-fdrc", FDR_type | CONSTRAINTS_type}, 45 | {"-pleasure", PLEASURE_type}, 46 | {"-eqn", EQNTOTT_type}, 47 | {"-eqntott", EQNTOTT_type}, 48 | {"-kiss", KISS_type}, 49 | {"-cons", CONSTRAINTS_type}, 50 | {"-scons", SYMBOLIC_CONSTRAINTS_type}, 51 | {0, 0} 52 | }; 53 | 54 | 55 | struct cube_struct cube, temp_cube_save; 56 | struct cdata_struct cdata, temp_cdata_save; 57 | 58 | int bit_count[256] = { 59 | 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5, 60 | 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6, 61 | 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6, 62 | 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7, 63 | 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6, 64 | 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7, 65 | 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7, 66 | 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8 67 | }; 68 | -------------------------------------------------------------------------------- /examples/m2: -------------------------------------------------------------------------------- 1 | .i 8 2 | .o 16 3 | 00000000 1110111111111111 4 | 00000001 1111000001001111 5 | 00000010 1111000000111110 6 | 00000011 1111000000110101 7 | 00000100 1111000100101110 8 | 00000101 1111000100101001 9 | 00000110 1111001000100101 10 | 00000111 1111001000100010 11 | 00001000 1111001100011111 12 | 00001001 1111001100011101 13 | 00001010 1111010000011011 14 | 00001011 1111010000011001 15 | 00001100 1111010000010111 16 | 00001101 1111010100010110 17 | 00001110 1111010100010100 18 | 00001111 1111010100010011 19 | 00010000 1111011000010010 20 | 00010001 1111011000010001 21 | 00010010 1111011000010000 22 | 00010011 1111011100001111 23 | 00010100 1111011100001110 24 | 00010101 1111011100001110 25 | 00010110 1111100000001101 26 | 00010111 1111100000001100 27 | 00011000 1111100000001100 28 | 00011001 1111100000001011 29 | 00011010 1111100100001010 30 | 00011011 1111100100001010 31 | 00011100 1111100100001001 32 | 00011101 1111100100001001 33 | 00011110 1111101000001001 34 | 00011111 1111101000001000 35 | 00100000 1111101000001000 36 | 00100001 1111101000000111 37 | 00100010 1111101100000111 38 | 00100011 1111101100000111 39 | 00100100 1111101100000110 40 | 00100101 1111101100000110 41 | 00100110 1111101100000110 42 | 00100111 1111101100000110 43 | 00101000 1111110000000101 44 | 00101001 1111110000000101 45 | 00101010 1111110000000101 46 | 00101011 1111110000000101 47 | 00101100 1111110000000100 48 | 00101101 1111110000000100 49 | 00101110 1111110100000100 50 | 00101111 1111110100000100 51 | 00110000 1111110100000100 52 | 00110001 1111110100000100 53 | 00110010 1111110100000011 54 | 00110011 1111110100000011 55 | 00110100 1111110100000011 56 | 00110101 1111110100000011 57 | 00110110 1111110100000011 58 | 00110111 1111111000000011 59 | 00111000 1111111000000011 60 | 00111001 1111111000000011 61 | 00111010 1111111000000010 62 | 00111011 1111111000000010 63 | 00111100 1111111000000010 64 | 00111101 1111111000000010 65 | 00111110 1111111000000010 66 | 00111111 1111111000000010 67 | 01000000 1111111000000010 68 | 01000001 1111111000000010 69 | 01000010 1111111000000010 70 | 01000011 1111111000000010 71 | 01000100 1111111100000010 72 | 01000101 1111111100000010 73 | 01000110 1111111100000010 74 | 01000111 1111111100000001 75 | 01001000 1111111100000001 76 | 01001001 1111111100000001 77 | 01001010 1111111100000001 78 | 01001011 1111111100000001 79 | 01001100 1111111100000001 80 | 01001101 1111111100000001 81 | 01001110 1111111100000001 82 | 01001111 1111111100000001 83 | 01010000 1111111100000001 84 | 01010001 1111111100000001 85 | 01010010 1111111100000001 86 | 01010011 1111111100000001 87 | 01010100 1111111100000001 88 | 01010101 1111111100000001 89 | 01010110 1111111100000001 90 | 01010111 1111111100000001 91 | 01011000 1111111100000001 92 | 01011001 1111111100000001 93 | 01011010 1111111100000001 94 | 01011011 1111111100000001 95 | 01011100 1111111100000001 96 | 01011101 1111111100000001 97 | 01011110 1111111100000001 98 | 01011111 1111111100000001 99 | -------------------------------------------------------------------------------- /espresso-src/signature.h: -------------------------------------------------------------------------------- 1 | #if BPI == 16 2 | #define ODD_MASK 0xaaaa 3 | #define EVEN_MASK 0x5555 4 | #else 5 | #define ODD_MASK 0xaaaaaaaa 6 | #define EVEN_MASK 0x55555555 7 | #endif 8 | 9 | #define POSITIVE 1 10 | #define NEGATIVE 0 11 | 12 | #define PRESENT 1 13 | #define ABSENT 0 14 | 15 | #define RAISED 2 16 | 17 | typedef struct { 18 | int variable; 19 | int free_count; 20 | } VAR; 21 | 22 | /* black_white.c */ extern void setup_bw (pset_family R, pset c); 23 | /* black_white.c */ extern void free_bw (void); 24 | /* black_white.c */ extern int black_white (void); 25 | /* black_white.c */ extern void split_list (pset_family R, int v); 26 | /* black_white.c */ extern void merge_list (void); 27 | /* black_white.c */ extern void print_bw (int size); 28 | /* black_white.c */ extern void variable_list_alloc (int size); 29 | /* black_white.c */ extern void variable_list_init (int reduced_c_free_count, int *reduced_c_free_list); 30 | /* black_white.c */ extern void variable_list_delete (int element); 31 | /* black_white.c */ extern void variable_list_insert (int element); 32 | /* black_white.c */ extern int variable_list_empty (void); 33 | /* black_white.c */ extern void get_next_variable (int *pv, int *pphase, pset_family R); 34 | /* black_white.c */ extern void print_variable_list (void); 35 | /* black_white.c */ extern void reset_black_list (void); 36 | /* black_white.c */ extern void push_black_list (void); 37 | /* black_white.c */ extern void pop_black_list (void); 38 | /* canonical.c */ extern pset_family find_canonical_cover (pset_family F1, pset_family D, pset_family R); 39 | /* essentiality.c */ extern pset_family etr_order (pset_family F, pset_family E, pset_family R, pset c, pset d); 40 | /* essentiality.c */ extern void aux_etr_order (pset_family F, pset_family E, pset_family R, pset c, pset d); 41 | /* essentiality.c */ extern pset_family get_mins (pset c); 42 | /* essentiality.c */ extern int ascending (VAR *p1, VAR *p2); 43 | /* util_signature.c */ extern void set_time_limit (int seconds); 44 | /* util_signature.c */ extern void print_cover (pset_family F, char *name); 45 | /* util_signature.c */ extern int sf_equal (pset_family F1, pset_family F2); 46 | /* util_signature.c */ extern int mem_usage (char *name); 47 | /* util_signature.c */ extern int time_usage (char *name); 48 | /* util_signature.c */ extern void s_totals (long time, int i); 49 | /* util_signature.c */ extern void s_runtime (long total); 50 | /* sigma.c */ extern pset get_sigma (pset_family R, register pset c); 51 | /* sigma.c */ extern void set_not (pset c); 52 | /* signature.c */ extern void cleanup (void); 53 | /* signature.c */ extern pset_family signature (pset_family F1, pset_family D1, pset_family R1); 54 | /* signature.c */ extern pset_family generate_primes (pset_family F, pset_family R); 55 | /* signature_exact.c */ extern pset_family signature_minimize_exact (pset_family ESCubes, pset_family ESSet); 56 | /* signature_exact.c */ extern sm_matrix * signature_form_table (pset_family ESCubes, pset_family ESSet); 57 | -------------------------------------------------------------------------------- /espresso-src/sparse_int.h: -------------------------------------------------------------------------------- 1 | #include "port.h" 2 | #include "utility.h" 3 | #include "sparse.h" 4 | 5 | 6 | 7 | /* 8 | * sorted, double-linked list insertion 9 | * 10 | * type: object type 11 | * 12 | * first, last: fields (in header) to head and tail of the list 13 | * count: field (in header) of length of the list 14 | * 15 | * next, prev: fields (in object) to link next and previous objects 16 | * value: field (in object) which controls the order 17 | * 18 | * newval: value field for new object 19 | * e: an object to use if insertion needed (set to actual value used) 20 | */ 21 | 22 | #define sorted_insert(type, first, last, count, next, prev, value, newval, e) \ 23 | if (last == 0) { \ 24 | e->value = newval; \ 25 | first = e; \ 26 | last = e; \ 27 | e->next = 0; \ 28 | e->prev = 0; \ 29 | count++; \ 30 | } else if (last->value < newval) { \ 31 | e->value = newval; \ 32 | last->next = e; \ 33 | e->prev = last; \ 34 | last = e; \ 35 | e->next = 0; \ 36 | count++; \ 37 | } else if (first->value > newval) { \ 38 | e->value = newval; \ 39 | first->prev = e; \ 40 | e->next = first; \ 41 | first = e; \ 42 | e->prev = 0; \ 43 | count++; \ 44 | } else { \ 45 | type *p; \ 46 | for(p = first; p->value < newval; p = p->next) \ 47 | ; \ 48 | if (p->value > newval) { \ 49 | e->value = newval; \ 50 | p = p->prev; \ 51 | p->next->prev = e; \ 52 | e->next = p->next; \ 53 | p->next = e; \ 54 | e->prev = p; \ 55 | count++; \ 56 | } else { \ 57 | e = p; \ 58 | } \ 59 | } 60 | 61 | 62 | /* 63 | * double linked-list deletion 64 | */ 65 | #define dll_unlink(p, first, last, next, prev, count) { \ 66 | if (p->prev == 0) { \ 67 | first = p->next; \ 68 | } else { \ 69 | p->prev->next = p->next; \ 70 | } \ 71 | if (p->next == 0) { \ 72 | last = p->prev; \ 73 | } else { \ 74 | p->next->prev = p->prev; \ 75 | } \ 76 | count--; \ 77 | } 78 | 79 | 80 | #ifdef FAST_AND_LOOSE 81 | extern sm_element *sm_element_freelist; 82 | extern sm_row *sm_row_freelist; 83 | extern sm_col *sm_col_freelist; 84 | 85 | #define sm_element_alloc(newobj) \ 86 | if (sm_element_freelist == NIL(sm_element)) { \ 87 | newobj = ALLOC(sm_element, 1); \ 88 | } else { \ 89 | newobj = sm_element_freelist; \ 90 | sm_element_freelist = sm_element_freelist->next_col; \ 91 | } \ 92 | newobj->user_word = NIL(char); \ 93 | 94 | #define sm_element_free(e) \ 95 | (e->next_col = sm_element_freelist, sm_element_freelist = e) 96 | 97 | #else 98 | 99 | #define sm_element_alloc(newobj) \ 100 | newobj = ALLOC(sm_element, 1); \ 101 | newobj->user_word = NIL(char); 102 | #define sm_element_free(e) \ 103 | FREE(e) 104 | #endif 105 | 106 | 107 | extern void sm_row_remove_element(register sm_row *prow, register sm_element *p); 108 | extern void sm_col_remove_element(register sm_col *pcol, register sm_element *p); 109 | 110 | /* LINTLIBRARY */ 111 | -------------------------------------------------------------------------------- /tlex/Z5xp1.pla: -------------------------------------------------------------------------------- 1 | .i 7 2 | .o 10 3 | .p 128 4 | 0000000 0000000001 5 | 0000001 0000000110 6 | 0000010 0000001011 7 | 0000011 0000010000 8 | 0000100 0000010101 9 | 0000101 0000011010 10 | 0000110 0000011111 11 | 0000111 0000100100 12 | 0001000 0000101001 13 | 0001001 0000101110 14 | 0001010 0000110011 15 | 0001011 0000111000 16 | 0001100 0000111101 17 | 0001101 0001000010 18 | 0001110 0001000111 19 | 0001111 0001001100 20 | 0010000 0001010001 21 | 0010001 0001010110 22 | 0010010 0001011011 23 | 0010011 0001100000 24 | 0010100 0001100101 25 | 0010101 0001101010 26 | 0010110 0001101111 27 | 0010111 0001110100 28 | 0011000 0001111001 29 | 0011001 0001111110 30 | 0011010 0010000011 31 | 0011011 0010001000 32 | 0011100 0010001101 33 | 0011101 0010010010 34 | 0011110 0010010111 35 | 0011111 0010011100 36 | 0100000 0010100001 37 | 0100001 0010100110 38 | 0100010 0010101011 39 | 0100011 0010110000 40 | 0100100 0010110101 41 | 0100101 0010111010 42 | 0100110 0010111111 43 | 0100111 0011000100 44 | 0101000 0011001001 45 | 0101001 0011001110 46 | 0101010 0011010011 47 | 0101011 0011011000 48 | 0101100 0011011101 49 | 0101101 0011100010 50 | 0101110 0011100111 51 | 0101111 0011101100 52 | 0110000 0011110001 53 | 0110001 0011110110 54 | 0110010 0011111011 55 | 0110011 0100000000 56 | 0110100 0100000101 57 | 0110101 0100001010 58 | 0110110 0100001111 59 | 0110111 0100010100 60 | 0111000 0100011001 61 | 0111001 0100011110 62 | 0111010 0100100011 63 | 0111011 0100101000 64 | 0111100 0100101101 65 | 0111101 0100110010 66 | 0111110 0100110111 67 | 0111111 0100111100 68 | 1000000 0101000001 69 | 1000001 0101000110 70 | 1000010 0101001011 71 | 1000011 0101010000 72 | 1000100 0101010101 73 | 1000101 0101011010 74 | 1000110 0101011111 75 | 1000111 0101100100 76 | 1001000 0101101001 77 | 1001001 0101101110 78 | 1001010 0101110011 79 | 1001011 0101111000 80 | 1001100 0101111101 81 | 1001101 0110000010 82 | 1001110 0110000111 83 | 1001111 0110001100 84 | 1010000 0110010001 85 | 1010001 0110010110 86 | 1010010 0110011011 87 | 1010011 0110100000 88 | 1010100 0110100101 89 | 1010101 0110101010 90 | 1010110 0110101111 91 | 1010111 0110110100 92 | 1011000 0110111001 93 | 1011001 0110111110 94 | 1011010 0111000011 95 | 1011011 0111001000 96 | 1011100 0111001101 97 | 1011101 0111010010 98 | 1011110 0111010111 99 | 1011111 0111011100 100 | 1100000 0111100001 101 | 1100001 0111100110 102 | 1100010 0111101011 103 | 1100011 0111110000 104 | 1100100 0111110101 105 | 1100101 0111111010 106 | 1100110 0111111111 107 | 1100111 1000000100 108 | 1101000 1000001001 109 | 1101001 1000001110 110 | 1101010 1000010011 111 | 1101011 1000011000 112 | 1101100 1000011101 113 | 1101101 1000100010 114 | 1101110 1000100111 115 | 1101111 1000101100 116 | 1110000 1000110001 117 | 1110001 1000110110 118 | 1110010 1000111011 119 | 1110011 1001000000 120 | 1110100 1001000101 121 | 1110101 1001001010 122 | 1110110 1001001111 123 | 1110111 1001010100 124 | 1111000 1001011001 125 | 1111001 1001011110 126 | 1111010 1001100011 127 | 1111011 1001101000 128 | 1111100 1001101101 129 | 1111101 1001110010 130 | 1111110 1001110111 131 | 1111111 1001111100 132 | .e 133 | -------------------------------------------------------------------------------- /examples/b11: -------------------------------------------------------------------------------- 1 | .i 8 2 | .o 31 3 | 00000--- -000010000000001000100000000000 4 | 00001--- -000010000000001000000000000000 5 | 0001---- -000010000000001000010000000000 6 | --1-0--- -000000000000000100000000000000 7 | 0010-0-- -000000110000000000000000000000 8 | --100--- -000000000000000100000000000000 9 | --10---- -000000000000000100000000000000 10 | --1----- -000000000000000100000000000000 11 | 0010-1-- -000000100000000000000000000010 12 | --1-1--- -000000000000000100000000000000 13 | --101--- -000000000000000100000000000000 14 | --11---- -000000000000000100000000000000 15 | 001100-- -000001010000000000000000000000 16 | --110--- -000000000000000100000000000000 17 | 001101-- -011001000000000000000000000000 18 | --111--- -000000000000000100000000000000 19 | 00111--- -100001010000000000000000000000 20 | -1-0---- -000000000000000100000000000000 21 | -1------ -000000000000000100000000000000 22 | -1--0--- -000000000000000100000000000000 23 | -1-00--- -000000000000000100000000000000 24 | 010000-- -100000000111010000000000000100 25 | 0100010- -100000000110110000000000000100 26 | 0100011- -000000000011010000000000000100 27 | -1--1--- -000000000000000100000000000000 28 | -1-01--- -000000000000000100000000000000 29 | 01001--- -000000000010110000000000000100 30 | -1-1---- -000000000000000100000000000000 31 | -1-10--- -000000000000000100000000000000 32 | 0101---- -000000000000010000000000000100 33 | -1-11--- -000000000000000100000000000000 34 | 01100--- -001000001000000000000000000100 35 | -11----- -000000000000000100000000000000 36 | -11-0--- -000000000000000100000000000000 37 | -110---- -000000000000000100000000000000 38 | 01101--- -001000001000000000000000000100 39 | -11-1--- -000000000000000100000000000000 40 | 0111---- -001000001000000000000000000100 41 | -111---- -000000000000000100000000000000 42 | 1--00--- -000000000000000100000000000000 43 | 1------- -000000000000000100000000000000 44 | 1---0--- -000000000000000100000000000000 45 | 1--0---- -000000000000000100000000000000 46 | 100000-- -000000000000000000000001000000 47 | 100000-1 -000100000000000000000000000000 48 | 100001-- -000000000000000100000001101000 49 | 100001-1 -000100000000000000000000000000 50 | 1--01--- -000000000000000100000000000000 51 | 1---1--- -000000000000000100000000000000 52 | 1--1---- -000000000000000100000000000000 53 | 1--10--- -000000000000000100000000000000 54 | 100100-- -000100000000000000000110000000 55 | 100101-- -000100000000000100000110101000 56 | 1--11--- -000000000000000100000000000000 57 | 10011--- -000000000000000000000000010000 58 | 101000-- -000010000000000001000000000000 59 | 1-1-0--- -000000000000000100000000000000 60 | 1-10---- -000000000000000100000000000000 61 | 1-1----- -000000000000000100000000000000 62 | 101001-- -000010000000000010000000000000 63 | 1-1-1--- -000000000000000100000000000000 64 | 101010-- -000010000000000001000000000000 65 | 101011-- -000010000000000010000000000000 66 | 1-11---- -000000000000000100000000000000 67 | 10110--- -000010000000000000000000000001 68 | 10111--- -000010000000000000000000000000 69 | 11--0--- -000000000000000100000000000000 70 | 1100---- -001100000000000000000100000000 71 | 11-0---- -000000000000000100000000000000 72 | 11------ -000000000000000100000000000000 73 | 11--1--- -000000000000000100000000000000 74 | 1101---- -000000000000000000000000010000 75 | 11-1---- -000000000000000100000000000000 76 | 111----- -000000000000000100001000001000 77 | -------------------------------------------------------------------------------- /examples/b4: -------------------------------------------------------------------------------- 1 | .i 33 2 | .o 23 3 | 1------1------------------------- -0001000111100100011010 4 | 0---0---------------------------1 -0100000000000000000000 5 | 01--------------------1-----1-10- -1000000000000000000000 6 | 0--------------00--------------1- -1000000000000000000000 7 | 0--------0100-01010---------0-1-- -0000010011001000000000 8 | 0--1------------------------000-- -0010000000000000000011 9 | 0--------0100--0101---------0-1-- -0000001100110000000000 10 | 0--1------------------------010-- -0011000000000000000001 11 | ------01-0100--1000---------0-1-- -0000000010100000000000 12 | 0--------10-0------111------011-- -0000100000000000000110 13 | 0-----0--0100--0010---------0-1-- -0000001000001000000000 14 | ---1----------------------10----- -0000000000000000001000 15 | 0--------1110------1-1------011-- -0000100000000000000110 16 | 0--------0111--------1------011-- -0000100000000000000110 17 | 0--------1111------11-------011-- -0000100000000000000101 18 | 0----1--------------------------- -0000000000000000100000 19 | ---0-----------------------1----- -0000000000000000001000 20 | 0---------------------1-----1-1-- -0000000000000000100000 21 | 01----1--0011--001-----1----0-1-- -0000001000000000000000 22 | 01-------0011--0011----1------1-- -0000000000010000000000 23 | 01----0-00011--0011----1----0-1-- -0000001000001000000000 24 | 01----1--0011--1-00---1-----0-1-- -0000000000100000000000 25 | 0--------1011------111------011-- -0000100000000000000111 26 | 01-------0011--0000----1----0-1-- -0000001000000000000000 27 | 1------0------------------------- -0001000110011100011010 28 | 01-------------0101---1-----1-1-- -0000000100100000000000 29 | -1-----------------------1--11--- -0000000000000100000000 30 | 01-----------1--------0-1---11--- -0000000000000010000000 31 | 0--------0100---------------0-1-- -0000100000000000011000 32 | 0--------0010---------------0-1-- -0000100000000000000101 33 | 0--------1101---------------0-1-- -0000100000000000000110 34 | 01----01-------1000----1----1-1-- -0000010000000000000000 35 | 01----0--------0010----1----1-1-- -0000011000000000000000 36 | 01--------------010----1----1-1-- -0000000000001000000000 37 | 01------------01010----1----1-1-- -0000010000000000000000 38 | 01-------------0101----1----1-1-- -0000001000010000000000 39 | 01-------------0011----1----1-1-- -0000000000011000000000 40 | -1-------------10-0---1-----1-1-- -0000000010000000000000 41 | -1----01-------1000---1-----1-1-- -0000000001100000000000 42 | -1-------------1100---1-----1-1-- -0000000110000000000000 43 | 01----0--------0010---1-----1-1-- -0000000001000000000000 44 | 01------------01010---1-----1-1-- -0000000001000000000000 45 | -1-----1-0011--0000---1-----0-1-- -0000000000100000000000 46 | 01----1--0011---000---1-----0-1-- -0000000000100000000000 47 | ---0------------------------010-- -0000000000000000000010 48 | --1-------------------------000-- -0000000000000000000010 49 | --------------------------11----- -0000000000000000010000 50 | ---0----------------------1------ -0000000000000000010000 51 | 0--------10-1------111------011-- -0000100000000000000101 52 | 0--------1-00------111------011-- -0000100000000000000101 53 | 01----------------------1---11--0 -0100000000000000000000 54 | 01----------------------1---11--- -0000000000000101000000 55 | 01----0-10011--1100---1-----0-1-- -0000000010100000000000 56 | -1-------0011--1100---1-------1-- -0000000100000000000000 57 | -------------------------------------------------------------------------------- /examples/b7: -------------------------------------------------------------------------------- 1 | .i 8 2 | .o 31 3 | 00000--- -000010000000001000100000000000 4 | 00001--- -000010000000001000000000000000 5 | 0001---- -000010000000001000010000000000 6 | --1-0--- -000000000000000100000000000000 7 | 0010-0-- -000000110000000000000000000000 8 | --100--- -000000000000000100000000000000 9 | --10---- -000000000000000100000000000000 10 | --1----- -000000000000000100000000000000 11 | 0010-1-- -000000100000000000000000000010 12 | --1-1--- -000000000000000100000000000000 13 | --101--- -000000000000000100000000000000 14 | --11---- -000000000000000100000000000000 15 | 001100-- -000001010000000000000000000000 16 | --110--- -000000000000000100000000000000 17 | 001101-- -011001000000000000000000000000 18 | --111--- -000000000000000100000000000000 19 | 00111--- -100001010000000000000000000000 20 | -1-0---- -000000000000000100000000000000 21 | -1------ -000000000000000100000000000000 22 | -1--0--- -000000000000000100000000000000 23 | -1-00--- -000000000000000100000000000000 24 | 010000-- -100000000111010000000000000100 25 | 0100010- -100000000110110000000000000100 26 | 0100011- -000000000011010000000000000100 27 | -1--1--- -000000000000000100000000000000 28 | -1-01--- -000000000000000100000000000000 29 | 01001--- -000000000010110000000000000100 30 | -1-1---- -000000000000000100000000000000 31 | -1-10--- -000000000000000100000000000000 32 | 0101---- -000000000000010000000000000100 33 | -1-11--- -000000000000000100000000000000 34 | 01100--- -001000001000000000000000000100 35 | -11----- -000000000000000100000000000000 36 | -11-0--- -000000000000000100000000000000 37 | -110---- -000000000000000100000000000000 38 | 01101--- -001000001000000000000000000100 39 | -11-1--- -000000000000000100000000000000 40 | 0111---- -001000001000000000000000000100 41 | -111---- -000000000000000100000000000000 42 | 1--00--- -000000000000000100000000000000 43 | 1------- -000000000000000100000000000000 44 | 1---0--- -000000000000000100000000000000 45 | 1--0---- -000000000000000100000000000000 46 | 100000-- -000000000000000000000001000000 47 | 100000-1 -000100000000000000000000000000 48 | 100001-- -000000000000000100000001101000 49 | 100001-1 -000100000000000000000000000000 50 | 1--01--- -000000000000000100000000000000 51 | 1---1--- -000000000000000100000000000000 52 | 1--1---- -000000000000000100000000000000 53 | 1--10--- -000000000000000100000000000000 54 | 100100-- -000100000000000000000110000000 55 | 100101-- -000100000000000100000110101000 56 | 1--11--- -000000000000000100000000000000 57 | 10011--- -000000000000000000000000010000 58 | 101000-- -000010000000000001000000000000 59 | 1-1-0--- -000000000000000100000000000000 60 | 1-10---- -000000000000000100000000000000 61 | 1-1----- -000000000000000100000000000000 62 | 101001-- -000010000000000010000000000000 63 | 1-1-1--- -000000000000000100000000000000 64 | 101010-- -000010000000000001000000000000 65 | 101011-- -000010000000000010000000000000 66 | 1-11---- -000000000000000100000000000000 67 | 10110--- -000010000000000000000000000001 68 | 10111--- -000010000000000000000000000000 69 | 11--0--- -000000000000000100000000000000 70 | 1100---- -001100000000000000000100000000 71 | 11-0---- -000000000000000100000000000000 72 | 11------ -000000000000000100000000000000 73 | 11--1--- -000000000000000100000000000000 74 | 1101---- -000000000000000000000000010000 75 | 11-1---- -000000000000000100000000000000 76 | 111----- -000000000000000100001000001000 77 | -------------------------------------------------------------------------------- /examples/risc: -------------------------------------------------------------------------------- 1 | .i 8 2 | .o 31 3 | 00000--- 0000100000000010001000000000000 4 | 00001--- 0000100000000010000000000000000 5 | 0001---- 0000100000000010000100000000000 6 | --1-0--- 0000000000000001000000000000000 7 | 0010-0-- 0000001100000000000000000000000 8 | --100--- 0000000000000001000000000000000 9 | --10---- 0000000000000001000000000000000 10 | --1----- 0000000000000001000000000000000 11 | 0010-1-- 0000001000000000000000000000100 12 | --1-1--- 0000000000000001000000000000000 13 | --101--- 0000000000000001000000000000000 14 | --11---- 0000000000000001000000000000000 15 | 001100-- 0000010100000000000000000000000 16 | --110--- 0000000000000001000000000000000 17 | 001101-- 0110010000000000000000000000000 18 | --111--- 0000000000000001000000000000000 19 | 00111--- 1000010100000000000000000000000 20 | -1-0---- 0000000000000001000000000000000 21 | -1------ 0000000000000001000000000000000 22 | -1--0--- 0000000000000001000000000000000 23 | -1-00--- 0000000000000001000000000000000 24 | 010000-- 1000000001110100000000000001000 25 | 0100010- 1000000001101100000000000001000 26 | 0100011- 0000000000110100000000000001000 27 | -1--1--- 0000000000000001000000000000000 28 | -1-01--- 0000000000000001000000000000000 29 | 01001--- 0000000000101100000000000001000 30 | -1-1---- 0000000000000001000000000000000 31 | -1-10--- 0000000000000001000000000000000 32 | 0101---- 0000000000000100000000000001000 33 | -1-11--- 0000000000000001000000000000000 34 | 01100--- 0010000010000000000000000001000 35 | -11----- 0000000000000001000000000000000 36 | -11-0--- 0000000000000001000000000000000 37 | -110---- 0000000000000001000000000000000 38 | 01101--- 0010000010000000000000000001000 39 | -11-1--- 0000000000000001000000000000000 40 | 0111---- 0010000010000000000000000001000 41 | -111---- 0000000000000001000000000000000 42 | 1--00--- 0000000000000001000000000000000 43 | 1------- 0000000000000001000000000000000 44 | 1---0--- 0000000000000001000000000000000 45 | 1--0---- 0000000000000001000000000000000 46 | 100000-- 0000000000000000000000010000000 47 | 100000-1 0001000000000000000000000000000 48 | 100001-- 0000000000000001000000011010000 49 | 100001-1 0001000000000000000000000000000 50 | 1--01--- 0000000000000001000000000000000 51 | 1---1--- 0000000000000001000000000000000 52 | 1--1---- 0000000000000001000000000000000 53 | 1--10--- 0000000000000001000000000000000 54 | 100100-- 0001000000000000000001100000000 55 | 100101-- 0001000000000001000001101010000 56 | 1--11--- 0000000000000001000000000000000 57 | 10011--- 0000000000000000000000000100000 58 | 101000-- 0000100000000000010000000000001 59 | 1-1-0--- 0000000000000001000000000000000 60 | 1-10---- 0000000000000001000000000000000 61 | 1-1----- 0000000000000001000000000000000 62 | 101001-- 0000100000000000100000000000001 63 | 1-1-1--- 0000000000000001000000000000000 64 | 101010-- 0000100000000000010000000000000 65 | 101011-- 0000100000000000100000000000000 66 | 1-11---- 0000000000000001000000000000000 67 | 10110--- 0000100000000000000000000000010 68 | 10111--- 0000100000000000000000000000000 69 | 11--0--- 0000000000000001000000000000000 70 | 1100---- 0011000000000000000001000000000 71 | 11-0---- 0000000000000001000000000000000 72 | 11------ 0000000000000001000000000000000 73 | 11--1--- 0000000000000001000000000000000 74 | 1101---- 0000000000000000000000000100000 75 | 11-1---- 0000000000000001000000000000000 76 | 111----- 0000000000000001000010000010000 77 | -------------------------------------------------------------------------------- /espresso-src/util_signature.c: -------------------------------------------------------------------------------- 1 | /* Module:util_signature.c 2 | * Purpose: 3 | * contains miscellaneous utility routines 4 | * Routines: 5 | * void set_time_limit(seconds) 6 | * sets the cpu time limit 7 | * int sf_equal(): 8 | * checks equlaity of two set families. 9 | * int print_cover(): 10 | * prints cover. 11 | * int mem_usage(): 12 | * current Memory usage. 13 | * Initialized on the first call. 14 | * int time_usage(): 15 | * current time usage. 16 | * Initialized on the first call. 17 | */ 18 | 19 | #include 20 | #include 21 | #include "espresso.h" 22 | #include "signature.h" 23 | #include 24 | #include 25 | #include 26 | 27 | void 28 | set_time_limit(int seconds) 29 | { 30 | struct rlimit rlp_st, *rlp = &rlp_st; 31 | rlp->rlim_cur = seconds; 32 | setrlimit(RLIMIT_CPU, rlp); 33 | } 34 | 35 | void 36 | print_cover(pset_family F, char *name) 37 | { 38 | pcube last, p; 39 | printf("%s:\t %d\n",name,F->count); 40 | foreach_set(F,last,p){ 41 | print_cube(stdout,p,"~0"); 42 | } 43 | /* printf("\n\n",name); AB? */ 44 | printf("\n\n"); 45 | } 46 | 47 | /* sf_equal: Check equality of two set families */ 48 | int 49 | sf_equal(pset_family F1, pset_family F2) 50 | { 51 | int i; 52 | int count = F1->count; 53 | pcube *list1,*list2; 54 | 55 | if(F1->count != F2->count){ 56 | return(FALSE); 57 | } 58 | 59 | list1 = sf_sort(F1, (qsort_compare_func) descend); 60 | list2 = sf_sort(F2, (qsort_compare_func) descend); 61 | 62 | for(i = 0; i < count; i++){ 63 | if(!setp_equal(list1[i],list2[i])){ 64 | return FALSE; 65 | } 66 | } 67 | 68 | return TRUE; 69 | } 70 | 71 | /* mem_usage: 72 | * Initialized on first call. Prints current memory usage. 73 | */ 74 | int 75 | mem_usage(char *name) 76 | { 77 | static int memory_init; 78 | int memory_current; 79 | static int flag = 1; 80 | 81 | if(flag){ 82 | memory_init = 0; 83 | /* AB, sbrk is soooo BSD sbrk(0); */ 84 | flag = 0; 85 | } 86 | 87 | memory_current = 0; 88 | /* AB, sbrk is soooo BSD sbrk(0); */ 89 | 90 | printf("Memory %s\t %d\n", name, memory_current - memory_init); 91 | 92 | return memory_current; 93 | 94 | } 95 | 96 | /* time_usage: 97 | * Initialized on first call. Prints current time usage. 98 | */ 99 | int 100 | time_usage(char *name) 101 | { 102 | static int time_init; 103 | int time_current; 104 | static int flag = 1; 105 | 106 | if(flag){ 107 | time_init = ptime(); 108 | flag = 0; 109 | return time_init; 110 | } 111 | 112 | time_current = ptime(); 113 | 114 | printf("%s\t %ld\n", name, (time_current - time_init)/1000L); 115 | 116 | return time_current; 117 | 118 | } 119 | 120 | /* s_totals : add time spent in the function and update call count */ 121 | void 122 | s_totals(long int time, int i) 123 | { 124 | time = ptime() - time; 125 | total_time[i] += time; 126 | total_calls[i]++; 127 | } 128 | 129 | void 130 | s_runtime(long int total) 131 | { 132 | int i; 133 | long temp; 134 | 135 | for(i = 0; i < TIME_COUNT; i++) { 136 | if (total_calls[i] != 0) { 137 | temp = 100 * total_time[i]; 138 | printf("# %s\t%2d call(s) for %s ( %2ld.%01ld%% )\n", 139 | total_name[i], total_calls[i], print_time(total_time[i]), 140 | temp/total, (10 * (temp%total)) / total); 141 | } 142 | } 143 | } 144 | 145 | -------------------------------------------------------------------------------- /tlex/bw.pla: -------------------------------------------------------------------------------- 1 | 2 | .i 5 3 | .o 28 4 | .p 87 5 | 00000 ~~~~~~~~~~~~~~~~~~~~~~~~~~~1 6 | -00-0 ~~~~~~~~~~~~~~~~~~~1~~~~~~~~ 7 | 0-100 ~~~1~~~~~~~~~~1~~~~1~~~~~~~~ 8 | 1-0-0 ~~~1~~~~~~~~~~~~~~~1~~~~~~~~ 9 | 1-01- ~~~1~~1~~~~~~~~~~~~1~~~~~~~~ 10 | 0-001 ~~~1~~~~~~~~~~~~~~~1~~~~~~~~ 11 | --010 ~~~1~~~~1~~~~~~~~~~1~~~~~~~~ 12 | --0-- ~~~~~~~~~1~~1~~~1~~~~~~~~~~~ 13 | 0---0 ~~~~~1~~~1~~1~~~~~~~~~~~1~~~ 14 | 00-0- ~~~~~~~~~~~~1~~~~~~~~~~~~~~~ 15 | -10-- ~1~~~1~~~~~~~~~~~~~~~~~~1~~~ 16 | -10-0 ~~~~~~~~1~~~~~~~~~~~~~~~~~~~ 17 | 0-10- ~~~~~1~~~~~~~~~~~~~~~~~~~~~~ 18 | --01- ~~~~~1~~~~~~~~~~~~~~~~~~~~~~ 19 | 1-0-- ~~~~~1~~~~~~~~~~~~~~~~~~~~1~ 20 | 0--0- ~~~~~~~~~~~~~~~~1~~~~~~~1~~~ 21 | --0-1 ~~~~~~~~~~~~~~~~~~~~~~~~1~1~ 22 | --00- ~~~~~~~~~~~~~~~~~~~~~~~~1~~~ 23 | 0001- ~~~~~~~~~~~~~~~1~~~~~~~~~~~~ 24 | 001-0 ~~~~~~~~~~~~~~~~~~~~~~~1~~~~ 25 | 10010 ~~~~~~~~~~~~~~~~~~~~~~~1~~~~ 26 | 01010 ~~~~~~~~~~~~~~~~~~~~~~~1~~~~ 27 | 01--0 ~1~~~~~~~~~~~~~~1~~~~~~~~~~~ 28 | 00110 ~~~~1~~~~~~~~~~~~~~~~~~~~~~~ 29 | 1001- ~~~~1~~~~~~~~~~~~~~~~~~~~~~~ 30 | 01-0- ~1~~~~~~~1~~~~~~~~~~~~~~~~~~ 31 | 0-010 ~~1~~~~~~~~~~~~~~1~~~~~~~~~~ 32 | 00001 ~~1~~~~~~~~~~~~~~~~~~~~~~~~~ 33 | 1-000 ~~1~~~~~~~~~~~~~~~~~~~~~~~~~ 34 | 01100 ~~~~~~~~~~~~~~~~~~~~~1~~~~~~ 35 | 01000 ~~~~~~~~~~1~~1~~~~~~~~~~~~~~ 36 | 00100 ~~~~~~~~1~~~~1~~~~~~~~~~~~1~ 37 | 1-0-1 ~~~~~~1~1~~~~1~~~~~~1~~~~~~~ 38 | 1101- ~~~~~~~~~~~~~1~~~~~~~~~~~~~~ 39 | -1011 ~~~~~~1~~~~~~~~~~~~~~~~~~~~~ 40 | 011-0 1~~~~~1~~~~~~~~~~~~~~~~~~~~~ 41 | -0000 ~~~~~~~~~~~1~~~~~~~~~~~~~~~~ 42 | 0-110 1~~~~~1~~~~~~~~1~~~~1~1~~~~~ 43 | 00-00 ~~~~~~~~~~~1~~~~~~~~~~~~~~~~ 44 | 110-- ~~~~~~1~~~~~~~~~~~~~~~~~~~~~ 45 | 1-011 ~~~~~~~~~~~~~~~~~1~~~~~~~1~~ 46 | -1001 1~~~~~~~~~~~~~~~~~~~~~~~~1~~ 47 | -0011 ~~~~~~~~~~~1~~~~~~~~~~~~~1~~ 48 | 0-1-0 ~~~~~~~1~~~~~~~~~~~~~~~~~1~~ 49 | 10000 ~~~~~~~~~~~~~~~~~1~~~~~~~1~~ 50 | 110-1 ~~~~~~~~~~~~~~~~~1~~~~~~~~~~ 51 | 1000- ~~~~~~~~~~~~~~~~~~1~~~~~~~~~ 52 | 0100- ~~~~~~~~~~~~~~~1~1~~~~~~~~~~ 53 | 000-1 ~~~~1~~~~~~~~~~~~1~~~~~1~~~~ 54 | 0010- ~~~~~~~~~~~~~~~~~~1~~~~~~~~~ 55 | -0001 ~~~~~~~~1~~~~~~~~~1~~~~~~~~~ 56 | -101- ~~~~~~~~~~~~~~~~~~~~~~~~~~1~ 57 | 00010 ~~~~~~~~~~1~~~~~~~1~~~~~~~~~ 58 | --011 ~~~~~~~~~~~~~~~~~~~~1~~~~~~~ 59 | 11010 1~~~~~~~~~~~~~~~~~~~~~~~~~~~ 60 | 1-010 ~~~~1~~1~~~~~~~~~~~~~~~~~~~~ 61 | 0--00 ~~~~~~~1~~~~~~~~~~~~~~~~~~~~ 62 | 00--0 ~~~~~~~1~~~~~~~~~~~~~~~~~~~~ 63 | 000-0 ~~~~~~~~~~~1~~~~~~~~~~1~~~~~ 64 | 0-000 ~~~~~~~~~~~~~~~~~~~~1~1~~~~~ 65 | 1-001 1~~~~~~~~~~~~~~~~~~~~~1~~~~~ 66 | 0-011 ~~~~~~~~~~~~~~~1~~~~~~1~~~~~ 67 | 11011 ~~~~~~~~~~~~~~1~~~~~~~~1~~~~ 68 | 0-101 1~~~~~~~~~~~~~~~~~~~1~1~~~~~ 69 | 11000 ~~~~~~~~~~~~~~1~~~~~~~~~~~~~ 70 | 00011 -~~-~~~-~~-~~~-~~~~-~-~~~~~~ 71 | 01011 -~~-~~~-~~--~~-~~~--~-~~~~~~ 72 | 10001 ~~--~~~-~~-~~~-~~~~-~~~~~~~~ 73 | 11001 ~~--~~~-~~--~~~~~~--~~~~~~~~ 74 | 00110 ~~~-~~~~~~-~~~-~~~~-~-~~~~-~ 75 | 01110 ~~--~~~~~~--~~-~~~--~~~~~~-~ 76 | 00101 ~~---~---~-~~---~-~-~-~-~--~ 77 | 01101 ~~---~---~--~---~---~-~-~--~ 78 | 00000 -~-~-~-~-~~~~---~-~~~-~-~-~~ 79 | 10010 ~~-~~~~~~~~~~~-~~~~~-~~~~~~~ 80 | 11010 ~~-~~~~~~~~-~~-~~~-~~~~~~~~~ 81 | 01100 ~~~~~~~~~~~-~~~~~~-~~~~~~~-~ 82 | 11000 -~~~~~~~~~~-~~~~~~-~-~~~~~~~ 83 | 10011 -~-~~~~-~~~~~~~~~~~~~~~~~~~~ 84 | 11011 -~-~~~~~~~~-~~~~~~-~~~~~~~~~ 85 | 00100 ~~-~~~~~~~~~~~~~~~~~-~~~~~~~ 86 | 10000 -~~~~~~-~~~~~~~~~~~~-~~~~~~~ 87 | 00001 ~~~~~~~-~~~~~~-~~~~~-~~~~~~~ 88 | 01010 -~~~~~~~~~~-~~-~~~-~-~~~~~~~ 89 | 00010 -~~~~~~~~~~~~~-~~~~~-~~~~~~~ 90 | 01000 -~~~~~~~~~~-~~-~~~-~~-~~~~~~ 91 | 01001 ~~~~~~~-~~~-~~-~~~-~~-~~~~~~ 92 | .e 93 | -------------------------------------------------------------------------------- /examples/in6: -------------------------------------------------------------------------------- 1 | .i 33 2 | .o 23 3 | 1------1------------------------- 00010001111001000110100 4 | 0---0---------------------------1 01000000000000000000000 5 | 01--------------------1-----1-10- 10000000000000000000000 6 | 0--------------00--------------1- 10000000000000000000000 7 | 0--------0100-01010---------0-1-- 00000100110010000000000 8 | 0--1------------------------000-- 00100000000000000000110 9 | 0--------0100--0101---------0-1-- 00000011001100000000000 10 | 0--1------------------------010-- 00110000000000000000010 11 | ------01-0100--1000---------0-1-- 00000000101000000000000 12 | 0--------10-0------111------011-- 00001000000000000001100 13 | 0-----0--0100--0010---------0-1-- 00000010000010000000000 14 | ---1----------------------10----- 00000000000000000010000 15 | 0--------1110------1-1------011-- 00001000000000000001100 16 | 0--------0111--------1------011-- 00001000000000000001100 17 | 0--------1111------11-------011-- 00001000000000000001011 18 | 0----1--------------------------- 00000000000000001000000 19 | ---0-----------------------1----- 00000000000000000010000 20 | 0---------------------1-----1-1-- 00000000000000001000000 21 | 01----1--0011--001-----1----0-1-- 00000010000000000000000 22 | 01-------0011--0011----1------1-- 00000000000100000000000 23 | 01----0-00011--0011----1----0-1-- 00000010000010000000000 24 | 01----1--0011--1-00---1-----0-1-- 00000000001000000000000 25 | 0--------1011------111------011-- 00001000000000000001110 26 | 01-------0011--0000----1----0-1-- 00000010000000000000000 27 | 1------0------------------------- 00010001100111000110100 28 | 01-------------0101---1-----1-1-- 00000001001000000000000 29 | -1-----------------------1--11--- 00000000000001000000000 30 | 01-----------1--------0-1---11--- 00000000000000100000000 31 | 0--------0100---------------0-1-- 00001000000000000110000 32 | 0--------0010---------------0-1-- 00001000000000000001010 33 | 0--------1101---------------0-1-- 00001000000000000001100 34 | 01----01-------1000----1----1-1-- 00000100000000000000000 35 | 01----0--------0010----1----1-1-- 00000110000000000000000 36 | 01--------------010----1----1-1-- 00000000000010000000000 37 | 01------------01010----1----1-1-- 00000100000000000000000 38 | 01-------------0101----1----1-1-- 00000010000100000000000 39 | 01-------------0011----1----1-1-- 00000000000110000000000 40 | -1-------------10-0---1-----1-1-- 00000000100000000000000 41 | -1----01-------1000---1-----1-1-- 00000000011000000000000 42 | -1-------------1100---1-----1-1-- 00000001100000000000000 43 | 01----0--------0010---1-----1-1-- 00000000010000000000000 44 | 01------------01010---1-----1-1-- 00000000010000000000000 45 | -1-----1-0011--0000---1-----0-1-- 00000000001000000000000 46 | 01----1--0011---000---1-----0-1-- 00000000001000000000000 47 | ---0------------------------010-- 00000000000000000000100 48 | --1-------------------------000-- 00000000000000000000100 49 | --------------------------11----- 00000000000000000100000 50 | ---0----------------------1------ 00000000000000000100000 51 | 0--------10-1------111------011-- 00001000000000000001010 52 | 0--------1-00------111------011-- 00001000000000000001010 53 | 01----------------------1---11--0 01000000000000000000000 54 | 01----------------------1---11--- 00000000000001010000000 55 | 01----0-10011--1100---1-----0-1-- 00000000101000000000000 56 | -1-------0011--1100---1-------1-- 00000001000000000000000 57 | -------------------------------------------------------------------------------- /examples/b9: -------------------------------------------------------------------------------- 1 | .i 16 2 | .o 5 3 | -----------1---1 00001 4 | ----001----1---- 00010 5 | ----001---1----- 00100 6 | ----001--1------ 01000 7 | ----001-1------- 10000 8 | ----010--------1 00010 9 | ----010-------1- 00100 10 | ----010------1-- 01000 11 | ----010-----1--- 10000 12 | ----011----1---1 00010 13 | ----011---1---1- 00100 14 | ----011--1---1-- 01000 15 | ----011-1---1--- 10000 16 | ----101----0---1 00010 17 | ----101---0---1- 00100 18 | ----101--0---1-- 01000 19 | ----101-0---1--- 10000 20 | ----101----1---0 00010 21 | ----101---1---0- 00100 22 | ----101--1---0-- 01000 23 | ----101-1---0--- 10000 24 | ----11-0--0000-1 00010 25 | --0-11----00---1 00010 26 | ----11-0-0-00-01 00010 27 | ----11-00-00-0-1 00010 28 | 0---11--0-00-0-1 00010 29 | ----11-000-0--01 00010 30 | ----11-00000---1 00010 31 | ----11-0---00001 00010 32 | -0--11---000---1 00010 33 | -0--11---0-0--01 00010 34 | 0---11-----00001 00010 35 | ----11-00--0-001 00010 36 | 0---11--0--0-001 00010 37 | --0-11-----0--01 00010 38 | 0---11---0000--1 00010 39 | -0--11-----0-001 00010 40 | 0---11----0000-1 00010 41 | ----11-0-0000--1 00010 42 | 0---11---0-00-01 00010 43 | 0---11--00-0--01 00010 44 | -0--11----00-0-1 00010 45 | 0---11--0000---1 00010 46 | ----11-0-00-0-1- 00100 47 | ----11-0000---1- 00100 48 | 0---11--0-0--01- 00100 49 | 0---11--000---1- 00100 50 | ----11-0--0-001- 00100 51 | ----11-00-0--01- 00100 52 | -0--11---00---1- 00100 53 | -0--11----0--01- 00100 54 | 0---11----0-001- 00100 55 | 0---11---00-0-1- 00100 56 | 0---11---0--01-- 01000 57 | ----11-000---1-- 01000 58 | ----11-0-0--01-- 01000 59 | 0---11--00---1-- 01000 60 | ----11-00---1--- 10000 61 | --0-11-----1--00 00010 62 | ----11-00-01-0-0 00010 63 | ----11-000-1--00 00010 64 | ----11-00001---0 00010 65 | -0--11---0-1--00 00010 66 | -0--11---001---0 00010 67 | -0--11----01-0-0 00010 68 | 0---11-----10000 00010 69 | 0---11----0100-0 00010 70 | 0---11---0-10-00 00010 71 | -0--11-----1-000 00010 72 | 0---11---0010--0 00010 73 | ----11-0---10000 00010 74 | 0---11--0--1-000 00010 75 | 0---11--0-01-0-0 00010 76 | 0---11--00-1--00 00010 77 | 0---11--0001---0 00010 78 | ----11-0--0100-0 00010 79 | ----11-0-0-10-00 00010 80 | ----11-0-0010--0 00010 81 | --0-11----01---0 00010 82 | ----11-00--1-000 00010 83 | 0---11--0-1--00- 00100 84 | -0--11---01---0- 00100 85 | 0---11---01-0-0- 00100 86 | -0--11----1--00- 00100 87 | ----11-0-01-0-0- 00100 88 | 0---11----1-000- 00100 89 | 0---11--001---0- 00100 90 | ----11-00-1--00- 00100 91 | ----11-0001---0- 00100 92 | ----11-0--1-000- 00100 93 | ----11----10--10 00010 94 | ----11----11--11 00010 95 | 0---11---1--00-- 01000 96 | ----11-0-1--00-- 01000 97 | ----11-001---0-- 01000 98 | 0---11--01---0-- 01000 99 | ----11---10--10- 00100 100 | ----11---11--11- 00100 101 | ----11-01---0--- 10000 102 | ----11--10--10-- 01000 103 | ----11--11--11-- 01000 104 | ----11-10---0--- 10000 105 | ----11-11---1--- 10000 106 | ---1------1---1- 00001 107 | ---1100--------- 00010 108 | --1-100--------- 00100 109 | --1-11---1-0-1-0 00010 110 | --1-11---1-1-1-1 00010 111 | --11-----1---1-- 00001 112 | -1--100--------- 01000 113 | -1--11--1-0-1-0- 00100 114 | -1--11--1-1-1-1- 00100 115 | -11-11--1--01--0 00010 116 | -11-11--1--11--1 00010 117 | -111----1---1--- 00001 118 | 1---100--------- 10000 119 | 1---11-1-0---0-- 01000 120 | 1---11-1-1---1-- 01000 121 | 1-11---1-------- 00001 122 | 11--11-1--0---0- 00100 123 | 11--11-1--1---1- 00100 124 | 111-11-1---0---0 00010 125 | 111-11-1---1---1 00010 126 | -------------------------------------------------------------------------------- /examples/ex7: -------------------------------------------------------------------------------- 1 | .i 16 2 | .o 5 3 | -----------1---1 00001 4 | ----001----1---- 00010 5 | ----001---1----- 00100 6 | ----001--1------ 01000 7 | ----001-1------- 10000 8 | ----010--------1 00010 9 | ----010-------1- 00100 10 | ----010------1-- 01000 11 | ----010-----1--- 10000 12 | ----011----1---1 00010 13 | ----011---1---1- 00100 14 | ----011--1---1-- 01000 15 | ----011-1---1--- 10000 16 | ----101----0---1 00010 17 | ----101---0---1- 00100 18 | ----101--0---1-- 01000 19 | ----101-0---1--- 10000 20 | ----101----1---0 00010 21 | ----101---1---0- 00100 22 | ----101--1---0-- 01000 23 | ----101-1---0--- 10000 24 | ----11-0--0000-1 00010 25 | --0-11----00---1 00010 26 | ----11-0-0-00-01 00010 27 | ----11-00-00-0-1 00010 28 | 0---11--0-00-0-1 00010 29 | ----11-000-0--01 00010 30 | ----11-00000---1 00010 31 | ----11-0---00001 00010 32 | -0--11---000---1 00010 33 | -0--11---0-0--01 00010 34 | 0---11-----00001 00010 35 | ----11-00--0-001 00010 36 | 0---11--0--0-001 00010 37 | --0-11-----0--01 00010 38 | 0---11---0000--1 00010 39 | -0--11-----0-001 00010 40 | 0---11----0000-1 00010 41 | ----11-0-0000--1 00010 42 | 0---11---0-00-01 00010 43 | 0---11--00-0--01 00010 44 | -0--11----00-0-1 00010 45 | 0---11--0000---1 00010 46 | ----11-0-00-0-1- 00100 47 | ----11-0000---1- 00100 48 | 0---11--0-0--01- 00100 49 | 0---11--000---1- 00100 50 | ----11-0--0-001- 00100 51 | ----11-00-0--01- 00100 52 | -0--11---00---1- 00100 53 | -0--11----0--01- 00100 54 | 0---11----0-001- 00100 55 | 0---11---00-0-1- 00100 56 | 0---11---0--01-- 01000 57 | ----11-000---1-- 01000 58 | ----11-0-0--01-- 01000 59 | 0---11--00---1-- 01000 60 | ----11-00---1--- 10000 61 | --0-11-----1--00 00010 62 | ----11-00-01-0-0 00010 63 | ----11-000-1--00 00010 64 | ----11-00001---0 00010 65 | -0--11---0-1--00 00010 66 | -0--11---001---0 00010 67 | -0--11----01-0-0 00010 68 | 0---11-----10000 00010 69 | 0---11----0100-0 00010 70 | 0---11---0-10-00 00010 71 | -0--11-----1-000 00010 72 | 0---11---0010--0 00010 73 | ----11-0---10000 00010 74 | 0---11--0--1-000 00010 75 | 0---11--0-01-0-0 00010 76 | 0---11--00-1--00 00010 77 | 0---11--0001---0 00010 78 | ----11-0--0100-0 00010 79 | ----11-0-0-10-00 00010 80 | ----11-0-0010--0 00010 81 | --0-11----01---0 00010 82 | ----11-00--1-000 00010 83 | 0---11--0-1--00- 00100 84 | -0--11---01---0- 00100 85 | 0---11---01-0-0- 00100 86 | -0--11----1--00- 00100 87 | ----11-0-01-0-0- 00100 88 | 0---11----1-000- 00100 89 | 0---11--001---0- 00100 90 | ----11-00-1--00- 00100 91 | ----11-0001---0- 00100 92 | ----11-0--1-000- 00100 93 | ----11----10--10 00010 94 | ----11----11--11 00010 95 | 0---11---1--00-- 01000 96 | ----11-0-1--00-- 01000 97 | ----11-001---0-- 01000 98 | 0---11--01---0-- 01000 99 | ----11---10--10- 00100 100 | ----11---11--11- 00100 101 | ----11-01---0--- 10000 102 | ----11--10--10-- 01000 103 | ----11--11--11-- 01000 104 | ----11-10---0--- 10000 105 | ----11-11---1--- 10000 106 | ---1------1---1- 00001 107 | ---1100--------- 00010 108 | --1-100--------- 00100 109 | --1-11---1-0-1-0 00010 110 | --1-11---1-1-1-1 00010 111 | --11-----1---1-- 00001 112 | -1--100--------- 01000 113 | -1--11--1-0-1-0- 00100 114 | -1--11--1-1-1-1- 00100 115 | -11-11--1--01--0 00010 116 | -11-11--1--11--1 00010 117 | -111----1---1--- 00001 118 | 1---100--------- 10000 119 | 1---11-1-0---0-- 01000 120 | 1---11-1-1---1-- 01000 121 | 1-11---1-------- 00001 122 | 11--11-1--0---0- 00100 123 | 11--11-1--1---1- 00100 124 | 111-11-1---0---0 00010 125 | 111-11-1---1---1 00010 126 | -------------------------------------------------------------------------------- /espresso-src/indep.c: -------------------------------------------------------------------------------- 1 | #include "mincov_int.h" 2 | 3 | static sm_matrix *build_intersection_matrix(sm_matrix *A); 4 | 5 | 6 | #if 0 7 | /* 8 | * verify that all rows in 'indep' are actually independent ! 9 | */ 10 | static int 11 | verify_indep_set(A, indep) 12 | sm_matrix *A; 13 | sm_row *indep; 14 | { 15 | register sm_row *prow, *prow1; 16 | register sm_element *p, *p1; 17 | 18 | for(p = indep->first_col; p != 0; p = p->next_col) { 19 | prow = sm_get_row(A, p->col_num); 20 | for(p1 = p->next_col; p1 != 0; p1 = p1->next_col) { 21 | prow1 = sm_get_row(A, p1->col_num); 22 | if (sm_row_intersects(prow, prow1)) { 23 | return 0; 24 | } 25 | } 26 | } 27 | return 1; 28 | } 29 | #endif 30 | 31 | solution_t * 32 | sm_maximal_independent_set(sm_matrix *A, int *weight) 33 | { 34 | register sm_row *best_row, *prow; 35 | register sm_element *p; 36 | int least_weight; 37 | sm_row *save; 38 | sm_matrix *B; 39 | solution_t *indep; 40 | 41 | indep = solution_alloc(); 42 | B = build_intersection_matrix(A); 43 | 44 | while (B->nrows > 0) { 45 | /* Find the row which is disjoint from a maximum number of rows */ 46 | best_row = B->first_row; 47 | for(prow = B->first_row->next_row; prow != 0; prow = prow->next_row) { 48 | if (prow->length < best_row->length) { 49 | best_row = prow; 50 | } 51 | } 52 | 53 | /* Find which element in this row has least weight */ 54 | if (weight == NIL(int)) { 55 | least_weight = 1; 56 | } else { 57 | prow = sm_get_row(A, best_row->row_num); 58 | least_weight = weight[prow->first_col->col_num]; 59 | for(p = prow->first_col->next_col; p != 0; p = p->next_col) { 60 | if (weight[p->col_num] < least_weight) { 61 | least_weight = weight[p->col_num]; 62 | } 63 | } 64 | } 65 | indep->cost += least_weight; 66 | (void) sm_row_insert(indep->row, best_row->row_num); 67 | 68 | /* Discard the rows which intersect this row */ 69 | save = sm_row_dup(best_row); 70 | for(p = save->first_col; p != 0; p = p->next_col) { 71 | sm_delrow(B, p->col_num); 72 | sm_delcol(B, p->col_num); 73 | } 74 | sm_row_free(save); 75 | } 76 | 77 | sm_free(B); 78 | 79 | /* 80 | if (! verify_indep_set(A, indep->row)) { 81 | fail("sm_maximal_independent_set: row set is not independent"); 82 | } 83 | */ 84 | return indep; 85 | } 86 | 87 | static sm_matrix * 88 | build_intersection_matrix(sm_matrix *A) 89 | { 90 | register sm_row *prow, *prow1; 91 | register sm_element *p, *p1; 92 | register sm_col *pcol; 93 | sm_matrix *B; 94 | 95 | /* Build row-intersection matrix */ 96 | B = sm_alloc(); 97 | for(prow = A->first_row; prow != 0; prow = prow->next_row) { 98 | 99 | /* Clear flags on all rows we can reach from row 'prow' */ 100 | for(p = prow->first_col; p != 0; p = p->next_col) { 101 | pcol = sm_get_col(A, p->col_num); 102 | for(p1 = pcol->first_row; p1 != 0; p1 = p1->next_row) { 103 | prow1 = sm_get_row(A, p1->row_num); 104 | prow1->flag = 0; 105 | } 106 | } 107 | 108 | /* Now record which rows can be reached */ 109 | for(p = prow->first_col; p != 0; p = p->next_col) { 110 | pcol = sm_get_col(A, p->col_num); 111 | for(p1 = pcol->first_row; p1 != 0; p1 = p1->next_row) { 112 | prow1 = sm_get_row(A, p1->row_num); 113 | if (! prow1->flag) { 114 | prow1->flag = 1; 115 | (void) sm_insert(B, prow->row_num, prow1->row_num); 116 | } 117 | } 118 | } 119 | } 120 | 121 | return B; 122 | } 123 | -------------------------------------------------------------------------------- /espresso-src/map.c: -------------------------------------------------------------------------------- 1 | #include "espresso.h" 2 | 3 | static pcube Gcube; 4 | static pset Gminterm; 5 | 6 | pset minterms(pset_family T) 7 | { 8 | int size, var; 9 | register pcube last; 10 | 11 | size = 1; 12 | for(var = 0; var < cube.num_vars; var++) 13 | size *= cube.part_size[var]; 14 | Gminterm = set_new(size); 15 | 16 | foreach_set(T, last, Gcube) 17 | explode(cube.num_vars-1, 0); 18 | 19 | return Gminterm; 20 | } 21 | 22 | 23 | void explode(int var, int z) 24 | { 25 | int i, last = cube.last_part[var]; 26 | for(i=cube.first_part[var], z *= cube.part_size[var]; i<=last; i++, z++) 27 | if (is_in_set(Gcube, i)) 28 | { 29 | if (var == 0) 30 | set_insert(Gminterm, z); 31 | else 32 | explode(var-1, z); 33 | } 34 | } 35 | 36 | 37 | static int mapindex[16][16] = { 38 | {0, 1, 3, 2, 16, 17, 19, 18, 80, 81, 83, 82, 64, 65, 67, 66}, 39 | {4, 5, 7, 6, 20, 21, 23, 22, 84, 85, 87, 86, 68, 69, 71, 70}, 40 | {12, 13, 15, 14, 28, 29, 31, 30, 92, 93, 95, 94, 76, 77, 79, 78}, 41 | {8, 9, 11, 10, 24, 25, 27, 26, 88, 89, 91, 90, 72, 73, 75, 74}, 42 | 43 | {32, 33, 35, 34, 48, 49, 51, 50, 112,113,115,114, 96, 97, 99, 98}, 44 | {36, 37, 39, 38, 52, 53, 55, 54, 116,117,119,118, 100,101,103,102}, 45 | {44, 45, 47, 46, 60, 61, 63, 62, 124,125,127,126, 108,109,111,110}, 46 | {40, 41, 43, 42, 56, 57, 59, 58, 120,121,123,122, 104,105,107,106}, 47 | 48 | 49 | {160,161,163,162, 176,177,179,178, 240,241,243,242, 224,225,227,226}, 50 | {164,165,167,166, 180,181,183,182, 244,245,247,246, 228,229,231,230}, 51 | {172,173,175,174, 188,189,191,190, 252,253,255,254, 236,237,239,238}, 52 | {168,169,171,170, 184,185,187,186, 248,249,251,250, 232,233,235,234}, 53 | 54 | {128,129,131,130, 144,145,147,146, 208,209,211,210, 192,193,195,194}, 55 | {132,133,135,134, 148,149,151,150, 212,213,215,214, 196,197,199,198}, 56 | {140,141,143,142, 156,157,159,158, 220,221,223,222, 204,205,207,206}, 57 | {136,137,139,138, 152,153,155,154, 216,217,219,218, 200,201,203,202} 58 | }; 59 | 60 | #define POWER2(n) (1 << n) 61 | void map(pset_family T) 62 | { 63 | int j, k, l, other_input_offset, output_offset, outnum, ind; 64 | int largest_input_ind, numout; 65 | char c; 66 | pset m; 67 | bool some_output; 68 | 69 | m = minterms(T); 70 | largest_input_ind = POWER2(cube.num_binary_vars); 71 | numout = cube.part_size[cube.num_vars-1]; 72 | 73 | for(outnum = 0; outnum < numout; outnum++) { 74 | output_offset = outnum * largest_input_ind; 75 | printf("\n\nOutput space # %d\n", outnum); 76 | for(l = 0; l <= MAX(cube.num_binary_vars - 8, 0); l++) { 77 | other_input_offset = l * 256; 78 | for(k = 0; k < 16; k++) { 79 | some_output = FALSE; 80 | for(j = 0; j < 16; j++) { 81 | ind = mapindex[k][j] + other_input_offset; 82 | if (ind < largest_input_ind) { 83 | c = is_in_set(m, ind+output_offset) ? '1' : '.'; 84 | putchar(c); 85 | some_output = TRUE; 86 | } 87 | if ((j+1)%4 == 0) 88 | putchar(' '); 89 | if ((j+1)%8 == 0) 90 | printf(" "); 91 | } 92 | if (some_output) 93 | putchar('\n'); 94 | if ((k+1)%4 == 0) { 95 | if (k != 15 && mapindex[k+1][0] >= largest_input_ind) 96 | break; 97 | putchar('\n'); 98 | } 99 | if ((k+1)%8 == 0) 100 | putchar('\n'); 101 | } 102 | } 103 | } 104 | set_free(m); 105 | } 106 | -------------------------------------------------------------------------------- /tlex/clip.pla: -------------------------------------------------------------------------------- 1 | .i 9 2 | .o 5 3 | .p 167 4 | 101------ 10000 5 | 110------ 10000 6 | -01--0--- 10000 7 | -10--0--- 10000 8 | 001---0-- 10000 9 | 010---0-- 10000 10 | 00100---- 10000 11 | 0010---1- 10000 12 | 0010----1 10000 13 | 0100----1 10000 14 | 001-0---1 10000 15 | 1--1-00-1 10000 16 | 001----11 10000 17 | 1-11100-- 10000 18 | 01000--1- 10000 19 | 1-11-001- 10000 20 | 1--11001- 10000 21 | 1-1-100-1 10000 22 | 010-0--11 10000 23 | 1-1--0011 10000 24 | 1---10011 10000 25 | -0--00-1- 01000 26 | -0--0-01- 01000 27 | --0-0-01- 01000 28 | 1--1100-- 01000 29 | 10--0-11- 01000 30 | 1-1-0-11- 01000 31 | -0-00-11- 01000 32 | --100-11- 01000 33 | --1-0011- 01000 34 | -11-1-01- 01000 35 | 10--1-10- 01000 36 | 1-1-1-10- 01000 37 | -0--1010- 01000 38 | --1-1010- 01000 39 | 0-0-1-00- 01000 40 | 1--1-00-1 01000 41 | 1---100-1 01000 42 | -0--0-111 01000 43 | --1-0-111 01000 44 | 1111-00-- 01000 45 | 1-1100-1- 01000 46 | 110-1-11- 01000 47 | -10-1011- 01000 48 | 001-10-0- 01000 49 | 110-0-10- 01000 50 | -10-0010- 01000 51 | 001-1-00- 01000 52 | 10-11-00- 01000 53 | 1-011-00- 01000 54 | 011-0-00- 01000 55 | 111--00-1 01000 56 | 1-1-00-11 01000 57 | -0-01-101 01000 58 | --101-101 01000 59 | 10--1-001 01000 60 | 1-0-1-001 01000 61 | --001-000 01000 62 | 11110-00- 01000 63 | -1001-111 01000 64 | -1000-101 01000 65 | 111-0-001 01000 66 | -01010-00 01000 67 | -0101-000 01000 68 | -1100-000 01000 69 | 1--1-00-- 00100 70 | 1----00-1 00100 71 | -0-00-1-1 00100 72 | --100-1-1 00100 73 | -0-00-0-1 00100 74 | --000-0-1 00100 75 | -0-0--111 00100 76 | --10--111 00100 77 | ---00-111 00100 78 | ---11-011 00100 79 | -0-0--001 00100 80 | --00--001 00100 81 | ---00-001 00100 82 | -0-10-0-0 00100 83 | --010-0-0 00100 84 | ---01-010 00100 85 | -0-1--000 00100 86 | --01--000 00100 87 | ---10-000 00100 88 | -1111-0-1 00100 89 | -111--011 00100 90 | 1--11-101 00100 91 | ---110101 00100 92 | 10-10-1-0 00100 93 | 1-110-1-0 00100 94 | -0-1001-0 00100 95 | --11001-0 00100 96 | -1101-0-0 00100 97 | 10-1--110 00100 98 | 1-11--110 00100 99 | 1--10-110 00100 100 | -0-1-0110 00100 101 | --11-0110 00100 102 | ---100110 00100 103 | -110--010 00100 104 | 1--01-100 00100 105 | ---010100 00100 106 | 11011-1-1 00100 107 | -101101-1 00100 108 | 1101--101 00100 109 | -101-0101 00100 110 | 11001-1-0 00100 111 | -100101-0 00100 112 | 1100--100 00100 113 | -100-0100 00100 114 | 1----00-- 00010 115 | 1--0--1-1 00010 116 | 0--1--0-1 00010 117 | 1--0--0-0 00010 118 | 10-00-1-- 00010 119 | 1-100-1-- 00010 120 | 10-00-0-- 00010 121 | 1-000-0-- 00010 122 | 10-0--11- 00010 123 | 1-10--11- 00010 124 | 1--00-11- 00010 125 | 0--11-01- 00010 126 | 10-0--00- 00010 127 | 1-00--00- 00010 128 | 1--00-00- 00010 129 | 10--0-1-1 00010 130 | 1-1-0-1-1 00010 131 | 10----111 00010 132 | 1-1---111 00010 133 | 1---0-111 00010 134 | 0---1-011 00010 135 | 0--1-01-0 00010 136 | 10--0-0-0 00010 137 | 1-0-0-0-0 00010 138 | 10----000 00010 139 | 1-0---000 00010 140 | 1---0-000 00010 141 | 01111-0-- 00010 142 | 0111--01- 00010 143 | 0--11010- 00010 144 | 011-1-0-1 00010 145 | 011---011 00010 146 | 0---10100 00010 147 | 0101101-- 00010 148 | 0101-010- 00010 149 | 010-101-0 00010 150 | 010--0100 00010 151 | 0----1--- 00001 152 | -----11-- 00001 153 | ---0-1--0 00001 154 | -0-001--- 00001 155 | --0001--- 00001 156 | -0-0-1-0- 00001 157 | --00-1-0- 00001 158 | ---001-0- 00001 159 | -0--01--0 00001 160 | --0-01--0 00001 161 | 0--1--1-0 00001 162 | -0---1-00 00001 163 | --0--1-00 00001 164 | ----01-00 00001 165 | 0--11-10- 00001 166 | 0---1-100 00001 167 | 01011-1-- 00001 168 | 0101--10- 00001 169 | 010-1-1-0 00001 170 | 010---100 00001 171 | .e 172 | -------------------------------------------------------------------------------- /espresso-src/cvrmisc.c: -------------------------------------------------------------------------------- 1 | #include "espresso.h" 2 | 3 | 4 | /* cost -- compute the cost of a cover */ 5 | void cover_cost(pset_family F, pcost cost) 6 | { 7 | register pcube p, last; 8 | pcube *T; 9 | int var; 10 | 11 | /* use the routine used by cofactor to decide splitting variables */ 12 | massive_count(T = cube1list(F)); 13 | free_cubelist(T); 14 | 15 | cost->cubes = F->count; 16 | cost->total = cost->in = cost->out = cost->mv = cost->primes = 0; 17 | 18 | /* Count transistors (zeros) for each binary variable (inputs) */ 19 | for(var = 0; var < cube.num_binary_vars; var++) 20 | cost->in += cdata.var_zeros[var]; 21 | 22 | /* Count transistors for each mv variable based on sparse/dense */ 23 | for(var = cube.num_binary_vars; var < cube.num_vars - 1; var++) 24 | if (cube.sparse[var]) 25 | cost->mv += F->count * cube.part_size[var] - cdata.var_zeros[var]; 26 | else 27 | cost->mv += cdata.var_zeros[var]; 28 | 29 | /* Count the transistors (ones) for the output variable */ 30 | if (cube.num_binary_vars != cube.num_vars) { 31 | var = cube.num_vars - 1; 32 | cost->out = F->count * cube.part_size[var] - cdata.var_zeros[var]; 33 | } 34 | 35 | /* Count the number of nonprime cubes */ 36 | foreach_set(F, last, p) 37 | cost->primes += TESTP(p, PRIME) != 0; 38 | 39 | /* Count the total number of literals */ 40 | cost->total = cost->in + cost->out + cost->mv; 41 | } 42 | 43 | 44 | /* fmt_cost -- return a string which reports the "cost" of a cover */ 45 | char *fmt_cost(pcost cost) 46 | { 47 | static char s[200]; 48 | 49 | if (cube.num_binary_vars == cube.num_vars - 1) 50 | (void) sprintf(s, "c=%d(%d) in=%d out=%d tot=%d", 51 | cost->cubes, cost->cubes - cost->primes, cost->in, 52 | cost->out, cost->total); 53 | else 54 | (void) sprintf(s, "c=%d(%d) in=%d mv=%d out=%d", 55 | cost->cubes, cost->cubes - cost->primes, cost->in, 56 | cost->mv, cost->out); 57 | return s; 58 | } 59 | 60 | 61 | char *print_cost(pset_family F) 62 | { 63 | cost_t cost; 64 | cover_cost(F, &cost); 65 | return fmt_cost(&cost); 66 | } 67 | 68 | 69 | /* copy_cost -- copy a cost function from s to d */ 70 | void copy_cost(pcost s, pcost d) 71 | { 72 | d->cubes = s->cubes; 73 | d->in = s->in; 74 | d->out = s->out; 75 | d->mv = s->mv; 76 | d->total = s->total; 77 | d->primes = s->primes; 78 | } 79 | 80 | 81 | /* size_stamp -- print single line giving the size of a cover */ 82 | void size_stamp(pset_family T, char *name) 83 | { 84 | printf("# %s\tCost is %s\n", name, print_cost(T)); 85 | (void) fflush(stdout); 86 | } 87 | 88 | 89 | /* print_trace -- print a line reporting size and time after a function */ 90 | void print_trace(pset_family T, char *name, long int time) 91 | { 92 | printf("# %s\tTime was %s, cost is %s\n", 93 | name, print_time(time), print_cost(T)); 94 | (void) fflush(stdout); 95 | } 96 | 97 | 98 | /* totals -- add time spent in the function into the totals */ 99 | void totals(long int time, int i, pset_family T, pcost cost) 100 | { 101 | time = ptime() - time; 102 | total_time[i] += time; 103 | total_calls[i]++; 104 | cover_cost(T, cost); 105 | if (trace) { 106 | printf("# %s\tTime was %s, cost is %s\n", 107 | total_name[i], print_time(time), fmt_cost(cost)); 108 | (void) fflush(stdout); 109 | } 110 | } 111 | 112 | 113 | /* fatal -- report fatal error message and take a dive */ 114 | void fatal(char *s) 115 | { 116 | fprintf(stderr, "espresso: %s\n", s); 117 | exit(1); 118 | } 119 | -------------------------------------------------------------------------------- /examples/in7: -------------------------------------------------------------------------------- 1 | .i 26 2 | .o 10 3 | 0---1----0000--0--01--0-0- 0010000000 4 | ------------------1------1 0100000000 5 | 0-----1--0000--0--01--0-0- 0011000000 6 | 1--1-----------0--010-00-- 0000011000 7 | ---------0000-----01---1-- 0000000010 8 | 0----1---0000--0--01--0-0- 0010100000 9 | ------------------1-0----0 0000010100 10 | --------------------1--1-- 0000010010 11 | 0-1------------0--010-000- 0000011000 12 | -0-------1--------01---1-- 0000000010 13 | --1------0--------01---1-- 0000000010 14 | ------------------1----1-1 0100010010 15 | 0-1------------0--01--0-0- 0001100000 16 | -0-------1---------1-----1 0100000000 17 | --1------0---------1-----1 0100000000 18 | ---------0000------1-----1 0100000000 19 | -------------------1---1-- 0000010000 20 | 0------1-0000--0--01--0-0- 0011100000 21 | 0-0------001---1--01--0-0- 0001000000 22 | --------0---------0-----1- 0100000000 23 | --------0----------0-----1 0100000000 24 | ---0---------------0-----1 0100000000 25 | ---0-----------------0--10 0100000000 26 | ---0--------------00---1-- 0000010010 27 | 0-0------01----1--010-0-0- 0000011000 28 | 0-0------010---1--01--0-0- 0010100000 29 | 0-----------------00---1-- 0000010010 30 | --------0---------00---1-- 0000010010 31 | 0-----1--0000--0--010-000- 0000011000 32 | 0------1-0000--0--010-000- 0000011000 33 | 0---1----0000--0--010-000- 0000011000 34 | 0----1---0000--0--010-000- 0000011000 35 | -------------------1-0--1- 0100000000 36 | ------------------01----1- 0100000000 37 | 0-0------0--1--1--010-0-0- 0000011000 38 | 0-0------0001--1--01--0-0- 0011100000 39 | 01-------1-----1--010-0-0- 0000011000 40 | 01-------1-----1--01--0-0- 0001100000 41 | ------------------0---11-- 0000010010 42 | ---------------0--0----1-- 0000010010 43 | ------------------1------0 0011000000 44 | -----------------11------0 0011100000 45 | 0--------------------0--1- 0100000000 46 | --------0------------0--1- 0100000000 47 | 0------------------0-----1 0100000000 48 | 1------------------1-----1 0100000000 49 | ---------------0---------1 0100000000 50 | ----------------------1--1 0100000000 51 | 0-0------0-1---1--01--0-0- 0010000000 52 | 0-0------0-1---1--010-0-0- 0010011000 53 | ---0--------------0-----1- 0100000000 54 | 0-----------------0-----1- 0100000000 55 | 1-----------------01---1-- 0000010010 56 | ------------------01---11- 0100010010 57 | ------------------0---1--- 0100000000 58 | -0-------1---------1-0---- 0100000000 59 | ---------0000------1-0---- 0100000000 60 | 1--1-----------0--01--0--- 0001100000 61 | --1------0---------1-0---- 0100000000 62 | ---0---------------0-0---- 0100000000 63 | 0------------------0-0---- 0100000000 64 | 1--1----1------1--00--0--- 0001100000 65 | 1--1----1------1--000-0--- 0001111000 66 | ---------------0-----0---- 0100000000 67 | ------------------1--0---- 0100000000 68 | --------0----------0-0---- 0100000000 69 | 1------------------1-0---- 0100000000 70 | ---------------0--0------- 0100000000 71 | --1------0--------01------ 0100000000 72 | -0-------1--------01------ 0100000000 73 | 00-------1-----------0---- 0100000000 74 | ---------0000-----01------ 0100000000 75 | 0--------0000--------0---- 0100000000 76 | ---------00001------------ 1000000000 77 | 0-1------0-----------0---- 0100000000 78 | ---------0000-11---------- 1000000000 79 | ----------------1--------- 1000000000 80 | ---------0001------------- 0000000001 81 | --------0---------00------ 0100000000 82 | 0-----------------00------ 0100000000 83 | 1--0-----------------0---- 0100000000 84 | 1-------0------------0---- 0100000000 85 | ---0--------------00------ 0100000000 86 | 1-----------------01------ 0100000000 87 | -------------------------------------------------------------------------------- /examples/pope.rom: -------------------------------------------------------------------------------- 1 | .i 6 2 | .o 48 3 | 000000 111111011100111000001101111011010111010111000110 4 | 100000 111111011100111000001101111011010111010111000110 5 | 010000 110101010000011000001101111011000111010111000111 6 | 110000 101011001110010000001111111011010111000111000110 7 | 001000 101110010100010000001111101001010010000111000110 8 | 101000 110000010010010000000011111011010010000101000100 9 | 011000 101100001101010000000000111011010010100111111110 10 | 111000 111111011000101001101100111011010110110111000110 11 | 000100 101110001100101001001100111011010110110111000110 12 | 100100 111111011000011000001100111111010110110111000110 13 | 010100 111111011100010000001111110010011100110111000010 14 | 110100 101110010100010000001111111011011100110011000110 15 | 001100 101111010110010000001111111011010110000111000110 16 | 101100 101111010100011000001111111011010110000101000010 17 | 011100 101111010100011000001100111011010010100010111100 18 | 111100 101111001100011000001100111011010110110111000110 19 | 000010 101110010100111000001100111011010110110111000110 20 | 100010 101110010100011000000000111011010110110111000110 21 | 010010 111111011100011000000000111011001100110111000010 22 | 110010 111111011000011000001100111011011100110011000110 23 | 001010 110100001100010000001111111011010110000101000100 24 | 101010 110101001100010000001111111011010110000101011000 25 | 011010 110001010100010000001111111011010110000010011110 26 | 111010 111111011110010000001111111011010110000101000010 27 | 000110 101110010100111000001111111011010010000101000100 28 | 100110 111111011000001001110000111011010010001011000111 29 | 010110 101101001100101001001111111011010110000011011010 30 | 110110 110010010000011000001100111011010010001011000110 31 | 001110 110000001100010000000011111011010011001111000110 32 | 101110 111111011110110000001100111011010111010111000110 33 | 011110 111111011000011000001100111011010111010111000110 34 | 111110 110001001100010010001111111011010111010111000110 35 | 000001 111111011100111000001101111011010111010111000110 36 | 100001 110100010100111000001101111011010111010111000110 37 | 010001 010000010000011000000001111011000111010111000111 38 | 110001 011101010101010000000000111011010111000111000110 39 | 001001 101101010100011000000100101011010010000111000110 40 | 101001 011010001110110100001101111011010010000101000100 41 | 011001 111111011100111000001101111011010010100111111110 42 | 111001 111111011100111000001101111011010110110111000110 43 | 000101 111111011100111000001101111011010110110111000110 44 | 100101 111111011100111000001101111011010110110111000110 45 | 010101 010000010100111000001101110011011100110111000010 46 | 110101 110100010000011000001001111011011100110011000110 47 | 001101 101101001110110000001110111011010110000111000110 48 | 101101 111111011100111000001110111011010110000101000010 49 | 011101 111111011100111000001110111011010010100010111100 50 | 111101 111111011100111000001110111011010110110111000110 51 | 000011 111111011100111000001110111011010110110111000110 52 | 100011 110100010100111000001110111011010110110111000110 53 | 010011 010000010000011000000010111011001100110111000010 54 | 110011 110100010101010000001100111011011100110011000110 55 | 001011 010000010100011000001000111011010110000101000100 56 | 101011 111111011110110100001110111011010110000101011000 57 | 011011 110100001100111000001110111011010110000010011110 58 | 111011 111111011100111000001110111011010110000101000010 59 | 000111 111111011100111000001110111011010010000101000100 60 | 100111 111111011100111000001110111011010010001011000111 61 | 010111 101101010100111000001110111011010110000011011010 62 | 110111 011101110000011000000110111011010010001011000110 63 | 001111 111111011110110000001101111011010011001111000110 64 | 101111 010000001100111000001101111011010111010111000110 65 | 011111 111111011100111000001101111011010111010111000110 66 | 111111 111111011100111000001101111011010111010111000110 67 | -------------------------------------------------------------------------------- /examples/apla: -------------------------------------------------------------------------------- 1 | .i 10 2 | .o 12 3 | 0100000000 100000000000 4 | 0000100000 100000000000 5 | 0000010000 100000000000 6 | 1000000000 001000000000 7 | 0010000000 001000000000 8 | 0001000000 001000000000 9 | 0000001000 001000000000 10 | 1000000000 000000000010 11 | 0001000000 000000000010 12 | 0100000000 000000001001 13 | 0000100000 000000001001 14 | 0000010000 000000001001 15 | 0010000000 000000010010 16 | 0000001000 000000010010 17 | 0100000001 010000000000 18 | 0000100001 010000000000 19 | 0000010001 010000000000 20 | 1000000001 000100000000 21 | 0010000001 000100000000 22 | 0001000001 000100000000 23 | 0000001001 000100000000 24 | 1000000001 000000000010 25 | 0001000001 000000000010 26 | 0100000001 000000001001 27 | 0000100001 000000001001 28 | 0000010001 000000001001 29 | 0010000001 000000010010 30 | 0000001001 000000010010 31 | 0000100010 100000000000 32 | 0000010010 100000000000 33 | 0000001010 100000000000 34 | 1000000010 001000000000 35 | 0100000010 001000000000 36 | 0010000010 001000000000 37 | 0001000010 001000000000 38 | 0100000010 000000000100 39 | 0001000010 000000000100 40 | 1000000010 000000001010 41 | 0010000010 000000001010 42 | 0000100010 000000010001 43 | 0000010010 000000010001 44 | 0000001010 000000010001 45 | 0000100011 100000000000 46 | 0000010011 100000000000 47 | 0000001011 100000000000 48 | 1000000011 000100000000 49 | 0010000011 000100000000 50 | 0100000011 000010000000 51 | 0001000011 000010000000 52 | 0100000011 000000000100 53 | 0001000011 000000000100 54 | 1000000011 000000001010 55 | 0010000011 000000001010 56 | 0000100011 000000010101 57 | 0000010011 000000010101 58 | 0000001011 000000010101 59 | 0100000100 010000000000 60 | 0000100100 010000000000 61 | 1000000100 001000000000 62 | 0010000100 001000000000 63 | 0001000100 001000000000 64 | 0000010100 001000000000 65 | 0000001100 001000000000 66 | 0100000100 000000000101 67 | 0000100100 000000000101 68 | 1000000100 000000001000 69 | 0010000100 000000001000 70 | 0001000100 000000010100 71 | 0000010100 000000010100 72 | 0000001100 000000010100 73 | 0100000101 100000000000 74 | 0000100101 100000000000 75 | 1000000101 000010000000 76 | 0010000101 000010000000 77 | 0001000101 000010000000 78 | 0000010101 000010000000 79 | 0000001101 000010000000 80 | 1000000101 000000000010 81 | 0001000101 000000000010 82 | 0100000101 000000000101 83 | 0000100101 000000000101 84 | 0010000101 000000010010 85 | 0000001101 000000010010 86 | 0000010101 000000010100 87 | 0100000110 100000000000 88 | 0000100110 010000000000 89 | 0000010110 010000000000 90 | 0000001110 010000000000 91 | 1000000110 000010000000 92 | 0010000110 000010000000 93 | 0001000110 000010000000 94 | 0100000110 000000000001 95 | 1000000110 000000001010 96 | 0010000110 000000001010 97 | 0000100110 000000010001 98 | 0000010110 000000010001 99 | 0000001110 000000010001 100 | 0001000110 000000010100 101 | 0100000111 010000000000 102 | 0000100111 010000000000 103 | 0000010111 010000000000 104 | 0000001111 010000000000 105 | 1000000111 000001000000 106 | 0010000111 000001000000 107 | 0001000111 000000100000 108 | 0100000111 000000000001 109 | 1000000111 000000001000 110 | 0010000111 000000001000 111 | 0001000111 000000010000 112 | 0000100111 000000010101 113 | 0000010111 000000010101 114 | 0000001111 000000010101 115 | 11-------- 222222222222 116 | 1-1------- 222222222222 117 | 1--1------ 222222222222 118 | 1---1----- 222222222222 119 | 1----1---- 222222222222 120 | 1-----1--- 222222222222 121 | 0000000--- 222222222222 122 | -11------- 222222222222 123 | -1-1------ 222222222222 124 | -1--1----- 222222222222 125 | -1---1---- 222222222222 126 | -1----1--- 222222222222 127 | --11------ 222222222222 128 | --1-1----- 222222222222 129 | --1--1---- 222222222222 130 | --1---1--- 222222222222 131 | ---11----- 222222222222 132 | ---1-1---- 222222222222 133 | ---1--1--- 222222222222 134 | ----11---- 222222222222 135 | ----1-1--- 222222222222 136 | -----11--- 222222222222 137 | -------------------------------------------------------------------------------- /examples/m3: -------------------------------------------------------------------------------- 1 | .i 8 2 | .o 16 3 | 00000000 1110101111111111 4 | 00000001 1110101101101011 5 | 00000010 1110110001010110 6 | 00000011 1110110001001010 7 | 00000100 1110110001000001 8 | 00000101 1110110100111011 9 | 00000110 1110110100110110 10 | 00000111 1110111000110001 11 | 00001000 1110111000101110 12 | 00001001 1110111100101011 13 | 00001010 1110111100101000 14 | 00001011 1111000000100101 15 | 00001100 1111000000100011 16 | 00001101 1111000000100001 17 | 00001110 1111000100011111 18 | 00001111 1111000100011110 19 | 00010000 1111001000011000 20 | 00010001 1111001000011011 21 | 00010010 1111001000011001 22 | 00010011 1111001100011000 23 | 00010100 1111001100010111 24 | 00010101 1111001100010110 25 | 00010110 1111010000010101 26 | 00010111 1111010000010100 27 | 00011000 1111010000010011 28 | 00011001 1111010100010010 29 | 00011010 1111010100010001 30 | 00011011 1111010100010001 31 | 00011100 1111010100010000 32 | 00011101 1111011000001111 33 | 00011110 1111011000001111 34 | 00011111 1111011000001110 35 | 00100000 1111011100001110 36 | 00100001 1111011100001101 37 | 00100010 1111011100001101 38 | 00100011 1111011100001100 39 | 00100100 1111011100001100 40 | 00100101 1111100000001011 41 | 00100110 1111100000001011 42 | 00100111 1111100000001010 43 | 00101000 1111100000001010 44 | 00101001 1111100100001010 45 | 00101010 1111100100001001 46 | 00101011 1111100100001001 47 | 00101100 1111100100001001 48 | 00101101 1111101000001000 49 | 00101110 1111101000001000 50 | 00101111 1111101000001000 51 | 00110000 1111101000000111 52 | 00110001 1111101000000111 53 | 00110010 1111101000000111 54 | 00110011 1111101100000111 55 | 00110100 1111101100000110 56 | 00110101 1111101100000110 57 | 00110110 1111101100000110 58 | 00110111 1111101100000110 59 | 00111000 1111101100000110 60 | 00111001 1111101100000101 61 | 00111010 1111110000000101 62 | 00111011 1111110000000101 63 | 00111100 1111110000000101 64 | 00111101 1111110000000101 65 | 00111110 1111110000000100 66 | 00111111 1111110000000100 67 | 01000000 1111110000000100 68 | 01000001 1111110000000100 69 | 01000010 1111110100000100 70 | 01000011 1111110100000100 71 | 01000100 1111110100000100 72 | 01000101 1111110100000100 73 | 01000110 1111110100000011 74 | 01000111 1111110100000011 75 | 01001000 1111110100000011 76 | 01001001 1111110100000011 77 | 01001010 1111110100000011 78 | 01001011 1111110100000011 79 | 01001100 1111110100000011 80 | 01001101 1111111000000011 81 | 01001110 1111111000000011 82 | 01001111 1111111000000011 83 | 01010000 1111111000000010 84 | 01010001 1111111000000010 85 | 01010010 1111111000000010 86 | 01010011 1111111000000010 87 | 01010100 1111111000000010 88 | 01010101 1111111000000010 89 | 01010110 1111111000000010 90 | 01010111 1111111000000010 91 | 01011000 1111111000000010 92 | 01011001 1111111000000010 93 | 01011010 1111111000000010 94 | 01011011 1111111000000010 95 | 01011100 1111111000000010 96 | 01011101 1111111100000010 97 | 01011110 1111111100000010 98 | 01011111 1111111100000001 99 | 01100000 1111111100000001 100 | 01100001 1111111100000001 101 | 01100010 1111111100000001 102 | 01100011 1111111100000001 103 | 01100100 1111111100000001 104 | 01100101 1111111100000001 105 | 01100110 1111111100000001 106 | 01100111 1111111100000001 107 | 01101000 1111111100000001 108 | 01101001 1111111100000001 109 | 01101010 1111111100000001 110 | 01101011 1111111100000001 111 | 01101100 1111111100000001 112 | 01101101 1111111100000001 113 | 01101110 1111111100000001 114 | 01101111 1111111100000001 115 | 01110000 1111111100000001 116 | 01110001 1111111100000001 117 | 01110010 1111111100000001 118 | 01110011 1111111100000001 119 | 01110100 1111111100000001 120 | 01110101 1111111100000001 121 | 01110110 1111111100000001 122 | 01110111 1111111100000001 123 | 01111000 1111111100000001 124 | 01111001 1111111100000001 125 | 01111010 1111111100000001 126 | 01111011 1111111100000001 127 | 01111100 1111111100000001 128 | 01111101 1111111100000001 129 | 01111110 1111111100000001 130 | 01111111 1111111100000001 131 | -------------------------------------------------------------------------------- /espresso-src/sparse.c: -------------------------------------------------------------------------------- 1 | /* 2 | module: sparse.c 3 | 4 | make_sparse is a last-step cleanup to reduce the total number 5 | of literals in the cover. 6 | 7 | This is done by reducing the "sparse" variables (using a modified 8 | version of irredundant rather than reduce), followed by expanding 9 | the "dense" variables (using modified version of expand). 10 | */ 11 | 12 | #include "espresso.h" 13 | 14 | pcover make_sparse(pset_family F, pset_family D, pset_family R) 15 | { 16 | cost_t cost, best_cost; 17 | 18 | cover_cost(F, &best_cost); 19 | 20 | do { 21 | EXECUTE(F = mv_reduce(F, D), MV_REDUCE_TIME, F, cost); 22 | if (cost.total == best_cost.total) 23 | break; 24 | copy_cost(&cost, &best_cost); 25 | 26 | EXECUTE(F = expand(F, R, TRUE), RAISE_IN_TIME, F, cost); 27 | if (cost.total == best_cost.total) 28 | break; 29 | copy_cost(&cost, &best_cost); 30 | } while (force_irredundant); 31 | 32 | return F; 33 | } 34 | 35 | /* 36 | mv_reduce -- perform an "optimal" reduction of the variables which 37 | we desire to be sparse 38 | 39 | This could be done using "reduce" and then saving just the desired 40 | part of the reduction. Instead, this version uses IRRED to find 41 | which cubes of an output are redundant. Note that this gets around 42 | the cube-ordering problem. 43 | 44 | In normal use, it is expected that the cover is irredundant and 45 | hence no cubes will be reduced to the empty cube (however, this is 46 | checked for and such cubes will be deleted) 47 | */ 48 | 49 | pcover 50 | mv_reduce(pset_family F, pset_family D) 51 | { 52 | register int i, var; 53 | register pcube p, p1, last; 54 | int index; 55 | pcover F1, D1; 56 | pcube *F_cube_table; 57 | 58 | /* loop for each multiple-valued variable */ 59 | for(var = 0; var < cube.num_vars; var++) { 60 | 61 | if (cube.sparse[var]) { 62 | 63 | /* loop for each part of the variable */ 64 | for(i = cube.first_part[var]; i <= cube.last_part[var]; i++) { 65 | 66 | /* remember mapping of F1 cubes back to F cubes */ 67 | F_cube_table = ALLOC(pcube, F->count); 68 | 69 | /* 'cofactor' against part #i of variable #var */ 70 | F1 = new_cover(F->count); 71 | foreach_set(F, last, p) { 72 | if (is_in_set(p, i)) { 73 | F_cube_table[F1->count] = p; 74 | p1 = GETSET(F1, F1->count++); 75 | (void) set_diff(p1, p, cube.var_mask[var]); 76 | set_insert(p1, i); 77 | } 78 | } 79 | 80 | /* 'cofactor' against part #i of variable #var */ 81 | /* not really necessary -- just more efficient ? */ 82 | D1 = new_cover(D->count); 83 | foreach_set(D, last, p) { 84 | if (is_in_set(p, i)) { 85 | p1 = GETSET(D1, D1->count++); 86 | (void) set_diff(p1, p, cube.var_mask[var]); 87 | set_insert(p1, i); 88 | } 89 | } 90 | 91 | mark_irredundant(F1, D1); 92 | 93 | /* now remove part i from cubes which are redundant */ 94 | index = 0; 95 | foreach_set(F1, last, p1) { 96 | if (! TESTP(p1, ACTIVE)) { 97 | p = F_cube_table[index]; 98 | 99 | /* don't reduce a variable which is full 100 | * (unless it is the output variable) 101 | */ 102 | if (var == cube.num_vars-1 || 103 | ! setp_implies(cube.var_mask[var], p)) { 104 | set_remove(p, i); 105 | } 106 | RESET(p, PRIME); 107 | } 108 | index++; 109 | } 110 | 111 | free_cover(F1); 112 | free_cover(D1); 113 | FREE(F_cube_table); 114 | } 115 | } 116 | } 117 | 118 | /* Check if any cubes disappeared */ 119 | (void) sf_active(F); 120 | for(var = 0; var < cube.num_vars; var++) { 121 | if (cube.sparse[var]) { 122 | foreach_active_set(F, last, p) { 123 | if (setp_disjoint(p, cube.var_mask[var])) { 124 | RESET(p, ACTIVE); 125 | F->active_count--; 126 | } 127 | } 128 | } 129 | } 130 | 131 | if (F->count != F->active_count) { 132 | F = sf_inactive(F); 133 | } 134 | return F; 135 | } 136 | -------------------------------------------------------------------------------- /espresso-src/espresso.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Module: espresso.c 3 | * Purpose: The main espresso algorithm 4 | * 5 | * Returns a minimized version of the ON-set of a function 6 | * 7 | * The following global variables affect the operation of Espresso: 8 | * 9 | * MISCELLANEOUS: 10 | * trace 11 | * print trace information as the minimization progresses 12 | * 13 | * remove_essential 14 | * remove essential primes 15 | * 16 | * single_expand 17 | * if true, stop after first expand/irredundant 18 | * 19 | * LAST_GASP or SUPER_GASP strategy: 20 | * use_super_gasp 21 | * uses the super_gasp strategy rather than last_gasp 22 | * 23 | * SETUP strategy: 24 | * recompute_onset 25 | * recompute onset using the complement before starting 26 | * 27 | * unwrap_onset 28 | * unwrap the function output part before first expand 29 | * 30 | * MAKE_SPARSE strategy: 31 | * force_irredundant 32 | * iterates make_sparse to force a minimal solution (used 33 | * indirectly by make_sparse) 34 | * 35 | * skip_make_sparse 36 | * skip the make_sparse step (used by opo only) 37 | */ 38 | 39 | #include "espresso.h" 40 | 41 | pcover espresso(pset_family F, pset_family D1, pset_family R) 42 | { 43 | pcover E, D, Fsave; 44 | pset last, p; 45 | cost_t cost, best_cost; 46 | 47 | begin: 48 | Fsave = sf_save(F); /* save original function */ 49 | D = sf_save(D1); /* make a scratch copy of D */ 50 | 51 | /* Setup has always been a problem */ 52 | if (recompute_onset) { 53 | EXEC(E = simplify(cube1list(F)), "SIMPLIFY ", E); 54 | free_cover(F); 55 | F = E; 56 | } 57 | cover_cost(F, &cost); 58 | if (unwrap_onset && (cube.part_size[cube.num_vars - 1] > 1) 59 | && (cost.out != cost.cubes*cube.part_size[cube.num_vars-1]) 60 | && (cost.out < 5000)) 61 | EXEC(F = sf_contain(unravel(F, cube.num_vars - 1)), "SETUP ", F); 62 | 63 | /* Initial expand and irredundant */ 64 | foreach_set(F, last, p) { 65 | RESET(p, PRIME); 66 | } 67 | EXECUTE(F = expand(F, R, FALSE), EXPAND_TIME, F, cost); 68 | EXECUTE(F = irredundant(F, D), IRRED_TIME, F, cost); 69 | 70 | if (! single_expand) { 71 | if (remove_essential) { 72 | EXECUTE(E = essential(&F, &D), ESSEN_TIME, E, cost); 73 | } else { 74 | E = new_cover(0); 75 | } 76 | 77 | cover_cost(F, &cost); 78 | do { 79 | 80 | /* Repeat inner loop until solution becomes "stable" */ 81 | do { 82 | copy_cost(&cost, &best_cost); 83 | EXECUTE(F = reduce(F, D), REDUCE_TIME, F, cost); 84 | EXECUTE(F = expand(F, R, FALSE), EXPAND_TIME, F, cost); 85 | EXECUTE(F = irredundant(F, D), IRRED_TIME, F, cost); 86 | } while (cost.cubes < best_cost.cubes); 87 | 88 | /* Perturb solution to see if we can continue to iterate */ 89 | copy_cost(&cost, &best_cost); 90 | if (use_super_gasp) { 91 | F = super_gasp(F, D, R, &cost); 92 | if (cost.cubes >= best_cost.cubes) 93 | break; 94 | } else { 95 | F = last_gasp(F, D, R, &cost); 96 | } 97 | 98 | } while (cost.cubes < best_cost.cubes || 99 | (cost.cubes == best_cost.cubes && cost.total < best_cost.total)); 100 | 101 | /* Append the essential cubes to F */ 102 | F = sf_append(F, E); /* disposes of E */ 103 | if (trace) size_stamp(F, "ADJUST "); 104 | } 105 | 106 | /* Free the D which we used */ 107 | free_cover(D); 108 | 109 | /* Attempt to make the PLA matrix sparse */ 110 | if (! skip_make_sparse) { 111 | F = make_sparse(F, D1, R); 112 | } 113 | 114 | /* 115 | * Check to make sure function is actually smaller !! 116 | * This can only happen because of the initial unravel. If we fail, 117 | * then run the whole thing again without the unravel. 118 | */ 119 | if (Fsave->count < F->count) { 120 | free_cover(F); 121 | F = Fsave; 122 | unwrap_onset = FALSE; 123 | goto begin; 124 | } else { 125 | free_cover(Fsave); 126 | } 127 | 128 | return F; 129 | } 130 | -------------------------------------------------------------------------------- /examples/t3: -------------------------------------------------------------------------------- 1 | .i 12 2 | .o 8 3 | 0----------- 00000000 4 | 1----------- 00000000 5 | 00000------- 10000000 6 | 000010000000 01000000 7 | 000010000001 01000000 8 | 000010000010 10000000 9 | 000010000011 10000000 10 | 000010000100 00100000 11 | 000010000101 01000000 12 | 000010000110 00100000 13 | 000010000111 10000000 14 | 000010001000 01000000 15 | 000010001001 01000000 16 | 000010001010 10000000 17 | 000010001011 10000000 18 | 000010001100 00100000 19 | 000010001101 01000000 20 | 000010001110 00100000 21 | 000010001111 10000000 22 | 000010010000 01000000 23 | 000010010001 01000000 24 | 000010010010 10000000 25 | 000010010011 10000000 26 | 000010010100 00100000 27 | 000010010101 01000000 28 | 000010010110 00100000 29 | 000010010111 10000000 30 | 000010011000 01000000 31 | 000010011001 01000000 32 | 000010011010 10000000 33 | 000010011011 10000000 34 | 000010011100 00100000 35 | 000010011101 01000000 36 | 000010011110 00100000 37 | 000010011111 10000000 38 | 000010100000 00010000 39 | 000010100001 00010000 40 | 000010100010 00010000 41 | 000010100011 00010000 42 | 000010100100 00100000 43 | 000010100101 00100000 44 | 000010100110 00100000 45 | 000010100111 00100000 46 | 000010101000 00010000 47 | 000010101001 00010000 48 | 000010101010 00010000 49 | 000010101011 00010000 50 | 000010101100 00010000 51 | 000010101101 00010000 52 | 000010101110 00010000 53 | 000010101111 00010000 54 | 000010110000 01000000 55 | 000010110001 01000000 56 | 000010110010 10000000 57 | 000010110011 10000000 58 | 000010110100 00100000 59 | 000010110101 01000000 60 | 000010110110 00100000 61 | 000010110111 10000000 62 | 000010111000 00010000 63 | 000010111001 00010000 64 | 000010111010 00010000 65 | 000010111011 00010000 66 | 000010111100 00010000 67 | 000010111101 00010000 68 | 000010111110 00010000 69 | 000010111111 00010000 70 | 000011000000 00100000 71 | 000011000001 01000000 72 | 000011000010 00100000 73 | 000011000011 10000000 74 | 000011000100 00100000 75 | 000011000101 01000000 76 | 000011000110 00100000 77 | 000011000111 10000000 78 | 000011001000 00100000 79 | 000011001001 01000000 80 | 000011001010 00100000 81 | 000011001011 10000000 82 | 000011001100 00100000 83 | 000011001101 01000000 84 | 000011001110 00100000 85 | 000011001111 10000000 86 | 000011010000 00100000 87 | 000011010001 01000000 88 | 000011010010 00100000 89 | 000011010011 10000000 90 | 000011010100 00100000 91 | 000011010101 01000000 92 | 000011010110 00100000 93 | 000011010111 10000000 94 | 000011011000 00100000 95 | 000011011001 01000000 96 | 000011011010 00100000 97 | 000011011011 10000000 98 | 000011011100 00100000 99 | 000011011101 01000000 100 | 000011011110 00100000 101 | 000011011111 10000000 102 | 000011100000 00100000 103 | 000011100001 00100000 104 | 000011100010 00100000 105 | 000011100011 00100000 106 | 000011100100 00100000 107 | 000011100101 01000000 108 | 000011100110 00100000 109 | 000011100111 10000000 110 | 000011101000 00010000 111 | 000011101001 00010000 112 | 000011101010 00010000 113 | 000011101011 00010000 114 | 000011101100 00010000 115 | 000011101101 00010000 116 | 000011101110 00010000 117 | 000011101111 00010000 118 | 000011110000 00100000 119 | 000011110001 01000000 120 | 000011110010 00100000 121 | 000011110011 10000000 122 | 000011110100 00100000 123 | 000011110101 01000000 124 | 000011110110 00100000 125 | 000011110111 10000000 126 | 000011111000 00010000 127 | 000011111001 00010000 128 | 000011111010 00010000 129 | 000011111011 00010000 130 | 000011111100 00010000 131 | 000011111101 00010000 132 | 000011111110 00010000 133 | 000011111111 00010000 134 | 0001-------- 00001000 135 | 001--------- 00000100 136 | 01---------- 00000010 137 | 1-0-0--00--- 00010000 138 | 1-0-0--01--- 00001000 139 | 1-0-0--10--- 00000100 140 | 1-0-0--11--- 00000010 141 | 1-0-1--00--- 10000000 142 | 1-0-1--01--- 00000001 143 | 1-0-1--10--- 00100000 144 | 1-0-1--11--- 01000000 145 | 1-1-0--00--- 00010000 146 | 1-1-0--01--- 00001000 147 | 1-1-0--10--- 00010000 148 | 1-1-0--11--- 00001000 149 | 1-1-1--00--- 00000001 150 | 1-1-1--01--- 00000001 151 | 1-1-1--10--- 00000001 152 | 1-1-1--11--- 00000001 153 | 0----------- 00000000 154 | 1----------- 00000000 155 | -------------------------------------------------------------------------------- /examples/shift: -------------------------------------------------------------------------------- 1 | .i 19 2 | .o 16 3 | 0001--------------- 1000000000000000 4 | 0011--------------- 1100000000000000 5 | 0101--------------- 1110000000000000 6 | 0111--------------- 1111000000000000 7 | 1001--------------- 1111100000000000 8 | 1011--------------- 1111110000000000 9 | 1101--------------- 1111111000000000 10 | 1111--------------- 1111111100000000 11 | 000-1-------------- 0100000000000000 12 | 000--1------------- 0010000000000000 13 | 001-1-------------- 0010000000000000 14 | 000---1------------ 0001000000000000 15 | 001--1------------- 0001000000000000 16 | 010-1-------------- 0001000000000000 17 | 000----1----------- 0000100000000000 18 | 001---1------------ 0000100000000000 19 | 010--1------------- 0000100000000000 20 | 011-1-------------- 0000100000000000 21 | 000-----1---------- 0000010000000000 22 | 001----1----------- 0000010000000000 23 | 010---1------------ 0000010000000000 24 | 011--1------------- 0000010000000000 25 | 100-1-------------- 0000010000000000 26 | 000------1--------- 0000001000000000 27 | 001-----1---------- 0000001000000000 28 | 010----1----------- 0000001000000000 29 | 011---1------------ 0000001000000000 30 | 100--1------------- 0000001000000000 31 | 101-1-------------- 0000001000000000 32 | 000-------1-------- 0000000100000000 33 | 001------1--------- 0000000100000000 34 | 010-----1---------- 0000000100000000 35 | 011----1----------- 0000000100000000 36 | 100---1------------ 0000000100000000 37 | 101--1------------- 0000000100000000 38 | 110-1-------------- 0000000100000000 39 | 000--------1------- 0000000010000000 40 | 001-------1-------- 0000000010000000 41 | 010------1--------- 0000000010000000 42 | 011-----1---------- 0000000010000000 43 | 100----1----------- 0000000010000000 44 | 101---1------------ 0000000010000000 45 | 110--1------------- 0000000010000000 46 | 111-1-------------- 0000000010000000 47 | 000---------1------ 0000000001000000 48 | 001--------1------- 0000000001000000 49 | 010-------1-------- 0000000001000000 50 | 011------1--------- 0000000001000000 51 | 100-----1---------- 0000000001000000 52 | 101----1----------- 0000000001000000 53 | 110---1------------ 0000000001000000 54 | 111--1------------- 0000000001000000 55 | 000----------1----- 0000000000100000 56 | 001---------1------ 0000000000100000 57 | 010--------1------- 0000000000100000 58 | 011-------1-------- 0000000000100000 59 | 100------1--------- 0000000000100000 60 | 101-----1---------- 0000000000100000 61 | 110----1----------- 0000000000100000 62 | 111---1------------ 0000000000100000 63 | 000-----------1---- 0000000000010000 64 | 001----------1----- 0000000000010000 65 | 010---------1------ 0000000000010000 66 | 011--------1------- 0000000000010000 67 | 100-------1-------- 0000000000010000 68 | 101------1--------- 0000000000010000 69 | 110-----1---------- 0000000000010000 70 | 111----1----------- 0000000000010000 71 | 000------------1--- 0000000000001000 72 | 001-----------1---- 0000000000001000 73 | 010----------1----- 0000000000001000 74 | 011---------1------ 0000000000001000 75 | 100--------1------- 0000000000001000 76 | 101-------1-------- 0000000000001000 77 | 110------1--------- 0000000000001000 78 | 111-----1---------- 0000000000001000 79 | 000-------------1-- 0000000000000100 80 | 001------------1--- 0000000000000100 81 | 010-----------1---- 0000000000000100 82 | 011----------1----- 0000000000000100 83 | 100---------1------ 0000000000000100 84 | 101--------1------- 0000000000000100 85 | 110-------1-------- 0000000000000100 86 | 111------1--------- 0000000000000100 87 | 000--------------1- 0000000000000010 88 | 001-------------1-- 0000000000000010 89 | 010------------1--- 0000000000000010 90 | 011-----------1---- 0000000000000010 91 | 100----------1----- 0000000000000010 92 | 101---------1------ 0000000000000010 93 | 110--------1------- 0000000000000010 94 | 111-------1-------- 0000000000000010 95 | 000---------------1 0000000000000001 96 | 001--------------1- 0000000000000001 97 | 010-------------1-- 0000000000000001 98 | 011------------1--- 0000000000000001 99 | 100-----------1---- 0000000000000001 100 | 101----------1----- 0000000000000001 101 | 110---------1------ 0000000000000001 102 | 111--------1------- 0000000000000001 103 | -------------------------------------------------------------------------------- /hard_examples/shift: -------------------------------------------------------------------------------- 1 | .i 19 2 | .o 16 3 | 0001--------------- 1000000000000000 4 | 0011--------------- 1100000000000000 5 | 0101--------------- 1110000000000000 6 | 0111--------------- 1111000000000000 7 | 1001--------------- 1111100000000000 8 | 1011--------------- 1111110000000000 9 | 1101--------------- 1111111000000000 10 | 1111--------------- 1111111100000000 11 | 000-1-------------- 0100000000000000 12 | 000--1------------- 0010000000000000 13 | 001-1-------------- 0010000000000000 14 | 000---1------------ 0001000000000000 15 | 001--1------------- 0001000000000000 16 | 010-1-------------- 0001000000000000 17 | 000----1----------- 0000100000000000 18 | 001---1------------ 0000100000000000 19 | 010--1------------- 0000100000000000 20 | 011-1-------------- 0000100000000000 21 | 000-----1---------- 0000010000000000 22 | 001----1----------- 0000010000000000 23 | 010---1------------ 0000010000000000 24 | 011--1------------- 0000010000000000 25 | 100-1-------------- 0000010000000000 26 | 000------1--------- 0000001000000000 27 | 001-----1---------- 0000001000000000 28 | 010----1----------- 0000001000000000 29 | 011---1------------ 0000001000000000 30 | 100--1------------- 0000001000000000 31 | 101-1-------------- 0000001000000000 32 | 000-------1-------- 0000000100000000 33 | 001------1--------- 0000000100000000 34 | 010-----1---------- 0000000100000000 35 | 011----1----------- 0000000100000000 36 | 100---1------------ 0000000100000000 37 | 101--1------------- 0000000100000000 38 | 110-1-------------- 0000000100000000 39 | 000--------1------- 0000000010000000 40 | 001-------1-------- 0000000010000000 41 | 010------1--------- 0000000010000000 42 | 011-----1---------- 0000000010000000 43 | 100----1----------- 0000000010000000 44 | 101---1------------ 0000000010000000 45 | 110--1------------- 0000000010000000 46 | 111-1-------------- 0000000010000000 47 | 000---------1------ 0000000001000000 48 | 001--------1------- 0000000001000000 49 | 010-------1-------- 0000000001000000 50 | 011------1--------- 0000000001000000 51 | 100-----1---------- 0000000001000000 52 | 101----1----------- 0000000001000000 53 | 110---1------------ 0000000001000000 54 | 111--1------------- 0000000001000000 55 | 000----------1----- 0000000000100000 56 | 001---------1------ 0000000000100000 57 | 010--------1------- 0000000000100000 58 | 011-------1-------- 0000000000100000 59 | 100------1--------- 0000000000100000 60 | 101-----1---------- 0000000000100000 61 | 110----1----------- 0000000000100000 62 | 111---1------------ 0000000000100000 63 | 000-----------1---- 0000000000010000 64 | 001----------1----- 0000000000010000 65 | 010---------1------ 0000000000010000 66 | 011--------1------- 0000000000010000 67 | 100-------1-------- 0000000000010000 68 | 101------1--------- 0000000000010000 69 | 110-----1---------- 0000000000010000 70 | 111----1----------- 0000000000010000 71 | 000------------1--- 0000000000001000 72 | 001-----------1---- 0000000000001000 73 | 010----------1----- 0000000000001000 74 | 011---------1------ 0000000000001000 75 | 100--------1------- 0000000000001000 76 | 101-------1-------- 0000000000001000 77 | 110------1--------- 0000000000001000 78 | 111-----1---------- 0000000000001000 79 | 000-------------1-- 0000000000000100 80 | 001------------1--- 0000000000000100 81 | 010-----------1---- 0000000000000100 82 | 011----------1----- 0000000000000100 83 | 100---------1------ 0000000000000100 84 | 101--------1------- 0000000000000100 85 | 110-------1-------- 0000000000000100 86 | 111------1--------- 0000000000000100 87 | 000--------------1- 0000000000000010 88 | 001-------------1-- 0000000000000010 89 | 010------------1--- 0000000000000010 90 | 011-----------1---- 0000000000000010 91 | 100----------1----- 0000000000000010 92 | 101---------1------ 0000000000000010 93 | 110--------1------- 0000000000000010 94 | 111-------1-------- 0000000000000010 95 | 000---------------1 0000000000000001 96 | 001--------------1- 0000000000000001 97 | 010-------------1-- 0000000000000001 98 | 011------------1--- 0000000000000001 99 | 100-----------1---- 0000000000000001 100 | 101----------1----- 0000000000000001 101 | 110---------1------ 0000000000000001 102 | 111--------1------- 0000000000000001 103 | -------------------------------------------------------------------------------- /espresso-src/signature.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Module: signature.c 3 | * Purpose: The main signature algorithm 4 | * Routines; 5 | * pcover signature(): 6 | * Entry point for the signature cubes algorithm. 7 | * pcover generate_primes(): 8 | * Generates the set of primes corresponding to 9 | * the Essential Signature Cubes 10 | */ 11 | 12 | #include 13 | #include 14 | #include "espresso.h" 15 | #include "signature.h" 16 | 17 | static long start_time; /* yuk */ 18 | 19 | pcover 20 | signature(pset_family F1, pset_family D1, pset_family R1) 21 | { 22 | pcover ESC,ESSet,ESSENTIAL; 23 | pcover F,D,R; 24 | pcube last,p; 25 | 26 | /* make scratch copy */ 27 | F = sf_save(F1); 28 | D = sf_save(D1); 29 | R = sf_save(R1); 30 | 31 | /* unwrap offset */ 32 | R = unravel(R, cube.num_binary_vars); 33 | R = sf_contain(R); 34 | 35 | start_time = ptime(); 36 | 37 | /* Initial expand and irredundant */ 38 | foreach_set(F, last, p) { 39 | RESET(p, PRIME); 40 | } 41 | 42 | S_EXECUTE(F = expand(F, R, FALSE), ESSEN_TIME); 43 | S_EXECUTE(F = irredundant(F, D), ESSEN_TIME); 44 | S_EXECUTE(ESSENTIAL = essential(&F,&D), ESSEN_TIME); 45 | 46 | S_EXECUTE(ESC = find_canonical_cover(F,D,R), FCC_TIME); 47 | /************************************************** 48 | printf("ESCubes %d\n", ESC->count + ESSENTIAL->count); 49 | fflush(stdout); 50 | **************************************************/ 51 | 52 | S_EXECUTE(ESSet = generate_primes(ESC,R), PRIMES_TIME); 53 | /************************************************** 54 | printf("ESSet %d\n",ESSet->count + ESSENTIAL->count); 55 | fflush(stdout); 56 | **************************************************/ 57 | 58 | S_EXECUTE(F = signature_minimize_exact(ESC,ESSet), MINCOV_TIME); 59 | sf_append(F,ESSENTIAL); 60 | /************************************************** 61 | printf("Exact_Minimum %d\n",F->count); 62 | print_cover(F,"Exact Minimum"); 63 | **************************************************/ 64 | 65 | if (! skip_make_sparse && R != 0) { 66 | F = make_sparse(F, D1, R); 67 | } 68 | 69 | free_cover(D); 70 | free_cover(R); 71 | free_cover(ESC); 72 | free_cover(ESSet); 73 | return F; 74 | } 75 | 76 | 77 | pcover 78 | generate_primes(pset_family F, pset_family R) 79 | { 80 | pcube c,r,lastc,b,lastb; 81 | pcover BB,PRIMES; 82 | pcube odd,even,out_part_r; 83 | register int i; 84 | register int w, last; 85 | register unsigned int x; 86 | int count; 87 | 88 | out_part_r = new_cube(); 89 | odd = new_cube(); 90 | even = new_cube(); 91 | 92 | count = 0; 93 | PRIMES = new_cover(F->count); 94 | foreach_set(F,lastc,c){ 95 | BB = new_cover(R->count); 96 | BB->count = R->count; 97 | /* BB = get_blocking_matrix(R,c); */ 98 | foreachi_set(R,i,r){ 99 | b = GETSET(BB,i); 100 | if ((last = cube.inword) != -1) { 101 | /* Check the partial word of binary variables */ 102 | x = r[last] & c[last]; 103 | x = ~(x | x >> 1) & cube.inmask; 104 | b[last] = r[last] & (x | x << 1); 105 | /* Check the full words of binary variables */ 106 | for(w = 1; w < last; w++) { 107 | x = r[w] & c[w]; 108 | x = ~(x | x >> 1) & DISJOINT; 109 | b[w] = r[w] & (x | x << 1); 110 | } 111 | } 112 | PUTLOOP(b,LOOP(r)); 113 | INLINEset_and(b,b,cube.binary_mask); 114 | INLINEset_and(out_part_r,cube.mv_mask,r); 115 | if(!setp_implies(out_part_r,c)){ 116 | INLINEset_or(b,b,out_part_r); 117 | } 118 | } 119 | BB = unate_compl(BB); 120 | if(BB != NULL){ 121 | foreach_set(BB,lastb,b){ 122 | set_not(b); 123 | } 124 | sf_append(PRIMES,BB); 125 | } 126 | count++; 127 | if(count % 100 == 0){ 128 | PRIMES = sf_contain(PRIMES); 129 | } 130 | } 131 | PRIMES = sf_contain(PRIMES); 132 | free_cube(out_part_r); 133 | free_cube(odd); 134 | free_cube(even); 135 | return PRIMES; 136 | } 137 | 138 | void 139 | cleanup(void) 140 | { 141 | s_runtime(ptime() - start_time); 142 | printf("CPU Limit Exceeded\n"); 143 | exit(1); 144 | } 145 | -------------------------------------------------------------------------------- /examples/mp2d: -------------------------------------------------------------------------------- 1 | .i 14 2 | .o 14 3 | 0------------- 10000000000000 4 | 11------------ 10000000000000 5 | 100----------- 10000000000000 6 | 1011---------- 11111100010000 7 | 10100--------- 10000000000000 8 | 101010-------- 10000000000000 9 | 1010111------- 10000000000000 10 | 10101100------ 10000000000000 11 | 101011011----- 10000000000000 12 | 1010110101---- 10000000000000 13 | 10101101001--- 10000000000000 14 | 0-----1------- 01110100000000 15 | 0-----00------ 01110100000000 16 | 0-----011----- 01110000000000 17 | 0-----0101---- 01000000000000 18 | 0-----01000--- 01000000000000 19 | 111---1------- 01110100000000 20 | 111---00------ 01110100000000 21 | 111---011----- 01110000000000 22 | 111---0101---- 01000000000000 23 | 111---01000--- 01000000000000 24 | 1101--1------- 01110100000000 25 | 1101--00------ 01110100000000 26 | 1101--011----- 01110000000000 27 | 1101--0101---- 01000000000000 28 | 1101--01000--- 01000000000000 29 | 11001--------- 01110100111000 30 | 11000-1------- 01110100000000 31 | 11000-00------ 01110100000000 32 | 11000-011----- 01110000000000 33 | 11000-0101---- 01000000000000 34 | 11000-01000--- 01000000000000 35 | 1010--1------- 01110100000000 36 | 1010--00------ 01110100000000 37 | 1010--011----- 01110000000000 38 | 1010--0101---- 01000000000000 39 | 1010--01000--- 01000000000000 40 | 1001--1------- 01110100000000 41 | 1001--00------ 01110100000000 42 | 1001--011----- 01110000000000 43 | 1001--0101---- 01000000000000 44 | 1001--01000--- 01000000000000 45 | 10000--------- 01110101010000 46 | 10001-1------- 01110100000000 47 | 10001-00------ 01110100000000 48 | 10001-011----- 01110000000000 49 | 10001-0101---- 01000000000000 50 | 10001-01000--- 01000000000000 51 | 0-----0100---- 00110000000000 52 | 0-----01011--- 00100000000000 53 | 111---0100---- 00110000000000 54 | 111---01011--- 00100000000000 55 | 1101--0100---- 00110000000000 56 | 1101--01011--- 00100000000000 57 | 11000-0100---- 00110000000000 58 | 11000-01011--- 00100000000000 59 | 1010--0100---- 00110000000000 60 | 1010--01011--- 00100000000000 61 | 1001--0100---- 00110000000000 62 | 1001--01011--- 00100000000000 63 | 10001-0100---- 00110000000000 64 | 10001-01011--- 00100000000000 65 | 0--1---------- 00100000000000 66 | 0--0-0-------- 00100000000000 67 | 11-1---------- 00100000000000 68 | 11-0-0-------- 00100000000000 69 | 1001---------- 00100000000000 70 | 1000-0-------- 00100000000000 71 | 10101--------- 00100000000000 72 | 101000-------- 00100000000000 73 | 0-----01010--- 00010000000000 74 | 111---01010--- 00010000000000 75 | 1101--01010--- 00010000000000 76 | 11000-01010--- 00010000000000 77 | 1010--01010--- 00010000000000 78 | 1001--01010--- 00010000000000 79 | 10001-01010--- 00010000000000 80 | 11001---100--- 00001000000000 81 | 1011----100--- 00001000000000 82 | 10000---100--- 00001000000000 83 | ------1-100--- 00001000000000 84 | ------00100--- 00001000000000 85 | 0-----010----- 00000100000000 86 | 0-----0111---- 00000100000000 87 | 0-----01100--- 00000100000000 88 | 111---010----- 00000100000000 89 | 111---0111---- 00000100000000 90 | 111---01100--- 00000100000000 91 | 1101--010----- 00000100000000 92 | 1101--0111---- 00000100000000 93 | 1101--01100--- 00000100000000 94 | 11000-010----- 00000100000000 95 | 11000-0111---- 00000100000000 96 | 11000-01100--- 00000100000000 97 | 1010--010----- 00000100000000 98 | 1010--0111---- 00000100000000 99 | 1010--01100--- 00000100000000 100 | 1001--010----- 00000100000000 101 | 1001--0111---- 00000100000000 102 | 1001--01100--- 00000100000000 103 | 10001-010----- 00000100000000 104 | 10001-0111---- 00000100000000 105 | 10001-01100--- 00000100000000 106 | 11001-01------ 00000010000000 107 | 1011--01------ 00000010000000 108 | 10000-01------ 00000010000000 109 | 11001-11111--- 00000010000000 110 | 1011--11111--- 00000010000000 111 | 10000-11111--- 00000010000000 112 | ------0------- 00000000010000 113 | ------10------ 00000000010000 114 | ------110----- 00000000010000 115 | ------1110---- 00000000010000 116 | ------11110--- 00000000010000 117 | 00001--------- 00000000001000 118 | 00110--------- 00000000001000 119 | 00101--------- 00000000001000 120 | ------11111010 00000000000110 121 | 1------------- 00000000000001 122 | 00------------ 00000000000001 123 | 010----------- 00000000000001 124 | 0110---------- 00000000000001 125 | 01111--------- 00000000000001 126 | -------------------------------------------------------------------------------- /examples/b2: -------------------------------------------------------------------------------- 1 | .i 16 2 | .o 17 3 | ----00----00-00- 11101111111111111 4 | 0----1----1100-0 11111010000010011 5 | 01--110-11011110 10110001101000110 6 | 01--010-1-011110 01111001000110101 7 | -----111--1100-0 11111010000010011 8 | ----------101110 11101111111111111 9 | 0---11-01-010000 10010001101010110 10 | 01--110-10011110 10110001101001000 11 | ----11111-010000 10011001101010110 12 | 10--------1010-1 11011111111111111 13 | 0---110---010000 10010001101010110 14 | 0-----010-110000 11111010000010011 15 | ----1-----000110 11111001101101001 16 | --------1-100110 11111010100100101 17 | ----1-----001000 11111010000010001 18 | 1---------101000 11111010101101001 19 | ----000011011000 01111001000011101 20 | ----100011011000 11111001110001101 21 | 0---100100111000 11111001101000100 22 | ----1-----000100 11111001101101100 23 | ----1-----001010 11111010010001110 24 | 0---010---010011 01111001000011101 25 | -----0----011100 11111001100110001 26 | 00--0-----000010 11111001001111000 27 | ----1-----0000-- 01111001001000010 28 | ----100001010111 11001001101010110 29 | 01--110-1-0100-0 10110001101010110 30 | ----1-----000111 11111010001010111 31 | 0---11-01-010011 10000001101010110 32 | ----1-----001011 11111010010000101 33 | 0---110---010011 10000001101010110 34 | 0---------101001 11111010000010001 35 | -----0----011101 11111001100101110 36 | 0---010---010000 01111001000011101 37 | ----0--10-101101 11111001001000010 38 | ----1-----101101 11111001001000110 39 | 0---00010-11100- 01111001000011101 40 | ----11111-010011 10001001101010110 41 | ----0-0001101101 11111001000110101 42 | ----0--111101101 11111001000100010 43 | ----0-----000--0 11101111111111111 44 | ----0-----0010-- 11101111111111111 45 | ----000001-10111 01111001000011101 46 | ----0--110101101 11111001000111100 47 | ----100010010101 11111001101010101 48 | ----100001110111 11001001110100001 49 | 00--1110-0011001 10100001100010100 50 | ----000010010101 01111001000011101 51 | ----------101111 01111111111111111 52 | ----1-----000101 11111001101110101 53 | 0---000-0111100- 01111001000011111 54 | 0---10000111100- 11001001110100101 55 | 00--1110-1011001 11100001100010010 56 | 0---100100111001 11111001101000001 57 | -------10110011- 11111010100100101 58 | ----1-0---001001 11111010010011110 59 | 0---10010111100- 11111001100111110 60 | --------0-010010 01111001000110101 61 | ----------10-100 11110111111111111 62 | 0---011---011001 01111001000011101 63 | ----0001-1100000 01111001000011001 64 | ----00011-100000 01111001000011001 65 | -----1111-11000- 11111010000010011 66 | 0----1--1-11000- 11111010000010011 67 | 0---0111--01-001 01111001000011101 68 | 01--011---01-001 01111001000011101 69 | ----100111100000 11111001010110100 70 | 0---10011110000- 11111001010110100 71 | ----100110100000 11111001010110011 72 | 0---10011010000- 11111001010110011 73 | 0---0001-110000- 01111001000011001 74 | 0---00011-10000- 01111001000011001 75 | 0---10010110000- 11111001100111110 76 | ----100101100000 11111001100111110 77 | 0-----001-1100-0 11111010000010011 78 | 0-----00-11100-0 11111010000010011 79 | ----------101100 10010111111111111 80 | ----------10010- 11011111111111111 81 | ----0-----010010 01111001000110101 82 | ------1---010010 01111001000110101 83 | -0--------010010 01111001000110101 84 | -----0----010010 01111001000110101 85 | 0---01--1-010011 01111001000011101 86 | ----01111-010011 01111001000011101 87 | 0---------10001- 11111001001100111 88 | 0---------100011 11111001001100010 89 | 10--------00001- 01111001001000010 90 | -0--------000011 01111001001000010 91 | ----------10101- 10110111111111111 92 | ----------101011 10000111111111111 93 | ----0--010101101 11111001000110111 94 | ----00-010101101 11111001000110110 95 | 0---1111-101-001 11111001101000110 96 | 01--111--101-001 11111001101000110 97 | 0---1111-001-001 10111001101001000 98 | 01--111--001-001 10111001101001000 99 | 0-0-1111-001110- 10111001101001000 100 | 010-111--001110- 10111001101001000 101 | 0-0-1111-101110- 11111001101000110 102 | 010-111--101110- 11111001101000110 103 | 0-0-0111--01110- 01111001000011101 104 | 010-011---01110- 01111001000011101 105 | -0----1---001001 01111001000110101 106 | ----1-1---001001 01111001000110101 107 | 0----10-1-1100-- 11111010000010011 108 | 0----10---11000- 11111010000010011 109 | 0---01--1-010000 01111001000011101 110 | ----01111-010000 01111001000011101 111 | -----1----000-01 01111001001000010 112 | -----1----0001-1 01111001001000010 113 | -------------------------------------------------------------------------------- /examples/vg2: -------------------------------------------------------------------------------- 1 | .i 25 2 | .o 8 3 | 1-11--------------------- 10000000 4 | -111--------------------- 10000000 5 | 00-----1----------------- 10000000 6 | --0-001------------------ 10000000 7 | 110----1----------------- 10000000 8 | 1-1-----1---------------- 01000000 9 | -11-----1---------------- 01000000 10 | 00--------1-------------- 01000000 11 | --0-00---1--------------- 01000000 12 | 110-------1-------------- 01000000 13 | 1-1-----1--00--00000----- 00100000 14 | -11-----1--00--00000----- 00100000 15 | 00--------100--00000----- 00100000 16 | 1-11-------11--11111----- 00100000 17 | -111-------11--11111----- 00100000 18 | 00-----1---11--11111----- 00100000 19 | --0-00---1-00--00000----- 00100000 20 | 110-------100--00000----- 00100000 21 | --0-001----11--11111----- 00100000 22 | 110----1---11--11111----- 00100000 23 | 1-1-----1--00000000000000 00010000 24 | -11-----1--00000000000000 00010000 25 | 00--------100000000000000 00010000 26 | 1-11-------11111111111111 00010000 27 | -111-------11111111111111 00010000 28 | 00-----1---11111111111111 00010000 29 | --0-00---1-00000000000000 00010000 30 | 110-------100000000000000 00010000 31 | --0-001----11111111111111 00010000 32 | 110----1---11111111111111 00010000 33 | 1-1-----1---1------------ 00001000 34 | -11-----1---1------------ 00001000 35 | 00--------1-1------------ 00001000 36 | 1-11--------0------------ 00001000 37 | -111--------0------------ 00001000 38 | 00-----1----0------------ 00001000 39 | --0-00---1--1------------ 00001000 40 | 110-------1-1------------ 00001000 41 | 1-1-----1--0-------1----- 00001000 42 | -11-----1--0-------1----- 00001000 43 | 00--------10-------1----- 00001000 44 | --0-001-----0------------ 00001000 45 | 110----1----0------------ 00001000 46 | 1-11-------1-------0----- 00001000 47 | -111-------1-------0----- 00001000 48 | 00-----1---1-------0----- 00001000 49 | --0-00---1-0-------1----- 00001000 50 | 110-------10-------1----- 00001000 51 | 1-1-----1--0-----10------ 00001000 52 | -11-----1--0-----10------ 00001000 53 | 00--------10-----10------ 00001000 54 | --0-001----1-------0----- 00001000 55 | 110----1---1-------0----- 00001000 56 | 1-11-------1-----01------ 00001000 57 | -111-------1-----01------ 00001000 58 | 00-----1---1-----01------ 00001000 59 | --0-00---1-0-----10------ 00001000 60 | 110-------10-----10------ 00001000 61 | --0-001----1-----01------ 00001000 62 | 110----1---1-----01------ 00001000 63 | 1-1-----1------1--------- 00000100 64 | -11-----1------1--------- 00000100 65 | 00--------1----1--------- 00000100 66 | 1-11-----------0--------- 00000100 67 | -111-----------0--------- 00000100 68 | 00-----1-------0--------- 00000100 69 | --0-00---1-----1--------- 00000100 70 | 110-------1----1--------- 00000100 71 | 1-1-----1-----0---------1 00000100 72 | -11-----1-----0---------1 00000100 73 | 00--------1---0---------1 00000100 74 | --0-001--------0--------- 00000100 75 | 110----1-------0--------- 00000100 76 | 1-11----------1---------0 00000100 77 | -111----------1---------0 00000100 78 | 00-----1------1---------0 00000100 79 | --0-00---1----0---------1 00000100 80 | 110-------1---0---------1 00000100 81 | 1-1-----1----00--------1- 00000100 82 | -11-----1----00--------1- 00000100 83 | 00--------1--00--------1- 00000100 84 | --0-001-------1---------0 00000100 85 | 110----1------1---------0 00000100 86 | 1-11---------11--------0- 00000100 87 | -111---------11--------0- 00000100 88 | 00-----1-----11--------0- 00000100 89 | --0-00---1---00--------1- 00000100 90 | 110-------1--00--------1- 00000100 91 | 1-1-----1----00------10-- 00000100 92 | -11-----1----00------10-- 00000100 93 | 00--------1--00------10-- 00000100 94 | --0-001------11--------0- 00000100 95 | 110----1-----11--------0- 00000100 96 | 1-11---------11------01-- 00000100 97 | -111---------11------01-- 00000100 98 | 00-----1-----11------01-- 00000100 99 | --0-00---1---00------10-- 00000100 100 | 110-------1--00------10-- 00000100 101 | --0-001------11------01-- 00000100 102 | 110----1-----11------01-- 00000100 103 | 1-11-------11---1111----- 00000010 104 | -111-------11---1111----- 00000010 105 | 00-----1---11---1111----- 00000010 106 | --0-001----11---1111----- 00000010 107 | 110----1---11---1111----- 00000010 108 | 1-1-----1--00---0000----- 00000001 109 | -11-----1--00---0000----- 00000001 110 | 00--------100---0000----- 00000001 111 | --0-00---1-00---0000----- 00000001 112 | 110-------100---0000----- 00000001 113 | -------------------------------------------------------------------------------- /examples/vtx1: -------------------------------------------------------------------------------- 1 | .i 27 2 | .o 6 3 | -1--0-11-------1----------- 100000 4 | -101--11-------1----------- 100000 5 | -1--0-1-1------1----------- 100000 6 | -101--1-1------1----------- 100000 7 | -0--1-11----1-------------- 100000 8 | -010--11----1-------------- 100000 9 | -0--1-1-1---1-------------- 100000 10 | -010--1-1---1-------------- 100000 11 | 1-----11----1-------------- 100000 12 | 0-----11-------1----------- 100000 13 | 1-----1-1---1-------------- 100000 14 | 0-----1-1------1----------- 100000 15 | -1--0-011----1------------- 100000 16 | -101--011----1------------- 100000 17 | -1--0-0---00--1------------ 100000 18 | -101--0---00--1------------ 100000 19 | -0--11011------------------ 100000 20 | -010-1011------------------ 100000 21 | -0--1-0--100--------------- 100000 22 | -010--0--100--------------- 100000 23 | 1----1011------------------ 100000 24 | 0-----011----1------------- 100000 25 | 1-----0--100--------------- 100000 26 | 0-----0---00--1------------ 100000 27 | -1--0--00----1------------- 100000 28 | -101---00----1------------- 100000 29 | -0--11-00------------------ 100000 30 | -010-1-00------------------ 100000 31 | 1----1-00------------------ 100000 32 | 0------00----1------------- 100000 33 | ------11-------1-01-------- 010000 34 | ------11-------1--101------ 010000 35 | ------11-------1--1-101---- 010000 36 | ------1-1------1-01-------- 010000 37 | ------1-1------1--101------ 010000 38 | ------1-1------1--1-101---- 010000 39 | ------11----1----10-------- 010000 40 | ------11----1-----010------ 010000 41 | ------11----1-----0-010---- 010000 42 | ------1-1---1----10-------- 010000 43 | ------1-1---1-----010------ 010000 44 | ------1-1---1-----0-010---- 010000 45 | ------11----1---1---------- 010000 46 | ------11-------10---------- 010000 47 | ------1-1---1---1---------- 010000 48 | ------1-1------10---------- 010000 49 | ------011----1---01-------- 010000 50 | ------011----1----101------ 010000 51 | ------011----1----1-101---- 010000 52 | ------0---00--1--01-------- 010000 53 | ------0---00--1---101------ 010000 54 | ------0---00--1---1-101---- 010000 55 | -----1011--------10-------- 010000 56 | -----1011---------010------ 010000 57 | -----1011---------0-010---- 010000 58 | ------0--100-----10-------- 010000 59 | ------0--100------010------ 010000 60 | ------0--100------0-010---- 010000 61 | -----1011-------1---------- 010000 62 | ------011----1--0---------- 010000 63 | ------0--100----1---------- 010000 64 | ------0---00--1-0---------- 010000 65 | -------00----1---01-------- 010000 66 | -------00----1----101------ 010000 67 | -------00----1----1-101---- 010000 68 | -----1-00--------10-------- 010000 69 | -----1-00---------010------ 010000 70 | -----1-00---------0-010---- 010000 71 | -----1-00-------1---------- 010000 72 | -------00----1--0---------- 010000 73 | 11111-11-------11------1--- 001000 74 | 11111-1-1------11------1--- 001000 75 | 11111-011----1--1------1--- 001000 76 | 11111-0---00--1-1------1--- 001000 77 | 11111--00----1--1------1--- 001000 78 | 00000-11----1---0------0--- 001000 79 | 00000-1-1---1---0------0--- 001000 80 | 000001011-------0------0--- 001000 81 | 00000-0--100----0------0--- 001000 82 | 000001-00-------0------0--- 001000 83 | 11111-11-------1-------1--- 000100 84 | 11111-1-1------1-------1--- 000100 85 | 11111-011----1---------1--- 000100 86 | 11111-0---00--1--------1--- 000100 87 | 11111--00----1---------1--- 000100 88 | 00000-11----1----------0--- 000010 89 | 00000-1-1---1----------0--- 000010 90 | 000001011--------------0--- 000010 91 | 00000-0--100-----------0--- 000010 92 | 000001-00--------------0--- 000010 93 | 11111-11-------1111111110-1 000001 94 | 11111-11-------111111111-01 000001 95 | 11111-1-1------1111111110-1 000001 96 | 11111-1-1------111111111-01 000001 97 | 11111-011----1--111111110-1 000001 98 | 11111-011----1--11111111-01 000001 99 | 11111-0---00--1-111111110-1 000001 100 | 11111-0---00--1-11111111-01 000001 101 | 11111--00----1--111111110-1 000001 102 | 11111--00----1--11111111-01 000001 103 | 00000-11----1---000000000-0 000001 104 | 00000-11----1---00000000-00 000001 105 | 00000-1-1---1---000000000-0 000001 106 | 00000-1-1---1---00000000-00 000001 107 | 000001011-------000000000-0 000001 108 | 000001011-------00000000-00 000001 109 | 00000-0--100----000000000-0 000001 110 | 00000-0--100----00000000-00 000001 111 | 000001-00-------000000000-0 000001 112 | 000001-00-------00000000-00 000001 113 | -------------------------------------------------------------------------------- /tlex/vg2.pla: -------------------------------------------------------------------------------- 1 | 2 | .i 25 3 | .o 8 4 | .p 110 5 | -----1------------1-----1 ~~~~~~~1 6 | --0-------0----------1--0 ~~~~~~~1 7 | -----1-------1-1--------0 ~~~~~~~1 8 | -------------1----1-----1 ~~~~~~~1 9 | -----0-------0-1--------- ~~~~~~~1 10 | -------1-----1----------1 ~~~~~1~~ 11 | 1-0-------0-------------0 ~~~~~1~~ 12 | -----1-1----------------1 ~~~~~1~~ 13 | -----1-------1-----1----0 ~~~~~1~~ 14 | -----0-------0-----1----- ~~~~~1~~ 15 | -1-1--1-1--1-11---1-1---1 ~~~1~~~~ 16 | 1000--0-0-00--0-----0---0 ~~~1~~~~ 17 | -0-0-10-0--0-10----10---0 ~~~1~~~~ 18 | -0-0-1010--0--0-----0---1 ~~~1~~~~ 19 | -101--1-1-01--1-----11--0 ~~~1~~~~ 20 | -1-1-11-1--1--1---1-1---1 ~~~1~~~~ 21 | -1-1-11-1--1-111----1---0 ~~~1~~~~ 22 | -0-0--010--0-10-----0---1 ~~~1~~~~ 23 | -0-0-00-0--0-00----10---- ~~~1~~~~ 24 | -1-1-01-1--1-011----1---- ~~~1~~~~ 25 | -1-11-1-11-1111-111-1-111 ~1~~~~~~ 26 | 10000-0-00000-0-00--0-000 ~1~~~~~~ 27 | -0-0010100-00-0-00--0-001 ~1~~~~~~ 28 | -0-0010-00-0010-00-10-000 ~1~~~~~~ 29 | -1011-1-11011-1-11--11110 ~1~~~~~~ 30 | -1-1111-11-11-1-111-1-111 ~1~~~~~~ 31 | -1-1111-11-1111111--1-110 ~1~~~~~~ 32 | -0-00-0100-0010-00--0-001 ~1~~~~~~ 33 | -0-0000-00-0000-00-10-00- ~1~~~~~~ 34 | -1-1101-11-1101111--1-11- ~1~~~~~~ 35 | ---1---1-----1----------1 ~~~~~~1~ 36 | --0-------01--1-----01--0 ~~~~~~1~ 37 | 1-0-------00--0-----1---0 ~~~~~~1~ 38 | -----1-----1--1---1-0---1 ~~~~~~1~ 39 | -----1-----1-111----0---0 ~~~~~~1~ 40 | -----1-----0-10----11---0 ~~~~~~1~ 41 | -----0-----1-011----0---- ~~~~~~1~ 42 | -----0-----0-00----11---- ~~~~~~1~ 43 | -------1---0-10-----1---1 ~~~~~~1~ 44 | -----------1-11---1-0---1 ~~~~~~1~ 45 | -----1-1---0--0-----1---1 ~~~~~~1~ 46 | -----10----1------1-----1 ~~~~~~1~ 47 | 1-0---1---00------------0 ~~~~~~1~ 48 | -----10----1-1-1--------0 ~~~~~~1~ 49 | --0---0---01---------1--0 ~~~~~~1~ 50 | -----11----0-1-----1----0 ~~~~~~1~ 51 | -----01----0-0-----1----- ~~~~~~1~ 52 | ------11---0-1----------1 ~~~~~~1~ 53 | ------0----1-1----1-----1 ~~~~~~1~ 54 | -----00----1-0-1--------- ~~~~~~1~ 55 | -----111---0------------1 ~~~~~~1~ 56 | ---0-1-------1-1--------0 ~~~~~~1~ 57 | ---1-1-------1-----1----0 ~~~~~~1~ 58 | ---0-1------------1-----1 ~~~~~~1~ 59 | 1-01------0-------------0 ~~~~~~1~ 60 | ---1-1-1----------------1 ~~~~~~1~ 61 | --00------0----------1--0 ~~~~~~1~ 62 | ---0-0-------0-1--------- ~~~~~~1~ 63 | ---0---------1----1-----1 ~~~~~~1~ 64 | ---1-0-------0-----1----- ~~~~~~1~ 65 | -------11----1----------1 ~~~~1~~~ 66 | 1-0-1-----0-----0-----000 ~~~~1~~~ 67 | --0-0-----0-----1----1110 ~~~~1~~~ 68 | ----01-------1-11-----110 ~~~~1~~~ 69 | ----11-1--------0-----001 ~~~~1~~~ 70 | ----11-------1--0--1--000 ~~~~1~~~ 71 | ----01----------1-1---111 ~~~~1~~~ 72 | ----1--1-----1--0-----001 ~~~~1~~~ 73 | ----10-------0--0--1--00- ~~~~1~~~ 74 | ----00-------0-11-----11- ~~~~1~~~ 75 | ----0--------1--1-1---111 ~~~~1~~~ 76 | 1-0-------0-----01----0-0 ~~~~1~~~ 77 | -----1-------1-110----1-0 ~~~~1~~~ 78 | --0-------0-----10---11-0 ~~~~1~~~ 79 | -----1----------101---1-1 ~~~~1~~~ 80 | -----1-------1--01-1--0-0 ~~~~1~~~ 81 | -----1-1--------01----0-1 ~~~~1~~~ 82 | -------1-----1--01----0-1 ~~~~1~~~ 83 | -----0-------0-110----1-- ~~~~1~~~ 84 | -------------1--101---1-1 ~~~~1~~~ 85 | -----0-------0--01-1--0-- ~~~~1~~~ 86 | 1-0------10-----0-------0 ~~~~1~~~ 87 | --0------00-----1----1--0 ~~~~1~~~ 88 | -----1---1---1--0--1----0 ~~~~1~~~ 89 | -----1---0---1-11-------0 ~~~~1~~~ 90 | -----1-1-1------0-------1 ~~~~1~~~ 91 | -----1---0------1-1-----1 ~~~~1~~~ 92 | -----0---0---0-11-------- ~~~~1~~~ 93 | -----0---1---0--0--1----- ~~~~1~~~ 94 | -------1-1---1--0-------1 ~~~~1~~~ 95 | ---------0---1--1-1-----1 ~~~~1~~~ 96 | -----1--0----1-1--------0 ~~~~1~~~ 97 | --0-----0-0----------1--0 ~~~~1~~~ 98 | 1-0-----1-0-------------0 ~~~~1~~~ 99 | -----1--0---------1-----1 ~~~~1~~~ 100 | -----1--1----1-----1----0 ~~~~1~~~ 101 | -----1-11---------------1 ~~~~1~~~ 102 | -----0--0----0-1--------- ~~~~1~~~ 103 | --------0----1----1-----1 ~~~~1~~~ 104 | -----0--1----0-----1----- ~~~~1~~~ 105 | -1-1--1----1-11---1-1---1 ~~1~~~~~ 106 | -101--1---01--1-----11--0 ~~1~~~~~ 107 | -1-1-11----1--1---1-1---1 ~~1~~~~~ 108 | -1-1-11----1-111----1---0 ~~1~~~~~ 109 | -1-1-01----1-011----1---- ~~1~~~~~ 110 | -0-0--01---0-10-----0---1 1~~~~~~~ 111 | 1000--0---00--0-----0---0 1~~~~~~~ 112 | -0-0-101---0--0-----0---1 1~~~~~~~ 113 | -0-0-10----0-10----10---0 1~~~~~~~ 114 | -0-0-00----0-00----10---- 1~~~~~~~ 115 | .e 116 | -------------------------------------------------------------------------------- /espresso-src/primes.c: -------------------------------------------------------------------------------- 1 | #include "espresso.h" 2 | 3 | static bool primes_consensus_special_cases(pset *T, pset_family *Tnew); 4 | static pcover primes_consensus_merge(pset_family Tl, pset_family Tr, pset cl, pset cr); 5 | static pcover and_with_cofactor(pset_family A, register pset cof); 6 | 7 | 8 | /* primes_consensus -- generate primes using consensus */ 9 | pcover primes_consensus(pset *T) 10 | /* T will be disposed of */ 11 | { 12 | register pcube cl, cr; 13 | register int best; 14 | pcover Tnew, Tl, Tr; 15 | 16 | if (primes_consensus_special_cases(T, &Tnew) == MAYBE) { 17 | cl = new_cube(); 18 | cr = new_cube(); 19 | best = binate_split_select(T, cl, cr, COMPL); 20 | 21 | Tl = primes_consensus(scofactor(T, cl, best)); 22 | Tr = primes_consensus(scofactor(T, cr, best)); 23 | Tnew = primes_consensus_merge(Tl, Tr, cl, cr); 24 | 25 | free_cube(cl); 26 | free_cube(cr); 27 | free_cubelist(T); 28 | } 29 | 30 | return Tnew; 31 | } 32 | 33 | static bool 34 | primes_consensus_special_cases(pset *T, pset_family *Tnew) 35 | /* will be disposed if answer is determined */ 36 | /* returned only if answer determined */ 37 | { 38 | register pcube *T1, p, ceil, cof=T[0]; 39 | pcube last; 40 | pcover A; 41 | 42 | /* Check for no cubes in the cover */ 43 | if (T[2] == NULL) { 44 | *Tnew = new_cover(0); 45 | free_cubelist(T); 46 | return TRUE; 47 | } 48 | 49 | /* Check for only a single cube in the cover */ 50 | if (T[3] == NULL) { 51 | *Tnew = sf_addset(new_cover(1), set_or(cof, cof, T[2])); 52 | free_cubelist(T); 53 | return TRUE; 54 | } 55 | 56 | /* Check for a row of all 1's (implies function is a tautology) */ 57 | for(T1 = T+2; (p = *T1++) != NULL; ) { 58 | if (full_row(p, cof)) { 59 | *Tnew = sf_addset(new_cover(1), cube.fullset); 60 | free_cubelist(T); 61 | return TRUE; 62 | } 63 | } 64 | 65 | /* Check for a column of all 0's which can be factored out */ 66 | ceil = set_save(cof); 67 | for(T1 = T+2; (p = *T1++) != NULL; ) { 68 | INLINEset_or(ceil, ceil, p); 69 | } 70 | if (! setp_equal(ceil, cube.fullset)) { 71 | p = new_cube(); 72 | (void) set_diff(p, cube.fullset, ceil); 73 | (void) set_or(cof, cof, p); 74 | free_cube(p); 75 | 76 | A = primes_consensus(T); 77 | foreach_set(A, last, p) { 78 | INLINEset_and(p, p, ceil); 79 | } 80 | *Tnew = A; 81 | set_free(ceil); 82 | return TRUE; 83 | } 84 | set_free(ceil); 85 | 86 | /* Collect column counts, determine unate variables, etc. */ 87 | massive_count(T); 88 | 89 | /* If single active variable not factored out above, then tautology ! */ 90 | if (cdata.vars_active == 1) { 91 | *Tnew = sf_addset(new_cover(1), cube.fullset); 92 | free_cubelist(T); 93 | return TRUE; 94 | 95 | /* Check for unate cover */ 96 | } else if (cdata.vars_unate == cdata.vars_active) { 97 | A = cubeunlist(T); 98 | *Tnew = sf_contain(A); 99 | free_cubelist(T); 100 | return TRUE; 101 | 102 | /* Not much we can do about it */ 103 | } else { 104 | return MAYBE; 105 | } 106 | } 107 | 108 | static pcover 109 | primes_consensus_merge(pset_family Tl, pset_family Tr, pset cl, pset cr) 110 | { 111 | register pcube pl, pr, lastl, lastr, pt; 112 | pcover T, Tsave; 113 | 114 | Tl = and_with_cofactor(Tl, cl); 115 | Tr = and_with_cofactor(Tr, cr); 116 | 117 | T = sf_new(500, Tl->sf_size); 118 | pt = T->data; 119 | Tsave = sf_contain(sf_join(Tl, Tr)); 120 | 121 | foreach_set(Tl, lastl, pl) { 122 | foreach_set(Tr, lastr, pr) { 123 | if (cdist01(pl, pr) == 1) { 124 | consensus(pt, pl, pr); 125 | if (++T->count >= T->capacity) { 126 | Tsave = sf_union(Tsave, sf_contain(T)); 127 | T = sf_new(500, Tl->sf_size); 128 | pt = T->data; 129 | } else { 130 | pt += T->wsize; 131 | } 132 | } 133 | } 134 | } 135 | free_cover(Tl); 136 | free_cover(Tr); 137 | 138 | Tsave = sf_union(Tsave, sf_contain(T)); 139 | return Tsave; 140 | } 141 | 142 | 143 | static pcover 144 | and_with_cofactor(pset_family A, register pset cof) 145 | { 146 | register pset last, p; 147 | 148 | foreach_set(A, last, p) { 149 | INLINEset_and(p, p, cof); 150 | if (cdist(p, cube.fullset) > 0) { 151 | RESET(p, ACTIVE); 152 | } else { 153 | SET(p, ACTIVE); 154 | } 155 | } 156 | return sf_inactive(A); 157 | } 158 | --------------------------------------------------------------------------------