예제 #1
0
파일: bpred.c 프로젝트: Anmol2307/PranaliOS
void bpred_init()
{
	int core, thread;

	/* Two-level bpred parameters. */
	bpred_hist_size = bpred_twolevel_param[2];
	bpred_level1_size = bpred_twolevel_param[0];
	bpred_level2_size = bpred_twolevel_param[1];
	bpred_level2_height = 1 << bpred_hist_size;
	
	/* Integrity */
	if (bpred_bimod_size & (bpred_bimod_size - 1))
		fatal("bpred:bimod must be power of 2");
	if (bpred_choice_size & (bpred_choice_size - 1))
		fatal("bpred:choice must be power of 2");
	if (sscanf(bpred_btb, "%d:%d", &bpred_btb_sets, &bpred_btb_assoc) != 2)
		fatal("invalid bpred:btb format");
	if (bpred_btb_sets & (bpred_btb_sets - 1))
		fatal("number of btb sets must be power of 2");
	if (bpred_btb_assoc & (bpred_btb_assoc - 1))
		fatal("btb associativity must be power of 2");
	
	if (bpred_hist_size < 1 || bpred_hist_size > 30)
		fatal("predictor history size must be >=1 and <=30");
	if (bpred_level1_size & (bpred_level1_size - 1))
		fatal("two-level predictor sizes must be power of 2");
	if (bpred_level2_size & (bpred_level2_size - 1))
		fatal("two-level predictor sizes must be power of 2");
	
	/* Initialization */
	FOREACH_CORE FOREACH_THREAD {
		THREAD.bpred = bpred_create();
		sprintf(THREAD.bpred->name, "c%dt%d.bpred", core, thread);
	}
}
예제 #2
0
파일: sim-bpred.c 프로젝트: hoangt/sim-mp
/* check simulator-specific option values */
void
sim_check_options(struct opt_odb_t *odb, int argc, char **argv)
{
  if (!mystricmp(pred_type, "taken"))
    {
      /* static predictor, not taken */
      pred = bpred_create(BPredTaken, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }
  else if (!mystricmp(pred_type, "nottaken"))
    {
      /* static predictor, taken */
      pred = bpred_create(BPredNotTaken, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }
  else if (!mystricmp(pred_type, "bimod"))
    {
      if (bimod_nelt != 1)
	fatal("bad bimod predictor config (<table_size>)");
      if (btb_nelt != 2)
	fatal("bad btb config (<num_sets> <associativity>)");

      /* bimodal predictor, bpred_create() checks BTB_SIZE */
      pred = bpred_create(BPred2bit,
			  /* bimod table size */bimod_config[0],
			  /* 2lev l1 size */0,
			  /* 2lev l2 size */0,
			  /* meta table size */0,
			  /* history reg size */0,
			  /* history xor address */0,
			  /* btb sets */btb_config[0],
			  /* btb assoc */btb_config[1],
			  /* ret-addr stack size */ras_size);
    }
  else if (!mystricmp(pred_type, "2lev"))
    {
      /* 2-level adaptive predictor, bpred_create() checks args */
      if (twolev_nelt != 4)
	fatal("bad 2-level pred config (<l1size> <l2size> <hist_size> <xor>)");
      if (btb_nelt != 2)
	fatal("bad btb config (<num_sets> <associativity>)");

      pred = bpred_create(BPred2Level,
			  /* bimod table size */0,
			  /* 2lev l1 size */twolev_config[0],
			  /* 2lev l2 size */twolev_config[1],
			  /* meta table size */0,
			  /* history reg size */twolev_config[2],
			  /* history xor address */twolev_config[3],
			  /* btb sets */btb_config[0],
			  /* btb assoc */btb_config[1],
			  /* ret-addr stack size */ras_size);
    }
  else if (!mystricmp(pred_type, "comb"))
    {
      /* combining predictor, bpred_create() checks args */
      if (twolev_nelt != 4)
	fatal("bad 2-level pred config (<l1size> <l2size> <hist_size> <xor>)");
      if (bimod_nelt != 1)
	fatal("bad bimod predictor config (<table_size>)");
      if (comb_nelt != 1)
	fatal("bad combining predictor config (<meta_table_size>)");
      if (btb_nelt != 2)
	fatal("bad btb config (<num_sets> <associativity>)");

      pred = bpred_create(BPredComb,
			  /* bimod table size */bimod_config[0],
			  /* l1 size */twolev_config[0],
			  /* l2 size */twolev_config[1],
			  /* meta table size */comb_config[0],
			  /* history reg size */twolev_config[2],
			  /* history xor address */twolev_config[3],
			  /* btb sets */btb_config[0],
			  /* btb assoc */btb_config[1],
			  /* ret-addr stack size */ras_size);
    }
  else
    fatal("cannot parse predictor type `%s'", pred_type);
}
예제 #3
0
static void
sim_check_options(struct opt_odb_t *odb,        /* options database */
		  int argc, char **argv)        /* command line arguments */
{
  char name[128], c;

  if (ruu_ifq_size < 1 || (ruu_ifq_size & (ruu_ifq_size - 1)) != 0)
    fatal("inst fetch queue size must be positive > 0 and a power of two");
  pipe_ibuf_size = ruu_ifq_size;

  fetch_width = ruu_decode_width * fetch_speed;

  //if (ruu_branch_penalty < 1)
   // fatal("mis-prediction penalty must be at least 1 cycle");

  if (!mystricmp(pred_type, "perfect"))
    {
      /* perfect predictor */
      bpred_scheme = NO_BPRED;
    }
#if 0
  else if (!mystricmp(pred_type, "taken"))
    {
      /* static predictor, not taken */
      //pred = bpred_create(BPredTaken, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }
  else if (!mystricmp(pred_type, "nottaken"))
    {
      /* static predictor, taken */
      //pred = bpred_create(BPredNotTaken, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }
#endif
  else if (!mystricmp(pred_type, "bimod"))
    {
      /* bimodal predictor, bpred_create() checks BTB_SIZE */
      if (bimod_nelt != 1)
	fatal("bad bimod predictor config (<table_size>)");
      if (btb_nelt != 2)
	fatal("bad btb config (<num_sets> <associativity>)");

      bpred_scheme = LOCAL;
      BHT_SIZE = btb_config[0];
      BHT = log_base2(BHT_SIZE);
      BHT_MSK = BHT_SIZE - 1;
    }
  else if (!mystricmp(pred_type, "2lev"))
    {
      if (twolev_nelt != 4)
	fatal("bad 2-level pred config (<l1size> <l2size> <hist_size> <xor>)");
      if (btb_nelt != 2)
	fatal("bad btb config (<num_sets> <associativity>)");
      if ((twolev_config[1] & (twolev_config[1] - 1)) != 0)
	fatal("Branch History Table (BHT) size %d is not power of 2!\n", twolev_config[1]);
      if ((twolev_config[2] < 0) || (twolev_config[2] > 4))
	fatal("Branch History Register (BHR) bits %d is not within [0, 4]\n", twolev_config[2]);

      if (twolev_config[2] == 0)
	  bpred_scheme = LOCAL;
      if (twolev_config[3] == FALSE)
	  bpred_scheme = GAG;
      else
	  bpred_scheme = GSHARE;
      BHT_SIZE = twolev_config[1];
      BHT = log_base2(BHT_SIZE);
      BHT_MSK = BHT_SIZE - 1;
      BHR = twolev_config[2];
      BHR_PWR = 1 << BHR;
      BHR_MSK = BHR_PWR - 1;
      
      if ( (1 << BHR) > BHT_SIZE)
	fatal("The combination of Branch History Register (BHR) bits %d and \nBranch History Table size %d is invalid because 2^BHR > BHT \n", BHR, BHT_SIZE);
    }
#if 0
  else if (!mystricmp(pred_type, "comb"))
    {
      /* combining predictor, bpred_create() checks args */
      if (twolev_nelt != 4)
	fatal("bad 2-level pred config (<l1size> <l2size> <hist_size> <xor>)");
      if (bimod_nelt != 1)
	fatal("bad bimod predictor config (<table_size>)");
      if (comb_nelt != 1)
	fatal("bad combining predictor config (<meta_table_size>)");
      if (btb_nelt != 2)
	fatal("bad btb config (<num_sets> <associativity>)");

      pred = bpred_create(BPredComb,
			  /* bimod table size */bimod_config[0],
			  /* l1 size */twolev_config[0],
			  /* l2 size */twolev_config[1],
			  /* meta table size */comb_config[0],
			  /* history reg size */twolev_config[2],
			  /* history xor address */twolev_config[3],
			  /* btb sets */btb_config[0],
			  /* btb assoc */btb_config[1],
			  /* ret-addr stack size */ras_size);
    }
#endif
  else
    fatal("cannot parse predictor type `%s'", pred_type);

#if 0
  if (ruu_decode_width < 1 || (ruu_decode_width & (ruu_decode_width-1)) != 0)
    fatal("issue width must be positive non-zero and a power of two");

  if (ruu_issue_width < 1 || (ruu_issue_width & (ruu_issue_width-1)) != 0)
    fatal("issue width must be positive non-zero and a power of two");

  if (ruu_commit_width < 1)
    fatal("commit width must be positive non-zero");
#endif

  if (RUU_size < 2)
    fatal("Re-order buffer size must be greater than one!");
  pipe_iwin_size = RUU_size;
  PROLOG_SIZE = pipe_iwin_size + pipe_ibuf_size;
  EPILOG_SIZE = pipe_iwin_size * 2;
  LSQ_size = pipe_iwin_size;

#if 0
  if (LSQ_size < 2 || (LSQ_size & (LSQ_size-1)) != 0)
    fatal("LSQ size must be a positive number > 1 and a power of two");
#endif

  /* use a level 1 D-cache? */
  if (!mystricmp(cache_dl1_opt, "none"))
    {
#if 0
      cache_dl1 = NULL;
#endif
      enable_dcache = enable_scp_dcache = 0;  
      /* the level 2 D-cache cannot be defined */
      if (strcmp(cache_dl2_opt, "none"))
	fatal("the l1 data cache must defined if the l2 cache is defined");
#if 0
      cache_dl2 = NULL;
#endif
    }
  else /* dl1 is defined */
    {
      enable_scp_dcache = 1;
      if (sscanf(cache_dl1_opt, "%[^:]:%d:%d:%d:%c",
		 name, &nsets_dl1, &bsize_dl1, &assoc_dl1, &c) != 5)
		fatal("bad l1 D-cache parms: <name>:<nsets>:<bsize>:<assoc>:<repl>");

		/* sudiptac ::: enable level 1 data cache analysis */
		enable_dcache = 1; 	
#if 0
      cache_dl1 = cache_create(name, nsets, bsize, /* balloc */FALSE,
			       /* usize */0, assoc, cache_char2policy(c),
			       dl1_access_fn, /* hit lat */cache_dl1_lat);
#endif
    /* is the level 2 D-cache defined? */
    if (!mystricmp(cache_dl2_opt, "none"))
		  enable_ul2cache = 0;
#if 0
		  cache_dl2 = NULL;
#endif
    else
	 {
	   if (sscanf(cache_dl2_opt, "%[^:]:%d:%d:%d:%c",
		     name, &nsets_dl2, &bsize_dl2, &assoc_dl2, &c) != 5)
	     fatal("bad l2 D-cache parms: "
		  "<name>:<nsets>:<bsize>:<assoc>:<repl>");

	    enable_scp_dl2cache = 1;
	 }
  }