OpenCores
URL https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk

Subversion Repositories qaz_libs

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 44 to Rev 45
    Reverse comparison

Rev 44 → Rev 45

/qaz_libs/trunk/BFM/sim/tests/tb_axis_video_frame/dut.sv
0,0 → 1,43
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
 
module
dut
#(
N, // data bus width in bytes
I = 1, // TID width
D = 1, // TDEST width
U = 1 // TUSER width
)
(
axis_if axis_in
);
 
//---------------------------------------------------
endmodule
 
/qaz_libs/trunk/BFM/sim/tests/tb_axis_video_frame/init_test.do
0,0 → 1,30
# ------------------------------------
#
# ------------------------------------
 
global env
 
# setup environment
do ../../../../scripts/sim_env.do
set env(SIM_TARGET) fpga
 
radix -hexadecimal
 
make_lib work 1
 
sim_compile_lib $env(LIB_BASE_DIR) tb_packages
sim_compile_lib $env(LIB_BASE_DIR) bfm_packages
sim_compile_lib $env(LIB_BASE_DIR) axi4_lib
sim_compile_lib $env(LIB_BASE_DIR) sim
 
# compile simulation files
vlog -f ./tb_pkg_files.f
vlog -f ./tb_files.f
 
#
# vlog -f ./files.f
 
# run the sim
sim_run_test
 
 
/qaz_libs/trunk/BFM/sim/tests/tb_axis_video_frame/s_debug.svh
0,0 → 1,43
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class s_debug extends s_avf_base;
`uvm_object_utils(s_debug)
 
// --------------------------------------------------------------------
task body();
avf_api_h.put_frame("counting");
avf_api_h.put_frame("constant", 16'habba);
avf_api_h.put_frame("horizontal");
avf_api_h.put_frame("vertical");
avf_api_h.put_frame("random");
 
avf_api_h.send_frame_buffer(m_sequencer, this);
endtask: body
 
// --------------------------------------------------------------------
endclass : s_debug
/qaz_libs/trunk/BFM/sim/tests/tb_axis_video_frame/sim.do
0,0 → 1,10
#
#
 
quit -sim
 
vsim -suppress 12110 -novopt work.tb_top
# vsim -f ./sim.f work.tb_top
 
# log all signals
log /* -r
/qaz_libs/trunk/BFM/sim/tests/tb_axis_video_frame/t_debug.svh
0,0 → 1,68
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class t_debug extends t_top_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, 100ns);
endfunction
 
// --------------------------------------------------------------------
function void final_phase(uvm_phase phase);
super.final_phase(phase);
$display("^^^ %16.t | %m | Test Done!!!", $time);
$stop;
endfunction : final_phase
 
// --------------------------------------------------------------------
virtual task run_phase(uvm_phase phase);
s_debug seq = s_debug::type_id::create("seq");
s_avf_slave_base s_seq = s_avf_slave_base::type_id::create("s_seq");
s_seq.sequencer_h = env_h.s_agent_h.sequencer_h;
fork
s_seq.start(env_h.s_agent_h.sequencer_h);
join_none
seq.init( env_h.cfg_h.m_cfg_h.pixels_per_line
, env_h.cfg_h.m_cfg_h.lines_per_frame
, env_h.cfg_h.m_cfg_h.bits_per_pixel
, env_h.cfg_h.m_cfg_h.pixels_per_clk
);
phase.raise_objection(this);
seq.start(env_h.m_agent_h.sequencer_h);
phase.drop_objection(this);
endtask : run_phase
 
// --------------------------------------------------------------------
endclass : t_debug
/qaz_libs/trunk/BFM/sim/tests/tb_axis_video_frame/t_top_base.svh
0,0 → 1,43
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
virtual class t_top_base extends uvm_test;
`uvm_component_utils(t_top_base);
tb_env env_h;
 
// --------------------------------------------------------------------
function new (string name, uvm_component parent);
super.new(name,parent);
endfunction : new
 
// --------------------------------------------------------------------
function void build_phase(uvm_phase phase);
env_h = tb_env::type_id::create("env_h",this);
endfunction : build_phase
 
// --------------------------------------------------------------------
endclass : t_top_base
/qaz_libs/trunk/BFM/sim/tests/tb_axis_video_frame/tb_axis_video_frame_pkg.sv
0,0 → 1,49
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 tb_axis_video_frame_pkg;
import uvm_pkg::*;
`include "uvm_macros.svh"
import avf_pkg::*;
 
// --------------------------------------------------------------------
localparam AVF_B = 2; // BYTES_PER_PIXEL
localparam AVF_T = 4; // pixels per clock
localparam AVF_AW = 32; // active width
localparam AVF_AH = 16; // active height
localparam AVF_N = AVF_B * AVF_T;
localparam AVF_U = 3;
 
// --------------------------------------------------------------------
`include "tb_dut_config.svh"
`include "tb_env.svh"
`include "s_debug.svh"
`include "t_top_base.svh"
`include "t_debug.svh"
 
// --------------------------------------------------------------------
endpackage : tb_axis_video_frame_pkg
/qaz_libs/trunk/BFM/sim/tests/tb_axis_video_frame/tb_dut_config.svh
0,0 → 1,58
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class tb_dut_config #(N, U);
 
avf_config #(N, U) m_cfg_h; // master
avf_config #(N, U) s_cfg_h; // slave
 
