Line 25... |
Line 25... |
//// ////
|
//// ////
|
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
|
|
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
class video_frame_class;
|
class video_frame_class;
|
logger_class log;
|
|
rand int frame_id;
|
rand int frame_id;
|
rand int pixels_per_line;
|
rand int pixels_per_line;
|
rand int lines_per_frame;
|
rand int lines_per_frame;
|
rand int bits_per_pixel;
|
rand int bits_per_pixel;
|
int bytes_per_pixel;
|
int bytes_per_pixel;
|
Line 57... |
Line 56... |
bits_per_pixel >= 1 && bits_per_pixel <= 32;
|
bits_per_pixel >= 1 && bits_per_pixel <= 32;
|
}
|
}
|
|
|
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
function new;
|
function new;
|
this.log = new;
|
|
this.frame_id = 0;
|
this.frame_id = 0;
|
endfunction: new
|
endfunction: new
|
|
|
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
function void init
|
function void init
|
Line 70... |
Line 68... |
int lines_per_frame,
|
int lines_per_frame,
|
int bits_per_pixel,
|
int bits_per_pixel,
|
int pixels_per_clk = 1,
|
int pixels_per_clk = 1,
|
string name = ""
|
string name = ""
|
);
|
);
|
log.info($sformatf("%m"));
|
|
this.pixels_per_line = pixels_per_line;
|
this.pixels_per_line = pixels_per_line;
|
this.lines_per_frame = lines_per_frame;
|
this.lines_per_frame = lines_per_frame;
|
this.bits_per_pixel = bits_per_pixel;
|
this.bits_per_pixel = bits_per_pixel;
|
this.pixels_per_clk = pixels_per_clk;
|
this.pixels_per_clk = pixels_per_clk;
|
this.name = name;
|
this.name = name;
|
Line 111... |
Line 108... |
lines[l].pixel[p] = a[(l*pixels_per_line)+p];
|
lines[l].pixel[p] = a[(l*pixels_per_line)+p];
|
endfunction: load_flatten_frame
|
endfunction: load_flatten_frame
|
|
|
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
function void make_constant(int pixel);
|
function void make_constant(int pixel);
|
log.info($sformatf("%m"));
|
|
this.lines = new[lines_per_frame];
|
this.lines = new[lines_per_frame];
|
|
|
foreach(this.lines[l])
|
foreach(this.lines[l])
|
begin
|
begin
|
this.lines[l].pixel = new[pixels_per_line];
|
this.lines[l].pixel = new[pixels_per_line];
|
Line 127... |
Line 123... |
pattern = "constant";
|
pattern = "constant";
|
endfunction: make_constant
|
endfunction: make_constant
|
|
|
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
function void make_counting(int offset = 0);
|
function void make_counting(int offset = 0);
|
log.info($sformatf("%m"));
|
|
this.lines = new[lines_per_frame];
|
this.lines = new[lines_per_frame];
|
|
|
foreach(this.lines[l])
|
foreach(this.lines[l])
|
begin
|
begin
|
this.lines[l].pixel = new[pixels_per_line];
|
this.lines[l].pixel = new[pixels_per_line];
|
Line 143... |
Line 138... |
pattern = "counting";
|
pattern = "counting";
|
endfunction: make_counting
|
endfunction: make_counting
|
|
|
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
function void make_horizontal();
|
function void make_horizontal();
|
log.info($sformatf("%m"));
|
|
this.lines = new[lines_per_frame];
|
this.lines = new[lines_per_frame];
|
|
|
foreach(this.lines[l])
|
foreach(this.lines[l])
|
begin
|
begin
|
this.lines[l].pixel = new[pixels_per_line];
|
this.lines[l].pixel = new[pixels_per_line];
|
Line 159... |
Line 153... |
pattern = "horizontal";
|
pattern = "horizontal";
|
endfunction: make_horizontal
|
endfunction: make_horizontal
|
|
|
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
function void make_vertical();
|
function void make_vertical();
|
log.info($sformatf("%m"));
|
|
this.lines = new[lines_per_frame];
|
this.lines = new[lines_per_frame];
|
|
|
foreach(this.lines[l])
|
foreach(this.lines[l])
|
begin
|
begin
|
this.lines[l].pixel = new[pixels_per_line];
|
this.lines[l].pixel = new[pixels_per_line];
|
Line 175... |
Line 168... |
pattern = "vertical";
|
pattern = "vertical";
|
endfunction: make_vertical
|
endfunction: make_vertical
|
|
|
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
function void make_random();
|
function void make_random();
|
log.info($sformatf("%m"));
|
|
this.lines = new[lines_per_frame];
|
this.lines = new[lines_per_frame];
|
|
|
foreach(this.lines[l])
|
foreach(this.lines[l])
|
begin
|
begin
|
this.lines[l].pixel = new[pixels_per_line];
|
this.lines[l].pixel = new[pixels_per_line];
|
Line 191... |
Line 183... |
pattern = "random";
|
pattern = "random";
|
endfunction: make_random
|
endfunction: make_random
|
|
|
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
function void copy(video_frame_class from);
|
function void copy(video_frame_class from);
|
log.info($sformatf("%m"));
|
|
this.frame_id = from.frame_id;
|
this.frame_id = from.frame_id;
|
this.pixels_per_line = from.pixels_per_line;
|
this.pixels_per_line = from.pixels_per_line;
|
this.lines_per_frame = from.lines_per_frame;
|
this.lines_per_frame = from.lines_per_frame;
|
this.bits_per_pixel = from.bits_per_pixel;
|
this.bits_per_pixel = from.bits_per_pixel;
|
this.name = from.name;
|
this.name = from.name;
|
Line 210... |
Line 201... |
end
|
end
|
endfunction: copy
|
endfunction: copy
|
|
|
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
virtual function video_frame_class clone;
|
virtual function video_frame_class clone;
|
log.info($sformatf("%m"));
|
|
clone = new();
|
clone = new();
|
clone.copy(this);
|
clone.copy(this);
|
endfunction: clone
|
endfunction: clone
|
|
|
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
function video_frame_class catenate_horizontally(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)
|
if(this.lines_per_frame != tail.lines_per_frame)
|
return(null);
|
return(null);
|
|
|
if(this.bits_per_pixel != tail.bits_per_pixel)
|
if(this.bits_per_pixel != tail.bits_per_pixel)
|
Line 246... |
Line 235... |
end
|
end
|
endfunction: catenate_horizontally
|
endfunction: catenate_horizontally
|
|
|
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
function void shift_right(ref line_s column);
|
function void shift_right(ref line_s column);
|
log.info($sformatf("%m"));
|
|
|
|
foreach(this.lines[l])
|
foreach(this.lines[l])
|
for(int p = pixels_per_line - 1; p > 0; p--)
|
for(int p = pixels_per_line - 1; p > 0; p--)
|
this.lines[l].pixel[p] = this.lines[l].pixel[p - 1];
|
this.lines[l].pixel[p] = this.lines[l].pixel[p - 1];
|
|
|
foreach(this.lines[l])
|
foreach(this.lines[l])
|
this.lines[l].pixel[0] = column.pixel[l];
|
this.lines[l].pixel[0] = column.pixel[l];
|
endfunction: shift_right
|
endfunction: shift_right
|
|
|
// --------------------------------------------------------------------
|
// // --------------------------------------------------------------------
|
function int compare_line
|
// function int compare_line
|
( int line
|
// ( int line
|
, int max_mismatches
|
// , int max_mismatches
|
, video_frame_class to
|
// , video_frame_class to
|
);
|
// );
|
int mismatch_count = 0;
|
// int mismatch_count = 0;
|
|
|
if(to.bits_per_pixel != this.bits_per_pixel)
|
// if(to.bits_per_pixel != this.bits_per_pixel)
|
begin
|
// begin
|
log.error($sformatf("to.bits_per_pixel != this.bits_per_pixel | %s", name));
|
// log.error($sformatf("to.bits_per_pixel != this.bits_per_pixel | %s", name));
|
return(-3);
|
// return(-3);
|
end
|
// end
|
|
|
foreach(this.lines[line].pixel[p])
|
// foreach(this.lines[line].pixel[p])
|
if(to.lines[line].pixel[p] != this.lines[line].pixel[p])
|
// if(to.lines[line].pixel[p] != this.lines[line].pixel[p])
|
begin
|
// begin
|
|
|
if(max_mismatches > 0)
|
// if(max_mismatches > 0)
|
mismatch_count++;
|
// mismatch_count++;
|
|
|
log.error($sformatf("mismatch @ frame[%4h][%4h] | to == %4h | this == %4h | %s",
|
// 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));
|
// line, p, to.lines[line].pixel[p], this.lines[line].pixel[p], name));
|
|
|
if(mismatch_count > max_mismatches)
|
// if(mismatch_count > max_mismatches)
|
return(mismatch_count);
|
// return(mismatch_count);
|
end
|
// end
|
|
|
return(mismatch_count);
|
// return(mismatch_count);
|
endfunction: compare_line
|
// endfunction: compare_line
|
|
|
// --------------------------------------------------------------------
|
// // --------------------------------------------------------------------
|
function int compare(int max_mismatches, video_frame_class to);
|
// function int compare(int max_mismatches, video_frame_class to);
|
int mismatch_count = 0;
|
// int mismatch_count = 0;
|
log.info($sformatf("%m"));
|
// log.info($sformatf("%m"));
|
|
|
if(to.pixels_per_line != this.pixels_per_line)
|
// if(to.pixels_per_line != this.pixels_per_line)
|
begin
|
// begin
|
log.error($sformatf("to.pixels_per_line != this.pixels_per_line | %s", name));
|
// log.error($sformatf("to.pixels_per_line != this.pixels_per_line | %s", name));
|
return(-1);
|
// return(-1);
|
end
|
// end
|
|
|
if(to.lines_per_frame != this.lines_per_frame)
|
// if(to.lines_per_frame != this.lines_per_frame)
|
begin
|
// begin
|
log.error($sformatf("to.lines_per_frame != this.lines_per_frame | %s", name));
|
// log.error($sformatf("to.lines_per_frame != this.lines_per_frame | %s", name));
|
return(-2);
|
// return(-2);
|
end
|
// end
|
|
|
if(to.bits_per_pixel != this.bits_per_pixel)
|
// if(to.bits_per_pixel != this.bits_per_pixel)
|
begin
|
// begin
|
log.error($sformatf("to.bits_per_pixel != this.bits_per_pixel | %s", name));
|
// log.error($sformatf("to.bits_per_pixel != this.bits_per_pixel | %s", name));
|
return(-3);
|
// return(-3);
|
end
|
// end
|
|
|
foreach(this.lines[l])
|
// foreach(this.lines[l])
|
begin
|
// begin
|
foreach(this.lines[l].pixel[p])
|
// foreach(this.lines[l].pixel[p])
|
if(to.lines[l].pixel[p] != this.lines[l].pixel[p])
|
// if(to.lines[l].pixel[p] != this.lines[l].pixel[p])
|
begin
|
// begin
|
if(max_mismatches > 0)
|
// if(max_mismatches > 0)
|
mismatch_count++;
|
// 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));
|
// 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)
|
// if(mismatch_count > max_mismatches)
|
return(mismatch_count);
|
// return(mismatch_count);
|
end
|
// end
|
end
|
// end
|
|
|
return(mismatch_count);
|
// return(mismatch_count);
|
endfunction: compare
|
// endfunction: compare
|
|
|
// --------------------------------------------------------------------
|
// // --------------------------------------------------------------------
|
function void print_line(int line, int pixel, int count);
|
// function void print_line(int line, int pixel, int count);
|
log.info($sformatf("%m"));
|
// log.info($sformatf("%m"));
|
|
|
for(int i = 0; i < count; i++)
|
// 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));
|
// log.display($sformatf("%4h @ frame[%4h][%4h] | %s", this.lines[line].pixel[(pixel + i)], line, (pixel + i), name));
|
endfunction: print_line
|
// 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 void print_config();
|
function void print_config();
|
log.display($sformatf("%m | frame_id = %06d | %s", frame_id, name));
|
$display($sformatf("%m | frame_id = %06d | %s", frame_id, name));
|
log.display($sformatf("%m | pixels_per_line = %06d | %s", pixels_per_line, name));
|
$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));
|
$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));
|
$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));
|
$display($sformatf("%m | pixels_per_clk = %06d | %s", pixels_per_clk, name));
|
log.display($sformatf("%m | pattern = %s | %s", pattern, name));
|
$display($sformatf("%m | pattern = %s | %s", pattern, name));
|
endfunction: print_config
|
endfunction: print_config
|
|
|
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
function string convert2string(int grid=8);
|
function string convert2string(int grid=8);
|
string s;
|
string s0, s1;
|
string f ="";
|
string f ="";
|
string fs = $sformatf("%%s%%%0d.h" , (bits_per_pixel % 4 == 0)
|
int nibbles = ( bits_per_pixel % 4 == 0)
|
? bits_per_pixel / 4
|
? bits_per_pixel / 4
|
: (bits_per_pixel / 4) + 1
|
: (bits_per_pixel / 4) + 1;
|
);
|
|
foreach(this.lines[l])
|
|
begin
|
|
s = $sformatf("[%4.d]", l);
|
|
foreach(this.lines[l].pixel[p])
|
|
s = {s, $sformatf(fs, (p % grid == 0) ? "!" : "|", this.lines[l].pixel[p])};
|
|
|
|
f = {f, s, "|\n"};
|
foreach(this.lines[l]) begin
|
|
s0 = $sformatf("[%4.d]", l);
|
|
foreach(this.lines[l].pixel[p]) begin
|
|
s1 = $sformatf("%.h", this.lines[l].pixel[p]);
|
|
s1 = s1.substr(nibbles, s1.len()-1);
|
|
s0 = {s0, (p % grid == 0) ? "!" : "|", s1};
|
end
|
end
|
|
|
|
f = {f, s0, "|\n"};
|
|
end
|
|
|
return f;
|
return f;
|
endfunction: convert2string
|
endfunction: convert2string
|
|
|
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
endclass: video_frame_class
|
endclass
|
endclass
|
endclass
|