libfpga icon indicating copy to clipboard operation
libfpga copied to clipboard

Incorrect arbitration in case of waits on a higher prior AHB

Open chrmard opened this issue 6 months ago • 2 comments

The arbitration fails if higher priority src interface overrules a lower priority src interface in two consecutive accesses.

If the higher priority src interface has a single access, the old code is working fine. The issue occurs if the higher prior src interface introduces at least one wait.

I solved it by preventing a re-arbitration.

diff --git a/rtl/libfpga/ahbl_arbiter.v b/rtl/libfpga/ahbl_arbiter.v
index b3dbfd9..3f4b9dc 100644
--- a/rtl/libfpga/ahbl_arbiter.v
+++ b/rtl/libfpga/ahbl_arbiter.v
@@ -208,7 +208,7 @@ always @ (posedge clk or negedge rst_n) begin
                        buf_valid <= buf_valid & ~mast_gnt_a;
                end
                for (i = 0; i < N_PORTS; i = i + 1) begin
-                       if (buf_wen[i]) begin
+                       if (buf_wen[i] && !buf_valid[i]) begin
                                buf_valid    [i] <= 1'b1;
                                buf_htrans   [i] <= src_htrans   [i * 2 +: 2];
                                buf_haddr    [i] <= src_haddr    [i * W_ADDR +: W_ADDR];

chrmard avatar Oct 24 '25 14:10 chrmard

Thanks. It might take me a while to reproduce this because I'll need to clean up the tests a bit to use a sane simulator.

Wren6991 avatar Oct 28 '25 23:10 Wren6991

For your convivence I added two waveforms showing the issue.

The signals src_htrans[3] to src_hready_resp[0] in figure relates to the upper/lower part of the combined signals on src interface. Only split to keep the numbers short for reading.

Image Image

chrmard avatar Dec 12 '25 16:12 chrmard