Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hw: Support multi-ID DMA #144

Merged
merged 31 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
43da2c3
hw: Enable Multi channel DMA
fischeti May 28, 2024
9931322
sw: Clean up runtime and add support for multi channel DMA
fischeti May 28, 2024
b45b2b7
sw: Format clean up DMA runtime functions
fischeti May 28, 2024
f4b5138
sw: Format again
fischeti May 28, 2024
a3bdecd
hw: Connect multi channels to wide Xbar directly
fischeti May 28, 2024
379636c
sw: Fix dst and src stride order in `dmstr` instruction
fischeti May 28, 2024
e40d894
sw: Wait for DMA transfers to finish during initialization
fischeti May 29, 2024
3ef6e60
sw: Fix channel selection for 2D transfers
fischeti May 29, 2024
7293b16
sw: Add channel specific DMA wait functions
fischeti May 29, 2024
ee3c438
sw: Add DMA mchan test
fischeti May 29, 2024
9da8dd5
ci: Add multi channel DMA test to CI
fischeti May 29, 2024
87feae7
ci: Remove `dma_mchan` from default configuration tests
fischeti May 29, 2024
6f6a63c
ci: Fix dma mchan config
fischeti May 29, 2024
84920b2
lint: C sources
fischeti May 29, 2024
7ec052c
ci: Build `dma_mchan` test but don't run it
fischeti May 29, 2024
9a7e0a2
sw: Small comment changes in `dma_chan` test
fischeti May 30, 2024
8ea2ea8
sw: Switch back to `.word` instructions for DMA ISA extensions
fischeti Jul 16, 2024
5d180f9
sw: Small fixes for DMA runtime functions
fischeti Jul 16, 2024
bb0ad23
sw: Lint C sources
fischeti Jul 16, 2024
05cbdad
hw: Align port signals
fischeti Jul 16, 2024
e83c94c
hw: Fix typo
fischeti Jul 16, 2024
f2e5f8d
sw: Remove DMA waits again and move to `main`
fischeti Jul 16, 2024
f89adeb
test: Remove empty test configuration in `run.yaml`
fischeti Jul 16, 2024
e08d50c
doc: Update documentation for multi-ID DMA usage
fischeti Jul 16, 2024
9cc09cd
Revert "sw: Remove DMA waits again and move to `main`"
fischeti Jul 16, 2024
338c3d7
sw: Remove redundant DMA wait calls
fischeti Jul 16, 2024
e0d9fdd
test: Use separate test list for `dma_mchan` configuration
fischeti Jul 16, 2024
fc20636
git: Ignore `.rtlbinary` File
fischeti Jul 16, 2024
93ece3a
test: Compile all test by default
fischeti Jul 22, 2024
ee4e8c4
test: Don't use `TEST_LIST` flag anymore
fischeti Jul 22, 2024
ac92eba
test: Remove deprecated `interrupt` test
fischeti Jul 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ snitch-cluster-omega-vsim:
- make bin/snitch_cluster.vsim
- ./util/run.py sw/run.yaml --simulator vsim -j --run-dir runs/vsim

# Test Multi-channel DMA
snitch-cluster-mchan-vsim:
script:
- cd target/snitch_cluster
- make CFG_OVERRIDE=cfg/dma_mchan.hjson sw
- make bin/snitch_cluster.vsim
- ./util/run.py sw/dma_mchan.yaml --simulator vsim -j --run-dir runs/vsim

############
# Non-free #
############
Expand Down
1 change: 1 addition & 0 deletions docs/rm/custom_instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ DMCPY and DMCPYI initiate an asynchronous data movement with the parameters conf
|--------------|-------------|-------------
| config[0] | decouple_rw | Decouple the handshakes of the read and write channels
| config[1] | enable_2d | Enable two-dimensional transfer
| config[4:2] | channel_sel | Selects the DMA backend if a multi-channel DMA is used

DMSTAT and DMSTATI place the selected *status* flag of the DMA into register *rd*. The following *status* flags are supported:

Expand Down
5 changes: 5 additions & 0 deletions docs/schema/snitch_cluster.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@
"description": "Id width of the wide AXI plug into the cluster.",
"default": 1
},
"dma_nr_channels": {
"type": "number",
"description": "The number of separate DMA channels to instantiate.",
"default": 1
},
"user_width": {
"type": "number",
"description": "User width of the narrower AXI plug into the cluster.",
Expand Down
4 changes: 2 additions & 2 deletions hw/snitch/src/snitch_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ package snitch_pkg;
} cluster_slave_dma_e;

typedef enum int unsigned {
SDMAMst = 32'd0,
SoCDMAIn = 32'd1,
SoCDMAIn = 32'd0,
SDMAMst = 32'd1,
colluca marked this conversation as resolved.
Show resolved Hide resolved
ICache = 32'd2
} cluster_master_dma_e;

