Esempio n. 1
0
/* register simulator-specific options */
void
sim_reg_options(struct opt_odb_t *odb)
{
  opt_reg_header(odb, 
"sim-eio: This simulator implements simulator support for generating\n"
"external event traces (EIO traces) and checkpoint files.  External\n"
"event traces capture one execution of a program, and allow it to be\n"
"packaged into a single file for later re-execution.  EIO trace executions\n"
"are 100% reproducible between subsequent executions (on the same platform.\n"
"This simulator also provides functionality to generate checkpoints at\n"
"arbitrary points within an external event trace (EIO) execution.  The\n"
"checkpoint file (along with the EIO trace) can be used to start any\n"
"SimpleScalar simulator in the middle of a program execution.\n"
		 );

  /* instruction limit */
  opt_reg_uint(odb, "-max:inst", "maximum number of inst's to execute",
	       &max_insts, /* default */0,
	       /* print */TRUE, /* format */NULL);

  opt_reg_int(odb, "-fastfwd", "number of insts skipped before tracing starts",
	      &fastfwd_count, /* default */0,
	      /* print */TRUE, /* format */NULL);

  opt_reg_string(odb, "-trace", "EIO trace file output file name",
		 &trace_fname, /* default */NULL,
		 /* print */TRUE, NULL);

  opt_reg_string_list(odb, "-perdump",
		      "periodic checkpoint every n instructions: "
		      "<base fname> <interval>",
		      per_chkpt_opts, /* sz */2, &per_chkpt_nelt,
		      /* default */NULL,
		      /* !print */FALSE, /* format */NULL, /* !accrue */FALSE);

  opt_reg_string_list(odb, "-dump",
		      "specify checkpoint file and trigger: <fname> <range>",
		      chkpt_opts, /* sz */2, &chkpt_nelt, /* default */NULL,
		      /* !print */FALSE, /* format */NULL, /* !accrue */FALSE);

  opt_reg_note(odb,
"  Checkpoint range triggers are formatted as follows:\n"
"\n"
"    {{@|#}<start>}:{{@|#|+}<end>}\n"
"\n"
"  Both ends of the range are optional, if neither are specified, the range\n"
"  triggers immediately.  Ranges that start with a `@' designate an address\n"
"  range to trigger on, those that start with an `#' designate a cycle count\n"
"  trigger.  All other ranges represent an instruction count range.  The\n"
"  second argument, if specified with a `+', indicates a value relative\n"
"  to the first argument, e.g., 1000:+100 == 1000:1100.\n"
"\n"
"    Examples:   -ptrace FOO.trc #0:#1000\n"
"                -ptrace BAR.trc @2000:\n"
"                -ptrace BLAH.trc :1500\n"
"                -ptrace UXXE.trc :\n"
	       );
}
Esempio n. 2
0
/* register simulator-specific options */
void
sim_reg_options(struct opt_odb_t *odb)
{
  opt_reg_header(odb, 
"sim-cheetah: This program implements a functional simulator driver for\n"
"Cheetah.  Cheetah is a cache simulation package written by Rabin Sugumar\n"
"and Santosh Abraham which can efficiently simulate multiple cache\n"
"configurations in a single run of a program.  Specifically, Cheetah can\n"
"simulate ranges of single level set-associative and fully-associative\n"
"caches.  See the directory libcheetah/ for more details on Cheetah.\n"
		 );

  /* instruction limit */
  opt_reg_uint(odb, "-max:inst", "maximum number of inst's to execute",
	       &max_insts, /* default */LIBCHEETAH_MAX_INST,
	       /* print */TRUE, /* format */NULL);

  opt_reg_string(odb, "-refs",
		 "reference stream to analyze, i.e., {none|inst|data|unified}",
		 &ref_stream, "data", /* print */TRUE, /* format */NULL);

  opt_reg_string(odb, "-R", "replacement policy, i.e., lru or opt",
		 &repl_str, "lru", /* print */TRUE, /* format */NULL);

  opt_reg_string(odb, "-C", "cache configuration, i.e., fa, sa, or dm",
		 &conf_str, "sa", /* print */TRUE, /* format */NULL);

  opt_reg_int(odb, "-a", "min number of sets (log base 2, line size for DM)",
	      &min_sets, 7, /* print */TRUE, /* format */NULL);

  opt_reg_int(odb, "-b", "max number of sets (log base 2, line size for DM)",
	      &max_sets, 14, /* print */TRUE, /* format */NULL);

  opt_reg_int(odb, "-l", "line size of the caches (log base 2)",
	      &line_size, 4, /* print */TRUE, /* format */NULL);

  opt_reg_int(odb, "-n", "max degree of associativity to analyze (log base 2)",
	      &max_assoc, 1, /* print */TRUE, /* format */NULL);

  opt_reg_int(odb, "-in", "cache size intervals at which miss ratio is shown",
	      &cache_interval, 512, /* print */TRUE, /* format */NULL);

  opt_reg_int(odb, "-M", "maximum cache size of interest",
	      &max_cache, 524288, /* print */TRUE, /* format */NULL);

  opt_reg_int(odb, "-c", "size of cache (log base 2) for DM analysis",
	      &cache_size, 16, /* print */TRUE, /* format */NULL);
}
Esempio n. 3
0
void decode_reg_options(struct opt_odb_t * odb, struct core_knobs_t * knobs)
{

  /* decode pipe */
  opt_reg_int(odb, "-decode:depth","decode pipeline depth (stages) [DS]",
      &knobs->decode.depth, /*default*/ knobs->decode.depth, /*print*/true,/*format*/NULL);

  opt_reg_int(odb, "-decode:width","decode pipeline width (Macro-ops) [DS]",
      &knobs->decode.width, /*default*/ knobs->decode.width, /*print*/true,/*format*/NULL);

  opt_reg_int(odb, "-decode:targetstage","decode pipeline stage of branch address calculator [DS]",
      &knobs->decode.target_stage, /*default*/ knobs->decode.target_stage, /*print*/true,/*format*/NULL);

  opt_reg_int(odb, "-decode:branches","maximum branches decoded per cycle [D]",
      &knobs->decode.branch_decode_limit, /*default*/ knobs->decode.branch_decode_limit, /*print*/true,/*format*/NULL);

  /* actual decoders */
  opt_reg_int_list(odb, "-decoders", "maximum uops generated for each decoder (e.g., 4 1 1) [D]",
      knobs->decode.decoders, MAX_DECODE_WIDTH, &knobs->decode.num_decoder_specs, knobs->decode.decoders, /* print */true, /* format */NULL, /* !accrue */false);

  opt_reg_int(odb, "-MS:latency","additional latency for accessing ucode sequencer (cycles) [D]",
      &knobs->decode.MS_latency, /*default*/ knobs->decode.MS_latency, /*print*/true,/*format*/NULL);

  opt_reg_int(odb, "-uopQ:size","number of entries in uopQ [D]",
      &knobs->decode.uopQ_size, /*default*/ knobs->decode.uopQ_size, /*print*/true,/*format*/NULL);

  /* fusion options */
  opt_reg_flag(odb, "-fuse:none","disable all uop fusion rules [DS]",
      &knobs->decode.fusion_none, /*default*/ false, /*print*/true,/*format*/NULL);
  opt_reg_flag(odb, "-fuse:all","enable all uop fusion rules [D]",
      &knobs->decode.fusion_all, /*default*/ false, /*print*/true,/*format*/NULL);
  opt_reg_flag(odb, "-fuse:loadop","enable load-op uop fusion [D]",
      &knobs->decode.fusion_load_op, /*default*/ false, /*print*/true,/*format*/NULL);
  opt_reg_flag(odb, "-fuse:stastd","enable sta-std uop fusion [D]",
      &knobs->decode.fusion_sta_std, /*default*/ false, /*print*/true,/*format*/NULL);
  opt_reg_flag(odb, "-fuse:partial","enable uop-fusion of partial register write combining uops [D]",
      &knobs->decode.fusion_partial, /*default*/ false, /*print*/true,/*format*/NULL);
}
Esempio n. 4
0
void fetch_reg_options(struct opt_odb_t * odb, struct core_knobs_t * knobs)
{
  /* branch prediction */
  opt_reg_string_list(odb, "-bpred", "bpred configuration string(s) [DS]",
      knobs->fetch.bpred_opt_str, MAX_HYBRID_BPRED, &knobs->fetch.num_bpred_components, knobs->fetch.bpred_opt_str, /* print */true, /* format */NULL, /* !accrue */false);

  opt_reg_string(odb, "-bpred:fusion","fusion/meta-prediction algorithm configurations string [DS]",
      &knobs->fetch.fusion_opt_str, /*default*/ "none", /*print*/true,/*format*/NULL);

  opt_reg_string(odb, "-bpred:btb","branch target buffer configuration configuration string [DS]",
      &knobs->fetch.dirjmpbtb_opt_str, /*default*/ "btac:BTB:512:4:8:l", /*print*/true,/*format*/NULL);

  opt_reg_string(odb, "-bpred:ibtb","indirect branch target buffer configuration string [DS]",
      &knobs->fetch.indirjmpbtb_opt_str, /*default*/ "2levbtac:iBTB:1:8:1:128:4:8:l", /*print*/true,/*format*/NULL);

  opt_reg_string(odb, "-bpred:ras","return address stack predictor configuration string [DS]",
      &knobs->fetch.ras_opt_str, /*default*/ "stack:RAS:16", /*print*/true,/*format*/NULL);

  opt_reg_int(odb, "-jeclear:delay","additional latency from branch-exec to jeclear [D]",
      &knobs->fetch.jeclear_delay, /*default*/ 1, /*print*/true,/*format*/NULL);

  opt_reg_int(odb, "-byteQ:size","number of entries in byteQ [DS]",
      &knobs->fetch.byteQ_size, /*default*/ knobs->fetch.byteQ_size, /*print*/true,/*format*/NULL);
  opt_reg_int(odb, "-byteQ:linesize","linesize of byteQ (bytes) [DS]",
      &knobs->fetch.byteQ_linesize, /*default*/ knobs->fetch.byteQ_linesize, /*print*/true,/*format*/NULL);

  opt_reg_int(odb, "-predecode:depth","number of stages in predecode pipe [D]",
      &knobs->fetch.depth, /*default*/ knobs->fetch.depth, /*print*/true,/*format*/NULL);
  opt_reg_int(odb, "-predecode:width","width of predecode pipe (Macro-ops) [D]",
      &knobs->fetch.width, /*default*/ knobs->fetch.width, /*print*/true,/*format*/NULL);

  opt_reg_int(odb, "-IQ:size","size of instruction queue (Macro-ops - placed between predecode and decode) [D]",
      &knobs->fetch.IQ_size, /*default*/ knobs->fetch.IQ_size, /*print*/true,/*format*/NULL);

  opt_reg_flag(odb, "-warm:bpred","warm branch predictors during functional fast-forwarding [DS]",
      &knobs->fetch.warm_bpred, /*default*/ false, /*print*/true,/*format*/NULL);
}
Esempio n. 5
0
int
main(int argc, char **argv, char **envp)
{
  char *s;
  int i, exit_code;

#ifndef _MSC_VER
  /* catch SIGUSR1 and dump intermediate stats */
  signal(SIGUSR1, signal_sim_stats);

  /* catch SIGUSR2 and dump final stats and exit */
  signal(SIGUSR2, signal_exit_now);
#endif /* _MSC_VER */

  /* register an error handler */
  fatal_hook(sim_print_stats);

  /* set up a non-local exit point */
  if ((exit_code = setjmp(sim_exit_buf)) != 0)
    {
      /* special handling as longjmp cannot pass 0 */
      exit_now(exit_code-1);
    }

  /* register global options */
  sim_odb = opt_new(orphan_fn);
  opt_reg_flag(sim_odb, "-h", "print help message",
	       &help_me, /* default */FALSE, /* !print */FALSE, NULL);
  opt_reg_flag(sim_odb, "-v", "verbose operation",
	       &verbose, /* default */FALSE, /* !print */FALSE, NULL);
#ifdef DEBUG
  opt_reg_flag(sim_odb, "-d", "enable debug message",
	       &debugging, /* default */FALSE, /* !print */FALSE, NULL);
#endif /* DEBUG */
  opt_reg_flag(sim_odb, "-i", "start in Dlite debugger",
	       &dlite_active, /* default */FALSE, /* !print */FALSE, NULL);
  opt_reg_int(sim_odb, "-seed",
	      "random number generator seed (0 for timer seed)",
	      &rand_seed, /* default */1, /* print */TRUE, NULL);
  opt_reg_flag(sim_odb, "-q", "initialize and terminate immediately",
	       &init_quit, /* default */FALSE, /* !print */FALSE, NULL);
  opt_reg_string(sim_odb, "-chkpt", "restore EIO trace execution from <fname>",
		 &sim_chkpt_fname, /* default */NULL, /* !print */FALSE, NULL);

  /* stdio redirection options */
  opt_reg_string(sim_odb, "-redir:sim",
		 "redirect simulator output to file (non-interactive only)",
		 &sim_simout,
		 /* default */NULL, /* !print */FALSE, NULL);
  opt_reg_string(sim_odb, "-redir:prog",
		 "redirect simulated program output to file",
		 &sim_progout, /* default */NULL, /* !print */FALSE, NULL);

#ifndef _MSC_VER
  /* scheduling priority option */
  opt_reg_int(sim_odb, "-nice",
	      "simulator scheduling priority", &nice_priority,
	      /* default */NICE_DEFAULT_VALUE, /* print */TRUE, NULL);
#endif

  /* FIXME: add stats intervals and max insts... */

  /* register all simulator-specific options */
  sim_reg_options(sim_odb);

  /* parse simulator options */
  exec_index = -1;
  opt_process_options(sim_odb, argc, argv);

  /* redirect I/O? */
  if (sim_simout != NULL)
    {
      /* send simulator non-interactive output (STDERR) to file SIM_SIMOUT */
      fflush(stderr);
      if (!freopen(sim_simout, "w", stderr))
	fatal("unable to redirect simulator output to file `%s'", sim_simout);
    }

  if (sim_progout != NULL)
    {
      /* redirect simulated program output to file SIM_PROGOUT */
      sim_progfd = fopen(sim_progout, "w");
      if (!sim_progfd)
	fatal("unable to redirect program output to file `%s'", sim_progout);
    }

  /* need at least two argv values to run */
  if (argc < 2)
    {
      banner(stderr, argc, argv);
      usage(stderr, argc, argv);
      exit(1);
    }

  /* opening banner */
  banner(stderr, argc, argv);

  if (help_me)
    {
      /* print help message and exit */
      usage(stderr, argc, argv);
      exit(1);
    }

  /* seed the random number generator */
  if (rand_seed == 0)
    {
      /* seed with the timer value, true random */
      mysrand(time((time_t *)NULL));
    }
  else
    {
      /* seed with default or user-specified random number generator seed */
      mysrand(rand_seed);
    }

  /* exec_index is set in orphan_fn() */
  if (exec_index == -1)
    {
      /* executable was not found */
      fprintf(stderr, "error: no executable specified\n");
      usage(stderr, argc, argv);
      exit(1);
    }
  /* else, exec_index points to simulated program arguments */

  /************modification for XAMP*************/
  cseq_outfile=argv[exec_index];
  /***************end****************************/
  
  /* check simulator-specific options */
  sim_check_options(sim_odb, argc, argv);

#ifndef _MSC_VER
  /* set simulator scheduling priority */
  if (nice(0) < nice_priority)
    {
      if (nice(nice_priority - nice(0)) < 0)
        fatal("could not renice simulator process");
    }
#endif

  /* default architected value... */
  sim_num_insn = 0;

#ifdef BFD_LOADER
  /* initialize the bfd library */
  bfd_init();
#endif /* BFD_LOADER */

  /* initialize the instruction decoder */
  md_init_decoder();

  /* initialize all simulation modules */
  sim_init();

  /* initialize architected state */
  sim_load_prog(argv[exec_index], argc-exec_index, argv+exec_index, envp);

  /* register all simulator stats */
  sim_sdb = stat_new();
  sim_reg_stats(sim_sdb);
#if 0 /* not portable... :-( */
  stat_reg_uint(sim_sdb, "sim_mem_usage",
		"total simulator (data) memory usage",
		&sim_mem_usage, sim_mem_usage, "%11dk");
#endif

  /* record start of execution time, used in rate stats */
  sim_start_time = time((time_t *)NULL);

  /* emit the command line for later reuse */
  fprintf(stderr, "sim: command line: ");
  for (i=0; i < argc; i++)
    fprintf(stderr, "%s ", argv[i]);
  fprintf(stderr, "\n");

  /* output simulation conditions */
  s = ctime(&sim_start_time);
  if (s[strlen(s)-1] == '\n')
    s[strlen(s)-1] = '\0';
  fprintf(stderr, "\nsim: simulation started @ %s, options follow:\n", s);
  opt_print_options(sim_odb, stderr, /* short */TRUE, /* notes */TRUE);
  sim_aux_config(stderr);
  fprintf(stderr, "\n");

  /* omit option dump time from rate stats */
  sim_start_time = time((time_t *)NULL);

  if (init_quit)
    exit_now(0);

  running = TRUE;
  sim_main();

  /* simulation finished early */
  exit_now(0);

  return 0;
}
/* register simulator-specific options */
void
sim_reg_options(struct opt_odb_t *odb)
{
  opt_reg_header(odb,
"sim-bpred: This simulator implements a branch predictor analyzer.\n"
     );

  /* branch predictor options */
  opt_reg_note(odb,
"  Branch predictor configuration examples for 2-level predictor:\n"
"    Configurations:   N, M, W, X\n"
"      N   # entries in first level (# of shift register(s))\n"
"      W   width of shift register(s)\n"
"      M   # entries in 2nd level (# of counters, or other FSM)\n"
"      X   (yes-1/no-0) xor history and address for 2nd level index\n"
"    Sample predictors:\n"
"      GAg     : 1, W, 2^W, 0\n"
"      GAp     : 1, W, M (M > 2^W), 0\n"
"      PAg     : N, W, 2^W, 0\n"
"      PAp     : N, W, M (M == 2^(N+W)), 0\n"
"      gshare  : 1, W, 2^W, 1\n"
"  Predictor `comb' combines a bimodal and a 2-level predictor.\n"
               );

  /* instruction limit */
  opt_reg_uint(odb, "-max:inst", "maximum number of inst's to execute",
         &max_insts, /* default */0,
         /* print */TRUE, /* format */NULL);

  opt_reg_string(odb, "-bpred",
     "branch predictor type {nottaken|taken|smartstatic|bimod|2lev|comb}",
                 &pred_type, /* default */"bimod",
                 /* print */TRUE, /* format */NULL);

  opt_reg_int_list(
      odb,
      "-bpred:bimod",
      "bimodal predictor config (<num bits> <table size>)",
      bimod_config,
      bimod_nelt,
      &bimod_nelt,
      bimod_config,  // default
      TRUE,          // print
      NULL,          // format
      FALSE);        // !accrue

  opt_reg_int_list(
      odb,
      "-bpred:2lev",
      "2-level predictor config "
      "(<num bits> <l1size> <l2size> <hist_size> <xor>)",
      twolev_config,
      twolev_nelt,
      &twolev_nelt,
      twolev_config,  // default
      TRUE,           // print
      NULL,           // format
      FALSE);         // !accrue

  opt_reg_int_list(odb, "-bpred:comb",
       "combining predictor config (<meta_table_size>)",
       comb_config, comb_nelt, &comb_nelt,
       /* default */comb_config,
       /* print */TRUE, /* format */NULL, /* !accrue */FALSE);

  opt_reg_int(odb, "-bpred:ras",
              "return address stack size (0 for no return stack)",
              &ras_size, /* default */ras_size,
              /* print */TRUE, /* format */NULL);

  opt_reg_int_list(odb, "-bpred:btb",
       "BTB config (<num_sets> <associativity>) (-1 -1 to disable)",
       btb_config, btb_nelt, &btb_nelt,
       /* default */btb_config,
       /* print */TRUE, /* format */NULL, /* !accrue */FALSE);
}
Esempio n. 7
0
/* register simulator-specific options */
static void
sim_reg_options(struct opt_odb_t *odb)
{
  

  /* ifetch options */

  opt_reg_int(odb, "-fetch:ifqsize", "instruction fetch queue size (in insts)",
	      &ruu_ifq_size, /* default */4,
	      /* print */TRUE, /* format */NULL);

  opt_reg_int(odb, "-fetch:mplat", "extra branch mis-prediction latency",
	      &ruu_branch_penalty, /* default */5,
	      /* print */TRUE, /* format */NULL);


  opt_reg_int(odb, "-fetch:speed", "speed of front-end of machine relative to execution core",
	      &fetch_speed, /* default */1,
	      /* print */TRUE, /* format */NULL);


  /* branch predictor options */

  opt_reg_string(odb, "-bpred",
		 "branch predictor type {nottaken|taken|perfect|bimod|2lev|comb}",
                 &pred_type, /* default */"perfect",
                 /* print */TRUE, /* format */NULL);

  opt_reg_int_list(odb, "-bpred:bimod",
		   "bimodal predictor config (<table size>)",
		   bimod_config, bimod_nelt, &bimod_nelt,
		   /* default */bimod_config,
		   /* print */TRUE, /* format */NULL, /* !accrue */FALSE);

  opt_reg_int_list(odb, "-bpred:2lev",
                   "2-level predictor config "
		   "(<l1size> <l2size> <hist_size> <xor>)",
                   twolev_config, twolev_nelt, &twolev_nelt,
		   /* default */twolev_config,
                   /* print */TRUE, /* format */NULL, /* !accrue */FALSE);

  opt_reg_int_list(odb, "-bpred:comb",
		   "combining predictor config (<meta_table_size>)",
		   comb_config, comb_nelt, &comb_nelt,
		   /* default */comb_config,
		   /* print */TRUE, /* format */NULL, /* !accrue */FALSE);

  opt_reg_int_list(odb, "-bpred:btb",
		   "BTB config (<num_sets> <associativity>)",
		   btb_config, btb_nelt, &btb_nelt,
		   /* default */btb_config,
		   /* print */TRUE, /* format */NULL, /* !accrue */FALSE);

  /* decode options */

  opt_reg_int(odb, "-decode:width",
	      "instruction decode B/W (insts/cycle)",
	      &ruu_decode_width, /* default */1,
	      /* print */TRUE, /* format */NULL);

  /* issue options */

  opt_reg_int(odb, "-issue:width",
	      "instruction issue B/W (insts/cycle)",
	      &ruu_issue_width, /* default */1,
	      /* print */TRUE, /* format */NULL);

  opt_reg_flag(odb, "-issue:inorder", "run pipeline with in-order issue",
	       &ruu_inorder_issue, /* default */TRUE,
	       /* print */TRUE, /* format */NULL);

  opt_reg_flag(odb, "-issue:wrongpath",
	       "issue instructions down wrong execution paths",
	       &ruu_include_spec, /* default */TRUE,
	       /* print */TRUE, /* format */NULL);

  /* commit options */

  opt_reg_int(odb, "-commit:width",
	      "instruction commit B/W (insts/cycle)",
	      &ruu_commit_width, /* default */1,
	      /* print */TRUE, /* format */NULL);

  /* register scheduler options */

  opt_reg_int(odb, "-ruu:size",
	      "register update unit (RUU) size",
	      &RUU_size, /* default */2,
	      /* print */TRUE, /* format */NULL);

  /* memory scheduler options  */

  opt_reg_int(odb, "-lsq:size",
	      "load/store queue (LSQ) size",
	      &LSQ_size, /* default */1,
	      /* print */TRUE, /* format */NULL);

  /* cache options */

  opt_reg_string(odb, "-cache:dl1",
		 "l1 data cache config, i.e., {<config>|none}",
		 &cache_dl1_opt, "dl1:128:32:1:l",
		 /* print */TRUE, NULL);

  opt_reg_int(odb, "-cache:dl1lat",
	      "l1 data cache hit latency (in cycles)",
	      &cache_dl1_lat, /* default */1,
	      /* print */TRUE, /* format */NULL);

  opt_reg_string(odb, "-cache:dl2",
		 "l2 data cache config, i.e., {<config>|none}",
		 &cache_dl2_opt, "none", //"ul2:128:32:1:l",
		 /* print */TRUE, NULL);

  opt_reg_int(odb, "-cache:dl2lat",
	      "l2 data cache hit latency (in cycles)",
	      &cache_dl2_lat, /* default */25,
	      /* print */TRUE, /* format */NULL);

  opt_reg_string(odb, "-cache:il1",
		 "l1 inst cache config, i.e., {<config>|dl1|dl2|none}",
		 &cache_il1_opt, "il1:128:32:1:l",
		 /* print */TRUE, NULL);

  opt_reg_int(odb, "-cache:il1lat",
	      "l1 instruction cache hit latency (in cycles)",
	      &cache_il1_lat, /* default */1,
	      /* print */TRUE, /* format */NULL);

  opt_reg_string(odb, "-cache:il2",
		 "l2 instruction cache config, i.e., {<config>|dl2|none}",
		 &cache_il2_opt, "none", //"dl2", //"ul2:256:64:8:l",
		 /* print */TRUE, NULL);

  opt_reg_int(odb, "-cache:il2lat",
	      "l2 instruction cache hit latency (in cycles)",
	      &cache_il2_lat, /* default */25,
	      /* print */TRUE, /* format */NULL);

  /* mem options */
  opt_reg_int_list(odb, "-mem:lat",
		   "memory access latency (<first_chunk> <inter_chunk>)",
		   mem_lat, mem_nelt, &mem_nelt, mem_lat,
		   /* print */TRUE, /* format */NULL, /* !accrue */FALSE);

  opt_reg_int(odb, "-mem:width", "memory access bus width (in bytes)",
	      &mem_bus_width, /* default */64,
	      /* print */TRUE, /* format */NULL);

  /* TLB options */

  opt_reg_string(odb, "-tlb:itlb",
		 "instruction TLB config, i.e., {<config>|none}",
		 &itlb_opt, "none", /* print */TRUE, NULL);

  opt_reg_string(odb, "-tlb:dtlb",
		 "data TLB config, i.e., {<config>|none}",
		 &dtlb_opt, "none", /* print */TRUE, NULL);

  opt_reg_int(odb, "-tlb:lat",
	      "inst/data TLB miss latency (in cycles)",
	      &tlb_miss_lat, /* default */30,
	      /* print */TRUE, /* format */NULL);

  /* resource configuration */

  opt_reg_int(odb, "-res:ialu",
	      "total number of integer ALU's available",
	      &res_ialu, /* default */fu_config[FU_IALU_INDEX].quantity,
	      /* print */TRUE, /* format */NULL);

  opt_reg_int(odb, "-res:imult",
	      "total number of integer multiplier/dividers available",
	      &res_imult, /* default */fu_config[FU_IMULT_INDEX].quantity,
	      /* print */TRUE, /* format */NULL);

  opt_reg_int(odb, "-res:memport",
	      "total number of memory system ports available (to CPU)",
	      &res_memport, /* default */fu_config[FU_MEMPORT_INDEX].quantity,
	      /* print */TRUE, /* format */NULL);

  opt_reg_int(odb, "-res:fpalu",
	      "total number of floating point ALU's available",
	      &res_fpalu, /* default */fu_config[FU_FPALU_INDEX].quantity,
	      /* print */TRUE, /* format */NULL);

  opt_reg_int(odb, "-res:fpmult",
	      "total number of floating point multiplier/dividers available",
	      &res_fpmult, /* default */fu_config[FU_FPMULT_INDEX].quantity,
	      /* print */TRUE, /* format */NULL);

  opt_reg_int(odb, "-recursive",
              "maximum occurance of a function in the call string",
              &max_recursive_calls, 2, TRUE, NULL);

  // register my options
  opt_reg_string(odb, "-run",
		 "functionality {CFG EST}",
                 &run_opt, /* default */"EST",
                 /* print */TRUE, /* format */NULL);

}
Esempio n. 8
0
int
main(int argc, char **argv, char **envp)
{
  char *s;
  int i, exit_code;

#ifndef _MSC_VER
  /* catch SIGUSR1 and dump intermediate stats */
  signal(SIGUSR1, signal_sim_stats);

  /* catch SIGUSR2 and dump final stats and exit */
  signal(SIGUSR2, signal_exit_now);
#endif /* _MSC_VER */

  /* register an error handler */
  fatal_hook(sim_print_stats);

  /* set up a non-local exit point */
  if ((exit_code = setjmp(sim_exit_buf)) != 0)
    {
      /* special handling as longjmp cannot pass 0 */
      exit_now(exit_code-1);
    }

  /* register global options */
  sim_odb = opt_new(orphan_fn);
  opt_reg_flag(sim_odb, "-v", "verbose operation",
	       &verbose, /* default */FALSE, /* !print */FALSE, NULL);
  opt_reg_int(sim_odb, "-seed",
	      "random number generator seed (0 for timer seed)",
	      &rand_seed, /* default */1, /* print */TRUE, NULL);
  opt_reg_string(sim_odb, "-chkpt", "restore EIO trace execution from <fname>",
		 &sim_chkpt_fname, /* default */NULL, /* !print */FALSE, NULL);

  /* register instruction execution options */
  insn_reg_options(sim_odb);

  /* register all simulator-specific options */
  sim_reg_options(sim_odb);

  /* parse simulator options */
  exec_index = -1;
  opt_process_options(sim_odb, argc, argv);

  /* need at least two argv values to run */
  if (argc < 2)
    {
      banner(stderr, argc, argv);
      usage(stderr, argc, argv);
      exit(1);
    }

  /* opening banner */
  banner(stderr, argc, argv);

  /* seed the random number generator */
  if (rand_seed == 0)
    {
      /* seed with the timer value, true random */
      mysrand(time((time_t *)NULL));
    }
  else
    {
      /* seed with default or user-specified random number generator seed */
      mysrand(rand_seed);
    }

  /* exec_index is set in orphan_fn() */
  if (exec_index == -1)
    {
      /* executable was not found */
      fprintf(stderr, "error: no executable specified\n");
      usage(stderr, argc, argv);
      exit(1);
    }
  /* else, exec_index points to simulated program arguments */

  /* initialize the instruction decoder */
  md_init_decoder();

  /* need options */
  insn_check_options();

  /* check simulator-specific options */
  sim_check_options();

  /* default architected value... */
  sim_num_insn = 0;

#ifdef BFD_LOADER
  /* initialize the bfd library */
  bfd_init();
#endif /* BFD_LOADER */

  /* initialize all simulation modules */
  sim_init();

  /* initialize architected state */
  sim_load_prog(argv[exec_index], argc-exec_index, argv+exec_index, envp);

  /* register all simulator stats */

  /* record start of execution time, used in rate stats */
  sim_start_time = time((time_t *)NULL);

  /* emit the command line for later reuse */
  fprintf(stderr, "sim: command line: ");
  for (i=0; i < argc; i++)
    fprintf(stderr, "%s ", argv[i]);
  fprintf(stderr, "\n");

  /* output simulation conditions */
  s = ctime(&sim_start_time);
  if (s[strlen(s)-1] == '\n')
    s[strlen(s)-1] = '\0';
  fprintf(stderr, "\nsim: simulation started @ %s, options follow:\n", s);
  opt_print_options(sim_odb, stderr, /* short */TRUE, /* notes */TRUE);
  sim_aux_config(stderr);
  fprintf(stderr, "\n");

  /* omit option dump time from rate stats */
  sim_start_time = time((time_t *)NULL);

  running = TRUE;
  sim_main();

  /* simulation finished early */
  exit_now(0);

  return 0;
}
Esempio n. 9
0
void
main(int argc, char **argv)
{
  struct opt_odb_t *odb;

  int n_int_vars, n_uint_vars, n_float_vars, n_double_vars;
  int n_enum_vars, n_enum_eval_vars, n_flag_vars, n_string_vars;
  int int_var, int_vars[MAX_VARS];
  unsigned int uint_var, uint_vars[MAX_VARS];
  float float_var, float_vars[MAX_VARS];
  double double_var, double_vars[MAX_VARS];
  int flag_var, flag_vars[MAX_VARS];
  char *string_var, *string_vars[MAX_VARS];

  enum etest_t { enum_a, enum_b, enum_c, enum_d, enum_NUM };
  static char *enum_emap[enum_NUM] =
    { "enum_a", "enum_b", "enum_c", "enum_d" };
  static int enum_eval[enum_NUM] =
    { enum_d, enum_c, enum_b, enum_a };
  int enum_var, enum_vars[MAX_VARS];
  int enum_eval_var, enum_eval_vars[MAX_VARS];

  /* get an options processor */
  odb = opt_new(f_orphan_fn);


  opt_reg_int(odb, "-opt:int", "This is an integer option.",
	      &int_var, 1, /* print */TRUE, /* default format */NULL);
  opt_reg_int_list(odb, "-opt:int:list", "This is an integer list option.",
		   int_vars, MAX_VARS, &n_int_vars, 2,
		   /* print */TRUE, /* default format */NULL);
  opt_reg_uint(odb, "-opt:uint", "This is an unsigned integer option.",
	       &uint_var, 3, /* print */TRUE, /* default format */NULL);
  opt_reg_uint_list(odb, "-opt:uint:list",
		    "This is an unsigned integer list option.",
		    uint_vars, MAX_VARS, &n_uint_vars, 4,
		    /* print */TRUE, /* default format */NULL);
  opt_reg_float(odb, "-opt:float", "This is a float option.",
		&float_var, 5.0, /* print */TRUE, /* default format */NULL);
  opt_reg_float_list(odb, "-opt:float:list", "This is a float list option.",
		     float_vars, MAX_VARS, &n_float_vars, 6.0,
		     /* print */TRUE, /* default format */NULL);
  opt_reg_double(odb, "-opt:double", "This is a double option.",
		 &double_var, 7.0, /* print */TRUE, /* default format */NULL);
  opt_reg_double_list(odb, "-opt:double:list", "This is a double list option.",
		      double_vars, MAX_VARS, &n_double_vars, 8.0,
		      /* print */TRUE, /* default format */NULL);
  opt_reg_enum(odb, "-opt:enum", "This is an enumeration option.",
	       &enum_var, "enum_a", enum_emap, /* index map */NULL, enum_NUM,
	       /* print */TRUE, /* default format */NULL);
  opt_reg_enum_list(odb, "-opt:enum:list", "This is a enum list option.",
		    enum_vars, MAX_VARS, &n_enum_vars, "enum_b",
		    enum_emap, /* index map */NULL, enum_NUM,
		    /* print */TRUE, /* default format */NULL);
  opt_reg_enum(odb, "-opt:enum:eval", "This is an enumeration option w/eval.",
	       &enum_eval_var, "enum_b", enum_emap, enum_eval, enum_NUM,
	       /* print */TRUE, /* default format */NULL);
  opt_reg_enum_list(odb, "-opt:enum:eval:list",
		    "This is a enum list option w/eval.",
		    enum_eval_vars, MAX_VARS, &n_enum_eval_vars, "enum_a",
		    enum_emap, enum_eval, enum_NUM,
		    /* print */TRUE, /* default format */NULL);
  opt_reg_flag(odb, "-opt:flag", "This is a boolean flag option.",
	       &flag_var, FALSE, /* print */TRUE, /* default format */NULL);
  opt_reg_flag_list(odb, "-opt:flag:list",
		    "This is a boolean flag list option.",
		    flag_vars, MAX_VARS, &n_flag_vars, TRUE,
		    /* print */TRUE, /* default format */NULL);
  opt_reg_string(odb, "-opt:string", "This is a string option.",
		 &string_var, "a:string",
		 /* print */TRUE, /* default format */NULL);
  opt_reg_string_list(odb, "-opt:string:list", "This is a string list option.",
		    string_vars, MAX_VARS, &n_string_vars, "another:string",
		    /* print */TRUE, /* default format */NULL);

  /* parse options */
  opt_process_options(odb, argc, argv);

  /* print options */
  fprintf(stdout, "## Current Option Values ##\n");
  opt_print_options(odb, stdout, /* long */FALSE, /* notes */TRUE);

  /* all done */
  opt_delete(odb);
  exit(0);
}
Esempio n. 10
0
/* network configuration inputfile */
void optical_options(struct opt_odb_t *odb)
{
    opt_reg_int (odb, "-network:input_buffer_size", "input buffer size (flit unit)", &input_buffer_size, /* default */ 1, 
		    /* print */ TRUE, /* format */ NULL);
                                                                                                                                                                                                     
    opt_reg_int (odb, "-network:output_buffer_size", "output buffer size (flit unit)", &output_buffer_size, /* default */ 1,
                    /* print */ TRUE, /* format */ NULL);
                                                                                                                                                                                                     
    opt_reg_int (odb, "-network:output_ports", "output buffer ports", &output_ports, /* default */ 1,
                    /* print */ TRUE, /* format */ NULL);

    opt_reg_int (odb, "-network:packet_queue_size", "packet queue size (packet unit, used for output buffer)", &packet_queue_size, /* default */ 1,
                    /* print */ TRUE, /* format */ NULL);
                                                                                                                                                                                                     
    opt_reg_int (odb, "-network:meta_receivers", "total number of receivers for meta packets", &meta_receivers, /* default */ 1,
                        /* print */ TRUE, /* format */ NULL);
                                                                                                                                                                                                     
    opt_reg_int (odb, "-network:data_receivers", "total number of receivers for data packets", &data_receivers, /* default */ 1,
                    /* print */ TRUE, /* format */ NULL);
                                                                                                                                                                                                     
    opt_reg_int (odb, "-network:transmitters", "total numbers of transmitters", &transmitters, /* default */ 1,
                    /* print */ TRUE, /* format */ NULL);
                                                                                                                                                                                                     
                                                                                                                                                                                                     
    opt_reg_int (odb, "-network:confirmation_trans", "number of confirmation transmitters", &confirmation_trans, /* default */ 1,
                    /* print */ TRUE, /* format */ NULL);
                                                                                                                                                                                                     
                                                                                                                                                                                                     
    opt_reg_int (odb, "-network:confirmation_receiver", "number of confirmation receiver", &confirmation_receiver, /* default */ 1,
                    /* print */ TRUE, /* format */ NULL);
                                                                                                                                                                                                     
                                                                                                                                                                                                     
    opt_reg_int (odb, "-network:laser_cycle", "laser cycle (1 CPU cycle)", &laser_cycle, /* default */ 8,
                    /* print */ TRUE, /* format */ NULL);
                                                                                                                                                                                                     
    opt_reg_int (odb, "-network:meta_transmitter_size", "how many bits can be transfered in one laser cycle", &meta_transmitter_size, /* default */ 8,
                    /* print */ TRUE, /* format */ NULL);

    opt_reg_int (odb, "-network:data_transmitter_size", "how many bits can be transfered in one laser cycle", &data_transmitter_size, /* default */ 8,
                    /* print */ TRUE, /* format */ NULL);
                                                                                                                                                                                                     
                                                                                                                                                                                                     
    opt_reg_int (odb, "-network:flit_size", "flit size (bits)", &flit_size, /* default */ 64,
                    /* print */ TRUE, /* format */ NULL);
                                                                                                                                                                                                     
                                                                                                                                                                                                     
    opt_reg_int (odb, "-network:data_packet_size", "Data packet size", &data_packet_size, /* default */ 1,
                    /* print */ TRUE, /* format */ NULL);
                                                                                                                                                                                                     
                                                                                                                                                                                                     
    opt_reg_int (odb, "-network:meta_packet_size", "meta packet size", &meta_packet_size, /* default */ 1,
                    /* print */ TRUE, /* format */ NULL);
                                                                                                                                                                                                     
    opt_reg_int (odb, "-network:confirmation_bit", "confirmation bit", &confirmation_bit, /* default */ 1,
                    /* print */ TRUE, /* format */ NULL);
                                                                                                                                                                                                     
                                                                                                                                                                                                     
    opt_reg_int (odb, "-network:laser_warmup_time", "laser warm up time", &laser_warmup_time, /* default */ 1,
                    /* print */ TRUE, /* format */ NULL);
                                                                                                                                                                                                     
                                                                                                                                                                                                     
    opt_reg_int (odb, "-network:laser_setup_time", "laser set up time", &laser_setup_time, /* default */ 1,
                    /* print */ TRUE, /* format */ NULL);
                                                                                                                                                                                                     
                                                                                                                                                                                                     
    opt_reg_int (odb, "-network:laser_switchoff_timeout", "", &laser_switchoff_timeout, /* default */ 1,
                    /* print */ TRUE, /* format */ NULL);
                                                                                                                                                                                                     
    opt_reg_int (odb, "-network:data_chan_timeslot", "", &data_chan_timeslot, /* default */ 1,
                    /* print */ TRUE, /* format */ NULL);
                                                                                                                                                                                                     
    opt_reg_int (odb, "-network:meta_chan_timeslot", "", &meta_chan_timeslot, /* default */ 1,
                    /* print */ TRUE, /* format */ NULL);
                                                                                                                                                                                                     
    opt_reg_int (odb, "-network:exp_backoff", "", &exp_backoff, /* default */ 1,
                    /* print */ TRUE, /* format */ NULL);

    opt_reg_float (odb, "-network:first_slot_num", "", &first_slot_num, /* default */ 5,
                    /* print */ TRUE, /* format */ NULL);

    opt_reg_int (odb, "-network:retry_algr", "", &retry_algr, /* default */ 0,
                    /* print */ TRUE, /* format */ NULL);

    opt_reg_int (odb, "-network:TBEB_algr", "", &TBEB_algr, /* default */ 0,
                    /* print */ TRUE, /* format */ NULL);

    opt_reg_int (odb, "-network:confirmation_time", "", &confirmation_time, /* default */ 1,
                    /* print */ TRUE, /* format */ NULL);

}
int
main (int argc, char **argv, char **envp)
{
    char *s ;
    s = NULL ;
    int i, exit_code, j;

#ifndef _MSC_VER
    /* catch SIGUSR1 and dump intermediate stats */
    signal (SIGUSR1, signal_sim_stats);

    /* catch SIGUSR2 and dump final stats and exit */
    signal (SIGUSR2, signal_exit_now);
#endif /* _MSC_VER */

    /* register an error handler */
    fatal_hook (sim_print_stats);

    /* set up a non-local exit point */
    if ((exit_code = setjmp (sim_exit_buf)) != 0)
    {
	/* special handling as longjmp cannot pass 0 */
	exit_now (exit_code - 1);
    }

    /* register global options */
    sim_odb = opt_new (orphan_fn);
    opt_reg_flag (sim_odb, "-h", "print help message", &help_me, /* default */ FALSE, /* !print */ FALSE, NULL);
    opt_reg_flag (sim_odb, "-v", "verbose operation", &verbose, /* default */ FALSE, /* !print */ FALSE, NULL);
#ifdef DEBUG
    opt_reg_flag (sim_odb, "-d", "enable debug message", &debugging, /* default */ FALSE, /* !print */ FALSE, NULL);
#endif /* DEBUG */
    opt_reg_flag (sim_odb, "-i", "start in Dlite debugger", &dlite_active, /* default */ FALSE, /* !print */ FALSE, NULL);
    opt_reg_int (sim_odb, "-seed", "random number generator seed (0 for timer seed)", &rand_seed, /* default */ 1, /* print */ TRUE, NULL);
    opt_reg_flag (sim_odb, "-q", "initialize and terminate immediately", &init_quit, /* default */ FALSE, /* !print */ FALSE, NULL);

#ifdef SMT_SS
    fprintf (stderr, "Note: -chkpt option is disabled for SMT version \n");
#else
    opt_reg_string (sim_odb, "-chkpt", "restore EIO trace execution from <fname>", &sim_chkpt_fname, /* default */ NULL, /* !print */ FALSE, NULL);
#endif

#ifdef REMOVE_MY_CODE
    opt_reg_string (sim_odb, "-chkpt", "restore EIO trace execution from <fname>", &sim_chkpt_fname, /* default */ NULL, /* !print */ FALSE, NULL);
#endif

    /* stdio redirection options */
    opt_reg_string (sim_odb, "-redir:sim", "redirect simulator output to file (non-interactive only)", &sim_simout,
		    /* default */ NULL, /* !print */ FALSE, NULL);
#ifdef SMT_SS
#ifndef PROG_OUT_FROM_SIM_OUT
    fprintf (stderr, "Note: -redir:prog option is controled in *.bnc configuration " "file of each program in SMT version \n");
#else // !PROG_OUT_FROM_SIM_OUT
    fprintf (stderr, "Note: -redir:prog option is controled by combining the *.bnc configuration " "setting with the -redir:sim option. \n");
#endif // !PROG_OUT_FROM_SIM_OUT
#else
    opt_reg_string (sim_odb, "-redir:prog", "redirect simulated program output to file", &sim_progout, /* default */ NULL, /* !print */ FALSE, NULL);
#endif

#ifdef REMOVE_MY_CODE
    opt_reg_string (sim_odb, "-redir:prog", "redirect simulated program output to file", &sim_progout, /* default */ NULL, /* !print */ FALSE, NULL);
#endif

    /* Dump files to load assembly code and dumping stats etc. */
    opt_reg_string (sim_odb, "-redir:dump", "redirect simulated program output to file", &sim_str_dump, /* default */ NULL, /* !print */ FALSE, NULL);

#ifndef _MSC_VER
    /* scheduling priority option */
    opt_reg_int (sim_odb, "-nice", "simulator scheduling priority", &nice_priority,
		 /* default */ NICE_DEFAULT_VALUE, /* print */ TRUE, NULL);
#endif

    /* register all simulator-specific options */
    sim_reg_options (sim_odb);

    /* parse simulator options */
    exec_index = -1;

#ifdef REMOVE_MY_CODE
    fprintf (stderr, "sim_odb %lu \n", (long) sim_odb);
    fprintf (stderr, "sim: command line: ");
    for (i = 0; i < argc; i++)
	fprintf (stderr, "%s ", argv[i]);
    fprintf (stderr, "\n");
    {
	char name[256];

	gethostname (name, 256);
	fprintf (stderr, "Run on %s\n", name);
    }
#endif
    opt_process_options (sim_odb, argc, argv);
    /* redirect I/O? */
    if (sim_simout != NULL)
    {
	/* send simulator non-interactive output (STDERR) to file SIM_SIMOUT */
	if (fflush (stderr))
	    fatal ("unable to flush stderr ");
	else
	{
	   if (!freopen (sim_simout, "w", stderr))
		fatal ("unable to redirect simulator output to file `%s'", sim_simout);
	}

    }

#ifndef SMT_SS
    if (sim_progout != NULL)
    {
	/* redirect simulated program output to file SIM_PROGOUT */
	sim_progfd = fopen (sim_progout, "w");
	if (!sim_progfd)
	    fatal ("unable to redirect program output to file `%s'", sim_progout);
    }
#endif

    /* need at least two argv values to run */
    if (argc < 2)
    {
	banner (stderr, argc, argv);
	usage (stderr, argc, argv);
	fprintf (stderr, "error:exit from main argc < 2\n");
	exit (1);
    }

    /* opening banner */
    banner (stderr, argc, argv);

    if (help_me)
    {
	/* print help message and exit */
	usage (stderr, argc, argv);
	fprintf (stderr, "error:exit from main help_me\n");
	exit (1);
    }

    /* seed the random number generator */
    if (rand_seed == 0)
    {
	/* seed with the timer value, true random */
	mysrand (time ((time_t *) NULL));
    }
    else
    {
	/* seed with default or user-specified random number generator seed */
	mysrand (rand_seed);
    }

    /* exec_index is set in orphan_fn() */
    if (exec_index == -1)
    {
	/* executable was not found */
	fprintf (stderr, "error: no executable specified\n");
	usage (stderr, argc, argv);
	exit (1);
    }
    /* else, exec_index points to simulated program arguments */

    /* check simulator-specific options */
    sim_check_options (sim_odb, argc, argv);

#ifndef _MSC_VER
    /* set simulator scheduling priority */
    if (nice (0) < nice_priority)
    {
	if (nice (nice_priority - nice (0)) < 0)
	    fatal ("could not renice simulator process");
    }
#endif
    /* emit the command line for later reuse */
    /* copied here for easier debugging */
    fprintf (stderr, "sim: command line: ");
    for (i = 0; i < argc; i++)
	fprintf (stderr, "%s ", argv[i]);
    fprintf (stderr, "\n");
    {
	char name[256];

	gethostname (name, 256);
	fprintf (stderr, "Run on %s\n", name);
    }


    /* default architected value... */
    sim_num_insn = 0;

#ifdef BFD_LOADER
    /* initialize the bfd library */
    bfd_init ();
#endif /* BFD_LOADER */

    /* initialize the instruction decoder */
    md_init_decoder ();

#ifndef SMT_SS
    /* initialize all simulation modules */
    sim_init ();
#endif

    /* initialize architected state */
#ifdef SMT_SS
    sim_load_threads (argc - exec_index, argv + exec_index, envp);
#else
    sim_load_prog (argv[exec_index], argc - exec_index, argv + exec_index, envp);
#endif

#ifdef SMT_SS
    /* initialize all simulation modules */
    sim_init ();
#endif

#ifndef PARALLEL_EMUL
    /* register all simulator stats */
    sim_sdb = stat_new ();
    sim_reg_stats (sim_sdb);
#endif
    
    /* record start of execution time, used in rate stats */
    sim_start_time = time ((time_t *) NULL);

    /* emit the command line for later reuse */
    fprintf (stderr, "sim: command line: ");
    for (i = 0; i < argc; i++)
	fprintf (stderr, "%s ", argv[i]);
    fprintf (stderr, "\n");
    {
	char name[256];

	gethostname (name, 256);
	fprintf (stderr, "Run on %s\n", name);
    }

    /* output simulation conditions */
    s = ctime (&sim_start_time);
    if (s[strlen (s) - 1] == '\n')
	s[strlen (s) - 1] = '\0';
#ifdef __VERSION__
#define COMPILEDWITH "gcc version " __VERSION__
#else
#define COMPILEDWITH "unknown compiler"
#endif
    fprintf (stderr, "\nsim: main.c compiled on " __DATE__ " at " __TIME__ " with " COMPILEDWITH);
    fprintf (stderr, "\nsim: simulation started @ %s, options follow:\n", s);
    opt_print_options (sim_odb, stderr, /* short */ TRUE, /* notes */ TRUE);
    sim_aux_config (stderr);
    fprintf (stderr, "\n");

    /* omit option dump time from rate stats */
    sim_start_time = time ((time_t *) NULL);

    if (init_quit)
	exit_now (0);

    running = TRUE;

    for (j = 0; j < 4; j++)
    {
	for (i = 0; i < NUM_COM_REGS; i++)
	{
	    common_regs_s[j][i].regs_lock = 0;
	    common_regs_s[j][i].address = 0;
	}
    }
    //outFile = fopen ("simOutFile.txt", "w");
//    fprintf(outFile,"fanglei\n");           // fprintf test @ fanglei
//    fflush(outFile);                        // flush @ fanglei
    if(!strcmp(argv[9], "ilink1030.BNC"))
	ilink_run = 1;
    else
	ilink_run = 0;
    if(!strcmp(argv[9], "../../BNCfor16/em3d1030.BNC"))
	em3d_run = 1;
    else
	em3d_run = 0;
    sim_main ();

    /* simulation finished early */
    exit_now (0);
#ifdef __GNUC__
    return 0;
#endif
}
Esempio n. 12
0
int init(simoutorder* in_simobj,
         int argc,
         char** argv,
         char **envp
         )
{
in_simobj->sim_odb = opt_new(orphan_fn);
opt_reg_flag(in_simobj->sim_odb, "-h", "print help message",
	       &help_me, /* default */FALSE, /* !print */FALSE, NULL);
  opt_reg_flag(in_simobj->sim_odb, "-v", "verbose operation",
	       &verbose, /* default */FALSE, /* !print */FALSE, NULL);
#ifdef DEBUG
  opt_reg_flag(in_simobj->sim_odb, "-d", "enable debug message",
	       &debugging, /* default */FALSE, /* !print */FALSE, NULL);
#endif /* DEBUG */
  opt_reg_flag(in_simobj->sim_odb, "-i", "start in Dlite debugger",
	       &dlite_active, /* default */FALSE, /* !print */FALSE, NULL);
  opt_reg_int(in_simobj->sim_odb, "-seed",
	      "random number generator seed (0 for timer seed)",
	      &rand_seed, /* default */1, /* print */TRUE, NULL);
  opt_reg_flag(in_simobj->sim_odb, "-q", "initialize and terminate immediately",
	       &init_quit, /* default */FALSE, /* !print */FALSE, NULL);
  opt_reg_string(in_simobj->sim_odb, "-chkpt", "restore EIO trace execution from <fname>",
		 &sim_chkpt_fname, /* default */NULL, /* !print */FALSE, NULL);

  /* stdio redirection options */
  opt_reg_string(in_simobj->sim_odb, "-redir:sim",
		 "redirect simulator output to file (non-interactive only)",
		 &sim_simout,
		 /* default */NULL, /* !print */FALSE, NULL);
  opt_reg_string(in_simobj->sim_odb, "-redir:prog",
		 "redirect simulated program output to file",
		 &sim_progout, /* default */NULL, /* !print */FALSE, NULL);
  #ifndef _MSC_VER
  /* scheduling priority option */
  opt_reg_int(in_simobj->sim_odb, "-nice",
	      "simulator scheduling priority", &nice_priority,
	      /* default */NICE_DEFAULT_VALUE, /* print */TRUE, NULL);
#endif
in_simobj->sim_reg_options(in_simobj->sim_odb);

exec_index = -1;
  opt_process_options(in_simobj->sim_odb, argc, argv);

  /* redirect I/O? */
  if (sim_simout != NULL)
    {
      /* send simulator non-interactive output (STDERR) to file SIM_SIMOUT */
      fflush(stderr);
      if (!freopen(sim_simout, "w", stderr))
	fatal("unable to redirect simulator output to file `%s'", sim_simout);
    }

  if (sim_progout != NULL)
    {
      /* redirect simulated program output to file SIM_PROGOUT */
      sim_progfd = fopen(sim_progout, "w");
      if (!sim_progfd)
	fatal("unable to redirect program output to file `%s'", sim_progout);
    }

  /* need at least two argv values to run */
  if (argc < 2)
    {
      banner(stderr, argc, argv);
      usage(stderr, argc, argv, in_simobj->sim_odb);
      exit(1);
    }
  
  if (help_me)
    {
      /* print help message and exit */
      usage(stderr, argc, argv, in_simobj->sim_odb);
      exit(1);
    }

  /* seed the random number generator */
  if (rand_seed == 0)
    {
      /* seed with the timer value, true random */
      mysrand(time((time_t *)NULL));
    }
  else
    {
      /* seed with default or user-specified random number generator seed */
      mysrand(rand_seed);
    }

  /* exec_index is set in orphan_fn() */
  if (exec_index == -1)
    {
      /* executable was not found */
      fprintf(stderr, "error: no executable specified\n");
      usage(stderr, argc, argv, in_simobj->sim_odb);
      exit(1);
    }
  /* else, exec_index points to simulated program arguments */

  /* check simulator-specific options */
  in_simobj->sim_check_options(in_simobj->sim_odb, argc, argv);

#ifndef _MSC_VER
  /* set simulator scheduling priority */
  if (nice(0) < nice_priority)
    {
      if (nice(nice_priority - nice(0)) < 0)
        fatal("could not renice simulator process");
    }
#endif

  /* default architected value... */
  sim_num_insn = 0;

#ifdef BFD_LOADER
  /* initialize the bfd library */
  bfd_init();
#endif /* BFD_LOADER */

 

  /* initialize all simulation modules */
  in_simobj->sim_init();

  /* initialize architected state */
  in_simobj->sim_load_prog(argv[exec_index], argc-exec_index, argv+exec_index, envp);
 
  /* register all simulator stats */
  struct stat_sdb_t *sdb;

  in_simobj->sim_sdb = (struct stat_sdb_t *)calloc(1, sizeof(struct stat_sdb_t));
  if (!in_simobj->sim_sdb)
    fatal("out of virtual memory");

  in_simobj->sim_sdb->stats = NULL;
  in_simobj->sim_sdb->evaluator = eval_new(stat_eval_ident, in_simobj->sim_sdb);

  in_simobj->sim_reg_stats(in_simobj->sim_sdb);
  
  return 1;
  
}