1 |
49 |
qaztronic |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// Copyright (C) 2019 Authors and OPENCORES.ORG ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// This source file may be used and distributed without ////
|
6 |
|
|
//// restriction provided that this copyright statement is not ////
|
7 |
|
|
//// removed from the file and that any derivative work contains ////
|
8 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
9 |
|
|
//// ////
|
10 |
|
|
//// This source file is free software; you can redistribute it ////
|
11 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
12 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
13 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
14 |
|
|
//// later version. ////
|
15 |
|
|
//// ////
|
16 |
|
|
//// This source is distributed in the hope that it will be ////
|
17 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
18 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
19 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
20 |
|
|
//// details. ////
|
21 |
|
|
//// ////
|
22 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
23 |
|
|
//// Public License along with this source; if not, download it ////
|
24 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
25 |
|
|
//// ////
|
26 |
|
|
//////////////////////////////////////////////////////////////////////
|
27 |
|
|
|
28 |
|
|
class s_anf_api #(type T = shortreal) extends s_avf_api;
|
29 |
|
|
`uvm_object_param_utils(s_anf_api #(T))
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
// --------------------------------------------------------------------
|
33 |
|
|
function numeric_frame#(T) new_frame;
|
34 |
|
|
numeric_frame #(T) f_h = new();
|
35 |
|
|
f_h.init( '{c_h.lines_per_frame, c_h.pixels_per_line}
|
36 |
|
|
, c_h.pixels_per_clk
|
37 |
|
|
);
|
38 |
|
|
return f_h;
|
39 |
|
|
endfunction
|
40 |
|
|
|
41 |
|
|
// --------------------------------------------------------------------
|
42 |
|
|
task put_array(numeric_frame #(T) f_h);
|
43 |
|
|
f_h.make_2d_frame();
|
44 |
|
|
frame_buffer.put(f_h);
|
45 |
|
|
endtask
|
46 |
|
|
|
47 |
|
|
// --------------------------------------------------------------------
|
48 |
|
|
task automatic put_test_pattern(string pattern, T value = 0.0);
|
49 |
|
|
numeric_frame #(T) f_h = new();
|
50 |
|
|
f_h.init( '{c_h.lines_per_frame, c_h.pixels_per_line}
|
51 |
|
|
, c_h.pixels_per_clk
|
52 |
|
|
);
|
53 |
|
|
case(pattern.tolower)
|
54 |
|
|
"constant": f_h.a_h.make_2d_constant(value);
|
55 |
|
|
// "counting": f_h.make_counting();
|
56 |
|
|
// "horizontal": f_h.make_horizontal();
|
57 |
|
|
// "vertical": f_h.make_vertical();
|
58 |
|
|
// "random": f_h.make_random();
|
59 |
|
|
default: `uvm_fatal(get_name(), "Pattern not supported!")
|
60 |
|
|
endcase
|
61 |
|
|
f_h.make_2d_frame();
|
62 |
|
|
frame_buffer.put(f_h);
|
63 |
|
|
uvm_report_info(get_name(), $sformatf("| put_test_pattern(%s)", pattern.tolower));
|
64 |
|
|
endtask
|
65 |
|
|
|
66 |
|
|
// --------------------------------------------------------------------
|
67 |
|
|
task load_from_file(string file_name);
|
68 |
|
|
byte mem[3:0];
|
69 |
|
|
integer fd;
|
70 |
|
|
integer code;
|
71 |
|
|
int x, y;
|
72 |
|
|
numeric_frame #(T) f_h = new();
|
73 |
|
|
|
74 |
|
|
fd = $fopen(file_name, "rb");
|
75 |
|
|
f_h.init( '{c_h.lines_per_frame, c_h.pixels_per_line}
|
76 |
|
|
, c_h.pixels_per_clk
|
77 |
|
|
);
|
78 |
|
|
f_h = new_frame();
|
79 |
|
|
|
80 |
|
|
for(int i = 0; $feof(fd) == 0; i++)
|
81 |
|
|
begin
|
82 |
|
|
code = $fread(mem, fd);
|
83 |
|
|
y = i / c_h.pixels_per_line;
|
84 |
|
|
x = i % c_h.pixels_per_line;
|
85 |
|
|
f_h.lines[y].pixel[x] = {>>{mem}};
|
86 |
|
|
end
|
87 |
|
|
|
88 |
|
|
frame_buffer.put(f_h);
|
89 |
|
|
$fclose(fd);
|
90 |
|
|
endtask
|
91 |
|
|
|
92 |
|
|
// --------------------------------------------------------------------
|
93 |
|
|
function new(string name = "s_anf_api");
|
94 |
|
|
super.new(name);
|
95 |
|
|
endfunction
|
96 |
|
|
|
97 |
|
|
// --------------------------------------------------------------------
|
98 |
|
|
endclass
|