Skip to content

Commit f657f16

Browse files
andreaskurthzarubaf
andcommitted
axi_isolate: Add parameter TerminateTransaction
This parameter allows to respond to transactions during isolation. Adapted from `0011-axi-Improve-isolation-with-termination.patch` from the Snitch repository. Co-authored-by: Florian Zaruba <[email protected]>
1 parent f3b5a55 commit f657f16

File tree

2 files changed

+139
-4
lines changed

2 files changed

+139
-4
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,21 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111
- `axi_demux`: Add parameter `AtopSupport` to optionally disable the support for atomic operations
1212
(ATOPs). This parameter defaults to `1'b1`, i.e., ATOPs are supported. Therefore, this change is
1313
backward-compatible.
14+
- `axi_isolate`: Add parameter `TerminateTransaction` to optionally respond to transactions during
15+
isolation. This parameter defaults to `1'b0`, i.e., transactions do not get responses.
16+
Therefore, this change is backward-compatible.
1417
- `axi_xbar`: Add `Connectivity` parameter to enable the implementation of partially-connected
1518
crossbars. This parameter defaults to `'1`, i.e., every slave port is connected to every master
1619
port. Therefore, this change is backward-compatible.
1720
- `axi_test`: Add monitor class `axi_monitor`.
1821
- `axi_test::axi_driver`: Add monitor tasks.
1922

2023
### Changed
24+
- `axi_isolate`: Add parameters for the address, data, ID, and user signal width. This is required
25+
for the implementation of the `TerminateTransaction` parameter (see *Added* section). This change
26+
is **backward-incompatible** for all instances of `axi_isolate` outside this repository. Users
27+
must update all instances of `axi_isolate` in their code. The interface variant is not affected
28+
and remains backward-compatible.
2129

2230
### Fixed
2331

src/axi_isolate.sv

Lines changed: 131 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// - Wolfgang Roenninger <[email protected]>
1414
// - Andreas Kurth <[email protected]>
1515

16+
`include "axi/typedef.svh"
1617
`include "common_cells/registers.svh"
1718

