📄 verify.c
字号:
/* * Revision Control Information * * $Source: /projects/mvsis/Repository/mvsis-1.3/src/sis/espresso/verify.c,v $ * $Author: wjiang $ * $Revision: 1.1.1.1 $ * $Date: 2003/02/24 22:24:08 $ * *//* */#include "espresso.h"/* * verify -- check that all minterms of F are contained in (Fold u Dold) * and that all minterms of Fold are contained in (F u Dold). */bool verify(F, Fold, Dold)pcover F, Fold, Dold;{ pcube p, last, *FD; bool verify_error = FALSE; /* Make sure the function didn't grow too large */ FD = cube2list(Fold, Dold); foreach_set(F, last, p) if (! cube_is_covered(FD, p)) { (void) printf("some minterm in F is not covered by Fold u Dold\n"); verify_error = TRUE; if (verbose_debug) (void) printf("%s\n", pc1(p)); else break; } free_cubelist(FD); /* Make sure minimized function covers the original function */ FD = cube2list(F, Dold); foreach_set(Fold, last, p) if (! cube_is_covered(FD, p)) { (void) printf("some minterm in Fold is not covered by F u Dold\n"); verify_error = TRUE; if (verbose_debug) (void) printf("%s\n", pc1(p)); else break; } free_cubelist(FD); return verify_error;}/* * PLA_verify -- verify that two PLA's are identical * * If names are given, row and column permutations are done to make * the comparison meaningful. * */bool PLA_verify(PLA1, PLA2)pPLA PLA1, PLA2;{ /* Check if both have names given; if so, attempt to permute to * match the names */ if (PLA1->label != NULL && PLA1->label[0] != NULL && PLA2->label != NULL && PLA2->label[0] != NULL) { PLA_permute(PLA1, PLA2); } else { (void) fprintf(stderr, "Warning: cannot permute columns without names\n"); return TRUE; } if (PLA1->F->sf_size != PLA2->F->sf_size) { (void) fprintf(stderr, "PLA_verify: PLA's are not the same size\n"); return TRUE; } return verify(PLA2->F, PLA1->F, PLA1->D);}/* * Permute the columns of PLA1 so that they match the order of PLA2 * Discard any columns of PLA1 which are not in PLA2 * Association is strictly by the names of the columns of the cover. */PLA_permute(PLA1, PLA2)pPLA PLA1, PLA2;{ register int i, j, *permute, npermute; register char *labi; char **label; /* determine which columns of PLA1 to save, and place these in the list * "permute"; the order in this list is the final output order */ npermute = 0; permute = ALLOC(int, PLA2->F->sf_size); for(i = 0; i < PLA2->F->sf_size; i++) { labi = PLA2->label[i]; for(j = 0; j < PLA1->F->sf_size; j++) { if (strcmp(labi, PLA1->label[j]) == 0) { permute[npermute++] = j; break; } } } /* permute columns */ if (PLA1->F != NULL) { PLA1->F = sf_permute(PLA1->F, permute, npermute); } if (PLA1->R != NULL) { PLA1->R = sf_permute(PLA1->R, permute, npermute); } if (PLA1->D != NULL) { PLA1->D = sf_permute(PLA1->D, permute, npermute); } /* permute the labels */ label = ALLOC(char *, cube.size); for(i = 0; i < npermute; i++) { label[i] = PLA1->label[permute[i]]; } for(i = npermute; i < cube.size; i++) { label[i] = NULL; } FREE(PLA1->label); PLA1->label = label; FREE(permute);}/* * check_consistency -- test that the ON-set, OFF-set and DC-set form * a partition of the boolean space. */bool check_consistency(PLA)pPLA PLA;{ bool verify_error = FALSE; pcover T; T = cv_intersect(PLA->F, PLA->D); if (T->count == 0) (void) printf("ON-SET and DC-SET are disjoint\n"); else { (void) printf("Some minterm(s) belong to both the ON-SET and DC-SET !\n"); if (verbose_debug) cprint(T); verify_error = TRUE; } (void) fflush(stdout); free_cover(T); T = cv_intersect(PLA->F, PLA->R); if (T->count == 0) (void) printf("ON-SET and OFF-SET are disjoint\n"); else { (void) printf("Some minterm(s) belong to both the ON-SET and OFF-SET !\n"); if (verbose_debug) cprint(T); verify_error = TRUE; } (void) fflush(stdout); free_cover(T); T = cv_intersect(PLA->D, PLA->R); if (T->count == 0) (void) printf("DC-SET and OFF-SET are disjoint\n"); else { (void) printf("Some minterm(s) belong to both the OFF-SET and DC-SET !\n"); if (verbose_debug) cprint(T); verify_error = TRUE; } (void) fflush(stdout); free_cover(T); if (tautology(cube3list(PLA->F, PLA->D, PLA->R))) (void) printf("Union of ON-SET, OFF-SET and DC-SET is the universe\n"); else { T = complement(cube3list(PLA->F, PLA->D, PLA->R)); (void) printf("There are minterms left unspecified !\n"); if (verbose_debug) cprint(T); verify_error = TRUE; free_cover(T); } (void) fflush(stdout); return verify_error;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -