URL
https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk
Subversion Repositories qaz_libs
[/] [qaz_libs/] [trunk/] [axi4_stream_lib/] [sim/] [tests/] [legacy/] [tb_axis_gear_box/] [tests_pkg.sv] - Rev 50
Compare with Previous | Blame | View Log
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2017 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 tests_pkg;
// --------------------------------------------------------------------
//
import uvm_pkg::*;
`include "uvm_macros.svh"
import axis_pkg::*;
import tb_axis_gear_box_pkg::*;
import tests_base_pkg::*;
// --------------------------------------------------------------------
//
class t_counting extends test_base;
`uvm_component_utils(t_counting)
// --------------------------------------------------------------------
//
function new(string name = "my_test", uvm_component parent);
super.new(name, parent);
endfunction
// --------------------------------------------------------------------
//
virtual function void end_of_elaboration_phase(uvm_phase phase);
uvm_phase run_phase = uvm_run_phase::get();
run_phase.phase_done.set_drain_time(this, 300ns);
endfunction
// --------------------------------------------------------------------
//
virtual task run_phase(uvm_phase phase);
axis_counting_sequence #(dut_cfg.axis_cfg_in) seq_h;
super.run_phase(phase);
phase.raise_objection(this);
fork
repeat(3)
begin
seq_h = axis_counting_sequence #(dut_cfg.axis_cfg_in)::type_id::create("seq_h");
seq_h.start(env_h.agent_h.sequencer);
end
join
phase.drop_objection(this);
endtask : run_phase
// --------------------------------------------------------------------
//
endclass : t_counting
// --------------------------------------------------------------------
//
// --------------------------------------------------------------------
//
class gear_box_sequence #(dut_config_t dut_cfg)
extends uvm_sequence #(axis_sequence_item #(dut_cfg.axis_cfg_in));
`uvm_object_param_utils(gear_box_sequence #(dut_cfg))
rand int length = 7 * 3;
// --------------------------------------------------------------------
//
typedef logic [15:0] packed_data_t[7];
function packed_data_t next_data(int init);
static logic [15:0] previous_value;
logic [13:0] unpacked_data[8];
logic [15:0] packed_data[7];
if(init == 0)
previous_value = 0;
foreach(unpacked_data[i])
begin
unpacked_data[i] = previous_value;
// $display("^^^ %16.t | unpacked_data[%0.d] = %h", $time, i, unpacked_data[i]);
previous_value++;
end
packed_data = {<<16{{<<14{unpacked_data}}}};
// $display("^^^ %16.t | %p", $time, packed_data);
// foreach(packed_data[i])
// $display("^^^ %16.t | packed_data[%0.d] = %h", $time, i, packed_data[i]);
next_data = packed_data;
endfunction
// --------------------------------------------------------------------
//
virtual task body();
localparam CHUNKS = 3;
axis_sequence_item #(dut_cfg.axis_cfg_in) item;
logic [15:0] data[7];
item = axis_sequence_item #(dut_cfg.axis_cfg_in)::type_id::create("axis_sequence_item");
for(int i = 0; i < CHUNKS; i++)
begin
data = next_data(i);
foreach(data[k])
begin
start_item(item);
item.tdata = data[k];
item.tlast = (i == CHUNKS - 1) & (k == 0);
item.tuser = 0;
finish_item(item);
// $display("^^^ %16.t | %d | %x", $time, (i * 7) + k, item.tdata);
end
end
endtask
// --------------------------------------------------------------------
//
function new(string name = "gear_box_sequence");
super.new(name);
endfunction
// --------------------------------------------------------------------
//
endclass : gear_box_sequence
// --------------------------------------------------------------------
//
class t_debug extends test_debug_base;
`uvm_component_utils(t_debug)
// --------------------------------------------------------------------
//
function new(string name = "t_debug", uvm_component parent);
super.new(name, parent);
endfunction
// --------------------------------------------------------------------
//
function void end_of_elaboration_phase(uvm_phase phase);
uvm_phase run_phase = uvm_run_phase::get();
run_phase.phase_done.set_drain_time(this, 300ns);
endfunction
// --------------------------------------------------------------------
//
virtual task run_phase(uvm_phase phase);
gear_box_sequence #(dut_cfg) seq_h;
super.run_phase(phase);
phase.raise_objection(this);
fork
repeat(3)
begin
seq_h = gear_box_sequence #(dut_cfg)::type_id::create("seq_h");
seq_h.start(env_h.agent_h.sequencer);
end
join
phase.drop_objection(this);
endtask : run_phase
// --------------------------------------------------------------------
//
endclass : t_debug
// --------------------------------------------------------------------
//
endpackage: tests_pkg