forked from olofk/axi_node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaxi_address_decoder_AR.sv
More file actions
227 lines (181 loc) · 8.86 KB
/
axi_address_decoder_AR.sv
File metadata and controls
227 lines (181 loc) · 8.86 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
// 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_AR //
// Project Name: PULP //
// Language: SystemVerilog //
// //
// Description: Address decoder for the address read channel //
// //
// //
// Revision: //
// Revision v0.1 - 01/02/2014 : File Created //
// //
// //
// //
// //
// //
// //
// ============================================================================= //
module axi_address_decoder_AR
#(
parameter ADDR_WIDTH = 32,
parameter N_INIT_PORT = 8,
parameter N_REGION = 4
)
(
input logic clk,
input logic rst_n,
input logic arvalid_i,
input logic [ADDR_WIDTH-1:0] araddr_i,
output logic arready_o,
output logic [N_INIT_PORT-1:0] arvalid_o,
input logic [N_INIT_PORT-1:0] arready_i,
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 sample_ardata_info_o
);
logic [N_INIT_PORT-1:0] match_region;
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 arready_int;
logic [N_INIT_PORT-1:0] arvalid_int;
genvar i,j;
enum logic {OPERATIVE, ERROR} 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 ) ? (araddr_i >= START_ADDR_i[j][i]) && (araddr_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(arvalid_i)
begin
{error_req_o,arvalid_int} = {N_INIT_PORT+1{arvalid_i} } & match_region_masked;
end
else
begin
arvalid_int = '0;
error_req_o = 1'b0;
end
arready_int = |({error_gnt_i,arready_i} & match_region_masked);
end
// --------------------------------------------------------------------------------------------------------------------------------------------------//
// ERROR MANAGMENT BLOCK - STALL in case of ERROR, WAIT untill there are no more pending tranaction 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
always_comb
begin
arready_o = 1'b0;
arvalid_o = arvalid_int;
sample_ardata_info_o = 1'b0;
incr_req_o = 1'b0;
case(CS)
OPERATIVE:
begin
if(error_req_o)
begin
NS = ERROR;
arready_o = 1'b1; // granbt then stall any incoming resposnses
sample_ardata_info_o = 1'b1;
arvalid_o = '0;
end
else
begin
NS = OPERATIVE;
arready_o = arready_int;
sample_ardata_info_o = 1'b0;
incr_req_o = |(arvalid_o & arready_i);
arvalid_o = arvalid_int;
end
end
ERROR:
begin
arready_o = 1'b0;
arvalid_o = '0;
if(outstanding_trans_i)
begin
NS = ERROR;
end
else
begin
if(error_gnt_i)
begin
NS = OPERATIVE;
end
else
begin
NS = ERROR;
end
end
end
default :
begin
NS = OPERATIVE;
arready_o = arready_int;
end
endcase
end
// --------------------------------------------------------------------------------------------------------------------------------------------------//
// //
// --------------------------------------------------------------------------------------------------------------------------------------------------//
endmodule