Expand Down
44 changes: 23 additions & 21 deletions hw/snitch_cluster/src/snitch_cc.sv
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module snitch_cc #(
parameter int unsigned DMAUserWidth = 0,
parameter int unsigned DMANumAxInFlight = 0,
parameter int unsigned DMAReqFifoDepth = 0,
parameter int unsigned DMANumChannels = 0,
/// Data port request type.
parameter type dreq_t = logic,
/// Data port response type.
Expand Down Expand Up @@ -114,33 +115,33 @@ module snitch_cc #(
parameter type addr_t = logic [AddrWidth-1:0],
parameter type data_t = logic [DataWidth-1:0]
) (
input logic clk_i,
input logic clk_d2_i,
input logic rst_ni,
input logic rst_int_ss_ni,
input logic rst_fp_ss_ni,
input logic [31:0] hart_id_i,
input snitch_pkg::interrupts_t irq_i,
output hive_req_t hive_req_o,
input hive_rsp_t hive_rsp_i,
input logic clk_i,
input logic clk_d2_i,
input logic rst_ni,
input logic rst_int_ss_ni,
input logic rst_fp_ss_ni,
input logic [31:0] hart_id_i,
input snitch_pkg::interrupts_t irq_i,
output hive_req_t hive_req_o,
input hive_rsp_t hive_rsp_i,
// Core data ports
output dreq_t data_req_o,
input drsp_t data_rsp_i,
output dreq_t data_req_o,
input drsp_t data_rsp_i,
// TCDM Streamer Ports
output tcdm_req_t [TCDMPorts-1:0] tcdm_req_o,
input tcdm_rsp_t [TCDMPorts-1:0] tcdm_rsp_i,
output tcdm_req_t [TCDMPorts-1:0] tcdm_req_o,
input tcdm_rsp_t [TCDMPorts-1:0] tcdm_rsp_i,
// Accelerator Offload port
// DMA ports
output axi_req_t axi_dma_req_o,
input axi_rsp_t axi_dma_res_i,
output logic axi_dma_busy_o,
output dma_events_t axi_dma_events_o,
output axi_req_t [DMANumChannels-1:0] axi_dma_req_o,
input axi_rsp_t [DMANumChannels-1:0] axi_dma_res_i,
output logic [DMANumChannels-1:0] axi_dma_busy_o,
output dma_events_t [DMANumChannels-1:0] axi_dma_events_o,
fischeti marked this conversation as resolved.
Show resolved Hide resolved
// Core event strobes
output snitch_pkg::core_events_t core_events_o,
input addr_t tcdm_addr_base_i,
output snitch_pkg::core_events_t core_events_o,
input addr_t tcdm_addr_base_i,
// Cluster HW barrier
output logic barrier_o,
input logic barrier_i
output logic barrier_o,
input logic barrier_i
);

// FMA architecture is "merged" -> mulexp and macexp instructions are supported
Expand Down Expand Up @@ -385,6 +386,7 @@ module snitch_cc #(
.AxiUserWidth (DMAUserWidth),
.NumAxInFlight (DMANumAxInFlight),
.DMAReqFifoDepth (DMAReqFifoDepth),
.NumChannels (DMANumChannels),
.axi_ar_chan_t (axi_ar_chan_t),
.axi_aw_chan_t (axi_aw_chan_t),
.axi_req_t (axi_req_t),
Expand Down
27 changes: 16 additions & 11 deletions hw/snitch_cluster/src/snitch_cluster.sv
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module snitch_cluster
parameter int unsigned WideDataWidth = 512,
/// AXI: id width in.
parameter int unsigned NarrowIdWidthIn = 2,
/// AXI: dma id with in *currently not available*
/// AXI: dma id width in.
parameter int unsigned WideIdWidthIn = 2,
/// AXI: user width.
parameter int unsigned NarrowUserWidth = 1,
Expand All @@ -57,6 +57,8 @@ module snitch_cluster
parameter int unsigned DMANumAxInFlight = 3,
/// Size of DMA request fifo.
parameter int unsigned DMAReqFifoDepth = 3,
/// Number of DMA channels.
parameter int unsigned DMANumChannels = 1,
/// Width of a single icache line.
parameter int unsigned ICacheLineWidth [NrHives] = '{default: 0},
/// Number of icache lines per set.
Expand Down Expand Up @@ -274,8 +276,8 @@ module snitch_cluster
localparam int unsigned NrRuleIdcs = NrSlaves - 1;
localparam int unsigned NrRules = (1 + AliasRegionEnable) * NrRuleIdcs;

// DMA, SoC Request, `n` instruction caches.
localparam int unsigned NrWideMasters = 2 + NrHives;
// SoC Request, DMA Channels, `n` instruction caches.
localparam int unsigned NrWideMasters = 1 + DMANumChannels + NrHives;
localparam int unsigned WideIdWidthOut = $clog2(NrWideMasters) + WideIdWidthIn;
// DMA X-BAR configuration
localparam int unsigned NrWideSlaves = 3;
Expand Down Expand Up @@ -837,10 +839,10 @@ module snitch_cluster
localparam int unsigned TcdmPorts = get_tcdm_ports(i);
localparam int unsigned TcdmPortsOffs = get_tcdm_port_offs(i);

