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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_67/] [or1ksim/] [bpb/] [branch_predict.c] - Diff between revs 1344 and 1350

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

Rev 1344 Rev 1350
Line 28... Line 28...
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include <errno.h>
#include <errno.h>
#include <stdarg.h>
#include <stdarg.h>
 
 
 
#include "config.h"
 
 
 
#ifdef HAVE_INTTYPES_H
 
#include <inttypes.h>
 
#endif
 
 
 
#include "port.h"
 
#include "arch.h"
#include "branch_predict.h"
#include "branch_predict.h"
#include "opcode/or32.h"
 
#include "abstract.h"
#include "abstract.h"
 
#include "opcode/or32.h"
#include "stats.h"
#include "stats.h"
#include "sim-config.h"
#include "sim-config.h"
 
 
/* Branch prediction buffer */
/* Branch prediction buffer */
 
 
Line 51... Line 59...
#define BPB_USTATES 2
#define BPB_USTATES 2
 
 
/* branch prediction buffer entry */
/* branch prediction buffer entry */
struct bpb_entry {
struct bpb_entry {
        struct {
        struct {
                unsigned long addr;     /* address of a branch insn */
                oraddr_t addr;          /* address of a branch insn */
                int taken;              /* taken == 1, not taken == 0  OR */
                int taken;              /* taken == 1, not taken == 0  OR */
                                        /* strongly taken == 3, taken == 2,
                                        /* strongly taken == 3, taken == 2,
                                           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];
Line 85... Line 93...
      'taken' field with (BPB_PSTATES/2 - 1) + 'taken'
      'taken' field with (BPB_PSTATES/2 - 1) + 'taken'
    - set 'lru' with BPB_USTATES - 1 and decrement 'lru' of other
    - set 'lru' with BPB_USTATES - 1 and decrement 'lru' of other
      ways unless they have reached 0
      ways unless they have reached 0
*/
*/
 
 
void bpb_update(unsigned long addr, int taken)
void bpb_update(oraddr_t addr, int taken)
{
{
        int entry, way = -1;
        int entry, way = -1;
        int i;
        int i;
 
 
        /* BPB simulation enabled/disabled. */
        /* BPB simulation enabled/disabled. */
Line 157... Line 165...
/* Target block size in bytes. */
/* Target block size in bytes. */
#define BTIC_BLOCKSIZE 4
#define BTIC_BLOCKSIZE 4
 
 
struct btic_entry {
struct btic_entry {
        struct {
        struct {
                unsigned long addr;     /* cached target address of a branch */
                oraddr_t 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];
 
 
Line 186... Line 194...
      'insn' with NULL
      'insn' with NULL
    - set 'lru' with BTIC_USTATES - 1 and decrement 'lru' of other
    - set 'lru' with BTIC_USTATES - 1 and decrement 'lru' of other
      ways unless they have reached 0
      ways unless they have reached 0
*/
*/
 
 
void btic_update(unsigned long targetaddr)
void btic_update(oraddr_t targetaddr)
{
{
        int entry, way = -1;
        int entry, way = -1;
        int i;
        int i;
 
 
        /* BTIC simulation enabled/disabled. */
        /* BTIC simulation enabled/disabled. */

powered by: WebSVN 2.1.0

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