Altera Avalon Verification IP Suite User Manual
Page 158

1–2
Chapter 1: SOPC Builder Tutorial
Verifying Avalon-MM Slave DUT
Avalon Verification IP Suite User Guide
May 2011
Altera Corporation
shows an excerpt from the test program that demonstrates the use of the
Avalon-MM Master API.
shows the following two tasks:
■
master_set_and_push_commands
—Sets the fields of the command descriptor and
inserts it on to the command queue.
■
master_pop_and_get_response
—Pops or removes the response received by the
Avalon-MM Master BFM.
As these tasks illustrates, use the
set_command_
methods to define the
command and the
push_command
method to add the command to the queue. Use the
pop_response
method to get a response and the
get_response_
to retrieve
the fields of the response.
f
For more information about the methods that the Avalon-MM Master BFM uses, refer
to the
“Application Program Interface” on page 1–9
in the Avalon Memory-Mapped
Master BFM.
1
Although this testbench is written in Verilog HDL, the Avalon Verification IP Suite
supports VHDL by providing wrappers for the Avalon-MM Master and Slave BFMs.
You can include the BFMs with wrappers in simulators that support mixed language
simulation. For more information, refer to
Chapter 2, Avalon-MM Master BFM with
Chapter 4, Avalon-MM Slave BFM with Avalon-ST API
.
Example 1–1. Verilog Tasks Illustrating the Avalon-MM Master BFM API
//this task sets the command descriptor for master BFM and push it to the queue
task master_set_and_push_command;
// . . .
begin
`MSTR_BFM.set_command_request(request);
`MSTR_BFM.set_command_address(addr);
`MSTR_BFM.set_command_byte_enable(byte_enable,`INDEX_ZERO);
`MSTR_BFM.set_command_idle(idle, `INDEX_ZERO);
`MSTR_BFM.set_command_init_latency(init_latency);
if (request == REQ_WRITE)
begin
`MSTR_BFM.set_command_data(data, `INDEX_ZERO);
end
`MSTR_BFM.push_command();
end
endtask
//this task pops the response received by master BFM from queue
task master_pop_and_get_response;
// . . .
begin
`MSTR_BFM.pop_response();
request = Request_t' (`MSTR_BFM.get_response_request());
addr = `MSTR_BFM.get_response_address();
data = `MSTR_BFM.get_response_data(`INDEX_ZERO);
end
endtask