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 4

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 4 eyalhoc
        ahb_bursts=1;
118 2 eyalhoc
     end
119
 
120
 
121
CREATE axi_master.v \\
122 4 eyalhoc
   DEFCMD(SWAP.GLOBAL CONST(PREFIX) PREFIX_axi_master) \\
123 2 eyalhoc
   DEFCMD(SWAP.GLOBAL CONST(ID_BITS) ID_BITS) \\
124
   DEFCMD(SWAP.GLOBAL CONST(ADDR_BITS) ADDR_BITS) \\
125
   DEFCMD(SWAP.GLOBAL CONST(DATA_BITS) DATA_BITS) \\
126
   DEFCMD(SWAP.GLOBAL CONST(ID_NUM) 1)  \\
127
   DEFCMD(SWAP.GLOBAL CONST(ID0_VAL) ID_BITS'b0)
128 4 eyalhoc
   PREFIX_axi_master axi_master(
129 2 eyalhoc
                         .clk(clk),
130
                         .reset(reset),
131
 
132
                         .GROUP_AXI(GROUP_AXI),
133
                         .idle(idle),
134
                         .scrbrd_empty(scrbrd_empty)
135
                         );
136
 
137
 
138
   CREATE axi2ahb.v \\
139 4 eyalhoc
   DEFCMD(SWAP.GLOBAL CONST(PREFIX) PREFIX) \\
140 2 eyalhoc
   DEFCMD(SWAP.GLOBAL CONST(CMD_DEPTH) 4) \\
141
   DEFCMD(SWAP.GLOBAL CONST(ADDR_BITS) ADDR_BITS) \\
142
   DEFCMD(SWAP.GLOBAL CONST(DATA_BITS) DATA_BITS) \\
143
   DEFCMD(SWAP.GLOBAL CONST(ID_BITS) ID_BITS)
144 4 eyalhoc
     PREFIX_axi2ahb axi2ahb(
145 2 eyalhoc
                         .clk(clk),
146
                         .reset(reset),
147
 
148
                         .GROUP_AXI(GROUP_AXI),
149
                         .GROUP_AHB(GROUP_AHB),
150
                             STOMP ,
151
                             );
152
 
153
   task enable;
154
      begin
155
         axi_master.enable(0);
156
      end
157
   endtask
158
 
159
   task write_single;
160
      input [ADDR_BITS-1:0]  addr;
161
      input [DATA_BITS-1:0]  wdata;
162
      begin
163
         axi_master.write_single(0, addr, wdata);
164
      end
165
   endtask
166
 
167
   task read_single;
168
      input [ADDR_BITS-1:0]  addr;
169
      output [DATA_BITS-1:0]  rdata;
170
      begin
171
         axi_master.read_single(0, addr, rdata);
172
      end
173
   endtask
174
 
175
   task check_single;
176
      input [ADDR_BITS-1:0]  addr;
177
      input [DATA_BITS-1:0]  expected;
178
      begin
179
         axi_master.check_single(0, addr, expected);
180
      end
181
   endtask
182
 
183
   task write_and_check_single;
184
      input [ADDR_BITS-1:0]  addr;
185
      input [DATA_BITS-1:0]  data;
186
      begin
187
         axi_master.write_and_check_single(0, addr, data);
188
      end
189
   endtask
190
 
191
   task insert_wr_cmd;
192
      input [ADDR_BITS-1:0]  addr;
193
      input [LEN_BITS-1:0]   len;
194
      input [SIZE_BITS-1:0]  size;
195
      begin
196
         axi_master.insert_wr_cmd(0, addr, len, size);
197
      end
198
   endtask
199
 
200
   task insert_rd_cmd;
201
      input [ADDR_BITS-1:0]  addr;
202
      input [LEN_BITS-1:0]   len;
203
      input [SIZE_BITS-1:0]  size;
204
      begin
205
         axi_master.insert_rd_cmd(0, addr, len, size);
206
      end
207
   endtask
208
 
209
   task insert_wr_data;
210
      input [DATA_BITS-1:0]  wdata;
211
      begin
212
         axi_master.insert_wr_data(0, wdata);
213
      end
214
   endtask
215
 
216
   task insert_wr_incr_data;
217
      input [ADDR_BITS-1:0]  addr;
218
      input [LEN_BITS-1:0]   len;
219
      input [SIZE_BITS-1:0]  size;
220
      begin
221
         axi_master.insert_wr_incr_data(0, addr, len, size);
222
      end
223
   endtask
224
 
225
   task insert_rand_chk;
226
      input [31:0] burst_num;
227
      begin
228
         axi_master.insert_rand_chk(0, burst_num);
229
      end
230
   endtask
231
 
232
 
233
endmodule
234
 
235
 

powered by: WebSVN 2.1.0

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