Skip to content

Commit

Permalink
TODOs and gitignore setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenny Witham committed Feb 6, 2017
1 parent a6f12ad commit 3ecc152
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 47 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

.vscode
119 changes: 73 additions & 46 deletions bpred.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ bpred_create(enum bpred_class class, /* type of predictor to create */
pred->dirpred.bimod =
bpred_dir_create(class, bimod_size, 0, 0, 0);

break;

case BPredMine:
pred->dirpred.mine =
bpred_dir_create(class,0,0,0,0);
//TODO: enter correct config info

case BPredTaken:
case BPredNotTaken:
/* no other state */
Expand All @@ -117,6 +124,7 @@ bpred_create(enum bpred_class class, /* type of predictor to create */
panic("bogus predictor class");
}

//TODO: do something here!
/* allocate ret-addr stack */
switch (class) {
case BPredComb:
Expand Down Expand Up @@ -176,6 +184,7 @@ bpred_create(enum bpred_class class, /* type of predictor to create */
return pred;
}

//TODO: add mine here
/* create a branch direction predictor */
struct bpred_dir_t * /* branch direction predictor instance */
bpred_dir_create (
Expand Down Expand Up @@ -225,10 +234,10 @@ bpred_dir_create (
/* initialize counters to weakly this-or-that */
flipflop = 1;
for (cnt = 0; cnt < l2size; cnt++)
{
pred_dir->config.two.l2table[cnt] = flipflop;
flipflop = 3 - flipflop;
}
{
pred_dir->config.two.l2table[cnt] = flipflop;
flipflop = 3 - flipflop;
}

break;
}
Expand All @@ -245,8 +254,8 @@ bpred_dir_create (
flipflop = 1;
for (cnt = 0; cnt < l1size; cnt++)
{
pred_dir->config.bimod.table[cnt] = flipflop;
flipflop = 3 - flipflop;
pred_dir->config.bimod.table[cnt] = flipflop;
flipflop = 3 - flipflop;
}

break;
Expand All @@ -263,6 +272,7 @@ bpred_dir_create (
return pred_dir;
}

//TODO: add case for printing config
/* print branch direction predictor configuration */
void
bpred_dir_config(
Expand Down Expand Up @@ -291,11 +301,15 @@ bpred_dir_config(
fprintf(stream, "pred_dir: %s: predict not taken\n", name);
break;

case BPredMine:
break;

default:
panic("bogus branch direction predictor class");
}
}

//TODO: add case for mine
/* print branch predictor configuration */
void
bpred_config(struct bpred_t *pred, /* branch predictor instance */
Expand Down Expand Up @@ -348,6 +362,7 @@ bpred_stats(struct bpred_t *pred, /* branch predictor instance */
(double)pred->dir_hits/(double)(pred->dir_hits+pred->misses));
}

//TODO: add name for stats Done!
/* register branch predictor stats */
void
bpred_reg_stats(struct bpred_t *pred, /* branch predictor instance */
Expand All @@ -373,6 +388,9 @@ bpred_reg_stats(struct bpred_t *pred, /* branch predictor instance */
case BPredNotTaken:
name = "bpred_nottaken";
break;
case BPredMine:
name = "bpred_mine";
break;
default:
panic("bogus branch predictor class");
}
Expand Down Expand Up @@ -497,13 +515,13 @@ bpred_dir_lookup(struct bpred_dir_t *pred_dir, /* branch dir predictor inst */
/* Except for jumps, get a pointer to direction-prediction bits */
switch (pred_dir->class) {
case BPred2Level:
{
int l1index, l2index;
{
int l1index, l2index;

/* traverse 2-level tables */
l1index = (baddr >> MD_BR_SHIFT) & (pred_dir->config.two.l1size - 1);
l2index = pred_dir->config.two.shiftregs[l1index];
if (pred_dir->config.two.xor)
/* traverse 2-level tables */
l1index = (baddr >> MD_BR_SHIFT) & (pred_dir->config.two.l1size - 1);
l2index = pred_dir->config.two.shiftregs[l1index];
if (pred_dir->config.two.xor)
{
#if 1
/* this L2 index computation is more "compatible" to McFarling's
Expand Down Expand Up @@ -533,6 +551,9 @@ bpred_dir_lookup(struct bpred_dir_t *pred_dir, /* branch dir predictor inst */
case BPred2bit:
p = &pred_dir->config.bimod.table[BIMOD_HASH(pred_dir, baddr)];
break;
case BPredMine:
//TODO: add stuff here
break;
case BPredTaken:
case BPredNotTaken:
break;
Expand Down Expand Up @@ -581,52 +602,56 @@ bpred_lookup(struct bpred_t *pred, /* branch predictor instance */
switch (pred->class) {
case BPredComb:
if ((MD_OP_FLAGS(op) & (F_CTRL|F_UNCOND)) != (F_CTRL|F_UNCOND))
{
char *bimod, *twolev, *meta;
bimod = bpred_dir_lookup (pred->dirpred.bimod, baddr);
twolev = bpred_dir_lookup (pred->dirpred.twolev, baddr);
meta = bpred_dir_lookup (pred->dirpred.meta, baddr);
dir_update_ptr->pmeta = meta;
dir_update_ptr->dir.meta = (*meta >= 2);
dir_update_ptr->dir.bimod = (*bimod >= 2);
dir_update_ptr->dir.twolev = (*twolev >= 2);
if (*meta >= 2)
{
dir_update_ptr->pdir1 = twolev;
dir_update_ptr->pdir2 = bimod;
}
else
{
dir_update_ptr->pdir1 = bimod;
dir_update_ptr->pdir2 = twolev;
}
}
{
char *bimod, *twolev, *meta;
bimod = bpred_dir_lookup (pred->dirpred.bimod, baddr);
twolev = bpred_dir_lookup (pred->dirpred.twolev, baddr);
meta = bpred_dir_lookup (pred->dirpred.meta, baddr);
dir_update_ptr->pmeta = meta;
dir_update_ptr->dir.meta = (*meta >= 2);
dir_update_ptr->dir.bimod = (*bimod >= 2);
dir_update_ptr->dir.twolev = (*twolev >= 2);
if (*meta >= 2)
{
dir_update_ptr->pdir1 = twolev;
dir_update_ptr->pdir2 = bimod;
}
else
{
dir_update_ptr->pdir1 = bimod;
dir_update_ptr->pdir2 = twolev;
}
}
break;
case BPred2Level:
if ((MD_OP_FLAGS(op) & (F_CTRL|F_UNCOND)) != (F_CTRL|F_UNCOND))
{
dir_update_ptr->pdir1 =
bpred_dir_lookup (pred->dirpred.twolev, baddr);
}
{
dir_update_ptr->pdir1 =
bpred_dir_lookup (pred->dirpred.twolev, baddr);
}
break;
case BPred2bit:
if ((MD_OP_FLAGS(op) & (F_CTRL|F_UNCOND)) != (F_CTRL|F_UNCOND))
{
dir_update_ptr->pdir1 =
bpred_dir_lookup (pred->dirpred.bimod, baddr);
}
{
dir_update_ptr->pdir1 =
bpred_dir_lookup (pred->dirpred.bimod, baddr);
}
break;
case BPredTaken:
return btarget;
case BPredNotTaken:
if ((MD_OP_FLAGS(op) & (F_CTRL|F_UNCOND)) != (F_CTRL|F_UNCOND))
{
return baddr + sizeof(md_inst_t);
}
{
return baddr + sizeof(md_inst_t);
}
else
{
return btarget;
}
{
return btarget;
}
break;
case BPredMine:
//TODO: add mine!
break;
default:
panic("bogus predictor class");
}
Expand Down Expand Up @@ -982,4 +1007,6 @@ bpred_update(struct bpred_t *pred, /* branch predictor instance */
pbtb->target = btarget;
}
}

//TODO: add mine maybe
}
4 changes: 3 additions & 1 deletion bpred.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ enum bpred_class {
BPred2bit, /* 2-bit saturating cntr pred (dir mapped) */
BPredTaken, /* static predict taken */
BPredNotTaken, /* static predict not taken */
BPred_NUM
BPred_NUM,
BPredMine
};

/* an entry in a BTB */
Expand Down Expand Up @@ -141,6 +142,7 @@ struct bpred_t {
struct bpred_dir_t *bimod; /* first direction predictor */
struct bpred_dir_t *twolev; /* second direction predictor */
struct bpred_dir_t *meta; /* meta predictor */
struct bpred_dir_t *mine;
} dirpred;

struct {
Expand Down

0 comments on commit 3ecc152

Please sign in to comment.