1 |
2 |
eyalhoc |
/////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// Author: Eyal Hochberg ////
|
4 |
|
|
//// eyal@provartec.com ////
|
5 |
|
|
//// ////
|
6 |
|
|
//// Downloaded from: http://www.opencores.org ////
|
7 |
|
|
/////////////////////////////////////////////////////////////////////
|
8 |
|
|
//// ////
|
9 |
|
|
//// Copyright (C) 2010 Provartec LTD ////
|
10 |
|
|
//// www.provartec.com ////
|
11 |
|
|
//// info@provartec.com ////
|
12 |
|
|
//// ////
|
13 |
|
|
//// This source file may be used and distributed without ////
|
14 |
|
|
//// restriction provided that this copyright statement is not ////
|
15 |
|
|
//// removed from the file and that any derivative work contains ////
|
16 |
|
|
//// the original copyright notice and the associated disclaimer.////
|
17 |
|
|
//// ////
|
18 |
|
|
//// This source file is free software; you can redistribute it ////
|
19 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
20 |
|
|
//// Public License as published by the Free Software Foundation.////
|
21 |
|
|
//// ////
|
22 |
|
|
//// This source is distributed in the hope that it will be ////
|
23 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
24 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
25 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more////
|
26 |
|
|
//// details. http://www.gnu.org/licenses/lgpl.html ////
|
27 |
|
|
//// ////
|
28 |
|
|
/////////////////////////////////////////////////////////////////////
|
29 |
|
|
|
30 |
|
|
//////////////////////////////////////
|
31 |
|
|
//
|
32 |
|
|
// General:
|
33 |
|
|
// The AXI master has an internal master per ID.
|
34 |
|
|
// These internal masters work simultaniously and an interconnect matrix connets them.
|
35 |
|
|
//
|
36 |
|
|
//
|
37 |
|
|
// I/F :
|
38 |
|
|
// idle - all internal masters emptied their command FIFOs
|
39 |
|
|
// scrbrd_empty - all scoreboard checks have been completed (for random testing)
|
40 |
|
|
//
|
41 |
|
|
//
|
42 |
|
|
// Tasks:
|
43 |
|
|
//
|
44 |
|
|
// enable(input master_num)
|
45 |
|
|
// Description: Enables master
|
46 |
|
|
// Parameters: master_num - number of internal master
|
47 |
|
|
//
|
48 |
|
|
// enable_all()
|
49 |
|
|
// Description: Enables all masters
|
50 |
|
|
//
|
51 |
|
|
// write_single(input master_num, input addr, input wdata)
|
52 |
|
|
// Description: write a single AXI burst (1 data cycle)
|
53 |
|
|
// Parameters: master_num - number of internal master
|
54 |
|
|
// addr - address
|
55 |
|
|
// wdata - write data
|
56 |
|
|
//
|
57 |
|
|
// read_single(input master_num, input addr, output rdata)
|
58 |
|
|
// Description: read a single AXI burst (1 data cycle)
|
59 |
|
|
// Parameters: master_num - number of internal master
|
60 |
|
|
// addr - address
|
61 |
|
|
// rdata - return read data
|
62 |
|
|
//
|
63 |
|
|
// check_single(input master_num, input addr, input expected)
|
64 |
|
|
// Description: read a single AXI burst and gives an error if the data read does not match expected
|
65 |
|
|
// Parameters: master_num - number of internal master
|
66 |
|
|
// addr - address
|
67 |
|
|
// expected - expected read data
|
68 |
|
|
//
|
69 |
|
|
// write_and_check_single(input master_num, input addr, input data)
|
70 |
|
|
// Description: write a single AXI burst read it back and compare the write and read data
|
71 |
|
|
// Parameters: master_num - number of internal master
|
72 |
|
|
// addr - address
|
73 |
|
|
// data - data to write and expect on read
|
74 |
|
|
//
|
75 |
|
|
// insert_wr_cmd(input master_num, input addr, input len, input size)
|
76 |
|
|
// Description: add an AXI write burst to command FIFO
|
77 |
|
|
// Parameters: master_num - number of internal master
|
78 |
|
|
// addr - address
|
79 |
|
|
// len - AXI LEN (data strobe number)
|
80 |
|
|
// size - AXI SIZE (data width)
|
81 |
|
|
//
|
82 |
|
|
// insert_rd_cmd(input master_num, input addr, input len, input size)
|
83 |
|
|
// Description: add an AXI read burst to command FIFO
|
84 |
|
|
// Parameters: master_num - number of internal master
|
85 |
|
|
// addr - address
|
86 |
|
|
// len - AXI LEN (data strobe number)
|
87 |
|
|
// size - AXI SIZE (data width)
|
88 |
|
|
//
|
89 |
|
|
// insert_wr_data(input master_num, input wdata)
|
90 |
|
|
// Description: add a single data to data FIFO (to be used in write bursts)
|
91 |
|
|
// Parameters: master_num - number of internal master
|
92 |
|
|
// wdata - write data
|
93 |
|
|
//
|
94 |
|
|
// insert_wr_incr_data(input master_num, input addr, input len, input size)
|
95 |
|
|
// Description: add an AXI write burst to command FIFO will use incremental data (no need to use insert_wr_data)
|
96 |
|
|
// Parameters: master_num - number of internal master
|
97 |
|
|
// addr - address
|
98 |
|
|
// len - AXI LEN (data strobe number)
|
99 |
|
|
// size - AXI SIZE (data width)
|
100 |
|
|
//
|
101 |
|
|
// insert_rand_chk(input master_num, input burst_num)
|
102 |
|
|
// Description: add multiple commands to command FIFO. Each command writes incremental data to a random address, reads the data back and checks the data. Useful for random testing.
|
103 |
|
|
// Parameters: master_num - number of internal master
|
104 |
|
|
// burst_num - total number of bursts to check
|
105 |
|
|
//
|
106 |
|
|
|
107 |
|
|
//
|
108 |
|
|
// Parameters:
|
109 |
|
|
//
|
110 |
|
|
// For random testing: (changing these values automatically update interanl masters)
|
111 |
|
|
// len_min - minimum burst AXI LEN (length)
|
112 |
|
|
// len_max - maximum burst AXI LEN (length)
|
113 |
|
|
// size_min - minimum burst AXI SIZE (width)
|
114 |
|
|
// size_max - maximum burst AXI SIZE (width)
|
115 |
|
|
// addr_min - minimum address (in bytes)
|
116 |
|
|
// addr_max - maximum address (in bytes)
|
117 |
|
|
//
|
118 |
|
|
//////////////////////////////////////
|
119 |
|
|
|
120 |
|
|
OUTFILE PREFIX.v
|
121 |
|
|
|
122 |
|
|
INCLUDE def_axi_master.txt
|
123 |
|
|
|
124 |
|
|
|
125 |
|
|
ITER IX ID_NUM
|
126 |
|
|
module PREFIX(PORTS);
|
127 |
|
|
|
128 |
|
|
input clk;
|
129 |
|
|
input reset;
|
130 |
|
|
|
131 |
|
|
port GROUP_STUB_AXI;
|
132 |
|
|
|
133 |
|
|
output idle;
|
134 |
|
|
output scrbrd_empty;
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
//random parameters
|
138 |
|
|
integer GROUP_AXI_MASTER_RAND = GROUP_AXI_MASTER_RAND.DEFAULT;
|
139 |
|
|
|
140 |
|
|
wire GROUP_STUB_AXI_IX;
|
141 |
|
|
wire idle_IX;
|
142 |
|
|
wire scrbrd_empty_IX;
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
always @(*)
|
146 |
|
|
begin
|
147 |
|
|
#FFD;
|
148 |
|
|
PREFIX_singleIX.GROUP_AXI_MASTER_RAND = GROUP_AXI_MASTER_RAND;
|
149 |
|
|
end
|
150 |
|
|
|
151 |
|
|
assign idle = CONCAT(idle_IX &);
|
152 |
|
|
assign scrbrd_empty = CONCAT(scrbrd_empty_IX &);
|
153 |
|
|
|
154 |
|
|
|
155 |
|
|
CREATE axi_master_single.v
|
156 |
|
|
|
157 |
|
|
LOOP IX ID_NUM
|
158 |
|
|
PREFIX_single #(IX, IDIX_VAL, CMD_DEPTH)
|
159 |
|
|
PREFIX_singleIX(
|
160 |
|
|
.clk(clk),
|
161 |
|
|
.reset(reset),
|
162 |
|
|
.GROUP_STUB_AXI(GROUP_STUB_AXI_IX),
|
163 |
|
|
.idle(idle_IX),
|
164 |
|
|
.scrbrd_empty(scrbrd_empty_IX)
|
165 |
|
|
);
|
166 |
|
|
ENDLOOP IX
|
167 |
|
|
|
168 |
|
|
IFDEF TRUE(ID_NUM==1)
|
169 |
|
|
|
170 |
|
|
assign GROUP_STUB_AXI.OUT = GROUP_STUB_AXI_0.OUT;
|
171 |
|
|
assign GROUP_STUB_AXI_0.IN = GROUP_STUB_AXI.IN;
|
172 |
|
|
|
173 |
|
|
ELSE TRUE(ID_NUM==1)
|
174 |
|
|
|
175 |
|
|
CREATE ic.v DEFCMD(SWAP.GLOBAL PARENT PREFIX) DEFCMD(SWAP.GLOBAL MASTER_NUM ID_NUM) DEFCMD(SWAP.GLOBAL CONST(ID_BITS) ID_BITS) DEFCMD(SWAP.GLOBAL CONST(CMD_DEPTH) CMD_DEPTH) DEFCMD(SWAP.GLOBAL CONST(DATA_BITS) DATA_BITS) DEFCMD(SWAP.GLOBAL CONST(ADDR_BITS) ADDR_BITS)
|
176 |
|
|
LOOP IX ID_NUM
|
177 |
|
|
STOMP NEWLINE
|
178 |
|
|
DEFCMD(LOOP.GLOBAL MIX_IDX 1)
|
179 |
|
|
STOMP NEWLINE
|
180 |
|
|
DEFCMD(SWAP.GLOBAL ID_MIX_ID0 IDIX_VAL)
|
181 |
|
|
ENDLOOP IX
|
182 |
|
|
|
183 |
|
|
PREFIX_ic PREFIX_ic(
|
184 |
|
|
.clk(clk),
|
185 |
|
|
.reset(reset),
|
186 |
|
|
.MIX_GROUP_STUB_AXI(GROUP_STUB_AXI_IX),
|
187 |
|
|
.S0_GROUP_STUB_AXI(GROUP_STUB_AXI),
|
188 |
|
|
STOMP ,
|
189 |
|
|
|
190 |
|
|
);
|
191 |
|
|
|
192 |
|
|
ENDIF TRUE(ID_NUM==1)
|
193 |
|
|
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
task check_master_num;
|
197 |
|
|
input [24*8-1:0] task_name;
|
198 |
|
|
input [31:0] master_num;
|
199 |
|
|
begin
|
200 |
|
|
if (master_num >= ID_NUM)
|
201 |
|
|
begin
|
202 |
|
|
$display("FATAL ERROR: task %0s called for master %0d that does not exist.\tTime: %0d ns.", task_name, master_num, $time);
|
203 |
|
|
end
|
204 |
|
|
end
|
205 |
|
|
endtask
|
206 |
|
|
|
207 |
|
|
task enable;
|
208 |
|
|
input [31:0] master_num;
|
209 |
|
|
begin
|
210 |
|
|
check_master_num("enable", master_num);
|
211 |
|
|
case (master_num)
|
212 |
|
|
IX : PREFIX_singleIX.enable = 1;
|
213 |
|
|
endcase
|
214 |
|
|
end
|
215 |
|
|
endtask
|
216 |
|
|
|
217 |
|
|
task enable_all;
|
218 |
|
|
begin
|
219 |
|
|
PREFIX_singleIX.enable = 1;
|
220 |
|
|
end
|
221 |
|
|
endtask
|
222 |
|
|
|
223 |
|
|
task write_single;
|
224 |
|
|
input [31:0] master_num;
|
225 |
|
|
input [ADDR_BITS-1:0] addr;
|
226 |
|
|
input [DATA_BITS-1:0] wdata;
|
227 |
|
|
begin
|
228 |
|
|
check_master_num("write_single", master_num);
|
229 |
|
|
case (master_num)
|
230 |
|
|
IX : PREFIX_singleIX.write_single(addr, wdata);
|
231 |
|
|
endcase
|
232 |
|
|
end
|
233 |
|
|
endtask
|
234 |
|
|
|
235 |
|
|
task read_single;
|
236 |
|
|
input [31:0] master_num;
|
237 |
|
|
input [ADDR_BITS-1:0] addr;
|
238 |
|
|
output [DATA_BITS-1:0] rdata;
|
239 |
|
|
begin
|
240 |
|
|
check_master_num("read_single", master_num);
|
241 |
|
|
case (master_num)
|
242 |
|
|
IX : PREFIX_singleIX.read_single(addr, rdata);
|
243 |
|
|
endcase
|
244 |
|
|
end
|
245 |
|
|
endtask
|
246 |
|
|
|
247 |
|
|
task check_single;
|
248 |
|
|
input [31:0] master_num;
|
249 |
|
|
input [ADDR_BITS-1:0] addr;
|
250 |
|
|
input [DATA_BITS-1:0] expected;
|
251 |
|
|
begin
|
252 |
|
|
check_master_num("check_single", master_num);
|
253 |
|
|
case (master_num)
|
254 |
|
|
IX : PREFIX_singleIX.check_single(addr, expected);
|
255 |
|
|
endcase
|
256 |
|
|
end
|
257 |
|
|
endtask
|
258 |
|
|
|
259 |
|
|
task write_and_check_single;
|
260 |
|
|
input [31:0] master_num;
|
261 |
|
|
input [ADDR_BITS-1:0] addr;
|
262 |
|
|
input [DATA_BITS-1:0] data;
|
263 |
|
|
begin
|
264 |
|
|
check_master_num("write_and_check_single", master_num);
|
265 |
|
|
case (master_num)
|
266 |
|
|
IX : PREFIX_singleIX.write_and_check_single(addr, data);
|
267 |
|
|
endcase
|
268 |
|
|
end
|
269 |
|
|
endtask
|
270 |
|
|
|
271 |
|
|
task insert_wr_cmd;
|
272 |
|
|
input [31:0] master_num;
|
273 |
|
|
input [ADDR_BITS-1:0] addr;
|
274 |
|
|
input [LEN_BITS-1:0] len;
|
275 |
|
|
input [SIZE_BITS-1:0] size;
|
276 |
|
|
begin
|
277 |
|
|
check_master_num("insert_wr_cmd", master_num);
|
278 |
|
|
case (master_num)
|
279 |
|
|
IX : PREFIX_singleIX.insert_wr_cmd(addr, len, size);
|
280 |
|
|
endcase
|
281 |
|
|
end
|
282 |
|
|
endtask
|
283 |
|
|
|
284 |
|
|
task insert_rd_cmd;
|
285 |
|
|
input [31:0] master_num;
|
286 |
|
|
input [ADDR_BITS-1:0] addr;
|
287 |
|
|
input [LEN_BITS-1:0] len;
|
288 |
|
|
input [SIZE_BITS-1:0] size;
|
289 |
|
|
begin
|
290 |
|
|
check_master_num("insert_rd_cmd", master_num);
|
291 |
|
|
case (master_num)
|
292 |
|
|
IX : PREFIX_singleIX.insert_rd_cmd(addr, len, size);
|
293 |
|
|
endcase
|
294 |
|
|
end
|
295 |
|
|
endtask
|
296 |
|
|
|
297 |
|
|
task insert_wr_data;
|
298 |
|
|
input [31:0] master_num;
|
299 |
|
|
input [DATA_BITS-1:0] wdata;
|
300 |
|
|
begin
|
301 |
|
|
check_master_num("insert_wr_data", master_num);
|
302 |
|
|
case (master_num)
|
303 |
|
|
IX : PREFIX_singleIX.insert_wr_data(wdata);
|
304 |
|
|
endcase
|
305 |
|
|
end
|
306 |
|
|
endtask
|
307 |
|
|
|
308 |
|
|
task insert_wr_incr_data;
|
309 |
|
|
input [31:0] master_num;
|
310 |
|
|
input [ADDR_BITS-1:0] addr;
|
311 |
|
|
input [LEN_BITS-1:0] len;
|
312 |
|
|
input [SIZE_BITS-1:0] size;
|
313 |
|
|
begin
|
314 |
|
|
check_master_num("insert_wr_incr_data", master_num);
|
315 |
|
|
case (master_num)
|
316 |
|
|
IX : PREFIX_singleIX.insert_wr_incr_data(addr, len, size);
|
317 |
|
|
endcase
|
318 |
|
|
end
|
319 |
|
|
endtask
|
320 |
|
|
|
321 |
|
|
task insert_rand_chk;
|
322 |
|
|
input [31:0] master_num;
|
323 |
|
|
input [31:0] burst_num;
|
324 |
|
|
begin
|
325 |
|
|
check_master_num("insert_rand_chk", master_num);
|
326 |
|
|
case (master_num)
|
327 |
|
|
IX : PREFIX_singleIX.insert_rand_chk(burst_num);
|
328 |
|
|
endcase
|
329 |
|
|
end
|
330 |
|
|
endtask
|
331 |
|
|
|
332 |
|
|
|
333 |
|
|
|
334 |
|
|
endmodule
|
335 |
|
|
|
336 |
|
|
|