Line 35... |
Line 35... |
#include "stats.h"
|
#include "stats.h"
|
|
|
/* Branch prediction buffer */
|
/* Branch prediction buffer */
|
|
|
/* Length of BPB */
|
/* Length of BPB */
|
#define BPB_LEN 32
|
#define BPB_LEN 128
|
|
|
/* Number of BPB ways (1, 2, 3 etc.). */
|
/* Number of BPB ways (1, 2, 3 etc.). */
|
#define BPB_WAYS 2
|
#define BPB_WAYS 1
|
|
|
/* Number of prediction states (2, 4, 8 etc.). */
|
/* Number of prediction states (2, 4, 8 etc.). */
|
#define BPB_PSTATES 2
|
#define BPB_PSTATES 2
|
|
|
/* Number of usage states (2, 3, 4 etc.). */
|
/* Number of usage states (2, 3, 4 etc.). */
|
Line 57... |
Line 57... |
not taken == 1, strongly not taken == 0 */
|
not taken == 1, strongly not taken == 0 */
|
int lru; /* least recently == 0 */
|
int lru; /* least recently == 0 */
|
} way[BPB_WAYS];
|
} way[BPB_WAYS];
|
} bpb[BPB_LEN];
|
} bpb[BPB_LEN];
|
|
|
|
void bpb_info()
|
|
{
|
|
printf("BPB %d bytes: ", BPB_LEN * BPB_WAYS * (BPB_PSTATES + BPB_USTATES) / 8);
|
|
printf("%d ways, %d sets, %d bits/prediction\n", BPB_WAYS, BPB_LEN, BPB_PSTATES + BPB_USTATES);
|
|
}
|
|
|
/* First check if branch is already in the cache and if it is:
|
/* First check if branch is already in the cache and if it is:
|
- increment BPB hit stats,
|
- increment BPB hit stats,
|
- set 'lru' at this way to BPB_USTATES - 1 and
|
- set 'lru' at this way to BPB_USTATES - 1 and
|
decrement 'lru' of other ways unless they have reached 0,
|
decrement 'lru' of other ways unless they have reached 0,
|
- increment correct/incorrect stats according to BPB 'taken' field
|
- increment correct/incorrect stats according to BPB 'taken' field
|
Line 127... |
Line 133... |
}
|
}
|
|
|
/* Branch target instruction cache */
|
/* Branch target instruction cache */
|
|
|
/* Length of BTIC */
|
/* Length of BTIC */
|
#define BTIC_LEN 32
|
#define BTIC_LEN 128
|
|
|
/* Number of BTIC ways (1, 2, 3 etc.). */
|
/* Number of BTIC ways (1, 2, 3 etc.). */
|
#define BTIC_WAYS 2
|
#define BTIC_WAYS 2
|
|
|
/* Number of usage states (2, 3, 4 etc.). */
|
/* Number of usage states (2, 3, 4 etc.). */
|
#define BTIC_USTATES 2
|
#define BTIC_USTATES 2
|
|
|
|
/* Target block size in bytes. */
|
|
#define BTIC_BLOCKSIZE 4
|
|
|
struct btic_entry {
|
struct btic_entry {
|
struct {
|
struct {
|
unsigned long addr; /* cached target address of a branch */
|
unsigned long addr; /* cached target address of a branch */
|
int lru; /* least recently used */
|
int lru; /* least recently used */
|
char *insn; /* cached insn at target address (not used currently) */
|
char *insn; /* cached insn at target address (not used currently) */
|
} way[BTIC_WAYS];
|
} way[BTIC_WAYS];
|
} btic[BTIC_LEN];
|
} btic[BTIC_LEN];
|
|
|
|
void btic_info()
|
|
{
|
|
printf("BTIC %d bytes: ", BTIC_LEN * BTIC_WAYS * (BTIC_USTATES + BTIC_BLOCKSIZE * 8) / 8);
|
|
printf("%d ways, %d sets, %d bits/target\n", BTIC_WAYS, BTIC_LEN, BTIC_USTATES + BTIC_BLOCKSIZE * 8);
|
|
}
|
|
|
/* First check if target addr is already in the cache and if it is:
|
/* First check if target addr is already in the cache and if it is:
|
- increment BTIC hit stats,
|
- increment BTIC hit stats,
|
- set 'lru' at this way to BTIC_USTATES - 1 and
|
- set 'lru' at this way to BTIC_USTATES - 1 and
|
decrement 'lru' of other ways unless they have reached 0,
|
decrement 'lru' of other ways unless they have reached 0,
|
and if not:
|
and if not:
|