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 8

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
   DEFCMD(SWAP.GLOBAL CONST(ID_NUM) 1)  \\
155
   DEFCMD(SWAP.GLOBAL CONST(ID0_VAL) ID_BITS'b0)
156
   PREFIX_axi_master axi_master(
157
                         .clk(clk),
158
                         .reset(reset),
159
 
160
                         .GROUP_AXI(GROUP_AXI),
161
                         .idle(idle),
162
                         .scrbrd_empty(scrbrd_empty)
163
                         );
164
 
165
 
166
   CREATE axi2ahb.v \\
167
   DEFCMD(SWAP.GLOBAL CONST(PREFIX) PREFIX) \\
168
   DEFCMD(SWAP.GLOBAL CONST(CMD_DEPTH) 4) \\
169
   DEFCMD(SWAP.GLOBAL CONST(ADDR_BITS) ADDR_BITS) \\
170
   DEFCMD(SWAP.GLOBAL CONST(DATA_BITS) DATA_BITS) \\
171
   DEFCMD(SWAP.GLOBAL CONST(ID_BITS) ID_BITS)
172
     PREFIX_axi2ahb axi2ahb(
173
                         .clk(clk),
174
                         .reset(reset),
175
 
176
                         .GROUP_AXI(GROUP_AXI),
177
                         .GROUP_AHB(GROUP_AHB),
178
                             STOMP ,
179
                             );
180
 
181
   task enable;
182
      begin
183
         axi_master.enable(0);
184
      end
185
   endtask
186
 
187
   task write_single;
188
      input [ADDR_BITS-1:0]  addr;
189
      input [DATA_BITS-1:0]  wdata;
190
      begin
191
         axi_master.write_single(0, addr, wdata);
192
      end
193
   endtask
194
 
195
   task read_single;
196
      input [ADDR_BITS-1:0]  addr;
197
      output [DATA_BITS-1:0]  rdata;
198
      begin
199
         axi_master.read_single(0, addr, rdata);
200
      end
201
   endtask
202
 
203
   task check_single;
204
      input [ADDR_BITS-1:0]  addr;
205
      input [DATA_BITS-1:0]  expected;
206
      begin
207
         axi_master.check_single(0, addr, expected);
208
      end
209
   endtask
210
 
211
   task write_and_check_single;
212
      input [ADDR_BITS-1:0]  addr;
213
      input [DATA_BITS-1:0]  data;
214
      begin
215
         axi_master.write_and_check_single(0, addr, data);
216
      end
217
   endtask
218
 
219
   task insert_wr_cmd;
220
      input [ADDR_BITS-1:0]  addr;
221
      input [LEN_BITS-1:0]   len;
222
      input [SIZE_BITS-1:0]  size;
223
      begin
224
         axi_master.insert_wr_cmd(0, addr, len, size);
225
      end
226
   endtask
227
 
228
   task insert_rd_cmd;
229
      input [ADDR_BITS-1:0]  addr;
230
      input [LEN_BITS-1:0]   len;
231
      input [SIZE_BITS-1:0]  size;
232
      begin
233
         axi_master.insert_rd_cmd(0, addr, len, size);
234
      end
235
   endtask
236
 
237
   task insert_wr_data;
238
      input [DATA_BITS-1:0]  wdata;
239
      begin
240
         axi_master.insert_wr_data(0, wdata);
241
      end
242
   endtask
243
 
244
   task insert_wr_incr_data;
245
      input [ADDR_BITS-1:0]  addr;
246
      input [LEN_BITS-1:0]   len;
247
      input [SIZE_BITS-1:0]  size;
248
      begin
249
         axi_master.insert_wr_incr_data(0, addr, len, size);
250
      end
251
   endtask
252
 
253
   task insert_rand_chk;
254
      input [31:0] burst_num;
255
      begin
256
         axi_master.insert_rand_chk(0, burst_num);
257
      end
258
   endtask
259
 
260
 
261
endmodule
262
 
263
 

powered by: WebSVN 2.1.0

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