Skip to content

Commit

Permalink
add id and unexpected message policy parameter
Browse files Browse the repository at this point in the history
Implementing rules 5 and 10.
The logger name is set according to the id field.
  • Loading branch information
c-thaler committed Nov 8, 2024
1 parent f6fd6e5 commit 2eb5409
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
5 changes: 4 additions & 1 deletion vunit/vhdl/verification_components/src/apb_requester.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
21 changes: 19 additions & 2 deletions vunit/vhdl/verification_components/src/apb_requester_pkg.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,29 @@ 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;

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;
Expand Down Expand Up @@ -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
Expand All @@ -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;

Expand Down
9 changes: 9 additions & 0 deletions vunit/vhdl/verification_components/test/tb_apb_requester.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 2eb5409

Please sign in to comment.