Video and Image Processing Suite User Guide

ID 683416
Date 4/04/2022
Public
Document Table of Contents

A.2.5.2. nios_control_model.sv

The register items mailboxes defined in the BFM drivers file are used in the testbench/nios_control_model.sv by creating a new control register object, setting the address and data as required, and passing it to the mailbox, as shown in the send_write_to_mixer task code:
task send_write_to_mixer(int unsigned address, int unsigned data);
    automatic c_av_mm_control_register register_update = new(1);
    register_update.use_event = 0;
    register_update.write = 1;
    register_update.address = address;
    register_update.value = data;
    m_register_items_for_mixer_control_bfm.put(register_update);
endtask

The nios_control_model.sv code contains the writes to the Mixer II and Video Frame Buffer II IP cores, as required by both the example constrained random and video files tests:

`ifdef CONSTRAINED_RANDOM_TEST
send_write_to_mixer(8, 0); // X offset
repeat (10) @ (posedge (av_st_clk));
$display("%t NIOS CONTROL EMULATOR : Test harness writing 0 to the X offset of the Mixer",$time);
 
send_write_to_mixer(9, 0); // Y offset
repeat (10) @ (posedge (av_st_clk));
$display("%t NIOS CONTROL EMULATOR : Test harness writing 0 to the Y offset of the Mixer",$time);
 
send_write_to_mixer(3, `MIXER_BACKGROUND_WIDTH_SW); 
repeat (10) @ (posedge (av_st_clk));
$display("%t NIOS CONTROL EMULATOR : Test harness writing a background layer of width %0d to the Mixer",$time,`MIXER_BACKGROUND_WIDTH_SW);
 
send_write_to_mixer(4, `MIXER_BACKGROUND_HEIGHT_SW); 
repeat (10) @ (posedge (av_st_clk));
$display("%t NIOS CONTROL EMULATOR : Test harness writing a background layer of height %0d to the Mixer",$time,`MIXER_BACKGROUND_HEIGHT_SW);
 
`else
send_write_to_mixer(8, 20); // X offset
repeat (10) @ (posedge (av_st_clk));
$display("%t NIOS CONTROL EMULATOR : Test harness writing 20 to the X offset of the Mixer",$time);

send_write_to_mixer(9, 20); // Y offset
repeat (10) @ (posedge (av_st_clk));
$display("%t NIOS CONTROL EMULATOR : Test harness writing 20 to the Y offset of the Mixer",$time);
`endif

The control interfaces for each VIP core in the DUT has their own BFM driver and associated mailbox.

To port these tasks and test register accesses to C code for a Nios 2 processor to run on real hardware, you need to factor in the base addresses for each VIP IP core in the DUT.