scratchpad optimization for stack access using custom bank offset aligned to stack size
This commit is contained in:
84
hw/rtl/cache/VX_bank.v
vendored
84
hw/rtl/cache/VX_bank.v
vendored
@@ -7,7 +7,7 @@ module VX_bank #(
|
||||
// Size of cache in bytes
|
||||
parameter CACHE_SIZE = 1,
|
||||
// Size of line inside a bank in bytes
|
||||
parameter BANK_LINE_SIZE = 1,
|
||||
parameter CACHE_LINE_SIZE = 1,
|
||||
// Number of bankS
|
||||
parameter NUM_BANKS = 1,
|
||||
// Size of a word in bytes
|
||||
@@ -40,7 +40,10 @@ module VX_bank #(
|
||||
parameter CORE_TAG_WIDTH = 1,
|
||||
|
||||
// size of tag id in core request tag
|
||||
parameter CORE_TAG_ID_BITS = 0
|
||||
parameter CORE_TAG_ID_BITS = 0,
|
||||
|
||||
// bank offset from beginning of index range
|
||||
parameter BANK_ADDR_OFFSET = 0
|
||||
) (
|
||||
`SCOPE_IO_VX_bank
|
||||
|
||||
@@ -74,17 +77,18 @@ module VX_bank #(
|
||||
// DRAM request
|
||||
output wire dram_req_valid,
|
||||
output wire dram_req_rw,
|
||||
output wire [BANK_LINE_SIZE-1:0] dram_req_byteen,
|
||||
output wire [CACHE_LINE_SIZE-1:0] dram_req_byteen,
|
||||
output wire [`LINE_ADDR_WIDTH-1:0] dram_req_addr,
|
||||
output wire [`BANK_LINE_WIDTH-1:0] dram_req_data,
|
||||
output wire [`CACHE_LINE_WIDTH-1:0] dram_req_data,
|
||||
input wire dram_req_ready,
|
||||
|
||||
// DRAM response
|
||||
input wire dram_rsp_valid,
|
||||
input wire [`LINE_ADDR_WIDTH-1:0] dram_rsp_addr,
|
||||
input wire [`BANK_LINE_WIDTH-1:0] dram_rsp_data,
|
||||
input wire [`CACHE_LINE_WIDTH-1:0] dram_rsp_data,
|
||||
output wire dram_rsp_ready
|
||||
);
|
||||
|
||||
`ifdef DBG_CACHE_REQ_INFO
|
||||
/* verilator lint_off UNUSED */
|
||||
wire [31:0] debug_pc_st0;
|
||||
@@ -105,7 +109,7 @@ module VX_bank #(
|
||||
wire drsq_empty;
|
||||
|
||||
wire [`LINE_ADDR_WIDTH-1:0] drsq_addr_st0;
|
||||
wire [`BANK_LINE_WIDTH-1:0] drsq_filldata_st0;
|
||||
wire [`CACHE_LINE_WIDTH-1:0] drsq_filldata_st0;
|
||||
|
||||
wire drsq_push = dram_rsp_valid && dram_rsp_ready;
|
||||
|
||||
@@ -146,14 +150,24 @@ module VX_bank #(
|
||||
wire creq_rw_st0;
|
||||
wire [WORD_SIZE-1:0] creq_byteen_st0;
|
||||
`IGNORE_WARNINGS_BEGIN
|
||||
wire [`WORD_ADDR_WIDTH-1:0] creq_addr_st0;
|
||||
`IGNORE_WARNINGS_END
|
||||
wire [`WORD_ADDR_WIDTH-1:0] creq_addr_unqual;
|
||||
`IGNORE_WARNINGS_END
|
||||
wire [`LINE_ADDR_WIDTH-1:0] creq_addr_st0;
|
||||
wire [`UP(`WORD_SELECT_BITS)-1:0] creq_wsel_st0;
|
||||
wire [`WORD_WIDTH-1:0] creq_writeword_st0;
|
||||
wire [CORE_TAG_WIDTH-1:0] creq_tag_st0;
|
||||
|
||||
wire creq_push = (| core_req_valid) && core_req_ready;
|
||||
assign core_req_ready = !creq_full;
|
||||
|
||||
if (BANK_ADDR_OFFSET == 0) begin
|
||||
assign creq_addr_st0 = `LINE_SELECT_ADDR0(creq_addr_unqual);
|
||||
end else begin
|
||||
assign creq_addr_st0 = `LINE_SELECT_ADDRX(creq_addr_unqual);
|
||||
end
|
||||
|
||||
assign creq_wsel_st0 = creq_addr_unqual[`UP(`WORD_SELECT_BITS)-1:0];
|
||||
|
||||
VX_fifo_queue #(
|
||||
.DATAW (CORE_TAG_WIDTH + `REQS_BITS + 1 + WORD_SIZE + `WORD_ADDR_WIDTH + `WORD_WIDTH),
|
||||
.SIZE (CREQ_SIZE),
|
||||
@@ -165,7 +179,7 @@ module VX_bank #(
|
||||
.push (creq_push),
|
||||
.pop (creq_pop),
|
||||
.data_in ({core_req_tag, core_req_tid, core_req_rw, core_req_byteen, core_req_addr, core_req_data}),
|
||||
.data_out({creq_tag_st0, creq_tid_st0, creq_rw_st0, creq_byteen_st0, creq_addr_st0, creq_writeword_st0}),
|
||||
.data_out({creq_tag_st0, creq_tid_st0, creq_rw_st0, creq_byteen_st0, creq_addr_unqual, creq_writeword_st0}),
|
||||
.empty (creq_empty),
|
||||
.full (creq_full),
|
||||
`UNUSED_PIN (size)
|
||||
@@ -179,7 +193,7 @@ module VX_bank #(
|
||||
wire mshr_valid_st0;
|
||||
wire [`REQS_BITS-1:0] mshr_tid_st0;
|
||||
wire [`LINE_ADDR_WIDTH-1:0] mshr_addr_st0;
|
||||
wire [`UP(`WORD_SELECT_WIDTH)-1:0] mshr_wsel_st0;
|
||||
wire [`UP(`WORD_SELECT_BITS)-1:0] mshr_wsel_st0;
|
||||
wire [`WORD_WIDTH-1:0] mshr_writeword_st0;
|
||||
wire [`REQ_TAG_WIDTH-1:0] mshr_tag_st0;
|
||||
wire mshr_rw_st0;
|
||||
@@ -190,9 +204,9 @@ module VX_bank #(
|
||||
wire is_mshr_st0;
|
||||
wire valid_st0;
|
||||
wire [`LINE_ADDR_WIDTH-1:0] addr_st0;
|
||||
wire [`UP(`WORD_SELECT_WIDTH)-1:0] wsel_st0;
|
||||
wire [`UP(`WORD_SELECT_BITS)-1:0] wsel_st0;
|
||||
wire [`WORD_WIDTH-1:0] writeword_st0;
|
||||
wire [`BANK_LINE_WIDTH-1:0] writedata_st0;
|
||||
wire [`CACHE_LINE_WIDTH-1:0] writedata_st0;
|
||||
wire [`REQ_TAG_WIDTH-1:0] tag_st0;
|
||||
wire mem_rw_st0;
|
||||
wire [WORD_SIZE-1:0] byteen_st0;
|
||||
@@ -202,12 +216,12 @@ module VX_bank #(
|
||||
wire is_mshr_st1;
|
||||
wire valid_st1;
|
||||
wire [`LINE_ADDR_WIDTH-1:0] addr_st1;
|
||||
wire [`UP(`WORD_SELECT_WIDTH)-1:0] wsel_st1;
|
||||
wire [`UP(`WORD_SELECT_BITS)-1:0] wsel_st1;
|
||||
wire [`WORD_WIDTH-1:0] readword_st1;
|
||||
wire [`BANK_LINE_WIDTH-1:0] readdata_st1;
|
||||
wire [BANK_LINE_SIZE-1:0] dirtyb_st1;
|
||||
wire [`CACHE_LINE_WIDTH-1:0] readdata_st1;
|
||||
wire [CACHE_LINE_SIZE-1:0] dirtyb_st1;
|
||||
wire [`WORD_WIDTH-1:0] writeword_st1;
|
||||
wire [`BANK_LINE_WIDTH-1:0] writedata_st1;
|
||||
wire [`CACHE_LINE_WIDTH-1:0] writedata_st1;
|
||||
wire [`TAG_SELECT_BITS-1:0] readtag_st1;
|
||||
wire miss_st1;
|
||||
wire force_miss_st1;
|
||||
@@ -227,18 +241,18 @@ module VX_bank #(
|
||||
wire valid_st12;
|
||||
wire writeen_st12;
|
||||
wire [`LINE_ADDR_WIDTH-1:0] addr_st12;
|
||||
wire [`UP(`WORD_SELECT_WIDTH)-1:0] wsel_st12;
|
||||
wire [`UP(`WORD_SELECT_BITS)-1:0] wsel_st12;
|
||||
wire [WORD_SIZE-1:0] byteen_st12;
|
||||
wire [`WORD_WIDTH-1:0] writeword_st12;
|
||||
wire [`REQ_TAG_WIDTH-1:0] tag_st12;
|
||||
|
||||
wire valid_st2;
|
||||
wire [`UP(`WORD_SELECT_WIDTH)-1:0] wsel_st2;
|
||||
wire [`UP(`WORD_SELECT_BITS)-1:0] wsel_st2;
|
||||
wire [`WORD_WIDTH-1:0] readword_st2;
|
||||
wire [`WORD_WIDTH-1:0] writeword_st2;
|
||||
wire [`BANK_LINE_WIDTH-1:0] readdata_st2;
|
||||
wire [`BANK_LINE_WIDTH-1:0] writedata_st2;
|
||||
wire [BANK_LINE_SIZE-1:0] dirtyb_st2;
|
||||
wire [`CACHE_LINE_WIDTH-1:0] readdata_st2;
|
||||
wire [`CACHE_LINE_WIDTH-1:0] writedata_st2;
|
||||
wire [CACHE_LINE_SIZE-1:0] dirtyb_st2;
|
||||
wire [`TAG_SELECT_BITS-1:0] readtag_st2;
|
||||
wire is_fill_st2;
|
||||
wire is_mshr_st2;
|
||||
@@ -298,14 +312,15 @@ module VX_bank #(
|
||||
|
||||
assign addr_st0 = mshr_pop_unqual ? mshr_addr_st0 :
|
||||
drsq_pop_unqual ? drsq_addr_st0 :
|
||||
creq_pop_unqual ? creq_addr_st0[`LINE_SELECT_ADDR_RNG] :
|
||||
creq_pop_unqual ? creq_addr_st0 :
|
||||
0;
|
||||
|
||||
if (`WORD_SELECT_WIDTH != 0) begin
|
||||
assign wsel_st0 = creq_pop_unqual ? creq_addr_st0[`WORD_SELECT_WIDTH-1:0] :
|
||||
if (`WORD_SELECT_BITS != 0) begin
|
||||
assign wsel_st0 = creq_pop_unqual ? creq_wsel_st0 :
|
||||
mshr_pop_unqual ? mshr_wsel_st0 :
|
||||
0;
|
||||
end else begin
|
||||
`UNUSED_VAR (creq_wsel_st0)
|
||||
`UNUSED_VAR (mshr_wsel_st0)
|
||||
assign wsel_st0 = 0;
|
||||
end
|
||||
@@ -349,7 +364,7 @@ if (DRAM_ENABLE) begin
|
||||
|| (valid_st2 && (miss_st2 || force_miss_st2) && (addr_st2 == addr_st0));
|
||||
|
||||
VX_pipe_register #(
|
||||
.DATAW (1 + 1 + 1 + `LINE_ADDR_WIDTH + `UP(`WORD_SELECT_WIDTH) + `WORD_WIDTH + 1 + `BANK_LINE_WIDTH + 1 + WORD_SIZE + `REQS_BITS + `REQ_TAG_WIDTH),
|
||||
.DATAW (1 + 1 + 1 + `LINE_ADDR_WIDTH + `UP(`WORD_SELECT_BITS) + `WORD_WIDTH + 1 + `CACHE_LINE_WIDTH + 1 + WORD_SIZE + `REQS_BITS + `REQ_TAG_WIDTH),
|
||||
.RESETW (1)
|
||||
) pipe_reg1 (
|
||||
.clk (clk),
|
||||
@@ -379,10 +394,11 @@ if (DRAM_ENABLE) begin
|
||||
.CACHE_ID (CACHE_ID),
|
||||
.CORE_TAG_ID_BITS(CORE_TAG_ID_BITS),
|
||||
.CACHE_SIZE (CACHE_SIZE),
|
||||
.BANK_LINE_SIZE (BANK_LINE_SIZE),
|
||||
.CACHE_LINE_SIZE (CACHE_LINE_SIZE),
|
||||
.NUM_BANKS (NUM_BANKS),
|
||||
.WORD_SIZE (WORD_SIZE),
|
||||
.WRITE_ENABLE (WRITE_ENABLE)
|
||||
.WRITE_ENABLE (WRITE_ENABLE),
|
||||
.BANK_ADDR_OFFSET (BANK_ADDR_OFFSET)
|
||||
) tag_access (
|
||||
.clk (clk),
|
||||
.reset (reset),
|
||||
@@ -454,7 +470,7 @@ end else begin
|
||||
assign wsel_st1 = wsel_st0;
|
||||
assign writeword_st1 = writeword_st0;
|
||||
assign writedata_st1 = writedata_st0;
|
||||
assign addr_st1 = creq_addr_st0[`LINE_SELECT_ADDR_RNG];
|
||||
assign addr_st1 = creq_addr_st0;
|
||||
assign tag_st1 = tag_st0;
|
||||
assign mem_rw_st1 = mem_rw_st0;
|
||||
assign byteen_st1 = byteen_st0;
|
||||
@@ -482,7 +498,7 @@ end else begin
|
||||
end
|
||||
|
||||
VX_pipe_register #(
|
||||
.DATAW (1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + `LINE_ADDR_WIDTH + `UP(`WORD_SELECT_WIDTH) + `WORD_WIDTH + `WORD_WIDTH + `TAG_SELECT_BITS + 1 + `BANK_LINE_WIDTH + 1 + WORD_SIZE + `REQS_BITS + `REQ_TAG_WIDTH),
|
||||
.DATAW (1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + `LINE_ADDR_WIDTH + `UP(`WORD_SELECT_BITS) + `WORD_WIDTH + `WORD_WIDTH + `TAG_SELECT_BITS + 1 + `CACHE_LINE_WIDTH + 1 + WORD_SIZE + `REQS_BITS + `REQ_TAG_WIDTH),
|
||||
.RESETW (1)
|
||||
) pipe_reg2 (
|
||||
.clk (clk),
|
||||
@@ -500,7 +516,7 @@ end
|
||||
end else begin
|
||||
|
||||
VX_pipe_register #(
|
||||
.DATAW (BANK_LINE_SIZE + `BANK_LINE_WIDTH),
|
||||
.DATAW (CACHE_LINE_SIZE + `CACHE_LINE_WIDTH),
|
||||
.RESETW (0)
|
||||
) pipe_reg2b (
|
||||
.clk (clk),
|
||||
@@ -526,7 +542,7 @@ end
|
||||
.CACHE_ID (CACHE_ID),
|
||||
.CORE_TAG_ID_BITS(CORE_TAG_ID_BITS),
|
||||
.CACHE_SIZE (CACHE_SIZE),
|
||||
.BANK_LINE_SIZE (BANK_LINE_SIZE),
|
||||
.CACHE_LINE_SIZE (CACHE_LINE_SIZE),
|
||||
.NUM_BANKS (NUM_BANKS),
|
||||
.DRAM_ENABLE (DRAM_ENABLE),
|
||||
.WORD_SIZE (WORD_SIZE),
|
||||
@@ -595,7 +611,7 @@ end
|
||||
.BANK_ID (BANK_ID),
|
||||
.CACHE_ID (CACHE_ID),
|
||||
.CORE_TAG_ID_BITS (CORE_TAG_ID_BITS),
|
||||
.BANK_LINE_SIZE (BANK_LINE_SIZE),
|
||||
.CACHE_LINE_SIZE (CACHE_LINE_SIZE),
|
||||
.NUM_BANKS (NUM_BANKS),
|
||||
.WORD_SIZE (WORD_SIZE),
|
||||
.NUM_REQS (NUM_REQS),
|
||||
@@ -710,11 +726,11 @@ end
|
||||
wire [`LINE_ADDR_WIDTH-1:0] dreq_addr = (WRITE_THROUGH || !writeback) ? addr_st2 :
|
||||
{readtag_st2, addr_st2[`LINE_SELECT_BITS-1:0]};
|
||||
|
||||
wire [BANK_LINE_SIZE-1:0] dreq_byteen = writeback ? dirtyb_st2 : {BANK_LINE_SIZE{1'b1}};
|
||||
wire [CACHE_LINE_SIZE-1:0] dreq_byteen = writeback ? dirtyb_st2 : {CACHE_LINE_SIZE{1'b1}};
|
||||
|
||||
if (DRAM_ENABLE) begin
|
||||
VX_fifo_queue #(
|
||||
.DATAW (1 + BANK_LINE_SIZE + `LINE_ADDR_WIDTH + `BANK_LINE_WIDTH),
|
||||
.DATAW (1 + CACHE_LINE_SIZE + `LINE_ADDR_WIDTH + `CACHE_LINE_WIDTH),
|
||||
.SIZE (DREQ_SIZE),
|
||||
.BUFFERED (1),
|
||||
.FASTRAM (1)
|
||||
|
||||
48
hw/rtl/cache/VX_cache.v
vendored
48
hw/rtl/cache/VX_cache.v
vendored
@@ -6,7 +6,7 @@ module VX_cache #(
|
||||
// Size of cache in bytes
|
||||
parameter CACHE_SIZE = 8092,
|
||||
// Size of line inside a bank in bytes
|
||||
parameter BANK_LINE_SIZE = 16,
|
||||
parameter CACHE_LINE_SIZE = 16,
|
||||
// Number of banks
|
||||
parameter NUM_BANKS = 4,
|
||||
// Size of a word in bytes
|
||||
@@ -42,7 +42,10 @@ module VX_cache #(
|
||||
parameter CORE_TAG_ID_BITS = 0,
|
||||
|
||||
// dram request tag size
|
||||
parameter DRAM_TAG_WIDTH = (32 - $clog2(BANK_LINE_SIZE))
|
||||
parameter DRAM_TAG_WIDTH = (32 - $clog2(CACHE_LINE_SIZE)),
|
||||
|
||||
// bank offset from beginning of index range
|
||||
parameter BANK_ADDR_OFFSET = 0
|
||||
) (
|
||||
`SCOPE_IO_VX_cache
|
||||
|
||||
@@ -72,20 +75,21 @@ module VX_cache #(
|
||||
// DRAM request
|
||||
output wire dram_req_valid,
|
||||
output wire dram_req_rw,
|
||||
output wire [BANK_LINE_SIZE-1:0] dram_req_byteen,
|
||||
output wire [CACHE_LINE_SIZE-1:0] dram_req_byteen,
|
||||
output wire [`DRAM_ADDR_WIDTH-1:0] dram_req_addr,
|
||||
output wire [`BANK_LINE_WIDTH-1:0] dram_req_data,
|
||||
output wire [`CACHE_LINE_WIDTH-1:0] dram_req_data,
|
||||
output wire [DRAM_TAG_WIDTH-1:0] dram_req_tag,
|
||||
input wire dram_req_ready,
|
||||
|
||||
// DRAM response
|
||||
input wire dram_rsp_valid,
|
||||
input wire [`BANK_LINE_WIDTH-1:0] dram_rsp_data,
|
||||
input wire [`CACHE_LINE_WIDTH-1:0] dram_rsp_data,
|
||||
input wire [DRAM_TAG_WIDTH-1:0] dram_rsp_tag,
|
||||
output wire dram_rsp_ready
|
||||
);
|
||||
|
||||
`STATIC_ASSERT(NUM_BANKS <= NUM_REQS, ("invalid value"))
|
||||
`UNUSED_VAR (dram_rsp_tag)
|
||||
|
||||
wire [NUM_BANKS-1:0] per_bank_core_req_valid;
|
||||
wire [NUM_BANKS-1:0][`REQS_BITS-1:0] per_bank_core_req_tid;
|
||||
@@ -104,9 +108,9 @@ module VX_cache #(
|
||||
|
||||
wire [NUM_BANKS-1:0] per_bank_dram_req_valid;
|
||||
wire [NUM_BANKS-1:0] per_bank_dram_req_rw;
|
||||
wire [NUM_BANKS-1:0][BANK_LINE_SIZE-1:0] per_bank_dram_req_byteen;
|
||||
wire [NUM_BANKS-1:0][CACHE_LINE_SIZE-1:0] per_bank_dram_req_byteen;
|
||||
wire [NUM_BANKS-1:0][`DRAM_ADDR_WIDTH-1:0] per_bank_dram_req_addr;
|
||||
wire [NUM_BANKS-1:0][`BANK_LINE_WIDTH-1:0] per_bank_dram_req_data;
|
||||
wire [NUM_BANKS-1:0][`CACHE_LINE_WIDTH-1:0] per_bank_dram_req_data;
|
||||
wire [NUM_BANKS-1:0] per_bank_dram_req_ready;
|
||||
|
||||
wire [NUM_BANKS-1:0] per_bank_dram_rsp_ready;
|
||||
@@ -119,11 +123,12 @@ module VX_cache #(
|
||||
`endif
|
||||
|
||||
VX_cache_core_req_bank_sel #(
|
||||
.BANK_LINE_SIZE (BANK_LINE_SIZE),
|
||||
.NUM_BANKS (NUM_BANKS),
|
||||
.WORD_SIZE (WORD_SIZE),
|
||||
.NUM_REQS (NUM_REQS),
|
||||
.CORE_TAG_WIDTH (CORE_TAG_WIDTH)
|
||||
.CACHE_LINE_SIZE (CACHE_LINE_SIZE),
|
||||
.NUM_BANKS (NUM_BANKS),
|
||||
.WORD_SIZE (WORD_SIZE),
|
||||
.NUM_REQS (NUM_REQS),
|
||||
.CORE_TAG_WIDTH (CORE_TAG_WIDTH),
|
||||
.BANK_ADDR_OFFSET(BANK_ADDR_OFFSET)
|
||||
) cache_core_req_bank_sel (
|
||||
.clk (clk),
|
||||
.reset (reset),
|
||||
@@ -174,13 +179,13 @@ module VX_cache #(
|
||||
|
||||
wire curr_bank_dram_req_valid;
|
||||
wire curr_bank_dram_req_rw;
|
||||
wire [BANK_LINE_SIZE-1:0] curr_bank_dram_req_byteen;
|
||||
wire [CACHE_LINE_SIZE-1:0] curr_bank_dram_req_byteen;
|
||||
wire [`LINE_ADDR_WIDTH-1:0] curr_bank_dram_req_addr;
|
||||
wire[`BANK_LINE_WIDTH-1:0] curr_bank_dram_req_data;
|
||||
wire[`CACHE_LINE_WIDTH-1:0] curr_bank_dram_req_data;
|
||||
wire curr_bank_dram_req_ready;
|
||||
|
||||
wire curr_bank_dram_rsp_valid;
|
||||
wire [`BANK_LINE_WIDTH-1:0] curr_bank_dram_rsp_data;
|
||||
wire [`CACHE_LINE_WIDTH-1:0] curr_bank_dram_rsp_data;
|
||||
wire [`LINE_ADDR_WIDTH-1:0] curr_bank_dram_rsp_addr;
|
||||
wire curr_bank_dram_rsp_ready;
|
||||
|
||||
@@ -208,7 +213,7 @@ module VX_cache #(
|
||||
if (NUM_BANKS == 1) begin
|
||||
assign per_bank_dram_req_addr[i] = curr_bank_dram_req_addr;
|
||||
end else begin
|
||||
assign per_bank_dram_req_addr[i] = `LINE_TO_DRAM_ADDR(curr_bank_dram_req_addr, i);
|
||||
assign per_bank_dram_req_addr[i] = `LINE_TO_DRAM_ADDR(curr_bank_dram_req_addr, i);
|
||||
end
|
||||
assign per_bank_dram_req_data[i] = curr_bank_dram_req_data;
|
||||
assign curr_bank_dram_req_ready = per_bank_dram_req_ready[i];
|
||||
@@ -219,7 +224,7 @@ module VX_cache #(
|
||||
assign curr_bank_dram_rsp_addr = dram_rsp_tag;
|
||||
end else begin
|
||||
assign curr_bank_dram_rsp_valid = dram_rsp_valid && (`DRAM_ADDR_BANK(dram_rsp_tag) == i);
|
||||
assign curr_bank_dram_rsp_addr = `DRAM_TO_LINE_ADDR(dram_rsp_tag);
|
||||
assign curr_bank_dram_rsp_addr = `DRAM_TO_LINE_ADDR(dram_rsp_tag);
|
||||
end
|
||||
assign curr_bank_dram_rsp_data = dram_rsp_data;
|
||||
assign per_bank_dram_rsp_ready[i] = curr_bank_dram_rsp_ready;
|
||||
@@ -228,7 +233,7 @@ module VX_cache #(
|
||||
.BANK_ID (i),
|
||||
.CACHE_ID (CACHE_ID),
|
||||
.CACHE_SIZE (CACHE_SIZE),
|
||||
.BANK_LINE_SIZE (BANK_LINE_SIZE),
|
||||
.CACHE_LINE_SIZE (CACHE_LINE_SIZE),
|
||||
.NUM_BANKS (NUM_BANKS),
|
||||
.WORD_SIZE (WORD_SIZE),
|
||||
.NUM_REQS (NUM_REQS),
|
||||
@@ -241,7 +246,8 @@ module VX_cache #(
|
||||
.WRITE_ENABLE (WRITE_ENABLE),
|
||||
.WRITE_THROUGH (WRITE_THROUGH),
|
||||
.CORE_TAG_WIDTH (CORE_TAG_WIDTH),
|
||||
.CORE_TAG_ID_BITS (CORE_TAG_ID_BITS)
|
||||
.CORE_TAG_ID_BITS (CORE_TAG_ID_BITS),
|
||||
.BANK_ADDR_OFFSET (BANK_ADDR_OFFSET)
|
||||
) bank (
|
||||
`SCOPE_BIND_VX_cache_bank(i)
|
||||
|
||||
@@ -309,14 +315,14 @@ module VX_cache #(
|
||||
);
|
||||
|
||||
if (DRAM_ENABLE) begin
|
||||
wire [NUM_BANKS-1:0][(`DRAM_ADDR_WIDTH + 1 + BANK_LINE_SIZE + `BANK_LINE_WIDTH)-1:0] data_in;
|
||||
wire [NUM_BANKS-1:0][(`DRAM_ADDR_WIDTH + 1 + CACHE_LINE_SIZE + `CACHE_LINE_WIDTH)-1:0] data_in;
|
||||
for (genvar i = 0; i < NUM_BANKS; i++) begin
|
||||
assign data_in[i] = {per_bank_dram_req_addr[i], per_bank_dram_req_rw[i], per_bank_dram_req_byteen[i], per_bank_dram_req_data[i]};
|
||||
end
|
||||
|
||||
VX_stream_arbiter #(
|
||||
.NUM_REQS (NUM_BANKS),
|
||||
.DATAW (`DRAM_ADDR_WIDTH + 1 + BANK_LINE_SIZE + `BANK_LINE_WIDTH),
|
||||
.DATAW (`DRAM_ADDR_WIDTH + 1 + CACHE_LINE_SIZE + `CACHE_LINE_WIDTH),
|
||||
.BUFFERED (1)
|
||||
) dram_req_arb (
|
||||
.clk (clk),
|
||||
|
||||
55
hw/rtl/cache/VX_cache_config.vh
vendored
55
hw/rtl/cache/VX_cache_config.vh
vendored
@@ -15,66 +15,55 @@
|
||||
`define REQ_INST_META_WIDTH (`REQ_TAG_WIDTH + 1 + WORD_SIZE + `REQS_BITS)
|
||||
|
||||
// data metadata word_sel
|
||||
`define MSHR_DATA_WIDTH (`WORD_WIDTH + `REQ_INST_META_WIDTH + `UP(`WORD_SELECT_WIDTH))
|
||||
|
||||
`define BANK_BITS `LOG2UP(NUM_BANKS)
|
||||
`define MSHR_DATA_WIDTH (`WORD_WIDTH + `REQ_INST_META_WIDTH + `UP(`WORD_SELECT_BITS))
|
||||
|
||||
`define WORD_WIDTH (8 * WORD_SIZE)
|
||||
|
||||
`define BANK_LINE_WIDTH (8 * BANK_LINE_SIZE)
|
||||
`define CACHE_LINE_WIDTH (8 * CACHE_LINE_SIZE)
|
||||
|
||||
`define BANK_SIZE (CACHE_SIZE / NUM_BANKS)
|
||||
`define BANK_LINE_COUNT (`BANK_SIZE / BANK_LINE_SIZE)
|
||||
`define BANK_LINE_WORDS (BANK_LINE_SIZE / WORD_SIZE)
|
||||
`define BANK_SIZE (CACHE_SIZE / NUM_BANKS)
|
||||
`define LINES_PER_BANK (`BANK_SIZE / CACHE_LINE_SIZE)
|
||||
`define WORDS_PER_LINE (CACHE_LINE_SIZE / WORD_SIZE)
|
||||
|
||||
// Offset select
|
||||
`define OFFSET_ADDR_BITS `CLOG2(WORD_SIZE)
|
||||
`define OFFSET_ADDR_START 0
|
||||
`define OFFSET_ADDR_END (`OFFSET_ADDR_START+`OFFSET_ADDR_BITS-1)
|
||||
`define WORD_SELECT_BITS `CLOG2(`WORDS_PER_LINE)
|
||||
`define WORD_ADDR_WIDTH (32-`CLOG2(WORD_SIZE))
|
||||
`define DRAM_ADDR_WIDTH (32-`CLOG2(CACHE_LINE_SIZE))
|
||||
`define LINE_ADDR_WIDTH (`DRAM_ADDR_WIDTH-`BANK_SELECT_BITS)
|
||||
|
||||
// Word select
|
||||
`define WORD_SELECT_BITS `CLOG2(`BANK_LINE_WORDS)
|
||||
`define WORD_SELECT_ADDR_START (1+`OFFSET_ADDR_END)
|
||||
`define WORD_SELECT_BITS `CLOG2(`WORDS_PER_LINE)
|
||||
`define WORD_SELECT_ADDR_START 0
|
||||
`define WORD_SELECT_ADDR_END (`WORD_SELECT_ADDR_START+`WORD_SELECT_BITS-1)
|
||||
|
||||
// Bank select
|
||||
`define BANK_SELECT_BITS `CLOG2(NUM_BANKS)
|
||||
`define BANK_SELECT_ADDR_START (1+`WORD_SELECT_ADDR_END)
|
||||
`define BANK_SELECT_ADDR_START (1+`WORD_SELECT_ADDR_END+BANK_ADDR_OFFSET)
|
||||
`define BANK_SELECT_ADDR_END (`BANK_SELECT_ADDR_START+`BANK_SELECT_BITS-1)
|
||||
|
||||
// Line select
|
||||
`define LINE_SELECT_BITS `CLOG2(`BANK_LINE_COUNT)
|
||||
`define LINE_SELECT_BITS `CLOG2(`LINES_PER_BANK)
|
||||
`define LINE_SELECT_ADDR_START (1+`BANK_SELECT_ADDR_END)
|
||||
`define LINE_SELECT_ADDR_END (`LINE_SELECT_ADDR_START+`LINE_SELECT_BITS-1)
|
||||
`define LINE_SELECT_ADDR_END (`LINE_SELECT_ADDR_START-BANK_ADDR_OFFSET+`LINE_SELECT_BITS-1)
|
||||
|
||||
// Tag select
|
||||
`define TAG_SELECT_BITS (31-`LINE_SELECT_ADDR_END)
|
||||
`define TAG_SELECT_BITS (`WORD_ADDR_WIDTH-1-`LINE_SELECT_ADDR_END)
|
||||
`define TAG_SELECT_ADDR_START (1+`LINE_SELECT_ADDR_END)
|
||||
`define TAG_SELECT_ADDR_END 31
|
||||
`define TAG_SELECT_ADDR_END (`WORD_ADDR_WIDTH-1)
|
||||
|
||||
`define WORD_SELECT_WIDTH `CLOG2(`BANK_LINE_WORDS)
|
||||
`define BANK_SELECT_ADDR(x) x[`BANK_SELECT_ADDR_END : `BANK_SELECT_ADDR_START]
|
||||
|
||||
`define WORD_ADDR_WIDTH (32-`CLOG2(WORD_SIZE))
|
||||
`define LINE_SELECT_ADDR0(x) x[`WORD_ADDR_WIDTH-1 : `LINE_SELECT_ADDR_START]
|
||||
`define LINE_SELECT_ADDRX(x) {x[`WORD_ADDR_WIDTH-1 : `LINE_SELECT_ADDR_START], x[`BANK_SELECT_ADDR_START-1 : 1+`WORD_SELECT_ADDR_END]}
|
||||
|
||||
`define DRAM_ADDR_WIDTH (32-`CLOG2(BANK_LINE_SIZE))
|
||||
|
||||
`define LINE_ADDR_WIDTH (`DRAM_ADDR_WIDTH-`BANK_SELECT_BITS)
|
||||
|
||||
`define BANK_SELECT_ADDR_RNG (`BANK_SELECT_BITS+`WORD_SELECT_BITS-1):`WORD_SELECT_BITS
|
||||
|
||||
`define LINE_SELECT_ADDR_RNG `WORD_ADDR_WIDTH-1:(`BANK_SELECT_BITS + `WORD_SELECT_BITS)
|
||||
|
||||
`define TAG_LINE_ADDR_RNG `LINE_ADDR_WIDTH-1:`LINE_SELECT_BITS
|
||||
|
||||
`define BASE_ADDR_BITS (`WORD_SELECT_BITS+`OFFSET_ADDR_BITS)
|
||||
`define LINE_TAG_ADDR(x) x[`LINE_ADDR_WIDTH-1 : `LINE_SELECT_BITS]
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
`define CORE_REQ_TAG_COUNT ((CORE_TAG_ID_BITS != 0) ? 1 : NUM_REQS)
|
||||
|
||||
`define DRAM_ADDR_BANK(x) x[`BANK_SELECT_BITS-1:0]
|
||||
`define DRAM_ADDR_BANK(x) x[`BANK_SELECT_BITS+BANK_ADDR_OFFSET-1 : BANK_ADDR_OFFSET]
|
||||
|
||||
`define DRAM_TO_LINE_ADDR(x) x[`DRAM_ADDR_WIDTH-1:`BANK_SELECT_BITS]
|
||||
`define DRAM_TO_LINE_ADDR(x) x[`DRAM_ADDR_WIDTH-1 : `BANK_SELECT_BITS]
|
||||
|
||||
`define LINE_TO_DRAM_ADDR(x, i) {x, `BANK_SELECT_BITS'(i)}
|
||||
|
||||
|
||||
35
hw/rtl/cache/VX_cache_core_req_bank_sel.v
vendored
35
hw/rtl/cache/VX_cache_core_req_bank_sel.v
vendored
@@ -1,8 +1,8 @@
|
||||
`include "VX_cache_config.vh"
|
||||
|
||||
module VX_cache_core_req_bank_sel #(
|
||||
module VX_cache_core_req_bank_sel #(
|
||||
// Size of line inside a bank in bytes
|
||||
parameter BANK_LINE_SIZE = 1,
|
||||
parameter CACHE_LINE_SIZE= 1,
|
||||
// Size of a word in bytes
|
||||
parameter WORD_SIZE = 1,
|
||||
// Number of banks
|
||||
@@ -10,7 +10,10 @@ module VX_cache_core_req_bank_sel #(
|
||||
// Number of Word requests per cycle
|
||||
parameter NUM_REQS = 1,
|
||||
// core request tag size
|
||||
parameter CORE_TAG_WIDTH = 1
|
||||
parameter CORE_TAG_WIDTH = 1,
|
||||
|
||||
// bank offset from beginning of index range
|
||||
parameter BANK_ADDR_OFFSET = 0
|
||||
) (
|
||||
input wire clk,
|
||||
input wire reset,
|
||||
@@ -33,22 +36,22 @@ module VX_cache_core_req_bank_sel #(
|
||||
output wire [NUM_BANKS-1:0][CORE_TAG_WIDTH-1:0] per_bank_core_req_tag,
|
||||
output wire [NUM_BANKS-1:0][`WORD_WIDTH-1:0] per_bank_core_req_data,
|
||||
input wire [NUM_BANKS-1:0] per_bank_core_req_ready
|
||||
);
|
||||
);
|
||||
if (NUM_BANKS > 1) begin
|
||||
|
||||
reg [NUM_BANKS-1:0] per_bank_core_req_valid_r;
|
||||
reg [NUM_BANKS-1:0][`REQS_BITS-1:0] per_bank_core_req_tid_r;
|
||||
reg [NUM_BANKS-1:0] per_bank_core_req_rw_r;
|
||||
reg [NUM_BANKS-1:0][WORD_SIZE-1:0] per_bank_core_req_byteen_r;
|
||||
reg [NUM_BANKS-1:0][`WORD_ADDR_WIDTH-1:0] per_bank_core_req_addr_r;
|
||||
reg [NUM_BANKS-1:0][CORE_TAG_WIDTH-1:0] per_bank_core_req_tag_r;
|
||||
reg [NUM_BANKS-1:0][`WORD_WIDTH-1:0] per_bank_core_req_data_r;
|
||||
reg [NUM_REQS-1:0] core_req_ready_r;
|
||||
reg [NUM_BANKS-1:0] core_req_sel_r;
|
||||
wire [NUM_REQS-1:0][`BANK_BITS-1:0] core_req_bid;
|
||||
reg [NUM_BANKS-1:0] per_bank_core_req_valid_r;
|
||||
reg [NUM_BANKS-1:0][`REQS_BITS-1:0] per_bank_core_req_tid_r;
|
||||
reg [NUM_BANKS-1:0] per_bank_core_req_rw_r;
|
||||
reg [NUM_BANKS-1:0][WORD_SIZE-1:0] per_bank_core_req_byteen_r;
|
||||
reg [NUM_BANKS-1:0][`WORD_ADDR_WIDTH-1:0] per_bank_core_req_addr_r;
|
||||
reg [NUM_BANKS-1:0][CORE_TAG_WIDTH-1:0] per_bank_core_req_tag_r;
|
||||
reg [NUM_BANKS-1:0][`WORD_WIDTH-1:0] per_bank_core_req_data_r;
|
||||
reg [NUM_REQS-1:0] core_req_ready_r;
|
||||
reg [NUM_BANKS-1:0] core_req_sel_r;
|
||||
wire [NUM_REQS-1:0][`BANK_SELECT_BITS-1:0] core_req_bid;
|
||||
|
||||
for (genvar i = 0; i < NUM_REQS; ++i) begin
|
||||
assign core_req_bid[i] = core_req_addr[i][`BANK_SELECT_ADDR_RNG];
|
||||
assign core_req_bid[i] = `BANK_SELECT_ADDR(core_req_addr[i]);
|
||||
end
|
||||
|
||||
always @(*) begin
|
||||
@@ -79,7 +82,7 @@ module VX_cache_core_req_bank_sel #(
|
||||
|
||||
for (integer j = 0; j < NUM_BANKS; ++j) begin
|
||||
for (integer i = 0; i < NUM_REQS; ++i) begin
|
||||
if (core_req_valid[i] && (core_req_bid[i] == `BANK_BITS'(j))) begin
|
||||
if (core_req_valid[i] && (core_req_bid[i] == `BANK_SELECT_BITS'(j))) begin
|
||||
core_req_ready_r[i] = per_bank_core_req_ready[j];
|
||||
core_req_sel_r[i] = 1;
|
||||
break;
|
||||
|
||||
38
hw/rtl/cache/VX_data_access.v
vendored
38
hw/rtl/cache/VX_data_access.v
vendored
@@ -7,7 +7,7 @@ module VX_data_access #(
|
||||
// Size of cache in bytes
|
||||
parameter CACHE_SIZE = 1,
|
||||
// Size of line inside a bank in bytes
|
||||
parameter BANK_LINE_SIZE = 1,
|
||||
parameter CACHE_LINE_SIZE = 1,
|
||||
// Number of banks
|
||||
parameter NUM_BANKS = 1,
|
||||
// Size of a word in bytes
|
||||
@@ -44,29 +44,29 @@ module VX_data_access #(
|
||||
`IGNORE_WARNINGS_BEGIN
|
||||
input wire[`LINE_ADDR_WIDTH-1:0] raddr_in,
|
||||
`IGNORE_WARNINGS_END
|
||||
input wire [`UP(`WORD_SELECT_WIDTH)-1:0] rwsel_in,
|
||||
input wire [`UP(`WORD_SELECT_BITS)-1:0] rwsel_in,
|
||||
input wire [WORD_SIZE-1:0] rbyteen_in,
|
||||
output wire[`WORD_WIDTH-1:0] readword_out,
|
||||
output wire [`BANK_LINE_WIDTH-1:0] readdata_out,
|
||||
output wire [BANK_LINE_SIZE-1:0] dirtyb_out,
|
||||
output wire [`CACHE_LINE_WIDTH-1:0] readdata_out,
|
||||
output wire [CACHE_LINE_SIZE-1:0] dirtyb_out,
|
||||
|
||||
// writing
|
||||
input wire writeen_in,
|
||||
`IGNORE_WARNINGS_BEGIN
|
||||
input wire[`LINE_ADDR_WIDTH-1:0] waddr_in,
|
||||
`IGNORE_WARNINGS_END
|
||||
input wire [`UP(`WORD_SELECT_WIDTH)-1:0] wwsel_in,
|
||||
input wire [`UP(`WORD_SELECT_BITS)-1:0] wwsel_in,
|
||||
input wire [WORD_SIZE-1:0] wbyteen_in,
|
||||
input wire wfill_in,
|
||||
input wire [`WORD_WIDTH-1:0] writeword_in,
|
||||
input wire [`BANK_LINE_WIDTH-1:0] writedata_in
|
||||
input wire [`CACHE_LINE_WIDTH-1:0] writedata_in
|
||||
);
|
||||
|
||||
wire [BANK_LINE_SIZE-1:0] read_dirtyb, dirtyb_qual;
|
||||
wire [`BANK_LINE_WIDTH-1:0] read_data, readdata_qual;
|
||||
wire [CACHE_LINE_SIZE-1:0] read_dirtyb, dirtyb_qual;
|
||||
wire [`CACHE_LINE_WIDTH-1:0] read_data, readdata_qual;
|
||||
|
||||
wire [BANK_LINE_SIZE-1:0] byte_enable;
|
||||
wire [`BANK_LINE_WIDTH-1:0] write_data;
|
||||
wire [CACHE_LINE_SIZE-1:0] byte_enable;
|
||||
wire [`CACHE_LINE_WIDTH-1:0] write_data;
|
||||
wire write_enable;
|
||||
|
||||
wire [`LINE_SELECT_BITS-1:0] raddr = raddr_in[`LINE_SELECT_BITS-1:0];
|
||||
@@ -76,7 +76,7 @@ module VX_data_access #(
|
||||
|
||||
VX_data_store #(
|
||||
.CACHE_SIZE (CACHE_SIZE),
|
||||
.BANK_LINE_SIZE (BANK_LINE_SIZE),
|
||||
.CACHE_LINE_SIZE (CACHE_LINE_SIZE),
|
||||
.NUM_BANKS (NUM_BANKS),
|
||||
.WORD_SIZE (WORD_SIZE),
|
||||
.WRITE_ENABLE (WRITE_ENABLE)
|
||||
@@ -95,12 +95,12 @@ module VX_data_access #(
|
||||
.write_data (write_data)
|
||||
);
|
||||
|
||||
wire [`BANK_LINE_WORDS-1:0][WORD_SIZE-1:0] wbyteen_qual;
|
||||
wire [`BANK_LINE_WIDTH-1:0] writeword_qual;
|
||||
wire [`WORDS_PER_LINE-1:0][WORD_SIZE-1:0] wbyteen_qual;
|
||||
wire [`CACHE_LINE_WIDTH-1:0] writeword_qual;
|
||||
|
||||
if (`WORD_SELECT_WIDTH != 0) begin
|
||||
for (genvar i = 0; i < `BANK_LINE_WORDS; i++) begin
|
||||
assign wbyteen_qual[i] = (wwsel_in == `WORD_SELECT_WIDTH'(i)) ? wbyteen_in : {WORD_SIZE{1'b0}};
|
||||
if (`WORD_SELECT_BITS != 0) begin
|
||||
for (genvar i = 0; i < `WORDS_PER_LINE; i++) begin
|
||||
assign wbyteen_qual[i] = (wwsel_in == `WORD_SELECT_BITS'(i)) ? wbyteen_in : {WORD_SIZE{1'b0}};
|
||||
assign writeword_qual[i * `WORD_WIDTH +: `WORD_WIDTH] = writeword_in;
|
||||
end
|
||||
end else begin
|
||||
@@ -109,13 +109,13 @@ module VX_data_access #(
|
||||
assign writeword_qual = writeword_in;
|
||||
end
|
||||
|
||||
assign byte_enable = wfill_in ? {BANK_LINE_SIZE{1'b1}} : wbyteen_qual;
|
||||
assign byte_enable = wfill_in ? {CACHE_LINE_SIZE{1'b1}} : wbyteen_qual;
|
||||
assign write_data = wfill_in ? writedata_in : writeword_qual;
|
||||
|
||||
assign write_enable = writeen_in && !stall;
|
||||
|
||||
wire rw_hazard = DRAM_ENABLE && (raddr == waddr) && writeen_in;
|
||||
for (genvar i = 0; i < BANK_LINE_SIZE; i++) begin
|
||||
for (genvar i = 0; i < CACHE_LINE_SIZE; i++) begin
|
||||
assign dirtyb_qual[i] = rw_hazard ? byte_enable[i] : read_dirtyb[i];
|
||||
assign readdata_qual[i * 8 +: 8] = (rw_hazard && byte_enable[i]) ? write_data[i * 8 +: 8] : read_data[i * 8 +: 8];
|
||||
end
|
||||
@@ -129,7 +129,7 @@ module VX_data_access #(
|
||||
assign readdata_out = readdata_qual;
|
||||
end
|
||||
|
||||
if (`WORD_SELECT_WIDTH != 0) begin
|
||||
if (`WORD_SELECT_BITS != 0) begin
|
||||
wire [`WORD_WIDTH-1:0] readword = readdata_qual[rwsel_in * `WORD_WIDTH +: `WORD_WIDTH];
|
||||
for (genvar i = 0; i < WORD_SIZE; i++) begin
|
||||
assign readword_out[i * 8 +: 8] = readword[i * 8 +: 8] & {8{rbyteen_in[i]}};
|
||||
|
||||
18
hw/rtl/cache/VX_data_store.v
vendored
18
hw/rtl/cache/VX_data_store.v
vendored
@@ -4,7 +4,7 @@ module VX_data_store #(
|
||||
// Size of cache in bytes
|
||||
parameter CACHE_SIZE = 1,
|
||||
// Size of line inside a bank in bytes
|
||||
parameter BANK_LINE_SIZE = 1,
|
||||
parameter CACHE_LINE_SIZE = 1,
|
||||
// Number of banks
|
||||
parameter NUM_BANKS = 1,
|
||||
// Size of a word in bytes
|
||||
@@ -18,18 +18,18 @@ module VX_data_store #(
|
||||
|
||||
input wire write_enable,
|
||||
input wire write_fill,
|
||||
input wire[BANK_LINE_SIZE-1:0] byte_enable,
|
||||
input wire[CACHE_LINE_SIZE-1:0] byte_enable,
|
||||
input wire[`LINE_SELECT_BITS-1:0] write_addr,
|
||||
input wire[`BANK_LINE_WIDTH-1:0] write_data,
|
||||
input wire[`CACHE_LINE_WIDTH-1:0] write_data,
|
||||
|
||||
input wire[`LINE_SELECT_BITS-1:0] read_addr,
|
||||
output wire[`BANK_LINE_WORDS-1:0][WORD_SIZE-1:0] read_dirtyb,
|
||||
output wire[`BANK_LINE_WIDTH-1:0] read_data
|
||||
output wire[`WORDS_PER_LINE-1:0][WORD_SIZE-1:0] read_dirtyb,
|
||||
output wire[`CACHE_LINE_WIDTH-1:0] read_data
|
||||
);
|
||||
`UNUSED_VAR (reset)
|
||||
|
||||
if (WRITE_ENABLE) begin
|
||||
reg [`BANK_LINE_WORDS-1:0][WORD_SIZE-1:0] dirtyb[`BANK_LINE_COUNT-1:0];
|
||||
reg [`WORDS_PER_LINE-1:0][WORD_SIZE-1:0] dirtyb[`LINES_PER_BANK-1:0];
|
||||
always @(posedge clk) begin
|
||||
if (write_enable) begin
|
||||
dirtyb[write_addr] <= write_fill ? 0 : (dirtyb[write_addr] | byte_enable);
|
||||
@@ -43,9 +43,9 @@ module VX_data_store #(
|
||||
end
|
||||
|
||||
VX_dp_ram #(
|
||||
.DATAW(BANK_LINE_SIZE * 8),
|
||||
.SIZE(`BANK_LINE_COUNT),
|
||||
.BYTEENW(BANK_LINE_SIZE),
|
||||
.DATAW(CACHE_LINE_SIZE * 8),
|
||||
.SIZE(`LINES_PER_BANK),
|
||||
.BYTEENW(CACHE_LINE_SIZE),
|
||||
.RWCHECK(1)
|
||||
) data (
|
||||
.clk(clk),
|
||||
|
||||
2
hw/rtl/cache/VX_miss_resrv.v
vendored
2
hw/rtl/cache/VX_miss_resrv.v
vendored
@@ -5,7 +5,7 @@ module VX_miss_resrv #(
|
||||
parameter BANK_ID = 0,
|
||||
|
||||
// Size of line inside a bank in bytes
|
||||
parameter BANK_LINE_SIZE = 1,
|
||||
parameter CACHE_LINE_SIZE = 1,
|
||||
// Number of banks
|
||||
parameter NUM_BANKS = 1,
|
||||
// Size of a word in bytes
|
||||
|
||||
20
hw/rtl/cache/VX_tag_access.v
vendored
20
hw/rtl/cache/VX_tag_access.v
vendored
@@ -2,22 +2,21 @@
|
||||
|
||||
module VX_tag_access #(
|
||||
parameter CACHE_ID = 0,
|
||||
parameter BANK_ID = 0,
|
||||
|
||||
parameter BANK_ID = 0,
|
||||
// Size of cache in bytes
|
||||
parameter CACHE_SIZE = 1,
|
||||
// Size of line inside a bank in bytes
|
||||
parameter BANK_LINE_SIZE = 1,
|
||||
parameter CACHE_LINE_SIZE = 1,
|
||||
// Number of banks
|
||||
parameter NUM_BANKS = 1,
|
||||
// Size of a word in bytes
|
||||
parameter WORD_SIZE = 1,
|
||||
|
||||
parameter WORD_SIZE = 1,
|
||||
// Enable cache writeable
|
||||
parameter WRITE_ENABLE = 0,
|
||||
|
||||
// size of tag id in core request tag
|
||||
parameter CORE_TAG_ID_BITS = 0
|
||||
parameter CORE_TAG_ID_BITS = 0,
|
||||
// bank offset from beginning of index range
|
||||
parameter BANK_ADDR_OFFSET = 0
|
||||
) (
|
||||
input wire clk,
|
||||
input wire reset,
|
||||
@@ -53,14 +52,15 @@ module VX_tag_access #(
|
||||
wire do_write;
|
||||
wire do_invalidate;
|
||||
|
||||
wire [`TAG_SELECT_BITS-1:0] addrtag = addr_in [`TAG_LINE_ADDR_RNG];
|
||||
wire [`TAG_SELECT_BITS-1:0] addrtag = `LINE_TAG_ADDR(addr_in);
|
||||
wire [`LINE_SELECT_BITS-1:0] addrline = addr_in [`LINE_SELECT_BITS-1:0];
|
||||
|
||||
VX_tag_store #(
|
||||
.CACHE_SIZE (CACHE_SIZE),
|
||||
.BANK_LINE_SIZE (BANK_LINE_SIZE),
|
||||
.CACHE_LINE_SIZE (CACHE_LINE_SIZE),
|
||||
.NUM_BANKS (NUM_BANKS),
|
||||
.WORD_SIZE (WORD_SIZE)
|
||||
.WORD_SIZE (WORD_SIZE),
|
||||
.BANK_ADDR_OFFSET (BANK_ADDR_OFFSET)
|
||||
) tag_store (
|
||||
.clk (clk),
|
||||
.reset (reset),
|
||||
|
||||
18
hw/rtl/cache/VX_tag_store.v
vendored
18
hw/rtl/cache/VX_tag_store.v
vendored
@@ -2,13 +2,15 @@
|
||||
|
||||
module VX_tag_store #(
|
||||
// Size of cache in bytes
|
||||
parameter CACHE_SIZE = 1,
|
||||
parameter CACHE_SIZE = 1,
|
||||
// Size of line inside a bank in bytes
|
||||
parameter BANK_LINE_SIZE = 1,
|
||||
parameter CACHE_LINE_SIZE = 1,
|
||||
// Number of banks
|
||||
parameter NUM_BANKS = 1,
|
||||
parameter NUM_BANKS = 1,
|
||||
// Size of a word in bytes
|
||||
parameter WORD_SIZE = 1
|
||||
parameter WORD_SIZE = 1,
|
||||
// bank offset from beginning of index range
|
||||
parameter BANK_ADDR_OFFSET = 0
|
||||
) (
|
||||
input wire clk,
|
||||
input wire reset,
|
||||
@@ -24,12 +26,12 @@ module VX_tag_store #(
|
||||
output wire read_valid,
|
||||
output wire read_dirty
|
||||
);
|
||||
reg [`BANK_LINE_COUNT-1:0] dirty;
|
||||
reg [`BANK_LINE_COUNT-1:0] valid;
|
||||
reg [`LINES_PER_BANK-1:0] dirty;
|
||||
reg [`LINES_PER_BANK-1:0] valid;
|
||||
|
||||
always @(posedge clk) begin
|
||||
if (reset) begin
|
||||
for (integer i = 0; i < `BANK_LINE_COUNT; i++) begin
|
||||
for (integer i = 0; i < `LINES_PER_BANK; i++) begin
|
||||
valid[i] <= 0;
|
||||
dirty[i] <= 0;
|
||||
end
|
||||
@@ -47,7 +49,7 @@ module VX_tag_store #(
|
||||
|
||||
VX_dp_ram #(
|
||||
.DATAW(`TAG_SELECT_BITS),
|
||||
.SIZE(`BANK_LINE_COUNT),
|
||||
.SIZE(`LINES_PER_BANK),
|
||||
.FASTRAM(1),
|
||||
.RWCHECK(1)
|
||||
) tags (
|
||||
|
||||
Reference in New Issue
Block a user