void hillclimbing(int (*cube)[CUBE],int x,int y,int (*target)[CUBE]){ struct Node *currentnode=malloc(sizeof(struct Node)); currentnode->x=x,currentnode->y=y,currentnode->prev=NULL; cube_copy(cube,currentnode->cube); push(currentnode); struct Node *node; int tmpcube[CUBE][CUBE]; while(!empty()){ currentnode=top(); if(cube_equal(currentnode->cube,target)){ displayoutcome(currentnode); break; } pop(); nodesszie=0; //up cube_copy(currentnode->cube,tmpcube); if(currentnode->x > 0){ move_up(tmpcube,currentnode->x,currentnode->y); if(!inme(currentnode,tmpcube)){ node=malloc(sizeof(struct Node)); cube_copy(tmpcube,node->cube); node->x=currentnode->x-1,node->y=currentnode->y; node->prev=currentnode; push(node); } } //down cube_copy(currentnode->cube,tmpcube); if(currentnode->x <CUBE-1){ move_down(tmpcube,currentnode->x,currentnode->y); if(!inme(currentnode,tmpcube)){ node=malloc(sizeof(struct Node)); cube_copy(tmpcube,node->cube); node->x=currentnode->x+1,node->y=currentnode->y; node->prev=currentnode; push(node); } } //left cube_copy(currentnode->cube,tmpcube); if(currentnode->y > 0){ move_left(tmpcube,currentnode->x,currentnode->y); if(!inme(currentnode,tmpcube)){ node=malloc(sizeof(struct Node)); cube_copy(tmpcube,node->cube); node->x=currentnode->x,node->y=currentnode->y-1; node->prev=currentnode; push(node); } } //right cube_copy(currentnode->cube,tmpcube); if(currentnode->y < CUBE-1){ move_right(tmpcube,currentnode->x,currentnode->y); if(!inme(currentnode,tmpcube)){ node=malloc(sizeof(struct Node)); cube_copy(tmpcube,node->cube); node->x=currentnode->x,node->y=currentnode->y+1; node->prev=currentnode; push(node); } } } }
int main(int argc, char **argv) { int index1,index2; CUBE F,R,D; CUBE W; /*this will store the original ON-set function*/ CUBE V; /*this will store the espresso expand output*/ /*in case of improper invocation*/ if(argc != 4) { printf("Please check the usage:\n"); printf("Usage: ./logic_min <input_file> <file_flag> <output_file\n"); printf("Example ./logic_min input_file -e\n"); exit(0); } /*parse the input file and build up the ON-set, *OFF-set and dont-care set*/ read_inputs_from_file(&F,&R,&D,argv[1]); /*preserve org onset function*/ cube_copy(&W, &F); /*call the expand function*/ expand(&F,&R); /*printing party*/ printf("\nJust after Espresso Expand and before logic_min\n"); printf("\n**********************************************\n"); printf("\nThe ON set is %d %d\n",F.rows,F.cols); print_cube(&F); printf("\n"); printf("\nThe OFF set is %d %d\n",R.rows,R.cols); print_cube(&R); printf("\n"); printf("\nThe DONT CARE set is %d %d\n",D.rows,D.cols); print_cube(&D); printf("\n"); printf("\n**********************************************\n"); /*preserve the espresso expand output*/ cube_copy(&V, &F); /*logic minimization routine*/ logic_min(&F); /*parse the command line argument to check what type of * output file needs to be generated*/ if (strcmp(argv[2],"-e") == 0) { text_file_output(&W, &V, &R, &D,argv[3], ESPEXP_TEXT_OUTPUT); } else if (strcmp(argv[2],"-t") == 0) { text_file_output(&W, &F, &R, &D,argv[3], OPT_TEXT_OUTPUT); } else if (strcmp(argv[2],"-v") == 0) { verilog_file_output(&F, argv[3]); } else { printf("Invalid flag.\n"); } }/*end of main*/