<commit_before>
#include "Vpfmonitor_wp.h"
#include "verilated.h"
#include "verilated_vcd_c.h"


//#include "DOLC.h"

#include <list>
#include <vector>

#include <time.h>

#define DEBUG_TRACE 1
//#define GENERATED_PREFETCH 1
#define VTAGE_TABLE 6
#define VTAGE_TABLE_ENTRIES 512
#define BIMODAL_TABLE_ENTRIES 512

vluint64_t global_time = 0;
VerilatedVcdC* tfp = 0;

void advance_half_clock(Vpfmonitor_wp *top) {
#ifdef TRACE
  tfp->dump(global_time);
#endif

  top->eval();
  top->clk = !top->clk;
  top->eval();

  global_time++;
  if (Verilated::gotFinish())  
    exit(0);
}

void advance_clock(Vpfmonitor_wp *top, int nclocks=1) {

  for( int i=0;i<nclocks;i++) {
    for (int clk=0; clk<2; clk++) {
      advance_half_clock(top);
    }
  }
}

void sim_finish(bool pass) {
#ifdef TRACE
  tfp->close();
#endif

  if (pass)
    printf("\nTB:PASS\n");
  else
    printf("\nTB:FAILED\n");

  exit(0);
}

struct InputPacket_coretopfm_dec {
  uint64_t  coretopfm_dec_pcsign; 
  uint16_t  coretopfm_dec_rid; 
  uint8_t   coretopfm_dec_decmask;  
};

struct InputPacket_coretopfm_retire {
  uint8_t  coretopfm_retire_pfentry;

  uint16_t coretopfm_retire_d0_rid;   
  uint8_t  coretopfm_retire_d0_val;
  uint16_t coretopfm_retire_d1_rid;
  uint8_t  coretopfm_retire_d1_val;

  uint16_t coretopfm_retire_d2_rid;
  uint8_t  coretopfm_retire_d2_val;
  uint16_t coretopfm_retire_d3_rid;
  uint8_t  coretopfm_retire_d3_val;
};

struct OutputPacket_pfmtocore {
  uint8_t  pfmtocore_pfentry;

  uint16_t pfmtocore_d0_rid;
  uint8_t  pfmtocore_d0_val;
  uint8_t  pfmtocore_d0_w;
  uint16_t pfmtocore_d1_rid;
  uint8_t  pfmtocore_d1_val;
  uint8_t  pfmtocore_d1_w;

  uint16_t pfmtocore_d2_rid;
  uint8_t  pfmtocore_d2_val;
  uint8_t  pfmtocore_d2_w;
  uint16_t pfmtocore_d3_rid;
  uint8_t  pfmtocore_d3_val;
  uint8_t  pfmtocore_d3_w;
};

struct pc_circular_buffer {
  uint64_t  cir_buffer_pcsign_idx0;
  uint64_t  cir_buffer_pcsign_idx1;
  uint64_t  cir_buffer_pcsign_idx2;
  uint64_t  cir_buffer_pcsign_idx3;
  uint8_t  cir_buffer_decmask;
};

struct vtage_components {
  uint16_t delta[VTAGE_TABLE_ENTRIES];
  uint16_t weight[VTAGE_TABLE_ENTRIES]; 
  uint16_t offset[VTAGE_TABLE_ENTRIES];
  uint8_t  sat_ctr[VTAGE_TABLE_ENTRIES];
  uint8_t  u[VTAGE_TABLE_ENTRIES];
  uint64_t tag[VTAGE_TABLE_ENTRIES];
};

double sc_time_stamp() {
  return 0;
}

uint16_t memory[256];
uint64_t key;
uint8_t doUpdate;       //flag for VTAGE update on miss
uint8_t misPredUpdate;  //flag for VTAGE update on misprediction
DOLC dolc(12,2,4,8);               //historySize = 12         //init DOLC pc based history
std::vector<uint64_t> l1_generated_prefetch;  //L1 can have max of 4 pretfetch generations
std::vector<uint64_t> l2_generated_prefetch;

std::list<InputPacket_coretopfm_dec>  inp_list_dec;
std::list<InputPacket_coretopfm_retire>  inp_list_retire;
std::list<OutputPacket_pfmtocore> out_list;


vtage_components bimodalTable;
vtage_components tables[VTAGE_TABLE];

uint64_t *histLength;
uint64_t *taggedTable_TagMask;
uint64_t *taggedTable_IdxMask;