// --------------------------------------------------------------------
//
function void init
( int pixels_per_line
, int lines_per_frame
, int bits_per_pixel
);
m_cfg_h.init( pixels_per_line
, lines_per_frame
, bits_per_pixel
);
s_cfg_h.init( pixels_per_line
, lines_per_frame
, bits_per_pixel
);
endfunction: init
 
 
// --------------------------------------------------------------------
function new(virtual axis_if #(.N(N), .U(U)) vif);
m_cfg_h = new(vif, UVM_ACTIVE);
s_cfg_h = new(vif, UVM_ACTIVE);
endfunction : new
 
// --------------------------------------------------------------------
endclass : tb_dut_config
/qaz_libs/trunk/BFM/sim/tests/tb_axis_video_frame/tb_env.svh
0,0 → 1,65
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class tb_env extends uvm_env;
`uvm_component_utils(tb_env);
 
// --------------------------------------------------------------------
tb_dut_config #(AVF_N, AVF_U) cfg_h;
// coverage coverage_h;
avf_scoreboard scoreboard_h;
avf_master_agent #(AVF_N, AVF_U) m_agent_h;
avf_slave_agent #(AVF_N, AVF_U) s_agent_h;
 
// --------------------------------------------------------------------
function new (string name, uvm_component parent);
super.new(name,parent);
endfunction : new
 
// --------------------------------------------------------------------
function void build_phase(uvm_phase phase);
if (!uvm_config_db #(tb_dut_config #(AVF_N, AVF_U))::get(this, "", "tb_dut_config", cfg_h))
`uvm_fatal(get_name(), "Couldn't get config object!")
 
m_agent_h = avf_master_agent #(AVF_N, AVF_U)::type_id::create("m_agent_h", this);
m_agent_h.cfg_h = cfg_h.m_cfg_h;
m_agent_h.is_active = cfg_h.m_cfg_h.get_is_active();
 
s_agent_h = avf_slave_agent #(AVF_N, AVF_U)::type_id::create("s_agent_h", this);
s_agent_h.cfg_h = cfg_h.s_cfg_h;
s_agent_h.is_active = cfg_h.s_cfg_h.get_is_active();
 
scoreboard_h = avf_scoreboard::type_id::create("scoreboard_h", this);
endfunction : build_phase
 
// --------------------------------------------------------------------
function void connect_phase(uvm_phase phase);
s_agent_h.monitor_h.ap.connect(scoreboard_h.analysis_export);
endfunction : connect_phase
 
// --------------------------------------------------------------------
endclass : tb_env
/qaz_libs/trunk/BFM/sim/tests/tb_axis_video_frame/tb_files.f
0,0 → 1,6
#
 
./tb_axis_video_frame_pkg.sv
 
./dut.sv
./tb_top.sv
/qaz_libs/trunk/BFM/sim/tests/tb_axis_video_frame/tb_pkg_files.f
0,0 → 1,4
#
 
# +incdir+${LIB_BASE_DIR}/BFM/src/axis_video_frame
${LIB_BASE_DIR}/BFM/src/axis_video_frame/avf_pkg.sv
/qaz_libs/trunk/BFM/sim/tests/tb_axis_video_frame/tb_top.sv
0,0 → 1,69
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
module tb_top;
import uvm_pkg::*;
import tb_axis_video_frame_pkg::*;
`include "uvm_macros.svh"
 
// --------------------------------------------------------------------
wire clk_100mhz;
wire tb_clk = clk_100mhz;
wire tb_rst;
 
tb_base #(.PERIOD(10_000)) tb(clk_100mhz, tb_rst);
 
// --------------------------------------------------------------------
wire clk = clk_100mhz;
wire reset = tb_rst;
wire aclk = clk;
wire aresetn = ~reset;
 
// --------------------------------------------------------------------
axis_if #(.N(AVF_N), .U(AVF_U)) dut_if(.*);
 
// --------------------------------------------------------------------
dut #(.N(AVF_N), .U(AVF_U)) dut(dut_if);
 
// --------------------------------------------------------------------
bind dut axis_checker #(.N(N), .U(U)) dut_b(.*);
 
// --------------------------------------------------------------------
tb_dut_config #(AVF_N, AVF_U) cfg_h = new(dut_if);
 
initial
begin
cfg_h.init( .pixels_per_line(AVF_AW)
, .lines_per_frame(AVF_AH)
, .bits_per_pixel(AVF_B * 8)
);
uvm_config_db #(tb_dut_config #(AVF_N, AVF_U))::set(null, "*", "tb_dut_config", cfg_h);
run_test("t_debug");
end
 
// --------------------------------------------------------------------
endmodule
/qaz_libs/trunk/BFM/sim/tests/tb_axis_video_frame/wip.do
0,0 → 1,6
#
 
# compile test bench files
vlog -f ./tb_files.f
# vlog -f ./files.f
 
/qaz_libs/trunk/BFM/sim/tests/tb_video_frame_dpi/count.raw Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream
/qaz_libs/trunk/BFM/sim/tests/tb_video_frame_dpi/py_dpi.c
90,7 → 90,6
 
char pre_string[] = "exec(open('./";
char post_string[] = "').read())";
char v_filename[] = "try_it.py";
unsigned int size = (sizeof(pre_string) + sizeof(post_string)) * sizeof(char);
size += strlen(filename);
char *run_string = (char *)malloc(size);
/qaz_libs/trunk/BFM/sim/tests/tb_video_frame_dpi/view_raw.py
0,0 → 1,42
#
 
import os
import numpy as np
import matplotlib.pyplot as plt
 
fname = 'count.raw'
number_of_frames = 4
width = 32
height = 32
# dtype='uint16'
dtype=np.dtype('uint16')
 
data = np.arange(number_of_frames*width*height, dtype=dtype)
# data = np.ones((number_of_frames, width, height), dtype=dtype)
# data = np.zeros((number_of_frames, width, height), dtype=dtype)
# data *= 32
 
with open(fname, 'w+') as infile:
data.tofile(infile, format=dtype.str)
 
infile.close()
 
statinfo = os.stat(fname)
print(statinfo.st_size, ': file size')
print(statinfo.st_size / (width * height * dtype.itemsize), ': frames')
print(dtype.itemsize, ': itemsize')
 
 
# with open(fname, 'r') as infile:
# data = np.fromfile(infile, dtype=dtype).reshape(number_of_frames, width, height)
data = np.memmap(fname, dtype=dtype, mode='r', shape=(number_of_frames, width, height))
 
for i in range(number_of_frames):
print('Frame #', i)
fig, ax = plt.subplots()
im = ax.imshow(data[i], cmap='gray')
ax.set(xticks=[], yticks=[])
fig.colorbar(im)
plt.show()
 
/qaz_libs/trunk/BFM/src/axis_video_frame/avf_config.svh
0,0 → 1,73
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class avf_config #(N, U);
 
virtual axis_if #(.N(N), .U(U)) vif;
protected uvm_active_passive_enum is_active; // UVM_ACTIVE or UVM_PASSIVE
int pixels_per_line;
int lines_per_frame;
int bits_per_pixel;
int bytes_per_pixel;
int pixels_per_clk;
string name;
 
// --------------------------------------------------------------------
function void init
( int pixels_per_line
, int lines_per_frame
, int bits_per_pixel
, string name = ""
);
this.pixels_per_line = pixels_per_line;
this.lines_per_frame = lines_per_frame;
this.bits_per_pixel = bits_per_pixel;
this.name = name;
this.bytes_per_pixel = (bits_per_pixel % 8 == 0)
? (bits_per_pixel / 8)
: (bits_per_pixel / 8) + 1;
assert(N % bytes_per_pixel == 0) else
`uvm_fatal("avf_config", "N % bytes_per_pixel != 0")
this.pixels_per_clk = N / bytes_per_pixel;
endfunction: init
 
// --------------------------------------------------------------------
function new
( virtual axis_if #(.N(N), .U(U)) vif
, uvm_active_passive_enum is_active = UVM_ACTIVE
);
this.vif = vif;
this.is_active = is_active;
endfunction : new
 
// --------------------------------------------------------------------
function uvm_active_passive_enum get_is_active();
return is_active;
endfunction : get_is_active
 
// --------------------------------------------------------------------
endclass : avf_config
/qaz_libs/trunk/BFM/src/axis_video_frame/avf_master_agent.svh
0,0 → 1,67
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class avf_master_agent #(N, U)
extends uvm_agent;
`uvm_component_param_utils(avf_master_agent #(N, U))
 
// --------------------------------------------------------------------
avf_config #(N, U) cfg_h;
avf_master_sequencer sequencer_h;
avf_master_driver #(N, U) driver_h;
avf_monitor #(N, U) monitor_h;
 
// --------------------------------------------------------------------
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
if(is_active == UVM_ACTIVE)
begin
driver_h = avf_master_driver #(N, U)::type_id::create("driver_h", this);
sequencer_h = avf_master_sequencer::type_id::create("sequencer_h", this);
end
monitor_h = avf_monitor #(N, U)::type_id::create("monitor_h", this);
endfunction
 
// --------------------------------------------------------------------
virtual function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
if(is_active == UVM_ACTIVE)
begin
driver_h.vif = cfg_h.vif;
driver_h.seq_item_port.connect(sequencer_h.seq_item_export);
end
monitor_h.vif = cfg_h.vif;
monitor_h.cfg_h = cfg_h;
endfunction
 
// --------------------------------------------------------------------
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
 
// --------------------------------------------------------------------
endclass : avf_master_agent
/qaz_libs/trunk/BFM/src/axis_video_frame/avf_master_driver.svh
0,0 → 1,124
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class avf_master_driver #(N, U)
extends uvm_driver #(avf_sequence_item);
`uvm_component_param_utils(avf_master_driver #(N, U))
 
// --------------------------------------------------------------------
virtual axis_if #(.N(N), .U(U)) vif;
video_frame_class f_h;
 
//--------------------------------------------------------------------
function void set_default;
vif.cb_m.tvalid <= 0;
vif.cb_m.tdata <= 'x;
vif.cb_m.tstrb <= {N{1'b1}};
vif.cb_m.tkeep <= {N{1'b1}};
vif.cb_m.tlast <= 'x;
vif.cb_m.tid <= 0;
vif.cb_m.tdest <= 0;
vif.cb_m.tuser <= 'x;
endfunction: set_default
 
//--------------------------------------------------------------------
virtual task run_phase(uvm_phase phase);
avf_sequence_item item;
logic [(8*N)-1:0] tdata;
int offset;
 
super.run_phase(phase);
 
set_default();
 
forever
begin
wait(vif.aresetn);
seq_item_port.get_next_item(item);
 
while(item.frame_buffer.try_get(f_h))
begin
vif.zero_cycle_delay();
repeat(item.delay_h.get(item.sof_delay))
@(vif.cb_m);
vif.cb_m.tvalid <= 1;
 
foreach(f_h.lines[l])
for(int p = 0; p < f_h.pixels_per_line; p += f_h.pixels_per_clk)
begin
if(l == 0 && p == 0)
vif.cb_m.tuser[0] <= 1;
else
vif.cb_m.tuser[0] <= 0;
 
if(p == 0)
vif.cb_m.tuser[1] <= 1;
else
vif.cb_m.tuser[1] <= 0;
 
if(p + f_h.pixels_per_clk >= f_h.pixels_per_line && l + 1 >= f_h.lines_per_frame)
vif.cb_m.tuser[2] <= 1;
else
vif.cb_m.tuser[2] <= 0;
 
if(p + f_h.pixels_per_clk >= f_h.pixels_per_line)
vif.cb_m.tlast <= 1;
else
vif.cb_m.tlast <= 0;
 
for(int i = 0; i < f_h.pixels_per_clk; i++)
begin
offset = i * f_h.bytes_per_pixel * 8;
for(int k = 0; k < f_h.bytes_per_pixel; k++)
tdata[offset + (k * 8) +: 8] = f_h.lines[l].pixel[p + i][k * 8 +: 8];
end
 
vif.cb_m.tdata <= tdata;
@(vif.cb_m iff vif.cb_m.tready);
 
vif.cb_m.tvalid <= 0;
repeat(item.get_delay(vif.cb_s.tlast, vif.cb_s.tuser[2]))
@(vif.cb_m);
vif.cb_m.tvalid <= 1;
end
 
vif.cb_m.tuser[2] <= 0;
vif.cb_m.tlast <= 0;
vif.cb_m.tvalid <= 0;
end
 
seq_item_port.item_done();
end
endtask : run_phase
 
//--------------------------------------------------------------------
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
 
// --------------------------------------------------------------------
endclass : avf_master_driver
/qaz_libs/trunk/BFM/src/axis_video_frame/avf_monitor.svh
0,0 → 1,109
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class avf_monitor #(N, U) extends uvm_component;
`uvm_component_param_utils(avf_monitor #(N, U));
 
virtual axis_if #(.N(N), .U(U)) vif;
avf_config #(N, U) cfg_h;
uvm_analysis_port #(avf_sequence_item) ap;
uvm_analysis_port #(avf_sequence_item) req;
 
// --------------------------------------------------------------------
function new (string name, uvm_component parent);
super.new(name,parent);
endfunction
 
// --------------------------------------------------------------------
function void build_phase(uvm_phase phase);
ap = new("ap", this);
req = new("req", this);
endfunction : build_phase
 
// --------------------------------------------------------------------
task run_phase(uvm_phase phase);
avf_sequence_item req_item;
avf_sequence_item ap_item;
bit sof_received = 0;
int l, p;
int offset;
 
forever @(vif.cb_m iff vif.cb_m.aresetn === 1)
begin
if(vif.cb_s.tvalid & ~vif.cb_m.tready)
begin
req_item = avf_sequence_item::type_id::create("req_item");
req_item.kind = AVF_REQUEST;
req.write(req_item);
end
 
if(vif.cb_s.tvalid & vif.cb_m.tready)
begin
if(vif.cb_s.tuser[0]) // SOF
begin
ap_item = avf_sequence_item::type_id::create("ap_item");
ap_item.kind = AVF_TRANSACTION;
ap_item.f_h = new();
ap_item.f_h.init( cfg_h.pixels_per_line
, cfg_h.lines_per_frame
, cfg_h.bits_per_pixel
, cfg_h.pixels_per_clk
, cfg_h.name
);
sof_received = 1;
p = 0;
l = 0;
end
 
if(sof_received)
begin
 
for(int i = 0; i < ap_item.f_h.pixels_per_clk; i++, p++)
begin
offset = i * ap_item.f_h.bytes_per_pixel * 8;
for(int k = 0; k < ap_item.f_h.bytes_per_pixel; k++)
ap_item.f_h.lines[l].pixel[p][k * 8 +: 8] = vif.cb_s.tdata[offset + (k * 8) +: 8];
end
 
if(p >= ap_item.f_h.pixels_per_line)
begin
p = 0;
l++;
end
 
if(vif.cb_s.tuser[2]) // EOF
begin
ap.write(ap_item);
sof_received = 0;
end
end
end
end
endtask : run_phase
 
// --------------------------------------------------------------------
endclass : avf_monitor
/qaz_libs/trunk/BFM/src/axis_video_frame/avf_pkg.sv
0,0 → 1,56
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 avf_pkg;
import uvm_pkg::*;
`include "uvm_macros.svh"
import tb_pkg::*;
import video_frame_pkg::*;
 
// --------------------------------------------------------------------
`include "avf_config.svh"
`include "avf_sequence_item.svh"
`include "avf_monitor.svh"
`include "avf_scoreboard.svh"
 
// --------------------------------------------------------------------
typedef uvm_sequencer #(avf_sequence_item) avf_master_sequencer;
`include "avf_master_driver.svh"
`include "avf_master_agent.svh"
 
// --------------------------------------------------------------------
`include "avf_slave_sequencer.svh"
`include "avf_slave_driver.svh"
`include "avf_slave_agent.svh"
`include "s_avf_slave_base.svh"
 
// --------------------------------------------------------------------
`include "s_avf_api.svh"
`include "s_avf_base.svh"
 
// --------------------------------------------------------------------
endpackage : avf_pkg
/qaz_libs/trunk/BFM/src/axis_video_frame/avf_scoreboard.svh
0,0 → 1,88
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class avf_scoreboard extends uvm_subscriber #(avf_sequence_item);
`uvm_component_utils(avf_scoreboard);
 
// --------------------------------------------------------------------
function new (string name, uvm_component parent);
super.new(name, parent);
endfunction : new
 
// --------------------------------------------------------------------
function void build_phase(uvm_phase phase);
endfunction : build_phase
 
// // --------------------------------------------------------------------
// mailbox #(avf_sequence_item) mb = new();
// avf_sequence_item c_t;
// avf_sequence_item item;
// int m_matches = 0;
// int m_mismatches = 0;
 
// function void write(avf_sequence_item t);
 
// $cast(c_t, t.clone);
 
// if((c_t.command = FIFO_WR) || (c_t.command = FIFO_BOTH))
// mb.try_put(c_t);
 
// if((c_t.command = FIFO_RD) || (c_t.command = FIFO_BOTH))
// mb.try_get(item);
 
// if(~c_t.compare(item))
// begin
// uvm_report_info(get_name(), $sformatf("^^^ %16.t | %m | MISMATCH!!! | %s", $time, {20{"-"}}));
// uvm_report_info(get_name(), c_t.convert2string);
// uvm_report_info(get_name(), item.convert2string);
// m_mismatches++;
// end
// else
// m_matches++;
// endfunction : write
 
// --------------------------------------------------------------------
//
function void print_video_frame(ref video_frame_class f_h);
string s;
f_h.print_config();
$display(f_h.convert2string());
endfunction : print_video_frame
 
// --------------------------------------------------------------------
function void write(avf_sequence_item t);
print_video_frame(t.f_h);
endfunction : write
 
// --------------------------------------------------------------------
function void report_phase(uvm_phase phase);
// uvm_report_info(get_name(), $sformatf("Matches : %0d", m_matches));
// uvm_report_info(get_name(), $sformatf("Mismatches: %0d", m_mismatches));
endfunction
 
// --------------------------------------------------------------------
endclass : avf_scoreboard
/qaz_libs/trunk/BFM/src/axis_video_frame/avf_sequence_item.svh
0,0 → 1,120
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
// --------------------------------------------------------------------
typedef enum {AVF_REQUEST, AVF_TRANSACTION} avf_sequence_item_t;
 
// --------------------------------------------------------------------
class avf_sequence_item
extends uvm_sequence_item;
`uvm_object_utils(avf_sequence_item)
 
// --------------------------------------------------------------------
avf_sequence_item_t kind = AVF_TRANSACTION;
video_frame_class f_h;
mailbox #(video_frame_class) frame_buffer;
random_delay delay_h;
random_delay_type_e sof_delay = REGULAR;
random_delay_type_e eol_delay = REGULAR;
random_delay_type_e eof_delay = REGULAR;
random_delay_type_e pixel_delay = SPORADIC;
random_delay_type_e slave_delay = REGULAR;
 
// --------------------------------------------------------------------
function int unsigned get_delay(bit eol, bit eof);
if(eof)
return(delay_h.get(eof_delay));
else if(eol)
return(delay_h.get(eol_delay));
else
return(delay_h.get(pixel_delay));
endfunction : get_delay
 
// --------------------------------------------------------------------
function new(string name = "");
super.new(name);
delay_h = new();
endfunction : new
 
// // --------------------------------------------------------------------
// function bit do_compare(uvm_object rhs, uvm_comparer comparer);
// avf_sequence_item tested;
// bit same;
 
// if (rhs==null)
// `uvm_fatal(get_type_name(), "| %m | comparison to a null pointer");
 
// if (!$cast(tested,rhs))
// same = 0;
// else
// same = super.do_compare(rhs, comparer);
 
// return same;
// endfunction : do_compare
 
// // --------------------------------------------------------------------
// function void do_copy(uvm_object rhs);
// avf_sequence_item item;
// assert(rhs != null) else
// `uvm_fatal(get_type_name(), "| %m | copy null transaction");
// super.do_copy(rhs);
// assert($cast(item,rhs)) else
// `uvm_fatal(get_type_name(), "| %m | failed cast");
// delay = item.delay;
// command = item.command;
// wr_full = item.wr_full;
// rd_empty = item.rd_empty;
// wr_data = item.wr_data;
// rd_data = item.rd_data;
// count = item.count;
// endfunction : do_copy
 
// // --------------------------------------------------------------------
// function string convert2string();
// string s0, s1, s2, s3;
// s0 = $sformatf( "| %m | wr | rd | full | empty |\n");
// s1 = $sformatf( "| %m | %1h | %1h | %1h | %1h |\n"
// , (command == FIFO_WR) || (command == FIFO_BOTH)
// , (command == FIFO_RD) || (command == FIFO_BOTH)
// , wr_full
// , rd_empty
// );
// s2 = $sformatf("| %m | wr_data: %h\n" , wr_data);
// s3 = $sformatf("| %m | rd_data: %h\n" , rd_data);
 
// if(command == FIFO_NULL)
// return {s1, s0};
// else if(command == FIFO_BOTH)
// return {s3, s2, s1, s0};
// else if(command == FIFO_WR)
// return {s2, s1, s0};
// else if(command == FIFO_RD)
// return {s3, s1, s0};
// endfunction : convert2string
 
// --------------------------------------------------------------------
endclass : avf_sequence_item
/qaz_libs/trunk/BFM/src/axis_video_frame/avf_slave_agent.svh
0,0 → 1,68
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class avf_slave_agent #(N, U)
extends uvm_agent;
`uvm_component_param_utils(avf_slave_agent #(N, U))
 
// --------------------------------------------------------------------
avf_config #(N, U) cfg_h;
avf_slave_sequencer sequencer_h;
avf_slave_driver #(N, U) driver_h;
avf_monitor #(N, U) monitor_h;
 
// --------------------------------------------------------------------
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
if(is_active == UVM_ACTIVE)
begin
driver_h = avf_slave_driver #(N, U)::type_id::create("driver_h", this);
sequencer_h = avf_slave_sequencer::type_id::create("sequencer_h", this);
end
monitor_h = avf_monitor #(N, U)::type_id::create("monitor_h", this);
endfunction
 
// --------------------------------------------------------------------
virtual function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
if(is_active == UVM_ACTIVE)
begin
driver_h.vif = cfg_h.vif;
driver_h.seq_item_port.connect(sequencer_h.seq_item_export);
monitor_h.req.connect(sequencer_h.m_request_export);
end
monitor_h.vif = cfg_h.vif;
monitor_h.cfg_h = cfg_h;
endfunction
 
// --------------------------------------------------------------------
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
 
// --------------------------------------------------------------------
endclass : avf_slave_agent
/qaz_libs/trunk/BFM/src/axis_video_frame/avf_slave_driver.svh
0,0 → 1,72
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class avf_slave_driver #(N, U)
extends uvm_driver #(avf_sequence_item);
`uvm_component_param_utils(avf_slave_driver #(N, U))
 
// --------------------------------------------------------------------
virtual axis_if #(.N(N), .U(U)) vif;
 
//--------------------------------------------------------------------
function void set_default;
vif.cb_s.tready <= 0;
endfunction: set_default
 
//--------------------------------------------------------------------
virtual task run_phase(uvm_phase phase);
avf_sequence_item item;
super.run_phase(phase);
 
set_default();
 
forever
begin
wait(vif.aresetn);
seq_item_port.get_next_item(item);
vif.zero_cycle_delay();
 
repeat(item.delay_h.get(item.slave_delay))
@(vif.cb_m);
 
vif.cb_s.tready <= 1;
 
repeat(item.delay_h.get(item.slave_delay))
@(vif.cb_m);
 
vif.cb_s.tready <= 0;
seq_item_port.item_done();
end
endtask : run_phase
 
//--------------------------------------------------------------------
function new(string name, uvm_component parent);
super.new(name, parent);
endfunction
 
// --------------------------------------------------------------------
endclass : avf_slave_driver
/qaz_libs/trunk/BFM/src/axis_video_frame/avf_slave_sequencer.svh
0,0 → 1,48
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class avf_slave_sequencer extends uvm_sequencer #(avf_sequence_item);
`uvm_component_utils(avf_slave_sequencer)
 
uvm_analysis_export #(avf_sequence_item) m_request_export;
uvm_tlm_analysis_fifo #(avf_sequence_item) m_request_fifo;
 
// --------------------------------------------------------------------
function new(string name, uvm_component parent);
super.new(name, parent);
m_request_fifo = new("m_request_fifo", this);
m_request_export = new("m_request_export", this);
endfunction
 
// --------------------------------------------------------------------
function void connect_phase(uvm_phase phase);
super.connect_phase(phase);
m_request_export.connect(m_request_fifo.analysis_export);
endfunction
 
// --------------------------------------------------------------------
endclass
/qaz_libs/trunk/BFM/src/axis_video_frame/legacy/avf_agent.sv
0,0 → 1,105
//////////////////////////////////////////////////////////////////////
//// ////
//// 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
 
import axis_video_frame_bfm_pkg::*;
 
module
avf_agent
#(
BYTES_PER_PIXEL = 2,
AVF_OUTPUTS = 4,
AVF_TILES = 1,
AVF_WIDTH = 32,
AVF_HEIGHT = 16,
AVF_BITS_PER_PIXEL = 16
)
(
axis_if axis_out[AVF_TILES],
axis_if axis_in[AVF_TILES]
);
 
// --------------------------------------------------------------------
//
axis_video_frame_bfm_class #(BYTES_PER_PIXEL, AVF_OUTPUTS) f_tx_h[AVF_TILES];
 
for(genvar j = 0; j < AVF_TILES; j++)
initial
begin
f_tx_h[j] = new(axis_out[j]);
 
f_tx_h[j].init
(
.avf_width(AVF_WIDTH),
.avf_height(AVF_HEIGHT),
.avf_bits_per_pixel(AVF_BITS_PER_PIXEL),
.avf_name($psprintf("AVF_%0d", j)),
.avf_type("TX")
);
end
 
 
// --------------------------------------------------------------------
//
axis_video_frame_bfm_class #(BYTES_PER_PIXEL, AVF_OUTPUTS) f_rx_h[AVF_TILES];
 
for(genvar j = 0; j < AVF_TILES; j++)
initial
begin
f_rx_h[j] = new(axis_in[j]);
 
f_rx_h[j].init
(
.avf_width(AVF_WIDTH),
.avf_height(AVF_HEIGHT),
.avf_bits_per_pixel(AVF_BITS_PER_PIXEL),
.avf_name($psprintf("AVF_%0d", j)),
.avf_type("RX")
);
end
 
 
// --------------------------------------------------------------------
//
avf_tx #(BYTES_PER_PIXEL, AVF_OUTPUTS, AVF_TILES)
avf_tx_bfm(.*);
 
 
// --------------------------------------------------------------------
//
avf_rx #(BYTES_PER_PIXEL, AVF_OUTPUTS, AVF_TILES)
avf_rx_bfm(.*);
 
 
// --------------------------------------------------------------------
//
 
endmodule
 
 
 
 
/qaz_libs/trunk/BFM/src/axis_video_frame/legacy/avf_agent_class_pkg.sv
0,0 → 1,166
//////////////////////////////////////////////////////////////////////
//// ////
//// 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 avf_agent_class_pkg;
 
// --------------------------------------------------------------------
//
import video_frame_pkg::*;
import axis_video_frame_bfm_pkg::*;
 
 
// --------------------------------------------------------------------
//
class avf_agent_class #(BYTES_PER_PIXEL, OUTPUTS_PER_TILE = 1, AVF_U = 3);
 
localparam AVF_N = BYTES_PER_PIXEL * OUTPUTS_PER_TILE; // data bus width in bytes
localparam AVF_B = BYTES_PER_PIXEL * 8; // bits per pixel on TDATA
 
virtual axis_if #(.N(AVF_N), .U(AVF_U)) avf_axis_in_if[];
virtual axis_if #(.N(AVF_N), .U(AVF_U)) avf_axis_out_if[];
 
avf_config_class c_h;
 
avf_tx_class #(BYTES_PER_PIXEL, OUTPUTS_PER_TILE, AVF_U) tx_h;
avf_rx_class #(BYTES_PER_PIXEL, OUTPUTS_PER_TILE, AVF_U) rx_h;
 
video_frame_class clone_h;
video_frame_class sent_f_h;
video_frame_class rx_f_h;
 
mailbox #(video_frame_class) q[];
 
 
// --------------------------------------------------------------------
//
virtual task
queue_frame
(
string pattern = "",
int pixel = 0
);
 
if(pattern != "")
tx_h.make_frame(pattern, pixel);
 
foreach(tx_h.tx_bfm_h[i])
begin
clone_h = tx_h.tx_bfm_h[i].f_h.clone();
tx_h.tx_bfm_h[i].put(clone_h);
q[i].put(clone_h);
end
 
$display("^^^ %16.t | %m | using %s pattern", $time, pattern);
 
endtask: queue_frame
 
 
// --------------------------------------------------------------------
//
virtual task automatic
compare_frame;
 
int mismatch_count;
 
$display("^^^ %16.t | %m", $time);
 
foreach(rx_h.rx_bfm_h[i])
begin
q[i].get(sent_f_h);
rx_h.rx_bfm_h[i].get(rx_f_h);
mismatch_count = sent_f_h.compare(8, rx_f_h);
end
 
endtask: compare_frame
 
 
// --------------------------------------------------------------------
//
virtual task set_tready(input tready);
$display("^^^ %16.t | %m", $time);
foreach(rx_h.rx_bfm_h[i])
rx_h.rx_bfm_h[i].set_tready(tready);
endtask: set_tready
 
 
// --------------------------------------------------------------------
//
virtual task flush_sent_frame;
$display("^^^ %16.t | %m", $time);
foreach(rx_h.rx_bfm_h[i])
q[i].get(sent_f_h);
endtask: flush_sent_frame
 
 
// --------------------------------------------------------------------
//
virtual task rx_flush_frame;
$display("^^^ %16.t | %m", $time);
foreach(rx_h.rx_bfm_h[i])
rx_h.rx_bfm_h[i].get(rx_f_h);
endtask: rx_flush_frame
 
 
//--------------------------------------------------------------------
//
function void init(avf_config_class c_h);
 
rx_h = new(c_h, avf_axis_in_if);
tx_h = new(c_h, avf_axis_out_if);
 
this.q = new[$size(avf_axis_out_if)];
foreach(q[i])
this.q[i] = new();
 
endfunction: init
 
 
//--------------------------------------------------------------------
//
function new
(
virtual axis_if #(.N(AVF_N), .U(AVF_U)) avf_axis_in_if[],
virtual axis_if #(.N(AVF_N), .U(AVF_U)) avf_axis_out_if[]
);
 
this.avf_axis_in_if = avf_axis_in_if;
this.avf_axis_out_if = avf_axis_out_if;
endfunction: new
 
 
// --------------------------------------------------------------------
//
 
endclass: avf_agent_class
 
endpackage: avf_agent_class_pkg
 
 
 
 
 
/qaz_libs/trunk/BFM/src/axis_video_frame/legacy/avf_rx.sv
0,0 → 1,134
//////////////////////////////////////////////////////////////////////
//// ////
//// 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
import axis_video_frame_bfm_pkg::*;
 
module
avf_rx
#(
BYTES_PER_PIXEL = 2,
AVF_OUTPUTS = 4,
AVF_TILES = 1
)
(
ref axis_video_frame_bfm_class f_tx_h[AVF_TILES],
ref axis_video_frame_bfm_class f_rx_h[AVF_TILES]
);
 
// --------------------------------------------------------------------
//
localparam AVF_VERTICAL_BLANKING = 20;
 
task automatic
init_avf_rx;
 
f_rx_h[0].run_rx_q(RIGHT_DOWN);
f_rx_h[1].run_rx_q(RIGHT_UP);
f_rx_h[2].run_rx_q(LEFT_DOWN);
f_rx_h[3].run_rx_q(LEFT_UP);
 
endtask: init_avf_rx
 
 
// --------------------------------------------------------------------
//
task
wait_for_rx_frames
(
input int unsigned count
);
 
repeat(count)
@(f_rx_h[0].rx_frame_done);
 
endtask: wait_for_rx_frames
 
 
// --------------------------------------------------------------------
//
semaphore get_frame_semaphore = new(1);
logic get_frame_active = 0;
 
task automatic
get_frame;
 
if(get_frame_semaphore.try_get() == 0)
begin
$display("^^^ %16.t | %m | ERROR! Already getting a frame.", $time);
return;
end
 
$display("^^^ %16.t | %m | getting a frame.", $time);
get_frame_active = 1;
 
fork
begin
 
f_rx_h[0].avf_fork_rx(RIGHT_DOWN);
f_rx_h[1].avf_fork_rx(RIGHT_UP);
f_rx_h[2].avf_fork_rx(LEFT_DOWN);
f_rx_h[3].avf_fork_rx(LEFT_UP);
 
wait fork;
get_frame_active = 0;
$display("^^^ %16.t | %m | Got a frame.", $time);
get_frame_semaphore.put();
 
end
join_none
 
 
endtask: get_frame
 
 
// --------------------------------------------------------------------
//
import video_frame_pkg::*;
 
function automatic
int compare_frame;
 
int mismatch_count[AVF_TILES];
 
$display("^^^ %16.t | %m", $time);
 
foreach(f_rx_h[i])
mismatch_count[i] = f_rx_h[i].f_h.compare(8, f_tx_h[i].f_h);
 
 
endfunction: compare_frame
 
 
// --------------------------------------------------------------------
//
 
 
endmodule
 
 
 
 
/qaz_libs/trunk/BFM/src/axis_video_frame/legacy/avf_tx.sv
0,0 → 1,171
//////////////////////////////////////////////////////////////////////
//// ////
//// 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
 
import axis_video_frame_bfm_pkg::*;
 
module
avf_tx
#(
BYTES_PER_PIXEL = 2,
AVF_OUTPUTS = 4,
AVF_TILES = 1
)
(
ref axis_video_frame_bfm_class f_tx_h[AVF_TILES],
ref axis_video_frame_bfm_class f_rx_h[AVF_TILES]
);
 
// --------------------------------------------------------------------
//
localparam AVF_VERTICAL_BLANKING = 20;
 
task automatic
init_avf_tx;
 
foreach(f_tx_h[i])
f_tx_h[i].avf_vertical_blanking = AVF_VERTICAL_BLANKING;
 
f_tx_h[0].run_tx_q(RIGHT_DOWN, 0);
f_tx_h[1].run_tx_q(RIGHT_UP, 0);
f_tx_h[2].run_tx_q(LEFT_DOWN, 0);
f_tx_h[3].run_tx_q(LEFT_UP, 0);
 
endtask: init_avf_tx
 
 
// --------------------------------------------------------------------
//
import video_frame_pkg::*;
 
video_frame_class clone_h;
 
 
// --------------------------------------------------------------------
//
task automatic
make_frame
(
string pattern,
int pixel = 0
);
 
case(pattern.tolower)
"constant": foreach(f_tx_h[i]) f_tx_h[i].f_h.make_constant(pixel);
"counting": foreach(f_tx_h[i]) f_tx_h[i].f_h.make_counting();
"horizontal": foreach(f_tx_h[i]) f_tx_h[i].f_h.make_horizontal();
"vertical": foreach(f_tx_h[i]) f_tx_h[i].f_h.make_vertical();
"random": foreach(f_tx_h[i]) f_tx_h[i].f_h.make_random();
default: $display("^^^ %16.t | %m | ERROR! %s pattern not supported", $time, pattern);
endcase
 
endtask: make_frame
 
 
// --------------------------------------------------------------------
//
 
task automatic
queue_frame
(
string pattern = ""
);
 
if(pattern != "")
make_frame(pattern);
 
foreach(f_tx_h[i])
begin
clone_h = f_tx_h[i].f_h.clone();
f_tx_h[i].avf_q.put(clone_h);
f_rx_h[i].avf_q.put(clone_h);
end
 
$display("^^^ %16.t | %m | using %s pattern", $time, pattern);
 
endtask: queue_frame
 
 
// --------------------------------------------------------------------
//
task
wait_for_tx_frames
(
input int unsigned count
);
 
repeat(count)
@(f_tx_h[0].tx_frame_done);
 
endtask: wait_for_tx_frames
 
 
// --------------------------------------------------------------------
//
logic put_frame_active = 0;
semaphore put_frame_semaphore = new(1);
 
task automatic
put_frame;
 
if(put_frame_semaphore.try_get() == 0)
begin
$display("^^^ %16.t | %m | ERROR! Already put a frame.", $time);
return;
end
 
$display("^^^ %16.t | %m | Putting a frame.", $time);
put_frame_active = 1;
 
fork
begin
 
f_tx_h[0].avf_fork_tx(RIGHT_DOWN, 0);
f_tx_h[1].avf_fork_tx(RIGHT_UP, 0);
f_tx_h[2].avf_fork_tx(LEFT_DOWN, 0);
f_tx_h[3].avf_fork_tx(LEFT_UP, 0);
 
wait fork;
put_frame_active = 0;
$display("^^^ %16.t | %m | Put a frame.", $time);
put_frame_semaphore.put();
 
end
join_none
 
endtask: put_frame
 
 
// --------------------------------------------------------------------
//
 
 
endmodule
 
 
 
 
/qaz_libs/trunk/BFM/src/axis_video_frame/legacy/axis_video_frame_bfm_pkg.sv
0,0 → 1,617
//////////////////////////////////////////////////////////////////////
//// ////
//// 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_video_frame_bfm_pkg;
 
typedef enum
{
RIGHT_DOWN,
RIGHT_UP,
LEFT_DOWN,
LEFT_UP
} avf_direction_t;
 
typedef struct
{
avf_direction_t direction;
int delay = 0;
} avf_tile_config_t;
 
// --------------------------------------------------------------------
//
import q_pkg::*;
import video_frame_pkg::*;
 
 
// --------------------------------------------------------------------
//
class avf_config_class;
 
int width;
int height;
int bytes_per_pixel;
int bits_per_pixel;
int pixels_per_clk;
string name;
int vertical_blanking;
 
avf_tile_config_t tile[];
 
 
//--------------------------------------------------------------------
function
new
(
int width,
int height,
int bytes_per_pixel,
int bits_per_pixel,
int pixels_per_clk,
string name,
int vertical_blanking,
avf_tile_config_t tile[]
);
 
this.width = width;
this.height = height;
this.bytes_per_pixel = bytes_per_pixel;
this.bits_per_pixel = bits_per_pixel;
this.pixels_per_clk = pixels_per_clk;
this.name = name;
this.vertical_blanking = vertical_blanking;
this.tile = tile;
 
$display("^^^ %16.t | %m", $time);
 
endfunction: new
 
 
// --------------------------------------------------------------------
//
task automatic
avf_direction
(
input avf_direction_t direction,
output frame_coordinate_t inc
);
 
case(direction)
RIGHT_DOWN: inc = '{ 1, 1};
RIGHT_UP: inc = '{ 1, -1};
LEFT_DOWN: inc = '{-1, 1};
LEFT_UP: inc = '{-1, -1};
default: $display("^^^ %16.t | %m | ERROR!!! Incorrect AVF direction.", $time );
endcase
 
endtask: avf_direction
 
 
// --------------------------------------------------------------------
//
task automatic
avf_calculate
(
input avf_direction_t direction,
output frame_coordinate_t start,
output frame_coordinate_t inc,
output int x_end,
output int y_end,
output int x_eol
);
 
case(direction)
RIGHT_DOWN: start = '{0 , 0 };
RIGHT_UP: start = '{0 , height - 1 };
LEFT_DOWN: start = '{width - 1 , 0 };
LEFT_UP: start = '{width - 1 , height - 1 };
default: $display("^^^ %16.t | %m | [%04d, %04d] | ERROR!!! Incorrect AVF direction.", $time, start.x, start.y );
endcase
 
avf_direction(direction, inc);
 
x_end = (start.x + (width * inc.x));
y_end = (start.y + (height * inc.y));
 
inc.x *= pixels_per_clk; // increment stride by number of outputs
x_eol = x_end - inc.x;
 
endtask: avf_calculate
 
endclass: avf_config_class
 
 
//--------------------------------------------------------------------
//
class avf_tx_bfm_class #(BYTES_PER_PIXEL, PIXELS_PER_CLK, AVF_U)
extends blocking_transmission_q_class #(video_frame_class);
 
localparam AVF_N = BYTES_PER_PIXEL * PIXELS_PER_CLK; // data bus width in bytes
localparam AVF_B = BYTES_PER_PIXEL * 8; // bits per pixel on TDATA
 
virtual axis_if #(.N(AVF_N), .U(AVF_U)) avf_axis_if;
 
string avf_name = "";
string avf_type = "";
 
avf_config_class c_h;
avf_tile_config_t tile;
video_frame_class f_h;
 
// --------------------------------------------------------------------
//
function void axis_default;
 
avf_axis_if.cb_m.tvalid <= 0;
avf_axis_if.cb_m.tdata <= 'hx;
avf_axis_if.cb_m.tlast <= 'hx;
avf_axis_if.cb_m.tuser <= 'hx;
 
endfunction: axis_default
 
 
// --------------------------------------------------------------------
//
task automatic
output_pixels(input int l, input int p);
 
for(int i = 0; i < PIXELS_PER_CLK; i++)
avf_axis_if.cb_m.tdata[i*AVF_B +: AVF_B] <= f_h.lines[l].pixel[p + i];
 
endtask: output_pixels
 
 
// --------------------------------------------------------------------
//
task automatic
avf_tx(input avf_direction_t direction, input int unsigned avf_delay);
 
frame_coordinate_t start;
frame_coordinate_t inc;
int x_end;
int y_end;
int x_eol;
int pixel_count = 0;
int l;
int p;
 
c_h.avf_calculate
(
.start(start),
.direction(direction),
.inc(inc),
.x_end(x_end),
.y_end(y_end),
.x_eol(x_eol)
);
 
@(avf_axis_if.cb_m);
 
repeat(avf_delay) @(avf_axis_if.cb_m);
 
avf_axis_if.cb_m.tvalid <= 1; // assert first pixel
avf_axis_if.cb_m.tuser[0] <= 1;
avf_axis_if.cb_m.tuser[1] <= 1;
avf_axis_if.cb_m.tuser[2] <= 0;
avf_axis_if.cb_m.tlast <= 0;
 
output_pixels(start.y, start.x);
 
for(l = start.y; y_end != l; l = l + inc.y)
for(p = start.x; x_end != p; p = p + inc.x)
begin
 
if((l == start.y) & (p == start.x)) // first pixel already asserted
continue;
 
@(avf_axis_if.cb_m iff avf_axis_if.cb_m.tready)
begin
avf_axis_if.cb_m.tvalid <= 1;
output_pixels(l, p);
 
avf_axis_if.cb_m.tuser[0] <= 0;
 
if(p == start.x)
avf_axis_if.cb_m.tuser[1] <= 1;
else
avf_axis_if.cb_m.tuser[1] <= 0;
 
if(p == x_eol)
avf_axis_if.cb_m.tlast <= 1;
else
avf_axis_if.cb_m.tlast <= 0;
 
if((l == y_end - 1) && (p == x_eol))
avf_axis_if.cb_m.tuser[2] <= 1;
end
end
 
@(avf_axis_if.cb_m);
wait(avf_axis_if.cb_m.tready);
axis_default();
 
endtask: avf_tx
 
 
// --------------------------------------------------------------------
//
task
avf_fork_tx;
 
fork
avf_tx(tile.direction, tile.delay);
join_none
 
#0;
 
endtask: avf_fork_tx
 
 
// --------------------------------------------------------------------
//
event tx_frame_done;
 
task automatic
transmit(ref Q_T tr_h);
 
f_h = tr_h;
 
avf_fork_tx();
wait fork;
 
repeat(c_h.vertical_blanking) @(avf_axis_if.cb_m);
->tx_frame_done;
 
endtask: transmit
 
 
//--------------------------------------------------------------------
//
function
new
(
int index,
avf_config_class c_h,
input string avf_type,
virtual axis_if #(.N(AVF_N), .U(AVF_U)) avf_axis_if
);
 
super.new();
 
this.avf_axis_if = avf_axis_if;
 
this.c_h = c_h;
this.tile = c_h.tile[index];
this.avf_name = $sformatf("%s%0d", c_h.name, index);
this.avf_type = avf_type.toupper();
 
f_h = new();
 
f_h.init
(
.pixels_per_line(c_h.width),
.lines_per_frame(c_h.height),
.bits_per_pixel(c_h.bits_per_pixel),
.name(avf_name)
);
 
axis_default();
 
endfunction: new
 
 
// --------------------------------------------------------------------
//
endclass: avf_tx_bfm_class
 
 
//--------------------------------------------------------------------
//
class avf_rx_bfm_class #(BYTES_PER_PIXEL, PIXELS_PER_CLK, AVF_U)
extends blocking_receiver_q_class #(video_frame_class);
 
localparam AVF_N = BYTES_PER_PIXEL * PIXELS_PER_CLK; // data bus width in bytes
localparam AVF_B = BYTES_PER_PIXEL * 8; // bits per pixel on TDATA
 
virtual axis_if #(.N(AVF_N), .U(AVF_U)) avf_axis_if;
 
string avf_name = "";
string avf_type = "";
 
avf_config_class c_h;
avf_tile_config_t tile;
video_frame_class f_h;
 
// --------------------------------------------------------------------
//
function void axis_default;
 
avf_axis_if.cb_s.tready <= 1;
 
endfunction: axis_default
 
 
// --------------------------------------------------------------------
//
task automatic
set_tready(input tready);
 
avf_axis_if.cb_s.tready <= tready;
 
endtask: set_tready
 
 
// --------------------------------------------------------------------
//
task automatic
avf_rx(input avf_direction_t direction);
 
frame_coordinate_t start;
frame_coordinate_t inc;
int x_end;
int y_end;
int x_eol;
int pixel_count = 0;
int l;
int p;
 
c_h.avf_calculate
(
.start(start),
.direction(direction),
.inc(inc),
.x_end(x_end),
.y_end(y_end),
.x_eol(x_eol)
);
 
wait(avf_axis_if.cb_s.tuser[0] & avf_axis_if.cb_s.tvalid & avf_axis_if.cb_m.tready);
 
for(l = start.y; y_end != l; l = l + inc.y)
for(p = start.x; x_end != p; p = p + inc.x)
begin
 
wait(avf_axis_if.cb_s.tvalid & avf_axis_if.cb_m.tready);
 
for(int i = 0; i < PIXELS_PER_CLK; i++)
f_h.lines[l].pixel[p + i] = avf_axis_if.cb_s.tdata[i*AVF_B +: AVF_B];
 
if(p == x_eol)
if(~avf_axis_if.cb_s.tlast)
$display("^^^ %16.t | %m | [%04d, %04d] | %s_%s | ERROR! x_eol without tlast | x_eol = %04d | 0x%06x", $time, p, l, avf_name, avf_type, x_eol, f_h.lines[l].pixel[p]);
 
if(avf_axis_if.cb_s.tlast)
if(p != x_eol)
$display("^^^ %16.t | %m | [%04d, %04d] | %s_%s | ERROR! tlast without x_eol | x_eol = %04d | 0x%06x", $time, p, l, avf_name, avf_type, x_eol, f_h.lines[l].pixel[p]);
 
@(avf_axis_if.cb_s);
 
end
 
endtask: avf_rx
 
 
// --------------------------------------------------------------------
//
task automatic
avf_fork_rx;
 
fork
avf_rx(tile.direction);
join_none
 
#0;
 
endtask: avf_fork_rx
 
 
// --------------------------------------------------------------------
//
event rx_frame_done;
 
virtual task
receive(ref Q_T tr_h);
 
avf_fork_rx();
wait fork;
 
tr_h = f_h.clone();
->rx_frame_done;
 
endtask: receive
 
 
//--------------------------------------------------------------------
//
function
new
(
int index,
avf_config_class c_h,
input string avf_type,
virtual axis_if #(.N(AVF_N), .U(AVF_U)) avf_axis_if
);
 
super.new();
 
this.avf_axis_if = avf_axis_if;
 
this.c_h = c_h;
this.tile = c_h.tile[index];
this.avf_name = $sformatf("%s%0d", c_h.name, index);
this.avf_type = avf_type.toupper();
 
f_h = new();
 
f_h.init
(
.pixels_per_line(c_h.width),
.lines_per_frame(c_h.height),
.bits_per_pixel(c_h.bits_per_pixel),
.name(avf_name)
);
 
axis_default();
 
endfunction: new
 
 
// --------------------------------------------------------------------
//
endclass: avf_rx_bfm_class
 
// --------------------------------------------------------------------
//
class avf_tx_class #(BYTES_PER_PIXEL, OUTPUTS_PER_TILE, AVF_U);
 
localparam AVF_N = BYTES_PER_PIXEL * OUTPUTS_PER_TILE; // data bus width in bytes
localparam AVF_B = BYTES_PER_PIXEL * 8; // bits per pixel on TDATA
 
int number_of_tx_tiles;
 
virtual axis_if #(.N(AVF_N), .U(AVF_U)) avf_axis_out_if[];
 
avf_tx_bfm_class #(BYTES_PER_PIXEL, OUTPUTS_PER_TILE, AVF_U) tx_bfm_h[];
 
video_frame_class clone_h;
 
 
// --------------------------------------------------------------------
//
virtual task automatic
make_frame
(
string pattern,
int pixel = 0
);
 
case(pattern.tolower)
"constant": foreach(tx_bfm_h[i]) tx_bfm_h[i].f_h.make_constant(pixel);
"counting": foreach(tx_bfm_h[i]) tx_bfm_h[i].f_h.make_counting();
"horizontal": foreach(tx_bfm_h[i]) tx_bfm_h[i].f_h.make_horizontal();
"vertical": foreach(tx_bfm_h[i]) tx_bfm_h[i].f_h.make_vertical();
"random": foreach(tx_bfm_h[i]) tx_bfm_h[i].f_h.make_random();
default: $display("^^^ %16.t | %m | ERROR! %s pattern not supported", $time, pattern);
endcase
 
endtask: make_frame
 
 
// --------------------------------------------------------------------
//
virtual task
wait_for_tx_frames
(
input int unsigned count
);
 
repeat(count)
@(tx_bfm_h[0].tx_frame_done);
 
endtask: wait_for_tx_frames
 
 
//--------------------------------------------------------------------
//
function new
(
avf_config_class c_h,
virtual axis_if #(.N(AVF_N), .U(AVF_U)) avf_axis_out_if[]
);
 
this.number_of_tx_tiles = $size(avf_axis_out_if);
this.avf_axis_out_if = avf_axis_out_if;
 
this.tx_bfm_h = new[number_of_tx_tiles];
foreach(tx_bfm_h[i])
tx_bfm_h[i] = new(i, c_h, "TX", avf_axis_out_if[i]);
 
endfunction: new
 
 
// --------------------------------------------------------------------
//
endclass: avf_tx_class
 
 
// --------------------------------------------------------------------
//
class avf_rx_class #(BYTES_PER_PIXEL, OUTPUTS_PER_TILE, AVF_U);
 
localparam AVF_N = BYTES_PER_PIXEL * OUTPUTS_PER_TILE; // data bus width in bytes
localparam AVF_B = BYTES_PER_PIXEL * 8; // bits per pixel on TDATA
 
int number_of_rx_tiles;
 
virtual axis_if #(.N(AVF_N), .U(AVF_U)) avf_axis_in_if[];
 
avf_rx_bfm_class #(BYTES_PER_PIXEL, OUTPUTS_PER_TILE, AVF_U) rx_bfm_h[];
 
video_frame_class clone_h;
 
 
// --------------------------------------------------------------------
//
virtual task
wait_for_rx_frames
(
input int unsigned count
);
 
repeat(count)
@(rx_bfm_h[0].rx_frame_done);
 
endtask: wait_for_rx_frames
 
 
//--------------------------------------------------------------------
//
function new
(
avf_config_class c_h,
virtual axis_if #(.N(AVF_N), .U(AVF_U)) avf_axis_in_if[]
);
 
this.number_of_rx_tiles = $size(avf_axis_in_if);
this.avf_axis_in_if = avf_axis_in_if;
 
this.rx_bfm_h = new[number_of_rx_tiles];
foreach(rx_bfm_h[i])
rx_bfm_h[i] = new(i, c_h, "RX", avf_axis_in_if[i]);
 
endfunction: new
 
 
// --------------------------------------------------------------------
//
endclass: avf_rx_class
 
 
// --------------------------------------------------------------------
//
endpackage: axis_video_frame_bfm_pkg
 
/qaz_libs/trunk/BFM/src/axis_video_frame/s_avf_api.svh
0,0 → 1,101
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class s_avf_api
extends uvm_sequence #(avf_sequence_item);
`uvm_object_utils(s_avf_api)
 
avf_sequence_item item;
 
// --------------------------------------------------------------------
mailbox #(video_frame_class) frame_buffer;
int pixels_per_line;
int lines_per_frame;
int bits_per_pixel;
int bytes_per_pixel;
int pixels_per_clk;
 
// --------------------------------------------------------------------
function void init( int pixels_per_line
, int lines_per_frame
, int bits_per_pixel
, int pixels_per_clk
);
this.pixels_per_line = pixels_per_line;
this.lines_per_frame = lines_per_frame;
this.bits_per_pixel = bits_per_pixel;
this.bytes_per_pixel = (bits_per_pixel % 8 == 0)
? (bits_per_pixel / 8)
: (bits_per_pixel / 8) + 1;
this.pixels_per_clk = pixels_per_clk;
endfunction : init
 
// --------------------------------------------------------------------
task automatic put_frame(string pattern, int pixel = 0);
video_frame_class f_h = new;
f_h.init( pixels_per_line
, lines_per_frame
, bits_per_pixel
, pixels_per_clk
);
case(pattern.tolower)
"constant": f_h.make_constant(pixel);
"counting": f_h.make_counting();
"horizontal": f_h.make_horizontal();
"vertical": f_h.make_vertical();
"random": f_h.make_random();
default: `uvm_fatal(get_name(), "Pattern not supported!")
endcase
 
frame_buffer.put(f_h);
uvm_report_info(get_name(), $sformatf("| put_frame(%s)", pattern.tolower));
endtask: put_frame
 
// --------------------------------------------------------------------
task send_frame_buffer( uvm_sequencer_base seqr
, uvm_sequence_base parent = null
);
this.start(seqr, parent);
endtask
 
// --------------------------------------------------------------------
task body();
item = avf_sequence_item::type_id::create("avf_sequence_item");
start_item(item);
if(frame_buffer.num() != 0)
item.frame_buffer = this.frame_buffer;
finish_item(item);
endtask
 
// --------------------------------------------------------------------
function new(string name = "s_avf_api");
super.new(name);
frame_buffer = new;
endfunction
 
// --------------------------------------------------------------------
endclass : s_avf_api
/qaz_libs/trunk/BFM/src/axis_video_frame/s_avf_base.svh
0,0 → 1,54
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class s_avf_base
extends uvm_sequence #(avf_sequence_item);
`uvm_object_utils(s_avf_base)
 
s_avf_api avf_api_h;
 
// --------------------------------------------------------------------
function void init( int pixels_per_line
, int lines_per_frame
, int bits_per_pixel
, int pixels_per_clk
);
avf_api_h = s_avf_api::type_id::create("s_avf_api");
avf_api_h.init( pixels_per_line
, lines_per_frame
, bits_per_pixel
, pixels_per_clk
);
endfunction : init
 
// --------------------------------------------------------------------
function new(string name = "s_avf_base");
super.new(name);
endfunction
 
// --------------------------------------------------------------------
endclass : s_avf_base
/qaz_libs/trunk/BFM/src/axis_video_frame/s_avf_slave_base.svh
0,0 → 1,51
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
class s_avf_slave_base
extends uvm_sequence #(avf_sequence_item);
`uvm_object_utils(s_avf_slave_base)
 
avf_slave_sequencer sequencer_h;
avf_sequence_item item;
 
// --------------------------------------------------------------------
task body();
forever
begin
sequencer_h.m_request_fifo.get(item);
start_item(item);
finish_item(item);
end
endtask: body
 
// --------------------------------------------------------------------
function new(string name = "s_avf_slave_base");
super.new(name);
endfunction
 
// --------------------------------------------------------------------
endclass : s_avf_slave_base
/qaz_libs/trunk/BFM/src/tb/random_delay.svh
0,0 → 1,67
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
 
// --------------------------------------------------------------------
typedef enum
{
NONE,
SPORADIC,
// BURSTY,
REGULAR
} random_delay_type_e;
 
// --------------------------------------------------------------------
class random_delay;
 
rand int unsigned delay = 0;
time wait_timescale = 1ns;
 
// --------------------------------------------------------------------
virtual function void set_delay(random_delay_type_e kind = REGULAR);
case(kind)
NONE: delay = 0;
SPORADIC: assert(this.randomize() with{delay dist {0 := 96, [1:3] := 3, [4:7] := 1};});
REGULAR: assert(this.randomize() with{delay dist {0 := 60, [1:3] := 30, [4:7] := 10};});
default: delay = 0;
endcase
endfunction: set_delay
 
// --------------------------------------------------------------------
virtual task next(random_delay_type_e kind = REGULAR);
set_delay(kind);
#(delay * wait_timescale);
endtask: next
 
// --------------------------------------------------------------------
virtual function int unsigned get(random_delay_type_e kind = REGULAR);
set_delay(kind);
return(delay);
endfunction: get
 
// --------------------------------------------------------------------
endclass: random_delay
/qaz_libs/trunk/BFM/src/tb/tb_pkg.sv
0,0 → 1,34
//////////////////////////////////////////////////////////////////////
//// ////
//// Copyright (C) 2018 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 tb_pkg;
 
// --------------------------------------------------------------------
`include "random_delay.svh"
 
// --------------------------------------------------------------------
endpackage : tb_pkg
/qaz_libs/trunk/BFM/src/video_frame/video_frame_pkg.sv
50,6 → 50,8
rand int pixels_per_line;
rand int lines_per_frame;
rand int bits_per_pixel;
int bytes_per_pixel;
rand int pixels_per_clk;
line_s lines[];
string name = "";
string pattern = "";
73,7 → 75,6
bits_per_pixel >= 1 && bits_per_pixel <= 32;
}
 
 
//--------------------------------------------------------------------
function new;
this.log = new;
80,127 → 81,40
this.frame_id = 0;
endfunction: new
 
 
// --------------------------------------------------------------------
//
function void init
(
input int pixels_per_line,
input int lines_per_frame,
input int bits_per_pixel,
string name = ""
int pixels_per_line,
int lines_per_frame,
int bits_per_pixel,
int pixels_per_clk = 1,
string name = ""
);
 
log.info($sformatf("%m"));
 
this.pixels_per_line = pixels_per_line;
this.lines_per_frame = lines_per_frame;
this.bits_per_pixel = bits_per_pixel;
this.pixels_per_clk = pixels_per_clk;
this.name = name;
this.bytes_per_pixel = (bits_per_pixel % 8 == 0)
? (bits_per_pixel / 8)
: (bits_per_pixel / 8) + 1;
 
this.make_constant(0);
 
endfunction: init
 
 
// --------------------------------------------------------------------
//
extern virtual task write_pixel
(
input frame_coordinate_t coordinate,
input int pixel
);
 
extern virtual function int read_pixel
(
input frame_coordinate_t coordinate
);
 
extern function flattened_frame_t flatten_frame();
 
extern virtual function void make_constant
(
input int pixel
);
 
extern virtual function void make_counting
(
input int offset = 0
);
 
extern virtual function void make_horizontal();
 
extern virtual function void make_vertical();
 
extern virtual function void make_random();
 
extern virtual function void shift_right(ref line_s column);
 
extern virtual function void copy
(
ref video_frame_class from
);
 
extern virtual function video_frame_class clone();
 
extern virtual function int compare
(
input int max_mismatches,
ref video_frame_class to
);
 
extern virtual function video_frame_class catenate_horizontally
(
ref video_frame_class tail
);
 
extern virtual function int compare_line
(
input int line,
input int max_mismatches,
ref video_frame_class to
);
 
extern virtual function void print_line
(
input int line,
input int pixel,
input int count
);
 
extern virtual function void print_config();
 
endclass: video_frame_class
 
 
// --------------------------------------------------------------------
//
task
video_frame_class::write_pixel
(
input frame_coordinate_t coordinate,
input int pixel
);
 
task write_pixel(frame_coordinate_t coordinate, int pixel);
this.lines[coordinate.y].pixel[coordinate.x] = pixel;
 
endtask: write_pixel
 
 
// --------------------------------------------------------------------
//
function int video_frame_class::read_pixel
(
input frame_coordinate_t coordinate
);
 
function int read_pixel(frame_coordinate_t coordinate);
read_pixel = this.lines[coordinate.y].pixel[coordinate.x];
 
endfunction: read_pixel
 
// --------------------------------------------------------------------
//
function flattened_frame_t video_frame_class::flatten_frame();
function flattened_frame_t flatten_frame();
int i = 0;
log.info($sformatf("%m"));
flatten_frame = new[lines_per_frame*pixels_per_line];
214,136 → 128,88
endfunction: flatten_frame
 
// --------------------------------------------------------------------
//
function void video_frame_class::make_constant
(
input int pixel
);
 
function void make_constant(int pixel);
log.info($sformatf("%m"));
 
 
this.lines = new[lines_per_frame];
 
foreach(this.lines[l])
begin
 
this.lines[l].pixel = new[pixels_per_line];
 
foreach(this.lines[l].pixel[p])
this.lines[l].pixel[p] = pixel;
 
end
 
pattern = "constant";
 
endfunction: make_constant
 
 
// --------------------------------------------------------------------
//
function void video_frame_class::make_counting
(
input int offset = 0
);
 
function void make_counting(int offset = 0);
log.info($sformatf("%m"));
 
this.lines = new[lines_per_frame];
 
foreach(this.lines[l])
begin
 
this.lines[l].pixel = new[pixels_per_line];
 
foreach(this.lines[l].pixel[p])
this.lines[l].pixel[p] = (pixels_per_line * l) + p + offset;
 
end
 
pattern = "counting";
 
endfunction: make_counting
 
 
// --------------------------------------------------------------------
//
function void video_frame_class::make_horizontal();
 
function void make_horizontal();
log.info($sformatf("%m"));
 
this.lines = new[lines_per_frame];
 
foreach(this.lines[l])
begin
 
this.lines[l].pixel = new[pixels_per_line];
 
foreach(this.lines[l].pixel[p])
this.lines[l].pixel[p] = p;
 
end
 
pattern = "horizontal";
 
endfunction: make_horizontal
 
 
// --------------------------------------------------------------------
//
function void video_frame_class::make_vertical();
 
function void make_vertical();
log.info($sformatf("%m"));
 
this.lines = new[lines_per_frame];
 
foreach(this.lines[l])
begin
 
this.lines[l].pixel = new[pixels_per_line];
 
foreach(this.lines[l].pixel[p])
this.lines[l].pixel[p] = l;
 
end
 
pattern = "vertical";
 
endfunction: make_vertical
 
 
// --------------------------------------------------------------------
//
function void video_frame_class::make_random();
 
function void make_random();
log.info($sformatf("%m"));
 
this.lines = new[lines_per_frame];
 
foreach(this.lines[l])
begin
 
this.lines[l].pixel = new[pixels_per_line];
 
foreach(this.lines[l].pixel[p])
this.lines[l].pixel[p] = $urandom_range(((2 ** bits_per_pixel) - 1), 0);
 
end
 
pattern = "random";
 
endfunction: make_random
 
 
// --------------------------------------------------------------------
//
function void video_frame_class::copy
(
ref video_frame_class from
);
 
function void copy(video_frame_class from);
log.info($sformatf("%m"));
 
this.frame_id = from.frame_id;
this.pixels_per_line = from.pixels_per_line;
this.lines_per_frame = from.lines_per_frame;
360,26 → 226,15
end
endfunction: copy
 
 
// --------------------------------------------------------------------
//
function video_frame_class video_frame_class::clone();
 
virtual function video_frame_class clone;
log.info($sformatf("%m"));
 
clone = new();
clone.copy(this);
 
endfunction: clone
 
 
// --------------------------------------------------------------------
//
function video_frame_class video_frame_class::catenate_horizontally
(
ref video_frame_class tail
);
 
function video_frame_class catenate_horizontally(video_frame_class tail);
log.info($sformatf("%m"));
 
if(this.lines_per_frame != tail.lines_per_frame)
389,7 → 244,6
return(null);
 
catenate_horizontally = new();
 
catenate_horizontally.pixels_per_line = this.pixels_per_line + tail.pixels_per_line;
catenate_horizontally.lines_per_frame = this.lines_per_frame;
catenate_horizontally.bits_per_pixel = this.bits_per_pixel;
409,8 → 263,7
endfunction: catenate_horizontally
 
// --------------------------------------------------------------------
//
function void video_frame_class::shift_right(ref line_s column);
function void shift_right(ref line_s column);
log.info($sformatf("%m"));
 
foreach(this.lines[l])
422,14 → 275,11
endfunction: shift_right
 
// --------------------------------------------------------------------
//
function int video_frame_class::compare_line
(
input int line,
input int max_mismatches,
ref video_frame_class to
);
 
function int compare_line
( int line
, int max_mismatches
, video_frame_class to
);
int mismatch_count = 0;
 
if(to.bits_per_pixel != this.bits_per_pixel)
450,24 → 300,14
 
if(mismatch_count > max_mismatches)
return(mismatch_count);
 
end
 
return(mismatch_count);
 
endfunction: compare_line
 
 
// --------------------------------------------------------------------
//
function int video_frame_class::compare
(
input int max_mismatches,
ref video_frame_class to
);
 
function int compare(int max_mismatches, video_frame_class to);
int mismatch_count = 0;
 
log.info($sformatf("%m"));
 
if(to.pixels_per_line != this.pixels_per_line)
493,7 → 333,6
foreach(this.lines[l].pixel[p])
if(to.lines[l].pixel[p] != this.lines[l].pixel[p])
begin
 
if(max_mismatches > 0)
mismatch_count++;
 
501,44 → 340,46
 
if(mismatch_count > max_mismatches)
return(mismatch_count);
 
end
end
 
return(mismatch_count);
 
endfunction: compare
 
 
// --------------------------------------------------------------------
//
function void video_frame_class::print_line
(
input int line,
input int pixel,
input int count
);
 
function void print_line(int line, int pixel, int count);
log.info($sformatf("%m"));
 
for(int i = 0; i < count; i++)
log.display($sformatf("%4h @ frame[%4h][%4h] | %s", this.lines[line].pixel[(pixel + i)], line, (pixel + i), name));
 
endfunction: print_line
 
 
// --------------------------------------------------------------------
//
function void video_frame_class::print_config();
 
function void print_config();
log.display($sformatf("%m | frame_id = %06d | %s", frame_id, name));
log.display($sformatf("%m | pixels_per_line = %06d | %s", pixels_per_line, name));
log.display($sformatf("%m | lines_per_frame = %06d | %s", lines_per_frame, name));
log.display($sformatf("%m | bits_per_pixel = %06d | %s", bits_per_pixel, name));
log.display($sformatf("%m | pixels_per_clk = %06d | %s", pixels_per_clk, name));
log.display($sformatf("%m | pattern = %s | %s", pattern, name));
 
endfunction: print_config
 
// --------------------------------------------------------------------
function string convert2string();
string s;
string f ="";
foreach(this.lines[l])
begin
s = $sformatf("[%4.d]", l);
foreach(this.lines[l].pixel[p])
s = {s, $sformatf("|%4.h", this.lines[l].pixel[p])};
f = {f, s, "|\n"};
end
return f;
endfunction: convert2string
 
// --------------------------------------------------------------------
endclass: video_frame_class
 
// --------------------------------------------------------------------
endpackage: video_frame_pkg
 
/qaz_libs/trunk/axi4_lib/sim/src/legacy/axi4_bfm/axi4_master_bfm_if.sv
0,0 → 1,526
//////////////////////////////////////////////////////////////////////
//// ////
//// 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
 
interface
axi4_master_bfm_if
#(
A = 32, // address bus width
N = 8, // data bus width in bytes
I = 1 // ID width
)
(
axi4_if axi4_s,
input aresetn,
input aclk
);
 
logic [(A-1):0] araddr;
logic [1:0] arburst;
logic [3:0] arcache;
logic [(I-1):0] arid;
logic [7:0] arlen;
logic arlock;
logic [2:0] arprot;
logic [3:0] arqos;
logic arready;
logic [3:0] arregion;
logic [2:0] arsize;
logic arvalid;
logic [(A-1):0] awaddr;
logic [1:0] awburst;
logic [3:0] awcache;
logic [(I-1):0] awid;
logic [7:0] awlen;
logic awlock;
logic [2:0] awprot;
logic [3:0] awqos;
logic awready;
logic [3:0] awregion;
logic [2:0] awsize;
logic awvalid;
logic [(I-1):0] bid;
logic bready;
logic [1:0] bresp;
logic bvalid;
logic [(8*N)-1:0] rdata;
logic [(I-1):0] rid;
logic rlast;
logic rready;
logic [1:0] rresp;
logic rvalid;
logic [(8*N)-1:0] wdata;
logic [(I-1):0] wid;
logic wlast;
logic wready;
logic [N-1:0] wstrb;
logic wvalid;
 
 
// --------------------------------------------------------------------
//
default clocking cb @(posedge aclk);
output arid;
output araddr;
output arburst;
output arcache;
output awid;
output arlen;
output arlock;
output arprot;
output arqos;
input arready;
output arregion;
output arsize;
output arvalid;
output awaddr;
output awburst;
output awcache;
output awlen;
output awlock;
output awprot;
output awqos;
input awready;
output awregion;
output awsize;
output awvalid;
output bready;
input bid;
input bresp;
input bvalid;
input rdata;
input rid;
input rlast;
output rready;
input rresp;
input rvalid;
output wdata;
output wlast;
input wready;
output wstrb;
output wvalid;
input aresetn;
input aclk;
endclocking
 
 
// --------------------------------------------------------------------
//
assign axi4_s.arid = arid;
assign axi4_s.araddr = araddr;
assign axi4_s.arburst = arburst;
assign axi4_s.arcache = arcache;
assign axi4_s.awid = awid;
assign axi4_s.arlen = arlen;
assign axi4_s.arlock = arlock;
assign axi4_s.arprot = arprot;
assign axi4_s.arqos = arqos;
assign arready = axi4_s.arready;
assign axi4_s.arregion = arregion;
assign axi4_s.arsize = arsize;
assign axi4_s.arvalid = arvalid;
assign axi4_s.awaddr = awaddr;
assign axi4_s.awburst = awburst;
assign axi4_s.awcache = awcache;
assign axi4_s.awlen = awlen;
assign axi4_s.awlock = awlock;
assign axi4_s.awprot = awprot;
assign axi4_s.awqos = awqos;
assign awready = axi4_s.awready;
assign axi4_s.awregion = awregion;
assign axi4_s.awsize = awsize;
assign axi4_s.awvalid = awvalid;
assign axi4_s.bready = bready;
assign bid = axi4_s.bid;
assign bresp = axi4_s.bresp;
assign bvalid = axi4_s.bvalid;
assign rdata = axi4_s.rdata;
assign rid = axi4_s.rid;
assign rlast = axi4_s.rlast;
assign axi4_s.rready = rready;
assign rresp = axi4_s.rresp;
assign rvalid = axi4_s.rvalid;
assign axi4_s.wdata = wdata;
assign axi4_s.wlast = wlast;
assign wready = axi4_s.wready;
assign axi4_s.wstrb = wstrb;
assign axi4_s.wvalid = wvalid;
 
 
// --------------------------------------------------------------------
//
function void
ar_default;
 
cb.araddr <= 'bx;
cb.arburst <= 'bx;
cb.arcache <= 'bx;
cb.arid <= 'bx;
cb.arlen <= 'bx;
cb.arlock <= 'bx;
cb.arprot <= 'bx;
cb.arqos <= 'bx;
cb.arregion <= 'bx;
cb.arsize <= 'bx;
cb.arvalid <= 0;
 
endfunction: ar_default
 
 
// --------------------------------------------------------------------
//
function void
aw_default;
 
cb.awaddr <= 'bx;
cb.awburst <= 'bx;
cb.awcache <= 'bx;
cb.awid <= 'bx;
cb.awlen <= 'bx;
cb.awlock <= 'bx;
cb.awprot <= 'bx;
cb.awqos <= 'bx;
cb.awregion <= 'bx;
cb.awsize <= 'bx;
cb.awvalid <= 0;
 
endfunction: aw_default
 
 
// --------------------------------------------------------------------
//
function void
r_default;
 
cb.rready <= 0;
 
endfunction: r_default
 
 
// --------------------------------------------------------------------
//
function void
w_default;
 
cb.wdata <= 'bx;
cb.wlast <= 'bx;
cb.wstrb <= {N{1'b1}};
cb.wvalid <= 0;
 
endfunction: w_default
 
 
// --------------------------------------------------------------------
//
function void
b_default;
 
cb.bready <= 0;
 
endfunction: b_default
 
 
// --------------------------------------------------------------------
//
function void
init;
 
ar_default();
r_default();
aw_default();
w_default();
b_default();
 
endfunction: init
 
 
// --------------------------------------------------------------------
//
task
zero_cycle_delay;
 
##0;
 
endtask: zero_cycle_delay
 
 
// --------------------------------------------------------------------
//
import tb_bfm_pkg::*;
import axi4_transaction_pkg::*;
 
 
// --------------------------------------------------------------------
//
class ar_master_transaction_class #(A = 32, N = 8, I = 1)
extends tb_blocking_transaction_q_class #(axi4_transaction_class #(.A(A), .N(N), .I(I)));
 
// --------------------------------------------------------------------
//
task automatic
transaction
(
ref T tr_h
);
 
->this.start;
 
##(tr_h.delay_h.next());
 
cb.araddr <= tr_h.addr;
cb.arid <= tr_h.id;
cb.arlen <= tr_h.len;
cb.arsize <= tr_h.size;
 
cb.arburst <= tr_h.burst;
cb.arcache <= tr_h.cache;
cb.arlock <= tr_h.lock;
cb.arprot <= tr_h.prot;
cb.arqos <= tr_h.qos;
cb.arregion <= tr_h.region;
cb.arvalid <= 1;
 
$display("^^^ %16.t | %m | master AR transaction @ 0x%08x |", $time, tr_h.addr);
 
##1;
wait(cb.arready);
 
##0;
ar_default();
 
->this.done;
 
endtask: transaction
 
 
// --------------------------------------------------------------------
//
endclass: ar_master_transaction_class
 
 
// --------------------------------------------------------------------
//
class r_master_transaction_class #(A = 32, N = 8, I = 1)
extends tb_blocking_transaction_q_class #(axi4_transaction_class #(.A(A), .N(N), .I(I)));
 
// --------------------------------------------------------------------
//
task automatic
transaction
(
ref T tr_h
);
 
->this.start;
 
tr_h.data_h = new(tr_h.len);
 
foreach(tr_h.payload_h.w[i])
begin
##(tr_h.delay_h.next());
cb.rready <= 1;
##1;
 
wait(cb.rvalid);
##0;
 
tr_h.data_h.w[i] = cb.rdata;
 
$display("^^^ %16.t | %m | master R transaction | %d | 0x%016x |", $time, i, tr_h.data_h.w[i]);
r_default();
end
 
->this.done;
 
endtask: transaction
 
 
// --------------------------------------------------------------------
//
endclass: r_master_transaction_class
 
 
// --------------------------------------------------------------------
//
class aw_master_transaction_class #(A = 32, N = 8, I = 1)
extends tb_blocking_transaction_q_class #(axi4_transaction_class #(.A(A), .N(N), .I(I)));
 
// --------------------------------------------------------------------
//
task automatic
transaction
(
ref T tr_h
);
 
->this.start;
 
##(tr_h.delay_h.next());
 
cb.awaddr <= tr_h.addr;
cb.awid <= tr_h.id;
cb.awlen <= tr_h.len;
cb.awsize <= tr_h.size;
 
cb.awburst <= tr_h.burst;
cb.awcache <= tr_h.cache;
cb.awlock <= tr_h.lock;
cb.awprot <= tr_h.prot;
cb.awqos <= tr_h.qos;
cb.awregion <= tr_h.region;
cb.awvalid <= 1;
 
$display("^^^ %16.t | %m | master AW transaction @ 0x%08x |", $time, tr_h.addr);
 
##1;
wait(cb.awready);
 
##0;
aw_default();
 
->this.done;
 
endtask: transaction
 
 
// --------------------------------------------------------------------
//
endclass: aw_master_transaction_class
 
 
// --------------------------------------------------------------------
//
class w_master_transaction_class #(A = 32, N = 8, I = 1)
extends tb_blocking_transaction_q_class #(axi4_transaction_class #(.A(A), .N(N), .I(I)));
 
// --------------------------------------------------------------------
//
task automatic
transaction
(
ref T tr_h
);
 
->this.start;
 
foreach(tr_h.payload_h.w[i])
begin
##(tr_h.delay_h.next());
 
cb.wdata <= tr_h.payload_h.w[i];
// cb.wstrb <= tr_h.strb; // need to fix
 
if(i < tr_h.payload_h.w.size - 1)
cb.wlast <= 0;
else
cb.wlast <= 1;
 
cb.wvalid <= 1;
 
##1;
wait(cb.wready);
 
##0;
$display("^^^ %16.t | %m | master W transaction | %d | 0x%016x |", $time, i, tr_h.payload_h.w[i]);
w_default();
end
 
->this.done;
 
endtask: transaction
 
 
// --------------------------------------------------------------------
//
endclass: w_master_transaction_class
 
 
// --------------------------------------------------------------------
//
class b_master_transaction_class #(A = 32, N = 8, I = 1)
extends tb_blocking_transaction_q_class #(axi4_transaction_class #(.A(A), .N(N), .I(I)));
 
// --------------------------------------------------------------------
//
task automatic
transaction
(
ref T tr_h
);
 
->this.start;
 
##(tr_h.delay_h.next());
cb.bready <= 1;
##1;
 
wait(cb.bvalid);
##0;
 
$display("^^^ %16.t | %m | master B transaction | 0x%x |", $time, cb.bresp);
b_default();
 
->this.done;
 
endtask: transaction
 
 
// --------------------------------------------------------------------
//
endclass: b_master_transaction_class
 
 
// --------------------------------------------------------------------
//
ar_master_transaction_class #(.A(A), .N(N), .I(I)) ar_h;
r_master_transaction_class #(.A(A), .N(N), .I(I)) r_h;
aw_master_transaction_class #(.A(A), .N(N), .I(I)) aw_h;
w_master_transaction_class #(.A(A), .N(N), .I(I)) w_h;
b_master_transaction_class #(.A(A), .N(N), .I(I)) b_h;
 
initial
begin
init();
ar_h = new;
ar_h.init();
r_h = new;
r_h.init();
aw_h = new;
aw_h.init();
w_h = new;
w_h.init();
b_h = new;
b_h.init();
end
 
 
// --------------------------------------------------------------------
//
 
endinterface
 
 
/qaz_libs/trunk/axi4_lib/sim/src/legacy/axi4_bfm/axi4_simple_agent_pkg.sv
0,0 → 1,153
//////////////////////////////////////////////////////////////////////
//// ////
//// 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_simple_agent_pkg;
 
// --------------------------------------------------------------------
//
import axi4_transaction_pkg::*;
 
 
// --------------------------------------------------------------------
//
class axi4_simple_agent_class #(A = 32, N = 8, I = 1);
 
axi4_transaction_class tr_h;
virtual axi4_master_bfm_if #(.A(A), .N(N), .I(I)) axi4_m;
virtual axi4_slave_bfm_if #(.A(A), .N(N), .I(I)) axi4_s;
 
 
//--------------------------------------------------------------------
function new
(
virtual axi4_master_bfm_if #(.A(A), .N(N), .I(I)) axi4_m,
virtual axi4_slave_bfm_if #(.A(A), .N(N), .I(I)) axi4_s
);
 
this.axi4_m = axi4_m;
this.axi4_s = axi4_s;
 
endfunction: new
 
 
// --------------------------------------------------------------------
//
task
basic_read
(
input logic [(A-1):0] araddr,
input logic [7:0] arlen,
output logic [(8*N)-1:0] data[],
output logic [1:0] rresp
);
 
this.tr_h = new;
this.tr_h.basic_read(araddr, arlen);
 
axi4_m.ar_h.put(tr_h);
axi4_s.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 [7:0] awlen,
input logic [(8*N)-1:0] data[],
output logic [1:0] bresp
);
 
this.tr_h = new;
this.tr_h.basic_write(awaddr, awlen);
 
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_s.aw_h.put(tr_h);
axi4_m.w_h.put(tr_h);
axi4_s.w_h.put(tr_h);
axi4_m.b_h.put(tr_h);
 
@(axi4_s.b_h.done);
bresp = tr_h.resp;
 
endtask: basic_write
 
 
// --------------------------------------------------------------------
//
task
basic_random_write
(
input logic [(A-1):0] awaddr,
input logic [7:0] awlen,
output logic [1:0] bresp
);
 
this.tr_h = new;
this.tr_h.basic_write(awaddr, awlen);
 
axi4_m.aw_h.put(tr_h);
axi4_s.aw_h.put(tr_h);
axi4_m.w_h.put(tr_h);
axi4_s.w_h.put(tr_h);
axi4_m.b_h.put(tr_h);
 
@(axi4_s.b_h.done);
bresp = tr_h.resp;
 
endtask: basic_random_write
 
 
// --------------------------------------------------------------------
//
function void
init;
 
endfunction: init
 
 
// --------------------------------------------------------------------
//
endclass: axi4_simple_agent_class
 
 
// --------------------------------------------------------------------
//
endpackage: axi4_simple_agent_pkg
 
/qaz_libs/trunk/axi4_lib/sim/src/legacy/axi4_bfm/axi4_slave_bfm_if.sv
0,0 → 1,514
//////////////////////////////////////////////////////////////////////
//// ////
//// 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
 
interface
axi4_slave_bfm_if
#(
A = 32, // address bus width
N = 8, // data bus width in bytes
I = 1 // ID width
)
(
axi4_if axi4_m,
input aresetn,
input aclk
);
 
logic [(A-1):0] araddr;
logic [1:0] arburst;
logic [3:0] arcache;
logic [(I-1):0] arid;
logic [7:0] arlen;
logic arlock;
logic [2:0] arprot;
logic [3:0] arqos;
logic arready;
logic [3:0] arregion;
logic [2:0] arsize;
logic arvalid;
logic [(A-1):0] awaddr;
logic [1:0] awburst;
logic [3:0] awcache;
logic [(I-1):0] awid;
logic [7:0] awlen;
logic awlock;
logic [2:0] awprot;
logic [3:0] awqos;
logic awready;
logic [3:0] awregion;
logic [2:0] awsize;
logic awvalid;
logic [(I-1):0] bid;
logic bready;
logic [1:0] bresp;
logic bvalid;
logic [(8*N)-1:0] rdata;
logic [(I-1):0] rid;
logic rlast;
logic rready;
logic [1:0] rresp;
logic rvalid;
logic [(8*N)-1:0] wdata;
logic [(I-1):0] wid;
logic wlast;
logic wready;
logic [N-1:0] wstrb;
logic wvalid;
 
 
// --------------------------------------------------------------------
//
default clocking cb @(posedge aclk);
input arid;
input araddr;
input arburst;
input arcache;
input awid;
input arlen;
input arlock;
input arprot;
input arqos;
output arready;
input arregion;
input arsize;
input arvalid;
input awaddr;
input awburst;
input awcache;
input awlen;
input awlock;
input awprot;
input awqos;
output awready;
input awregion;
input awsize;
input awvalid;
input bready;
output bid;
output bresp;
output bvalid;
output rdata;
output rid;
output rlast;
input rready;
output rresp;
output rvalid;
input wdata;
input wid;
input wlast;
output wready;
input wstrb;
input wvalid;
input aresetn;
input aclk;
endclocking
 
 
// --------------------------------------------------------------------
//
assign arid = axi4_m.arid;
assign araddr = axi4_m.araddr;
assign arburst = axi4_m.arburst;
assign arcache = axi4_m.arcache;
assign awid = axi4_m.awid;
assign arlen = axi4_m.arlen;
assign arlock = axi4_m.arlock;
assign arprot = axi4_m.arprot;
assign arqos = axi4_m.arqos;
assign axi4_m.arready = arready;
assign arregion = axi4_m.arregion;
assign arsize = axi4_m.arsize;
assign arvalid = axi4_m.arvalid;
assign awaddr = axi4_m.awaddr;
assign awburst = axi4_m.awburst;
assign awcache = axi4_m.awcache;
assign awlen = axi4_m.awlen;
assign awlock = axi4_m.awlock;
assign awprot = axi4_m.awprot;
assign awqos = axi4_m.awqos;
assign axi4_m.awready = awready;
assign awregion = axi4_m.awregion;
assign awsize = axi4_m.awsize;
assign awvalid = axi4_m.awvalid;
assign bready = axi4_m.bready;
assign axi4_m.bid = bid;
assign axi4_m.bresp = bresp;
assign axi4_m.bvalid = bvalid;
assign axi4_m.rdata = rdata;
assign axi4_m.rid = rid;
assign axi4_m.rlast = rlast;
assign rready = axi4_m.rready;
assign axi4_m.rresp = rresp;
assign axi4_m.rvalid = rvalid;
assign wdata = axi4_m.wdata;
assign wlast = axi4_m.wlast;
assign axi4_m.wready = wready;
assign wstrb = axi4_m.wstrb;
assign wvalid = axi4_m.wvalid;
 
 
// --------------------------------------------------------------------
//
function void
ar_default;
 
cb.arready <= 0;
 
endfunction: ar_default
 
 
// --------------------------------------------------------------------
//
function void
aw_default;
 
cb.awready <= 0;
 
endfunction: aw_default
 
 
// --------------------------------------------------------------------
//
function void
r_default;
 
cb.rdata <= 'bx;
cb.rid <= 'bx;
cb.rlast <= 'bx;
cb.rresp <= 0;
cb.rvalid <= 0;
 
endfunction: r_default
 
 
// --------------------------------------------------------------------
//
function void
w_default;
 
cb.wready <= 0;
 
endfunction: w_default
 
 
// --------------------------------------------------------------------
//
function void
b_default;
 
cb.bid <= 0;
cb.bresp <= 0;
cb.bvalid <= 0;
 
endfunction: b_default
 
 
// --------------------------------------------------------------------
//
function void
init;
 
ar_default();
r_default();
aw_default();
w_default();
b_default();
 
endfunction: init
 
 
// --------------------------------------------------------------------
//
task
zero_cycle_delay;
 
##0;
 
endtask: zero_cycle_delay
 
 
// --------------------------------------------------------------------
//
import tb_bfm_pkg::*;
import axi4_transaction_pkg::*;
 
 
// --------------------------------------------------------------------
//
class r_slave_transaction_class #(A = 32, N = 8, I = 1)
extends tb_blocking_transaction_q_class #(axi4_transaction_class #(.A(A), .N(N), .I(I)));
 
// --------------------------------------------------------------------
//
task automatic
transaction
(
ref T tr_h
);
 
->this.start;
 
foreach(tr_h.payload_h.w[i])
begin
##(tr_h.delay_h.next());
 
cb.rdata <= tr_h.payload_h.w[i];
cb.rresp <= tr_h.resp;
cb.rid <= tr_h.id;
 
if(i < tr_h.payload_h.w.size - 1)
cb.rlast <= 0;
else
cb.rlast <= 1;
 
cb.rvalid <= 1;
##1;
 
wait(cb.rready);
##0;
 
$display("^^^ %16.t | %m | slave R transaction | %d | 0x%016x |", $time, i, tr_h.payload_h.w[i]);
r_default();
end
 
->this.done;
 
endtask: transaction
 
 
// --------------------------------------------------------------------
//
endclass: r_slave_transaction_class
 
 
// --------------------------------------------------------------------
//
r_slave_transaction_class #(.A(A), .N(N), .I(I)) r_h;
 
class ar_slave_transaction_class #(A = 32, N = 8, I = 1)
extends tb_blocking_transaction_q_class #(axi4_transaction_class #(.A(A), .N(N), .I(I)));
 
// --------------------------------------------------------------------
//
task automatic
transaction
(
ref T tr_h
);
 
->this.start;
 
##(tr_h.delay_h.next());
 
cb.arready <= 1;
##1;
 
wait(cb.arvalid);
 
##0;
r_h.put(tr_h);
ar_default();
 
$display("^^^ %16.t | %m | slave AR transaction @ 0x%08x | 0x%016x |", $time, tr_h.addr, tr_h.payload_h.w[0]);
 
->this.done;
 
endtask: transaction
 
 
// --------------------------------------------------------------------
//
endclass: ar_slave_transaction_class
 
 
// --------------------------------------------------------------------
//
class aw_slave_transaction_class #(A = 32, N = 8, I = 1)
extends tb_blocking_transaction_q_class #(axi4_transaction_class #(.A(A), .N(N), .I(I)));
 
semaphore aw_semaphore;
 
 
//--------------------------------------------------------------------
function new;
 
super.new();
this.aw_semaphore = new(0);
 
endfunction: new
 
 
// --------------------------------------------------------------------
//
task automatic
transaction
(
ref T tr_h
);
 
->this.start;
 
##(tr_h.delay_h.next());
 
cb.awready <= 1;
##1;
 
wait(cb.awvalid);
 
##0;
this.aw_semaphore.put();
aw_default();
 
$display("^^^ %16.t | %m | slave AW transaction @ 0x%08x | 0x%016x |", $time, tr_h.addr, tr_h.payload_h.w[0]);
 
->this.done;
 
endtask: transaction
 
// --------------------------------------------------------------------
//
endclass: aw_slave_transaction_class
 
 
// --------------------------------------------------------------------
//
aw_slave_transaction_class #(.A(A), .N(N), .I(I)) aw_h;
 
class b_slave_transaction_class #(A = 32, N = 8, I = 1)
extends tb_blocking_transaction_q_class #(axi4_transaction_class #(.A(A), .N(N), .I(I)));
 
// --------------------------------------------------------------------
//
task automatic
transaction
(
ref T tr_h
);
 
->this.start;
 
// Error: AXI4_ERRS_BRESP_AW: A slave must not give a write response before the write address.
// Spec: section A3.3.1 and figure A3-7.
aw_h.aw_semaphore.get(); // better way to do this???
 
##(tr_h.delay_h.next());
 
cb.bresp <= tr_h.resp;
cb.bid <= tr_h.id;
 
cb.bvalid <= 1;
##1;
 
wait(cb.bready);
##0;
 
$display("^^^ %16.t | %m | slave B transaction |", $time);
b_default();
 
->this.done;
 
endtask: transaction
 
// --------------------------------------------------------------------
//
endclass: b_slave_transaction_class
 
 
// --------------------------------------------------------------------
//
b_slave_transaction_class #(.A(A), .N(N), .I(I)) b_h;
 
class w_slave_transaction_class #(A = 32, N = 8, I = 1)
extends tb_blocking_transaction_q_class #(axi4_transaction_class #(.A(A), .N(N), .I(I)));
 
// --------------------------------------------------------------------
//
task automatic
transaction
(
ref T tr_h
);
 
->this.start;
 
tr_h.data_h = new(tr_h.len);
 
foreach(tr_h.payload_h.w[i])
begin
##(tr_h.delay_h.next());
 
cb.wready <= 1;
##1;
 
wait(cb.wvalid);
##0;
 
tr_h.data_h.w[i] <= cb.wdata;
$display("^^^ %16.t | %m | slave W transaction | %d | 0x%016x |", $time, i, cb.wdata);
w_default();
end
 
b_h.put(tr_h);
 
->this.done;
 
endtask: transaction
 
 
// --------------------------------------------------------------------
//
endclass: w_slave_transaction_class
 
 
// --------------------------------------------------------------------
//
ar_slave_transaction_class #(.A(A), .N(N), .I(I)) ar_h;
w_slave_transaction_class #(.A(A), .N(N), .I(I)) w_h;
 
initial
begin
init();
ar_h = new;
ar_h.init();
r_h = new;
r_h.init();
aw_h = new;
aw_h.init();
w_h = new;
w_h.init();
b_h = new;
b_h.init();
end
 
 
// --------------------------------------------------------------------
//
 
endinterface
 
 
/qaz_libs/trunk/axi4_lib/sim/src/legacy/axi4_bfm/axi4_transaction_pkg.sv
0,0 → 1,253
//////////////////////////////////////////////////////////////////////
//// ////
//// 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
 
/qaz_libs/trunk/axi4_lib/sim/src/legacy/axi4_bfm_pkg.sv
0,0 → 1,563
//////////////////////////////////////////////////////////////////////
//// ////
//// 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_bfm_pkg;
 
// --------------------------------------------------------------------
//
import tb_bfm_pkg::*;
import axi4_transaction_pkg::*;
 
 
// --------------------------------------------------------------------
//
class ar_master_transaction_class #(A = 32, N = 8, I = 1)
extends tb_blocking_transaction_q_class #(axi4_transaction_class #(.A(A), .N(N), .I(I)));
 
virtual axi4_if #(.A(A), .N(N), .I(I)) axi4_m;
 
 
//--------------------------------------------------------------------
function new
(
virtual axi4_if #(.A(A), .N(N), .I(I)) axi4_m
);
 
super.new();
this.axi4_m = axi4_m;
 
endfunction: new
 
 
// --------------------------------------------------------------------
//
function void
ar_default;
 
axi4_m.cb_m.araddr <= 'bx;
axi4_m.cb_m.arburst <= 'bx;
axi4_m.cb_m.arcache <= 'bx;
axi4_m.cb_m.arid <= 'bx;
axi4_m.cb_m.arlen <= 'bx;
axi4_m.cb_m.arlock <= 'bx;
axi4_m.cb_m.arprot <= 'bx;
axi4_m.cb_m.arqos <= 'bx;
axi4_m.cb_m.arregion <= 'bx;
axi4_m.cb_m.arsize <= 'bx;
axi4_m.cb_m.arvalid <= 0;
 
endfunction: ar_default
 
 
// --------------------------------------------------------------------
//
task automatic
transaction
(
ref T tr_h
);
 
->this.start;
 
repeat(tr_h.delay_h.next()) @(axi4_m.cb_m);
 
axi4_m.cb_m.araddr <= tr_h.addr;
axi4_m.cb_m.arid <= tr_h.id;
axi4_m.cb_m.arlen <= tr_h.len;
axi4_m.cb_m.arsize <= tr_h.size;
 
axi4_m.cb_m.arburst <= tr_h.burst;
axi4_m.cb_m.arcache <= tr_h.cache;
axi4_m.cb_m.arlock <= tr_h.lock;
axi4_m.cb_m.arprot <= tr_h.prot;
axi4_m.cb_m.arqos <= tr_h.qos;
axi4_m.cb_m.arregion <= tr_h.region;
axi4_m.cb_m.arvalid <= 1;
 
$display("^^^ %16.t | %m | master AR transaction @ 0x%08x |", $time, tr_h.addr);
 
repeat(1) @(axi4_m.cb_m);
wait(axi4_m.cb_m.arready);
 
axi4_m.zero_cycle_delay();
ar_default();
 
->this.done;
 
endtask: transaction
 
 
// --------------------------------------------------------------------
//
endclass: ar_master_transaction_class
 
 
// --------------------------------------------------------------------
//
class r_master_transaction_class #(A = 32, N = 8, I = 1)
extends tb_blocking_transaction_q_class #(axi4_transaction_class #(.A(A), .N(N), .I(I)));
 
virtual axi4_if #(.A(A), .N(N), .I(I)) axi4_m;
 
 
//--------------------------------------------------------------------
function new
(
virtual axi4_if #(.A(A), .N(N), .I(I)) axi4_m
);
 
super.new();
this.axi4_m = axi4_m;
 
endfunction: new
 
 
// --------------------------------------------------------------------
//
function void
r_default;
 
axi4_m.cb_m.rready <= 0;
 
endfunction: r_default
 
 
// --------------------------------------------------------------------
//
task automatic
transaction
(
ref T tr_h
);
 
->this.start;
 
tr_h.data_h = new(tr_h.len);
 
foreach(tr_h.payload_h.w[i])
begin
repeat(tr_h.delay_h.next()) @(axi4_m.cb_m);
axi4_m.cb_m.rready <= 1;
repeat(1) @(axi4_m.cb_m);
 
wait(axi4_m.cb_m.rvalid);
axi4_m.zero_cycle_delay();
 
tr_h.data_h.w[i] = axi4_m.cb_m.rdata;
 
$display("^^^ %16.t | %m | master R transaction | %d | 0x%016x |", $time, i, tr_h.data_h.w[i]);
r_default();
end
 
->this.done;
 
endtask: transaction
 
 
// --------------------------------------------------------------------
//
endclass: r_master_transaction_class
 
 
// --------------------------------------------------------------------
//
class aw_master_transaction_class #(A = 32, N = 8, I = 1)
extends tb_blocking_transaction_q_class #(axi4_transaction_class #(.A(A), .N(N), .I(I)));
 
virtual axi4_if #(.A(A), .N(N), .I(I)) axi4_m;
 
 
//--------------------------------------------------------------------
function new
(
virtual axi4_if #(.A(A), .N(N), .I(I)) axi4_m
);
 
super.new();
this.axi4_m = axi4_m;
 
endfunction: new
 
 
// --------------------------------------------------------------------
//
function void
aw_default;
 
axi4_m.cb_m.awaddr <= 'bx;
axi4_m.cb_m.awburst <= 'bx;
axi4_m.cb_m.awcache <= 'bx;
axi4_m.cb_m.awid <= 'bx;
axi4_m.cb_m.awlen <= 'bx;
axi4_m.cb_m.awlock <= 'bx;
axi4_m.cb_m.awprot <= 'bx;
axi4_m.cb_m.awqos <= 'bx;
axi4_m.cb_m.awregion <= 'bx;
axi4_m.cb_m.awsize <= 'bx;
axi4_m.cb_m.awvalid <= 0;
 
endfunction: aw_default
 
// --------------------------------------------------------------------
//
task automatic
transaction
(
ref T tr_h
);
 
->this.start;
 
repeat(tr_h.delay_h.next()) @(axi4_m.cb_m);
 
axi4_m.cb_m.awaddr <= tr_h.addr;
axi4_m.cb_m.awid <= tr_h.id;
axi4_m.cb_m.awlen <= tr_h.len;
axi4_m.cb_m.awsize <= tr_h.size;
 
axi4_m.cb_m.awburst <= tr_h.burst;
axi4_m.cb_m.awcache <= tr_h.cache;
axi4_m.cb_m.awlock <= tr_h.lock;
axi4_m.cb_m.awprot <= tr_h.prot;
axi4_m.cb_m.awqos <= tr_h.qos;
axi4_m.cb_m.awregion <= tr_h.region;
axi4_m.cb_m.awvalid <= 1;
 
$display("^^^ %16.t | %m | master AW transaction @ 0x%08x |", $time, tr_h.addr);
 
repeat(1) @(axi4_m.cb_m);
wait(axi4_m.cb_m.awready);
 
axi4_m.zero_cycle_delay();
aw_default();
 
->this.done;
 
endtask: transaction
 
 
// --------------------------------------------------------------------
//
endclass: aw_master_transaction_class
 
 
// --------------------------------------------------------------------
//
class w_master_transaction_class #(A = 32, N = 8, I = 1)
extends tb_blocking_transaction_q_class #(axi4_transaction_class #(.A(A), .N(N), .I(I)));
 
virtual axi4_if #(.A(A), .N(N), .I(I)) axi4_m;
 
 
//--------------------------------------------------------------------
function new
(
virtual axi4_if #(.A(A), .N(N), .I(I)) axi4_m
);
 
super.new();
this.axi4_m = axi4_m;
 
endfunction: new
 
 
// --------------------------------------------------------------------
//
function void
w_default;
 
axi4_m.cb_m.wdata <= 'bx;
axi4_m.cb_m.wlast <= 'bx;
axi4_m.cb_m.wstrb <= {N{1'b1}};
axi4_m.cb_m.wvalid <= 0;
 
endfunction: w_default
 
 
// --------------------------------------------------------------------
//
task automatic
transaction
(
ref T tr_h
);
 
->this.start;
 
foreach(tr_h.payload_h.w[i])
begin
repeat(tr_h.delay_h.next()) @(axi4_m.cb_m);
 
axi4_m.cb_m.wdata <= tr_h.payload_h.w[i];
// axi4_m.cb_m.wstrb <= tr_h.strb; // need to fix
 
if(i < tr_h.payload_h.w.size - 1)
axi4_m.cb_m.wlast <= 0;
else
axi4_m.cb_m.wlast <= 1;
 
axi4_m.cb_m.wvalid <= 1;
 
repeat(1) @(axi4_m.cb_m);
wait(axi4_m.cb_m.wready);
 
axi4_m.zero_cycle_delay();
$display("^^^ %16.t | %m | master W transaction | %d | 0x%016x |", $time, i, tr_h.payload_h.w[i]);
w_default();
end
 
->this.done;
 
endtask: transaction
 
 
// --------------------------------------------------------------------
//
endclass: w_master_transaction_class
 
 
// --------------------------------------------------------------------
//
class b_master_transaction_class #(A = 32, N = 8, I = 1)
extends tb_blocking_transaction_q_class #(axi4_transaction_class #(.A(A), .N(N), .I(I)));
 
virtual axi4_if #(.A(A), .N(N), .I(I)) axi4_m;
 
 
//--------------------------------------------------------------------
function new
(
virtual axi4_if #(.A(A), .N(N), .I(I)) axi4_m
);
 
super.new();
this.axi4_m = axi4_m;
 
endfunction: new
 
 
// --------------------------------------------------------------------
//
function void
b_default;
 
axi4_m.cb_m.bready <= 0;
 
endfunction: b_default
 
 
// --------------------------------------------------------------------
//
task automatic
transaction
(
ref T tr_h
);
 
->this.start;
 
repeat(tr_h.delay_h.next()) @(axi4_m.cb_m);
axi4_m.cb_m.bready <= 1;
repeat(1) @(axi4_m.cb_m);
 
wait(axi4_m.cb_m.bvalid);
axi4_m.zero_cycle_delay();
 
$display("^^^ %16.t | %m | master B transaction | 0x%x |", $time, axi4_m.cb_m.bresp);
b_default();
 
->this.done;
 
endtask: transaction
 
 
// --------------------------------------------------------------------
//
endclass: b_master_transaction_class
 
 
// --------------------------------------------------------------------
//
class axi4_master_bfm_class #(A = 32, N = 8, I = 1);
 
ar_master_transaction_class #(.A(A), .N(N), .I(I)) ar_h;
r_master_transaction_class #(.A(A), .N(N), .I(I)) r_h;
aw_master_transaction_class #(.A(A), .N(N), .I(I)) aw_h;
w_master_transaction_class #(.A(A), .N(N), .I(I)) w_h;
b_master_transaction_class #(.A(A), .N(N), .I(I)) b_h;
 
axi4_transaction_class tr_h;
virtual axi4_if #(.A(A), .N(N), .I(I)) axi4_m;
 
 
//--------------------------------------------------------------------
function new
(
virtual axi4_if #(.A(A), .N(N), .I(I)) axi4_m
);
 
this.axi4_m = axi4_m;
 
ar_h = new(axi4_m);
r_h = new(axi4_m);
aw_h = new(axi4_m);
w_h = new(axi4_m);
b_h = new(axi4_m);
ar_h.init();
ar_h.ar_default();
 
r_h.init();
r_h.r_default();
 
aw_h.init();
aw_h.aw_default();
 
w_h.init();
w_h.w_default();
 
b_h.init();
b_h.b_default();
 
endfunction: new
 
 
// --------------------------------------------------------------------
//
function void
init;
 
endfunction: init
 
 
// --------------------------------------------------------------------
//
task
basic_read
(
input logic [(A-1):0] araddr,
input logic [7:0] arlen,
output logic [(8*N)-1:0] data[],
output logic [1:0] rresp
);
 
this.tr_h = new;
this.tr_h.basic_read(araddr, arlen);
 
ar_h.put(tr_h);
r_h.put(tr_h);
 
@(r_h.done);
data = tr_h.data_h.w;
rresp = tr_h.resp;
 
endtask: basic_read
 
// --------------------------------------------------------------------
//
task
basic_random_read_burst
(
output logic [(8*N)-1:0] data[],
output logic [1:0] rresp
);
 
this.tr_h = new;
this.tr_h.basic_random_burst;
 
ar_h.put(tr_h);
r_h.put(tr_h);
 
@(r_h.done);
data = tr_h.data_h.w;
rresp = tr_h.resp;
 
endtask: basic_random_read_burst
 
 
// --------------------------------------------------------------------
//
task
basic_write
(
input logic [(A-1):0] awaddr,
input logic [7:0] awlen,
input logic [(8*N)-1:0] data[],
output logic [1:0] bresp
);
 
this.tr_h = new;
this.tr_h.basic_write(awaddr, awlen);
 
foreach(this.tr_h.payload_h.w[i])
this.tr_h.payload_h.w[i] = data[i];
 
aw_h.put(tr_h);
w_h.put(tr_h);
b_h.put(tr_h);
 
@(b_h.done);
bresp = tr_h.resp;
 
endtask: basic_write
 
// --------------------------------------------------------------------
//
task
basic_random_write_burst
(
output logic [1:0] bresp
);
 
this.tr_h = new;
this.tr_h.basic_random_burst;
 
aw_h.put(tr_h);
w_h.put(tr_h);
b_h.put(tr_h);
 
@(b_h.done);
bresp = tr_h.resp;
 
endtask: basic_random_write_burst
 
 
// --------------------------------------------------------------------
//
endclass: axi4_master_bfm_class
// --------------------------------------------------------------------
//
endpackage: axi4_bfm_pkg
 
 
/qaz_libs/trunk/axi4_lib/sim/src/legacy/axi4_models/axi4_arbiter_pkg.sv
0,0 → 1,474
//////////////////////////////////////////////////////////////////////
//// ////
//// 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_arbiter_pkg;
 
// --------------------------------------------------------------------
//
import axi4_models_pkg::*;
import bfm_pkg::*;
import logger_pkg::*;
 
 
// --------------------------------------------------------------------
//
virtual class base_request_class #(A, N, I);
 
string kind;
int id = -1;
 
//--------------------------------------------------------------------
//
pure virtual function void write_ax_if(axi4_channel_if_class #(A, N, I) channel);
pure virtual function void copy_ax_if(axi4_channel_if_class #(A, N, I) channel);
 
 
// --------------------------------------------------------------------
//
endclass: base_request_class
 
 
// --------------------------------------------------------------------
//
class write_request_class #(A, N, I)
extends base_request_class #(A, N, I);
 
logic [(A-1):0] awaddr;
logic [1:0] awburst;
logic [(I-1):0] awid;
logic [7:0] awlen;
logic [2:0] awsize;
logic [3:0] awcache;
logic awlock;
logic [2:0] awprot;
logic [3:0] awqos;
logic [3:0] awregion;
 
 
// --------------------------------------------------------------------
//
function void write_ax_if(axi4_channel_if_class #(A, N, I) channel);
axi4_aw_if_class #(A, N, I) aw_if_h;
$cast(aw_if_h, channel);
aw_if_h.awaddr = awaddr;
aw_if_h.awburst = awburst;
aw_if_h.awid = awid;
aw_if_h.awlen = awlen;
aw_if_h.awsize = awsize;
aw_if_h.awcache = awcache;
aw_if_h.awlock = awlock;
aw_if_h.awprot = awprot;
aw_if_h.awqos = awqos;
aw_if_h.awregion = awregion;
endfunction: write_ax_if
 
 
// --------------------------------------------------------------------
//
function void copy_ax_if(axi4_channel_if_class #(A, N, I) channel);
axi4_aw_if_class #(A, N, I) aw_if_h;
$cast(aw_if_h, channel);
awaddr = aw_if_h.awaddr;
awburst = aw_if_h.awburst;
awid = aw_if_h.awid;
awlen = aw_if_h.awlen;
awsize = aw_if_h.awsize;
awcache = aw_if_h.awcache;
awlock = aw_if_h.awlock;
awprot = aw_if_h.awprot;
awqos = aw_if_h.awqos;
awregion = aw_if_h.awregion;
endfunction: copy_ax_if
 
 
//--------------------------------------------------------------------
function new(int id);
super.new;
this.kind = "WRITE";
this.id = id;
endfunction: new
 
 
// --------------------------------------------------------------------
//
endclass: write_request_class
 
 
// --------------------------------------------------------------------
//
class read_request_class #(A, N, I)
extends base_request_class #(A, N, I);
 
logic [(A-1):0] araddr;
logic [1:0] arburst;
logic [(I-1):0] arid;
logic [7:0] arlen;
logic [2:0] arsize;
logic [3:0] arcache;
logic arlock;
logic [2:0] arprot;
logic [3:0] arqos;
logic [3:0] arregion;
 
// --------------------------------------------------------------------
//
function void write_ax_if(axi4_channel_if_class #(A, N, I) channel);
axi4_ar_if_class #(A, N, I) ar_if_h;
$cast(ar_if_h, channel);
ar_if_h.araddr = araddr;
ar_if_h.arburst = arburst;
ar_if_h.arid = arid;
ar_if_h.arlen = arlen;
ar_if_h.arsize = arsize;
ar_if_h.arcache = arcache;
ar_if_h.arlock = arlock;
ar_if_h.arprot = arprot;
ar_if_h.arqos = arqos;
ar_if_h.arregion = arregion;
endfunction: write_ax_if
 
 
// --------------------------------------------------------------------
//
function void copy_ax_if(axi4_channel_if_class #(A, N, I) channel);
axi4_ar_if_class #(A, N, I) ar_if_h;
$cast(ar_if_h, channel);
araddr = ar_if_h.araddr;
arburst = ar_if_h.arburst;
arid = ar_if_h.arid;
arlen = ar_if_h.arlen;
arsize = ar_if_h.arsize;
arcache = ar_if_h.arcache;
arlock = ar_if_h.arlock;
arprot = ar_if_h.arprot;
arqos = ar_if_h.arqos;
arregion = ar_if_h.arregion;
endfunction: copy_ax_if
 
 
//--------------------------------------------------------------------
function new(int id);
super.new;
this.kind = "READ";
this.id = id;
endfunction: new
 
 
// --------------------------------------------------------------------
//
endclass: read_request_class
 
 
// --------------------------------------------------------------------
//
class requester_class #(A, N, I)
extends axi4_slave_model_class #(A, N, I);
 
mailbox #(base_request_class #(A, N, I)) q;
semaphore read_done;
semaphore write_done;
int id = -1;
logger_class log;
 
 
// --------------------------------------------------------------------
//
task automatic run_read_interface;
read_request_class #(A, N, I) r_req_h;
read_done = new;
forever
@(axi4_s.cb_s)
begin
ar_q_h.q.get(ar_if_h);
log.debug($sformatf("%m | start"));
log.debug($sformatf("%m | araddr = 0x%h", ar_if_h.araddr));
log.debug($sformatf("%m | arlen = 0x%h", ar_if_h.arlen));
r_req_h = new(id);
r_req_h.copy_ax_if(ar_if_h);
q.put(r_req_h);
read_done.get();
log.debug($sformatf("%m | done"));
end
endtask: run_read_interface
 
 
// --------------------------------------------------------------------
//
task run_write_interface;
write_request_class #(A, N, I) w_req_h;
write_done = new;
forever
@(axi4_s.cb_s)
begin
aw_q_h.q.get(aw_if_h);
log.debug($sformatf("%m | start"));
log.debug($sformatf("%m | awaddr = 0x%h", aw_if_h.awaddr));
log.debug($sformatf("%m | awlen = 0x%h", aw_if_h.awlen));
w_req_h = new(id);
w_req_h.copy_ax_if(aw_if_h);
q.put(w_req_h);
write_done.get();
log.debug($sformatf("%m | done"));
end
endtask: run_write_interface
 
 
// --------------------------------------------------------------------
//
task run_model;
wait(axi4_s.cb_s.aresetn);
axi4_s.zero_cycle_delay();
 
aw_q_h.run_q();
w_q_h.run_q();
b_q_h.run_q();
ar_q_h.run_q();
r_q_h.run_q();
 
fork
run_read_interface();
join_none
 
fork
run_write_interface();
join_none
 
endtask: run_model
 
 
//--------------------------------------------------------------------
function new(int id, virtual axi4_if #(.A(A), .N(N), .I(I)) axi4_s);
super.new(axi4_s);
this.aw_q_h = new(axi4_s, 2);
this.w_q_h = new(axi4_s, 16);
this.b_q_h = new(axi4_s, 2);
this.ar_q_h = new(axi4_s, 2);
this.r_q_h = new(axi4_s, 16);
this.id = id;
this.q = new(1);
this.log = new();
endfunction: new
 
 
// --------------------------------------------------------------------
//
endclass: requester_class
 
 
// --------------------------------------------------------------------
//
class axi4_granter_class #(A, N, I)
extends axi4_master_model_class #(A, N, I);
 
logger_class log;
 
 
// --------------------------------------------------------------------
//
task run_model;
wait(axi4_m.cb_s.aresetn);
axi4_m.zero_cycle_delay();
 
aw_q_h.run_q();
w_q_h.run_q();
b_q_h.run_q();
ar_q_h.run_q();
r_q_h.run_q();
endtask: run_model
 
 
//--------------------------------------------------------------------
function new(virtual axi4_if #(.A(A), .N(N), .I(I)) axi4_m);
super.new(axi4_m);
this.aw_q_h = new(axi4_m, 2);
this.w_q_h = new(axi4_m, 16);
this.b_q_h = new(axi4_m, 2);
this.ar_q_h = new(axi4_m, 2);
this.r_q_h = new(axi4_m, 16);
this.log = new();
endfunction: new
 
 
// --------------------------------------------------------------------
//
endclass: axi4_granter_class
 
 
// --------------------------------------------------------------------
//
class axi4_arbiter_class #(A, N, I);
 
axi4_granter_class #(A, N, I) g_h;
requester_class #(A, N, I) r_h[];
mailbox #(int) grant;
int count = -1;
int current = 0, previous;
logger_class log;
 
 
// --------------------------------------------------------------------
//
task automatic do_read(requester_class #(A, N, I) r_h);
int id;
read_request_class #(A, N, I) r_req_h;
base_request_class #(A, N, I) request;
log.debug($sformatf("%m | read grant for %d", r_h.id));
r_h.q.get(request);
$cast(r_req_h, request);
 
g_h.ar_if_h = new(g_h.axi4_m);
r_req_h.write_ax_if(g_h.ar_if_h);
g_h.ar_q_h.q.put(g_h.ar_if_h);
 
for(int i = 0; i < r_h.ar_if_h.arlen + 1; i++)
begin
g_h.r_if_h = new(g_h.axi4_m);
r_h.r_if_h = new(r_h.axi4_s);
g_h.r_q_h.q.get(g_h.r_if_h);
r_h.r_if_h.copy(g_h.r_if_h);
r_h.r_q_h.q.put(r_h.r_if_h);
@(r_h.axi4_s.cb_s);
end
 
r_h.read_done.put();
grant.get(id);
log.debug($sformatf("%m | read grant for %d done", id));
endtask: do_read
 
 
// --------------------------------------------------------------------
//
task automatic do_write(requester_class #(A, N, I) r_h);
int id;
write_request_class #(A, N, I) w_req_h;
base_request_class #(A, N, I) request;
log.debug($sformatf("%m | write grant for %d", r_h.id));
r_h.q.get(request);
$cast(w_req_h, request);
 
g_h.aw_if_h = new(g_h.axi4_m);
w_req_h.write_ax_if(g_h.aw_if_h);
g_h.aw_q_h.q.put(g_h.aw_if_h);
 
for(int i = 0; i < r_h.aw_if_h.awlen + 1; i++)
begin
r_h.w_if_h = new(r_h.axi4_s);
g_h.w_if_h = new(g_h.axi4_m);
r_h.w_q_h.q.get(r_h.w_if_h);
g_h.w_if_h.copy(r_h.w_if_h);
g_h.w_q_h.q.put(g_h.w_if_h);
@(r_h.axi4_s.cb_s);
end
 
g_h.b_q_h.q.get(g_h.b_if_h);
r_h.b_if_h = new(r_h.axi4_s);
r_h.b_if_h.copy(g_h.b_if_h);
r_h.b_q_h.q.put(r_h.b_if_h);
r_h.write_done.put();
grant.get(id);
log.debug($sformatf("%m | write grant for %d done", id));
endtask: do_write
 
 
// --------------------------------------------------------------------
//
task automatic give_grant(requester_class #(A, N, I) r_h);
base_request_class #(A, N, I) request;
grant.put(r_h.id);
r_h.q.peek(request);
log.debug($sformatf("%m | %d got grant for %s", r_h.id, request.kind));
 
if(request.kind.toupper == "WRITE")
do_write(r_h);
else if(request.kind.toupper == "READ")
do_read(r_h);
else
$stop;
 
current = (current + count + 1) % count;
log.debug($sformatf("%m | new current = %d", current));
endtask: give_grant
 
 
// --------------------------------------------------------------------
//
task automatic do_arbitration;
wait(g_h.axi4_m.cb_m.aresetn);
g_h.axi4_m.zero_cycle_delay();
forever
@(g_h.axi4_m.cb_m)
begin
for(int i = current; i < current + count; i++)
if(r_h[i % count].q.num > 0)
begin
give_grant(r_h[i % count]);
break;
end
end
endtask: do_arbitration
 
 
//--------------------------------------------------------------------
function void debug_enable;
log.debug_enable();
g_h.log.debug_enable();
foreach(r_h[i])
r_h[i].log.debug_enable();
endfunction: debug_enable
 
 
//--------------------------------------------------------------------
function new
(
virtual axi4_if #(A, N, I) axi4_s[],
virtual axi4_if #(.A(A), .N(N), .I(I)) axi4_m
);
this.grant = new(1);
this.g_h = new(axi4_m);
this.count = axi4_s.size;
this.r_h = new[axi4_s.size];
this.log = new;
 
foreach(axi4_s[i])
r_h[i] = new(i, axi4_s[i]);
 
fork
do_arbitration();
join_none
endfunction: new
 
 
// --------------------------------------------------------------------
//
endclass: axi4_arbiter_class
 
 
// --------------------------------------------------------------------
//
endpackage: axi4_arbiter_pkg
 
/qaz_libs/trunk/axi4_lib/sim/src/legacy/axi4_models/axi4_memory_pkg.sv
0,0 → 1,369
//////////////////////////////////////////////////////////////////////
//// ////
//// 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_memory_pkg;
 
// --------------------------------------------------------------------
//
import axi4_models_pkg::*;
import bfm_pkg::*;
import logger_pkg::*;
 
 
// --------------------------------------------------------------------
//
class memory_tr_class #(A, N, I, type WORD_T = byte)
extends transaction_class #(memory_tr_class #(A, N, I));
 
rand int addr;
rand int size;
rand byte data[];
 
constraint default_addr
{
addr[$clog2(N*8)-1:0] == 0;
}
 
constraint default_size
{
size dist {N := 40, [N*2:N*15] := 40, [N*16:N*255] := 20};
}
 
 
//--------------------------------------------------------------------
//
function void init(int addr, int size);
this.data = new[size];
this.addr = addr;
this.size = size;
endfunction: init
 
 
//--------------------------------------------------------------------
//
function void random(int addr, int size);
this.data = new[size];
assert(this.randomize() with
{
this.addr == addr; // why not working?
this.size == size;
});
this.addr = addr;
this.size = size;
endfunction: random
 
 
// --------------------------------------------------------------------
//
task constant(int addr, int size, byte value[]);
init(addr, size);
this.data = new[size];
for(int i = 0; i < size; i += value.size)
foreach(value[k])
data[i + k] = value[k];
endtask: constant
 
 
// --------------------------------------------------------------------
//
task automatic counting(int addr, int count);
byte word[];
int word_size = $bits(WORD_T) / 8; // word size in bytes
init(addr, count * word_size);
for(WORD_T i = 0; i < count; i++)
begin
word = {<< byte{i}};
foreach(word[k])
data[addr + (i * word_size) + k] = word[k];
end
endtask: counting
 
 
// --------------------------------------------------------------------
//
function void copy(TR_T from);
init(from.addr, from.size);
this.data = new[from.size];
foreach(from.data[i])
this.data[i] = from.data[i];
endfunction: copy
 
 
//--------------------------------------------------------------------
function new;
a_word_t_mod_n: assert($bits(WORD_T) % 8 == 0) else $fatal;
endfunction: new
 
 
// --------------------------------------------------------------------
//
endclass: memory_tr_class
 
 
// --------------------------------------------------------------------
//
class axi4_memory_class #(A, N, I, type WORD_T = byte)
extends axi4_slave_model_class #(.A(A), .N(N), .I(I));
 
logger_class log;
byte memory [*];
 
 
// --------------------------------------------------------------------
//
function void clear_all;
memory.delete;
endfunction: clear_all
 
 
// --------------------------------------------------------------------
//
function void compare(memory_tr_class #(A, N, I, WORD_T) tr_h);
foreach(tr_h.data[i])
if(memory.exists(tr_h.addr + i))
begin
if(memory[tr_h.addr + i] != tr_h.data[i])
log.error($sformatf("%m | 1 memory[0x%8.h] = 0x%2.h | 0x%2.h", tr_h.addr + i, memory[tr_h.addr + i], tr_h.data[i]));
end
else
log.error($sformatf("%m | 2 memory[0x%8.h] = 0x%2.h | 0x%2.h", tr_h.addr + i, 'bx, tr_h.data[i]));
endfunction: compare
 
 
// --------------------------------------------------------------------
//
task display_memory(int offset, int count);
for(int i = 0; i < count; i++)
if(memory.exists(offset + i))
$display("^^^ %16.t | %m | memory[0x%8.x] = 0x%2.x", $time, offset + i, memory[offset + i]);
else
$display("^^^ %16.t | %m | memory[0x%8.x] = 0x%2.x", $time, offset + i, 8'hxx);
endtask: display_memory
 
 
// --------------------------------------------------------------------
//
task constant_fill(int offset, int count, int value);
for(int i = 0; i < count; i++)
memory[offset + i] = value;
endtask: constant_fill
 
 
// --------------------------------------------------------------------
//
task counting_fill(int offset, int count);
for(int i = 0; i < count; i++)
memory[offset + i] = i;
endtask: counting_fill
 
 
// --------------------------------------------------------------------
//
task dump_words(int offset, ref byte data[]);
foreach(data[i])
if(memory.exists(offset + i))
data[i] = memory[offset + i];
else
data[i] = 'bx;
endtask: dump_words
 
 
// --------------------------------------------------------------------
//
function reg [7:0] dump(int offset);
if(memory.exists(offset))
return(memory[offset]);
else
return('bx);
endfunction: dump
 
 
// --------------------------------------------------------------------
//
task load_words(int offset, byte data[]);
foreach(data[i])
memory[offset + i] = data[i];
endtask: load_words
 
 
// --------------------------------------------------------------------
//
task load(int offset, reg [7:0] data);
memory[offset] = data;
endtask: load
 
 
// --------------------------------------------------------------------
//
task run_read_interface;
int result;
logic [9:0] delay = 0;
int memory_addr;
 
forever
@(axi4_s.cb_s)
begin
result = ar_q_h.q.try_peek(ar_if_h);
if(result != 0)
begin
log.debug($sformatf("araddr = 0x%h", ar_if_h.araddr));
log.debug($sformatf("arlen = 0x%h", ar_if_h.arlen));
delay = $urandom_range(9, 0);
if(delay > 6)
repeat($urandom_range(50, 1))
@(axi4_s.cb_s);
 
for(int i = 0; i < ar_if_h.arlen + 1; i++)
begin
memory_addr = ar_if_h.araddr + (i * (2 ** ar_if_h.arsize));
for(int i = 0; i < ar_if_h.N; i++)
begin
if(memory.exists(memory_addr))
r_if_h.rdata[i*8 +: 8] = memory[memory_addr];
else
r_if_h.rdata[i*8 +: 8] = 8'hxx;
 
memory_addr++;
end
log.debug($sformatf("rdata = 0x%h", r_if_h.rdata));
 
if(i == ar_if_h.arlen)
begin
ar_q_h.q.get(ar_if_h);
r_if_h.rlast = 1;
end
else
r_if_h.rlast = 0;
 
r_if_h.rid = 0;
r_if_h.rresp = 0;
 
r_q_h.q.put(r_if_h);
r_if_h = new(axi4_s);
 
@(axi4_s.cb_s);
end
r_if_h.rlast = 0;
end
end
endtask: run_read_interface
 
 
// --------------------------------------------------------------------
//
task run_write_interface;
 
int result;
logic [9:0] delay = 0;
int memory_addr;
 
forever
@(axi4_s.cb_s)
begin
result = aw_q_h.q.try_peek(aw_if_h);
if(result != 0)
begin
memory_addr = aw_if_h.awaddr;
log.debug($sformatf("awaddr = 0x%h", aw_if_h.awaddr));
 
delay = $urandom_range(9, 0);
if(delay > 6)
repeat($urandom_range(8, 1))
@(axi4_s.cb_s);
 
for(int i = 0; i < aw_if_h.awlen + 1; i++)
begin
w_q_h.q.get(w_if_h);
log.debug($sformatf("wdata = 0x%h", w_if_h.wdata));
for(int k = 0; k < aw_if_h.N; k++)
begin
memory[memory_addr] = w_if_h.wdata[k*8 +: 8];
memory_addr++;
end
 
if(i == aw_if_h.awlen)
begin
b_if_h.bresp = 0;
b_if_h.bid = aw_if_h.awid;
b_q_h.q.put(b_if_h);
b_if_h = new(axi4_s);
aw_q_h.q.get(aw_if_h);
end
 
@(axi4_s.cb_s);
end
end
end
 
endtask: run_write_interface
 
 
// --------------------------------------------------------------------
//
task run_model;
wait(axi4_s.cb_s.aresetn);
axi4_s.zero_cycle_delay();
 
aw_q_h.run_q();
w_q_h.run_q();
b_q_h.run_q();
ar_q_h.run_q();
r_q_h.run_q();
 
fork
run_write_interface();
join_none
 
fork
run_read_interface();
join_none
endtask: run_model
 
 
//--------------------------------------------------------------------
function new(virtual axi4_if #(.A(A), .N(N), .I(I)) axi4_s);
super.new(axi4_s);
a_word_t_mod_n: assert($bits(WORD_T) % 8 == 0) else $fatal;
this.aw_q_h = new(axi4_s, 2);
this.w_q_h = new(axi4_s, 16);
this.b_q_h = new(axi4_s, 2);
this.ar_q_h = new(axi4_s, 2);
this.r_q_h = new(axi4_s, 16);
this.log = new();
endfunction: new
 
 
// --------------------------------------------------------------------
//
endclass: axi4_memory_class
 
 
// --------------------------------------------------------------------
//
endpackage: axi4_memory_pkg
 
/qaz_libs/trunk/axi4_lib/sim/src/legacy/axi4_models/axi4_models_pkg.sv
0,0 → 1,822
//////////////////////////////////////////////////////////////////////
//// ////
//// 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_models_pkg;
 
// --------------------------------------------------------------------
//
virtual class axi4_channel_if_class #(A, N, I);
 
virtual axi4_if #(A, N, I) axi4_bus;
event valid;
 
 
// --------------------------------------------------------------------
//
pure virtual function void set_master_default;
pure virtual function void set_slave_default;
pure virtual function void copy(axi4_channel_if_class #(A, N, I) from);
pure virtual function void copy_if;
pure virtual function void drive_if;
pure virtual function void set_ready(bit value);
pure virtual function bit is_valid;
pure virtual function void set_valid(bit value);
pure virtual function bit is_ready;
pure virtual function bit is_transfer;
 
 
//--------------------------------------------------------------------
function new(virtual axi4_if #(A, N, I) axi4_bus);
this.axi4_bus = axi4_bus;
endfunction: new
 
 
// --------------------------------------------------------------------
//
endclass: axi4_channel_if_class
 
 
// --------------------------------------------------------------------
//
class axi4_channel_sink_q_class #(A, N, I, type T = logic);
 
virtual axi4_if #(A, N, I) axi4_bus;
T c_if_h;
int q_size;
mailbox #(T) q;
 
 
// --------------------------------------------------------------------
//
function automatic void run_q;
int result;
c_if_h.set_ready(1'b1);
 
fork
forever
@(axi4_bus.cb_s)
begin
if(c_if_h.is_transfer)
begin
result = q.try_put(c_if_h);
if(result == 0)
$error;
 
c_if_h.copy_if();
c_if_h = new(axi4_bus);
end
 
if(q.num >= q_size)
c_if_h.set_ready(1'b0);
else
c_if_h.set_ready(1'b1);
end
join_none
endfunction: run_q
 
 
//--------------------------------------------------------------------
function new( virtual axi4_if #(A, N, I) axi4_bus, int q_size);
this.axi4_bus = axi4_bus;
this.q_size = q_size;
this.q = new(q_size);
this.c_if_h = new(axi4_bus);
endfunction: new
 
 
// --------------------------------------------------------------------
//
endclass: axi4_channel_sink_q_class
 
 
// --------------------------------------------------------------------
//
class axi4_channel_source_q_class #(A, N, I, type T = logic);
 
virtual axi4_if #(A, N, I) axi4_bus;
T c_if_h;
int q_size;
mailbox #(T) q;
 
 
// --------------------------------------------------------------------
//
function automatic void run_q;
int result;
c_if_h.set_valid(1'b0);
 
fork
forever
@(axi4_bus.cb_s)
begin
if(c_if_h.is_transfer)
begin
result = q.try_get(c_if_h);
if(result == 0)
$stop;
end
 
result = q.try_peek(c_if_h);
if(result == 0)
c_if_h.set_valid(1'b0);
else
begin
c_if_h.set_valid(1'b1);
c_if_h.drive_if();
end
end
join_none
endfunction: run_q
 
 
//--------------------------------------------------------------------
function new(virtual axi4_if #(A, N, I) axi4_bus, int q_size);
this.axi4_bus = axi4_bus;
this.q_size = q_size;
this.q = new(q_size);
this.c_if_h = new(axi4_bus);
endfunction: new
 
 
// --------------------------------------------------------------------
//
endclass: axi4_channel_source_q_class
 
 
// --------------------------------------------------------------------
//
class axi4_aw_if_class #(A, N, I)
extends axi4_channel_if_class #(A, N, I);
 
logic [(A-1):0] awaddr;
logic [1:0] awburst;
logic [(I-1):0] awid;
logic [7:0] awlen;
logic [2:0] awsize;
logic [3:0] awcache;
logic awlock;
logic [2:0] awprot;
logic [3:0] awqos;
logic [3:0] awregion;
 
 
// --------------------------------------------------------------------
//
function void set_master_default;
axi4_bus.cb_m.awvalid <= 0;
endfunction: set_master_default
 
 
// --------------------------------------------------------------------
//
function void set_slave_default;
axi4_bus.cb_s.awready <= 0;
endfunction: set_slave_default
 
 
// --------------------------------------------------------------------
//
function void copy(axi4_channel_if_class #(A, N, I) from);
axi4_aw_if_class #(A, N, I) child;
$cast(child, from);
awaddr = child.awaddr;
awburst = child.awburst;
awid = child.awid;
awlen = child.awlen;
awsize = child.awsize;
awcache = child.awcache;
awlock = child.awlock;
awprot = child.awprot;
awqos = child.awqos;
awregion = child.awregion;
endfunction: copy
 
 
// --------------------------------------------------------------------
//
function void copy_if;
awaddr = axi4_bus.cb_s.awaddr;
awburst = axi4_bus.cb_s.awburst;
awid = axi4_bus.cb_s.awid;
awlen = axi4_bus.cb_s.awlen;
awsize = axi4_bus.cb_s.awsize;
awcache = axi4_bus.cb_s.awcache;
awlock = axi4_bus.cb_s.awlock;
awprot = axi4_bus.cb_s.awprot;
awqos = axi4_bus.cb_s.awqos;
awregion = axi4_bus.cb_s.awregion;
endfunction: copy_if
 
 
// --------------------------------------------------------------------
//
function void drive_if;
axi4_bus.cb_m.awaddr <= awaddr;
axi4_bus.cb_m.awburst <= awburst;
axi4_bus.cb_m.awid <= awid;
axi4_bus.cb_m.awlen <= awlen;
axi4_bus.cb_m.awsize <= awsize;
axi4_bus.cb_m.awcache <= awcache;
axi4_bus.cb_m.awlock <= awlock;
axi4_bus.cb_m.awprot <= awprot;
axi4_bus.cb_m.awqos <= awqos;
axi4_bus.cb_m.awregion <= awregion;
endfunction: drive_if
 
 
// --------------------------------------------------------------------
//
function void set_ready(bit value);
axi4_bus.cb_s.awready <= value;
endfunction: set_ready
 
 
// --------------------------------------------------------------------
//
function bit is_valid;
return(axi4_bus.cb_s.awvalid);
endfunction: is_valid
 
 
// --------------------------------------------------------------------
//
function void set_valid(bit value);
axi4_bus.cb_m.awvalid <= value;
endfunction: set_valid
 
 
// --------------------------------------------------------------------
//
function bit is_ready;
return(axi4_bus.cb_m.awready);
endfunction: is_ready
 
 
// --------------------------------------------------------------------
//
function bit is_transfer;
return(axi4_bus.cb_m.awready & axi4_bus.cb_s.awvalid);
endfunction: is_transfer
 
 
//--------------------------------------------------------------------
function new(virtual axi4_if #(A, N, I) axi4_bus);
super.new(axi4_bus);
endfunction: new
 
// --------------------------------------------------------------------
//
endclass: axi4_aw_if_class
 
 
// --------------------------------------------------------------------
//
class axi4_ar_if_class #(A, N, I)
extends axi4_channel_if_class #(A, N, I);
 
logic [(A-1):0] araddr;
logic [1:0] arburst;
logic [(I-1):0] arid;
logic [7:0] arlen;
logic [2:0] arsize;
logic [3:0] arcache;
logic arlock;
logic [2:0] arprot;
logic [3:0] arqos;
logic [3:0] arregion;
 
 
// --------------------------------------------------------------------
//
virtual function void set_master_default;
axi4_bus.cb_m.arvalid <= 0;
endfunction: set_master_default
 
 
// --------------------------------------------------------------------
//
virtual function void set_slave_default;
axi4_bus.cb_s.arready <= 0;
endfunction: set_slave_default
 
 
// --------------------------------------------------------------------
//
virtual function void copy(axi4_channel_if_class #(A, N, I) from);
axi4_ar_if_class #(A, N, I) child;
$cast(child, from);
araddr = child.araddr;
arburst = child.arburst;
arid = child.arid;
arlen = child.arlen;
arsize = child.arsize;
arcache = child.arcache;
arlock = child.arlock;
arprot = child.arprot;
arqos = child.arqos;
arregion = child.arregion;
endfunction: copy
 
 
// --------------------------------------------------------------------
//
virtual function void copy_if;
araddr = axi4_bus.cb_s.araddr;
arburst = axi4_bus.cb_s.arburst;
arid = axi4_bus.cb_s.arid;
arlen = axi4_bus.cb_s.arlen;
arsize = axi4_bus.cb_s.arsize;
arcache = axi4_bus.cb_s.arcache;
arlock = axi4_bus.cb_s.arlock;
arprot = axi4_bus.cb_s.arprot;
arqos = axi4_bus.cb_s.arqos;
arregion = axi4_bus.cb_s.arregion;
endfunction: copy_if
 
 
// --------------------------------------------------------------------
//
virtual function void drive_if;
axi4_bus.cb_m.araddr <= araddr;
axi4_bus.cb_m.arburst <= arburst;
axi4_bus.cb_m.arid <= arid;
axi4_bus.cb_m.arlen <= arlen;
axi4_bus.cb_m.arsize <= arsize;
axi4_bus.cb_m.arcache <= arcache;
axi4_bus.cb_m.arlock <= arlock;
axi4_bus.cb_m.arprot <= arprot;
axi4_bus.cb_m.arqos <= arqos;
axi4_bus.cb_m.arregion <= arregion;
endfunction: drive_if
 
 
// --------------------------------------------------------------------
//
virtual function void set_ready(bit value);
axi4_bus.cb_s.arready <= value;
endfunction: set_ready
 
 
// --------------------------------------------------------------------
//
virtual function bit is_valid;
return(axi4_bus.cb_s.arvalid);
endfunction: is_valid
 
 
// --------------------------------------------------------------------
//
function void set_valid(bit value);
axi4_bus.cb_m.arvalid <= value;
endfunction: set_valid
 
 
// --------------------------------------------------------------------
//
function bit is_ready;
return(axi4_bus.cb_m.arready);
endfunction: is_ready
 
 
// --------------------------------------------------------------------
//
function bit is_transfer;
return(axi4_bus.cb_m.arready & axi4_bus.cb_s.arvalid);
endfunction: is_transfer
 
 
//--------------------------------------------------------------------
function new(virtual axi4_if #(A, N, I) axi4_bus);
super.new(axi4_bus);
endfunction: new
 
 
// --------------------------------------------------------------------
//
endclass: axi4_ar_if_class
 
 
// --------------------------------------------------------------------
//
class axi4_w_if_class #(A, N, I)
extends axi4_channel_if_class #(A, N, I);
 
logic [(8*N)-1:0] wdata;
logic [(I-1):0] wid;
logic wlast;
logic [N-1:0] wstrb;
 
 
// --------------------------------------------------------------------
//
function void set_master_default;
axi4_bus.cb_m.wvalid <= 0;
endfunction: set_master_default
 
 
// --------------------------------------------------------------------
//
function void set_slave_default;
axi4_bus.cb_s.wready <= 0;
endfunction: set_slave_default
 
 
// --------------------------------------------------------------------
//
function void copy(axi4_channel_if_class #(A, N, I) from);
axi4_w_if_class #(A, N, I) child;
$cast(child, from);
wdata = child.wdata;
wid = child.wid;
wlast = child.wlast;
wstrb = child.wstrb;
endfunction: copy
 
 
// --------------------------------------------------------------------
//
function void copy_if;
wdata = axi4_bus.cb_s.wdata;
wid = axi4_bus.cb_s.wid;
wlast = axi4_bus.cb_s.wlast;
wstrb = axi4_bus.cb_s.wstrb;
endfunction: copy_if
 
 
// --------------------------------------------------------------------
//
function void drive_if;
axi4_bus.cb_m.wdata <= wdata;
axi4_bus.cb_m.wid <= wid;
axi4_bus.cb_m.wlast <= wlast;
axi4_bus.cb_m.wstrb <= wstrb;
endfunction: drive_if
 
 
// --------------------------------------------------------------------
//
function void set_ready(bit value);
axi4_bus.cb_s.wready <= value;
endfunction: set_ready
 
 
// --------------------------------------------------------------------
//
function bit is_valid;
return(axi4_bus.cb_s.wvalid);
endfunction: is_valid
 
 
// --------------------------------------------------------------------
//
function void set_valid(bit value);
axi4_bus.cb_m.wvalid <= value;
endfunction: set_valid
 
 
// --------------------------------------------------------------------
//
function bit is_ready;
return(axi4_bus.cb_m.wready);
endfunction: is_ready
 
 
// --------------------------------------------------------------------
//
function bit is_transfer;
return(axi4_bus.cb_m.wready & axi4_bus.cb_s.wvalid);
endfunction: is_transfer
 
 
//--------------------------------------------------------------------
function new(virtual axi4_if #(A, N, I) axi4_bus);
super.new(axi4_bus);
endfunction: new
 
// --------------------------------------------------------------------
//
endclass: axi4_w_if_class
 
 
// --------------------------------------------------------------------
//
class axi4_b_if_class #(A, N, I)
extends axi4_channel_if_class #(A, N, I);
 
logic [(I-1):0] bid;
logic [1:0] bresp;
 
 
// --------------------------------------------------------------------
//
function void set_master_default;
axi4_bus.cb_m.bready <= 0;
endfunction: set_master_default
 
 
// --------------------------------------------------------------------
//
function void set_slave_default;
axi4_bus.cb_s.bvalid <= 0;
endfunction: set_slave_default
 
 
// --------------------------------------------------------------------
//
function void copy(axi4_channel_if_class #(A, N, I) from);
axi4_b_if_class #(A, N, I) child;
$cast(child, from);
bid = child.bid;
bresp = child.bresp;
endfunction: copy
 
 
// --------------------------------------------------------------------
//
function void copy_if;
bid = axi4_bus.cb_m.bid;
bresp = axi4_bus.cb_m.bresp;
endfunction: copy_if
 
 
// --------------------------------------------------------------------
//
function void drive_if;
axi4_bus.cb_s.bid <= bid;
axi4_bus.cb_s.bresp <= bresp;
endfunction: drive_if
 
 
// --------------------------------------------------------------------
//
function void set_ready(bit value);
axi4_bus.cb_m.bready <= value;
endfunction: set_ready
 
 
// --------------------------------------------------------------------
//
function bit is_valid;
return(axi4_bus.cb_m.bvalid);
endfunction: is_valid
 
 
// --------------------------------------------------------------------
//
function void set_valid(bit value);
axi4_bus.cb_s.bvalid <= value;
endfunction: set_valid
 
 
// --------------------------------------------------------------------
//
function bit is_ready;
return(axi4_bus.cb_s.bready);
endfunction: is_ready
 
 
// --------------------------------------------------------------------
//
function bit is_transfer;
return(axi4_bus.cb_s.bready & axi4_bus.cb_m.bvalid);
endfunction: is_transfer
 
 
//--------------------------------------------------------------------
function new(virtual axi4_if #(A, N, I) axi4_bus);
super.new(axi4_bus);
endfunction: new
 
// --------------------------------------------------------------------
//
endclass: axi4_b_if_class
 
// --------------------------------------------------------------------
//
class axi4_r_if_class #(A, N, I)
extends axi4_channel_if_class #(A, N, I);
 
logic [(8*N)-1:0] rdata;
logic [(I-1):0] rid;
logic rlast;
logic [1:0] rresp;
 
 
// --------------------------------------------------------------------
//
function void set_master_default;
axi4_bus.cb_m.rready <= 0;
endfunction: set_master_default
 
 
// --------------------------------------------------------------------
//
function void set_slave_default;
axi4_bus.cb_s.rvalid <= 0;
endfunction: set_slave_default
 
 
// --------------------------------------------------------------------
//
function void copy(axi4_channel_if_class #(A, N, I) from);
axi4_r_if_class #(A, N, I) child;
$cast(child, from);
rdata = child.rdata;
rid = child.rid;
rlast = child.rlast;
rresp = child.rresp;
endfunction: copy
 
 
// --------------------------------------------------------------------
//
function void copy_if;
rdata = axi4_bus.cb_m.rdata;
rid = axi4_bus.cb_m.rid;
rlast = axi4_bus.cb_m.rlast;
rresp = axi4_bus.cb_m.rresp;
endfunction: copy_if
 
 
// --------------------------------------------------------------------
//
function void drive_if;
axi4_bus.cb_s.rdata <= rdata;
axi4_bus.cb_s.rid <= rid;
axi4_bus.cb_s.rlast <= rlast;
axi4_bus.cb_s.rresp <= rresp;
endfunction: drive_if
 
 
// --------------------------------------------------------------------
//
function void set_ready(bit value);
axi4_bus.cb_m.rready <= value;
endfunction: set_ready
 
 
// --------------------------------------------------------------------
//
function bit is_valid;
return(axi4_bus.cb_m.rvalid);
endfunction: is_valid
 
 
// --------------------------------------------------------------------
//
function void set_valid(bit value);
axi4_bus.cb_s.rvalid <= value;
endfunction: set_valid
 
 
// --------------------------------------------------------------------
//
function bit is_ready;
return(axi4_bus.cb_s.rready);
endfunction: is_ready
 
 
// --------------------------------------------------------------------
//
function bit is_transfer;
return(axi4_bus.cb_s.rready & axi4_bus.cb_m.rvalid);
endfunction: is_transfer
 
 
//--------------------------------------------------------------------
function new(virtual axi4_if #(A, N, I) axi4_bus);
super.new(axi4_bus);
endfunction: new
 
// --------------------------------------------------------------------
//
endclass: axi4_r_if_class
 
 
// --------------------------------------------------------------------
//
virtual class axi4_master_model_class #(A, N, I);
 
virtual axi4_if #(A, N, I) axi4_m;
axi4_aw_if_class #(A, N, I) aw_if_h;
axi4_channel_source_q_class #(A, N, I, axi4_aw_if_class #(A, N, I)) aw_q_h;
axi4_w_if_class #(A, N, I) w_if_h;
axi4_channel_source_q_class #(A, N, I, axi4_w_if_class #(A, N, I)) w_q_h;
axi4_b_if_class #(A, N, I) b_if_h;
axi4_channel_sink_q_class #(A, N, I, axi4_b_if_class #(A, N, I)) b_q_h;
axi4_ar_if_class #(A, N, I) ar_if_h;
axi4_channel_source_q_class #(A, N, I, axi4_ar_if_class #(A, N, I)) ar_q_h;
axi4_r_if_class #(A, N, I) r_if_h;
axi4_channel_sink_q_class #(A, N, I, axi4_r_if_class #(A, N, I)) r_q_h;
 
 
// --------------------------------------------------------------------
//
pure virtual task run_model;
 
 
//--------------------------------------------------------------------
function new(virtual axi4_if #(A, N, I) axi4_m);
this.axi4_m = axi4_m;
this.aw_if_h = new(axi4_m);
aw_if_h.set_master_default();
this.w_if_h = new(axi4_m);
w_if_h.set_master_default();
this.b_if_h = new(axi4_m);
b_if_h.set_master_default();
this.ar_if_h = new(axi4_m);
ar_if_h.set_master_default();
this.r_if_h = new(axi4_m);
r_if_h.set_master_default();
 
fork
run_model();
join_none
endfunction: new
 
 
// --------------------------------------------------------------------
//
endclass: axi4_master_model_class
 
 
// --------------------------------------------------------------------
//
virtual class axi4_slave_model_class #(A, N, I);
 
virtual axi4_if #(A, N, I) axi4_s;
axi4_aw_if_class #(A, N, I) aw_if_h;
axi4_channel_sink_q_class #(A, N, I, axi4_aw_if_class #(A, N, I)) aw_q_h;
axi4_w_if_class #(A, N, I) w_if_h;
axi4_channel_sink_q_class #(A, N, I, axi4_w_if_class #(A, N, I)) w_q_h;
axi4_b_if_class #(A, N, I) b_if_h;
axi4_channel_source_q_class #(A, N, I, axi4_b_if_class #(A, N, I)) b_q_h;
axi4_ar_if_class #(A, N, I) ar_if_h;
axi4_channel_sink_q_class #(A, N, I, axi4_ar_if_class #(A, N, I)) ar_q_h;
axi4_r_if_class #(A, N, I) r_if_h;
axi4_channel_source_q_class #(A, N, I, axi4_r_if_class #(A, N, I)) r_q_h;
 
 
// --------------------------------------------------------------------
//
pure virtual task run_model;
 
 
//--------------------------------------------------------------------
function new(virtual axi4_if #(A, N, I) axi4_s);
 
this.axi4_s = axi4_s;
this.aw_if_h = new(axi4_s);
aw_if_h.set_slave_default();
this.w_if_h = new(axi4_s);
w_if_h.set_slave_default();
this.b_if_h = new(axi4_s);
b_if_h.set_slave_default();
this.ar_if_h = new(axi4_s);
ar_if_h.set_slave_default();
this.r_if_h = new(axi4_s);
r_if_h.set_slave_default();
 
fork
run_model();
join_none
endfunction: new
 
 
// --------------------------------------------------------------------
//
endclass: axi4_slave_model_class
 
 
// --------------------------------------------------------------------
//
endpackage: axi4_models_pkg
 
 
/qaz_libs/trunk/axi4_lib/sim/src/legacy/axi4_models/tb_axi4_multi_port_memory.sv
0,0 → 1,89
//////////////////////////////////////////////////////////////////////
//// ////
//// 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 ////
//// ////
//////////////////////////////////////////////////////////////////////
 
module
tb_axi4_multi_port_memory
#(
A = 32, // address bus width
N = 8, // data bus width in bytes
I = 1, // ID width
PORTS,
MAXWAITS = 256,
type WORD_T = byte
)
(
axi4_if axi4_s[PORTS],
 
input aclk,
input aresetn
);
 
// --------------------------------------------------------------------
//
import axis_bfm_pkg::*;
import axi4_memory_pkg::*;
import axi4_arbiter_pkg::*;
 
 
// --------------------------------------------------------------------
//
axi4_if #(.A(A), .N(N), .I(I)) axi4_bus(.*);
 
 
// --------------------------------------------------------------------
//
axi4_arbiter_class #(A, N, I) arb_h;
axi4_memory_class #(A, N, I, WORD_T) m_h;
 
initial
begin
arb_h = new(axi4_s, axi4_bus);
m_h = new(axi4_bus);
end
 
 
// --------------------------------------------------------------------
//
axi4_checker #(.A(A), .N(N), .MAXWAITS(MAXWAITS))
axi4_bus_checker(.axi4_in(axi4_bus));
 
 
// --------------------------------------------------------------------
//
generate
begin: axi4_s_cherkers
for(genvar j = 0; j < PORTS; j++)
axi4_checker #(.A(A), .N(N), .MAXWAITS(MAXWAITS))
axi4_checker_i(.axi4_in(axi4_s[j]));
end
endgenerate
 
 
// --------------------------------------------------------------------
//
endmodule
 
/qaz_libs/trunk/axi4_stream_lib/sim/src/legacy/axis_bfm_pkg.sv
0,0 → 1,220
//////////////////////////////////////////////////////////////////////
//// ////
//// 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
 
/qaz_libs/trunk/axi4_stream_lib/src/axis_if.sv
28,15 → 28,13
 
interface
axis_if
#(
N, // data bus width in bytes
I = 1, // TID width
D = 1, // TDEST width
U = 1 // TUSER width
#( N // data bus width in bytes
, I = 1 // TID width
, D = 1 // TDEST width
, U = 1 // TUSER width
)
(
input aclk,
input aresetn
( input aclk
, input aresetn
);
wire tvalid;
wire tready;
48,10 → 46,10
wire [D-1:0] tdest;
wire [U-1:0] tuser;
 
 
// --------------------------------------------------------------------
// synthesis translate_off
default clocking cb_m @(posedge aclk iff aresetn);
default clocking cb_m @(posedge aclk);
input aresetn;
output tvalid;
input tready;
output tdata;
63,10 → 61,9
output tuser;
endclocking
 
 
// --------------------------------------------------------------------
//
clocking cb_s @(posedge aclk iff aresetn);
clocking cb_s @(posedge aclk);
input aresetn;
input tvalid;
output tready;
input tdata;
80,7 → 77,6
// synthesis translate_on
// --------------------------------------------------------------------
 
 
// --------------------------------------------------------------------
//
`ifdef USE_MOD_PORTS
105,9 → 101,7
output tuser
);
 
 
// --------------------------------------------------------------------
//
modport
slave
(
130,20 → 124,13
);
`endif
 
 
// --------------------------------------------------------------------
// synthesis translate_off
task
zero_cycle_delay;
 
task zero_cycle_delay;
##0;
 
endtask: zero_cycle_delay
// synthesis translate_on
// --------------------------------------------------------------------
 
 
// --------------------------------------------------------------------
//
endinterface: axis_if
 
/qaz_libs/trunk/sim/libs/bfm_packages_verilog/BFM.f
1,7 → 1,4
#
 
${LIB_BASE_DIR}/BFM/src/tb/tb_pkg.sv
${LIB_BASE_DIR}/BFM/src/tb/tb_bfm_pkg.sv
 
${LIB_BASE_DIR}/BFM/src/axis_video_frame/axis_video_frame_bfm_pkg.sv
${LIB_BASE_DIR}/BFM/src/axis_video_frame/avf_agent_class_pkg.sv
 
/qaz_libs/trunk/sim/libs/legacy_bfm_packages_verilog/BFM.f
0,0 → 1,5
#
 
${LIB_BASE_DIR}/BFM/src/axis_video_frame/legacy/axis_video_frame_bfm_pkg.sv
${LIB_BASE_DIR}/BFM/src/axis_video_frame/legacy/avf_agent_class_pkg.sv
 
/qaz_libs/trunk/sim/libs/legacy_bfm_packages_verilog/axi4_models.f
0,0 → 1,5
#
 
${LIB_BASE_DIR}/axi4_lib/sim/src/legacy/axi4_models/axi4_models_pkg.sv
${LIB_BASE_DIR}/axi4_lib/sim/src/legacy/axi4_models/axi4_memory_pkg.sv
${LIB_BASE_DIR}/axi4_lib/sim/src/legacy/axi4_models/axi4_arbiter_pkg.sv
/qaz_libs/trunk/sim/libs/legacy_bfm_packages_verilog/axis_bfm.f
0,0 → 1,9
#
 
${LIB_BASE_DIR}/axi4_stream_lib/sim/src/legacy/axis_bfm_pkg.sv
 
 
 
 
 
 
/qaz_libs/trunk/sim/libs/legacy_sim_verilog/axi4_models.f
0,0 → 1,4
#
 
${LIB_BASE_DIR}/axi4_lib/sim/src/axi4_models/tb_axi4_multi_port_memory.sv
 
/qaz_libs/trunk/sim/libs/sim_verilog/BFM.f
1,15 → 1,5
#
 
# ${LIB_BASE_DIR}/BFM/src/axis_video_frame/avf_agent.sv
# ${LIB_BASE_DIR}/BFM/src/axis_video_frame/avf_rx.sv
# ${LIB_BASE_DIR}/BFM/src/axis_video_frame/avf_tx.sv
 
# ${LIB_BASE_DIR}/BFM/src/clock/clock_checker.v
# ${LIB_BASE_DIR}/BFM/src/clock/clock_mult.v
# ${LIB_BASE_DIR}/BFM/src/clock/recover_clock.v
# ${LIB_BASE_DIR}/BFM/src/clock/tb_programmable_clk.v
 
# ${LIB_BASE_DIR}/BFM/src/tb/rand_delays_c.sv
${LIB_BASE_DIR}/BFM/src/tb/tb_base.sv
${LIB_BASE_DIR}/BFM/src/tb/tb_clk.sv
${LIB_BASE_DIR}/BFM/src/tb/tb_clk_class.sv

powered by: WebSVN 2.1.0

© copyright 1999-2020 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.