19 pcover Tplus, Tminus, Tplusbar, Tminusbar;
20 pcover newf, term1, term2, dcset, dcsetbar;
21 pcube cplus, cminus, last,
p;
23 if (PLA->label ==
NIL(
char *) || PLA->label[0] ==
NIL(
char))
28 for(i = 0; i <
cube.num_binary_vars * 2; i++) {
29 if (
strncmp(PLA->label[i],
"DONT_CARE", 9) == 0 ||
30 strncmp(PLA->label[i],
"DONTCARE", 8) == 0 ||
31 strncmp(PLA->label[i],
"dont_care", 9) == 0 ||
32 strncmp(PLA->label[i],
"dontcare", 8) == 0) {
76 for(i = 2*var+2; i <
cube.size; i++) {
77 PLA->label[i-2] = PLA->label[i];
79 for(i = var+1; i <
cube.num_vars; i++) {
80 cube.part_size[i-1] =
cube.part_size[i];
82 cube.num_binary_vars--;
85 PLA->F =
sf_delc(PLA->F, 2*var, 2*var+1);
86 PLA->D =
sf_delc(PLA->D, 2*var, 2*var+1);
96 int i, bit, tot_size, base, old_size;
99 if (PLA->D->count > 0) {
106 for(p1=PLA->symbolic_output; p1!=
NIL(
symbolic_t); p1=p1->next) {
108 if (p2->pos<0 || p2->pos>=
cube.part_size[
cube.output]) {
109 fatal(
"symbolic-output index out of range");
114 tot_size += 1 << p1->symbolic_list_length;
118 for(p1=PLA->symbolic_output; p1!=
NIL(
symbolic_t); p1=p1->next) {
125 old_size =
cube.size;
126 cube.part_size[
cube.output] += tot_size;
131 base =
cube.first_part[
cube.output];
132 PLA->F =
sf_addcol(PLA->F, base, tot_size);
133 PLA->D =
sf_addcol(PLA->D, base, tot_size);
134 PLA->R =
sf_addcol(PLA->R, base, tot_size);
137 for(p1=PLA->symbolic_output; p1!=
NIL(
symbolic_t); p1=p1->next) {
156 base += 1 << p1->symbolic_list_length;
161 for(p1=PLA->symbolic_output; p1!=
NIL(
symbolic_t); p1=p1->next) {
163 bit =
cube.first_part[
cube.output] + p2->pos;
172 if (
cube.size != PLA->F->sf_size)
fatal(
"error");
177 for(i = 0; i <
cube.num_vars; i++) {
293 int var, base, num_vars, num_binary_vars, *new_part_size;
294 int new_size, size_added, num_deleted_vars, num_added_vars, newvar;
298 for(p1 = PLA->symbolic; p1 !=
NIL(
symbolic_t); p1 = p1->next) {
300 if (p2->variable < 0 || p2->variable >=
cube.num_binary_vars) {
301 fatal(
".symbolic requires binary variables");
314 for(p1 = PLA->symbolic; p1 !=
NIL(
symbolic_t); p1 = p1->next) {
315 size_added += 1 << p1->symbolic_list_length;
319 for(p1 = PLA->symbolic; p1 !=
NIL(
symbolic_t); p1 = p1->next) {
325 num_deleted_vars = ((PLA->F->sf_size + size_added) -
set_ord(
compress))/2;
328 num_vars =
cube.num_vars - num_deleted_vars + num_added_vars;
329 num_binary_vars =
cube.num_binary_vars - num_deleted_vars;
330 new_size =
cube.size - num_deleted_vars*2 + size_added;
331 new_part_size =
ALLOC(
int, num_vars);
332 new_part_size[num_vars-1] =
cube.part_size[
cube.num_vars-1];
333 for(var =
cube.num_binary_vars; var <
cube.num_vars-1; var++) {
334 new_part_size[var-num_deleted_vars] =
cube.part_size[var];
338 base =
cube.first_part[
cube.output];
339 PLA->F =
sf_addcol(PLA->F, base, size_added);
340 PLA->D =
sf_addcol(PLA->D, base, size_added);
341 PLA->R =
sf_addcol(PLA->R, base, size_added);
344 newvar = (
cube.num_vars - 1) - num_deleted_vars;
345 for(p1 = PLA->symbolic; p1 !=
NIL(
symbolic_t); p1 = p1->next) {
349 base += 1 << p1->symbolic_list_length;
350 new_part_size[newvar++] = 1 << p1->symbolic_list_length;
359 new_size,
cube.size, size_added);
362 cube.num_vars = num_vars;
363 cube.num_binary_vars = num_binary_vars;
364 cube.part_size = new_part_size;
414int new_size, old_size, size_added;
422 if ((oldlabel = PLA->label) ==
NIL(
char *))
424 PLA->label =
ALLOC(
char *, new_size);
425 for(i = 0; i < new_size; i++) {
426 PLA->label[i] =
NIL(
char);
431 for(i = 0; i <
cube.first_part[
cube.output]; i++) {
433 PLA->label[base++] = oldlabel[i];
435 if (oldlabel[i] !=
NIL(
char)) {
443 p3 = p1->symbolic_label;
444 for(i = 0; i < (1 << p1->symbolic_list_length); i++) {
446 PLA->label[base+i] =
ALLOC(
char, 10);
447 (void)
sprintf(PLA->label[base+i],
"X%d", i);
449 PLA->label[base+i] = p3->
label;
453 base += 1 << p1->symbolic_list_length;
457 for(i =
cube.first_part[
cube.output]; i < old_size; i++) {
459 PLA->label[base++] = oldlabel[i];
461 if (oldlabel[i] !=
NIL(
char)) {
486 int nin, nstates, nout;
487 int before, after, present_state, next_state, i, j;
488 pcube next_state_mask, present_state_mask, state_mask,
p, p1, last;
497 if (
cube.num_vars -
cube.num_binary_vars != 2) {
498 (void) fprintf(stderr,
499 "use .symbolic and .symbolic-output to specify\n");
500 (void) fprintf(stderr,
501 "the present state and next state field information\n");
502 fatal(
"disassemble_pla: need two multiple-valued variables\n");
505 nin =
cube.num_binary_vars;
506 nstates =
cube.part_size[
cube.num_binary_vars];
507 nout =
cube.part_size[
cube.num_vars - 1];
508 if (nout < nstates) {
509 (void) fprintf(stderr,
510 "use .symbolic and .symbolic-output to specify\n");
511 (void) fprintf(stderr,
512 "the present state and next state field information\n");
513 fatal(
"disassemble_pla: # outputs < # states\n");
517 present_state =
cube.first_part[
cube.num_binary_vars];
519 for(i = 0; i < nstates; i++) {
520 set_insert(present_state_mask, i + present_state);
523 next_state =
cube.first_part[
cube.num_binary_vars+1];
525 for(i = 0; i < nstates; i++) {
529 state_mask =
set_or(
new_cube(), next_state_mask, present_state_mask);
537 for(i = 0; i < nstates; i++) {
548 tF = fsm_simplify(tF);
556 printf(
"# state EVERY to %d, before=%d after=%d\n",
573 before = go_nowhere->count;
575 cube.num_binary_vars,
cube.num_binary_vars);
576 after = go_nowhere->count;
579 printf(
"# state ANY to NOWHERE, before=%d after=%d\n", before, after);
586 for(i = 0; i < nstates; i++) {
587 for(j = 0; j < nstates; j++) {
606 tF = fsm_simplify(tF);
614 printf(
"# state %d to %d, before=%d after=%d\n",
615 i, j, before, after);
633 cube.num_binary_vars = nin;
634 cube.num_vars = nin + 3;
636 cube.part_size[
cube.num_binary_vars] = nstates;
637 cube.part_size[
cube.num_binary_vars+1] = nstates;
638 cube.part_size[
cube.num_binary_vars+2] = nout - nstates;