Skip to content

Commit

Permalink
Align cache subsystem to updated ace dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
ricted98 committed Nov 21, 2024
1 parent 125c68e commit 730dc95
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 63 deletions.
18 changes: 9 additions & 9 deletions core/cache_subsystem/axi_adapter.sv
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module axi_adapter #(
output logic busy_o,
input logic req_i,
input ariane_pkg::ad_req_t type_i,
input ace_pkg::ace_trs_t trans_type_i,
input std_cache_pkg::ace_trs_t trans_type_i,
input ariane_pkg::amo_t amo_i,
output logic gnt_o,
input logic [riscv::XLEN-1:0] addr_i,
Expand Down Expand Up @@ -520,42 +520,42 @@ module axi_adapter #(

case (trans_type_i)

ace_pkg::READ_SHARED: begin
std_cache_pkg::READ_SHARED: begin
axi_req_o.ar.domain = 2'b01;
axi_req_o.ar.snoop = 4'b0001;
end

ace_pkg::READ_ONCE: begin
std_cache_pkg::READ_ONCE: begin
axi_req_o.ar.domain = 2'b01;
axi_req_o.ar.snoop = 4'b0000;
end

ace_pkg::READ_UNIQUE: begin
std_cache_pkg::READ_UNIQUE: begin
axi_req_o.ar.domain = 2'b01;
axi_req_o.ar.snoop = 4'b0111;
end

ace_pkg::READ_NO_SNOOP: begin
std_cache_pkg::READ_NO_SNOOP: begin
axi_req_o.ar.domain = 2'b00;
axi_req_o.ar.snoop = 4'b0000;
end

ace_pkg::CLEAN_UNIQUE: begin
std_cache_pkg::CLEAN_UNIQUE: begin
axi_req_o.ar.domain = 2'b01;
axi_req_o.ar.snoop = 4'b1011;
end

ace_pkg::WRITE_UNIQUE: begin
std_cache_pkg::WRITE_UNIQUE: begin
axi_req_o.aw.domain = 2'b01;
axi_req_o.aw.snoop = 3'b000;
end

ace_pkg::WRITE_NO_SNOOP: begin
std_cache_pkg::WRITE_NO_SNOOP: begin
axi_req_o.aw.domain = 2'b00;
axi_req_o.aw.snoop = 3'b000;
end

ace_pkg::WRITE_BACK: begin
std_cache_pkg::WRITE_BACK: begin
axi_req_o.aw.domain = 2'b00;
axi_req_o.aw.snoop = 3'b011;
end
Expand Down
38 changes: 19 additions & 19 deletions core/cache_subsystem/miss_handler.sv
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ module miss_handler
CHECK_BEFORE_CLEAN, // F
SEND_CLEAN, // 10
REQ_CACHELINE_UNIQUE // 11
}
}
state_d, state_q;

// Registers
Expand Down Expand Up @@ -149,7 +149,7 @@ module miss_handler
logic [ (DCACHE_LINE_WIDTH/8)-1:0] req_fsm_miss_be;
ariane_pkg::ad_req_t req_fsm_miss_req;
logic [ 1:0] req_fsm_miss_size;
ace_pkg::ace_trs_t req_fsm_miss_type;
std_cache_pkg::ace_trs_t req_fsm_miss_type;

