RTL code refactoring
This commit is contained in:
15
hw/rtl/cache/VX_cache_core_req_bank_sel.v
vendored
15
hw/rtl/cache/VX_cache_core_req_bank_sel.v
vendored
@@ -1,8 +1,7 @@
|
||||
|
||||
`include "VX_cache_config.vh"
|
||||
|
||||
module VX_cache_core_req_bank_sel
|
||||
#(
|
||||
module VX_cache_core_req_bank_sel #(
|
||||
// Size of cache in bytes
|
||||
parameter CACHE_SIZE_BYTES = 1024,
|
||||
// Size of line inside a bank in bytes
|
||||
@@ -18,8 +17,7 @@ module VX_cache_core_req_bank_sel
|
||||
// Function ID, {Dcache=0, Icache=1, Sharedmemory=2}
|
||||
parameter FUNC_ID = 0,
|
||||
|
||||
// Queues feeding into banks Knobs {1, 2, 4, 8, ...}
|
||||
|
||||
// Queues feeding into banks Knobs {1, 2, 4, 8, ...}
|
||||
// Core Request Queue Size
|
||||
parameter REQQ_SIZE = 8,
|
||||
// Miss Reserv Queue Knob
|
||||
@@ -29,7 +27,7 @@ module VX_cache_core_req_bank_sel
|
||||
// Snoop Req Queue
|
||||
parameter SNRQ_SIZE = 8,
|
||||
|
||||
// Queues for writebacks Knobs {1, 2, 4, 8, ...}
|
||||
// Queues for writebacks Knobs {1, 2, 4, 8, ...}
|
||||
// Core Writeback Queue Size
|
||||
parameter CWBQ_SIZE = 8,
|
||||
// Dram Writeback Queue Size
|
||||
@@ -42,12 +40,9 @@ module VX_cache_core_req_bank_sel
|
||||
// Fill Invalidator Size {Fill invalidator must be active}
|
||||
parameter FILL_INVALIDAOR_SIZE = 16,
|
||||
|
||||
// Dram knobs
|
||||
// Dram knobs
|
||||
parameter SIMULATED_DRAM_LATENCY_CYCLES = 10
|
||||
|
||||
|
||||
)
|
||||
(
|
||||
) (
|
||||
input wire [NUM_REQUESTS-1:0] core_req_valid,
|
||||
input wire [NUM_REQUESTS-1:0][31:0] core_req_addr,
|
||||
|
||||
|
||||
24
hw/rtl/cache/VX_cache_req_queue.v
vendored
24
hw/rtl/cache/VX_cache_req_queue.v
vendored
@@ -56,21 +56,21 @@ module VX_cache_req_queue #(
|
||||
input wire [31:0] bank_pc,
|
||||
|
||||
// Dequeue Data
|
||||
input wire reqq_pop,
|
||||
output wire reqq_req_st0,
|
||||
input wire reqq_pop,
|
||||
output wire reqq_req_st0,
|
||||
output wire [`LOG2UP(NUM_REQUESTS)-1:0] reqq_req_tid_st0,
|
||||
output wire [31:0] reqq_req_addr_st0,
|
||||
output wire [`WORD_SIZE_RNG] reqq_req_writedata_st0,
|
||||
output wire [4:0] reqq_req_rd_st0,
|
||||
output wire [1:0] reqq_req_wb_st0,
|
||||
output wire [`NW_BITS-1:0] reqq_req_warp_num_st0,
|
||||
output wire [2:0] reqq_req_mem_read_st0,
|
||||
output wire [2:0] reqq_req_mem_write_st0,
|
||||
output wire [31:0] reqq_req_pc_st0,
|
||||
output wire [31:0] reqq_req_addr_st0,
|
||||
output wire [`WORD_SIZE_RNG] reqq_req_writedata_st0,
|
||||
output wire [4:0] reqq_req_rd_st0,
|
||||
output wire [1:0] reqq_req_wb_st0,
|
||||
output wire [`NW_BITS-1:0] reqq_req_warp_num_st0,
|
||||
output wire [2:0] reqq_req_mem_read_st0,
|
||||
output wire [2:0] reqq_req_mem_write_st0,
|
||||
output wire [31:0] reqq_req_pc_st0,
|
||||
|
||||
// State Data
|
||||
output wire reqq_empty,
|
||||
output wire reqq_full
|
||||
output wire reqq_empty,
|
||||
output wire reqq_full
|
||||
);
|
||||
|
||||
wire [NUM_REQUESTS-1:0] out_per_valids;
|
||||
|
||||
79
hw/rtl/cache/VX_dcache_llv_resp_bank_sel.v
vendored
79
hw/rtl/cache/VX_dcache_llv_resp_bank_sel.v
vendored
@@ -1,79 +0,0 @@
|
||||
`include "VX_cache_config.vh"
|
||||
|
||||
module VX_dcache_llv_resp_bank_sel #(
|
||||
// Size of cache in bytes
|
||||
parameter CACHE_SIZE_BYTES = 1024,
|
||||
// Size of line inside a bank in bytes
|
||||
parameter BANK_LINE_SIZE_BYTES = 16,
|
||||
// Number of banks {1, 2, 4, 8,...}
|
||||
parameter NUM_BANKS = 8,
|
||||
// Size of a word in bytes
|
||||
parameter WORD_SIZE_BYTES = 4,
|
||||
// Number of Word requests per cycle {1, 2, 4, 8, ...}
|
||||
parameter NUM_REQUESTS = 2,
|
||||
// Number of cycles to complete stage 1 (read from memory)
|
||||
parameter STAGE_1_CYCLES = 2,
|
||||
|
||||
// Queues feeding into banks Knobs {1, 2, 4, 8, ...}
|
||||
// Core Request Queue Size
|
||||
parameter REQQ_SIZE = 8,
|
||||
// Miss Reserv Queue Knob
|
||||
parameter MRVQ_SIZE = 8,
|
||||
// Dram Fill Rsp Queue Size
|
||||
parameter DFPQ_SIZE = 2,
|
||||
// Snoop Req Queue
|
||||
parameter SNRQ_SIZE = 8,
|
||||
|
||||
// Queues for writebacks Knobs {1, 2, 4, 8, ...}
|
||||
// Core Writeback Queue Size
|
||||
parameter CWBQ_SIZE = 8,
|
||||
// Dram Writeback Queue Size
|
||||
parameter DWBQ_SIZE = 4,
|
||||
// Dram Fill Req Queue Size
|
||||
parameter DFQQ_SIZE = 8,
|
||||
// Lower Level Cache Hit Queue Size
|
||||
parameter LLVQ_SIZE = 16,
|
||||
|
||||
// Fill Invalidator Size {Fill invalidator must be active}
|
||||
parameter FILL_INVALIDAOR_SIZE = 16,
|
||||
|
||||
// Dram knobs
|
||||
parameter SIMULATED_DRAM_LATENCY_CYCLES = 10
|
||||
) (
|
||||
output reg [NUM_BANKS-1:0] per_bank_llvq_pop,
|
||||
input wire[NUM_BANKS-1:0] per_bank_llvq_valid,
|
||||
input wire[NUM_BANKS-1:0][31:0] per_bank_llvq_rsp_addr,
|
||||
input wire[NUM_BANKS-1:0][`BANK_LINE_WORDS-1:0][31:0] per_bank_llvq_rsp_data,
|
||||
input wire[NUM_BANKS-1:0][`LOG2UP(NUM_REQUESTS)-1:0] per_bank_llvq_rsp_tid,
|
||||
|
||||
input wire llvq_pop,
|
||||
output reg[NUM_REQUESTS-1:0] llvq_valid,
|
||||
output reg[NUM_REQUESTS-1:0][31:0] llvq_rsp_addr,
|
||||
output reg[NUM_REQUESTS-1:0][`BANK_LINE_WORDS-1:0][31:0] llvq_rsp_data
|
||||
);
|
||||
|
||||
wire [(`LOG2UP(NUM_BANKS))-1:0] main_bank_index;
|
||||
wire found_bank;
|
||||
|
||||
VX_generic_priority_encoder #(
|
||||
.N(NUM_BANKS)
|
||||
) sel_bank(
|
||||
.valids(per_bank_llvq_valid),
|
||||
.index (main_bank_index),
|
||||
.found (found_bank)
|
||||
);
|
||||
|
||||
always @(*) begin
|
||||
llvq_valid = 0;
|
||||
llvq_rsp_addr = 0;
|
||||
llvq_rsp_data = 0;
|
||||
per_bank_llvq_pop = 0;
|
||||
if (found_bank && llvq_pop) begin
|
||||
llvq_valid [per_bank_llvq_rsp_tid[main_bank_index]] = 1'b1;
|
||||
llvq_rsp_addr[per_bank_llvq_rsp_tid[main_bank_index]] = per_bank_llvq_rsp_addr[main_bank_index];
|
||||
llvq_rsp_data[per_bank_llvq_rsp_tid[main_bank_index]] = per_bank_llvq_rsp_data[main_bank_index];
|
||||
per_bank_llvq_pop[main_bank_index] = 1'b1;
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
30
hw/rtl/cache/VX_fill_invalidator.v
vendored
30
hw/rtl/cache/VX_fill_invalidator.v
vendored
@@ -1,7 +1,6 @@
|
||||
`include "VX_cache_config.vh"
|
||||
|
||||
module VX_fill_invalidator
|
||||
#(
|
||||
module VX_fill_invalidator #(
|
||||
// Size of cache in bytes
|
||||
parameter CACHE_SIZE_BYTES = 1024,
|
||||
// Size of line inside a bank in bytes
|
||||
@@ -15,8 +14,7 @@ module VX_fill_invalidator
|
||||
// Number of cycles to complete stage 1 (read from memory)
|
||||
parameter STAGE_1_CYCLES = 2,
|
||||
|
||||
// Queues feeding into banks Knobs {1, 2, 4, 8, ...}
|
||||
|
||||
// Queues feeding into banks Knobs {1, 2, 4, 8, ...}
|
||||
// Core Request Queue Size
|
||||
parameter REQQ_SIZE = 8,
|
||||
// Miss Reserv Queue Knob
|
||||
@@ -26,7 +24,7 @@ module VX_fill_invalidator
|
||||
// Snoop Req Queue
|
||||
parameter SNRQ_SIZE = 8,
|
||||
|
||||
// Queues for writebacks Knobs {1, 2, 4, 8, ...}
|
||||
// Queues for writebacks Knobs {1, 2, 4, 8, ...}
|
||||
// Core Writeback Queue Size
|
||||
parameter CWBQ_SIZE = 8,
|
||||
// Dram Writeback Queue Size
|
||||
@@ -39,12 +37,9 @@ module VX_fill_invalidator
|
||||
// Fill Invalidator Size {Fill invalidator must be active}
|
||||
parameter FILL_INVALIDAOR_SIZE = 16,
|
||||
|
||||
// Dram knobs
|
||||
// Dram knobs
|
||||
parameter SIMULATED_DRAM_LATENCY_CYCLES = 10
|
||||
|
||||
|
||||
)
|
||||
(
|
||||
) (
|
||||
input wire clk,
|
||||
input wire reset,
|
||||
|
||||
@@ -53,22 +48,19 @@ module VX_fill_invalidator
|
||||
|
||||
input wire[31:0] fill_addr,
|
||||
|
||||
output reg invalidate_fill
|
||||
|
||||
output reg invalidate_fill
|
||||
);
|
||||
|
||||
|
||||
if (FILL_INVALIDAOR_SIZE == 0) begin
|
||||
|
||||
assign invalidate_fill = 0;
|
||||
|
||||
end else begin
|
||||
|
||||
reg[FILL_INVALIDAOR_SIZE-1:0] fills_active;
|
||||
reg[FILL_INVALIDAOR_SIZE-1:0][31:0] fills_address;
|
||||
reg [FILL_INVALIDAOR_SIZE-1:0] fills_active;
|
||||
reg [FILL_INVALIDAOR_SIZE-1:0][31:0] fills_address;
|
||||
|
||||
|
||||
reg[FILL_INVALIDAOR_SIZE-1:0] matched_fill;
|
||||
reg [FILL_INVALIDAOR_SIZE-1:0] matched_fill;
|
||||
wire matched;
|
||||
integer fi;
|
||||
always @(*) begin
|
||||
@@ -77,10 +69,8 @@ module VX_fill_invalidator
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
assign matched = (|(matched_fill));
|
||||
|
||||
|
||||
wire [(`LOG2UP(FILL_INVALIDAOR_SIZE))-1:0] enqueue_index;
|
||||
wire enqueue_found;
|
||||
|
||||
@@ -110,7 +100,7 @@ module VX_fill_invalidator
|
||||
end
|
||||
end
|
||||
|
||||
// reg success_found;
|
||||
// reg success_found;
|
||||
// reg[(`LOG2UP(FILL_INVALIDAOR_SIZE))-1:0] success_index;
|
||||
|
||||
// integer curr_fill;
|
||||
|
||||
122
hw/rtl/cache/VX_mrv_queue.v
vendored
122
hw/rtl/cache/VX_mrv_queue.v
vendored
@@ -1,122 +0,0 @@
|
||||
|
||||
module VX_mrv_queue
|
||||
#(
|
||||
parameter DATAW = 4,
|
||||
parameter SIZE = 277
|
||||
)
|
||||
(
|
||||
input wire clk,
|
||||
input wire reset,
|
||||
input wire push,
|
||||
input wire[DATAW-1:0] in_data,
|
||||
|
||||
input wire pop,
|
||||
output wire[DATAW-1:0] out_data,
|
||||
output wire empty,
|
||||
output wire full
|
||||
);
|
||||
|
||||
if (SIZE == 0) begin
|
||||
assign empty = 1;
|
||||
assign out_data = 0;
|
||||
assign full = 0;
|
||||
end else begin
|
||||
|
||||
reg[DATAW-1:0] data[SIZE-1:0], curr_r, head_r;
|
||||
reg[$clog2(SIZE+1)-1:0] size_r;
|
||||
reg[$clog2(SIZE)-1:0] wr_ctr_r;
|
||||
reg[$clog2(SIZE)-1:0] rd_ptr_r, rd_next_ptr_r;
|
||||
reg empty_r, full_r, bypass_r;
|
||||
wire reading, writing;
|
||||
|
||||
assign reading = pop && !empty;
|
||||
assign writing = push && !full;
|
||||
|
||||
if (SIZE == 1) begin
|
||||
always @(posedge clk) begin
|
||||
if (reset) begin
|
||||
size_r <= 0;
|
||||
end else begin
|
||||
if (writing && !reading) begin
|
||||
size_r <= 1;
|
||||
end else if (reading && !writing) begin
|
||||
size_r <= 0;
|
||||
end
|
||||
|
||||
if (writing) begin
|
||||
head_r <= in_data;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
assign out_data = head_r;
|
||||
assign empty = (size_r == 0);
|
||||
assign full = (size_r != 0) && !pop;
|
||||
end else begin
|
||||
always @(posedge clk) begin
|
||||
if (reset) begin
|
||||
wr_ctr_r <= 0;
|
||||
end else begin
|
||||
if (writing)
|
||||
wr_ctr_r <= wr_ctr_r + 1;
|
||||
end
|
||||
end
|
||||
|
||||
always @(posedge clk) begin
|
||||
if (reset) begin
|
||||
size_r <= 0;
|
||||
empty_r <= 1;
|
||||
full_r <= 0;
|
||||
end else begin
|
||||
if (writing && !reading) begin
|
||||
size_r <= size_r + 1;
|
||||
empty_r <= 0;
|
||||
if (size_r == SIZE-1)
|
||||
full_r <= 1;
|
||||
end else if (reading && !writing) begin
|
||||
size_r <= size_r - 1;
|
||||
if (size_r == 1)
|
||||
empty_r <= 1;
|
||||
full_r <= 0;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
always @(posedge clk) begin
|
||||
if (writing) begin
|
||||
data[wr_ctr_r] <= in_data;
|
||||
end
|
||||
end
|
||||
|
||||
always @(posedge clk) begin
|
||||
if (reset) begin
|
||||
rd_ptr_r <= 0;
|
||||
rd_next_ptr_r <= 1;
|
||||
bypass_r <= 0;
|
||||
end else begin
|
||||
if (reading) begin
|
||||
if (SIZE == 2) begin
|
||||
rd_ptr_r <= rd_next_ptr_r;
|
||||
rd_next_ptr_r <= ~rd_next_ptr_r;
|
||||
end else if (SIZE > 2) begin
|
||||
rd_ptr_r <= rd_next_ptr_r;
|
||||
rd_next_ptr_r <= rd_ptr_r + 2;
|
||||
end
|
||||
end
|
||||
|
||||
bypass_r <= writing && (empty_r || (1 == size_r) && reading);
|
||||
curr_r <= in_data;
|
||||
head_r <= data[reading ? rd_next_ptr_r : rd_ptr_r];
|
||||
end
|
||||
end
|
||||
|
||||
assign out_data = bypass_r ? curr_r : head_r;
|
||||
assign empty = empty_r;
|
||||
assign full = full_r;
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
endmodule
|
||||
Reference in New Issue
Block a user