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 2

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

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

powered by: WebSVN 2.1.0

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