URL
https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk
Subversion Repositories qaz_libs
[/] [qaz_libs/] [trunk/] [axi4_stream_lib/] [sim/] [src/] [legacy/] [axis_bfm_pkg.sv] - Rev 49
Go to most recent revision | 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 axis_bfm_pkg;
// --------------------------------------------------------------------
//
import q_pkg::*;
import bfm_pkg::*;
// --------------------------------------------------------------------
//
class axis_tr_class #(N, I, D, U)
extends transaction_class #(axis_tr_class #(N, I, D, U));
rand logic [(8*N)-1:0] tdata;
rand logic [N-1:0] tstrb;
rand logic [N-1:0] tkeep;
rand logic tlast;
rand logic [I-1:0] tid;
rand logic [D-1:0] tdest;
rand logic [U-1:0] tuser;
// --------------------------------------------------------------------
//
function void copy(TR_T from);
// delay_class delay_h;
this.tdata = from.tdata;
this.tstrb = from.tstrb;
this.tkeep = from.tkeep;
this.tlast = from.tlast;
this.tid = from.tid;
this.tdest = from.tdest;
this.tuser = from.tuser;
endfunction: copy
// --------------------------------------------------------------------
//
endclass: axis_tr_class
// --------------------------------------------------------------------
//
class axis_tx_bfm_class #(N, I, D, U)
extends blocking_transmission_q_class #(axis_tr_class #(.N(N), .I(I), .D(D), .U(U)));
virtual axis_if #(.N(N), .I(I), .D(D), .U(U)) axis_out;
//--------------------------------------------------------------------
//
function void set_default;
axis_out.cb_m.tvalid <= 0;
axis_out.cb_m.tdata <= 'bx;
axis_out.cb_m.tstrb <= 'bx;
axis_out.cb_m.tkeep <= 'bx;
axis_out.cb_m.tlast <= 'bx;
axis_out.cb_m.tid <= 'bx;
axis_out.cb_m.tdest <= 'bx;
axis_out.cb_m.tuser <= 'bx;
endfunction: set_default
//--------------------------------------------------------------------
//
task tx_transaction(axis_tr_class #(.N(N), .I(I), .D(D), .U(U)) tr_h);
axis_out.zero_cycle_delay();
repeat(tr_h.delay_h.delay) @(axis_out.cb_m);
axis_out.cb_m.tvalid <= 1;
axis_out.cb_m.tdata <= tr_h.tdata;
axis_out.cb_m.tstrb <= 0;
axis_out.cb_m.tkeep <= 0;
axis_out.cb_m.tlast <= tr_h.tlast;
axis_out.cb_m.tid <= 0;
axis_out.cb_m.tdest <= 0;
axis_out.cb_m.tuser <= tr_h.tuser;
@(axis_out.cb_m);
wait(axis_out.cb_m.tready);
// @(axis_out.cb_m iff axis_out.cb_m.tready);
set_default();
endtask: tx_transaction
// --------------------------------------------------------------------
//
event tx_done;
task automatic transmit(ref Q_T tr_h);
tx_transaction(tr_h);
->tx_done;
endtask: transmit
//--------------------------------------------------------------------
//
task init;
set_default();
endtask: init
//--------------------------------------------------------------------
//
function new(virtual axis_if #(.N(N), .I(I), .D(D), .U(U)) axis_out);
this.axis_out = axis_out;
tr_h = new();
fork
init();
join_none
$display("^^^ %16.t | %m", $time);
endfunction: new
// --------------------------------------------------------------------
//
endclass: axis_tx_bfm_class
// --------------------------------------------------------------------
//
class axis_rx_bfm_class #(N, I, D, U)
extends blocking_receiver_q_class #(axis_tr_class #(.N(N), .I(I), .D(D), .U(U)));
virtual axis_if #(.N(N), .I(I), .D(D), .U(U)) axis_in;
//--------------------------------------------------------------------
//
function void set_tready(bit value);
axis_in.cb_s.tready <= value;
endfunction: set_tready
//--------------------------------------------------------------------
//
task rx_transaction(axis_tr_class #(.N(N), .I(I), .D(D), .U(U)) tr_h);
repeat(tr_h.delay_h.delay) @(axis_in.cb_s);
axis_in.cb_s.tready <= 1;
@(axis_in.cb_s);
wait(axis_in.cb_s.tvalid);
// @(axis_in.cb_s iff axis_in.cb_s.tvalid);
tr_h.tdata <= axis_in.cb_s.tdata;
tr_h.tstrb <= axis_in.cb_s.tstrb;
tr_h.tkeep <= axis_in.cb_s.tkeep;
tr_h.tlast <= axis_in.cb_s.tlast;
tr_h.tid <= axis_in.cb_s.tid;
tr_h.tdest <= axis_in.cb_s.tdest;
tr_h.tuser <= axis_in.cb_s.tuser;
axis_in.cb_s.tready <= 0;
endtask: rx_transaction
// --------------------------------------------------------------------
//
event rx_frame_done;
virtual task receive(ref Q_T tr_h);
tr_h = new();
void'(tr_h.delay_h.next());
rx_transaction(tr_h);
->rx_frame_done;
endtask: receive
//--------------------------------------------------------------------
//
task init;
set_tready(0);
endtask: init
//--------------------------------------------------------------------
//
function new (virtual axis_if #(.N(N), .I(I), .D(D), .U(U)) axis_in);
this.axis_in = axis_in;
fork
init();
join_none
$display("^^^ %16.t | %m", $time);
endfunction: new
endclass: axis_rx_bfm_class
// --------------------------------------------------------------------
//
endpackage: axis_bfm_pkg
Go to most recent revision | Compare with Previous | Blame | View Log