URL
https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk
Subversion Repositories qaz_libs
[/] [qaz_libs/] [trunk/] [avalon_lib/] [sim/] [src/] [amm_bfm/] [amm_transaction_pkg.sv] - Rev 31
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 amm_transaction_pkg;// --------------------------------------------------------------------//class amm_delay_class;rand int unsigned delay;// --------------------------------------------------------------------//function int unsignednext;assert(this.randomize() with{delay dist {0 := 40, [1:3] := 40, [4:7] := 20};});return(delay);endfunction: next// --------------------------------------------------------------------//endclass: amm_delay_class// --------------------------------------------------------------------//class amm_payload_class #(N = 8, B = 1);rand logic [(8*N)-1:0] w[];// --------------------------------------------------------------------//functionnew(logic [B-1:0] burstcount = 0);this.w = new[burstcount + 1];endfunction: new// --------------------------------------------------------------------//function voidrandom(logic [B-1:0] burstcount = 0);this.w = new[burstcount + 1];assert(this.randomize());endfunction: random// --------------------------------------------------------------------//endclass: amm_payload_class// --------------------------------------------------------------------//class amm_transaction_class #(A = 32, N = 8, B = 1);amm_delay_class delay_h;amm_payload_class #(.N(N), .B(B)) payload_h;amm_payload_class #(.N(N), .B(B)) data_h;rand logic [(A-1):0] address = 'bz;rand logic [N-1:0] byteenable = {N{1'b1}};rand logic [B-1:0] burstcount = 1;constraint default_burstcount{burstcount dist {0 := 40, [1:15] := 40, [16:255] := 20};}// --------------------------------------------------------------------//functionnew(logic [B-1:0] burstcount = 0);this.payload_h = new(burstcount + 1);this.delay_h = new;endfunction: new// --------------------------------------------------------------------//function voidbasic_random;assert(this.randomize() with{this.burstcount == 1;});this.payload_h.random(this.burstcount);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 voidbasic_read(logic [(A-1):0] address,logic [B-1:0] burstcount = 1);this.address = address;this.burstcount = burstcount;this.payload_h.random(burstcount);endfunction: basic_read// --------------------------------------------------------------------//function voidbasic_write(logic [(A-1):0] address,logic [B-1:0] burstcount = 1);this.address = address;this.burstcount = burstcount;this.payload_h.random(burstcount);endfunction: basic_write// --------------------------------------------------------------------//function void copy(amm_transaction_class #(.A(A), .N(N), .B(B)) from);this.address = from.address;this.byteenable = from.byteenable;this.burstcount = from.burstcount;endfunction: copy// --------------------------------------------------------------------//virtual function amm_transaction_class #(.A(A), .N(N), .B(B)) clone;clone = new();clone.copy(this);return(clone);endfunction: clone// --------------------------------------------------------------------//endclass: amm_transaction_class// --------------------------------------------------------------------//endpackage: amm_transaction_pkg
