src/misc/espresso/verify.c File Reference

#include "espresso.h"
Include dependency graph for verify.c:

Go to the source code of this file.

Functions

bool verify (pcover F, pcover Fold, pcover Dold)
bool PLA_verify (pPLA PLA1, pPLA PLA2)
 PLA_permute (pPLA PLA1, pPLA PLA2)
bool check_consistency (pPLA PLA)

Function Documentation

bool check_consistency ( pPLA  PLA  ) 

Definition at line 139 of file verify.c.

00141 {
00142     bool verify_error = FALSE;
00143     pcover T;
00144 
00145     T = cv_intersect(PLA->F, PLA->D);
00146     if (T->count == 0)
00147         printf("ON-SET and DC-SET are disjoint\n");
00148     else {
00149         printf("Some minterm(s) belong to both the ON-SET and DC-SET !\n");
00150         if (verbose_debug)
00151             cprint(T);
00152         verify_error = TRUE;
00153     }
00154     (void) fflush(stdout);
00155     free_cover(T);
00156 
00157     T = cv_intersect(PLA->F, PLA->R);
00158     if (T->count == 0)
00159         printf("ON-SET and OFF-SET are disjoint\n");
00160     else {
00161         printf("Some minterm(s) belong to both the ON-SET and OFF-SET !\n");
00162         if (verbose_debug)
00163             cprint(T);
00164         verify_error = TRUE;
00165     }
00166     (void) fflush(stdout);
00167     free_cover(T);
00168 
00169     T = cv_intersect(PLA->D, PLA->R);
00170     if (T->count == 0)
00171         printf("DC-SET and OFF-SET are disjoint\n");
00172     else {
00173         printf("Some minterm(s) belong to both the OFF-SET and DC-SET !\n");
00174         if (verbose_debug)
00175             cprint(T);
00176         verify_error = TRUE;
00177     }
00178     (void) fflush(stdout);
00179     free_cover(T);
00180 
00181     if (tautology(cube3list(PLA->F, PLA->D, PLA->R)))
00182         printf("Union of ON-SET, OFF-SET and DC-SET is the universe\n");
00183     else {
00184         T = complement(cube3list(PLA->F, PLA->D, PLA->R));
00185         printf("There are minterms left unspecified !\n");
00186         if (verbose_debug)
00187             cprint(T);
00188         verify_error = TRUE;
00189         free_cover(T);
00190     }
00191     (void) fflush(stdout);
00192     return verify_error;
00193 }

PLA_permute ( pPLA  PLA1,
pPLA  PLA2 
)

Definition at line 86 of file verify.c.

00088 {
00089     register int i, j, *permute, npermute;
00090     register char *labi;
00091     char **label;
00092 
00093     /* determine which columns of PLA1 to save, and place these in the list
00094      * "permute"; the order in this list is the final output order
00095      */
00096     npermute = 0;
00097     permute = ALLOC(int, PLA2->F->sf_size);
00098     for(i = 0; i < PLA2->F->sf_size; i++) {
00099         labi = PLA2->label[i];
00100         for(j = 0; j < PLA1->F->sf_size; j++) {
00101             if (strcmp(labi, PLA1->label[j]) == 0) {
00102                 permute[npermute++] = j;
00103                 break;
00104             }
00105         }
00106     }
00107 
00108     /* permute columns */
00109     if (PLA1->F != NULL) {
00110         PLA1->F = sf_permute(PLA1->F, permute, npermute);
00111     }
00112     if (PLA1->R != NULL) {
00113         PLA1->R = sf_permute(PLA1->R, permute, npermute);
00114     }
00115     if (PLA1->D != NULL) {
00116         PLA1->D = sf_permute(PLA1->D, permute, npermute);
00117     }
00118 
00119     /* permute the labels */
00120     label = ALLOC(char *, cube.size);
00121     for(i = 0; i < npermute; i++) {
00122         label[i] = PLA1->label[permute[i]];
00123     }
00124     for(i = npermute; i < cube.size; i++) {
00125         label[i] = NULL;
00126     }
00127     FREE(PLA1->label);
00128     PLA1->label = label;
00129 
00130     FREE(permute);
00131 }

bool PLA_verify ( pPLA  PLA1,
pPLA  PLA2 
)

Definition at line 57 of file verify.c.

00059 {
00060     /* Check if both have names given; if so, attempt to permute to
00061      * match the names
00062      */
00063     if (PLA1->label != NULL && PLA1->label[0] != NULL &&
00064            PLA2->label != NULL && PLA2->label[0] != NULL) {
00065         PLA_permute(PLA1, PLA2);
00066     } else {
00067         (void) fprintf(stderr, "Warning: cannot permute columns without names\n");
00068         return TRUE;
00069     }
00070 
00071     if (PLA1->F->sf_size != PLA2->F->sf_size) {
00072         (void) fprintf(stderr, "PLA_verify: PLA's are not the same size\n");
00073         return TRUE;
00074     }
00075 
00076     return verify(PLA2->F, PLA1->F, PLA1->D);
00077 }

bool verify ( pcover  F,
pcover  Fold,
pcover  Dold 
)

Definition at line 19 of file verify.c.

00021 {
00022     pcube p, last, *FD;
00023     bool verify_error = FALSE;
00024 
00025     /* Make sure the function didn't grow too large */
00026     FD = cube2list(Fold, Dold);
00027     foreach_set(F, last, p)
00028         if (! cube_is_covered(FD, p)) {
00029             printf("some minterm in F is not covered by Fold u Dold\n");
00030             verify_error = TRUE;
00031             if (verbose_debug) printf("%s\n", pc1(p)); else break;
00032         }
00033     free_cubelist(FD);
00034 
00035     /* Make sure minimized function covers the original function */
00036     FD = cube2list(F, Dold);
00037     foreach_set(Fold, last, p)
00038         if (! cube_is_covered(FD, p)) {
00039             printf("some minterm in Fold is not covered by F u Dold\n");
00040             verify_error = TRUE;
00041             if (verbose_debug) printf("%s\n", pc1(p)); else break;
00042         }
00043     free_cubelist(FD);
00044 
00045     return verify_error;
00046 }


Generated on Tue Jan 5 12:19:13 2010 for abc70930 by  doxygen 1.6.1