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