axi_mst_dma_req_t axi_dma_req;
axi_mst_dma_resp_t axi_dma_res;
axi_mst_dma_req_t [DMANumChannels-1:0] axi_dma_req;
axi_mst_dma_resp_t [DMANumChannels-1:0] axi_dma_res;
interrupts_t irq;
dma_events_t dma_core_events;
dma_events_t [DMANumChannels-1:0] dma_core_events;

sync #(.STAGES (2))
i_sync_debug (.clk_i, .rst_ni, .serial_i (debug_req_i[i]), .serial_o (irq.debug));
Expand All @@ -863,6 +865,7 @@ module snitch_cluster
.SnitchPMACfg (SnitchPMACfg),
.DMANumAxInFlight (DMANumAxInFlight),
.DMAReqFifoDepth (DMAReqFifoDepth),
.DMANumChannels (DMANumChannels),
.dreq_t (reqrsp_req_t),
.drsp_t (reqrsp_rsp_t),
.tcdm_req_t (tcdm_req_t),
Expand Down Expand Up @@ -951,9 +954,11 @@ module snitch_cluster
end
end
if (Xdma[i]) begin : gen_dma_connection
assign wide_axi_mst_req[SDMAMst] = axi_dma_req;
assign axi_dma_res = wide_axi_mst_rsp[SDMAMst];
assign dma_events = dma_core_events;
for (genvar j = 0; j < DMANumChannels; j++) begin : gen_dma_connection
assign wide_axi_mst_req[SDMAMst + j] = axi_dma_req[j];
assign axi_dma_res[j] = wide_axi_mst_rsp[SDMAMst + j];
end
assign dma_events = dma_core_events[0]; // Only first channel is tracked
fischeti marked this conversation as resolved.
Show resolved Hide resolved
end
end

Expand Down Expand Up @@ -1001,8 +1006,8 @@ module snitch_cluster
.hive_rsp_o (hive_rsp_reshape),
.ptw_data_req_o (ptw_req[i]),
.ptw_data_rsp_i (ptw_rsp[i]),
.axi_req_o (wide_axi_mst_req[ICache+i]),
.axi_rsp_i (wide_axi_mst_rsp[ICache+i]),
.axi_req_o (wide_axi_mst_req[SDMAMst+DMANumChannels+i]),
.axi_rsp_i (wide_axi_mst_rsp[SDMAMst+DMANumChannels+i]),
.icache_prefetch_enable_i (icache_prefetch_enable),
.icache_events_o(icache_events_reshape),
.sram_cfgs_i
Expand Down
9 changes: 5 additions & 4 deletions hw/snitch_cluster/src/snitch_cluster_wrapper.sv.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ package ${cfg['pkg_name']};
localparam int unsigned WideDataWidth = ${cfg['dma_data_width']};

localparam int unsigned NarrowIdWidthIn = ${cfg['id_width_in']};
localparam int unsigned NrMasters = 3;
localparam int unsigned NarrowIdWidthOut = $clog2(NrMasters) + NarrowIdWidthIn;
localparam int unsigned NrNarrowMasters = 3;
localparam int unsigned NarrowIdWidthOut = $clog2(NrNarrowMasters) + NarrowIdWidthIn;

localparam int unsigned NrDmaMasters = 2 + ${cfg['nr_hives']};
localparam int unsigned NrWideMasters = 1 + ${cfg['dma_nr_channels']} + ${cfg['nr_hives']};
localparam int unsigned WideIdWidthIn = ${cfg['dma_id_width_in']};
localparam int unsigned WideIdWidthOut = $clog2(NrDmaMasters) + WideIdWidthIn;
localparam int unsigned WideIdWidthOut = $clog2(NrWideMasters) + WideIdWidthIn;

localparam int unsigned NarrowUserWidth = ${cfg['user_width']};
localparam int unsigned WideUserWidth = ${cfg['dma_user_width']};
Expand Down Expand Up @@ -274,6 +274,7 @@ module ${cfg['name']}_wrapper (
.NrBanks (${cfg['tcdm']['banks']}),
.DMANumAxInFlight (${cfg['dma_axi_req_fifo_depth']}),
.DMAReqFifoDepth (${cfg['dma_req_fifo_depth']}),
.DMANumChannels (${cfg['dma_nr_channels']}),
.ICacheLineWidth (${cfg['pkg_name']}::ICacheLineWidth),
.ICacheLineCount (${cfg['pkg_name']}::ICacheLineCount),
.ICacheSets (${cfg['pkg_name']}::ICacheSets),
Expand Down
Loading
Loading