Skip to content

Commit 8ae7d03

Browse files
Lore0599colluca
andauthored
treewide: Add multicast support (#234)
* treewide: Add wide multicast support * treewide: Add narrow multicast support * sw: Fix runtime to support multi cluster systems * ci: Sanitize repo name for Docker tag name --------- Co-authored-by: Luca Colagrande <luca.colagrande3@gmail.com>
1 parent 48aebb1 commit 8ae7d03

File tree

26 files changed

+353
-82
lines changed

26 files changed

+353
-82
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ jobs:
2727
- name: Define Docker image name
2828
id: image_name
2929
# To satisfy Docker tag naming requirements, we replace all slashes
30-
# in the ref name with dashes.
30+
# in the ref name with hyphens and convert the repository name to lowercase.
3131
run: |
3232
SANITIZED_REF_NAME="${GITHUB_REF_NAME//\//-}"
3333
echo "Sanitized GITHUB_REF_NAME: $SANITIZED_REF_NAME"
34-
IMAGE_NAME="ghcr.io/${GITHUB_REPOSITORY}:${SANITIZED_REF_NAME}"
34+
SANITIZED_REPO_NAME="$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')"
35+
echo "Sanitized GITHUB_REPOSITORY: $SANITIZED_REPO_NAME"
36+
IMAGE_NAME="ghcr.io/${SANITIZED_REPO_NAME}:${SANITIZED_REF_NAME}"
3537
echo "Image name: $IMAGE_NAME"
3638
echo "image_name=$IMAGE_NAME" >> $GITHUB_OUTPUT
3739
- name: Free Disk Space (Ubuntu)

Bender.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ packages:
77
dependencies:
88
- common_cells
99
axi:
10-
revision: 39f5f2d51c5e524f6fc5cf8b6e901f7dcc5622d7
11-
version: 0.39.6
10+
revision: bec548fa2a9b18cbd7531105bb1fdf481ea8ad49
11+
version: null
1212
source:
13-
Git: https://github.com/pulp-platform/axi
13+
Git: https://github.com/colluca/axi.git
1414
dependencies:
1515
- common_cells
1616
- common_verification
@@ -42,8 +42,8 @@ packages:
4242
- scm
4343
- tech_cells_generic
4444
common_cells:
45-
revision: 9afda9abb565971649c2aa0985639c096f351171
46-
version: 1.38.0
45+
revision: 265b4cf5fe561cb837899c580f392ea93bf7e147
46+
version: null
4747
source:
4848
Git: https://github.com/pulp-platform/common_cells
4949
dependencies:
@@ -71,10 +71,10 @@ packages:
7171
dependencies:
7272
- common_cells
7373
idma:
74-
revision: ff5d56fffb3767814db88d6bf8f381974ea33aa5
75-
version: 0.6.4
74+
revision: c396bbf477457b184a74b7f2386302f5895bb522
75+
version: null
7676
source:
77-
Git: https://github.com/pulp-platform/iDMA
77+
Git: https://github.com/pulp-platform/iDMA.git
7878
dependencies:
7979
- axi
8080
- axi_stream

Bender.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ package:
1919
- Matheus Cavalcante <matheusd@iis.ee.ethz.ch>
2020

2121
dependencies:
22-
axi: { git: https://github.com/pulp-platform/axi, version: 0.39.6 }
22+
axi: { git: https://github.com/colluca/axi, rev: multicast }
2323
axi_riscv_atomics: { git: https://github.com/pulp-platform/axi_riscv_atomics, version: 0.6.0 }
24-
common_cells: { git: https://github.com/pulp-platform/common_cells, version: 1.35.0 }
24+
common_cells: { git: https://github.com/pulp-platform/common_cells, rev: multicast-xbar }
2525
FPnew: { git: https://github.com/pulp-platform/cvfpu.git, rev: pulp-v0.1.3 }
2626
register_interface: { git: https://github.com/pulp-platform/register_interface, version: 0.4.2 }
2727
tech_cells_generic: { git: https://github.com/pulp-platform/tech_cells_generic, version: 0.2.13 }
2828
riscv-dbg: { git: https://github.com/pulp-platform/riscv-dbg, version: 0.8.0 }
2929
cluster_icache: { git: https://github.com/pulp-platform/cluster_icache.git, rev: 64e21ae455bbdde850c4df13bef86ea55ac42537 }
30-
idma: { git: https://github.com/pulp-platform/iDMA, version: 0.6.4 }
30+
idma: { git: https://github.com/pulp-platform/iDMA.git, rev: __deploy__3c6bbb7__multicast-integration }
3131

3232
export_include_dirs:
3333
- hw/reqrsp_interface/include

hw/reqrsp_interface/include/reqrsp_interface/typedef.svh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
`define REQRSP_TYPEDEF_REQ_CHAN_T(__req_chan_t, __addr_t, __data_t, __strb_t) \
1212
typedef struct packed { \
1313
__addr_t addr; \
14+
__addr_t mask; \
1415
logic write; \
1516
reqrsp_pkg::amo_op_e amo; \
1617
__data_t data; \

hw/reqrsp_interface/src/axi_to_reqrsp.sv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ module axi_to_reqrsp #(
303303
// Silence those channels in case of a read.
304304
data: data & {DataWidth{meta.write}},
305305
strb: axi_req_i.w.strb & {StrbWidth{meta.write}},
306-
size: meta.size
306+
size: meta.size,
307+
default: '0
307308
};
308309

309310
always_comb begin

hw/snitch/src/riscv_instr.sv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +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;
330331
localparam logic [31:0] FREP_O = 32'b????????????????????????10001011;
331332
localparam logic [31:0] FREP_I = 32'b????????????????????????00001011;
332333
localparam logic [31:0] IREP = 32'b?????????????????????????0111111;
@@ -1140,6 +1141,7 @@ package riscv_instr;
11401141
localparam logic [11:0] CSR_FPMODE = 12'h7c1;
11411142
localparam logic [11:0] CSR_BARRIER = 12'h7c2;
11421143
localparam logic [11:0] CSR_SC = 12'h7c3;
1144+
localparam logic [11:0] CSR_MCAST = 12'h7c4;
11431145
localparam logic [11:0] CSR_HTIMEDELTAH = 12'h615;
11441146
localparam logic [11:0] CSR_CYCLEH = 12'hc80;
11451147
localparam logic [11:0] CSR_TIMEH = 12'hc81;

hw/snitch/src/snitch.sv

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ module snitch import snitch_pkg::*; import riscv_instr::*; #(
248248
logic csr_en;
249249
logic csr_dump;
250250
logic csr_stall_d, csr_stall_q;
251+
// Multicast mask
252+
logic [31:0] csr_mcast_d, csr_mcast_q;
251253

252254
localparam logic M = 0;
253255
localparam logic S = 1;
@@ -317,6 +319,7 @@ module snitch import snitch_pkg::*; import riscv_instr::*; #(
317319
end
318320

319321
`FFAR(csr_stall_q, csr_stall_d, '0, clk_i, rst_i)
322+
`FFAR(csr_mcast_q, csr_mcast_d, '0, clk_i, rst_i)
320323

321324
typedef struct packed {
322325
fpnew_pkg::fmt_mode_t fmode;
@@ -2220,6 +2223,16 @@ module snitch import snitch_pkg::*; import riscv_instr::*; #(
22202223
illegal_inst = 1'b1;
22212224
end
22222225
end
2226+
DMMCAST: begin
2227+
if (Xdma) begin
2228+
acc_qreq_o.addr = DMA_SS;
2229+
opa_select = Reg;
2230+
acc_qvalid_o = valid_instr;
2231+
write_rd = 1'b0;
2232+
end else begin
2233+
illegal_inst = 1'b1;
2234+
end
2235+
end
22232236
SCFGRI: begin
22242237
if (Xssr) begin
22252238
write_rd = 1'b0;
@@ -2345,6 +2358,7 @@ module snitch import snitch_pkg::*; import riscv_instr::*; #(
23452358
dscratch_d = dscratch_q;
23462359

23472360
csr_stall_d = csr_stall_q;
2361+
csr_mcast_d = csr_mcast_q;
23482362

23492363
if (barrier_i) csr_stall_d = 1'b0;
23502364
barrier_o = 1'b0;
@@ -2568,6 +2582,11 @@ module snitch import snitch_pkg::*; import riscv_instr::*; #(
25682582
barrier_o = 1'b1;
25692583
csr_stall_d = 1'b1;
25702584
end
2585+
// Multicast mask
2586+
CSR_MCAST: begin
2587+
csr_rvalue = csr_mcast_q;
2588+
csr_mcast_d = alu_result[31:0];
2589+
end
25712590
default: begin
25722591
csr_rvalue = '0;
25732592
csr_dump = 1'b1;
@@ -2888,6 +2907,7 @@ module snitch import snitch_pkg::*; import riscv_instr::*; #(
28882907
.lsu_qsize_i (ls_size),
28892908
.lsu_qamo_i (ls_amo),
28902909
.lsu_qrepd_i (1'b0),
2910+
.lsu_qmcast_i (addr_t'(csr_mcast_q)),
28912911
.lsu_qvalid_i (lsu_qvalid),
28922912
.lsu_qready_o (lsu_qready),
28932913
.lsu_pdata_o (ld_result),

hw/snitch/src/snitch_lsu.sv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ module snitch_lsu #(
5252
input logic [1:0] lsu_qsize_i,
5353
input reqrsp_pkg::amo_op_e lsu_qamo_i,
5454
input logic lsu_qrepd_i, // Whether this is a sequencer repetition
55+
input addr_t lsu_qmcast_i, // Multicast mask
5556
input logic lsu_qvalid_i,
5657
output logic lsu_qready_o,
5758
// response channel
@@ -250,6 +251,7 @@ module snitch_lsu #(
250251
assign data_req_o.q_valid = lsu_postcaq_qvalid & (lsu_qwrite_i | ~laq_full) & ~mem_full;
251252
assign data_req_o.q.write = lsu_qwrite_i;
252253
assign data_req_o.q.addr = lsu_qaddr_i;
254+
assign data_req_o.q.mask = lsu_qmcast_i;
253255
assign data_req_o.q.amo = lsu_qamo_i;
254256
assign data_req_o.q.size = lsu_qsize_i;
255257

hw/snitch_cluster/src/snitch_cluster.sv

Lines changed: 100 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ module snitch_cluster
3838
parameter int unsigned NarrowUserWidth = 1,
3939
/// AXI: dma user width.
4040
parameter int unsigned WideUserWidth = 1,
41+
/// Width of the atomic ID to be used in a system.
42+
parameter int unsigned AtomicIdWidth = 1,
4143
/// Boot Address from which to fetch the first instructions.
4244
/// Used if `AliasRegionEnable` or `IntBootromEnable` is not set.
4345
parameter logic [31:0] BootAddr = 32'h0,
@@ -71,6 +73,8 @@ module snitch_cluster
7173
parameter int unsigned ICacheWays [NrHives] = '{default: 0},
7274
/// Enable virtual memory support.
7375
parameter bit VMSupport = 1,
76+
/// Enable multicast on DMA XBAR.
77+
parameter bit EnableDMAMulticast = 0,
7478
/// Per-core enabling of the standard `E` ISA reduced-register extension.
7579
parameter bit [NrCores-1:0] RVE = '0,
7680
/// Per-core enabling of the standard `F` ISA extensions.
@@ -307,10 +311,29 @@ module snitch_cluster
307311
UniqueIds: 1'b0,
308312
AxiAddrWidth: PhysicalAddrWidth,
309313
AxiDataWidth: NarrowDataWidth,
310-
NoAddrRules: NrRules
314+
NoAddrRules: NrRules,
315+
default: '0
311316
};
312317

313318
// DMA configuration struct
319+
localparam axi_pkg::xbar_cfg_t DmaMcastXbarCfg = '{
320+
NoSlvPorts: NrWideMasters,
321+
NoMstPorts: NrWideSlaves,
322+
MaxMstTrans: WideMaxMstTrans,
323+
MaxSlvTrans: WideMaxSlvTrans,
324+
FallThrough: 1'b0,
325+
LatencyMode: WideXbarLatency,
326+
PipelineStages: 0,
327+
AxiIdWidthSlvPorts: WideIdWidthIn,
328+
AxiIdUsedSlvPorts: WideIdWidthIn,
329+
UniqueIds: 1'b0,
330+
AxiAddrWidth: PhysicalAddrWidth,
331+
AxiDataWidth: WideDataWidth,
332+
NoAddrRules: NrWideRules,
333+
NoMulticastRules: 1,
334+
NoMulticastPorts: 2,
335+
default: '0
336+
};
314337
localparam axi_pkg::xbar_cfg_t DmaXbarCfg = '{
315338
NoSlvPorts: NrWideMasters,
316339
NoMstPorts: NrWideSlaves,
@@ -324,7 +347,8 @@ module snitch_cluster
324347
UniqueIds: 1'b0,
325348
AxiAddrWidth: PhysicalAddrWidth,
326349
AxiDataWidth: WideDataWidth,
327-
NoAddrRules: NrWideRules
350+
NoAddrRules: NrWideRules,
351+
default: '0
328352
};
329353

330354
function automatic int unsigned get_hive_size(int unsigned current_hive);
@@ -355,7 +379,9 @@ module snitch_cluster
355379
typedef logic [WideIdWidthIn-1:0] id_dma_mst_t;
356380
typedef logic [WideIdWidthOut-1:0] id_dma_slv_t;
357381
typedef logic [NarrowUserWidth-1:0] user_t;
358-
typedef logic [WideUserWidth-1:0] user_dma_t;
382+
typedef struct packed {
383+
logic [WideUserWidth-1:0] mcast;
384+
} user_dma_t;
359385

360386
typedef logic [TCDMMemAddrWidth-1:0] tcdm_mem_addr_t;
361387
typedef logic [TCDMAddrWidth-1:0] tcdm_addr_t;
@@ -587,8 +613,14 @@ module snitch_cluster
587613
.mst_resp_i (wide_axi_mst_rsp[SoCDMAIn])
588614
);
589615

590-
logic [DmaXbarCfg.NoSlvPorts-1:0][$clog2(DmaXbarCfg.NoMstPorts)-1:0] dma_xbar_default_port;
591-
assign dma_xbar_default_port = '{default: SoCDMAOut};
616+
617+
int unsigned dma_xbar_default_port = SoCDMAOut;
618+
xbar_rule_t dma_xbar_default_port_rule;
619+
assign dma_xbar_default_port_rule = '{
620+
idx: dma_xbar_default_port,
621+
start_addr: tcdm_start_address,
622+
end_addr: zero_mem_end_address
623+
};
592624

593625
xbar_rule_t [5:0] dma_xbar_rules;
594626
xbar_rule_t [DmaXbarCfg.NoAddrRules-1:0] enabled_dma_xbar_rule;
@@ -615,35 +647,67 @@ module snitch_cluster
615647
end
616648

617649
localparam bit [DmaXbarCfg.NoSlvPorts-1:0] DMAEnableDefaultMstPort = '1;
618-
axi_xbar #(
619-
.Cfg (DmaXbarCfg),
620-
.ATOPs (0),
621-
.slv_aw_chan_t (axi_mst_dma_aw_chan_t),
622-
.mst_aw_chan_t (axi_slv_dma_aw_chan_t),
623-
.w_chan_t (axi_mst_dma_w_chan_t),
624-
.slv_b_chan_t (axi_mst_dma_b_chan_t),
625-
.mst_b_chan_t (axi_slv_dma_b_chan_t),
626-
.slv_ar_chan_t (axi_mst_dma_ar_chan_t),
627-
.mst_ar_chan_t (axi_slv_dma_ar_chan_t),
628-
.slv_r_chan_t (axi_mst_dma_r_chan_t),
629-
.mst_r_chan_t (axi_slv_dma_r_chan_t),
630-
.slv_req_t (axi_mst_dma_req_t),
631-
.slv_resp_t (axi_mst_dma_resp_t),
632-
.mst_req_t (axi_slv_dma_req_t),
633-
.mst_resp_t (axi_slv_dma_resp_t),
634-
.rule_t (xbar_rule_t)
635-
) i_axi_dma_xbar (
636-
.clk_i (clk_i),
637-
.rst_ni (rst_ni),
638-
.test_i (1'b0),
639-
.slv_ports_req_i (wide_axi_mst_req),
640-
.slv_ports_resp_o (wide_axi_mst_rsp),
641-
.mst_ports_req_o (wide_axi_slv_req),
642-
.mst_ports_resp_i (wide_axi_slv_rsp),
643-
.addr_map_i (enabled_dma_xbar_rule),
644-
.en_default_mst_port_i (DMAEnableDefaultMstPort),
645-
.default_mst_port_i (dma_xbar_default_port)
646-
);
650+
if (EnableDMAMulticast) begin : gen_mcast_dma_xbar
651+
axi_mcast_xbar #(
652+
.Cfg (DmaMcastXbarCfg),
653+
.ATOPs (0),
654+
.slv_aw_chan_t (axi_mst_dma_aw_chan_t),
655+
.mst_aw_chan_t (axi_slv_dma_aw_chan_t),
656+
.w_chan_t (axi_mst_dma_w_chan_t),
657+
.slv_b_chan_t (axi_mst_dma_b_chan_t),
658+
.mst_b_chan_t (axi_slv_dma_b_chan_t),
659+
.slv_ar_chan_t (axi_mst_dma_ar_chan_t),
660+
.mst_ar_chan_t (axi_slv_dma_ar_chan_t),
661+
.slv_r_chan_t (axi_mst_dma_r_chan_t),
662+
.mst_r_chan_t (axi_slv_dma_r_chan_t),
663+
.slv_req_t (axi_mst_dma_req_t),
664+
.slv_resp_t (axi_mst_dma_resp_t),
665+
.mst_req_t (axi_slv_dma_req_t),
666+
.mst_resp_t (axi_slv_dma_resp_t),
667+
.rule_t (xbar_rule_t)
668+
) i_axi_dma_xbar (
669+
.clk_i (clk_i),
670+
.rst_ni (rst_ni),
671+
.test_i (1'b0),
672+
.slv_ports_req_i (wide_axi_mst_req),
673+
.slv_ports_resp_o (wide_axi_mst_rsp),
674+
.mst_ports_req_o (wide_axi_slv_req),
675+
.mst_ports_resp_i (wide_axi_slv_rsp),
676+
.addr_map_i (enabled_dma_xbar_rule),
677+
.en_default_mst_port_i (DMAEnableDefaultMstPort),
678+
.default_mst_port_i ({DmaXbarCfg.NoSlvPorts{dma_xbar_default_port_rule}})
679+
);
680+
end else begin : gen_dma_xbar
681+
axi_xbar #(
682+
.Cfg (DmaXbarCfg),
683+
.ATOPs (0),
684+
.slv_aw_chan_t (axi_mst_dma_aw_chan_t),
685+
.mst_aw_chan_t (axi_slv_dma_aw_chan_t),
686+
.w_chan_t (axi_mst_dma_w_chan_t),
687+
.slv_b_chan_t (axi_mst_dma_b_chan_t),
688+
.mst_b_chan_t (axi_slv_dma_b_chan_t),
689+
.slv_ar_chan_t (axi_mst_dma_ar_chan_t),
690+
.mst_ar_chan_t (axi_slv_dma_ar_chan_t),
691+
.slv_r_chan_t (axi_mst_dma_r_chan_t),
692+
.mst_r_chan_t (axi_slv_dma_r_chan_t),
693+
.slv_req_t (axi_mst_dma_req_t),
694+
.slv_resp_t (axi_mst_dma_resp_t),
695+
.mst_req_t (axi_slv_dma_req_t),
696+
.mst_resp_t (axi_slv_dma_resp_t),
697+
.rule_t (xbar_rule_t)
698+
) i_axi_dma_xbar (
699+
.clk_i (clk_i),
700+
.rst_ni (rst_ni),
701+
.test_i (1'b0),
702+
.slv_ports_req_i (wide_axi_mst_req),
703+
.slv_ports_resp_o (wide_axi_mst_rsp),
704+
.mst_ports_req_o (wide_axi_slv_req),
705+
.mst_ports_resp_i (wide_axi_slv_rsp),
706+
.addr_map_i (enabled_dma_xbar_rule),
707+
.en_default_mst_port_i (DMAEnableDefaultMstPort),
708+
.default_mst_port_i ({DmaXbarCfg.NoSlvPorts{dma_xbar_default_port}})
709+
);
710+
end
647711

648712
axi_zero_mem #(
649713
.axi_req_t (axi_slv_dma_req_t),
@@ -1089,7 +1153,8 @@ module snitch_cluster
10891153
user_t cluster_user;
10901154
// Atomic ID, needs to be unique ID of cluster
10911155
// cluster_id + HartIdOffset + 1 (because 0 is for non-atomic masters)
1092-
assign cluster_user = (hart_base_id_i / NrCores) + (hart_base_id_i % NrCores) + 1'b1;
1156+
assign cluster_user = (core_to_axi_req.q.mask << AtomicIdWidth) |
1157+
((hart_base_id_i / NrCores) + (hart_base_id_i % NrCores) + 1'b1);
10931158

10941159
reqrsp_mux #(
10951160
.NrPorts (NrCores),

hw/snitch_cluster/src/snitch_cluster_pkg.sv.tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ package ${cfg['cluster']['name']}_pkg;
5858

5959
localparam int unsigned NarrowUserWidth = ${cfg['cluster']['user_width']};
6060
localparam int unsigned WideUserWidth = ${cfg['cluster']['dma_user_width']};
61+
localparam int unsigned AtomicIdWidth = ${cfg['cluster']['atomic_id_width']};
6162

6263
localparam int unsigned ICacheLineWidth [NrHives] = '{${icache_cfg('cacheline')}};
6364
localparam int unsigned ICacheLineCount [NrHives] = '{${icache_cfg('depth')}};

0 commit comments

Comments
 (0)