Altera Mentor Verification IP Altera Edition AMBA AXI4-Stream User Manual

Page 214

Advertising
background image

Mentor Verification IP AE AMBA AXI4-Stream User Guide, V10.3

214

VHDL Master and Slave Test Programs
VHDL Master BFM Code Example

April 2014

end master_test_program;

architecture master_test_program_a of master_test_program is

begin
process
variable trans: integer;
variable byte_count : integer := AXI4_DATA_WIDTH/8;
variable transfer_count : integer;
variable k : integer;
variable m : integer;
begin
wait_on(AXI4STREAM_RESET_POSEDGE, index, axi4stream_tr_if_0(index));
wait_on(AXI4STREAM_CLOCK_POSEDGE, index, axi4stream_tr_if_0(index));

--************************
-- Traffic generation: **
--************************
-- 10 x packet with
-- Number of transfer = i % 10. Values : 1, 2 .. 10
-- id = i % 15. Values 0, 1, 2 .. 14
-- dest = i %20. Values 0, 1, 2 .. 19
for i in 0 to 9 loop
transfer_count := (i mod 10) + 1;
create_master_transaction(transfer_count, trans, index,
axi4stream_tr_if_0(index));
set_id(i mod 15, trans, index, axi4stream_tr_if_0(index));
set_dest(i mod 20, trans, index, axi4stream_tr_if_0(index));
for j in 0 to ((transfer_count * byte_count) - 1) loop
set_data(i + j, j, trans, index, axi4stream_tr_if_0(index));
if(((i + j) mod 5) = 0) then
set_byte_type(AXI4STREAM_NULL_BYTE, j, trans, index,
axi4stream_tr_if_0(index));
elsif(((i + j) mod 5) = 1) then
set_byte_type(AXI4STREAM_POS_BYTE, j, trans, index,
axi4stream_tr_if_0(index));
else
set_byte_type(AXI4STREAM_DATA_BYTE, j, trans, index,
axi4stream_tr_if_0(index));
end if;
end loop;
execute_transaction(trans, index, axi4stream_tr_if_0(index));
end loop;

-- 10 x packet at transfer level with
-- Number of transfer = i % 10. Values : 1, 2 .. 10
-- id = i % 15. Values 0, 1, 2 .. 14
-- dest = i %20. Values 0, 1, 2 .. 19
for i in 0 to 9 loop
transfer_count := (i mod 10) + 1;
create_master_transaction(transfer_count, trans, index,
axi4stream_tr_if_0(index));
set_id(i mod 15, trans, index, axi4stream_tr_if_0(index));
set_dest(i mod 20, trans, index, axi4stream_tr_if_0(index));
m := 0;
while(m < transfer_count) loop
k := 0;
while(k < byte_count) loop

Advertising