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/BFM
- from Rev 48 to Rev 49
- ↔ Reverse comparison
Rev 48 → Rev 49
/sim/tests/tb_axis_video_frame/t_debug.svh
54,11 → 54,7
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 |
); |
seq.init(env_h.cfg_h.m_cfg_h.c_h); |
phase.raise_objection(this); |
seq.start(env_h.m_agent_h.sequencer_h); |
phase.drop_objection(this); |
/src/anf/anf_pkg.sv
0,0 → 1,41
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2019 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 anf_pkg; |
import uvm_pkg::*; |
`include "uvm_macros.svh" |
import video_frame_pkg::*; |
import avf_pkg::*; |
|
// -------------------------------------------------------------------- |
`include "numeric_array.svh" |
`include "numeric_frame.svh" |
`include "s_anf_api.svh" |
`include "s_anf_base.svh" |
|
// -------------------------------------------------------------------- |
endpackage |
/src/anf/numeric_array.svh
0,0 → 1,120
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2019 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 int array_shape_t[]; // same shape convention as numpy |
typedef int array_index_t[]; |
|
class numeric_array #(type T = shortreal); |
array_shape_t shape; |
int dim; |
T a_1d[]; |
T a_2d[][]; |
T a_3d[][][]; |
|
// -------------------------------------------------------------------- |
function void set_entry(array_index_t i, T value); |
case(dim) |
1: a_1d[i[0]] = value; |
2: a_2d[i[0]][i[1]] = value; |
3: a_3d[i[0]][i[1]][i[2]] = value; //[z][y][x] |
default: $stop; // not supported |
endcase |
endfunction |
|
// -------------------------------------------------------------------- |
function T get_entry(array_index_t i); |
case(dim) |
1: get_entry = a_1d[i[0]]; |
2: get_entry = a_2d[i[0]][i[1]]; |
3: get_entry = a_3d[i[0]][i[1]][i[2]]; //[z][y][x] |
default: $stop; // not supported |
endcase |
endfunction |
|
// -------------------------------------------------------------------- |
function longint to_bits(array_index_t i); |
case(type(T)) |
type(shortreal): to_bits = $shortrealtobits(get_entry(i)); |
type(real): to_bits = $realtobits(get_entry(i)); |
default: $stop; // not supported |
endcase |
endfunction |
|
// -------------------------------------------------------------------- |
function int bits; |
case(type(T)) |
type(shortreal): bits = 32; |
type(real): bits = 64; |
default: $stop; // not supported |
endcase |
endfunction |
|
// -------------------------------------------------------------------- |
function void new_2d(array_shape_t shape); |
a_2d = new[shape[0]]; |
foreach(a_2d[y]) |
a_2d[y] = new[shape[1]]; |
endfunction |
|
// -------------------------------------------------------------------- |
function void new_3d(array_shape_t shape); |
a_3d = new[shape[0]]; |
foreach(a_3d[z]) |
begin |
a_3d[z] = new[shape[1]]; |
foreach(a_3d[z,y]) |
a_3d[z][y] = new[shape[2]]; |
end |
endfunction |
|
// -------------------------------------------------------------------- |
function void make_new; |
case(dim) |
1: a_1d = new[shape[0]]; |
2: new_2d(shape); |
3: new_3d(shape); |
default: $stop; // not supported |
endcase |
endfunction |
|
// -------------------------------------------------------------------- |
function void make_2d_constant(T value=0.0); |
$display("### value = %x", $shortrealtobits(value)); |
make_new(); |
foreach(a_2d[y,x]) |
a_2d[y][x] = value; |
endfunction |
|
// -------------------------------------------------------------------- |
function new(array_shape_t shape); |
this.shape = shape; |
this.dim = shape.size(); |
make_new(); |
endfunction |
|
// -------------------------------------------------------------------- |
endclass |
/src/anf/numeric_frame.svh
0,0 → 1,73
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2019 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 numeric_frame #(type T = shortreal) extends video_frame_class; |
numeric_array #(T) a_h; |
|
// -------------------------------------------------------------------- |
function void init |
( |
array_shape_t shape, |
int pixels_per_clk = 1, |
string name = "" |
); |
a_h = new(shape); |
super.init |
( |
a_h.shape[1], |
a_h.shape[0], |
a_h.bits(), |
pixels_per_clk, |
name |
); |
endfunction |
|
// -------------------------------------------------------------------- |
function void make_1d_frame; |
lines = new[lines_per_frame]; |
foreach(lines[l]) |
begin |
lines[l].pixel = new[pixels_per_line]; |
foreach(lines[l].pixel[p]) |
lines[l].pixel[p] = a_h.to_bits('{(l*lines_per_frame)+p}); |
end |
endfunction |
|
// -------------------------------------------------------------------- |
function void make_2d_frame; |
lines = new[lines_per_frame]; |
foreach(lines[l]) |
begin |
lines[l].pixel = new[pixels_per_line]; |
foreach(lines[l].pixel[p]) |
lines[l].pixel[p] = a_h.to_bits('{l,p}); |
end |
endfunction |
|
// -------------------------------------------------------------------- |
endclass |
/src/anf/s_anf_api.svh
0,0 → 1,98
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2019 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_anf_api #(type T = shortreal) extends s_avf_api; |
`uvm_object_param_utils(s_anf_api #(T)) |
|
|
// -------------------------------------------------------------------- |
function numeric_frame#(T) new_frame; |
numeric_frame #(T) f_h = new(); |
f_h.init( '{c_h.lines_per_frame, c_h.pixels_per_line} |
, c_h.pixels_per_clk |
); |
return f_h; |
endfunction |
|
// -------------------------------------------------------------------- |
task put_array(numeric_frame #(T) f_h); |
f_h.make_2d_frame(); |
frame_buffer.put(f_h); |
endtask |
|
// -------------------------------------------------------------------- |
task automatic put_test_pattern(string pattern, T value = 0.0); |
numeric_frame #(T) f_h = new(); |
f_h.init( '{c_h.lines_per_frame, c_h.pixels_per_line} |
, c_h.pixels_per_clk |
); |
case(pattern.tolower) |
"constant": f_h.a_h.make_2d_constant(value); |
// "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 |
f_h.make_2d_frame(); |
frame_buffer.put(f_h); |
uvm_report_info(get_name(), $sformatf("| put_test_pattern(%s)", pattern.tolower)); |
endtask |
|
// -------------------------------------------------------------------- |
task load_from_file(string file_name); |
byte mem[3:0]; |
integer fd; |
integer code; |
int x, y; |
numeric_frame #(T) f_h = new(); |
|
fd = $fopen(file_name, "rb"); |
f_h.init( '{c_h.lines_per_frame, c_h.pixels_per_line} |
, c_h.pixels_per_clk |
); |
f_h = new_frame(); |
|
for(int i = 0; $feof(fd) == 0; i++) |
begin |
code = $fread(mem, fd); |
y = i / c_h.pixels_per_line; |
x = i % c_h.pixels_per_line; |
f_h.lines[y].pixel[x] = {>>{mem}}; |
end |
|
frame_buffer.put(f_h); |
$fclose(fd); |
endtask |
|
// -------------------------------------------------------------------- |
function new(string name = "s_anf_api"); |
super.new(name); |
endfunction |
|
// -------------------------------------------------------------------- |
endclass |
/src/anf/s_anf_base.svh
0,0 → 1,45
////////////////////////////////////////////////////////////////////// |
//// //// |
//// Copyright (C) 2019 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_anf_base #(type T = shortreal) extends uvm_sequence #(avf_sequence_item); |
`uvm_object_param_utils(s_anf_base #(T)) |
|
s_anf_api anf_api_h; |
|
// -------------------------------------------------------------------- |
function void init(video_frame_config c_h); |
anf_api_h = s_anf_api #(T)::type_id::create("s_anf_api"); |
anf_api_h.init(c_h); |
endfunction |
|
// -------------------------------------------------------------------- |
function new(string name = "s_anf_base"); |
super.new(name); |
endfunction |
|
// -------------------------------------------------------------------- |
endclass |
/src/axis_video_frame/avf_scoreboard.svh
69,7 → 69,7
// |
function void print_video_frame(ref video_frame_class f_h); |
string s; |
f_h.print_config(); |
$display("%s", {80{"="}}); |
$display(f_h.convert2string()); |
endfunction : print_video_frame |
|
/src/video_frame/video_frame_class.svh
97,19 → 97,21
|
// -------------------------------------------------------------------- |
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 |
flatten_frame[(l*pixels_per_line)+p] = this.lines[l].pixel[p]; |
endfunction: flatten_frame |
|
// -------------------------------------------------------------------- |
function void load_flatten_frame(flattened_frame_t a); |
make_constant(0); |
foreach(lines[l]) |
foreach(lines[l].pixel[p]) |
lines[l].pixel[p] = a[(l*pixels_per_line)+p]; |
endfunction: load_flatten_frame |
|
// -------------------------------------------------------------------- |
function void make_constant(int pixel); |
log.info($sformatf("%m")); |
this.lines = new[lines_per_frame]; |
347,14 → 349,19
endfunction: print_config |
|
// -------------------------------------------------------------------- |
function string convert2string(); |
function string convert2string(int grid=8); |
string s; |
string f =""; |
string fs = $sformatf("%%s%%%0d.h" , (bits_per_pixel % 4 == 0) |
? bits_per_pixel / 4 |
: (bits_per_pixel / 4) + 1 |
); |
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])}; |
s = {s, $sformatf(fs, (p % grid == 0) ? "!" : "|", this.lines[l].pixel[p])}; |
|
f = {f, s, "|\n"}; |
end |
return f; |