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
/qaz_libs/trunk
- from Rev 46 to Rev 47
- ↔ Reverse comparison
Rev 46 → Rev 47
/BFM/src/8b10b/video_frame/vf_8b10b_config.svh
45,11 → 45,13
( int pixels_per_line |
, int lines_per_frame |
, int bits_per_pixel |
, int channel_id = 0 |
, string name = "" |
); |
this.pixels_per_line = pixels_per_line; |
this.lines_per_frame = lines_per_frame; |
this.bits_per_pixel = bits_per_pixel; |
this.channel_id = channel_id; |
this.name = name; |
this.bytes_per_pixel = (bits_per_pixel % 8 == 0) |
? (bits_per_pixel / 8) |
/BFM/src/8b10b/video_frame/vf_8b10b_scoreboard.svh
28,9 → 28,19
class vf_8b10b_scoreboard extends uvm_subscriber #(vf_8b10b_sequence_item); |
`uvm_component_utils(vf_8b10b_scoreboard); |
|
mailbox #(vf_8b10b_sequence_item) frame_buffer; |
video_frame_class channel_buffer[]; |
int channel_count; |
|
// -------------------------------------------------------------------- |
function void init(int channel_count); |
this.channel_count = channel_count; |
endfunction : init |
|
// -------------------------------------------------------------------- |
function new (string name, uvm_component parent); |
super.new(name, parent); |
frame_buffer = new(); |
endfunction : new |
|
// -------------------------------------------------------------------- |
46,12 → 56,31
endfunction : print_video_frame |
|
// -------------------------------------------------------------------- |
|
function void write(vf_8b10b_sequence_item t); |
print_video_frame(t.f_h); |
// print_video_frame(t.f_h); |
if(frame_buffer.try_put(t) == 0) |
`uvm_fatal(get_name(), "Couldn't put to frame_buffer!") |
endfunction : write |
|
// -------------------------------------------------------------------- |
function void gather_channels(vf_8b10b_sequence_item t); |
if(channel_buffer.size() == 0) |
channel_buffer = new[channel_count]; |
|
$display("%p", channel_buffer); |
// if(channel_buffer.find(x) with (x == "")) |
// $display("found null"); |
endfunction : gather_channels |
|
// -------------------------------------------------------------------- |
function void report_phase(uvm_phase phase); |
vf_8b10b_sequence_item t; |
while(frame_buffer.try_get(t)) |
print_video_frame(t.f_h); |
|
gather_channels(t); |
|
// uvm_report_info(get_name(), $sformatf("Matches : %0d", m_matches)); |
// uvm_report_info(get_name(), $sformatf("Mismatches: %0d", m_mismatches)); |
endfunction |
/BFM/src/SPI/spi_agent.svh
0,0 → 1,63
////////////////////////////////////////////////////////////////////// |
//// //// |
//// 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 spi_agent |
extends uvm_agent; |
`uvm_component_utils(spi_agent) |
|
// -------------------------------------------------------------------- |
virtual spi_if vif; |
spi_driver driver_h; |
spi_sequencer sequencer_h; |
// spi_monitor monitor_h; |
|
// -------------------------------------------------------------------- |
virtual function void build_phase(uvm_phase phase); |
// super.build_phase(phase); |
driver_h = spi_driver::type_id::create("driver_h", this); |
// monitor_h = spi_monitor ::type_id::create("monitor_h", this); |
sequencer_h = spi_sequencer::type_id::create("sequencer_h", this); |
|
endfunction |
|
// -------------------------------------------------------------------- |
virtual function void connect_phase(uvm_phase phase); |
// super.connect_phase(phase); |
|
driver_h.vif = vif; |
// monitor_h.vif = vif; |
|
driver_h.seq_item_port.connect(sequencer_h.seq_item_export); |
endfunction |
|
// -------------------------------------------------------------------- |
function new(string name, uvm_component parent); |
super.new(name, parent); |
endfunction |
|
// -------------------------------------------------------------------- |
endclass : spi_agent |
/BFM/src/SPI/spi_driver.svh
0,0 → 1,91
////////////////////////////////////////////////////////////////////// |
//// //// |
//// 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 spi_driver |
extends uvm_driver #(spi_sequence_item); |
`uvm_component_utils(spi_driver) |
|
// -------------------------------------------------------------------- |
virtual spi_if vif; |
|
//-------------------------------------------------------------------- |
function void set_default; |
vif.sclk <= 0; |
vif.ss_n <= 1; |
vif.mosi <= 'x; |
endfunction: set_default |
|
//-------------------------------------------------------------------- |
virtual task run_phase(uvm_phase phase); |
spi_sequence_item item; |
int index = 0; |
|
set_default(); |
|
forever |
begin |
seq_item_port.get_next_item(item); |
|
vif.ss_n <= 0; |
vif.mosi <= item.mo_data[index]; |
#(vif.period / 2); |
|
fork |
repeat(item.data_width) |
begin |
#(vif.period / 2); |
vif.sclk <= 1; |
#(vif.period / 2); |
vif.sclk <= 0; |
end |
join_none |
|
repeat(item.data_width) |
begin |
@(vif.cb_rise); |
item.mi_data[index] = vif.miso; |
index++; |
@(vif.cb_fall); |
vif.mosi <= item.mo_data[index]; |
end |
|
#(vif.period / 2); |
vif.ss_n <= 1; |
|
set_default(); |
seq_item_port.item_done(); |
end |
|
endtask : run_phase |
|
//-------------------------------------------------------------------- |
function new(string name, uvm_component parent); |
super.new(name, parent); |
endfunction |
|
// -------------------------------------------------------------------- |
endclass : spi_driver |
/BFM/src/SPI/spi_if.sv
0,0 → 1,63
////////////////////////////////////////////////////////////////////// |
//// //// |
//// 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 //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
interface |
spi_if(); |
import uvm_pkg::*; |
`include "uvm_macros.svh" |
import tb_spi_pkg::*; |
|
// -------------------------------------------------------------------- |
logic sclk; |
logic ss_n; |
logic mosi; |
logic miso; |
|
// -------------------------------------------------------------------- |
time period = 40ns; |
|
// -------------------------------------------------------------------- |
default clocking cb_rise @(posedge sclk); |
inout ss_n; |
output mosi; |
input miso; |
endclocking |
|
// -------------------------------------------------------------------- |
clocking cb_fall @(negedge sclk); |
inout ss_n; |
output mosi; |
input miso; |
endclocking |
|
// -------------------------------------------------------------------- |
task zero_cycle_delay; |
##0; |
endtask: zero_cycle_delay |
|
// -------------------------------------------------------------------- |
endinterface |
/BFM/src/SPI/spi_sequence_item.svh
0,0 → 1,111
////////////////////////////////////////////////////////////////////// |
//// //// |
//// 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 spi_sequence_item |
extends uvm_sequence_item; |
`uvm_object_utils(spi_sequence_item) |
|
// -------------------------------------------------------------------- |
rand int data_width; // data size in bits |
|
// -------------------------------------------------------------------- |
logic mi_data[]; // data from slave to master |
logic mo_data[]; // data from master to slave |
|
// -------------------------------------------------------------------- |
function new(string name = ""); |
super.new(name); |
endfunction : new |
|
// -------------------------------------------------------------------- |
function void init(int data_width = 16 * 16); |
this.data_width = data_width; |
this.mi_data = new[data_width]; |
this.mo_data = new[data_width]; |
|
foreach(this.mo_data[i]) |
mo_data[i] = 0; |
endfunction : init |
|
// // -------------------------------------------------------------------- |
// function bit do_compare(uvm_object rhs, uvm_comparer comparer); |
// spi_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); |
// spi_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 : spi_sequence_item |
/BFM/src/SPI/tb_spi_pkg.sv
0,0 → 1,55
////////////////////////////////////////////////////////////////////// |
//// //// |
//// 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_spi_pkg; |
import uvm_pkg::*; |
`include "uvm_macros.svh" |
import bfm_pkg::*; |
|
// // -------------------------------------------------------------------- |
// localparam W = 16; |
// localparam D = 8; |
// localparam UB = $clog2(D); |
|
// -------------------------------------------------------------------- |
// typedef enum {FIFO_RD, FIFO_WR, FIFO_BOTH, FIFO_NULL} fifo_command_t; |
|
// -------------------------------------------------------------------- |
`include "spi_sequence_item.svh" |
typedef uvm_sequencer #(spi_sequence_item) spi_sequencer; |
`include "spi_driver.svh" |
// `include "spi_monitor.svh" |
// `include "spi_scoreboard.svh" |
`include "spi_agent.svh" |
// `include "tb_env.svh" |
|
// `include "s_debug.svh" |
// `include "t_top_base.svh" |
// `include "t_debug.svh" |
|
// -------------------------------------------------------------------- |
endpackage : tb_spi_pkg |
/BFM/src/axis_video_frame/avf_config.svh
29,12 → 29,7
|
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; |
video_frame_config c_h; |
|
// -------------------------------------------------------------------- |
function void init |
43,16 → 38,12
, 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; |
c_h = new(); |
c_h.init( .pixels_per_line(pixels_per_line) |
, .lines_per_frame(lines_per_frame) |
, .bits_per_pixel(bits_per_pixel) |
, .bus_width(N) |
); |
endfunction: init |
|
// -------------------------------------------------------------------- |
/BFM/src/axis_video_frame/avf_master_agent.svh
55,7 → 55,7
driver_h.seq_item_port.connect(sequencer_h.seq_item_export); |
end |
monitor_h.vif = cfg_h.vif; |
monitor_h.cfg_h = cfg_h; |
monitor_h.c_h = cfg_h.c_h; |
endfunction |
|
// -------------------------------------------------------------------- |
/BFM/src/axis_video_frame/avf_monitor.svh
29,7 → 29,7
`uvm_component_param_utils(avf_monitor #(N, U)); |
|
virtual axis_if #(.N(N), .U(U)) vif; |
avf_config #(N, U) cfg_h; |
video_frame_config c_h; |
uvm_analysis_port #(avf_sequence_item) ap; |
uvm_analysis_port #(avf_sequence_item) req; |
|
68,11 → 68,11
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 |
ap_item.f_h.init( c_h.pixels_per_line |
, c_h.lines_per_frame |
, c_h.bits_per_pixel |
, c_h.pixels_per_clk |
, c_h.name |
); |
sof_received = 1; |
p = 0; |
/BFM/src/axis_video_frame/avf_slave_agent.svh
56,7 → 56,7
monitor_h.req.connect(sequencer_h.m_request_export); |
end |
monitor_h.vif = cfg_h.vif; |
monitor_h.cfg_h = cfg_h; |
monitor_h.c_h = cfg_h.c_h; |
endfunction |
|
// -------------------------------------------------------------------- |
/BFM/src/axis_video_frame/s_avf_api.svh
30,37 → 30,22
`uvm_object_utils(s_avf_api) |
|
avf_sequence_item item; |
mailbox #(video_frame_class) frame_buffer; |
|
// -------------------------------------------------------------------- |
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; |
video_frame_config c_h; |
|
// -------------------------------------------------------------------- |
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; |
function void init(video_frame_config c_h); |
this.c_h = c_h; |
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 |
f_h.init( c_h.pixels_per_line |
, c_h.lines_per_frame |
, c_h.bits_per_pixel |
, c_h.pixels_per_clk |
); |
case(pattern.tolower) |
"constant": f_h.make_constant(pixel); |
/BFM/src/axis_video_frame/s_avf_base.svh
32,17 → 32,9
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 |
); |
function void init(video_frame_config c_h); |
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 |
); |
avf_api_h.init(c_h); |
endfunction : init |
|
// -------------------------------------------------------------------- |
/BFM/src/video_frame/video_frame_class.svh
0,0 → 1,364
////////////////////////////////////////////////////////////////////// |
//// //// |
//// 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 //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
// -------------------------------------------------------------------- |
class video_frame_class; |
logger_class log; |
rand int frame_id; |
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 = ""; |
|
constraint default_pixels_per_line |
{ |
pixels_per_line >= 4; |
pixels_per_line % 2 == 0; |
pixels_per_line <= 16384; |
} |
|
constraint default_lines_per_frame |
{ |
lines_per_frame >= 4; |
lines_per_frame % 2 == 0; |
lines_per_frame <= 16384; |
} |
|
constraint default_bits_per_pixel |
{ |
bits_per_pixel >= 1 && bits_per_pixel <= 32; |
} |
|
//-------------------------------------------------------------------- |
function new; |
this.log = new; |
this.frame_id = 0; |
endfunction: new |
|
// -------------------------------------------------------------------- |
function void init |
( |
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 |
|
// -------------------------------------------------------------------- |
task write_pixel(frame_coordinate_t coordinate, int pixel); |
this.lines[coordinate.y].pixel[coordinate.x] = pixel; |
endtask: write_pixel |
|
// -------------------------------------------------------------------- |
function int read_pixel(frame_coordinate_t coordinate); |
read_pixel = this.lines[coordinate.y].pixel[coordinate.x]; |
endfunction: read_pixel |
|
// -------------------------------------------------------------------- |
function flattened_frame_t flatten_frame(); |
int i = 0; |
log.info($sformatf("%m")); |
flatten_frame = new[lines_per_frame*pixels_per_line]; |
|
foreach(this.lines[l]) |
foreach(this.lines[l].pixel[p]) |
begin |
flatten_frame[i] = this.lines[l].pixel[p]; |
i++; |
end |
endfunction: flatten_frame |
|
// -------------------------------------------------------------------- |
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 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 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 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 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 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; |
this.bits_per_pixel = from.bits_per_pixel; |
this.name = from.name; |
this.lines = new[this.lines_per_frame]; |
|
foreach(this.lines[l]) |
begin |
this.lines[l].pixel = new[this.pixels_per_line]; |
|
foreach(this.lines[l].pixel[p]) |
this.lines[l].pixel[p] = from.lines[l].pixel[p]; |
end |
endfunction: copy |
|
// -------------------------------------------------------------------- |
virtual function video_frame_class clone; |
log.info($sformatf("%m")); |
clone = new(); |
clone.copy(this); |
endfunction: clone |
|
// -------------------------------------------------------------------- |
function video_frame_class catenate_horizontally(video_frame_class tail); |
log.info($sformatf("%m")); |
|
if(this.lines_per_frame != tail.lines_per_frame) |
return(null); |
|
if(this.bits_per_pixel != tail.bits_per_pixel) |
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; |
catenate_horizontally.name = this.name; |
catenate_horizontally.lines = new[catenate_horizontally.lines_per_frame]; |
|
foreach(catenate_horizontally.lines[l]) |
begin |
catenate_horizontally.lines[l].pixel = new[catenate_horizontally.pixels_per_line]; |
|
foreach(this.lines[l].pixel[p]) |
catenate_horizontally.lines[l].pixel[p] = this.lines[l].pixel[p]; |
|
foreach(tail.lines[l].pixel[p]) |
catenate_horizontally.lines[l].pixel[p + this.pixels_per_line] = tail.lines[l].pixel[p]; |
end |
endfunction: catenate_horizontally |
|
// -------------------------------------------------------------------- |
function void shift_right(ref line_s column); |
log.info($sformatf("%m")); |
|
foreach(this.lines[l]) |
for(int p = pixels_per_line - 1; p > 0; p--) |
this.lines[l].pixel[p] = this.lines[l].pixel[p - 1]; |
|
foreach(this.lines[l]) |
this.lines[l].pixel[0] = column.pixel[l]; |
endfunction: shift_right |
|
// -------------------------------------------------------------------- |
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) |
begin |
log.error($sformatf("to.bits_per_pixel != this.bits_per_pixel | %s", name)); |
return(-3); |
end |
|
foreach(this.lines[line].pixel[p]) |
if(to.lines[line].pixel[p] != this.lines[line].pixel[p]) |
begin |
|
if(max_mismatches > 0) |
mismatch_count++; |
|
log.error($sformatf("mismatch @ frame[%4h][%4h] | to == %4h | this == %4h | %s", |
line, p, to.lines[line].pixel[p], this.lines[line].pixel[p], name)); |
|
if(mismatch_count > max_mismatches) |
return(mismatch_count); |
end |
|
return(mismatch_count); |
endfunction: compare_line |
|
// -------------------------------------------------------------------- |
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) |
begin |
log.error($sformatf("to.pixels_per_line != this.pixels_per_line | %s", name)); |
return(-1); |
end |
|
if(to.lines_per_frame != this.lines_per_frame) |
begin |
log.error($sformatf("to.lines_per_frame != this.lines_per_frame | %s", name)); |
return(-2); |
end |
|
if(to.bits_per_pixel != this.bits_per_pixel) |
begin |
log.error($sformatf("to.bits_per_pixel != this.bits_per_pixel | %s", name)); |
return(-3); |
end |
|
foreach(this.lines[l]) |
begin |
foreach(this.lines[l].pixel[p]) |
if(to.lines[l].pixel[p] != this.lines[l].pixel[p]) |
begin |
if(max_mismatches > 0) |
mismatch_count++; |
|
log.error($sformatf("mismatch @ frame[%4h][%4h] | to == %4h | this == %4h | %s", l, p, to.lines[l].pixel[p], this.lines[l].pixel[p], name)); |
|
if(mismatch_count > max_mismatches) |
return(mismatch_count); |
end |
end |
|
return(mismatch_count); |
endfunction: compare |
|
// -------------------------------------------------------------------- |
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 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 |
/BFM/src/video_frame/video_frame_config.svh
0,0 → 1,60
////////////////////////////////////////////////////////////////////// |
//// //// |
//// 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 //// |
//// //// |
////////////////////////////////////////////////////////////////////// |
|
// -------------------------------------------------------------------- |
class video_frame_config; |
rand int pixels_per_line; |
rand int lines_per_frame; |
rand int bits_per_pixel; |
rand int bus_width; |
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 |
, int bus_width |
, string name = "" |
); |
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.bus_width = bus_width; |
this.pixels_per_clk = bus_width / bytes_per_pixel; |
this.name = name; |
|
// -------------------------------------------------------------------- |
assert(bus_width % bytes_per_pixel == 0); |
endfunction : init |
|
// -------------------------------------------------------------------- |
endclass: video_frame_config |
/BFM/src/video_frame/video_frame_pkg.sv
26,360 → 26,28
////////////////////////////////////////////////////////////////////// |
|
package video_frame_pkg; |
import logger_pkg::*; |
|
import logger_pkg::*; |
|
typedef struct |
{ |
int pixel[]; |
} line_s; |
|
typedef struct |
{ |
int x; |
int y; |
} frame_coordinate_t; |
|
typedef int flattened_frame_t[]; |
typedef int unsigned video_array_t[][]; |
|
// -------------------------------------------------------------------- |
class video_frame_class; |
logger_class log; |
rand int frame_id; |
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 = ""; |
|
constraint default_pixels_per_line |
// -------------------------------------------------------------------- |
typedef struct |
{ |
pixels_per_line >= 4; |
pixels_per_line % 2 == 0; |
pixels_per_line <= 16384; |
} |
int pixel[]; |
} line_s; |
|
constraint default_lines_per_frame |
// -------------------------------------------------------------------- |
typedef struct |
{ |
lines_per_frame >= 4; |
lines_per_frame % 2 == 0; |
lines_per_frame <= 16384; |
} |
int x; |
int y; |
} frame_coordinate_t; |
|
constraint default_bits_per_pixel |
{ |
bits_per_pixel >= 1 && bits_per_pixel <= 32; |
} |
|
//-------------------------------------------------------------------- |
function new; |
this.log = new; |
this.frame_id = 0; |
endfunction: new |
|
// -------------------------------------------------------------------- |
function void init |
( |
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; |
typedef int flattened_frame_t[]; |
typedef int unsigned video_array_t[][]; |
|
this.make_constant(0); |
endfunction: init |
|
// -------------------------------------------------------------------- |
task write_pixel(frame_coordinate_t coordinate, int pixel); |
this.lines[coordinate.y].pixel[coordinate.x] = pixel; |
endtask: write_pixel |
`include "video_frame_config.svh" |
`include "video_frame_class.svh" |
|
// -------------------------------------------------------------------- |
function int read_pixel(frame_coordinate_t coordinate); |
read_pixel = this.lines[coordinate.y].pixel[coordinate.x]; |
endfunction: read_pixel |
|
// -------------------------------------------------------------------- |
function flattened_frame_t flatten_frame(); |
int i = 0; |
log.info($sformatf("%m")); |
flatten_frame = new[lines_per_frame*pixels_per_line]; |
|
foreach(this.lines[l]) |
foreach(this.lines[l].pixel[p]) |
begin |
flatten_frame[i] = this.lines[l].pixel[p]; |
i++; |
end |
endfunction: flatten_frame |
|
// -------------------------------------------------------------------- |
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 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 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 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 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 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; |
this.bits_per_pixel = from.bits_per_pixel; |
this.name = from.name; |
this.lines = new[this.lines_per_frame]; |
|
foreach(this.lines[l]) |
begin |
this.lines[l].pixel = new[this.pixels_per_line]; |
|
foreach(this.lines[l].pixel[p]) |
this.lines[l].pixel[p] = from.lines[l].pixel[p]; |
end |
endfunction: copy |
|
// -------------------------------------------------------------------- |
virtual function video_frame_class clone; |
log.info($sformatf("%m")); |
clone = new(); |
clone.copy(this); |
endfunction: clone |
|
// -------------------------------------------------------------------- |
function video_frame_class catenate_horizontally(video_frame_class tail); |
log.info($sformatf("%m")); |
|
if(this.lines_per_frame != tail.lines_per_frame) |
return(null); |
|
if(this.bits_per_pixel != tail.bits_per_pixel) |
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; |
catenate_horizontally.name = this.name; |
catenate_horizontally.lines = new[catenate_horizontally.lines_per_frame]; |
|
foreach(catenate_horizontally.lines[l]) |
begin |
catenate_horizontally.lines[l].pixel = new[catenate_horizontally.pixels_per_line]; |
|
foreach(this.lines[l].pixel[p]) |
catenate_horizontally.lines[l].pixel[p] = this.lines[l].pixel[p]; |
|
foreach(tail.lines[l].pixel[p]) |
catenate_horizontally.lines[l].pixel[p + this.pixels_per_line] = tail.lines[l].pixel[p]; |
end |
endfunction: catenate_horizontally |
|
// -------------------------------------------------------------------- |
function void shift_right(ref line_s column); |
log.info($sformatf("%m")); |
|
foreach(this.lines[l]) |
for(int p = pixels_per_line - 1; p > 0; p--) |
this.lines[l].pixel[p] = this.lines[l].pixel[p - 1]; |
|
foreach(this.lines[l]) |
this.lines[l].pixel[0] = column.pixel[l]; |
endfunction: shift_right |
|
// -------------------------------------------------------------------- |
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) |
begin |
log.error($sformatf("to.bits_per_pixel != this.bits_per_pixel | %s", name)); |
return(-3); |
end |
|
foreach(this.lines[line].pixel[p]) |
if(to.lines[line].pixel[p] != this.lines[line].pixel[p]) |
begin |
|
if(max_mismatches > 0) |
mismatch_count++; |
|
log.error($sformatf("mismatch @ frame[%4h][%4h] | to == %4h | this == %4h | %s", |
line, p, to.lines[line].pixel[p], this.lines[line].pixel[p], name)); |
|
if(mismatch_count > max_mismatches) |
return(mismatch_count); |
end |
|
return(mismatch_count); |
endfunction: compare_line |
|
// -------------------------------------------------------------------- |
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) |
begin |
log.error($sformatf("to.pixels_per_line != this.pixels_per_line | %s", name)); |
return(-1); |
end |
|
if(to.lines_per_frame != this.lines_per_frame) |
begin |
log.error($sformatf("to.lines_per_frame != this.lines_per_frame | %s", name)); |
return(-2); |
end |
|
if(to.bits_per_pixel != this.bits_per_pixel) |
begin |
log.error($sformatf("to.bits_per_pixel != this.bits_per_pixel | %s", name)); |
return(-3); |
end |
|
foreach(this.lines[l]) |
begin |
foreach(this.lines[l].pixel[p]) |
if(to.lines[l].pixel[p] != this.lines[l].pixel[p]) |
begin |
if(max_mismatches > 0) |
mismatch_count++; |
|
log.error($sformatf("mismatch @ frame[%4h][%4h] | to == %4h | this == %4h | %s", l, p, to.lines[l].pixel[p], this.lines[l].pixel[p], name)); |
|
if(mismatch_count > max_mismatches) |
return(mismatch_count); |
end |
end |
|
return(mismatch_count); |
endfunction: compare |
|
// -------------------------------------------------------------------- |
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 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 |