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
    /qaz_libs/trunk
    from Rev 6 to Rev 7
    Reverse comparison

Rev 6 → Rev 7

/video_frame_class/src/video_frame_class.sv
1,10 → 1,18
// --------------------------------------------------------------------
//
 
typedef struct
{
int pixel[];
} line_s
 
class video_frame_class;
rand int frame_id;
rand int pixels_per_line;
rand int lines_per_frame;
rand int bits_per_pixel;
line_s lines[];
 
constraint default_pixels_per_line
{
17,7 → 25,7
{
lines_per_frame >= 4;
lines_per_frame % 2 == 0;
lines_per_frame <= (16384 + 2);
lines_per_frame <= 16384;
}
 
constraint default_bits_per_pixel
24,18 → 32,189
{
bits_per_pixel >= 1 && bits_per_pixel <= 16;
}
 
//--------------------------------------------------------------------
function new;
this.pixel_type = MONO;
this.frame_id = 0;
endfunction: new
 
extern virtual function void copy(ref video_frame_class to);
extern virtual function void init
(
input int pixels_per_line,
input int lines_per_frame,
input int bits_per_pixel
);
extern virtual function void make_constant
(
input int pixel
);
extern virtual function void make_counting();
extern virtual function void make_random();
extern virtual function void copy
(
ref video_frame_class to
);
extern virtual function void compare
(
input int max_mismatches,
ref video_frame_class to
);
endclass: video_frame_class
 
 
// --------------------------------------------------------------------
//
function void video_frame_class::init
(
input int pixels_per_line,
input int lines_per_frame,
input int bits_per_pixel
);
this.pixels_per_line = pixels_per_line;
this.lines_per_frame = lines_per_frame;
this.bits_per_pixel = bits_per_pixel;
endfunction: init
// --------------------------------------------------------------------
//
function void video_frame_class::make_constant
(
input int pixel
);
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
endfunction: make_constant
// --------------------------------------------------------------------
//
function void video_frame_class::make_counting();
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;
end
endfunction: make_counting
 
// --------------------------------------------------------------------
//
function void video_frame_class::make_random();
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
endfunction: make_random
 
// --------------------------------------------------------------------
//
function void video_frame_class::copy
(
ref video_frame_class to
);
to.frame_id = this.frame_id;
to.pixels_per_line = this.pixels_per_line;
to.lines_per_frame = this.lines_per_frame;
to.bits_per_pixel =this.bits_per_pixel ;
to.lines = new[lines_per_frame];
 
foreach( this.lines[l] )
begin
to.lines[l].pixel = new[pixels_per_line];
foreach( this.lines[l].pixel[p] )
to.lines[l].pixel[p] = this.lines[l].pixel[p];
end
endfunction: copy
// --------------------------------------------------------------------
//
function void video_frame_class::compare
(
input int max_mismatches,
ref video_frame_class to
);
 
int mismatch_count = 0;
if( to.pixels_per_line != this.pixels_per_line )
begin
$display("^^^ %16.t | to.pixels_per_line != this.pixels_per_line ", $time );
return( -1 );
end
if( to.lines_per_frame = this.lines_per_frame )
begin
$display("^^^ %16.t | to.lines_per_frame = this.lines_per_frame ", $time );
return( -2 );
end
if( to.bits_per_pixel = this.bits_per_pixel )
begin
$display("^^^ %16.t | to.bits_per_pixel =this.bits_per_pixel ", $time );
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++;
$display("^^^ %16.t | mismatch @ frame[%4h].pixel[%4h] | to == %4h | this == %4h ", $time, to.lines[l].pixel[p], this.lines[l].pixel[p] );
if( max_mismatches > max_mismatches )
return( -4 );
end
end
endfunction: compare
/video_frame_class/sim/tests/debug/the_test.sv
2,13 → 2,60
//
// --------------------------------------------------------------------
 
`include "../../../src/video_frame_class.sv"
 
 
module the_test(
input tb_clk,
input tb_rst
);
 
// --------------------------------------------------------------------
//
video_frame_class f_h;
video_frame_class fc_h;
int return_code;
initial
begin
f_h = new;
f_h.init
(
.pixels_per_line('h100);
.lines_per_frame('h080);
.bits_per_pixel(14);
)
f_h.make_random();
fc_h = new;
f_h.copy(fc_h);
return_code = fh.compare( 16, fc_h );
if( return_code == 0 )
$display("^^^ %16.t | f_h == fc_h", $time );
else
$display("^^^ %16.t | f_h != fc_h | mismatches = %0d", $time, return_code );
$display("^^^ %16.t | inserting errors @ fc_h[11][22]", $time );
fc_h.lines['h11].pixel['h22] = ~(fc_h.lines['h11].pixel['h22])
 
$display("^^^ %16.t | inserting errors @ fc_h[33][44]", $time );
fc_h.lines['h33].pixel['h44] = ~(fc_h.lines['h33].pixel['h44])
 
return_code = fh.compare( 16, fc_h );
 
if( return_code == 0 )
$display("^^^ %16.t | f_h == fc_h", $time );
else
$display("^^^ %16.t | f_h != fc_h | mismatches = %0d", $time, return_code );
end
 
// --------------------------------------------------------------------
//
task run_the_test;
/video_frame_class/sim/src/tb_top.v
9,35 → 9,17
module tb_top();
 
// --------------------------------------------------------------------
// system wires
wire CLK_20;
wire CLK_50;
wire CLK_100;
wire CLK_125;
wire CLK_156_25;
 
wire tb_clk = CLK_50;
 
// test bench clock & reset
wire clk_50mhz;
wire tb_clk = clk_50mhz;
wire tb_rst;
 
 
tb_base #( .PERIOD(20_000) ) tb( clk_50mhz, tb_rst );
// --------------------------------------------------------------------
// clock & reset
//
parameter CLK_PERIOD = 2000;
 
tb_clk #( .CLK_PERIOD(5000) ) i_CLK_20 ( CLK_20 );
tb_clk #( .CLK_PERIOD(2000) ) i_CLK_50 ( CLK_50 );
tb_clk #( .CLK_PERIOD(1000) ) i_CLK_100 ( CLK_100 );
tb_clk #( .CLK_PERIOD(640) ) i_CLK_156_25 ( CLK_156_25 );
tb_clk #( .CLK_PERIOD(800) ) i_CLK_125 ( CLK_125 );
 
tb_reset #( .ASSERT_TIME(CLK_PERIOD*10) ) i_tb_rst( tb_rst );
 
initial
begin
$display("\n^^^---------------------------------");
i_tb_rst.assert_delayed_reset(CLK_PERIOD/3);
end
 
// --------------------------------------------------------------------
53,9 → 35,6
 
 
 
// --------------------------------------------------------------------
//
tb_log log();
 
// ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '

powered by: WebSVN 2.1.0

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