URL
https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk
Subversion Repositories qaz_libs
[/] [qaz_libs/] [trunk/] [axi4_lib/] [sim/] [src/] [legacy/] [axi4_bfm/] [axi4_transaction_pkg.sv] - Rev 45
Compare with Previous | Blame | View Log
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2015 Authors and OPENCORES.ORG ////
//// ////
//// This source file may be used and distributed without ////
//// restriction provided that this copyright statement is not ////
//// removed from the file and that any derivative work contains ////
//// the original copyright notice and the associated disclaimer. ////
//// ////
//// This source file is free software; you can redistribute it ////
//// and/or modify it under the terms of the GNU Lesser General ////
//// Public License as published by the Free Software Foundation; ////
//// either version 2.1 of the License, or (at your option) any ////
//// later version. ////
//// ////
//// This source is distributed in the hope that it will be ////
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
//// PURPOSE. See the GNU Lesser General Public License for more ////
//// details. ////
//// ////
//// You should have received a copy of the GNU Lesser General ////
//// Public License along with this source; if not, download it ////
//// from http://www.opencores.org/lgpl.shtml ////
//// ////
//////////////////////////////////////////////////////////////////////
package axi4_transaction_pkg;
// --------------------------------------------------------------------
//
class axi4_delay_class;
rand int unsigned delay;
// --------------------------------------------------------------------
//
function int unsigned
next;
assert(this.randomize() with{delay dist {0 := 40, [1:3] := 40, [4:7] := 20};});
return(delay);
endfunction: next
// --------------------------------------------------------------------
//
endclass: axi4_delay_class
// --------------------------------------------------------------------
//
class axi4_payload_class #(N = 8);
rand logic [(8*N)-1:0] w[];
// --------------------------------------------------------------------
//
function
new
(
logic [7:0] len = 0
);
this.w = new[len + 1];
endfunction: new
// --------------------------------------------------------------------
//
function void
random
(
logic [7:0] len = 0
);
this.w = new[len + 1];
assert(this.randomize());
endfunction: random
// --------------------------------------------------------------------
//
endclass: axi4_payload_class
// --------------------------------------------------------------------
//
class axi4_transaction_class #(A = 32, N = 8, I = 1);
axi4_delay_class delay_h;
axi4_payload_class #(.N(N)) payload_h;
axi4_payload_class #(.N(N)) data_h;
rand logic [(A-1):0] addr = 'bz;
rand logic [1:0] burst = 2'b01;
rand logic [7:0] len = 0;
rand logic [2:0] size = $clog2(N);
rand logic [(I-1):0] id = 0;
rand logic [1:0] resp = 0;
logic [3:0] cache = 0;
logic lock = 0;
logic [2:0] prot = 0;
logic [3:0] qos = 0;
logic [3:0] region = 0;
constraint default_len
{
len dist {0 := 40, [1:15] := 40, [16:255] := 20};
}
// --------------------------------------------------------------------
//
function
new
(
logic [7:0] len = 0
);
this.payload_h = new(len + 1);
this.delay_h = new;
endfunction: new
// --------------------------------------------------------------------
//
function void
basic_random;
assert(this.randomize() with
{
this.id == 0;
this.resp == 0;
this.burst == 2'b01;
this.len == 0;
this.size == $clog2(N);
});
this.payload_h.random(this.len);
endfunction: basic_random
// --------------------------------------------------------------------
//
function void
basic_random_burst;
assert(this.randomize() with
{
this.addr[$clog2(N*8)-1:0] == 0;
this.id == 0;
this.resp == 0;
this.burst == 2'b01;
this.size == $clog2(N);
this.len dist {0 := 40, [1:3] := 40, [4:15] := 20};
});
this.payload_h.random(this.len);
endfunction: basic_random_burst
// --------------------------------------------------------------------
//
function void
basic_read
(
logic [(A-1):0] addr,
logic [7:0] len = 0
);
this.id = 0;
this.resp = 0;
this.burst = 2'b01;
this.size = $clog2(N);
this.addr = addr;
this.len = len;
this.payload_h.random(len);
endfunction: basic_read
// --------------------------------------------------------------------
//
function void
basic_write
(
logic [(A-1):0] addr,
logic [7:0] len = 0
);
this.id = 0;
this.resp = 0;
this.burst = 2'b01;
this.size = $clog2(N);
this.addr = addr;
this.len = len;
this.payload_h.random(len);
endfunction: basic_write
// --------------------------------------------------------------------
//
function void copy
(
axi4_transaction_class #(.A(A), .N(N), .I(I)) from
);
this.addr = from.addr;
this.burst = from.burst;
this.len = from.len;
this.size = from.size;
this.id = from.id;
this.resp = from.resp;
this.cache = from.cache;
this.lock = from.lock;
this.prot = from.prot;
this.qos = from.qos;
this.region = from.region;
endfunction: copy
// --------------------------------------------------------------------
//
virtual function axi4_transaction_class #(.A(A), .N(N), .I(I)) clone;
clone = new();
clone.copy(this);
return(clone);
endfunction: clone
// --------------------------------------------------------------------
//
endclass: axi4_transaction_class
// --------------------------------------------------------------------
//
endpackage: axi4_transaction_pkg