logic gnt_miss_fsm;
logic valid_miss_fsm;
Expand Down Expand Up @@ -216,7 +216,7 @@ module miss_handler
req_fsm_miss_be = '0;
req_fsm_miss_req = ariane_pkg::CACHE_LINE_REQ;
req_fsm_miss_size = 2'b11;
req_fsm_miss_type = ace_pkg::READ_SHARED;
req_fsm_miss_type = std_cache_pkg::READ_SHARED;
// to AXI bypass
amo_bypass_req.req = 1'b0;
amo_bypass_req.reqtype = ariane_pkg::SINGLE_REQ;
Expand Down Expand Up @@ -343,13 +343,13 @@ module miss_handler
req_fsm_miss_addr = mshr_q.addr;
if (state_q == REQ_CACHELINE_UNIQUE) begin
// start a ReadUnique request, the requested adress was cleared by snoop
req_fsm_miss_type = ace_pkg::READ_UNIQUE;
req_fsm_miss_type = std_cache_pkg::READ_UNIQUE;
end else begin
case ({mshr_q.we, is_inside_shareable_regions(CVA6Cfg, mshr_q.addr)})
2'b00: req_fsm_miss_type = ace_pkg::READ_NO_SNOOP;
2'b01: req_fsm_miss_type = ace_pkg::READ_SHARED;
2'b10: req_fsm_miss_type = ace_pkg::READ_NO_SNOOP;
2'b11: req_fsm_miss_type = ace_pkg::READ_UNIQUE;
2'b00: req_fsm_miss_type = std_cache_pkg::READ_NO_SNOOP;
2'b01: req_fsm_miss_type = std_cache_pkg::READ_SHARED;
2'b10: req_fsm_miss_type = std_cache_pkg::READ_NO_SNOOP;
2'b11: req_fsm_miss_type = std_cache_pkg::READ_UNIQUE;
endcase
end
if (gnt_miss_fsm) begin
Expand Down Expand Up @@ -424,7 +424,7 @@ module miss_handler
req_fsm_miss_be = evict_cl_q.dirty;
req_fsm_miss_we = 1'b1;
req_fsm_miss_wdata = evict_cl_q.data;
req_fsm_miss_type = ace_pkg::WRITE_BACK;
req_fsm_miss_type = std_cache_pkg::WRITE_BACK;
flushing_o = state_q == WB_CACHELINE_FLUSH;

// we've got a grant --> this is timing critical, think about it
Expand Down Expand Up @@ -511,7 +511,7 @@ module miss_handler
if (matching_way) begin
req_fsm_miss_valid = 1'b1;
req_fsm_miss_addr = mshr_q.addr;
req_fsm_miss_type = ace_pkg::CLEAN_UNIQUE;
req_fsm_miss_type = std_cache_pkg::CLEAN_UNIQUE;
state_d = SEND_CLEAN;
end
else begin
Expand All @@ -525,7 +525,7 @@ module miss_handler
SEND_CLEAN: begin
req_fsm_miss_valid = 1'b1;
req_fsm_miss_addr = mshr_q.addr;
req_fsm_miss_type = ace_pkg::CLEAN_UNIQUE;
req_fsm_miss_type = std_cache_pkg::CLEAN_UNIQUE;

if (valid_miss_fsm) begin
// if the cacheline has just been invalidated, request it again
Expand Down Expand Up @@ -699,15 +699,15 @@ module miss_handler

if (miss_req_we[id]) begin
if (is_inside_shareable_regions(CVA6Cfg, miss_req_addr[id])) begin
bypass_ports_req[id].acetype = ace_pkg::WRITE_UNIQUE;
bypass_ports_req[id].acetype = std_cache_pkg::WRITE_UNIQUE;
end else begin
bypass_ports_req[id].acetype = ace_pkg::WRITE_NO_SNOOP;
bypass_ports_req[id].acetype = std_cache_pkg::WRITE_NO_SNOOP;
end
end else begin
if (is_inside_shareable_regions(CVA6Cfg, miss_req_addr[id])) begin
bypass_ports_req[id].acetype = ace_pkg::READ_ONCE;
bypass_ports_req[id].acetype = std_cache_pkg::READ_ONCE;
end else begin
bypass_ports_req[id].acetype = ace_pkg::READ_NO_SNOOP;
bypass_ports_req[id].acetype = std_cache_pkg::READ_NO_SNOOP;
end
end

