adding stream arbiter
This commit is contained in:
28
hw/rtl/cache/VX_bank.v
vendored
28
hw/rtl/cache/VX_bank.v
vendored
@@ -13,7 +13,7 @@ module VX_bank #(
|
||||
// Size of a word in bytes
|
||||
parameter WORD_SIZE = 1,
|
||||
// Number of Word requests per cycle
|
||||
parameter NUM_REQUESTS = 1,
|
||||
parameter NUM_REQS = 1,
|
||||
|
||||
// Core Request Queue Size
|
||||
parameter CREQ_SIZE = 1,
|
||||
@@ -55,13 +55,13 @@ module VX_bank #(
|
||||
input wire reset,
|
||||
|
||||
// Core Request
|
||||
input wire [NUM_REQUESTS-1:0] core_req_valid,
|
||||
input wire [`CORE_REQ_TAG_COUNT-1:0] core_req_rw,
|
||||
input wire [NUM_REQUESTS-1:0][WORD_SIZE-1:0] core_req_byteen,
|
||||
input wire [NUM_REQUESTS-1:0][`WORD_ADDR_WIDTH-1:0] core_req_addr,
|
||||
input wire [NUM_REQUESTS-1:0][`WORD_WIDTH-1:0] core_req_data,
|
||||
input wire [`CORE_REQ_TAG_COUNT-1:0][CORE_TAG_WIDTH-1:0] core_req_tag,
|
||||
output wire core_req_ready,
|
||||
input wire [NUM_REQS-1:0] core_req_valid,
|
||||
input wire [`CORE_REQ_TAG_COUNT-1:0] core_req_rw,
|
||||
input wire [NUM_REQS-1:0][WORD_SIZE-1:0] core_req_byteen,
|
||||
input wire [NUM_REQS-1:0][`WORD_ADDR_WIDTH-1:0] core_req_addr,
|
||||
input wire [NUM_REQS-1:0][`WORD_WIDTH-1:0] core_req_data,
|
||||
input wire [`CORE_REQ_TAG_COUNT-1:0][CORE_TAG_WIDTH-1:0] core_req_tag,
|
||||
output wire core_req_ready,
|
||||
|
||||
// Core Response
|
||||
output wire core_rsp_valid,
|
||||
@@ -152,7 +152,8 @@ module VX_bank #(
|
||||
|
||||
VX_generic_queue #(
|
||||
.DATAW(`LINE_ADDR_WIDTH + 1 + SNP_TAG_WIDTH),
|
||||
.SIZE(SNRQ_SIZE)
|
||||
.SIZE(SNRQ_SIZE),
|
||||
.BUFFERED(1)
|
||||
) snp_req_queue (
|
||||
.clk (clk),
|
||||
.reset (reset),
|
||||
@@ -192,7 +193,8 @@ module VX_bank #(
|
||||
|
||||
VX_generic_queue #(
|
||||
.DATAW(`LINE_ADDR_WIDTH + $bits(dram_rsp_data)),
|
||||
.SIZE(DRFQ_SIZE)
|
||||
.SIZE(DRFQ_SIZE),
|
||||
.BUFFERED(1)
|
||||
) dfp_queue (
|
||||
.clk (clk),
|
||||
.reset (reset),
|
||||
@@ -231,7 +233,7 @@ module VX_bank #(
|
||||
|
||||
VX_bank_core_req_arb #(
|
||||
.WORD_SIZE (WORD_SIZE),
|
||||
.NUM_REQUESTS (NUM_REQUESTS),
|
||||
.NUM_REQS (NUM_REQS),
|
||||
.CREQ_SIZE (CREQ_SIZE),
|
||||
.CORE_TAG_WIDTH (CORE_TAG_WIDTH),
|
||||
.CORE_TAG_ID_BITS (CORE_TAG_ID_BITS)
|
||||
@@ -704,7 +706,7 @@ end
|
||||
.BANK_LINE_SIZE (BANK_LINE_SIZE),
|
||||
.NUM_BANKS (NUM_BANKS),
|
||||
.WORD_SIZE (WORD_SIZE),
|
||||
.NUM_REQUESTS (NUM_REQUESTS),
|
||||
.NUM_REQS (NUM_REQS),
|
||||
.MSHR_SIZE (MSHR_SIZE),
|
||||
.CORE_TAG_WIDTH (CORE_TAG_WIDTH),
|
||||
.SNP_TAG_WIDTH (SNP_TAG_WIDTH)
|
||||
@@ -960,7 +962,7 @@ end
|
||||
if (creq_rw_st0)
|
||||
$display("%t: cache%0d:%0d core-wr-req: addr=%0h, tag=%0h, tid=%0d, byteen=%b, data=%0h, wid=%0d, PC=%0h", $time, CACHE_ID, BANK_ID, `LINE_TO_BYTE_ADDR(addr_st0, BANK_ID), creq_tag_st0, creq_tid_st0, creq_byteen_st0, creq_writeword_st0, debug_wid_st0, debug_pc_st0);
|
||||
else
|
||||
$display("%t: cache%0d:%0d core-rd-req: addr=%0h, tag=%0h, tid=%0d, byteen=%b, wid=%0d, PC=%0h", $time, CACHE_ID, BANK_ID, `LINE_TO_BYTE_ADDR(addr_st0, BANK_ID), creq_tag_st0, creq_tid_st0, creq_byteen_st0, creq_writeword_st0, debug_wid_st0, debug_pc_st0);
|
||||
$display("%t: cache%0d:%0d core-rd-req: addr=%0h, tag=%0h, tid=%0d, byteen=%b, wid=%0d, PC=%0h", $time, CACHE_ID, BANK_ID, `LINE_TO_BYTE_ADDR(addr_st0, BANK_ID), creq_tag_st0, creq_tid_st0, creq_byteen_st0, debug_wid_st0, debug_pc_st0);
|
||||
end
|
||||
if (snrq_pop) begin
|
||||
$display("%t: cache%0d:%0d snp-req: addr=%0h, tag=%0h, invalidate=%0d", $time, CACHE_ID, BANK_ID, `LINE_TO_BYTE_ADDR(addr_st0, BANK_ID), snrq_tag_st0, snrq_inv_st0);
|
||||
|
||||
62
hw/rtl/cache/VX_bank_core_req_arb.v
vendored
62
hw/rtl/cache/VX_bank_core_req_arb.v
vendored
@@ -2,27 +2,27 @@
|
||||
|
||||
module VX_bank_core_req_arb #(
|
||||
// Size of a word in bytes
|
||||
parameter WORD_SIZE = 1,
|
||||
parameter WORD_SIZE = 1,
|
||||
// Number of Word requests per cycle
|
||||
parameter NUM_REQUESTS = 1,
|
||||
parameter NUM_REQS = 1,
|
||||
// Core Request Queue Size
|
||||
parameter CREQ_SIZE = 1,
|
||||
parameter CREQ_SIZE = 1,
|
||||
// core request tag size
|
||||
parameter CORE_TAG_WIDTH = 1,
|
||||
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
|
||||
) (
|
||||
input wire clk,
|
||||
input wire reset,
|
||||
|
||||
// Enqueue
|
||||
input wire push,
|
||||
input wire [NUM_REQUESTS-1:0] valids_in,
|
||||
input wire [`CORE_REQ_TAG_COUNT-1:0][CORE_TAG_WIDTH-1:0] tag_in,
|
||||
input wire [NUM_REQUESTS-1:0][`WORD_ADDR_WIDTH-1:0] addr_in,
|
||||
input wire [`CORE_REQ_TAG_COUNT-1:0] rw_in,
|
||||
input wire [NUM_REQUESTS-1:0][WORD_SIZE-1:0] byteen_in,
|
||||
input wire [NUM_REQUESTS-1:0][`WORD_WIDTH-1:0] writedata_in,
|
||||
input wire push,
|
||||
input wire [NUM_REQS-1:0] valids_in,
|
||||
input wire [`CORE_REQ_TAG_COUNT-1:0][CORE_TAG_WIDTH-1:0] tag_in,
|
||||
input wire [NUM_REQS-1:0][`WORD_ADDR_WIDTH-1:0] addr_in,
|
||||
input wire [`CORE_REQ_TAG_COUNT-1:0] rw_in,
|
||||
input wire [NUM_REQS-1:0][WORD_SIZE-1:0] byteen_in,
|
||||
input wire [NUM_REQS-1:0][`WORD_WIDTH-1:0] writedata_in,
|
||||
|
||||
// Dequeue
|
||||
input wire pop,
|
||||
@@ -38,16 +38,16 @@ module VX_bank_core_req_arb #(
|
||||
output wire full
|
||||
);
|
||||
|
||||
wire [NUM_REQUESTS-1:0] q_valids;
|
||||
wire [`CORE_REQ_TAG_COUNT-1:0][CORE_TAG_WIDTH-1:0] q_tag;
|
||||
wire [`CORE_REQ_TAG_COUNT-1:0] q_rw;
|
||||
wire [NUM_REQUESTS-1:0][WORD_SIZE-1:0] q_byteen;
|
||||
wire [NUM_REQUESTS-1:0][`WORD_ADDR_WIDTH-1:0] q_addr;
|
||||
wire [NUM_REQUESTS-1:0][`WORD_WIDTH-1:0] q_writedata;
|
||||
wire q_push;
|
||||
wire q_pop;
|
||||
wire q_empty;
|
||||
wire q_full;
|
||||
wire [NUM_REQS-1:0] q_valids;
|
||||
wire [`CORE_REQ_TAG_COUNT-1:0][CORE_TAG_WIDTH-1:0] q_tag;
|
||||
wire [`CORE_REQ_TAG_COUNT-1:0] q_rw;
|
||||
wire [NUM_REQS-1:0][WORD_SIZE-1:0] q_byteen;
|
||||
wire [NUM_REQS-1:0][`WORD_ADDR_WIDTH-1:0] q_addr;
|
||||
wire [NUM_REQS-1:0][`WORD_WIDTH-1:0] q_writedata;
|
||||
wire q_push;
|
||||
wire q_pop;
|
||||
wire q_empty;
|
||||
wire q_full;
|
||||
|
||||
always @(*) begin
|
||||
assert(!push || (| valids_in));
|
||||
@@ -70,7 +70,7 @@ module VX_bank_core_req_arb #(
|
||||
`UNUSED_PIN (size)
|
||||
);
|
||||
|
||||
if (NUM_REQUESTS > 1) begin
|
||||
if (NUM_REQS > 1) begin
|
||||
|
||||
reg [`REQS_BITS-1:0] sel_idx, sel_idx_r;
|
||||
reg [CORE_TAG_WIDTH-1:0] sel_tag, sel_tag_r;
|
||||
@@ -79,16 +79,16 @@ module VX_bank_core_req_arb #(
|
||||
reg [WORD_SIZE-1:0] sel_byteen, sel_byteen_r;
|
||||
reg [`WORD_WIDTH-1:0] sel_writedata, sel_writedata_r;
|
||||
|
||||
reg [$clog2(NUM_REQUESTS+1)-1:0] q_valids_cnt_r;
|
||||
wire [$clog2(NUM_REQUESTS+1)-1:0] q_valids_cnt;
|
||||
reg [$clog2(NUM_REQS+1)-1:0] q_valids_cnt_r;
|
||||
wire [$clog2(NUM_REQS+1)-1:0] q_valids_cnt;
|
||||
|
||||
reg [NUM_REQUESTS-1:0] pop_mask;
|
||||
reg [NUM_REQS-1:0] pop_mask;
|
||||
reg fast_track;
|
||||
|
||||
assign q_push = push;
|
||||
assign q_pop = pop && (q_valids_cnt_r == 1 || q_valids_cnt_r == 2) && !fast_track;
|
||||
|
||||
wire [NUM_REQUESTS-1:0] requests = q_valids & ~pop_mask;
|
||||
wire [NUM_REQS-1:0] requests = q_valids & ~pop_mask;
|
||||
|
||||
always @(*) begin
|
||||
sel_idx = 0;
|
||||
@@ -98,9 +98,9 @@ module VX_bank_core_req_arb #(
|
||||
sel_byteen = 'x;
|
||||
sel_writedata = 'x;
|
||||
|
||||
for (integer i = 0; i < NUM_REQUESTS; i++) begin
|
||||
for (integer i = 0; i < NUM_REQS; i++) begin
|
||||
if (requests[i]) begin
|
||||
sel_idx = `REQS_BITS'(i);
|
||||
sel_idx = `REQS_BITS'(i);
|
||||
sel_addr = q_addr[i];
|
||||
if (0 == CORE_TAG_ID_BITS) begin
|
||||
sel_tag = q_tag[i];
|
||||
@@ -114,7 +114,7 @@ module VX_bank_core_req_arb #(
|
||||
end
|
||||
|
||||
VX_countones #(
|
||||
.N(NUM_REQUESTS)
|
||||
.N(NUM_REQS)
|
||||
) counter (
|
||||
.valids (q_valids),
|
||||
.count (q_valids_cnt)
|
||||
@@ -129,7 +129,7 @@ module VX_bank_core_req_arb #(
|
||||
if (!q_empty
|
||||
&& ((0 == q_valids_cnt_r) || (pop && fast_track))) begin
|
||||
q_valids_cnt_r <= q_valids_cnt;
|
||||
pop_mask <= (NUM_REQUESTS'(1) << sel_idx);
|
||||
pop_mask <= (NUM_REQS'(1) << sel_idx);
|
||||
fast_track <= 0;
|
||||
end else if (pop) begin
|
||||
q_valids_cnt_r <= q_valids_cnt_r - 1;
|
||||
|
||||
111
hw/rtl/cache/VX_cache.v
vendored
111
hw/rtl/cache/VX_cache.v
vendored
@@ -12,7 +12,7 @@ module VX_cache #(
|
||||
// Size of a word in bytes
|
||||
parameter WORD_SIZE = 4,
|
||||
// Number of Word requests per cycle
|
||||
parameter NUM_REQUESTS = 4,
|
||||
parameter NUM_REQS = 4,
|
||||
|
||||
// Core Request Queue Size
|
||||
parameter CREQ_SIZE = 4,
|
||||
@@ -57,19 +57,19 @@ module VX_cache #(
|
||||
input wire reset,
|
||||
|
||||
// Core request
|
||||
input wire [NUM_REQUESTS-1:0] core_req_valid,
|
||||
input wire [`CORE_REQ_TAG_COUNT-1:0] core_req_rw,
|
||||
input wire [NUM_REQUESTS-1:0][WORD_SIZE-1:0] core_req_byteen,
|
||||
input wire [NUM_REQUESTS-1:0][`WORD_ADDR_WIDTH-1:0] core_req_addr,
|
||||
input wire [NUM_REQUESTS-1:0][`WORD_WIDTH-1:0] core_req_data,
|
||||
input wire [NUM_REQS-1:0] core_req_valid,
|
||||
input wire [`CORE_REQ_TAG_COUNT-1:0] core_req_rw,
|
||||
input wire [NUM_REQS-1:0][WORD_SIZE-1:0] core_req_byteen,
|
||||
input wire [NUM_REQS-1:0][`WORD_ADDR_WIDTH-1:0] core_req_addr,
|
||||
input wire [NUM_REQS-1:0][`WORD_WIDTH-1:0] core_req_data,
|
||||
input wire [`CORE_REQ_TAG_COUNT-1:0][CORE_TAG_WIDTH-1:0] core_req_tag,
|
||||
output wire core_req_ready,
|
||||
output wire core_req_ready,
|
||||
|
||||
// Core response
|
||||
output wire [NUM_REQUESTS-1:0] core_rsp_valid,
|
||||
output wire [NUM_REQUESTS-1:0][`WORD_WIDTH-1:0] core_rsp_data,
|
||||
output wire [NUM_REQS-1:0] core_rsp_valid,
|
||||
output wire [NUM_REQS-1:0][`WORD_WIDTH-1:0] core_rsp_data,
|
||||
output wire [`CORE_REQ_TAG_COUNT-1:0][CORE_TAG_WIDTH-1:0] core_rsp_tag,
|
||||
input wire core_rsp_ready,
|
||||
input wire core_rsp_ready,
|
||||
|
||||
// DRAM request
|
||||
output wire dram_req_valid,
|
||||
@@ -101,9 +101,9 @@ module VX_cache #(
|
||||
output wire [NUM_BANKS-1:0] miss_vec
|
||||
);
|
||||
|
||||
`STATIC_ASSERT(NUM_BANKS <= NUM_REQUESTS, ("invalid value"))
|
||||
`STATIC_ASSERT(NUM_BANKS <= NUM_REQS, ("invalid value"))
|
||||
|
||||
wire [NUM_BANKS-1:0][NUM_REQUESTS-1:0] per_bank_valid;
|
||||
wire [NUM_BANKS-1:0][NUM_REQS-1:0] per_bank_valid;
|
||||
|
||||
wire [NUM_BANKS-1:0] per_bank_core_req_ready;
|
||||
|
||||
@@ -141,7 +141,7 @@ module VX_cache #(
|
||||
.BANK_LINE_SIZE (BANK_LINE_SIZE),
|
||||
.NUM_BANKS (NUM_BANKS),
|
||||
.WORD_SIZE (WORD_SIZE),
|
||||
.NUM_REQUESTS (NUM_REQUESTS)
|
||||
.NUM_REQS (NUM_REQS)
|
||||
) cache_core_req_bank_sel (
|
||||
.core_req_valid (core_req_valid),
|
||||
.core_req_addr (core_req_addr),
|
||||
@@ -158,13 +158,13 @@ module VX_cache #(
|
||||
end
|
||||
|
||||
for (genvar i = 0; i < NUM_BANKS; i++) begin
|
||||
wire [NUM_REQUESTS-1:0] curr_bank_core_req_valid;
|
||||
wire [`CORE_REQ_TAG_COUNT-1:0] curr_bank_core_req_rw;
|
||||
wire [NUM_REQUESTS-1:0][WORD_SIZE-1:0] curr_bank_core_req_byteen;
|
||||
wire [NUM_REQUESTS-1:0][`WORD_ADDR_WIDTH-1:0] curr_bank_core_req_addr;
|
||||
wire [`CORE_REQ_TAG_COUNT-1:0][CORE_TAG_WIDTH-1:0] curr_bank_core_req_tag;
|
||||
wire [NUM_REQUESTS-1:0][`WORD_WIDTH-1:0] curr_bank_core_req_data;
|
||||
wire curr_bank_core_req_ready;
|
||||
wire [NUM_REQS-1:0] curr_bank_core_req_valid;
|
||||
wire [`CORE_REQ_TAG_COUNT-1:0] curr_bank_core_req_rw;
|
||||
wire [NUM_REQS-1:0][WORD_SIZE-1:0] curr_bank_core_req_byteen;
|
||||
wire [NUM_REQS-1:0][`WORD_ADDR_WIDTH-1:0] curr_bank_core_req_addr;
|
||||
wire [`CORE_REQ_TAG_COUNT-1:0][CORE_TAG_WIDTH-1:0] curr_bank_core_req_tag;
|
||||
wire [NUM_REQS-1:0][`WORD_WIDTH-1:0] curr_bank_core_req_data;
|
||||
wire curr_bank_core_req_ready;
|
||||
|
||||
wire curr_bank_core_rsp_valid;
|
||||
wire [`REQS_BITS-1:0] curr_bank_core_rsp_tid;
|
||||
@@ -197,7 +197,7 @@ module VX_cache #(
|
||||
wire curr_bank_miss;
|
||||
|
||||
// Core Req
|
||||
assign curr_bank_core_req_valid = (per_bank_valid[i] & {NUM_REQUESTS{core_req_ready}});
|
||||
assign curr_bank_core_req_valid = (per_bank_valid[i] & {NUM_REQS{core_req_ready}});
|
||||
assign curr_bank_core_req_addr = core_req_addr;
|
||||
assign curr_bank_core_req_rw = core_req_rw;
|
||||
assign curr_bank_core_req_byteen = core_req_byteen;
|
||||
@@ -262,7 +262,7 @@ module VX_cache #(
|
||||
.BANK_LINE_SIZE (BANK_LINE_SIZE),
|
||||
.NUM_BANKS (NUM_BANKS),
|
||||
.WORD_SIZE (WORD_SIZE),
|
||||
.NUM_REQUESTS (NUM_REQUESTS),
|
||||
.NUM_REQS (NUM_REQS),
|
||||
.CREQ_SIZE (CREQ_SIZE),
|
||||
.MSHR_SIZE (MSHR_SIZE),
|
||||
.DRFQ_SIZE (DRFQ_SIZE),
|
||||
@@ -331,7 +331,7 @@ module VX_cache #(
|
||||
VX_cache_core_rsp_merge #(
|
||||
.NUM_BANKS (NUM_BANKS),
|
||||
.WORD_SIZE (WORD_SIZE),
|
||||
.NUM_REQUESTS (NUM_REQUESTS),
|
||||
.NUM_REQS (NUM_REQS),
|
||||
.CORE_TAG_WIDTH (CORE_TAG_WIDTH),
|
||||
.CORE_TAG_ID_BITS (CORE_TAG_ID_BITS)
|
||||
) cache_core_rsp_merge (
|
||||
@@ -349,26 +349,25 @@ module VX_cache #(
|
||||
);
|
||||
|
||||
if (DRAM_ENABLE) begin
|
||||
VX_cache_dram_req_arb #(
|
||||
.BANK_LINE_SIZE (BANK_LINE_SIZE),
|
||||
.NUM_BANKS (NUM_BANKS),
|
||||
.WORD_SIZE (WORD_SIZE)
|
||||
) cache_dram_req_arb (
|
||||
.clk (clk),
|
||||
.reset (reset),
|
||||
.per_bank_dram_req_valid (per_bank_dram_req_valid),
|
||||
.per_bank_dram_req_rw (per_bank_dram_req_rw),
|
||||
.per_bank_dram_req_byteen (per_bank_dram_req_byteen),
|
||||
.per_bank_dram_req_addr (per_bank_dram_req_addr),
|
||||
.per_bank_dram_req_data (per_bank_dram_req_data),
|
||||
.per_bank_dram_req_ready (per_bank_dram_req_ready),
|
||||
.dram_req_valid (dram_req_valid),
|
||||
.dram_req_rw (dram_req_rw),
|
||||
.dram_req_byteen (dram_req_byteen),
|
||||
.dram_req_addr (dram_req_addr),
|
||||
.dram_req_data (dram_req_data),
|
||||
.dram_req_ready (dram_req_ready)
|
||||
);
|
||||
wire [NUM_BANKS-1:0][(`DRAM_ADDR_WIDTH + 1 + BANK_LINE_SIZE + `BANK_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),
|
||||
.BUFFERED(NUM_BANKS >= 4)
|
||||
) dram_req_arb (
|
||||
.clk (clk),
|
||||
.reset (reset),
|
||||
.valid_in (per_bank_dram_req_valid),
|
||||
.valid_out (dram_req_valid),
|
||||
.data_in (data_in),
|
||||
.data_out ({dram_req_addr, dram_req_rw, dram_req_byteen, dram_req_data}),
|
||||
.ready_in (per_bank_dram_req_ready),
|
||||
.ready_out (dram_req_ready)
|
||||
);
|
||||
end else begin
|
||||
`UNUSED_VAR (per_bank_dram_req_valid)
|
||||
`UNUSED_VAR (per_bank_dram_req_rw)
|
||||
@@ -385,19 +384,19 @@ module VX_cache #(
|
||||
end
|
||||
|
||||
if (FLUSH_ENABLE) begin
|
||||
VX_snp_rsp_arb #(
|
||||
.NUM_BANKS (NUM_BANKS),
|
||||
.BANK_LINE_SIZE (BANK_LINE_SIZE),
|
||||
.SNP_TAG_WIDTH (SNP_TAG_WIDTH)
|
||||
) snp_rsp_arb (
|
||||
.clk (clk),
|
||||
.reset (reset),
|
||||
.per_bank_snp_rsp_valid (per_bank_snp_rsp_valid),
|
||||
.per_bank_snp_rsp_tag (per_bank_snp_rsp_tag),
|
||||
.per_bank_snp_rsp_ready (per_bank_snp_rsp_ready),
|
||||
.snp_rsp_valid (snp_rsp_valid),
|
||||
.snp_rsp_tag (snp_rsp_tag),
|
||||
.snp_rsp_ready (snp_rsp_ready)
|
||||
VX_stream_arbiter #(
|
||||
.NUM_REQS(NUM_BANKS),
|
||||
.DATAW(SNP_TAG_WIDTH),
|
||||
.BUFFERED(NUM_BANKS >= 4)
|
||||
) snp_rsp_arb (
|
||||
.clk (clk),
|
||||
.reset (reset),
|
||||
.valid_in (per_bank_snp_rsp_valid),
|
||||
.valid_out (snp_rsp_valid),
|
||||
.data_in (per_bank_snp_rsp_tag),
|
||||
.data_out (snp_rsp_tag),
|
||||
.ready_in (per_bank_snp_rsp_ready),
|
||||
.ready_out (snp_rsp_ready)
|
||||
);
|
||||
end else begin
|
||||
`UNUSED_VAR (per_bank_snp_rsp_valid)
|
||||
|
||||
4
hw/rtl/cache/VX_cache_config.vh
vendored
4
hw/rtl/cache/VX_cache_config.vh
vendored
@@ -9,7 +9,7 @@
|
||||
|
||||
`define REQ_TAG_WIDTH `MAX(CORE_TAG_WIDTH, SNP_TAG_WIDTH)
|
||||
|
||||
`define REQS_BITS `LOG2UP(NUM_REQUESTS)
|
||||
`define REQS_BITS `LOG2UP(NUM_REQS)
|
||||
|
||||
// tag rw byteen tid
|
||||
`define REQ_INST_META_WIDTH (`REQ_TAG_WIDTH + 1 + WORD_SIZE + `REQS_BITS)
|
||||
@@ -70,7 +70,7 @@
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
`define CORE_REQ_TAG_COUNT ((CORE_TAG_ID_BITS != 0) ? 1 : NUM_REQUESTS)
|
||||
`define CORE_REQ_TAG_COUNT ((CORE_TAG_ID_BITS != 0) ? 1 : NUM_REQS)
|
||||
|
||||
`define DRAM_ADDR_BANK(x) x[`BANK_SELECT_BITS-1:0]
|
||||
|
||||
|
||||
24
hw/rtl/cache/VX_cache_core_req_bank_sel.v
vendored
24
hw/rtl/cache/VX_cache_core_req_bank_sel.v
vendored
@@ -2,23 +2,23 @@
|
||||
|
||||
module VX_cache_core_req_bank_sel #(
|
||||
// Size of line inside a bank in bytes
|
||||
parameter BANK_LINE_SIZE = 1,
|
||||
parameter BANK_LINE_SIZE = 1,
|
||||
// Size of a word in bytes
|
||||
parameter WORD_SIZE = 1,
|
||||
parameter WORD_SIZE = 1,
|
||||
// Number of banks
|
||||
parameter NUM_BANKS = 1,
|
||||
parameter NUM_BANKS = 1,
|
||||
// Number of Word requests per cycle
|
||||
parameter NUM_REQUESTS = 1
|
||||
parameter NUM_REQS = 1
|
||||
) (
|
||||
input wire [NUM_REQUESTS-1:0] core_req_valid,
|
||||
input wire [NUM_REQUESTS-1:0][`WORD_ADDR_WIDTH-1:0] core_req_addr,
|
||||
output wire core_req_ready,
|
||||
input wire [NUM_REQS-1:0] core_req_valid,
|
||||
input wire [NUM_REQS-1:0][`WORD_ADDR_WIDTH-1:0] core_req_addr,
|
||||
output wire core_req_ready,
|
||||
|
||||
output wire [NUM_BANKS-1:0][NUM_REQUESTS-1:0] per_bank_valid,
|
||||
input wire [NUM_BANKS-1:0] per_bank_ready
|
||||
output wire [NUM_BANKS-1:0][NUM_REQS-1:0] per_bank_valid,
|
||||
input wire [NUM_BANKS-1:0] per_bank_ready
|
||||
);
|
||||
if (NUM_BANKS > 1) begin
|
||||
reg [NUM_BANKS-1:0][NUM_REQUESTS-1:0] per_bank_valid_r;
|
||||
reg [NUM_BANKS-1:0][NUM_REQS-1:0] per_bank_valid_r;
|
||||
reg [NUM_BANKS-1:0] per_bank_ready_ignore;
|
||||
reg [NUM_BANKS-1:0] per_bank_ready_other;
|
||||
|
||||
@@ -34,14 +34,14 @@ module VX_cache_core_req_bank_sel #(
|
||||
end
|
||||
end
|
||||
|
||||
for (integer i = 0; i < NUM_REQUESTS; i++) begin
|
||||
for (integer i = 0; i < NUM_REQS; i++) begin
|
||||
per_bank_valid_r[core_req_addr[i][`BANK_SELECT_ADDR_RNG]][i] = core_req_valid[i];
|
||||
per_bank_ready_ignore[core_req_addr[i][`BANK_SELECT_ADDR_RNG]] = 1'b0;
|
||||
end
|
||||
end
|
||||
|
||||
for (genvar i = 0; i < NUM_BANKS; i++) begin
|
||||
for (genvar j = 0; j < NUM_REQUESTS; j++) begin
|
||||
for (genvar j = 0; j < NUM_REQS; j++) begin
|
||||
assign per_bank_valid[i][j] = per_bank_valid_r[i][j] & per_bank_ready_other[i];
|
||||
end
|
||||
end
|
||||
|
||||
100
hw/rtl/cache/VX_cache_core_rsp_merge.v
vendored
100
hw/rtl/cache/VX_cache_core_rsp_merge.v
vendored
@@ -2,69 +2,68 @@
|
||||
|
||||
module VX_cache_core_rsp_merge #(
|
||||
// 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,
|
||||
// Number of Word requests per cycle
|
||||
parameter NUM_REQUESTS = 1,
|
||||
parameter NUM_REQS = 1,
|
||||
// core request tag size
|
||||
parameter CORE_TAG_WIDTH = 1,
|
||||
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
|
||||
) (
|
||||
input wire clk,
|
||||
input wire reset,
|
||||
input wire clk,
|
||||
input wire reset,
|
||||
|
||||
// Per Bank WB
|
||||
input wire [NUM_BANKS-1:0] per_bank_core_rsp_valid,
|
||||
input wire [NUM_BANKS-1:0][CORE_TAG_WIDTH-1:0] per_bank_core_rsp_tag,
|
||||
input wire [NUM_BANKS-1:0][`REQS_BITS-1:0] per_bank_core_rsp_tid,
|
||||
input wire [NUM_BANKS-1:0][`WORD_WIDTH-1:0] per_bank_core_rsp_data,
|
||||
output wire [NUM_BANKS-1:0] per_bank_core_rsp_ready,
|
||||
input wire [NUM_BANKS-1:0] per_bank_core_rsp_valid,
|
||||
input wire [NUM_BANKS-1:0][CORE_TAG_WIDTH-1:0] per_bank_core_rsp_tag,
|
||||
input wire [NUM_BANKS-1:0][`REQS_BITS-1:0] per_bank_core_rsp_tid,
|
||||
input wire [NUM_BANKS-1:0][`WORD_WIDTH-1:0] per_bank_core_rsp_data,
|
||||
output wire [NUM_BANKS-1:0] per_bank_core_rsp_ready,
|
||||
|
||||
// Core Writeback
|
||||
output wire [NUM_REQUESTS-1:0] core_rsp_valid,
|
||||
output wire [NUM_REQS-1:0] core_rsp_valid,
|
||||
output wire [`CORE_REQ_TAG_COUNT-1:0][CORE_TAG_WIDTH-1:0] core_rsp_tag,
|
||||
output wire [NUM_REQUESTS-1:0][`WORD_WIDTH-1:0] core_rsp_data,
|
||||
input wire core_rsp_ready
|
||||
output wire [NUM_REQS-1:0][`WORD_WIDTH-1:0] core_rsp_data,
|
||||
input wire core_rsp_ready
|
||||
);
|
||||
if (NUM_REQUESTS > 1) begin
|
||||
if (NUM_BANKS > 1) begin
|
||||
|
||||
reg [NUM_REQUESTS-1:0] core_rsp_valid_unqual;
|
||||
reg [NUM_REQUESTS-1:0][`WORD_WIDTH-1:0] core_rsp_data_unqual;
|
||||
reg [NUM_REQS-1:0] core_rsp_valid_unqual;
|
||||
reg [`CORE_REQ_TAG_COUNT-1:0][CORE_TAG_WIDTH-1:0] core_rsp_tag_unqual;
|
||||
reg [NUM_REQS-1:0][`WORD_WIDTH-1:0] core_rsp_data_unqual;
|
||||
reg [NUM_BANKS-1:0] core_rsp_bank_select;
|
||||
reg [CORE_TAG_ID_BITS-1:0] sel_tag_id;
|
||||
|
||||
if (CORE_TAG_ID_BITS != 0) begin
|
||||
wire [`BANK_BITS-1:0] sel_idx;
|
||||
|
||||
VX_rr_arbiter #(
|
||||
.N(NUM_BANKS)
|
||||
) sel_arb (
|
||||
.clk (clk),
|
||||
.reset (reset),
|
||||
.requests (per_bank_core_rsp_valid),
|
||||
`UNUSED_PIN (grant_valid),
|
||||
.grant_index (sel_idx),
|
||||
`UNUSED_PIN (grant_onehot)
|
||||
);
|
||||
|
||||
always @(*) begin
|
||||
core_rsp_valid_unqual = 0;
|
||||
core_rsp_tag_unqual = per_bank_core_rsp_tag[sel_idx];
|
||||
core_rsp_tag_unqual = 'x;
|
||||
sel_tag_id = 'x;
|
||||
core_rsp_data_unqual = 'x;
|
||||
core_rsp_bank_select = 0;
|
||||
core_rsp_bank_select = 0;
|
||||
|
||||
for (integer i = 0; i < NUM_BANKS; i++) begin
|
||||
if (per_bank_core_rsp_valid[i]) begin
|
||||
core_rsp_tag_unqual = per_bank_core_rsp_tag[i];
|
||||
sel_tag_id = per_bank_core_rsp_tag[i][CORE_TAG_ID_BITS-1:0];
|
||||
break;
|
||||
end
|
||||
end
|
||||
|
||||
for (integer i = 0; i < NUM_BANKS; i++) begin
|
||||
if (per_bank_core_rsp_valid[i]
|
||||
&& (per_bank_core_rsp_tag[i][CORE_TAG_ID_BITS-1:0] == per_bank_core_rsp_tag[sel_idx][CORE_TAG_ID_BITS-1:0])) begin
|
||||
&& (per_bank_core_rsp_tag[i][CORE_TAG_ID_BITS-1:0] == sel_tag_id)) begin
|
||||
core_rsp_valid_unqual[per_bank_core_rsp_tid[i]] = 1;
|
||||
core_rsp_data_unqual[per_bank_core_rsp_tid[i]] = per_bank_core_rsp_data[i];
|
||||
core_rsp_bank_select[i] = 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end else begin
|
||||
|
||||
always @(*) begin
|
||||
core_rsp_valid_unqual = 0;
|
||||
core_rsp_tag_unqual = 'x;
|
||||
@@ -86,8 +85,8 @@ module VX_cache_core_rsp_merge #(
|
||||
wire stall = ~core_rsp_ready && (| core_rsp_valid);
|
||||
|
||||
VX_generic_register #(
|
||||
.N(NUM_REQUESTS + (NUM_REQUESTS *`WORD_WIDTH) + (`CORE_REQ_TAG_COUNT * CORE_TAG_WIDTH)),
|
||||
.R(NUM_REQUESTS),
|
||||
.N(NUM_REQS + (NUM_REQS *`WORD_WIDTH) + (`CORE_REQ_TAG_COUNT * CORE_TAG_WIDTH)),
|
||||
.R(NUM_REQS),
|
||||
.PASSTHRU(NUM_BANKS <= 2)
|
||||
) pipe_reg (
|
||||
.clk (clk),
|
||||
@@ -98,16 +97,33 @@ module VX_cache_core_rsp_merge #(
|
||||
.out ({core_rsp_valid, core_rsp_data, core_rsp_tag})
|
||||
);
|
||||
|
||||
assign per_bank_core_rsp_ready = core_rsp_bank_select & {NUM_BANKS{~stall}};
|
||||
for (genvar i = 0; i < NUM_BANKS; i++) begin
|
||||
assign per_bank_core_rsp_ready[i] = core_rsp_bank_select[i] && ~stall;
|
||||
end
|
||||
end else begin
|
||||
`UNUSED_VAR (clk)
|
||||
`UNUSED_VAR (reset)
|
||||
`UNUSED_VAR (per_bank_core_rsp_tid)
|
||||
|
||||
assign core_rsp_valid = per_bank_core_rsp_valid;
|
||||
assign core_rsp_tag = per_bank_core_rsp_tag;
|
||||
assign core_rsp_data = per_bank_core_rsp_data;
|
||||
assign per_bank_core_rsp_ready = core_rsp_ready;
|
||||
if (NUM_REQS > 1) begin
|
||||
|
||||
assign core_rsp_valid[per_bank_core_rsp_tid[0]] = per_bank_core_rsp_valid;
|
||||
if (CORE_TAG_ID_BITS != 0) begin
|
||||
assign core_rsp_tag = per_bank_core_rsp_tag[0];
|
||||
end else begin
|
||||
assign core_rsp_tag[per_bank_core_rsp_tid[0]] = per_bank_core_rsp_tag[0];
|
||||
end
|
||||
assign core_rsp_data[per_bank_core_rsp_tid[0]] = per_bank_core_rsp_data[0];
|
||||
assign per_bank_core_rsp_ready[0] = core_rsp_ready;
|
||||
|
||||
end else begin
|
||||
|
||||
`UNUSED_VAR(per_bank_core_rsp_tid)
|
||||
assign core_rsp_valid = per_bank_core_rsp_valid;
|
||||
assign core_rsp_tag = per_bank_core_rsp_tag[0];
|
||||
assign core_rsp_data = per_bank_core_rsp_data[0];
|
||||
assign per_bank_core_rsp_ready[0] = core_rsp_ready;
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
||||
77
hw/rtl/cache/VX_cache_dram_req_arb.v
vendored
77
hw/rtl/cache/VX_cache_dram_req_arb.v
vendored
@@ -1,77 +0,0 @@
|
||||
`include "VX_cache_config.vh"
|
||||
|
||||
module VX_cache_dram_req_arb #(
|
||||
// Size of line inside a bank in bytes
|
||||
parameter BANK_LINE_SIZE = 1,
|
||||
// Number of banks
|
||||
parameter NUM_BANKS = 1,
|
||||
// Size of a word in bytes
|
||||
parameter WORD_SIZE = 1
|
||||
) (
|
||||
input wire clk,
|
||||
input wire reset,
|
||||
|
||||
// Inputs
|
||||
input wire [NUM_BANKS-1:0] per_bank_dram_req_valid,
|
||||
input wire [NUM_BANKS-1:0][`DRAM_ADDR_WIDTH-1:0] per_bank_dram_req_addr,
|
||||
input wire [NUM_BANKS-1:0] per_bank_dram_req_rw,
|
||||
input wire [NUM_BANKS-1:0][BANK_LINE_SIZE-1:0] per_bank_dram_req_byteen,
|
||||
input wire [NUM_BANKS-1:0][`BANK_LINE_WIDTH-1:0] per_bank_dram_req_data,
|
||||
output wire [NUM_BANKS-1:0] per_bank_dram_req_ready,
|
||||
|
||||
// Outputs
|
||||
output wire dram_req_valid,
|
||||
output wire dram_req_rw,
|
||||
output wire [BANK_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,
|
||||
input wire dram_req_ready
|
||||
);
|
||||
|
||||
if (NUM_BANKS > 1) begin
|
||||
wire sel_valid;
|
||||
wire [`BANK_BITS-1:0] sel_idx;
|
||||
wire [NUM_BANKS-1:0] sel_1hot;
|
||||
|
||||
VX_rr_arbiter #(
|
||||
.N(NUM_BANKS)
|
||||
) sel_arb (
|
||||
.clk (clk),
|
||||
.reset (reset),
|
||||
.requests (per_bank_dram_req_valid),
|
||||
.grant_valid (sel_valid),
|
||||
.grant_index (sel_idx),
|
||||
.grant_onehot(sel_1hot)
|
||||
);
|
||||
|
||||
wire stall = ~dram_req_ready && dram_req_valid;
|
||||
|
||||
VX_generic_register #(
|
||||
.N(1 + `DRAM_ADDR_WIDTH + 1 + BANK_LINE_SIZE + `BANK_LINE_WIDTH),
|
||||
.R(1),
|
||||
.PASSTHRU(NUM_BANKS <= 2)
|
||||
) pipe_reg (
|
||||
.clk (clk),
|
||||
.reset (reset),
|
||||
.stall (stall),
|
||||
.flush (1'b0),
|
||||
.in ({sel_valid, per_bank_dram_req_addr[sel_idx], per_bank_dram_req_rw[sel_idx], per_bank_dram_req_byteen[sel_idx], per_bank_dram_req_data[sel_idx]}),
|
||||
.out ({dram_req_valid, dram_req_addr, dram_req_rw, dram_req_byteen, dram_req_data})
|
||||
);
|
||||
|
||||
for (genvar i = 0; i < NUM_BANKS; i++) begin
|
||||
assign per_bank_dram_req_ready[i] = sel_1hot[i] && !stall;
|
||||
end
|
||||
end else begin
|
||||
`UNUSED_VAR (clk)
|
||||
`UNUSED_VAR (reset)
|
||||
|
||||
assign dram_req_valid = per_bank_dram_req_valid;
|
||||
assign dram_req_rw = per_bank_dram_req_rw;
|
||||
assign dram_req_byteen = per_bank_dram_req_byteen;
|
||||
assign dram_req_addr = per_bank_dram_req_addr;
|
||||
assign dram_req_data = per_bank_dram_req_data;
|
||||
assign per_bank_dram_req_ready = dram_req_ready;
|
||||
end
|
||||
|
||||
endmodule
|
||||
4
hw/rtl/cache/VX_miss_resrv.v
vendored
4
hw/rtl/cache/VX_miss_resrv.v
vendored
@@ -11,7 +11,7 @@ module VX_miss_resrv #(
|
||||
// Size of a word in bytes
|
||||
parameter WORD_SIZE = 1,
|
||||
// Number of Word requests per cycle
|
||||
parameter NUM_REQUESTS = 1,
|
||||
parameter NUM_REQS = 1,
|
||||
// Miss Reserv Queue Knob
|
||||
parameter MSHR_SIZE = 1,
|
||||
// core request tag size
|
||||
@@ -73,7 +73,7 @@ module VX_miss_resrv #(
|
||||
);
|
||||
wire [`MSHR_METADATA_WIDTH-1:0] metadata_table;
|
||||
|
||||
`NO_RW_RAM_CHECK reg [`LINE_ADDR_WIDTH-1:0] addr_table [MSHR_SIZE-1:0];
|
||||
reg [`LINE_ADDR_WIDTH-1:0] addr_table [MSHR_SIZE-1:0];
|
||||
|
||||
reg [MSHR_SIZE-1:0] valid_table;
|
||||
reg [MSHR_SIZE-1:0] ready_table;
|
||||
|
||||
116
hw/rtl/cache/VX_snp_forwarder.v
vendored
116
hw/rtl/cache/VX_snp_forwarder.v
vendored
@@ -4,51 +4,52 @@ module VX_snp_forwarder #(
|
||||
parameter CACHE_ID = 0,
|
||||
parameter SRC_ADDR_WIDTH = 1,
|
||||
parameter DST_ADDR_WIDTH = 1,
|
||||
parameter NUM_REQUESTS = 1,
|
||||
parameter NUM_REQS = 1,
|
||||
parameter SNP_TAG_WIDTH = 1,
|
||||
parameter SNRQ_SIZE = 1
|
||||
parameter SNRQ_SIZE = 1,
|
||||
parameter LOG_SNRQ_SIZE = `LOG2UP(SNRQ_SIZE)
|
||||
) (
|
||||
input wire clk,
|
||||
input wire reset,
|
||||
|
||||
// Snoop request
|
||||
input wire snp_req_valid,
|
||||
input wire [SRC_ADDR_WIDTH-1:0] snp_req_addr,
|
||||
input wire snp_req_inv,
|
||||
input wire [SNP_TAG_WIDTH-1:0] snp_req_tag,
|
||||
output wire snp_req_ready,
|
||||
input wire snp_req_valid,
|
||||
input wire [SRC_ADDR_WIDTH-1:0] snp_req_addr,
|
||||
input wire snp_req_inv,
|
||||
input wire [SNP_TAG_WIDTH-1:0] snp_req_tag,
|
||||
output wire snp_req_ready,
|
||||
|
||||
// Snoop response
|
||||
output wire snp_rsp_valid,
|
||||
output wire [SRC_ADDR_WIDTH-1:0] snp_rsp_addr,
|
||||
output wire snp_rsp_inv,
|
||||
output wire [SNP_TAG_WIDTH-1:0] snp_rsp_tag,
|
||||
input wire snp_rsp_ready,
|
||||
output wire snp_rsp_valid,
|
||||
output wire [SRC_ADDR_WIDTH-1:0] snp_rsp_addr,
|
||||
output wire snp_rsp_inv,
|
||||
output wire [SNP_TAG_WIDTH-1:0] snp_rsp_tag,
|
||||
input wire snp_rsp_ready,
|
||||
|
||||
// Snoop Forwarding out
|
||||
output wire [NUM_REQUESTS-1:0] snp_fwdout_valid,
|
||||
output wire [NUM_REQUESTS-1:0][DST_ADDR_WIDTH-1:0] snp_fwdout_addr,
|
||||
output wire [NUM_REQUESTS-1:0] snp_fwdout_inv,
|
||||
output wire [NUM_REQUESTS-1:0][`LOG2UP(SNRQ_SIZE)-1:0] snp_fwdout_tag,
|
||||
input wire [NUM_REQUESTS-1:0] snp_fwdout_ready,
|
||||
output wire [NUM_REQS-1:0] snp_fwdout_valid,
|
||||
output wire [NUM_REQS-1:0][DST_ADDR_WIDTH-1:0] snp_fwdout_addr,
|
||||
output wire [NUM_REQS-1:0] snp_fwdout_inv,
|
||||
output wire [NUM_REQS-1:0][LOG_SNRQ_SIZE-1:0] snp_fwdout_tag,
|
||||
input wire [NUM_REQS-1:0] snp_fwdout_ready,
|
||||
|
||||
// Snoop forwarding in
|
||||
input wire [NUM_REQUESTS-1:0] snp_fwdin_valid,
|
||||
input wire [NUM_REQUESTS-1:0][`LOG2UP(SNRQ_SIZE)-1:0] snp_fwdin_tag,
|
||||
output wire [NUM_REQUESTS-1:0] snp_fwdin_ready
|
||||
input wire [NUM_REQS-1:0] snp_fwdin_valid,
|
||||
input wire [NUM_REQS-1:0][LOG_SNRQ_SIZE-1:0] snp_fwdin_tag,
|
||||
output wire [NUM_REQS-1:0] snp_fwdin_ready
|
||||
);
|
||||
localparam ADDR_DIFF = DST_ADDR_WIDTH - SRC_ADDR_WIDTH;
|
||||
localparam NUM_REQUESTS_QUAL = NUM_REQUESTS * (1 << ADDR_DIFF);
|
||||
localparam NUM_REQUESTS_QUAL = NUM_REQS * (1 << ADDR_DIFF);
|
||||
localparam REQ_QUAL_BITS = `LOG2UP(NUM_REQUESTS_QUAL);
|
||||
|
||||
`STATIC_ASSERT(NUM_REQUESTS > 1, ("invalid value"))
|
||||
`STATIC_ASSERT(NUM_REQS > 1, ("invalid value"))
|
||||
|
||||
reg [REQ_QUAL_BITS:0] pending_cntrs [SNRQ_SIZE-1:0];
|
||||
|
||||
wire [`LOG2UP(SNRQ_SIZE)-1:0] sfq_write_addr, sfq_read_addr;
|
||||
wire [LOG_SNRQ_SIZE-1:0] sfq_write_addr, sfq_read_addr;
|
||||
wire sfq_full;
|
||||
|
||||
wire [`LOG2UP(SNRQ_SIZE)-1:0] fwdin_tag;
|
||||
wire [LOG_SNRQ_SIZE-1:0] fwdin_tag;
|
||||
wire fwdin_valid;
|
||||
|
||||
wire fwdin_ready = snp_rsp_ready || (1 != pending_cntrs[sfq_read_addr]);
|
||||
@@ -78,14 +79,14 @@ module VX_snp_forwarder #(
|
||||
);
|
||||
|
||||
wire fwdout_valid;
|
||||
wire [`LOG2UP(SNRQ_SIZE)-1:0] fwdout_tag;
|
||||
wire [LOG_SNRQ_SIZE-1:0] fwdout_tag;
|
||||
wire [DST_ADDR_WIDTH-1:0] fwdout_addr;
|
||||
wire fwdout_inv;
|
||||
wire fwdout_ready;
|
||||
wire dispatch_hold;
|
||||
|
||||
if (ADDR_DIFF != 0) begin
|
||||
reg [`LOG2UP(SNRQ_SIZE)-1:0] fwdout_tag_r;
|
||||
reg [LOG_SNRQ_SIZE-1:0] fwdout_tag_r;
|
||||
reg [DST_ADDR_WIDTH-1:0] fwdout_addr_r;
|
||||
reg fwdout_inv_r;
|
||||
reg dispatch_hold_r;
|
||||
@@ -136,9 +137,9 @@ module VX_snp_forwarder #(
|
||||
end
|
||||
end
|
||||
|
||||
reg [NUM_REQUESTS-1:0] snp_fwdout_ready_other;
|
||||
reg [NUM_REQS-1:0] snp_fwdout_ready_other;
|
||||
|
||||
for (genvar i = 0; i < NUM_REQUESTS; i++) begin
|
||||
for (genvar i = 0; i < NUM_REQS; i++) begin
|
||||
assign snp_fwdout_valid[i] = fwdout_valid && snp_fwdout_ready_other[i];
|
||||
assign snp_fwdout_addr[i] = fwdout_addr;
|
||||
assign snp_fwdout_inv[i] = fwdout_inv;
|
||||
@@ -146,9 +147,9 @@ module VX_snp_forwarder #(
|
||||
end
|
||||
|
||||
always @(*) begin
|
||||
snp_fwdout_ready_other = {NUM_REQUESTS{1'b1}};
|
||||
for (integer i = 0; i < NUM_REQUESTS; i++) begin
|
||||
for (integer j = 0; j < NUM_REQUESTS; j++) begin
|
||||
snp_fwdout_ready_other = {NUM_REQS{1'b1}};
|
||||
for (integer i = 0; i < NUM_REQS; i++) begin
|
||||
for (integer j = 0; j < NUM_REQS; j++) begin
|
||||
if (i != j)
|
||||
snp_fwdout_ready_other[i] &= snp_fwdout_ready[j];
|
||||
end
|
||||
@@ -159,45 +160,20 @@ module VX_snp_forwarder #(
|
||||
|
||||
assign snp_req_ready = fwdout_ready && !sfq_full && !dispatch_hold;
|
||||
|
||||
if (NUM_REQUESTS > 1) begin
|
||||
wire sel_valid;
|
||||
wire [`REQS_BITS-1:0] sel_idx;
|
||||
wire [NUM_REQUESTS-1:0] sel_1hot;
|
||||
|
||||
VX_rr_arbiter #(
|
||||
.N(NUM_REQUESTS)
|
||||
) sel_arb (
|
||||
.clk (clk),
|
||||
.reset (reset),
|
||||
.requests (snp_fwdin_valid),
|
||||
.grant_valid (sel_valid),
|
||||
.grant_index (sel_idx),
|
||||
.grant_onehot (sel_1hot)
|
||||
);
|
||||
|
||||
wire stall = ~fwdin_ready && fwdin_valid;
|
||||
|
||||
VX_generic_register #(
|
||||
.N(1 + `LOG2UP(SNRQ_SIZE)),
|
||||
.R(1),
|
||||
.PASSTHRU(NUM_REQUESTS <= 2)
|
||||
) pipe_reg (
|
||||
.clk (clk),
|
||||
.reset (reset),
|
||||
.stall (stall),
|
||||
.flush (1'b0),
|
||||
.in ({sel_valid, snp_fwdin_tag[sel_idx]}),
|
||||
.out ({fwdin_valid, fwdin_tag})
|
||||
);
|
||||
|
||||
for (genvar i = 0; i < NUM_REQUESTS; i++) begin
|
||||
assign snp_fwdin_ready[i] = sel_1hot[i] && !stall;
|
||||
end
|
||||
end else begin
|
||||
assign fwdin_valid = snp_fwdin_valid;
|
||||
assign fwdin_tag = snp_fwdin_tag;
|
||||
assign snp_fwdin_ready = fwdin_ready;
|
||||
end
|
||||
VX_stream_arbiter #(
|
||||
.NUM_REQS(NUM_REQS),
|
||||
.DATAW(LOG_SNRQ_SIZE),
|
||||
.BUFFERED(NUM_REQS >= 4)
|
||||
) snp_fwdin_arb (
|
||||
.clk (clk),
|
||||
.reset (reset),
|
||||
.valid_in (snp_fwdin_valid),
|
||||
.valid_out (fwdin_valid),
|
||||
.data_in (snp_fwdin_tag),
|
||||
.data_out (fwdin_tag),
|
||||
.ready_in (snp_fwdin_ready),
|
||||
.ready_out (fwdin_ready)
|
||||
);
|
||||
|
||||
`ifdef DBG_PRINT_CACHE_SNP
|
||||
always @(posedge clk) begin
|
||||
|
||||
59
hw/rtl/cache/VX_snp_rsp_arb.v
vendored
59
hw/rtl/cache/VX_snp_rsp_arb.v
vendored
@@ -1,59 +0,0 @@
|
||||
`include "VX_cache_config.vh"
|
||||
|
||||
module VX_snp_rsp_arb #(
|
||||
parameter NUM_BANKS = 1,
|
||||
parameter BANK_LINE_SIZE = 1,
|
||||
parameter SNP_TAG_WIDTH = 1
|
||||
) (
|
||||
input wire clk,
|
||||
input wire reset,
|
||||
|
||||
input wire [NUM_BANKS-1:0] per_bank_snp_rsp_valid,
|
||||
input wire [NUM_BANKS-1:0][SNP_TAG_WIDTH-1:0] per_bank_snp_rsp_tag,
|
||||
output wire [NUM_BANKS-1:0] per_bank_snp_rsp_ready,
|
||||
|
||||
output wire snp_rsp_valid,
|
||||
output wire [SNP_TAG_WIDTH-1:0] snp_rsp_tag,
|
||||
input wire snp_rsp_ready
|
||||
);
|
||||
if (NUM_BANKS > 1) begin
|
||||
wire sel_valid;
|
||||
wire [`BANK_BITS-1:0] sel_idx;
|
||||
wire [NUM_BANKS-1:0] sel_1hot;
|
||||
|
||||
VX_rr_arbiter #(
|
||||
.N(NUM_BANKS)
|
||||
) sel_arb (
|
||||
.clk (clk),
|
||||
.reset (reset),
|
||||
.requests (per_bank_snp_rsp_valid),
|
||||
.grant_valid (sel_valid),
|
||||
.grant_index (sel_idx),
|
||||
.grant_onehot(sel_1hot)
|
||||
);
|
||||
|
||||
wire stall = ~snp_rsp_ready && snp_rsp_valid;
|
||||
|
||||
VX_generic_register #(
|
||||
.N(1 + SNP_TAG_WIDTH),
|
||||
.R(1),
|
||||
.PASSTHRU(NUM_BANKS <= 2)
|
||||
) pipe_reg (
|
||||
.clk (clk),
|
||||
.reset (reset),
|
||||
.stall (stall),
|
||||
.flush (1'b0),
|
||||
.in ({sel_valid, per_bank_snp_rsp_tag[sel_idx]}),
|
||||
.out ({snp_rsp_valid, snp_rsp_tag})
|
||||
);
|
||||
|
||||
for (genvar i = 0; i < NUM_BANKS; i++) begin
|
||||
assign per_bank_snp_rsp_ready[i] = sel_1hot[i] && !stall;
|
||||
end
|
||||
end else begin
|
||||
assign snp_rsp_valid = per_bank_snp_rsp_valid;
|
||||
assign snp_rsp_tag = per_bank_snp_rsp_tag;
|
||||
assign per_bank_snp_rsp_ready = snp_rsp_ready;
|
||||
end
|
||||
|
||||
endmodule
|
||||
Reference in New Issue
Block a user