Skip to content

Commit 0c554a2

Browse files
committed
hw: Generalize DMMCAST instruction and MCAST CSR
1 parent 5b2fccd commit 0c554a2

File tree

4 files changed

+29
-25
lines changed

4 files changed

+29
-25
lines changed

hw/snitch/src/riscv_instr.sv

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ package riscv_instr;
327327
localparam logic [31:0] DMSTAT = 32'b0000101?????00000000?????0101011;
328328
localparam logic [31:0] DMSTR = 32'b0000110??????????000000000101011;
329329
localparam logic [31:0] DMREP = 32'b000011100000?????000000000101011;
330-
localparam logic [31:0] DMMCAST = 32'b000100000000?????000000000101011;
330+
localparam logic [31:0] DMUSER = 32'b0001000??????????000000000101011;
331331
localparam logic [31:0] FREP_O = 32'b????????????????????????10001011;
332332
localparam logic [31:0] IREP = 32'b?????????????????????????0111111;
333333
localparam logic [31:0] SCFGRI = 32'b????????????00000001?????0101011;
@@ -1140,7 +1140,8 @@ package riscv_instr;
11401140
localparam logic [11:0] CSR_FPMODE = 12'h7c1;
11411141
localparam logic [11:0] CSR_BARRIER = 12'h7c2;
11421142
localparam logic [11:0] CSR_SC = 12'h7c3;
1143-
localparam logic [11:0] CSR_MCAST = 12'h7c4;
1143+
localparam logic [11:0] CSR_USER_LOW = 12'h7c4;
1144+
localparam logic [11:0] CSR_USER_HIGH = 12'h7c5;
11441145
localparam logic [11:0] CSR_HTIMEDELTAH = 12'h615;
11451146
localparam logic [11:0] CSR_CYCLEH = 12'hc80;
11461147
localparam logic [11:0] CSR_TIMEH = 12'hc81;

hw/snitch/src/snitch.sv

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,10 @@ module snitch import snitch_pkg::*; import riscv_instr::*; #(
247247
logic csr_en;
248248
logic csr_dump;
249249
logic csr_stall_d, csr_stall_q;
250-
// Multicast mask
251-
logic [31:0] csr_mcast_d, csr_mcast_q;
250+
251+
// User Field
252+
logic [31:0] csr_user_high_d, csr_user_high_q;
253+
logic [31:0] csr_user_low_d, csr_user_low_q;
252254

253255
localparam logic M = 0;
254256
localparam logic S = 1;
@@ -320,7 +322,8 @@ module snitch import snitch_pkg::*; import riscv_instr::*; #(
320322
end
321323

