Skip to content

Commit ea1a208

Browse files
committed
[bus] Return error if decode fails
Return an error signal to the host if an address request does not match any device. Previously a decode failure would match against the first device, which in the Ibex Demo System happens to be the SRAM.
1 parent 14c2b3f commit ea1a208

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

shared/rtl/bus.sv

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,33 @@ module bus #(
5454
localparam int unsigned NumBitsHostSel = NrHosts > 1 ? $clog2(NrHosts) : 1;
5555
localparam int unsigned NumBitsDeviceSel = NrDevices > 1 ? $clog2(NrDevices) : 1;
5656

57+
logic host_sel_valid;
58+
logic device_sel_valid;
59+
logic decode_err_resp;
60+
5761
logic [NumBitsHostSel-1:0] host_sel_req, host_sel_resp;
5862
logic [NumBitsDeviceSel-1:0] device_sel_req, device_sel_resp;
5963

6064
// Master select prio arbiter
6165
always_comb begin
66+
host_sel_valid = 1'b0;
6267
host_sel_req = '0;
6368
for (integer host = NrHosts - 1; host >= 0; host = host - 1) begin
6469
if (host_req_i[host]) begin
70+
host_sel_valid = 1'b1;
6571
host_sel_req = NumBitsHostSel'(host);
6672
end
6773
end
6874
end
6975

7076
// Device select
7177
always_comb begin
78+
device_sel_valid = 1'b0;
7279
device_sel_req = '0;
7380
for (integer device = 0; device < NrDevices; device = device + 1) begin
7481
if ((host_addr_i[host_sel_req] & cfg_device_addr_mask[device])
7582
== cfg_device_addr_base[device]) begin
83+
device_sel_valid = 1'b1;
7684
device_sel_req = NumBitsDeviceSel'(device);
7785
end
7886
end
@@ -82,16 +90,19 @@ module bus #(
8290
if (!rst_ni) begin
8391
host_sel_resp <= '0;
8492
device_sel_resp <= '0;
93+
decode_err_resp <= 1'b0;
8594
end else begin
8695
// Responses are always expected 1 cycle after the request
8796
device_sel_resp <= device_sel_req;
8897
host_sel_resp <= host_sel_req;
98+
// Decode failed; no device matched?
99+
decode_err_resp <= host_sel_valid & !device_sel_valid;
89100
end
90101
end
91102

92103
always_comb begin
93104
for (integer device = 0; device < NrDevices; device = device + 1) begin
94-
if (NumBitsDeviceSel'(device) == device_sel_req) begin
105+
if (device_sel_valid && NumBitsDeviceSel'(device) == device_sel_req) begin
95106
device_req_o[device] = host_req_i[host_sel_req];
96107
device_we_o[device] = host_we_i[host_sel_req];
97108
device_addr_o[device] = host_addr_i[host_sel_req];
@@ -111,8 +122,8 @@ module bus #(
111122
for (integer host = 0; host < NrHosts; host = host + 1) begin
112123
host_gnt_o[host] = 1'b0;
113124
if (NumBitsHostSel'(host) == host_sel_resp) begin
114-
host_rvalid_o[host] = device_rvalid_i[device_sel_resp];
115-
host_err_o[host] = device_err_i[device_sel_resp];
125+
host_rvalid_o[host] = device_rvalid_i[device_sel_resp] | decode_err_resp;
126+
host_err_o[host] = device_err_i[device_sel_resp] | decode_err_resp;
116127
host_rdata_o[host] = device_rdata_i[device_sel_resp];
117128
end else begin
118129
host_rvalid_o[host] = 1'b0;

0 commit comments

Comments
 (0)