Skip to content

Commit

Permalink
feat(DPI): support for prefetch user bits (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kumonda221-CrO3 authored Oct 13, 2024
1 parent 05cb43d commit 0ce4f69
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 48 deletions.
12 changes: 12 additions & 0 deletions main/DPI/coupledL2_dpi.svh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ import "DPI-C" function void TileLinkPullChannelA (
output byte size,
output byte source,
output longint address,
output byte user_needHint,
output longint user_vaddr,
output byte user_alias,
output int mask,
output longint data0,
Expand All @@ -102,6 +104,8 @@ function void SvTileLinkPullChannelA (
output logic [2:0] size,
output logic [4:0] source,
output logic [35:0] address,
output logic user_needHint,
output logic [35:0] user_vaddr,
output logic [1:0] user_alias,
output logic [31:0] mask,
output logic [255:0] data,
Expand All @@ -118,6 +122,8 @@ function void SvTileLinkPullChannelA (
size,
source,
address,
user_needHint,
user_vaddr,
user_alias,
mask,
data[63:0],
Expand Down Expand Up @@ -259,6 +265,8 @@ import "DPI-C" function void TileLinkPullChannelC (
output byte size,
output byte source,
output longint address,
output byte user_needHint,
output longint user_vaddr,
output byte user_alias,
output longint data0,
output longint data1,
Expand All @@ -276,6 +284,8 @@ function void SvTileLinkPullChannelC (
output logic [2:0] size,
output logic [4:0] source,
output logic [35:0] address,
output logic user_needHint,
output logic [35:0] user_vaddr,
output logic [1:0] user_alias,
output logic [255:0] data,
output logic corrupt
Expand All @@ -291,6 +301,8 @@ function void SvTileLinkPullChannelC (
size,
source,
address,
user_needHint,
user_vaddr,
user_alias,
data[63:0],
data[127:64],
Expand Down
104 changes: 56 additions & 48 deletions main/DPI/tilelink_dpi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ extern "C" void TileLinkPullChannelA(
uint8_t* size,
uint8_t* source,
uint64_t* address,
uint8_t* user_needHint,
uint64_t* user_vaddr,
uint8_t* user_alias,
uint32_t* mask,
uint64_t* data0,
Expand All @@ -138,47 +140,49 @@ extern "C" void TileLinkPullChannelA(
{
TLSequencer::IOPort& port = passive->IO(deviceId);

*valid = port.a.valid;
*opcode = port.a.opcode;
*param = port.a.param;
*size = port.a.size;
*source = port.a.source;
*address = port.a.address;
*user_alias = port.a.alias;
*mask = port.a.mask;
*data0 = (uint64_t(port.a.data->data[0]))
| (uint64_t(port.a.data->data[1]) << 8)
| (uint64_t(port.a.data->data[2]) << 16)
| (uint64_t(port.a.data->data[3]) << 24)
| (uint64_t(port.a.data->data[4]) << 32)
| (uint64_t(port.a.data->data[5]) << 40)
| (uint64_t(port.a.data->data[6]) << 48)
| (uint64_t(port.a.data->data[7]) << 56);
*data1 = (uint64_t(port.a.data->data[8]))
| (uint64_t(port.a.data->data[9]) << 8)
| (uint64_t(port.a.data->data[10]) << 16)
| (uint64_t(port.a.data->data[11]) << 24)
| (uint64_t(port.a.data->data[12]) << 32)
| (uint64_t(port.a.data->data[13]) << 40)
| (uint64_t(port.a.data->data[14]) << 48)
| (uint64_t(port.a.data->data[15]) << 56);
*data2 = (uint64_t(port.a.data->data[16]))
| (uint64_t(port.a.data->data[17]) << 8)
| (uint64_t(port.a.data->data[18]) << 16)
| (uint64_t(port.a.data->data[19]) << 24)
| (uint64_t(port.a.data->data[20]) << 32)
| (uint64_t(port.a.data->data[21]) << 40)
| (uint64_t(port.a.data->data[22]) << 48)
| (uint64_t(port.a.data->data[23]) << 56);
*data3 = (uint64_t(port.a.data->data[24]))
| (uint64_t(port.a.data->data[25]) << 8)
| (uint64_t(port.a.data->data[26]) << 16)
| (uint64_t(port.a.data->data[27]) << 24)
| (uint64_t(port.a.data->data[28]) << 32)
| (uint64_t(port.a.data->data[29]) << 40)
| (uint64_t(port.a.data->data[30]) << 48)
| (uint64_t(port.a.data->data[31]) << 56);
*corrupt = 0;
*valid = port.a.valid;
*opcode = port.a.opcode;
*param = port.a.param;
*size = port.a.size;
*source = port.a.source;
*address = port.a.address;
*user_needHint = port.a.needHint;
*user_vaddr = port.a.vaddr;
*user_alias = port.a.alias;
*mask = port.a.mask;
*data0 = (uint64_t(port.a.data->data[0]))
| (uint64_t(port.a.data->data[1]) << 8)
| (uint64_t(port.a.data->data[2]) << 16)
| (uint64_t(port.a.data->data[3]) << 24)
| (uint64_t(port.a.data->data[4]) << 32)
| (uint64_t(port.a.data->data[5]) << 40)
| (uint64_t(port.a.data->data[6]) << 48)
| (uint64_t(port.a.data->data[7]) << 56);
*data1 = (uint64_t(port.a.data->data[8]))
| (uint64_t(port.a.data->data[9]) << 8)
| (uint64_t(port.a.data->data[10]) << 16)
| (uint64_t(port.a.data->data[11]) << 24)
| (uint64_t(port.a.data->data[12]) << 32)
| (uint64_t(port.a.data->data[13]) << 40)
| (uint64_t(port.a.data->data[14]) << 48)
| (uint64_t(port.a.data->data[15]) << 56);
*data2 = (uint64_t(port.a.data->data[16]))
| (uint64_t(port.a.data->data[17]) << 8)
| (uint64_t(port.a.data->data[18]) << 16)
| (uint64_t(port.a.data->data[19]) << 24)
| (uint64_t(port.a.data->data[20]) << 32)
| (uint64_t(port.a.data->data[21]) << 40)
| (uint64_t(port.a.data->data[22]) << 48)
| (uint64_t(port.a.data->data[23]) << 56);
*data3 = (uint64_t(port.a.data->data[24]))
| (uint64_t(port.a.data->data[25]) << 8)
| (uint64_t(port.a.data->data[26]) << 16)
| (uint64_t(port.a.data->data[27]) << 24)
| (uint64_t(port.a.data->data[28]) << 32)
| (uint64_t(port.a.data->data[29]) << 40)
| (uint64_t(port.a.data->data[30]) << 48)
| (uint64_t(port.a.data->data[31]) << 56);
*corrupt = 0;
}
//

Expand Down Expand Up @@ -240,6 +244,8 @@ extern "C" void TileLinkPullChannelC(
uint8_t* size,
uint8_t* source,
uint64_t* address,
uint8_t* user_needHint,
uint64_t* user_vaddr,
uint8_t* user_alias,
uint64_t* data0,
uint64_t* data1,
Expand All @@ -248,13 +254,15 @@ extern "C" void TileLinkPullChannelC(
uint8_t* corrupt)
{
TLSequencer::IOPort& port = passive->IO(deviceId);
*valid = port.c.valid;
*opcode = port.c.opcode;
*param = port.c.param;
*size = port.c.size;
*source = port.c.source;
*address = port.c.address;
*user_alias = 0;
*valid = port.c.valid;
*opcode = port.c.opcode;
*param = port.c.param;
*size = port.c.size;
*source = port.c.source;
*address = port.c.address;
*user_needHint = port.c.needHint;
*user_vaddr = port.c.vaddr;
*user_alias = 0;
*data0 = (uint64_t(port.c.data->data[0]))
| (uint64_t(port.c.data->data[1]) << 8)
| (uint64_t(port.c.data->data[2]) << 16)
Expand Down
4 changes: 4 additions & 0 deletions main/DPI/tilelink_dpi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ extern "C" void TileLinkPullChannelA(
uint8_t* size,
uint8_t* source,
uint64_t* address,
uint8_t* user_needHint,
uint64_t* user_vaddr,
uint8_t* user_alias,
uint32_t* mask,
uint64_t* data0,
Expand Down Expand Up @@ -108,6 +110,8 @@ extern "C" void TileLinkPullChannelC(
uint8_t* size,
uint8_t* source,
uint64_t* address,
uint8_t* user_needHint,
uint64_t* user_vaddr,
uint8_t* user_alias,
uint64_t* data0,
uint64_t* data1,
Expand Down
4 changes: 4 additions & 0 deletions main/TLAgent/Bundle.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ namespace tl_agent {
Usr usr;
Echo echo;
uint8_t corrupt;
uint8_t needHint;
paddr_t vaddr;
uint8_t alias;
};

Expand Down Expand Up @@ -65,6 +67,8 @@ namespace tl_agent {
uint8_t dirty;
shared_tldata_t<N> data;
uint8_t corrupt;
uint8_t needHint;
paddr_t vaddr;
uint8_t alias;
};

Expand Down
48 changes: 48 additions & 0 deletions main/TLAgent/CAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
#endif


//
#ifndef CAGENT_TRAIN_PREFETCH_A
# define CAGENT_TRAIN_PREFETCH_A 1
#endif

#ifndef CAGENT_TRAIN_PREFETCH_C
# define CAGENT_TRAIN_PREFETCH_C 1
#endif


namespace tl_agent {

TLPermission capGenPrivByProbe(TLLocalContext* ctx, TLParamProbe param) {
Expand Down Expand Up @@ -186,6 +196,8 @@ namespace tl_agent {
this->port->a.param = a->param;
this->port->a.mask = a->mask;
this->port->a.source = a->source;
this->port->a.needHint = a->needHint;
this->port->a.vaddr = a->vaddr;
this->port->a.alias = a->alias;
this->port->a.valid = true;
return OK;
Expand Down Expand Up @@ -220,6 +232,12 @@ namespace tl_agent {
req_c->source = this->probeIDpool.getid();
req_c->dirty = 1;
req_c->alias = b->alias;
req_c->vaddr = b->address;
#if CAGENT_TRAIN_PREFETCH_C
req_c->needHint = 1;
#else
req_c->needHint = 0;
#endif
// Log("== id == handleB %d\n", *req_c->source);
Log(this, ShowBase().Hex().Append("Accepting over Probe to ProbeAck: ", uint64_t(b->source), " -> ", uint64_t(req_c->source)).EndLine());
if (exact_status[b->alias] == S_SENDING_A || exact_status[b->alias] == S_INVALID || exact_status[b->alias] == S_A_WAITING_D) {
Expand Down Expand Up @@ -969,6 +987,12 @@ namespace tl_agent {
req_a->mask = (0xffffffffUL);
req_a->source = this->idpool.getid();
req_a->alias = alias;
req_a->vaddr = address;
#if CAGENT_TRAIN_PREFETCH_A
req_a->needHint = 1;
#else
req_a->needHint = 0;
#endif
// Log("== id == acquire %d\n", *req_a->source);
pendingA.init(req_a, 1);

Expand Down Expand Up @@ -1033,6 +1057,12 @@ namespace tl_agent {
req_a->mask = (0xffffffffUL);
req_a->source = this->idpool.getid();
req_a->alias = alias;
req_a->vaddr = address;
#if CAGENT_TRAIN_PREFETCH_A
req_a->needHint = 1;
#else
req_a->needHint = 0;
#endif
// Log("== id == acquire %d\n", *req_a->source);
pendingA.init(req_a, 1);

Expand Down Expand Up @@ -1077,6 +1107,12 @@ namespace tl_agent {
// Log("== id == release %d\n", *req_c->source);
req_c->data = data;
req_c->alias = alias;
req_c->vaddr = address;
#if CAGENT_TRAIN_PREFETCH_C
req_c->needHint = 1;
#else
req_c->needHint = 0;
#endif
pendingC.init(req_c, DATASIZE / BEATSIZE);

if (glbl.cfg.verbose_xact_sequenced)
Expand Down Expand Up @@ -1156,6 +1192,12 @@ namespace tl_agent {
req_c->source = this->idpool.getid();
req_c->dirty = 0;
req_c->alias = alias;
req_c->vaddr = address;
#if CAGENT_TRAIN_PREFETCH_C
req_c->needHint = 1;
#else
req_c->needHint = 0;
#endif

# if CAGENT_INCLUSIVE_SYSTEM == 1
{
Expand Down Expand Up @@ -1213,6 +1255,12 @@ namespace tl_agent {
req_c->size = ceil(log2((double)DATASIZE));
req_c->source = this->idpool.getid();
req_c->alias = alias;
req_c->vaddr = address;
#if CAGENT_TRAIN_PREFETCH_C
req_c->needHint = 1;
#else
req_c->needHint = 0;
#endif

bool acquirePermPrev = false;
if (acquirePermBoard->haskey(address))
Expand Down
28 changes: 28 additions & 0 deletions main/TLAgent/ULAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
#include <memory>
#include "ULAgent.h"


//
#ifndef ULAGENT_TRAIN_PREFETCH
# define ULAGENT_TRAIN_PREFETCH 1
#endif


namespace tl_agent {

ULAgent::ULAgent(TLLocalConfig* cfg, GlobalBoard<paddr_t> *gb, UncachedBoard<paddr_t>* ubs, int sysId, unsigned int seed, uint64_t* cycles) noexcept :
Expand Down Expand Up @@ -346,6 +353,12 @@ namespace tl_agent {
req_a->size = ceil(log2((double)DATASIZE));
req_a->mask = 0xffffffffUL;
req_a->source = this->idpool.getid();
req_a->vaddr = address;
#ifdef ULAGENT_TRAIN_PREFETCH
req_a->needHint = 1;
#else
req_a->needHint = 0;
#endif
pendingA.init(req_a, 1);

if (glbl.cfg.verbose_xact_sequenced)
Expand All @@ -370,6 +383,11 @@ namespace tl_agent {
req_a->size = size;
req_a->mask = mask;
req_a->source = this->idpool.getid();
#ifdef ULAGENT_TRAIN_PREFETCH
req_a->needHint = 1;
#else
req_a->needHint = 0;
#endif
pendingA.init(req_a, 1);

if (glbl.cfg.verbose_xact_sequenced)
Expand Down Expand Up @@ -398,6 +416,11 @@ namespace tl_agent {
req_a->mask = 0xffffffffUL;
req_a->source = this->idpool.getid();
req_a->data = data;
#ifdef ULAGENT_TRAIN_PREFETCH
req_a->needHint = 1;
#else
req_a->needHint = 0;
#endif
pendingA.init(req_a, DATASIZE / BEATSIZE);

if (glbl.cfg.verbose_xact_sequenced)
Expand Down Expand Up @@ -426,6 +449,11 @@ namespace tl_agent {
req_a->mask = mask;
req_a->source = this->idpool.getid();
req_a->data = data;
#ifdef ULAGENT_TRAIN_PREFETCH
req_a->needHint = 1;
#else
req_a->needHint = 0;
#endif
int nrBeat = ceil((float)pow(2, size) / (float)BEATSIZE);
pendingA.init(req_a, nrBeat);

Expand Down

0 comments on commit 0ce4f69

Please sign in to comment.