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

Subversion Repositories ahb_master

[/] [ahb_master/] [trunk/] [src/] [base/] [ahb_master.v] - Blame information for rev 11

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

Line No. Rev Author Line
1 8 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 AHB is built of an AXI master and an AXI2AHB bridge
34
// 
35
//
36
// I/F :
37
//   idle - all internal masters emptied their command FIFOs
38
//   scrbrd_empty - all scoreboard checks have been completed (for random testing)
39
//
40
//
41
// Tasks:
42
//
43
// enable()
44
//   Description: Enables AHB master
45
//
46
// write_single(input addr, input wdata)
47
//   Description: write a single AHB burst (1 data cycle)
48
//   Parameters:
49
//           addr  - address
50
//           wdata - write data
51
// 
52
// read_single(input addr, output rdata)
53
//   Description:
54
//   Parameters:
55
//               addr  - address
56
//               rdata - return read data
57
//
58
// check_single(input addr, input expected)
59
//   Description: read a single AHB burst and gives an error if the data read does not match expected
60
//   Parameters:
61
//               addr  - address
62
//               expected - expected read data
63
//
64
// write_and_check_single(input addr, input data)
65
//   Description: write a single AHB burst read it back and compare the write and read data
66
//   Parameters:
67
//               addr  - address
68
//               data - data to write and expect on read
69
//
70
// insert_wr_cmd(input addr, input len, input size)
71
//   Description: add an AHB write burst to command FIFO
72
//   Parameters:
73
//               addr - address
74
//               len - AHB LEN (data strobe number)
75
//               size - AHB SIZE (data width)
76
//  
77
// insert_rd_cmd(input addr, input len, input size)
78
//   Description: add an AHB read burst to command FIFO
79
//   Parameters:
80
//               addr - address
81
//               len - AHB LEN (data strobe number)
82
//               size - AHB SIZE (data width)
83
//  
84
// insert_wr_data(input wdata)
85
//   Description: add a single data to data FIFO (to be used in write bursts)
86
//   Parameters:
87
//               wdata - write data
88
//  
89
// insert_wr_incr_data(input addr, input len, input size)
90
//   Description: add an AHB write burst to command FIFO will use incremental data (no need to use insert_wr_data)
91
//   Parameters:
92
//               addr - address
93
//               len - AHB LEN (data strobe number)
94
//               size - AHB SIZE (data width)
95
//  
96
// insert_rand_chk(input burst_num)
97
//   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.
98
//   Parameters:
99
//               burst_num - total number of bursts to check
100
//  
101
//  
102
//  Parameters:
103
//  
104
//    For random testing: (changing these values automatically update interanl masters)
105
//      len_min  - minimum burst AHB LEN (length)
106
//      len_max  - maximum burst AHB LEN (length)
107
//      size_min - minimum burst AHB SIZE (width)
108
//      size_max - maximum burst AHB SIZE (width)
109
//      addr_min - minimum address (in bytes)
110
//      addr_max - maximum address (in bytes)
111
//  
112
//////////////////////////////////////
113
 
114
OUTFILE PREFIX.v
115
 
116
INCLUDE def_ahb_master.txt
117
 
118
module PREFIX(PORTS);
119
   input                      clk;
120
   input                      reset;
121
 
122
   revport                    GROUP_AHB;
123
   output                     idle;
124
   output                     scrbrd_empty;
125
 
126
 
127
   parameter                  LEN_BITS  = 4;
128
   ##parameter                  SIZE_BITS = 2;
129
 
130
   wire                       GROUP_AXI;
131
 
132
   wire                       GROUP_AHB;
133
 
134
   integer                             GROUP_AXI_MASTER_RAND = GROUP_AXI_MASTER_RAND.DEFAULT;
135
 
136
   always @(*)
137
     begin
138
        #FFD;
139
        axi_master.GROUP_AXI_MASTER_RAND = GROUP_AXI_MASTER_RAND;
140
     end
141
 
142
   initial
143
     begin
144
        #100;
145
        ahb_bursts=1;
146
     end
147
 
148
 
149
CREATE axi_master.v \\
150
   DEFCMD(SWAP.GLOBAL CONST(PREFIX) PREFIX_axi_master) \\
151
   DEFCMD(SWAP.GLOBAL CONST(ID_BITS) ID_BITS) \\
