User guide

Table Of Contents
A–22 Appendix A: Avalon-ST Video Verification IP Suite
Constrained Random Test
Video and Image Processing Suite January 2013 Altera Corporation
User Guide
If the reference video item is a
video_packet
type, the scoreboard code shown in
Example A–6 receives the reference video item from the scoreboard mailbox. The code
then receives two consecutive items from the DUT and checks whether or not these
items are a control and video packet. To check that greyscale video is generated the
code calls the to_grey function (refer to Example A–7) on the reference video item and
calls the
compare()
method. If the items matched, the code returns a 1. If the items
does not matched, the code returns an 0. Then, the result is output to the display. You
can run the test for as long as you have to. In this example, it is 1 us.
Example A–7 shows the code for the
to_grey
function.
to_grey
function reads each pixel in turn from the RGB
video_packet
object,
calculates the greyscale value, writes the value to each channel of the outgoing pixel,
and pushes that on to the returned
video_packet
object, grey.
Example A–7. Scoreboard Behavioral Model of the DUT
// The scoreboard calls a function which models the behaviour of the video algorithm
function c_av_st_video_data to_grey (c_av_st_video_data rgb) ;
const bit [7:0] red_factor = 76; // 255 * 0.299
const bit [7:0] green_factor = 150; // 255 * 0.587;
const bit [7:0] blue_factor = 29; // 255 * 0.114;
c_av_st_video_data grey;
c_pixel rgb_pixel;
c_pixel grey_pixel;
int grey_value;
grey = new ();
grey.packet_type = video_packet;
do
begin
grey_pixel = new();
rgb_pixel = rgb.pop_pixel();
// Turn RGB into greyscale :
grey_value = ( red_factor * rgb_pixel.get_data(2) +
green_factor * rgb_pixel.get_data(1) +
blue_factor * rgb_pixel.get_data(0));
grey_pixel.set_data(2, grey_value[15:8]);
grey_pixel.set_data(1, grey_value[15:8]);
grey_pixel.set_data(0, grey_value[15:8]);
grey.push_pixel(grey_pixel);
end
while (rgb.get_length()>0);
return grey;
endfunction