diff --git a/vunit/vhdl/verification_components/src/apb_requester.vhd b/vunit/vhdl/verification_components/src/apb_requester.vhd index fba759ceb..eedd67c09 100644 --- a/vunit/vhdl/verification_components/src/apb_requester.vhd +++ b/vunit/vhdl/verification_components/src/apb_requester.vhd @@ -15,6 +15,7 @@ use work.com_types_pkg.all; use work.queue_pkg.all; use work.sync_pkg.all; use work.logger_pkg.all; +use work.vc_pkg.all; use work.runner_pkg.all; use work.run_pkg.all; use work.run_types_pkg.all; @@ -74,7 +75,9 @@ begin elsif msg_type = wait_for_time_msg then push(message_queue, request_msg); else - unexpected_msg_type(msg_type); + if bus_handle.p_unexpected_msg_type_policy = fail then + unexpected_msg_type(msg_type); + end if; end if; end loop; end process; diff --git a/vunit/vhdl/verification_components/src/apb_requester_pkg.vhd b/vunit/vhdl/verification_components/src/apb_requester_pkg.vhd index 88e532476..e50de5024 100644 --- a/vunit/vhdl/verification_components/src/apb_requester_pkg.vhd +++ b/vunit/vhdl/verification_components/src/apb_requester_pkg.vhd @@ -13,6 +13,8 @@ use work.com_pkg.all; use work.com_types_pkg.all; use work.logger_pkg.all; use work.sync_pkg.all; +use work.id_pkg.all; +use work.vc_pkg.all; use work.memory_pkg.memory_t; use work.memory_pkg.to_vc_interface; @@ -20,16 +22,20 @@ package apb_requester_pkg is type apb_requester_t is record -- Private + p_id : id_t; p_bus_handle : bus_master_t; p_drive_invalid : boolean; p_drive_invalid_val : std_logic; + p_unexpected_msg_type_policy : unexpected_msg_type_policy_t; end record; impure function new_apb_requester( + id : id_t := null_id; data_length : natural; address_length : natural; logger : logger_t := null_logger; actor : actor_t := null_actor; + unexpected_msg_type_policy : unexpected_msg_type_policy_t := fail; drive_invalid : boolean := true; drive_invalid_val : std_logic := 'X' ) return apb_requester_t; @@ -129,10 +135,12 @@ end package; package body apb_requester_pkg is impure function new_apb_requester( + id : id_t := null_id; data_length : natural; address_length : natural; logger : logger_t := null_logger; actor : actor_t := null_actor; + unexpected_msg_type_policy : unexpected_msg_type_policy_t := fail; drive_invalid : boolean := true; drive_invalid_val : std_logic := 'X' ) return apb_requester_t is @@ -146,16 +154,25 @@ package body apb_requester_pkg is ); end function; variable logger_tmp : logger_t := null_logger; + variable id_tmp : id_t := null_id; + constant parent : id_t := get_id("vunit_lib:apb_requester"); begin + if id = null_id then + id_tmp := get_id(to_string(num_children(parent) + 1), parent); + else + id_tmp := id; + end if; if logger = null_logger then - logger_tmp := bus_logger; + logger_tmp := get_logger(id_tmp); else logger_tmp := logger; end if; return ( + p_id => id_tmp, p_bus_handle => create_bus(logger_tmp), p_drive_invalid => drive_invalid, - p_drive_invalid_val => drive_invalid_val + p_drive_invalid_val => drive_invalid_val, + p_unexpected_msg_type_policy => unexpected_msg_type_policy ); end; diff --git a/vunit/vhdl/verification_components/test/tb_apb_requester.vhd b/vunit/vhdl/verification_components/test/tb_apb_requester.vhd index 9051a32e8..d78fe11f5 100644 --- a/vunit/vhdl/verification_components/test/tb_apb_requester.vhd +++ b/vunit/vhdl/verification_components/test/tb_apb_requester.vhd @@ -54,6 +54,8 @@ begin variable buf : buffer_t; variable data, data2 : std_logic_vector(prdata'range); variable bus_ref1, bus_ref2 : bus_reference_t; + constant unexpected_message_type : msg_type_t := new_msg_type("unexpected message"); + variable unexpected_message : msg_t := new_msg(unexpected_message_type); begin show(get_logger("apb slave"), display_handler, debug); @@ -145,6 +147,13 @@ begin "Unexpected pslverror response for write request. - Got 0. Expected 1.", error); unmock(get_logger("check")); + elsif run("unexpected_msg_type_policy_fail") then + mock(get_logger("vunit_lib:com"), failure); + send(net, bus_handle.p_bus_handle.p_actor, unexpected_message); + check_only_log(get_logger("vunit_lib:com"), + "Got unexpected message unexpected message", failure); + unmock(get_logger("vunit_lib:com")); + end if; wait for 100 ns;