URL
https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk
Subversion Repositories qaz_libs
[/] [qaz_libs/] [trunk/] [axi4_lite_lib/] [sim/] [src/] [axi4_lite_agent_pkg.sv] - Rev 29
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_lite_agent_pkg;
// --------------------------------------------------------------------
//
import axi4_transaction_pkg::*;
// --------------------------------------------------------------------
//
class axi4_lite_agent_class #(A = 32, N = 8, I = 1, MW = 3);
axi4_transaction_class #(.A(A), .N(N), .I(I)) tr_h;
virtual axi4_master_bfm_if #(.A(A), .N(N), .I(I)) axi4_m;
virtual axi4_lite_register_if #(.N(N), .MW(MW)) r_if;
//--------------------------------------------------------------------
localparam LB = (N == 8) ? 3 : 2;
localparam UB = LB + MW - 1;
//--------------------------------------------------------------------
function new
(
virtual axi4_master_bfm_if #(.A(A), .N(N), .I(I)) axi4_m,
virtual axi4_lite_register_if #(.N(N), .MW(MW)) r_if
);
this.axi4_m = axi4_m;
this.r_if = r_if;
endfunction: new
// --------------------------------------------------------------------
//
task
basic_read
(
input logic [(A-1):0] araddr,
output logic [(8*N)-1:0] data[],
output logic [1:0] rresp
);
this.tr_h = new;
this.tr_h.basic_read(araddr);
axi4_m.ar_h.put(tr_h);
axi4_m.r_h.put(tr_h);
@(axi4_m.r_h.done);
data = tr_h.data_h.w;
rresp = tr_h.resp;
endtask: basic_read
// --------------------------------------------------------------------
//
task
basic_write
(
input logic [(A-1):0] awaddr,
input logic [(8*N)-1:0] data[],
output logic [1:0] bresp
);
this.tr_h = new;
this.tr_h.basic_write(awaddr);
foreach(this.tr_h.payload_h.w[i])
this.tr_h.payload_h.w[i] = data[i];
axi4_m.aw_h.put(tr_h);
axi4_m.w_h.put(tr_h);
axi4_m.b_h.put(tr_h);
endtask: basic_write
// --------------------------------------------------------------------
//
task
basic_random_write
(
input logic [(A-1):0] awaddr,
output logic [1:0] bresp
);
this.tr_h = new;
this.tr_h.basic_write(awaddr);
axi4_m.aw_h.put(tr_h);
axi4_m.w_h.put(tr_h);
axi4_m.b_h.put(tr_h);
@(axi4_m.b_h.done);
if(r_if.register_out[awaddr[UB:LB]] == this.tr_h.payload_h.w[0])
$display("^^^ %16.t | @0x%08x | PASS!!!", $time, awaddr);
else
$display("^^^ %16.t | @0x%08x | FAIL!!!", $time, awaddr);
endtask: basic_random_write
// --------------------------------------------------------------------
//
function void
init;
endfunction: init
// --------------------------------------------------------------------
//
endclass: axi4_lite_agent_class
// --------------------------------------------------------------------
//
endpackage: axi4_lite_agent_pkg