void initialize_tables() {<commit_msg>fixed pfmonitor_wp_tb so testbench runs<commit_after>
#include "Vpfmonitor_wp.h"
#include "verilated.h"
#include "verilated_vcd_c.h"


//#include "DOLC.h"

#include <list>
#include <vector>

#include <time.h>

#define DEBUG_TRACE 1
//#define GENERATED_PREFETCH 1
#define VTAGE_TABLE 6
#define VTAGE_TABLE_ENTRIES 512
#define BIMODAL_TABLE_ENTRIES 512

vluint64_t global_time = 0;
VerilatedVcdC* tfp = 0;

void advance_half_clock(Vpfmonitor_wp *top) {
#ifdef TRACE
  tfp->dump(global_time);
#endif

  top->eval();
  top->clk = !top->clk;
  top->eval();

  global_time++;
  if (Verilated::gotFinish())  
    exit(0);
}

void advance_clock(Vpfmonitor_wp *top, int nclocks=1) {

  for( int i=0;i<nclocks;i++) {
    for (int clk=0; clk<2; clk++) {
      advance_half_clock(top);
    }
  }
}

void sim_finish(bool pass) {
#ifdef TRACE
  tfp->close();
#endif

  if (pass)
    printf("\nTB:PASS\n");
  else
    printf("\nTB:FAILED\n");

  exit(0);
}

struct InputPacket_coretopfm_dec {
  uint64_t  coretopfm_dec_pcsign; 
  uint16_t  coretopfm_dec_rid; 
  uint8_t   coretopfm_dec_decmask;  
};

struct InputPacket_coretopfm_retire {
  uint8_t  coretopfm_retire_pfentry;

  uint16_t coretopfm_retire_d0_rid;   
  uint8_t  coretopfm_retire_d0_val;
  uint16_t coretopfm_retire_d1_rid;
  uint8_t  coretopfm_retire_d1_val;

  uint16_t coretopfm_retire_d2_rid;
  uint8_t  coretopfm_retire_d2_val;
  uint16_t coretopfm_retire_d3_rid;
  uint8_t  coretopfm_retire_d3_val;
};

struct OutputPacket_pfmtocore {
  uint8_t  pfmtocore_pfentry;

  uint16_t pfmtocore_d0_rid;
  uint8_t  pfmtocore_d0_val;
  uint8_t  pfmtocore_d0_w;
  uint16_t pfmtocore_d1_rid;
  uint8_t  pfmtocore_d1_val;
  uint8_t  pfmtocore_d1_w;

  uint16_t pfmtocore_d2_rid;
  uint8_t  pfmtocore_d2_val;
  uint8_t  pfmtocore_d2_w;
  uint16_t pfmtocore_d3_rid;
  uint8_t  pfmtocore_d3_val;
  uint8_t  pfmtocore_d3_w;
};

struct pc_circular_buffer {
  uint64_t  cir_buffer_pcsign_idx0;
  uint64_t  cir_buffer_pcsign_idx1;
  uint64_t  cir_buffer_pcsign_idx2;
  uint64_t  cir_buffer_pcsign_idx3;
  uint8_t  cir_buffer_decmask;
};

struct vtage_components {
  uint16_t delta[VTAGE_TABLE_ENTRIES];
  uint16_t weight[VTAGE_TABLE_ENTRIES]; 
  uint16_t offset[VTAGE_TABLE_ENTRIES];
  uint8_t  sat_ctr[VTAGE_TABLE_ENTRIES];
  uint8_t  u[VTAGE_TABLE_ENTRIES];
  uint64_t tag[VTAGE_TABLE_ENTRIES];
};

double sc_time_stamp() {
  return 0;
}

uint16_t memory[256];
uint64_t key;
uint8_t doUpdate;       //flag for VTAGE update on miss
uint8_t misPredUpdate;  //flag for VTAGE update on misprediction
//DOLC dolc(12,2,4,8);               //historySize = 12         //init DOLC pc based history
std::vector<uint64_t> l1_generated_prefetch;  //L1 can have max of 4 pretfetch generations
std::vector<uint64_t> l2_generated_prefetch;

std::list<InputPacket_coretopfm_dec>  inp_list_dec;
std::list<InputPacket_coretopfm_retire>  inp_list_retire;
std::list<OutputPacket_pfmtocore> out_list;


vtage_components bimodalTable;
vtage_components tables[VTAGE_TABLE];

uint64_t *histLength;
uint64_t *taggedTable_TagMask;
uint64_t *taggedTable_IdxMask;


void initialize_tables() {
{'fraction_non_alphanumeric': 0.08940719144800778, 'fraction_numerical': 0.04146420472951085, 'mean_word_length': 5.132075471698113, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5777679', 'n_tokens_mistral': 2851, 'n_tokens_neox': 2702, 'n_words': 450}