OpenCores
URL https://opencores.org/ocsvn/or2k/or2k/trunk

Subversion Repositories or2k

[/] [or2k/] [trunk/] [analysis-bin/] [insnanalysis/] [insnanalysis.c] - Diff between revs 19 and 21

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 19 Rev 21
Line 54... Line 54...
  if((fp = fopen(argv[ 1 ], "rb"))==NULL) {
  if((fp = fopen(argv[ 1 ], "rb"))==NULL) {
    printf("Cannot open file.\n");
    printf("Cannot open file.\n");
    exit(1);
    exit(1);
  }
  }
 
 
 
  int filesize_bytes, filesize_insns;
 
  // Determine filesize
 
  if ( fseek(fp, 0, SEEK_END))
 
    {
 
      fclose(fp);
 
      fprintf(stderr, "Error detecting filesize\n");
 
      return -1;
 
    }
 
 
 
  filesize_bytes = ftell(fp);
 
  filesize_insns = filesize_bytes / INSN_SIZE_BYTES;
 
 
 
  // Reset pointer
 
  rewind(fp);
 
 
 
 
 
 
  instruction * insn = (instruction *)insn_buff;
  instruction * insn = (instruction *)insn_buff;
 
 
  instruction_properties insn_props;
  instruction_properties insn_props;
 
 
  // Do initial analysis - frequency of each instruction
  // Go through the file, collect stats about instructions
 
 
 
  // What is one-percent of instructions
 
  float file_one_percent = ((float)filesize_insns / 100.0f );
 
  float percent_of_percent=0; int percent;
 
 
  insn_lists_init();
  insn_lists_init();
 
 
  while(!feof(fp)) {
  while(!feof(fp)) {
 
 
Line 78... Line 99...
 
 
    reset_instruction_properties(&insn_props);
    reset_instruction_properties(&insn_props);
 
 
    if (analyse_insn(*insn, &insn_props) == 0)
    if (analyse_insn(*insn, &insn_props) == 0)
      {
      {
        /*
 
        print_insn(&insn_props);
 
        printf("\n");
 
        */
 
        insns_seen_total++;
        insns_seen_total++;
 
 
        collect_stats(*insn, &insn_props);
        collect_stats(*insn, &insn_props);
      }
      }
    else
    else
Line 95... Line 113...
        // Is a NOP for now, but do something here if needed
        // Is a NOP for now, but do something here if needed
 
 
        do{ } while(0);
        do{ } while(0);
      }
      }
 
 
 
    // Progress indicator
 
    percent_of_percent += 1.0f;
 
    if (percent_of_percent >= file_one_percent)
 
      {
 
        percent++;
 
        fprintf(stderr, "\r%d%%", percent);
 
        percent_of_percent = 0;
 
      }
 
 
 
 
  }
  }
 
 
  fclose(fp);
  fclose(fp);
 
 
  printf("Saw %d instructions\n", insns_seen_total);
  printf("\rSaw %d instructions\n", insns_seen_total);
 
 
  generate_stats(stdout);
  generate_stats(stdout);
 
 
  insn_lists_free();
  insn_lists_free();
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.