322324
`FFAR(csr_stall_q, csr_stall_d, '0, clk_i, rst_i)
323-
`FFAR(csr_mcast_q, csr_mcast_d, '0, clk_i, rst_i)
325+
`FFAR(csr_user_high_q, csr_user_high_d, '0, clk_i, rst_i)
326+
`FFAR(csr_user_low_q, csr_user_low_d, '0, clk_i, rst_i)
324327

325328
typedef struct packed {
326329
fpnew_pkg::fmt_mode_t fmode;
@@ -2152,6 +2155,7 @@ module snitch import snitch_pkg::*; import riscv_instr::*; #(
21522155
// DMA instructions
21532156
DMSRC,
21542157
DMDST,
2158+
DMUSER,
21552159
DMSTR: begin
21562160
if (Xdma) begin
21572161
acc_qreq_o.addr = DMA_SS;
@@ -2221,16 +2225,6 @@ module snitch import snitch_pkg::*; import riscv_instr::*; #(
22212225
illegal_inst = 1'b1;
22222226
end
22232227
end
2224-
DMMCAST: begin
2225-
if (Xdma) begin
2226-
acc_qreq_o.addr = DMA_SS;
2227-
opa_select = Reg;
2228-
acc_qvalid_o = valid_instr;
2229-
write_rd = 1'b0;
2230-
end else begin
2231-
illegal_inst = 1'b1;
2232-
end
2233-
end
22342228
SCFGRI: begin
22352229
if (Xssr) begin
22362230
write_rd = 1'b0;
@@ -2358,7 +2352,8 @@ module snitch import snitch_pkg::*; import riscv_instr::*; #(
23582352
dscratch_d = dscratch_q;
23592353

23602354
csr_stall_d = csr_stall_q;
2361-
csr_mcast_d = csr_mcast_q;
2355+
csr_user_high_d = csr_user_high_q;
2356+
csr_user_low_d = csr_user_low_q;
23622357

23632358
if (barrier_i) csr_stall_d = 1'b0;
23642359
barrier_o = 1'b0;
@@ -2585,10 +2580,15 @@ module snitch import snitch_pkg::*; import riscv_instr::*; #(
25852580
barrier_o = 1'b1;
25862581
csr_stall_d = 1'b1;
25872582
end
2588-
// Multicast mask
2589-
CSR_MCAST: begin
2590-
csr_rvalue = csr_mcast_q;
2591-
csr_mcast_d = alu_result[31:0];
2583+
// User field high
2584+
CSR_USER_HIGH: begin
2585+
csr_rvalue = csr_user_high_q;
2586+
csr_user_high_d = alu_result[31:0];
2587+
end
2588+
// User field low
2589+
CSR_USER_LOW: begin
2590+
csr_rvalue = csr_user_low_q;
2591+
csr_user_low_d = alu_result[31:0];
25922592
end
25932593
default: begin
25942594
csr_rvalue = '0;
@@ -2890,6 +2890,7 @@ module snitch import snitch_pkg::*; import riscv_instr::*; #(
28902890
snitch_lsu #(
28912891
.AddrWidth (AddrWidth),
28922892
.DataWidth (DataWidth),
2893+
.UserWidth (64),
28932894
.dreq_t (dreq_t),
28942895
.drsp_t (drsp_t),
28952896
.tag_t (logic[RegWidth-1:0]),
@@ -2910,7 +2911,7 @@ module snitch import snitch_pkg::*; import riscv_instr::*; #(
29102911
.lsu_qsize_i (ls_size),
29112912
.lsu_qamo_i (ls_amo),
29122913
.lsu_qrepd_i (1'b0),
2913-
.lsu_qmcast_i (addr_t'(csr_mcast_q)),
2914+
.lsu_quser_i ({csr_user_high_q, csr_user_low_q}),
29142915
.lsu_qvalid_i (lsu_qvalid),
29152916
.lsu_qready_o (lsu_qready),
29162917
.lsu_pdata_o (ld_result),

hw/snitch/src/snitch_lsu.sv

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
module snitch_lsu #(
1212
parameter int unsigned AddrWidth = 32,
1313
parameter int unsigned DataWidth = 32,
14+
parameter int unsigned UserWidth = 0,
1415
/// Tag passed from input to output. All transactions are in-order.
1516
parameter type tag_t = logic [4:0],
1617
/// Number of outstanding memory transactions.
@@ -37,7 +38,8 @@ module snitch_lsu #(
3738
parameter type drsp_t = logic,
3839
/// Derived parameter *Do not override*
3940
parameter type addr_t = logic [AddrWidth-1:0],
40-
parameter type data_t = logic [DataWidth-1:0]
41+
parameter type data_t = logic [DataWidth-1:0],
42+
parameter type user_t = logic [UserWidth-1:0]
4143
) (
4244
input logic clk_i,
4345
input logic rst_i,
@@ -50,7 +52,7 @@ module snitch_lsu #(
5052
input logic [1:0] lsu_qsize_i,
5153
input reqrsp_pkg::amo_op_e lsu_qamo_i,
5254
input logic lsu_qrepd_i, // Whether this is a sequencer repetition
53-
input addr_t lsu_qmcast_i, // Multicast mask
55+
input user_t lsu_quser_i, // User field for the axi transmission
5456
input logic lsu_qvalid_i,
5557
output logic lsu_qready_o,
5658
// response channel
@@ -254,7 +256,7 @@ module snitch_lsu #(
254256
assign data_req_o.q_valid = lsu_postcaq_qvalid & (lsu_qwrite_i | ~laq_full) & ~mem_full;
255257
assign data_req_o.q.write = lsu_qwrite_i;
256258
assign data_req_o.q.addr = lsu_qaddr_i;
257-
assign data_req_o.q.mask = lsu_qmcast_i;
259+
assign data_req_o.q.user = lsu_quser_i;
258260
assign data_req_o.q.amo = lsu_qamo_i;
259261
assign data_req_o.q.size = lsu_qsize_i;
260262

sw/deps/riscv-opcodes

0 commit comments

Comments
 (0)