/*************************************************************************************************************************** Main Function( write all new functions in user.c only and call them in main.c) Compile Command: make Execution Command: ./proj2 "input file" "path file" "output file" ****************************************************************************************************************************/ int main(int argc, char **argv) { FILE *fisc, *path, *fout; //file pointers used for .isc file, .path file, and output file int Max,Bound; //maxnode id,Max nodes in a bdd of cct NODE *graph; //structure used to store the cct information in .isc file //Read the .isc file and store the information in graph structure fisc=fopen(argv[1],"r"); //file pointer to open .isc file graph=(NODE *) malloc(Mnod * sizeof(NODE)); //dynamic memory allocation for graph structure Max=0; Max=ReadIsc(fisc,graph); //read .isc file and return index of last node in graph formed fclose(fisc); //close file pointer for .isc file PrintCircuit(graph,Max); //print all members of graph structure test (graph, Max, manager); //BDD user.c function declaration manager=Cudd_Init(0,0,CUDD_UNIQUE_SLOTS,CUDD_CACHE_SLOTS,0); //intializing CUDD package manger path=fopen(argv[2],"r"); //File pointer to open .path file fout=fopen(argv[3],"w"); //File pointer to open .out file printf("\nNo of Unreferenced Bdds %d\n", Cudd_CheckZeroRef(manager)); Cudd_Quit(manager); //closing the cudd package manager ClearCircuit(graph,Mnod); //clear memeory for all members of graph fclose(path); //close the path file fclose(fout); //close the output file return 0; }//end of main
/*************************************************************************************************************************** Main Function(Serial and Parallel Fault Simulation) ****************************************************************************************************************************/ void main(int argc,char **argv) { FILE *fisc,*fvec,*ffau,*fres; //file pointers used for .isc file, .vec file, .faults file and resultfile int Max,Opt,Npi,Npo,Tot,Tfs; //maxnode id,option,tot no of PIs,tot no of Pos,Tot no of input patterns& faults in.vec in.faults clock_t is,it; //execution time clock signals double iexe; //execution time NODE graph[Mnod]; //structure used to store the ckt information in .isc file PATTERN vector[Mpt]; //structure used to store the input vectors information in .vec file FAULT struck[Mft]; //structure used to store the faults information in .faults file int a,b,c,d; //random variables //Read the .isc file and store the information in graph structure is=clock(); //starting timer fisc=fopen(argv[1],"r"); //file pointer to open .isc file Max=0; Max=ReadIsc(fisc,graph); //read .isc file and return index of last node in graph formed fclose(fisc); //close file pointer for .isc file it=clock(); //ending the timer iexe=((double)(it-is))/CLOCKS_PER_SEC; //execuetion time calculation PrintCircuit(graph,Max); //print all members of graph structure printf("\nTime Taken for ISC File: %f",iexe); //print execuetion time //Read the .vec file and store the information in vector structure fvec=fopen(argv[2],"r"); //file pointer to open .vec file Tot=0; Tot=ReadVec(fvec,vector); //read .vec file and store in vector structure and return tot number of patterns printf("\nTot No of Pattern: %d",Tot); //print total number of patterns in .vec file fclose(fvec); //close file pointer for .vec file printf("\nIndex\tInputVector\n"); for(a=0;a<Tot;a++){ printf("%d\t%s",a,vector[a].piv); } //print all members of vector structure ffau=fopen(argv[4],"r"); Tfs = Readfault(ffau,struck); fclose(ffau); for(a=0;a<Tfs;a++){ printf("%d/%d \n",struck[a].nod,struck[a].sval); } fres=fopen(argv[3],"w"); //file pointer to open .out file for printing results readgraph(graph, vector, fres, Max,Tot,struck,Tfs); //call the readgraph function to process and print outputs //Perform Logic Simulationfor each Input vector and print the Pos .val in output file fclose(fres); //close file pointer for .out file ClearCircuit(graph,Mnod); //clear memeory for all members of graph for(a=0;a<Tot;a++){ bzero(vector[a].piv,Mpi); } //clear memeory for all members of vector return; }//end of main