152
   DEFCMD(SWAP.GLOBAL CONST(ADDR_BITS) ADDR_BITS) \\
153
   DEFCMD(SWAP.GLOBAL CONST(DATA_BITS) DATA_BITS) \\
154 10 eyalhoc
   DEFCMD(GROUP.USER AXI_ID overrides {)  \\
155 11 eyalhoc
   DEFCMD(0) \\
156 10 eyalhoc
   DEFCMD(})
157 8 eyalhoc
   PREFIX_axi_master axi_master(
158
                         .clk(clk),
159
                         .reset(reset),
160
 
161
                         .GROUP_AXI(GROUP_AXI),
162
                         .idle(idle),
163
                         .scrbrd_empty(scrbrd_empty)
164
                         );
165
 
166
 
167
   CREATE axi2ahb.v \\
168 10 eyalhoc
   DEFCMD(SWAP.GLOBAL CONST(PREFIX) PREFIX_axi2ahb) \\
169 8 eyalhoc
   DEFCMD(SWAP.GLOBAL CONST(CMD_DEPTH) 4) \\
170
   DEFCMD(SWAP.GLOBAL CONST(ADDR_BITS) ADDR_BITS) \\
171
   DEFCMD(SWAP.GLOBAL CONST(DATA_BITS) DATA_BITS) \\
172
   DEFCMD(SWAP.GLOBAL CONST(ID_BITS) ID_BITS)
173
     PREFIX_axi2ahb axi2ahb(
174
                         .clk(clk),
175
                         .reset(reset),
176
 
177
                         .GROUP_AXI(GROUP_AXI),
178
                         .GROUP_AHB(GROUP_AHB),
179
                             STOMP ,
180
                             );
181
 
182
   task enable;
183
      begin
184
         axi_master.enable(0);
185
      end
186
   endtask
187
 
188
   task write_single;
189
      input [ADDR_BITS-1:0]  addr;
190
      input [DATA_BITS-1:0]  wdata;
191
      begin
192
         axi_master.write_single(0, addr, wdata);
193
      end
194
   endtask
195
 
196
   task read_single;
197
      input [ADDR_BITS-1:0]  addr;
198
      output [DATA_BITS-1:0]  rdata;
199
      begin
200
         axi_master.read_single(0, addr, rdata);
201
      end
202
   endtask
203
 
204
   task check_single;
205
      input [ADDR_BITS-1:0]  addr;
206
      input [DATA_BITS-1:0]  expected;
207
      begin
208
         axi_master.check_single(0, addr, expected);
209
      end
210
   endtask
211
 
212
   task write_and_check_single;
213
      input [ADDR_BITS-1:0]  addr;
214
      input [DATA_BITS-1:0]  data;
215
      begin
216
         axi_master.write_and_check_single(0, addr, data);
217
      end
218
   endtask
219
 
220
   task insert_wr_cmd;
221
      input [ADDR_BITS-1:0]  addr;
222
      input [LEN_BITS-1:0]   len;
223
      input [SIZE_BITS-1:0]  size;
224
      begin
225
         axi_master.insert_wr_cmd(0, addr, len, size);
226
      end
227
   endtask
228
 
229
   task insert_rd_cmd;
230
      input [ADDR_BITS-1:0]  addr;
231
      input [LEN_BITS-1:0]   len;
232
      input [SIZE_BITS-1:0]  size;
233
      begin
234
         axi_master.insert_rd_cmd(0, addr, len, size);
235
      end
236
   endtask
237
 
238
   task insert_wr_data;
239
      input [DATA_BITS-1:0]  wdata;
240
      begin
241
         axi_master.insert_wr_data(0, wdata);
242
      end
243
   endtask
244
 
245
   task insert_wr_incr_data;
246
      input [ADDR_BITS-1:0]  addr;
247
      input [LEN_BITS-1:0]   len;
248
      input [SIZE_BITS-1:0]  size;
249
      begin
250
         axi_master.insert_wr_incr_data(0, addr, len, size);
251
      end
252
   endtask
253
 
254
   task insert_rand_chk;
255
      input [31:0] burst_num;
256
      begin
257
         axi_master.insert_rand_chk(0, burst_num);
258
      end
259
   endtask
260
 
261
 
262
endmodule
263
 
264
 

powered by: WebSVN 2.1.0

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