forked from olofk/axi_node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaxi_address_decoder_AW.sv
More file actions
276 lines (214 loc) · 10.3 KB
/
axi_address_decoder_AW.sv
File metadata and controls
276 lines (214 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
// Copyright 2015 ETH Zurich and University of Bologna.
// Copyright and related rights are licensed under the Solderpad Hardware
// License, Version 0.51 (the “License”); you may not use this file except in
// compliance with the License. You may obtain a copy of the License at
// http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law
// or agreed to in writing, software, hardware and materials distributed under
// this License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
// ============================================================================= //
// Company: Multitherman Laboratory @ DEIS - University of Bologna //
// Viale Risorgimento 2 40136 //
// Bologna - fax 0512093785 - //
// //
// Engineer: Igor Loi - igor.loi@unibo.it //
// //
// //
// Additional contributions by: //
// //
// //
// //
// Create Date: 01/02/2014 //
// Design Name: AXI 4 INTERCONNECT //
// Module Name: axi_address_decoder_AW //
// Project Name: PULP //
// Language: SystemVerilog //
// //
// Description: Address decoder for the address write channel: Decoding //
// is performed on the address AR //
// //
// Revision: //
// Revision v0.1 - 01/02/2014 : File Created //
// //
// //
// //
// //
// //
// //
// ============================================================================= //
module axi_address_decoder_AW
#(
parameter ADDR_WIDTH = 32,
parameter N_INIT_PORT = 8,
parameter N_REGION = 2
)
(
input logic clk,
input logic rst_n,
input logic awvalid_i,
input logic [ADDR_WIDTH-1:0] awaddr_i,
output logic awready_o,
output logic [N_INIT_PORT-1:0] awvalid_o,
input logic [N_INIT_PORT-1:0] awready_i,
input logic grant_FIFO_DEST_i,
output logic [N_INIT_PORT-1:0] DEST_o,
output logic push_DEST_o,
//Error Managment
input logic [N_REGION-1:0][N_INIT_PORT-1:0][ADDR_WIDTH-1:0] START_ADDR_i,
input logic [N_REGION-1:0][N_INIT_PORT-1:0][ADDR_WIDTH-1:0] END_ADDR_i,
input logic [N_REGION-1:0][N_INIT_PORT-1:0] enable_region_i,
input logic [N_INIT_PORT-1:0] connectivity_map_i,
output logic incr_req_o,
input logic full_counter_i,
input logic outstanding_trans_i,
output logic error_req_o,
input logic error_gnt_i,
output logic handle_error_o,
input logic wdata_error_completed_i,
output logic sample_awdata_info_o
);
logic [N_INIT_PORT-1:0] match_region; // One of the slave or Error!!!
logic [N_INIT_PORT:0] match_region_masked;
logic [N_REGION-1:0][N_INIT_PORT-1:0] match_region_int;
logic [N_INIT_PORT-1:0][N_REGION-1:0] match_region_rev;
logic awready_int;
logic [N_INIT_PORT-1:0] awvalid_int;
logic error_detected;
logic local_increm;
genvar i,j;
assign DEST_o = match_region[N_INIT_PORT-1:0];
assign push_DEST_o = |(awvalid_i & awready_o) & ~error_detected;
enum logic [1:0] {OPERATIVE, COMPLETE_PENDING, ACCEPT_WDATA , COMPLETE_ERROR_RESP } CS, NS;
generate
// First calculate for each region where what slave ist matching
for(j=0;j<N_REGION;j++)
begin
for(i=0;i<N_INIT_PORT;i++)
begin
assign match_region_int[j][i] = (enable_region_i[j][i] == 1'b1 ) ? (awaddr_i >= START_ADDR_i[j][i]) && (awaddr_i <= END_ADDR_i[j][i]) : 1'b0;
end
end
// transpose the match_region_int bidimensional array
for(j=0;j<N_INIT_PORT;j++)
begin
for(i=0;i<N_REGION;i++)
begin
assign match_region_rev[j][i] = match_region_int[i][j];
end
end
//Or reduction
for(i=0;i<N_INIT_PORT;i++)
begin
assign match_region[i] = | match_region_rev[i];
end
assign match_region_masked[N_INIT_PORT-1:0] = match_region & connectivity_map_i;
// if there are no moatches, then assert an error
assign match_region_masked[N_INIT_PORT] = ~(|match_region_masked[N_INIT_PORT-1:0]);
endgenerate
always_comb
begin
if(grant_FIFO_DEST_i == 1'b1)
begin
if(awvalid_i)
begin
{error_detected,awvalid_int} = {N_INIT_PORT+1{awvalid_i}} & match_region_masked;
end
else
begin
awvalid_int = '0;
error_detected = 1'b0;
end
awready_int = |({error_gnt_i,awready_i} & match_region_masked);
end
else
begin
awvalid_int = '0;
awready_int = 1'b0;
error_detected = 1'b0; //FIXME
end
end
// --------------------------------------------------------------------------------------------------------------------------------------------------//
// ERROR MANAGMENT BLOCK - STALL in case of ERROR, WAIT untill there are no more pending transactions then deliver the error req to the BR ALLOCATOR.
// --------------------------------------------------------------------------------------------------------------------------------------------------//
always_ff @(posedge clk, negedge rst_n)
begin
if(rst_n == 1'b0)
begin
CS <= OPERATIVE;
end
else
begin
CS <= NS;
end
end
assign local_increm = |(awvalid_o & awready_i);
always_comb
begin
awready_o = 1'b0;
handle_error_o = 1'b0;
sample_awdata_info_o = 1'b0;
error_req_o = 1'b0;
incr_req_o = 1'b0;
awvalid_o = '0;
case(CS)
OPERATIVE:
begin
handle_error_o = 1'b0;
incr_req_o = local_increm;
if(error_detected)
begin
NS = COMPLETE_PENDING;
awready_o = 1'b1;
sample_awdata_info_o = 1'b1;
awvalid_o = '0;
end
else
begin
NS = OPERATIVE;
awready_o = awready_int;
awvalid_o = awvalid_int;
end
end
COMPLETE_PENDING:
begin
awready_o = 1'b0;
handle_error_o = 1'b0;
if(outstanding_trans_i)
begin
NS = COMPLETE_PENDING;
awready_o = 1'b0;
end
else
begin // There are no pending transactions
awready_o = 1'b0;
NS = ACCEPT_WDATA;
end
end
ACCEPT_WDATA :
begin
awready_o = 1'b0;
handle_error_o = 1'b1;
if(wdata_error_completed_i)
NS = COMPLETE_ERROR_RESP;
else
NS = ACCEPT_WDATA;
end
COMPLETE_ERROR_RESP :
begin
handle_error_o = 1'b0;
error_req_o = 1'b1;
if(error_gnt_i)
NS = OPERATIVE;
else
NS = COMPLETE_ERROR_RESP;
end
default :
begin
NS = OPERATIVE;
awready_o = awready_int;
handle_error_o = 1'b0;
end
endcase
end
endmodule