mirror of
https://github.com/openhwgroup/cva6.git
synced 2025-04-20 04:07:36 -04:00
hpdcache: update HPDcache to support parametrization (#2059)
This commit is contained in:
parent
4c58b50045
commit
cd241cb387
7 changed files with 172 additions and 233 deletions
7
Makefile
7
Makefile
|
@ -110,12 +110,6 @@ endif
|
|||
HPDCACHE_DIR ?= $(CVA6_REPO_DIR)/core/cache_subsystem/hpdcache
|
||||
export HPDCACHE_DIR
|
||||
|
||||
# Target HPDcache configuration package.
|
||||
# The HPDCACHE_TARGET_CFG variable contains the path (relative or absolute)
|
||||
# to your target configuration package
|
||||
HPDCACHE_TARGET_CFG ?= ${CVA6_REPO_DIR}/core/include/cva6_hpdcache_default_config_pkg.sv
|
||||
export HPDCACHE_TARGET_CFG
|
||||
|
||||
# Sources
|
||||
# Package files -> compile first
|
||||
ariane_pkg := \
|
||||
|
@ -692,7 +686,6 @@ check-torture:
|
|||
src_flist = $(shell \
|
||||
CVA6_REPO_DIR=$(CVA6_REPO_DIR) \
|
||||
TARGET_CFG=$(TARGET_CFG) \
|
||||
HPDCACHE_TARGET_CFG=$(HPDCACHE_TARGET_CFG) \
|
||||
HPDCACHE_DIR=$(HPDCACHE_DIR) \
|
||||
python3 util/flist_flattener.py core/Flist.cva6)
|
||||
fpga_filter := $(addprefix $(root-dir), corev_apu/bootrom/bootrom.sv)
|
||||
|
|
|
@ -159,7 +159,6 @@ ${CVA6_REPO_DIR}/core/cache_subsystem/cache_ctrl.sv
|
|||
${CVA6_REPO_DIR}/core/cache_subsystem/cva6_icache_axi_wrapper.sv
|
||||
${CVA6_REPO_DIR}/core/cache_subsystem/std_cache_subsystem.sv
|
||||
${CVA6_REPO_DIR}/core/cache_subsystem/std_nbdcache.sv
|
||||
${HPDCACHE_TARGET_CFG}
|
||||
-F ${HPDCACHE_DIR}/rtl/hpdcache.Flist
|
||||
${HPDCACHE_DIR}/rtl/src/utils/hpdcache_mem_req_read_arbiter.sv
|
||||
${HPDCACHE_DIR}/rtl/src/utils/hpdcache_mem_req_write_arbiter.sv
|
||||
|
|
|
@ -10,15 +10,19 @@
|
|||
// Date: February, 2023
|
||||
// Description: Interface adapter for the CVA6 core
|
||||
module cva6_hpdcache_if_adapter
|
||||
import hpdcache_pkg::*;
|
||||
|
||||
// Parameters
|
||||
// {{{
|
||||
#(
|
||||
parameter config_pkg::cva6_cfg_t CVA6Cfg = config_pkg::cva6_cfg_empty,
|
||||
parameter type dcache_req_i_t = logic,
|
||||
parameter type dcache_req_o_t = logic,
|
||||
parameter bit is_load_port = 1'b1
|
||||
parameter config_pkg::cva6_cfg_t CVA6Cfg = config_pkg::cva6_cfg_empty,
|
||||
parameter hpdcache_pkg::hpdcache_cfg_t hpdcacheCfg = '0,
|
||||
parameter type hpdcache_tag_t = logic,
|
||||
parameter type hpdcache_req_offset_t = logic,
|
||||
parameter type hpdcache_req_sid_t = logic,
|
||||
parameter type hpdcache_req_t = logic,
|
||||
parameter type hpdcache_rsp_t = logic,
|
||||
parameter type dcache_req_i_t = logic,
|
||||
parameter type dcache_req_o_t = logic,
|
||||
parameter bit is_load_port = 1'b1
|
||||
)
|
||||
// }}}
|
||||
|
||||
|
@ -30,7 +34,7 @@ module cva6_hpdcache_if_adapter
|
|||
input logic rst_ni,
|
||||
|
||||
// Port ID
|
||||
input hpdcache_pkg::hpdcache_req_sid_t hpdcache_req_sid_i,
|
||||
input hpdcache_req_sid_t hpdcache_req_sid_i,
|
||||
|
||||
// Request/response ports from/to the CVA6 core
|
||||
input dcache_req_i_t cva6_req_i,
|
||||
|
@ -41,14 +45,14 @@ module cva6_hpdcache_if_adapter
|
|||
// Request port to the L1 Dcache
|
||||
output logic hpdcache_req_valid_o,
|
||||
input logic hpdcache_req_ready_i,
|
||||
output hpdcache_pkg::hpdcache_req_t hpdcache_req_o,
|
||||
output hpdcache_req_t hpdcache_req_o,
|
||||
output logic hpdcache_req_abort_o,
|
||||
output hpdcache_pkg::hpdcache_tag_t hpdcache_req_tag_o,
|
||||
output hpdcache_tag_t hpdcache_req_tag_o,
|
||||
output hpdcache_pkg::hpdcache_pma_t hpdcache_req_pma_o,
|
||||
|
||||
// Response port from the L1 Dcache
|
||||
input logic hpdcache_rsp_valid_i,
|
||||
input hpdcache_pkg::hpdcache_rsp_t hpdcache_rsp_i
|
||||
input logic hpdcache_rsp_valid_i,
|
||||
input hpdcache_rsp_t hpdcache_rsp_i
|
||||
);
|
||||
// }}}
|
||||
|
||||
|
@ -102,35 +106,35 @@ module cva6_hpdcache_if_adapter
|
|||
// {{{
|
||||
else begin : store_amo_gen
|
||||
// STORE/AMO request
|
||||
hpdcache_req_addr_t amo_addr;
|
||||
hpdcache_req_offset_t amo_addr_offset;
|
||||
hpdcache_tag_t amo_tag;
|
||||
logic [63:0] amo_addr;
|
||||
hpdcache_req_offset_t amo_addr_offset;
|
||||
hpdcache_tag_t amo_tag;
|
||||
logic amo_is_word, amo_is_word_hi;
|
||||
logic [63:0] amo_data;
|
||||
logic [ 7:0] amo_data_be;
|
||||
hpdcache_req_op_t amo_op;
|
||||
logic [31:0] amo_resp_word;
|
||||
logic amo_pending_q;
|
||||
logic [63:0] amo_data;
|
||||
logic [ 7:0] amo_data_be;
|
||||
hpdcache_pkg::hpdcache_req_op_t amo_op;
|
||||
logic [31:0] amo_resp_word;
|
||||
logic amo_pending_q;
|
||||
|
||||
// AMO logic
|
||||
// {{{
|
||||
always_comb begin : amo_op_comb
|
||||
amo_addr = cva6_amo_req_i.operand_a;
|
||||
amo_addr_offset = amo_addr[0+:HPDCACHE_REQ_OFFSET_WIDTH];
|
||||
amo_tag = amo_addr[HPDCACHE_REQ_OFFSET_WIDTH+:HPDCACHE_TAG_WIDTH];
|
||||
amo_addr_offset = amo_addr[0+:hpdcacheCfg.reqOffsetWidth];
|
||||
amo_tag = amo_addr[hpdcacheCfg.reqOffsetWidth+:hpdcacheCfg.tagWidth];
|
||||
unique case (cva6_amo_req_i.amo_op)
|
||||
ariane_pkg::AMO_LR: amo_op = HPDCACHE_REQ_AMO_LR;
|
||||
ariane_pkg::AMO_SC: amo_op = HPDCACHE_REQ_AMO_SC;
|
||||
ariane_pkg::AMO_SWAP: amo_op = HPDCACHE_REQ_AMO_SWAP;
|
||||
ariane_pkg::AMO_ADD: amo_op = HPDCACHE_REQ_AMO_ADD;
|
||||
ariane_pkg::AMO_AND: amo_op = HPDCACHE_REQ_AMO_AND;
|
||||
ariane_pkg::AMO_OR: amo_op = HPDCACHE_REQ_AMO_OR;
|
||||
ariane_pkg::AMO_XOR: amo_op = HPDCACHE_REQ_AMO_XOR;
|
||||
ariane_pkg::AMO_MAX: amo_op = HPDCACHE_REQ_AMO_MAX;
|
||||
ariane_pkg::AMO_MAXU: amo_op = HPDCACHE_REQ_AMO_MAXU;
|
||||
ariane_pkg::AMO_MIN: amo_op = HPDCACHE_REQ_AMO_MIN;
|
||||
ariane_pkg::AMO_MINU: amo_op = HPDCACHE_REQ_AMO_MINU;
|
||||
default: amo_op = HPDCACHE_REQ_LOAD;
|
||||
ariane_pkg::AMO_LR: amo_op = hpdcache_pkg::HPDCACHE_REQ_AMO_LR;
|
||||
ariane_pkg::AMO_SC: amo_op = hpdcache_pkg::HPDCACHE_REQ_AMO_SC;
|
||||
ariane_pkg::AMO_SWAP: amo_op = hpdcache_pkg::HPDCACHE_REQ_AMO_SWAP;
|
||||
ariane_pkg::AMO_ADD: amo_op = hpdcache_pkg::HPDCACHE_REQ_AMO_ADD;
|
||||
ariane_pkg::AMO_AND: amo_op = hpdcache_pkg::HPDCACHE_REQ_AMO_AND;
|
||||
ariane_pkg::AMO_OR: amo_op = hpdcache_pkg::HPDCACHE_REQ_AMO_OR;
|
||||
ariane_pkg::AMO_XOR: amo_op = hpdcache_pkg::HPDCACHE_REQ_AMO_XOR;
|
||||
ariane_pkg::AMO_MAX: amo_op = hpdcache_pkg::HPDCACHE_REQ_AMO_MAX;
|
||||
ariane_pkg::AMO_MAXU: amo_op = hpdcache_pkg::HPDCACHE_REQ_AMO_MAXU;
|
||||
ariane_pkg::AMO_MIN: amo_op = hpdcache_pkg::HPDCACHE_REQ_AMO_MIN;
|
||||
ariane_pkg::AMO_MINU: amo_op = hpdcache_pkg::HPDCACHE_REQ_AMO_MINU;
|
||||
default: amo_op = hpdcache_pkg::HPDCACHE_REQ_LOAD;
|
||||
endcase
|
||||
end
|
||||
// }}}
|
||||
|
|
|
@ -129,6 +129,14 @@ module cva6_hpdcache_subsystem
|
|||
);
|
||||
// }}}
|
||||
|
||||
function int unsigned __minu(int unsigned x, int unsigned y);
|
||||
return x < y ? x : y;
|
||||
endfunction
|
||||
|
||||
function int unsigned __maxu(int unsigned x, int unsigned y);
|
||||
return y < x ? x : y;
|
||||
endfunction
|
||||
|
||||
// I$ instantiation
|
||||
// {{{
|
||||
logic icache_miss_valid, icache_miss_ready;
|
||||
|
@ -181,31 +189,78 @@ module cva6_hpdcache_subsystem
|
|||
// NumPorts + 1: Hardware Memory Prefetcher (hwpf)
|
||||
localparam int HPDCACHE_NREQUESTERS = NumPorts + 2;
|
||||
|
||||
typedef logic [CVA6Cfg.PLEN-1:0] hpdcache_mem_addr_t;
|
||||
typedef logic [CVA6Cfg.MEM_TID_WIDTH-1:0] hpdcache_mem_id_t;
|
||||
typedef logic [CVA6Cfg.AxiDataWidth-1:0] hpdcache_mem_data_t;
|
||||
typedef logic [CVA6Cfg.AxiDataWidth/8-1:0] hpdcache_mem_be_t;
|
||||
localparam hpdcache_pkg::hpdcache_user_cfg_t hpdcacheUserCfg = '{
|
||||
nRequesters: HPDCACHE_NREQUESTERS,
|
||||
paWidth: CVA6Cfg.PLEN,
|
||||
wordWidth: CVA6Cfg.XLEN,
|
||||
sets: CVA6Cfg.DCACHE_NUM_WORDS,
|
||||
ways: CVA6Cfg.DCACHE_SET_ASSOC,
|
||||
clWords: CVA6Cfg.DCACHE_LINE_WIDTH / CVA6Cfg.XLEN,
|
||||
reqWords: 1,
|
||||
reqTransIdWidth: CVA6Cfg.DcacheIdWidth,
|
||||
reqSrcIdWidth: 3, // Up to 8 requesters
|
||||
victimSel: hpdcache_pkg::HPDCACHE_VICTIM_RANDOM,
|
||||
dataWaysPerRamWord: __minu(CVA6Cfg.DCACHE_SET_ASSOC, 128 / CVA6Cfg.XLEN),
|
||||
dataSetsPerRam: CVA6Cfg.DCACHE_NUM_WORDS,
|
||||
dataRamByteEnable: 1'b1,
|
||||
accessWords: __maxu(CVA6Cfg.DCACHE_LINE_WIDTH / (2 * CVA6Cfg.XLEN), 1),
|
||||
mshrSets: CVA6Cfg.NrLoadBufEntries < 16 ? 1 : CVA6Cfg.NrLoadBufEntries / 2,
|
||||
mshrWays: CVA6Cfg.NrLoadBufEntries < 16 ? CVA6Cfg.NrLoadBufEntries : 2,
|
||||
mshrWaysPerRamWord: CVA6Cfg.NrLoadBufEntries < 16 ? CVA6Cfg.NrLoadBufEntries : 2,
|
||||
mshrSetsPerRam: CVA6Cfg.NrLoadBufEntries < 16 ? 1 : CVA6Cfg.NrLoadBufEntries / 2,
|
||||
mshrRamByteEnable: 1'b1,
|
||||
mshrUseRegbank: (CVA6Cfg.NrLoadBufEntries < 16),
|
||||
refillCoreRspFeedthrough: 1'b1,
|
||||
refillFifoDepth: 2,
|
||||
wbufDirEntries: CVA6Cfg.WtDcacheWbufDepth,
|
||||
wbufDataEntries: CVA6Cfg.WtDcacheWbufDepth,
|
||||
wbufWords: 1,
|
||||
wbufTimecntWidth: 3,
|
||||
wbufSendFeedThrough: 1'b0,
|
||||
rtabEntries: 4,
|
||||
memAddrWidth: CVA6Cfg.AxiAddrWidth,
|
||||
memIdWidth: CVA6Cfg.MEM_TID_WIDTH,
|
||||
memDataWidth: CVA6Cfg.AxiDataWidth
|
||||
};
|
||||
|
||||
localparam hpdcache_pkg::hpdcache_cfg_t hpdcacheCfg = hpdcache_pkg::hpdcacheBuildConfig(
|
||||
hpdcacheUserCfg
|
||||
);
|
||||
|
||||
`HPDCACHE_TYPEDEF_MEM_ATTR_T(hpdcache_mem_addr_t, hpdcache_mem_id_t, hpdcache_mem_data_t,
|
||||
hpdcache_mem_be_t, hpdcacheCfg);
|
||||
`HPDCACHE_TYPEDEF_MEM_REQ_T(hpdcache_mem_req_t, hpdcache_mem_addr_t, hpdcache_mem_id_t);
|
||||
`HPDCACHE_TYPEDEF_MEM_RESP_R_T(hpdcache_mem_resp_r_t, hpdcache_mem_id_t, hpdcache_mem_data_t);
|
||||
`HPDCACHE_TYPEDEF_MEM_REQ_W_T(hpdcache_mem_req_w_t, hpdcache_mem_data_t, hpdcache_mem_be_t);
|
||||
`HPDCACHE_TYPEDEF_MEM_RESP_W_T(hpdcache_mem_resp_w_t, hpdcache_mem_id_t);
|
||||
|
||||
`HPDCACHE_TYPEDEF_REQ_ATTR_T(hpdcache_req_offset_t, hpdcache_data_word_t, hpdcache_data_be_t,
|
||||
hpdcache_req_data_t, hpdcache_req_be_t, hpdcache_req_sid_t,
|
||||
hpdcache_req_tid_t, hpdcache_tag_t, hpdcacheCfg);
|
||||
`HPDCACHE_TYPEDEF_REQ_T(hpdcache_req_t, hpdcache_req_offset_t, hpdcache_req_data_t,
|
||||
hpdcache_req_be_t, hpdcache_req_sid_t, hpdcache_req_tid_t,
|
||||
hpdcache_tag_t);
|
||||
`HPDCACHE_TYPEDEF_RSP_T(hpdcache_rsp_t, hpdcache_req_data_t, hpdcache_req_sid_t,
|
||||
hpdcache_req_tid_t);
|
||||
|
||||
typedef logic [hpdcacheCfg.u.wbufTimecntWidth-1:0] hpdcache_wbuf_timecnt_t;
|
||||
|
||||
typedef logic [63:0] hwpf_stride_param_t;
|
||||
|
||||
logic dcache_req_valid[HPDCACHE_NREQUESTERS-1:0];
|
||||
logic dcache_req_ready[HPDCACHE_NREQUESTERS-1:0];
|
||||
hpdcache_pkg::hpdcache_req_t dcache_req [HPDCACHE_NREQUESTERS-1:0];
|
||||
hpdcache_req_t dcache_req [HPDCACHE_NREQUESTERS-1:0];
|
||||
logic dcache_req_abort[HPDCACHE_NREQUESTERS-1:0];
|
||||
hpdcache_pkg::hpdcache_tag_t dcache_req_tag [HPDCACHE_NREQUESTERS-1:0];
|
||||
hpdcache_tag_t dcache_req_tag [HPDCACHE_NREQUESTERS-1:0];
|
||||
hpdcache_pkg::hpdcache_pma_t dcache_req_pma [HPDCACHE_NREQUESTERS-1:0];
|
||||
logic dcache_rsp_valid[HPDCACHE_NREQUESTERS-1:0];
|
||||
hpdcache_pkg::hpdcache_rsp_t dcache_rsp [HPDCACHE_NREQUESTERS-1:0];
|
||||
hpdcache_rsp_t dcache_rsp [HPDCACHE_NREQUESTERS-1:0];
|
||||
logic dcache_read_miss, dcache_write_miss;
|
||||
|
||||
logic [ 2:0] snoop_valid;
|
||||
logic [ 2:0] snoop_abort;
|
||||
hpdcache_pkg::hpdcache_req_offset_t [ 2:0] snoop_addr_offset;
|
||||
hpdcache_pkg::hpdcache_tag_t [ 2:0] snoop_addr_tag;
|
||||
hpdcache_req_offset_t [ 2:0] snoop_addr_offset;
|
||||
hpdcache_tag_t [ 2:0] snoop_addr_tag;
|
||||
logic [ 2:0] snoop_phys_indexed;
|
||||
|
||||
logic dcache_cmo_req_is_prefetch;
|
||||
|
@ -256,19 +311,25 @@ module cva6_hpdcache_subsystem
|
|||
generate
|
||||
dcache_req_i_t dcache_req_ports[HPDCACHE_NREQUESTERS-1:0];
|
||||
|
||||
for (genvar r = 0; r < (NumPorts - 1); r++) begin : cva6_hpdcache_load_if_adapter_gen
|
||||
for (genvar r = 0; r < (NumPorts - 1); r++) begin : gen_cva6_hpdcache_load_if_adapter
|
||||
assign dcache_req_ports[r] = dcache_req_ports_i[r];
|
||||
|
||||
cva6_hpdcache_if_adapter #(
|
||||
.CVA6Cfg (CVA6Cfg),
|
||||
.dcache_req_i_t(dcache_req_i_t),
|
||||
.dcache_req_o_t(dcache_req_o_t),
|
||||
.is_load_port (1'b1)
|
||||
.CVA6Cfg (CVA6Cfg),
|
||||
.hpdcacheCfg (hpdcacheCfg),
|
||||
.hpdcache_tag_t (hpdcache_tag_t),
|
||||
.hpdcache_req_offset_t(hpdcache_req_offset_t),
|
||||
.hpdcache_req_sid_t (hpdcache_req_sid_t),
|
||||
.hpdcache_req_t (hpdcache_req_t),
|
||||
.hpdcache_rsp_t (hpdcache_rsp_t),
|
||||
.dcache_req_i_t (dcache_req_i_t),
|
||||
.dcache_req_o_t (dcache_req_o_t),
|
||||
.is_load_port (1'b1)
|
||||
) i_cva6_hpdcache_load_if_adapter (
|
||||
.clk_i,
|
||||
.rst_ni,
|
||||
|
||||
.hpdcache_req_sid_i(hpdcache_pkg::hpdcache_req_sid_t'(r)),
|
||||
.hpdcache_req_sid_i(hpdcache_req_sid_t'(r)),
|
||||
|
||||
.cva6_req_i (dcache_req_ports[r]),
|
||||
.cva6_req_o (dcache_req_ports_o[r]),
|
||||
|
@ -288,15 +349,21 @@ module cva6_hpdcache_subsystem
|
|||
end
|
||||
|
||||
cva6_hpdcache_if_adapter #(
|
||||
.CVA6Cfg (CVA6Cfg),
|
||||
.dcache_req_i_t(dcache_req_i_t),
|
||||
.dcache_req_o_t(dcache_req_o_t),
|
||||
.is_load_port (1'b0)
|
||||
.CVA6Cfg (CVA6Cfg),
|
||||
.hpdcacheCfg (hpdcacheCfg),
|
||||
.hpdcache_tag_t (hpdcache_tag_t),
|
||||
.hpdcache_req_offset_t(hpdcache_req_offset_t),
|
||||
.hpdcache_req_sid_t (hpdcache_req_sid_t),
|
||||
.hpdcache_req_t (hpdcache_req_t),
|
||||
.hpdcache_rsp_t (hpdcache_rsp_t),
|
||||
.dcache_req_i_t (dcache_req_i_t),
|
||||
.dcache_req_o_t (dcache_req_o_t),
|
||||
.is_load_port (1'b0)
|
||||
) i_cva6_hpdcache_store_if_adapter (
|
||||
.clk_i,
|
||||
.rst_ni,
|
||||
|
||||
.hpdcache_req_sid_i(hpdcache_pkg::hpdcache_req_sid_t'(NumPorts - 1)),
|
||||
.hpdcache_req_sid_i(hpdcache_req_sid_t'(NumPorts - 1)),
|
||||
|
||||
.cva6_req_i (dcache_req_ports_i[NumPorts-1]),
|
||||
.cva6_req_o (dcache_req_ports_o[NumPorts-1]),
|
||||
|
@ -322,7 +389,7 @@ module cva6_hpdcache_subsystem
|
|||
.clk_i,
|
||||
.rst_ni,
|
||||
|
||||
.dcache_req_sid_i(hpdcache_pkg::hpdcache_req_sid_t'(NumPorts)),
|
||||
.dcache_req_sid_i(hpdcache_req_sid_t'(NumPorts)),
|
||||
|
||||
.cva6_cmo_req_i (dcache_cmo_req_i),
|
||||
.cva6_cmo_resp_o(dcache_cmo_resp_o),
|
||||
|
@ -381,15 +448,24 @@ module cva6_hpdcache_subsystem
|
|||
`endif
|
||||
|
||||
generate
|
||||
for (genvar h = 0; h < NrHwPrefetchers; h++) begin : hwpf_throttle_gen
|
||||
for (genvar h = 0; h < NrHwPrefetchers; h++) begin : gen_hwpf_throttle
|
||||
assign hwpf_throttle_in[h] = hwpf_stride_pkg::hwpf_stride_throttle_t'(hwpf_throttle_i[h]),
|
||||
hwpf_throttle_o[h] = hwpf_stride_pkg::hwpf_stride_param_t'(hwpf_throttle_out[h]);
|
||||
end
|
||||
endgenerate
|
||||
|
||||
hwpf_stride_wrapper #(
|
||||
.NUM_HW_PREFETCH(NrHwPrefetchers),
|
||||
.NUM_SNOOP_PORTS(3)
|
||||
.hpdcacheCfg (hpdcacheCfg),
|
||||
.NUM_HW_PREFETCH (NrHwPrefetchers),
|
||||
.NUM_SNOOP_PORTS (3),
|
||||
.hpdcache_tag_t (hpdcache_tag_t),
|
||||
.hpdcache_req_offset_t(hpdcache_req_offset_t),
|
||||
.hpdcache_req_data_t (hpdcache_req_data_t),
|
||||
.hpdcache_req_be_t (hpdcache_req_be_t),
|
||||
.hpdcache_req_sid_t (hpdcache_req_sid_t),
|
||||
.hpdcache_req_tid_t (hpdcache_req_tid_t),
|
||||
.hpdcache_req_t (hpdcache_req_t),
|
||||
.hpdcache_rsp_t (hpdcache_rsp_t)
|
||||
) i_hwpf_stride_wrapper (
|
||||
.clk_i,
|
||||
.rst_ni,
|
||||
|
@ -411,7 +487,7 @@ module cva6_hpdcache_subsystem
|
|||
.snoop_addr_tag_i (snoop_addr_tag),
|
||||
.snoop_phys_indexed_i(snoop_phys_indexed),
|
||||
|
||||
.hpdcache_req_sid_i(hpdcache_pkg::hpdcache_req_sid_t'(NumPorts + 1)),
|
||||
.hpdcache_req_sid_i(hpdcache_req_sid_t'(NumPorts + 1)),
|
||||
|
||||
.hpdcache_req_valid_o(dcache_req_valid[NumPorts+1]),
|
||||
.hpdcache_req_ready_i(dcache_req_ready[NumPorts+1]),
|
||||
|
@ -424,10 +500,26 @@ module cva6_hpdcache_subsystem
|
|||
);
|
||||
|
||||
hpdcache #(
|
||||
.NREQUESTERS (HPDCACHE_NREQUESTERS),
|
||||
.HPDcacheMemAddrWidth(CVA6Cfg.PLEN),
|
||||
.HPDcacheMemIdWidth (CVA6Cfg.MEM_TID_WIDTH),
|
||||
.HPDcacheMemDataWidth(CVA6Cfg.AxiDataWidth)
|
||||
.hpdcacheCfg (hpdcacheCfg),
|
||||
.wbuf_timecnt_t (hpdcache_wbuf_timecnt_t),
|
||||
.hpdcache_tag_t (hpdcache_tag_t),
|
||||
.hpdcache_data_word_t (hpdcache_data_word_t),
|
||||
.hpdcache_data_be_t (hpdcache_data_be_t),
|
||||
.hpdcache_req_offset_t(hpdcache_req_offset_t),
|
||||
.hpdcache_req_data_t (hpdcache_req_data_t),
|
||||
.hpdcache_req_be_t (hpdcache_req_be_t),
|
||||
.hpdcache_req_sid_t (hpdcache_req_sid_t),
|
||||
.hpdcache_req_tid_t (hpdcache_req_tid_t),
|
||||
.hpdcache_req_t (hpdcache_req_t),
|
||||
.hpdcache_rsp_t (hpdcache_rsp_t),
|
||||
.hpdcache_mem_addr_t (hpdcache_mem_addr_t),
|
||||
.hpdcache_mem_id_t (hpdcache_mem_id_t),
|
||||
.hpdcache_mem_data_t (hpdcache_mem_data_t),
|
||||
.hpdcache_mem_be_t (hpdcache_mem_be_t),
|
||||
.hpdcache_mem_req_t (hpdcache_mem_req_t),
|
||||
.hpdcache_mem_req_w_t (hpdcache_mem_req_w_t),
|
||||
.hpdcache_mem_resp_r_t(hpdcache_mem_resp_r_t),
|
||||
.hpdcache_mem_resp_w_t(hpdcache_mem_resp_w_t)
|
||||
) i_hpdcache (
|
||||
.clk_i,
|
||||
.rst_ni,
|
||||
|
@ -499,7 +591,7 @@ module cva6_hpdcache_subsystem
|
|||
.wbuf_empty_o(wbuffer_empty_o),
|
||||
|
||||
.cfg_enable_i (dcache_enable_i),
|
||||
.cfg_wbuf_threshold_i (4'd2),
|
||||
.cfg_wbuf_threshold_i (3'd2),
|
||||
.cfg_wbuf_reset_timecnt_on_write_i (1'b1),
|
||||
.cfg_wbuf_sequential_waw_i (1'b0),
|
||||
.cfg_wbuf_inhibit_write_coalescing_i(1'b0),
|
||||
|
@ -521,6 +613,7 @@ module cva6_hpdcache_subsystem
|
|||
// {{{
|
||||
cva6_hpdcache_subsystem_axi_arbiter #(
|
||||
.CVA6Cfg (CVA6Cfg),
|
||||
.hpdcache_mem_id_t (hpdcache_mem_id_t),
|
||||
.hpdcache_mem_req_t (hpdcache_mem_req_t),
|
||||
.hpdcache_mem_req_w_t (hpdcache_mem_req_w_t),
|
||||
.hpdcache_mem_resp_r_t(hpdcache_mem_resp_r_t),
|
||||
|
@ -601,9 +694,16 @@ module cva6_hpdcache_subsystem
|
|||
// Assertions
|
||||
// {{{
|
||||
// pragma translate_off
|
||||
initial
|
||||
assert (hpdcache_pkg::HPDCACHE_REQ_SRC_ID_WIDTH >= $clog2(HPDCACHE_NREQUESTERS))
|
||||
initial begin : initial_assertions
|
||||
assert (hpdcacheCfg.u.reqSrcIdWidth >= $clog2(HPDCACHE_NREQUESTERS))
|
||||
else $fatal(1, "HPDCACHE_REQ_SRC_ID_WIDTH is not wide enough");
|
||||
assert (CVA6Cfg.MEM_TID_WIDTH <= CVA6Cfg.AxiIdWidth)
|
||||
else $fatal(1, "MEM_TID_WIDTH shall be less or equal to the AxiIdWidth");
|
||||
assert (CVA6Cfg.MEM_TID_WIDTH >= ($clog2(hpdcacheCfg.u.mshrSets * hpdcacheCfg.u.mshrWays) + 1))
|
||||
else $fatal(1, "MEM_TID_WIDTH shall allow to uniquely identify all D$ and I$ miss requests ");
|
||||
assert (CVA6Cfg.MEM_TID_WIDTH >= ($clog2(hpdcacheCfg.u.wbufDirEntries) + 1))
|
||||
else $fatal(1, "MEM_TID_WIDTH shall allow to uniquely identify all D$ write requests ");
|
||||
end
|
||||
|
||||
a_invalid_instruction_fetch :
|
||||
assert property (
|
||||
|
|
|
@ -17,6 +17,7 @@ module cva6_hpdcache_subsystem_axi_arbiter
|
|||
// {{{
|
||||
#(
|
||||
parameter config_pkg::cva6_cfg_t CVA6Cfg = config_pkg::cva6_cfg_empty,
|
||||
parameter type hpdcache_mem_id_t = logic,
|
||||
parameter type hpdcache_mem_req_t = logic,
|
||||
parameter type hpdcache_mem_req_w_t = logic,
|
||||
parameter type hpdcache_mem_resp_r_t = logic,
|
||||
|
@ -34,9 +35,7 @@ module cva6_hpdcache_subsystem_axi_arbiter
|
|||
parameter type axi_b_chan_t = logic,
|
||||
parameter type axi_r_chan_t = logic,
|
||||
parameter type axi_req_t = logic,
|
||||
parameter type axi_rsp_t = logic,
|
||||
|
||||
localparam type hpdcache_mem_id_t = logic [CVA6Cfg.MEM_TID_WIDTH-1:0]
|
||||
parameter type axi_rsp_t = logic
|
||||
)
|
||||
// }}}
|
||||
|
||||
|
@ -548,18 +547,6 @@ module cva6_hpdcache_subsystem_axi_arbiter
|
|||
initial
|
||||
assert (CVA6Cfg.MEM_TID_WIDTH <= AxiIdWidth)
|
||||
else $fatal("MEM_TID_WIDTH shall be less or equal to AxiIdWidth");
|
||||
initial
|
||||
assert (CVA6Cfg.MEM_TID_WIDTH >= (hpdcache_pkg::HPDCACHE_MSHR_SET_WIDTH + hpdcache_pkg::HPDCACHE_MSHR_WAY_WIDTH + 1))
|
||||
else
|
||||
$fatal(
|
||||
"MEM_TID_WIDTH shall be wide enough to identify all pending HPDcache misses and Icache misses"
|
||||
);
|
||||
initial
|
||||
assert (CVA6Cfg.MEM_TID_WIDTH >= (hpdcache_pkg::HPDCACHE_WBUF_DIR_PTR_WIDTH + 1))
|
||||
else
|
||||
$fatal(
|
||||
"MEM_TID_WIDTH shall be wide enough to identify all pending HPDcache cacheable writes and uncacheable writes"
|
||||
);
|
||||
initial
|
||||
assert (CVA6Cfg.AxiDataWidth <= CVA6Cfg.ICACHE_LINE_WIDTH)
|
||||
else $fatal("AxiDataWidth shall be less or equal to the width of a Icache line");
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit c9956896659489c23dd6d85ce692ab940c74a7e2
|
||||
Subproject commit 57c82d3d2f3c8dcf604b4841d6d7269a682d6462
|
|
@ -1,144 +0,0 @@
|
|||
// Copyright 2023 Commissariat a l'Energie Atomique et aux Energies
|
||||
// Alternatives (CEA)
|
||||
//
|
||||
// Licensed under the Solderpad Hardware License, Version 2.1 (the “License”);
|
||||
// you may not use this file except in compliance with the License.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1
|
||||
// You may obtain a copy of the License at https://solderpad.org/licenses/
|
||||
//
|
||||
// Authors: Cesar Fuguet
|
||||
// Date: February, 2023
|
||||
// Description:
|
||||
// Default package with parameters for the HPDcache in a CVA6 platform.
|
||||
// Users can copy this file, rename it, and adapt the configuration values as
|
||||
// needed.
|
||||
|
||||
package hpdcache_params_pkg;
|
||||
// Imports from the CVA6 configuration package
|
||||
// {{{
|
||||
import cva6_config_pkg::CVA6ConfigXlen;
|
||||
import cva6_config_pkg::CVA6ConfigDcacheByteSize;
|
||||
import cva6_config_pkg::CVA6ConfigDcacheSetAssoc;
|
||||
import cva6_config_pkg::CVA6ConfigDcacheLineWidth;
|
||||
import cva6_config_pkg::CVA6ConfigDcacheIdWidth;
|
||||
import cva6_config_pkg::CVA6ConfigWtDcacheWbufDepth;
|
||||
import cva6_config_pkg::CVA6ConfigNrLoadBufEntries;
|
||||
// }}}
|
||||
|
||||
// Definition of constants and functions used only in this file
|
||||
// {{{
|
||||
localparam int unsigned __BYTES_PER_WAY = CVA6ConfigDcacheByteSize / CVA6ConfigDcacheSetAssoc;
|
||||
localparam int unsigned __BYTES_PER_CACHELINE = CVA6ConfigDcacheLineWidth / 8;
|
||||
localparam int unsigned __MAX_RAM_WORD_BITS = 128;
|
||||
|
||||
function int unsigned __minu(int unsigned x, int unsigned y);
|
||||
return x < y ? x : y;
|
||||
endfunction
|
||||
|
||||
function int unsigned __maxu(int unsigned x, int unsigned y);
|
||||
return y < x ? x : y;
|
||||
endfunction
|
||||
// }}}
|
||||
|
||||
// Definition of global constants for the HPDcache data and directory
|
||||
// {{{
|
||||
// HPDcache physical address width (in bits)
|
||||
localparam int unsigned PARAM_PA_WIDTH = riscv::PLEN;
|
||||
|
||||
// HPDcache number of sets
|
||||
localparam int unsigned PARAM_SETS = __BYTES_PER_WAY / __BYTES_PER_CACHELINE;
|
||||
|
||||
// HPDcache number of ways
|
||||
localparam int unsigned PARAM_WAYS = CVA6ConfigDcacheSetAssoc;
|
||||
|
||||
// HPDcache word width (bits)
|
||||
localparam int unsigned PARAM_WORD_WIDTH = CVA6ConfigXlen;
|
||||
|
||||
// HPDcache cache-line width (bits)
|
||||
localparam int unsigned PARAM_CL_WORDS = CVA6ConfigDcacheLineWidth / PARAM_WORD_WIDTH;
|
||||
|
||||
// HPDcache number of words in the request data channels (request and response)
|
||||
localparam int unsigned PARAM_REQ_WORDS = 1;
|
||||
|
||||
// HPDcache request transaction ID width (bits)
|
||||
localparam int unsigned PARAM_REQ_TRANS_ID_WIDTH = CVA6ConfigDcacheIdWidth;
|
||||
|
||||
// HPDcache request source ID width (bits)
|
||||
localparam int unsigned PARAM_REQ_SRC_ID_WIDTH = 3;
|
||||
|
||||
// HPDcache victim selection policy
|
||||
// 0: (Pseudo) RANDOM
|
||||
// 1: (Pseudo) LRU
|
||||
localparam int unsigned PARAM_VICTIM_SEL = 0;
|
||||
// }}}
|
||||
|
||||
// Definition of constants and types for HPDcache data memory
|
||||
// {{{
|
||||
localparam int unsigned PARAM_DATA_WAYS_PER_RAM_WORD = __minu(
|
||||
__MAX_RAM_WORD_BITS / PARAM_WORD_WIDTH, PARAM_WAYS
|
||||
);
|
||||
|
||||
localparam int unsigned PARAM_DATA_SETS_PER_RAM = PARAM_SETS;
|
||||
|
||||
// HPDcache DATA RAM macros whether implements:
|
||||
// - Write byte enable (1'b1)
|
||||
// - Write bit mask (1'b0)
|
||||
localparam bit PARAM_DATA_RAM_WBYTEENABLE = 1'b1;
|
||||
|
||||
// Define the number of memory contiguous words that can be accessed
|
||||
// simultaneously from the cache.
|
||||
// - This limits the maximum width for the data channel from requesters
|
||||
// - This impacts the refill latency (more ACCESS_WORDS -> less REFILL LATENCY)
|
||||
localparam int unsigned PARAM_ACCESS_WORDS = PARAM_CL_WORDS / 2;
|
||||
// }}}
|
||||
|
||||
// Definition of constants and types for the Miss Status Holding Register (MSHR)
|
||||
// {{{
|
||||
// HPDcache MSHR number of sets
|
||||
localparam int unsigned PARAM_MSHR_SETS = 1;
|
||||
|
||||
// HPDcache MSHR number of ways
|
||||
localparam int unsigned PARAM_MSHR_WAYS = CVA6ConfigNrLoadBufEntries;
|
||||
|
||||
// HPDcache MSHR number of ways in the same SRAM word
|
||||
localparam int unsigned PARAM_MSHR_WAYS_PER_RAM_WORD = (PARAM_MSHR_WAYS > 1) ? 2 : 1;
|
||||
|
||||
// HPDcache MSHR number of sets in the same SRAM
|
||||
localparam int unsigned PARAM_MSHR_SETS_PER_RAM = PARAM_MSHR_SETS;
|
||||
|
||||
// HPDcache MSHR RAM whether implements:
|
||||
// - Write byte enable (1'b1)
|
||||
// - Write bit mask (1'b0)
|
||||
localparam bit PARAM_MSHR_RAM_WBYTEENABLE = 1'b1;
|
||||
|
||||
// HPDcache MSHR whether uses FFs or SRAM
|
||||
localparam bit PARAM_MSHR_USE_REGBANK = (PARAM_MSHR_SETS * PARAM_MSHR_WAYS) <= 16;
|
||||
|
||||
// HPDcache feedthrough FIFOs from the refill handler to the core
|
||||
localparam bit PARAM_REFILL_CORE_RSP_FEEDTHROUGH = 1'b1;
|
||||
|
||||
// HPDcache depth of the refill FIFO
|
||||
localparam int PARAM_REFILL_FIFO_DEPTH = 32'd2;
|
||||
// }}}
|
||||
|
||||
// Definition of constants and types for the Write Buffer (WBUF)
|
||||
// {{{
|
||||
// HPDcache Write-Buffer number of entries in the directory
|
||||
localparam int unsigned PARAM_WBUF_DIR_ENTRIES = CVA6ConfigWtDcacheWbufDepth;
|
||||
|
||||
// HPDcache Write-Buffer number of entries in the data buffer
|
||||
localparam int unsigned PARAM_WBUF_DATA_ENTRIES = CVA6ConfigWtDcacheWbufDepth;
|
||||
|
||||
// HPDcache Write-Buffer number of words per entry
|
||||
localparam int unsigned PARAM_WBUF_WORDS = PARAM_REQ_WORDS;
|
||||
|
||||
// HPDcache Write-Buffer threshold counter width (in bits)
|
||||
localparam int unsigned PARAM_WBUF_TIMECNT_WIDTH = 3;
|
||||
localparam bit PARAM_WBUF_SEND_FEEDTHROUGH = 1'b0;
|
||||
// }}}
|
||||
|
||||
// Definition of constants and types for the Replay Table (RTAB)
|
||||
// {{{
|
||||
localparam int PARAM_RTAB_ENTRIES = 4;
|
||||
// }}}
|
||||
endpackage
|
Loading…
Add table
Add a link
Reference in a new issue