From c9b31d89b258705fdfd2e57553f18e5697455bb5 Mon Sep 17 00:00:00 2001 From: Daniel Keller Date: Wed, 11 Nov 2026 14:20:02 +0100 Subject: [PATCH 1/2] backend: Size the channel coupler for the transpose tile The R-AW coupler queue was sized by NumAxInFlight alone, while a transpose tile issues one write per row before its first W beat. Below the tile height the coupler fills, stalls the legalizer and the tile never completes. With transpose enabled, size the coupler and every write queue that holds a tile to at least two writes per tile row, so rows split at a 4 KiB boundary still fit. A transpose config change drains the backend, so one tile is enough. MX-only and non-compute builds keep their sizing. Fixes #275 --- CHANGELOG.md | 7 +++++++ idma.mk | 11 +++++++--- src/backend/tpl/idma_backend.sv.tpl | 23 +++++++++++++-------- target/sim/vlt/testbenches.mk | 11 +++++++++- test/tb_idma_transpose_nd.sv | 31 +++++++++++++++++++++-------- 5 files changed, 63 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a173d884a..d75c1e170 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed +- Transpose no longer deadlocks when `NumAxInFlight` is below the tile height: the R-AW coupler + and the write queues hold at least one whole tile, including rows split at a 4 KiB boundary + [#275](https://github.com/pulp-platform/iDMA/issues/275). + ## 0.7.4 - 2026-10-06 MX changes the on-chip MX format and layout; MX has no production users yet, so they stay on 0.7.x. diff --git a/idma.mk b/idma.mk index 3ae3466bc..b70df376a 100644 --- a/idma.mk +++ b/idma.mk @@ -435,9 +435,14 @@ idma_sim_tb_idma_otf_transpose: .PHONY: idma_sim_tb_idma_transpose_nd idma_sim_tb_idma_transpose_nd: $(IDMA_VSIM_DIR)/compile.tcl cd $(IDMA_VSIM_DIR); $(VSIM) -c -do "source compile.tcl; quit" - # the TB sweeps the geometry list internally; one run per bus width - cd $(IDMA_VSIM_DIR); $(VSIM) -c -t 1ps -voptargs=+acc -gDataWidth=32 tb_idma_transpose_nd -do "run -all; quit" - cd $(IDMA_VSIM_DIR); $(VSIM) -c -t 1ps -voptargs=+acc -gDataWidth=64 tb_idma_transpose_nd -do "run -all; quit" + # the TB sweeps the geometry list internally; the shallow-queue runs must still fit a whole tile + cd $(IDMA_VSIM_DIR); for g in "-gDataWidth=32" "-gDataWidth=64" "-gDataWidth=64 -gAxIF=2" \ + "-gDataWidth=64 -gAxIF=2 -gMaxAwAhead=1" "-gDataWidth=128 -gAxIF=2 -gMaxAwAhead=1" \ + "-gDataWidth=512 -gAxIF=24 -gMaxAwAhead=1" "-gDataWidth=512 -gAxIF=24 -gMaxAwAhead=2"; do \ + $(VSIM) -c -t 1ps -voptargs=+acc $$g tb_idma_transpose_nd -logfile transpose_nd.log \ + -do "run -all; quit"; \ + ! grep -qE "Error:|Fatal:" transpose_nd.log || exit 1; \ + grep -q "\[TPN\] ALL PASS" transpose_nd.log || exit 1; done # OBI-destination transpose: the write strobe must mask edge tiles and padding .PHONY: idma_sim_tb_idma_transpose_obi diff --git a/src/backend/tpl/idma_backend.sv.tpl b/src/backend/tpl/idma_backend.sv.tpl index d4e022b37..86201350a 100644 --- a/src/backend/tpl/idma_backend.sv.tpl +++ b/src/backend/tpl/idma_backend.sv.tpl @@ -180,11 +180,17 @@ _rsp_t ${mh_format['aw'][protocol]}${protocol}_write_rsp_i, output idma_busy_t busy_o ); - /// Extra write-descriptor slots covering the compute (transpose) tile-fill latency. + /// Write queues holding a whole transpose tile; a transpose config change drains the backend % if compute_eligible: localparam int unsigned ComputeFifoDepth = EnableCompute ? StrbWidth : 32'd0; + // a transpose tile is up to StrbWidth row writes, each split in two at a 4 KiB boundary + localparam int unsigned TransposeTileDepth = + (EnableCompute && ComputeOps.transpose) ? 32'd2 * StrbWidth : 32'd0; + localparam int unsigned TileFifoDepth = + (NumAxInFlight + ComputeFifoDepth > TransposeTileDepth) ? + NumAxInFlight + ComputeFifoDepth : TransposeTileDepth; % else: - localparam int unsigned ComputeFifoDepth = 32'd0; + localparam int unsigned TileFifoDepth = NumAxInFlight; % endif /// Dataflow element depth; each ready cut needs one more entry for the same rate @@ -193,8 +199,8 @@ _rsp_t ${mh_format['aw'][protocol]}${protocol}_write_rsp_i, /// The localparam MetaFifoDepth holds the maximum number of transfers that can be /// in-flight under any circumstances. - localparam int unsigned MetaFifoDepth = DfeDepth + NumAxInFlight + MemSysDepth + - ComputeFifoDepth + 32'd2 * 32'(TimingCuts.wdp_head_spill); + localparam int unsigned MetaFifoDepth = DfeDepth + TileFifoDepth + MemSysDepth + + 32'd2 * 32'(TimingCuts.wdp_head_spill); /// Address type typedef logic [AddrWidth-1:0] addr_t; @@ -746,7 +752,7 @@ _rsp_t ${mh_format['aw'][protocol]}${protocol}_write_rsp_i, ); cc_stream_fifo_optimal_wrap #( - .Depth ( NumAxInFlight + ComputeFifoDepth ), + .Depth ( TileFifoDepth ), .data_t ( w_dp_req_t ), .PrintInfo ( PrintFifoInfo ) ) i_w_dp_req ( @@ -966,7 +972,7 @@ _rsp_t ${mh_format['aw'][protocol]}${protocol}_write_rsp_i, % if one_read_port and one_write_port and (used_read_protocols[0] == used_write_protocols[0]): // mirrors i_w_dp_req exactly: same depth, same push valid, same pop ready cc_stream_fifo_optimal_wrap #( - .Depth ( NumAxInFlight + ComputeFifoDepth ), + .Depth ( TileFifoDepth ), .data_t ( logic ), .PrintInfo ( PrintFifoInfo ) ) i_w_decouple_aw ( @@ -984,8 +990,9 @@ _rsp_t ${mh_format['aw'][protocol]}${protocol}_write_rsp_i, ); // instantiate the channel coupler + // holds a whole transpose tile of AWs, like i_w_dp_req idma_channel_coupler #( - .NumAxInFlight ( NumAxInFlight ), + .NumAxInFlight ( TileFifoDepth ), .AddrWidth ( AddrWidth ), .UserWidth ( UserWidth ), .AxiIdWidth ( AxiIdWidth ), @@ -1044,7 +1051,7 @@ w_req.decouple_aw || (w_req.w_dp_req.dst_protocol inside {\ % if compute_eligible: // combined aw+w read-meta buffer; deepened for the compute engine tile read-ahead (cf. i_w_dp_req) cc_stream_fifo_optimal_wrap #( - .Depth ( EnableCompute ? NumAxInFlight + ComputeFifoDepth : 32'd2 ), + .Depth ( EnableCompute ? TileFifoDepth : 32'd2 ), % else: // Atleast one write protocol uses combined aw and w -> Need to buffer read meta requests // As a write could depend on up to two reads diff --git a/target/sim/vlt/testbenches.mk b/target/sim/vlt/testbenches.mk index 36c682f4a..fa974a5bc 100644 --- a/target/sim/vlt/testbenches.mk +++ b/target/sim/vlt/testbenches.mk @@ -15,7 +15,8 @@ IDMA_VLT_TESTBENCHES := \ tb_idma_rt_midend IDMA_VLT_SUFFIXES_tb_idma_otf_transpose := sw8_fd0 sw8_fd1 sw64_fd0 sw64_fd1 -IDMA_VLT_SUFFIXES_tb_idma_transpose_nd := dw32 dw64 +IDMA_VLT_SUFFIXES_tb_idma_transpose_nd := dw32 dw64 dw64_axif2 dw64_axif2_aw1 dw128_axif2_aw1 \ + dw512_axif24_aw1 dw512_axif24_aw2 IDMA_VLT_SUFFIXES_tb_idma_transpose_b2b := dw32 dw64 IDMA_VLT_SUFFIXES_tb_idma_transpose_midend := dw64 dw512 IDMA_VLT_SUFFIXES_tb_idma_nd_midend_b2b := default @@ -42,6 +43,14 @@ IDMA_VLT_RUN_ARGS_tb_idma_otf_transpose__sw64_fd1 := +BP # End-to-end transpose and transpose-midend bus-width configurations. IDMA_VLT_ELAB_ARGS_tb_idma_transpose_nd__dw32 := -GDataWidth=32 IDMA_VLT_ELAB_ARGS_tb_idma_transpose_nd__dw64 := -GDataWidth=64 +# Shallow AW queues and a slave taking one AW ahead of its W must still fit a whole tile +IDMA_VLT_ELAB_ARGS_tb_idma_transpose_nd__dw64_axif2 := -GDataWidth=64 -GAxIF=2 +IDMA_VLT_ELAB_ARGS_tb_idma_transpose_nd__dw64_axif2_aw1 := -GDataWidth=64 -GAxIF=2 -GMaxAwAhead=1 +IDMA_VLT_ELAB_ARGS_tb_idma_transpose_nd__dw128_axif2_aw1 := -GDataWidth=128 -GAxIF=2 -GMaxAwAhead=1 +IDMA_VLT_ELAB_ARGS_tb_idma_transpose_nd__dw512_axif24_aw1 := \ + -GDataWidth=512 -GAxIF=24 -GMaxAwAhead=1 +IDMA_VLT_ELAB_ARGS_tb_idma_transpose_nd__dw512_axif24_aw2 := \ + -GDataWidth=512 -GAxIF=24 -GMaxAwAhead=2 IDMA_VLT_ELAB_ARGS_tb_idma_transpose_b2b__dw32 := -GDataWidth=32 IDMA_VLT_ELAB_ARGS_tb_idma_transpose_b2b__dw64 := -GDataWidth=64 IDMA_VLT_ELAB_ARGS_tb_idma_transpose_midend__dw64 := -GDataWidth=64 diff --git a/test/tb_idma_transpose_nd.sv b/test/tb_idma_transpose_nd.sv index e6aa41e6b..3f0654165 100644 --- a/test/tb_idma_transpose_nd.sv +++ b/test/tb_idma_transpose_nd.sv @@ -21,7 +21,10 @@ module tb_idma_transpose_nd parameter int unsigned UserWidth = 1, parameter int unsigned AxiIdWidth = 12, parameter int unsigned TFLenWidth = 32, - parameter int unsigned BufferDepth = 3 + parameter int unsigned BufferDepth = 3, + parameter int unsigned AxIF = DataWidth / 8, + // AWs the memory accepts ahead of their W data (0: unlimited), like an interconnect write limit + parameter int unsigned MaxAwAhead = 0 ); localparam time TA = 1ns; @@ -29,14 +32,12 @@ module tb_idma_transpose_nd localparam time TCK = 10ns; localparam int unsigned StrbWidth = DataWidth / 8; - // transpose buffers a full NE-beat tile before the first write; NE <= StrbWidth - localparam int unsigned AxIF = StrbWidth; localparam int unsigned NumDim = 4; // 1D + {row, row-tile, col-tile} localparam logic [NumDim-1:0][31:0] RepWidths = '{default: 32'd16}; // Geometry cases (M, N, EB) swept in one elaboration: aligned + edge // (M or N not a multiple of NE) for int8/fp16/fp32. EB>StrbWidth cases skip. - localparam int unsigned NCases = 14; + localparam int unsigned NCases = 16; localparam int unsigned Cases[NCases][3] = '{ '{8, 8, 1}, '{16, 16, 1}, @@ -51,7 +52,9 @@ module tb_idma_transpose_nd '{32, 24, 1}, '{9, 5, 4}, '{13, 19, 1}, - '{9, 5, 8} + '{9, 5, 8}, + '{4095, 4, 1}, + '{2047, 2, 2} }; // Whole-tile cases, all non-square so an M/N swap cannot hide @@ -158,8 +161,20 @@ module tb_idma_transpose_nd .mst_req_o (axi_req), .mst_resp_i (axi_rsp) ); - assign axi_req_mem = axi_req; - assign axi_rsp = axi_rsp_mem; + int aw_ahead_q; + logic aw_block; + assign aw_block = (MaxAwAhead != 0) && (aw_ahead_q >= int'(MaxAwAhead)); + always_comb begin + axi_req_mem = axi_req; + axi_rsp = axi_rsp_mem; + axi_req_mem.aw_valid = axi_req.aw_valid & ~aw_block; + axi_rsp.aw_ready = axi_rsp_mem.aw_ready & ~aw_block; + end + always_ff @(posedge clk or negedge rst_n) + if (!rst_n) aw_ahead_q <= 0; + else + aw_ahead_q <= aw_ahead_q + int'(axi_req_mem.aw_valid & axi_rsp_mem.aw_ready) - + int'(axi_req.w_valid & axi_rsp.w_ready & axi_req.w.last); axi_sim_mem #( .AddrWidth (AddrWidth), @@ -553,7 +568,7 @@ module tb_idma_transpose_nd // Sweep aligned and sub-beat misaligned bases to reach the 2-beat-row path for (int unsigned misalign = 0; misalign < 2; misalign++) begin sb = 'h0000_1000 + (misalign ? 1 : 0); - db = 'h0000_4000 + (misalign ? 3 : 0); + db = 'h0010_0000 + (misalign ? 3 : 0); // clear of the largest source matrix for (int unsigned k = 0; k < NCases; k++) begin if (Cases[k][2] > StrbWidth) continue; // element must fit the bus for (int unsigned compact = 0; compact < 2; compact++) begin From cb97c4b18132b442245928376a7071538527fbdf Mon Sep 17 00:00:00 2001 From: Daniel Keller Date: Thu, 12 Nov 2026 06:39:53 +0100 Subject: [PATCH 2/2] backend: Keep the coupler at NumAxInFlight without transpose Only the transpose tile needs the deeper coupler; MX-only and other compute builds keep the devel coupler depth and area. --- src/backend/tpl/idma_backend.sv.tpl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/backend/tpl/idma_backend.sv.tpl b/src/backend/tpl/idma_backend.sv.tpl index 86201350a..149c63c7e 100644 --- a/src/backend/tpl/idma_backend.sv.tpl +++ b/src/backend/tpl/idma_backend.sv.tpl @@ -189,8 +189,11 @@ _rsp_t ${mh_format['aw'][protocol]}${protocol}_write_rsp_i, localparam int unsigned TileFifoDepth = (NumAxInFlight + ComputeFifoDepth > TransposeTileDepth) ? NumAxInFlight + ComputeFifoDepth : TransposeTileDepth; + localparam int unsigned CouplerDepth = + (EnableCompute && ComputeOps.transpose) ? TileFifoDepth : NumAxInFlight; % else: localparam int unsigned TileFifoDepth = NumAxInFlight; + localparam int unsigned CouplerDepth = NumAxInFlight; % endif /// Dataflow element depth; each ready cut needs one more entry for the same rate @@ -990,9 +993,9 @@ _rsp_t ${mh_format['aw'][protocol]}${protocol}_write_rsp_i, ); // instantiate the channel coupler - // holds a whole transpose tile of AWs, like i_w_dp_req + // holds a whole transpose tile of AWs when transpose is enabled idma_channel_coupler #( - .NumAxInFlight ( TileFifoDepth ), + .NumAxInFlight ( CouplerDepth ), .AddrWidth ( AddrWidth ), .UserWidth ( UserWidth ), .AxiIdWidth ( AxiIdWidth ),