13
13
// - Wolfgang Roenninger <[email protected] >
14
14
// - Andreas Kurth <[email protected] >
15
15
16
+ `include " axi/typedef.svh"
16
17
`include " common_cells/registers.svh"
17
18
18
19
// / This module can isolate the AXI4+ATOPs bus on the master port from the slave port. When the
27
28
// / anymore, the `isolated_o` output is asserted. As long as `isolated_o` is asserted, all output
28
29
// / signals in `mst_req_o` are silenced to `'0`. When isolated, new transactions initiated on the
29
30
// / 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.
30
40
module axi_isolate # (
31
41
// / Maximum number of pending requests per channel
32
42
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 ,
33
54
// / Request struct type of all AXI4+ATOP ports
34
55
parameter type axi_req_t = logic ,
35
56
// / Response struct type of all AXI4+ATOP ports
@@ -52,6 +73,107 @@ module axi_isolate #(
52
73
// / Master port is isolated from slave port
53
74
output logic isolated_o
54
75
);
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
+
55
177
// plus 1 in clog for accouning no open transaction, plus one bit for atomic injection
56
178
localparam int unsigned CounterWidth = $clog2 (NumPending + 32'd1 ) + 32'd1 ;
57
179
typedef logic [CounterWidth- 1 : 0 ] cnt_t ;
@@ -283,14 +405,14 @@ module axi_isolate #(
283
405
// pragma translate_on
284
406
endmodule
285
407
286
- `include " axi/typedef.svh"
287
408
`include " axi/assign.svh"
288
409
289
410
// / Interface variant of [`axi_isolate`](module.axi_isolate).
290
411
// /
291
412
// / See the documentation of the main module for the definition of ports and parameters.
292
413
module axi_isolate_intf # (
293
414
parameter int unsigned NUM_PENDING = 32'd16 ,
415
+ parameter bit TERMINATE_TRANSACTION = 1'b0 ,
294
416
parameter int unsigned AXI_ID_WIDTH = 32'd0 ,
295
417
parameter int unsigned AXI_ADDR_WIDTH = 32'd0 ,
296
418
parameter int unsigned AXI_DATA_WIDTH = 32'd0 ,
@@ -329,9 +451,14 @@ module axi_isolate_intf #(
329
451
`AXI_ASSIGN_TO_RESP (mst_resp, mst)
330
452
331
453
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 )
335
462
) i_axi_isolate (
336
463
.clk_i,
337
464
.rst_ni,
0 commit comments