Expand All @@ -721,15 +721,15 @@ module miss_handler
bypass_ports_req[id].id = 4'b1000 + id;
if (amo_bypass_req.we) begin
if (is_inside_shareable_regions(CVA6Cfg, amo_bypass_req.addr)) begin
bypass_ports_req[id].acetype = ace_pkg::WRITE_UNIQUE;
bypass_ports_req[id].acetype = std_cache_pkg::WRITE_UNIQUE;
end else begin
bypass_ports_req[id].acetype = ace_pkg::WRITE_NO_SNOOP;
bypass_ports_req[id].acetype = std_cache_pkg::WRITE_NO_SNOOP;
end
end else begin
if (is_inside_shareable_regions(CVA6Cfg, amo_bypass_req.addr)) begin
bypass_ports_req[id].acetype = ace_pkg::READ_ONCE;
bypass_ports_req[id].acetype = std_cache_pkg::READ_ONCE;
end else begin
bypass_ports_req[id].acetype = ace_pkg::READ_NO_SNOOP;
bypass_ports_req[id].acetype = std_cache_pkg::READ_NO_SNOOP;
end
end
amo_bypass_rsp = bypass_ports_rsp[id];
Expand Down
24 changes: 12 additions & 12 deletions core/cache_subsystem/snoop_cache_ctrl.sv
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ module snoop_cache_ctrl import ariane_pkg::*; import std_cache_pkg::*; (

assign shared = |(shared_way_i & hit_way_i);

snoop_pkg::crresp_t cr_resp_d, cr_resp_q;
ace_pkg::crresp_t cr_resp_d, cr_resp_q;

snoop_pkg::acsnoop_t ac_snoop_d, ac_snoop_q;
ace_pkg::acsnoop_t ac_snoop_d, ac_snoop_q;

logic cr_done_q, cr_done_d;

Expand Down Expand Up @@ -156,10 +156,10 @@ module snoop_cache_ctrl import ariane_pkg::*; import std_cache_pkg::*; (
end
else begin
// invalidate request
if (snoop_port_i.ac.snoop == snoop_pkg::CLEAN_INVALID ||
snoop_port_i.ac.snoop == snoop_pkg::READ_SHARED ||
snoop_port_i.ac.snoop == snoop_pkg::READ_ONCE ||
snoop_port_i.ac.snoop == snoop_pkg::READ_UNIQUE) begin
if (snoop_port_i.ac.snoop == ace_pkg::CleanInvalid ||
snoop_port_i.ac.snoop == ace_pkg::ReadShared ||
snoop_port_i.ac.snoop == ace_pkg::ReadOnce ||
snoop_port_i.ac.snoop == ace_pkg::ReadUnique) begin
state_d = WAIT_GNT;
ac_snoop_d = snoop_port_i.ac.snoop;
// request the cache line (unless there is another cache controller which is uploading the cache content)
Expand Down Expand Up @@ -195,7 +195,7 @@ module snoop_cache_ctrl import ariane_pkg::*; import std_cache_pkg::*; (
cr_resp_d.passDirty = 1'b0; //dirty;
cache_data_d = cl_i;
case (ac_snoop_q)
snoop_pkg::CLEAN_INVALID: begin
ace_pkg::CleanInvalid: begin
cr_resp_d.dataTransfer = dirty;
cr_resp_d.passDirty = dirty;
cr_resp_d.isShared = 1'b0;
Expand All @@ -208,12 +208,12 @@ module snoop_cache_ctrl import ariane_pkg::*; import std_cache_pkg::*; (
state_d = INVALIDATE;
end
end
snoop_pkg::READ_ONCE: begin
ace_pkg::ReadOnce: begin
cr_resp_d.isShared = shared;
send_snoop_resp = 1'b1;
state_d = snoop_port_done ? IDLE : WAIT_SNOOP_PORT;
end
snoop_pkg::READ_SHARED: begin
ace_pkg::ReadShared: begin
cr_resp_d.isShared = 1'b1;
update_shared = 1'b1;
if (gnt_i) begin
Expand All @@ -225,11 +225,11 @@ module snoop_cache_ctrl import ariane_pkg::*; import std_cache_pkg::*; (
state_d = UPDATE_SHARED;
end
end
default : begin // snoop_pkg::READ_UNIQUE
default : begin // ace_pkg::ReadUnique
cr_resp_d.passDirty = dirty;
cr_resp_d.isShared = 1'b0;
state_d = INVALIDATE;
assert (ac_snoop_q == snoop_pkg::READ_UNIQUE) else
assert (ac_snoop_q == ace_pkg::ReadUnique) else
$error("Unexpected snoop type");
end
endcase
Expand All @@ -241,7 +241,7 @@ module snoop_cache_ctrl import ariane_pkg::*; import std_cache_pkg::*; (
cr_resp_d.isShared = 1'b0;
send_snoop_resp = 1'b1;
state_d = snoop_port_done ? IDLE : WAIT_SNOOP_PORT;
clean_invalid_miss_o = (ac_snoop_q == snoop_pkg::CLEAN_INVALID);
clean_invalid_miss_o = (ac_snoop_q == ace_pkg::CleanInvalid);
end
end

Expand Down
42 changes: 21 additions & 21 deletions core/include/ariane_ace_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,27 @@ package ariane_ace;
axi_pkg::atop_t atop;
ariane_axi_user_t user;
ace_pkg::awsnoop_t snoop;
ace_pkg::bar_t bar;
ace_pkg::domain_t domain;
ace_pkg::axbar_t bar;
ace_pkg::axdomain_t domain;
ace_pkg::awunique_t awunique;
} aw_chan_t;

// AR Channel
typedef struct packed {
ariane_axi_id_t id;
ariane_axi_addr_t addr;
axi_pkg::len_t len;
axi_pkg::size_t size;
axi_pkg::burst_t burst;
logic lock;
axi_pkg::cache_t cache;
axi_pkg::prot_t prot;
axi_pkg::qos_t qos;
axi_pkg::region_t region;
ariane_axi_user_t user;
ace_pkg::arsnoop_t snoop;
ace_pkg::bar_t bar;
ace_pkg::domain_t domain;
ariane_axi_id_t id;
ariane_axi_addr_t addr;
axi_pkg::len_t len;
axi_pkg::size_t size;
axi_pkg::burst_t burst;
logic lock;
axi_pkg::cache_t cache;
axi_pkg::prot_t prot;
axi_pkg::qos_t qos;
axi_pkg::region_t region;
ariane_axi_user_t user;
ace_pkg::arsnoop_t snoop;
ace_pkg::axbar_t bar;
ace_pkg::axdomain_t domain;
} ar_chan_t;

// R Channel
Expand All @@ -80,9 +80,9 @@ package ariane_ace;

// AC Channel
typedef struct packed {
ariane_axi_addr_t addr;
snoop_pkg::acsnoop_t snoop;
snoop_pkg::acprot_t prot;
ariane_axi_addr_t addr;
ace_pkg::acsnoop_t snoop;
ace_pkg::acprot_t prot;
} ac_chan_t;

// CD Cannel
Expand All @@ -109,7 +109,7 @@ package ariane_ace;
// Snoop signals are reversed w.r.t. request / response
logic ac_ready;
logic cr_valid;
snoop_pkg::crresp_t cr_resp;
ace_pkg::crresp_t cr_resp;
logic cd_valid;
cd_chan_t cd;
} req_t;
Expand Down Expand Up @@ -162,7 +162,7 @@ package ariane_ace;
typedef struct packed {
logic ac_ready;
logic cr_valid;
snoop_pkg::crresp_t cr_resp;
ace_pkg::crresp_t cr_resp;
logic cd_valid;
cd_chan_t cd;
} snoop_resp_t;
Expand Down
15 changes: 13 additions & 2 deletions core/include/std_cache_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,21 @@ package std_cache_pkg;
logic make_unique;
} miss_req_t;

typedef enum logic[2:0] {
READ_NO_SNOOP,
READ_ONCE,
READ_SHARED,
READ_UNIQUE,
CLEAN_UNIQUE,
WRITE_NO_SNOOP,
WRITE_BACK,
WRITE_UNIQUE
} ace_trs_t;

typedef struct packed {
logic req;
ariane_pkg::ad_req_t reqtype;
ace_pkg::ace_trs_t acetype;
ace_trs_t acetype;
ariane_pkg::amo_t amo;
logic [3:0] id;
logic [63:0] addr;
Expand Down Expand Up @@ -89,7 +100,7 @@ package std_cache_pkg;
logic valid;
logic [63:0] addr;
} readshared_done_t;

// convert one hot to bin for -> needed for cache replacement
function automatic logic [DCACHE_SET_ASSOC_WIDTH-1:0] one_hot_to_bin(
input logic [ariane_pkg::DCACHE_SET_ASSOC-1:0] in);
Expand Down

0 comments on commit 730dc95

Please sign in to comment.