OpenCores
URL https://opencores.org/ocsvn/axi_master/axi_master/trunk

Subversion Repositories axi_master

[/] [axi_master/] [trunk/] [src/] [base/] [axi_master.v] - Blame information for rev 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
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
OUTFILE PREFIX.v
31
 
32
INCLUDE def_axi_master.txt
33
 
34
 
35
//////////////////////////////////////
36
//
37
// General:
38
//   The AXI master has an internal master per ID. 
39
//   These internal masters work simultaniously and an interconnect matrix connets them. 
40
// 
41
//
42
// I/F :
43
//   idle - all internal masters emptied their command FIFOs
44
//   scrbrd_empty - all scoreboard checks have been completed (for random testing)
45
//
46
//
47
// Tasks:
48
//
49
// enable(input master_num)
50
//   Description: Enables master
51
//   Parameters: master_num - number of internal master
52
//
53
// enable_all()  
54
//   Description: Enables all masters
55
//
56
// write_single(input master_num, input addr, input wdata)
57
//   Description: write a single AXI burst (1 data cycle)
58
//   Parameters: master_num - number of internal master
59
//           addr  - address
60
//           wdata - write data
61
// 
62
// read_single(input master_num, input addr, output rdata)
63
//   Description: read a single AXI burst (1 data cycle)
64
//   Parameters: master_num - number of internal master
65
//               addr  - address
66
//               rdata - return read data
67
//
68
// insert_wr_cmd(input master_num, input addr, input len, input size)
69
//   Description: add an AXI write burst to command FIFO
70
//   Parameters: master_num - number of internal master
71
//               addr - address
72
//               len - AXI LEN (data strobe number)
73
//               size - AXI SIZE (data width)
74
//  
75
// insert_rd_cmd(input master_num, input addr, input len, input size)
76
//   Description: add an AXI read 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_wr_data(input master_num, input wdata)
83
//   Description: add a single data to data FIFO (to be used in write bursts)
84
//   Parameters: master_num - number of internal master
85
//               wdata - write data
86
//  
87
// insert_wr_incr_data(input master_num, input addr, input len, input size)
88
//   Description: add an AXI write burst to command FIFO will use incremental data (no need to use insert_wr_data)
89
//   Parameters: master_num - number of internal master
90
//               addr - address
91
//               len - AXI LEN (data strobe number)
92
//               size - AXI SIZE (data width)
93
//  
94
// insert_rand_chk(input master_num, input burst_num)
95
//   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.
96
//   Parameters: master_num - number of internal master
97
//               burst_num - total number of bursts to check
98
//  
99
 
100
//  
101
//  Parameters:
102
//  
103
//    For random testing: (changing these values automatically update interanl masters)
104
//      len_min  - minimum burst LEN (length)
105
//      len_max  - maximum burst LEN (length)
106
//      size_min - minimum burst SIZE (length)
107
//      size_max - maximum burst SIZE (length)
108
//      addr_min - minimum address (in bytes)
109
//      addr_max - maximum address (in bytes)
110
//  
111
//////////////////////////////////////
112
 
113
 
114
ITER IX ID_NUM
115
module PREFIX(PORTS);
116
 
117
   input                               clk;
118
   input                               reset;
119
 
120
   port                                GROUP_STUB_AXI;
121
 
122
   output                              idle;
123
   output                              scrbrd_empty;
124
 
125
 
126
   //random parameters
127
   integer                             GROUP_AXI_MASTER_RAND = GROUP_AXI_MASTER_RAND.DEFAULT;
128
 
129
   wire                                GROUP_STUB_AXI_IX;
130
   wire                                idle_IX;
131
   wire                                scrbrd_empty_IX;
132
 
133
 
134
   always @(*)
135
     begin
136
        #FFD;
137
        PREFIX_singleIX.GROUP_AXI_MASTER_RAND = GROUP_AXI_MASTER_RAND;
138
     end
139
 
140
   assign                              idle = CONCAT(idle_IX &);
141
   assign                              scrbrd_empty = CONCAT(scrbrd_empty_IX &);
142
 
143
 
144
   CREATE axi_master_single.v
145
 
146
     LOOP IX ID_NUM
147
   PREFIX_single #(IX, IDIX_VAL, CMD_DEPTH)
148
   PREFIX_singleIX(
149
                   .clk(clk),
150
                   .reset(reset),
151
                   .GROUP_STUB_AXI(GROUP_STUB_AXI_IX),
152
                   .idle(idle_IX),
153
                   .scrbrd_empty(scrbrd_empty_IX)
154
                   );
155
   ENDLOOP IX
156
 
157
     IFDEF TRUE(ID_NUM==1)
158
 
159
   assign GROUP_STUB_AXI.OUT = GROUP_STUB_AXI_0.OUT;