1819
/// This module can isolate the AXI4+ATOPs bus on the master port from the slave port. When the
@@ -27,9 +28,29 @@
2728
/// anymore, the `isolated_o` output is asserted. As long as `isolated_o` is asserted, all output
2829
/// signals in `mst_req_o` are silenced to `'0`. When isolated, new transactions initiated on the
2930
/// slave port are stalled until the isolation is terminated by deasserting `isolate_i`.
31+
///
32+
/// ## Response
33+
///
34+
/// If the `TerminateTransaction` parameter is set to `1'b1`, the module will return response errors
35+
/// in case there is an incoming transaction while the module isolates. The data returned on the
36+
/// bus is `1501A7ED` (hexspeak for isolated).
37+
///
38+
/// If `TerminateTransaction` is set to `1'b0`, the transaction will block indefinitely until the
39+
/// module is de-isolated again.
3040
module axi_isolate #(
3141
/// Maximum number of pending requests per channel
3242
parameter int unsigned NumPending = 32'd16,
43+
/// Gracefully terminate all incoming transactions in case of isolation by returning proper error
44+
/// responses.
45+
parameter bit TerminateTransaction = 1'b0,
46+
/// Address width of all AXI4+ATOP ports
47+
parameter int unsigned AxiAddrWidth = 32'd0,
48+
/// Data width of all AXI4+ATOP ports
49+
parameter int unsigned AxiDataWidth = 32'd0,
50+
/// ID width of all AXI4+ATOP ports
51+
parameter int unsigned AxiIdWidth = 32'd0,
52+
/// User signal width of all AXI4+ATOP ports
53+
parameter int unsigned AxiUserWidth = 32'd0,
3354
/// Request struct type of all AXI4+ATOP ports
3455
parameter type axi_req_t = logic,
3556
/// Response struct type of all AXI4+ATOP ports
@@ -52,6 +73,107 @@ module axi_isolate #(
5273
/// Master port is isolated from slave port
5374
output logic isolated_o
5475
);
76+
77+
typedef logic [AxiIdWidth-1:0] id_t;
78+
typedef logic [AxiAddrWidth-1:0] addr_t;
79+
typedef logic [AxiDataWidth-1:0] data_t;
80+
typedef logic [AxiDataWidth/8-1:0] strb_t;
81+
typedef logic [AxiUserWidth-1:0] user_t;
82+
83+
`AXI_TYPEDEF_AW_CHAN_T(aw_chan_t, addr_t, id_t, user_t)
84+
`AXI_TYPEDEF_W_CHAN_T(w_chan_t, data_t, strb_t, user_t)
85+
`AXI_TYPEDEF_B_CHAN_T(b_chan_t, id_t, user_t)
86+
`AXI_TYPEDEF_AR_CHAN_T(ar_chan_t, addr_t, id_t, user_t)
87+
`AXI_TYPEDEF_R_CHAN_T(r_chan_t, data_t, id_t, user_t)
88+
89+
axi_req_t [1:0] demux_req;
90+
axi_resp_t [1:0] demux_rsp;
91+
92+
if (TerminateTransaction) begin
93+
axi_demux #(
94+
.AxiIdWidth ( AxiIdWidth ),
95+
.AtopSupport ( 1'b1 ),
96+
.aw_chan_t ( aw_chan_t ),
97+
.w_chan_t ( w_chan_t ),
98+
.b_chan_t ( b_chan_t ),
99+
.ar_chan_t ( ar_chan_t ),
100+
.r_chan_t ( r_chan_t ),
101+
.axi_req_t ( axi_req_t ),
102+
.axi_resp_t ( axi_resp_t ),
103+
.NoMstPorts ( 2 ),
104+
.MaxTrans ( NumPending ),
105+
// We don't need many bits here as the common case will be to go for the pass-through.
106+
.AxiLookBits ( 1 ),
107+
.UniqueIds ( 1'b0 ),
108+
.FallThrough ( 1'b1 ),
109+
.SpillAw ( 1'b0 ),
110+
.SpillW ( 1'b0 ),
111+
.SpillB ( 1'b0 ),
112+
.SpillAr ( 1'b0 ),
113+
.SpillR ( 1'b0 )
114+
) i_axi_demux (
115+
.clk_i,
116+
.rst_ni,
117+
.test_i ( 1'b0 ),
118+
.slv_req_i,
119+
.slv_aw_select_i ( isolated_o ),
120+
.slv_ar_select_i ( isolated_o ),
121+
.slv_resp_o,
122+
.mst_reqs_o ( demux_req ),
123+
.mst_resps_i ( demux_rsp )
124+
);
125+
126+
axi_err_slv #(
127+
.AxiIdWidth ( AxiIdWidth ),
128+
.axi_req_t ( axi_req_t ),
129+
.axi_resp_t ( axi_resp_t ),
130+
.Resp ( axi_pkg::RESP_DECERR ),
131+
.RespData ( 'h1501A7ED ),
132+
.ATOPs ( 1'b1 ),
133+
.MaxTrans ( 1 )
134+
) i_axi_err_slv (
135+
.clk_i,
136+
.rst_ni,
137+
.test_i ( 1'b0 ),
138+
.slv_req_i ( demux_req[1] ),
139+
.slv_resp_o ( demux_rsp[1] )
140+
);
141+
end else begin
142+
assign demux_req[0] = slv_req_i;
143+
assign slv_resp_o = demux_rsp[0];
144+
end
145+
146+
axi_isolate_inner #(
147+
.NumPending ( NumPending ),
148+
.axi_req_t ( axi_req_t ),
149+
.axi_resp_t ( axi_resp_t )
150+
) i_axi_isolate (
151+
.clk_i,
152+
.rst_ni,
153+
.slv_req_i ( demux_req[0] ),
154+
.slv_resp_o ( demux_rsp[0] ),
155+
.mst_req_o,
156+
.mst_resp_i,
157+
.isolate_i,
158+
.isolated_o
159+
);
160+
endmodule
161+
162+
module axi_isolate_inner #(
163+
parameter int unsigned NumPending = 32'd16,
164+
parameter type axi_req_t = logic,
165+
parameter type axi_resp_t = logic
166+
) (
167+
input logic clk_i,
168+
input logic rst_ni,
169+
input axi_req_t slv_req_i,
170+
output axi_resp_t slv_resp_o,
171+
output axi_req_t mst_req_o,
172+
input axi_resp_t mst_resp_i,
173+
input logic isolate_i,
174+
output logic isolated_o
175+
);
176+
55177
// plus 1 in clog for accouning no open transaction, plus one bit for atomic injection
56178
localparam int unsigned CounterWidth = $clog2(NumPending + 32'd1) + 32'd1;
57179
typedef logic [CounterWidth-1:0] cnt_t;
@@ -283,14 +405,14 @@ module axi_isolate #(
283405
// pragma translate_on
284406
endmodule
285407

286-
`include "axi/typedef.svh"
287408
`include "axi/assign.svh"
288409

289410
/// Interface variant of [`axi_isolate`](module.axi_isolate).
290411
///
291412
/// See the documentation of the main module for the definition of ports and parameters.
292413
module axi_isolate_intf #(
293414
parameter int unsigned NUM_PENDING = 32'd16,
415+
parameter bit TERMINATE_TRANSACTION = 1'b0,
294416
parameter int unsigned AXI_ID_WIDTH = 32'd0,
295417
parameter int unsigned AXI_ADDR_WIDTH = 32'd0,
296418
parameter int unsigned AXI_DATA_WIDTH = 32'd0,
@@ -329,9 +451,14 @@ module axi_isolate_intf #(
329451
`AXI_ASSIGN_TO_RESP(mst_resp, mst)
330452

331453
axi_isolate #(
332-
.NumPending ( NUM_PENDING ),
333-
.axi_req_t ( axi_req_t ),
334-
.axi_resp_t ( axi_resp_t )
454+
.NumPending ( NUM_PENDING ),
455+
.TerminateTransaction ( TERMINATE_TRANSACTION ),
456+
.AxiAddrWidth ( AXI_ADDR_WIDTH ),
457+
.AxiDataWidth ( AXI_DATA_WIDTH ),
458+
.AxiIdWidth ( AXI_ID_WIDTH ),
459+
.AxiUserWidth ( AXI_USER_WIDTH ),
460+
.axi_req_t ( axi_req_t ),
461+
.axi_resp_t ( axi_resp_t )
335462
) i_axi_isolate (
336463
.clk_i,
337464
.rst_ni,

0 commit comments

Comments
 (0)