160
   assign GROUP_STUB_AXI_0.IN = GROUP_STUB_AXI.IN;
161
 
162
     ELSE TRUE(ID_NUM==1)
163
 
164
   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)
165
   LOOP IX ID_NUM
166
     STOMP NEWLINE
167
     DEFCMD(LOOP.GLOBAL MIX_IDX 1)
168
     STOMP NEWLINE
169
     DEFCMD(SWAP.GLOBAL ID_MIX_ID0 IDIX_VAL)
170
   ENDLOOP IX
171
 
172
    PREFIX_ic PREFIX_ic(
173
                       .clk(clk),
174
                       .reset(reset),
175
                       .MIX_GROUP_STUB_AXI(GROUP_STUB_AXI_IX),
176
                       .S0_GROUP_STUB_AXI(GROUP_STUB_AXI),
177
                       STOMP ,
178
 
179
      );
180
 
181
     ENDIF TRUE(ID_NUM==1)
182
 
183
 
184
 
185
   task check_master_num;
186
      input [24*8-1:0] task_name;
187
      input [31:0] master_num;
188
      begin
189
         if (master_num >= ID_NUM)
190
           begin
191
              $display("FATAL ERROR: task %0s called for master %0d that does not exist.\tTime: %0d ns.", task_name, master_num, $time);
192
           end
193
      end
194
   endtask
195
 
196
   task enable;
197
      input [31:0] master_num;
198
      begin
199
         check_master_num("enable", master_num);
200
         case (master_num)
201
           IX : PREFIX_singleIX.enable = 1;
202
         endcase
203
      end
204
   endtask
205
 
206
   task enable_all;
207
      begin
208
         PREFIX_singleIX.enable = 1;
209
      end
210
   endtask
211
 
212
   task write_single;
213
      input [31:0] master_num;
214
      input [ADDR_BITS-1:0]  addr;
215
      input [DATA_BITS-1:0]  wdata;
216
      begin
217
         check_master_num("write_single", master_num);
218
         case (master_num)
219
           IX : PREFIX_singleIX.write_single(addr, wdata);
220
         endcase
221
      end
222
   endtask
223
 
224
   task read_single;
225
      input [31:0] master_num;
226
      input [ADDR_BITS-1:0]  addr;
227
      output [DATA_BITS-1:0]  rdata;
228
      begin
229
         check_master_num("read_single", master_num);
230
         case (master_num)
231
           IX : PREFIX_singleIX.read_single(addr, rdata);
232
         endcase
233
      end
234
   endtask
235
 
236
   task insert_wr_cmd;
237
      input [31:0] master_num;
238
      input [ADDR_BITS-1:0]  addr;
239
      input [LEN_BITS-1:0]   len;
240
      input [SIZE_BITS-1:0]  size;
241
      begin
242
         check_master_num("insert_wr_cmd", master_num);
243
         case (master_num)
244
           IX : PREFIX_singleIX.insert_wr_cmd(addr, len, size);
245
         endcase
246
      end
247
   endtask
248
 
249
   task insert_rd_cmd;
250
      input [31:0] master_num;
251
      input [ADDR_BITS-1:0]  addr;
252
      input [LEN_BITS-1:0]   len;
253
      input [SIZE_BITS-1:0]  size;
254
      begin
255
         check_master_num("insert_rd_cmd", master_num);
256
         case (master_num)
257
           IX : PREFIX_singleIX.insert_rd_cmd(addr, len, size);
258
         endcase
259
      end
260
   endtask
261
 
262
   task insert_wr_data;
263
      input [31:0] master_num;
264
      input [DATA_BITS-1:0]  wdata;
265
      begin
266
         check_master_num("insert_wr_data", master_num);
267
         case (master_num)
268
           IX : PREFIX_singleIX.insert_wr_data(wdata);
269
         endcase
270
      end
271
   endtask
272
 
273
   task insert_wr_incr_data;
274
      input [31:0] master_num;
275
      input [ADDR_BITS-1:0]  addr;
276
      input [LEN_BITS-1:0]   len;
277
      input [SIZE_BITS-1:0]  size;
278
      begin
279
         check_master_num("insert_wr_incr_data", master_num);
280
         case (master_num)
281
           IX : PREFIX_singleIX.insert_wr_incr_data(addr, len, size);
282
         endcase
283
      end
284
   endtask
285
 
286
   task insert_rand_chk;
287
      input [31:0] master_num;
288
      input [31:0] burst_num;
289
      begin
290
         check_master_num("insert_rand_chk", master_num);
291
         case (master_num)
292
           IX : PREFIX_singleIX.insert_rand_chk(burst_num);
293
         endcase
294
      end
295
   endtask
296
 
297
 
298
 
299
endmodule
300
 
301
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.