Skip to content

Commit 2eb5409

Browse files
committed
add id and unexpected message policy parameter
Implementing rules 5 and 10. The logger name is set according to the id field.
1 parent f6fd6e5 commit 2eb5409

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

vunit/vhdl/verification_components/src/apb_requester.vhd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use work.com_types_pkg.all;
1515
use work.queue_pkg.all;
1616
use work.sync_pkg.all;
1717
use work.logger_pkg.all;
18+
use work.vc_pkg.all;
1819
use work.runner_pkg.all;
1920
use work.run_pkg.all;
2021
use work.run_types_pkg.all;
@@ -74,7 +75,9 @@ begin
7475
elsif msg_type = wait_for_time_msg then
7576
push(message_queue, request_msg);
7677
else
77-
unexpected_msg_type(msg_type);
78+
if bus_handle.p_unexpected_msg_type_policy = fail then
79+
unexpected_msg_type(msg_type);
80+
end if;
7881
end if;
7982
end loop;
8083
end process;

vunit/vhdl/verification_components/src/apb_requester_pkg.vhd

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,29 @@ use work.com_pkg.all;
1313
use work.com_types_pkg.all;
1414
use work.logger_pkg.all;
1515
use work.sync_pkg.all;
16+
use work.id_pkg.all;
17+
use work.vc_pkg.all;
1618
use work.memory_pkg.memory_t;
1719
use work.memory_pkg.to_vc_interface;
1820

1921
package apb_requester_pkg is
2022

2123
type apb_requester_t is record
2224
-- Private
25+
p_id : id_t;
2326
p_bus_handle : bus_master_t;
2427
p_drive_invalid : boolean;
2528
p_drive_invalid_val : std_logic;
29+
p_unexpected_msg_type_policy : unexpected_msg_type_policy_t;
2630
end record;
2731

2832
impure function new_apb_requester(
33+
id : id_t := null_id;
2934
data_length : natural;
3035
address_length : natural;
3136
logger : logger_t := null_logger;
3237
actor : actor_t := null_actor;
38+
unexpected_msg_type_policy : unexpected_msg_type_policy_t := fail;
3339
drive_invalid : boolean := true;
3440
drive_invalid_val : std_logic := 'X'
3541
) return apb_requester_t;
@@ -129,10 +135,12 @@ end package;
129135
package body apb_requester_pkg is
130136

131137
impure function new_apb_requester(
138+
id : id_t := null_id;
132139
data_length : natural;
133140
address_length : natural;
134141
logger : logger_t := null_logger;
135142
actor : actor_t := null_actor;
143+
unexpected_msg_type_policy : unexpected_msg_type_policy_t := fail;
136144
drive_invalid : boolean := true;
137145
drive_invalid_val : std_logic := 'X'
138146
) return apb_requester_t is
@@ -146,16 +154,25 @@ package body apb_requester_pkg is
146154
);
147155
end function;
148156
variable logger_tmp : logger_t := null_logger;
157+
variable id_tmp : id_t := null_id;
158+
constant parent : id_t := get_id("vunit_lib:apb_requester");
149159
begin
160+
if id = null_id then
161+
id_tmp := get_id(to_string(num_children(parent) + 1), parent);
162+
else
163+
id_tmp := id;
164+
end if;
150165
if logger = null_logger then
151-
logger_tmp := bus_logger;
166+
logger_tmp := get_logger(id_tmp);
152167
else
153168
logger_tmp := logger;
154169
end if;
155170
return (
171+
p_id => id_tmp,
156172
p_bus_handle => create_bus(logger_tmp),
157173
p_drive_invalid => drive_invalid,
158-
p_drive_invalid_val => drive_invalid_val
174+
p_drive_invalid_val => drive_invalid_val,
175+
p_unexpected_msg_type_policy => unexpected_msg_type_policy
159176
);
160177
end;
161178

vunit/vhdl/verification_components/test/tb_apb_requester.vhd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ begin
5454
variable buf : buffer_t;
5555
variable data, data2 : std_logic_vector(prdata'range);
5656
variable bus_ref1, bus_ref2 : bus_reference_t;
57+
constant unexpected_message_type : msg_type_t := new_msg_type("unexpected message");
58+
variable unexpected_message : msg_t := new_msg(unexpected_message_type);
5759
begin
5860
show(get_logger("apb slave"), display_handler, debug);
5961

@@ -145,6 +147,13 @@ begin
145147
"Unexpected pslverror response for write request. - Got 0. Expected 1.", error);
146148
unmock(get_logger("check"));
147149

150+
elsif run("unexpected_msg_type_policy_fail") then
151+
mock(get_logger("vunit_lib:com"), failure);
152+
send(net, bus_handle.p_bus_handle.p_actor, unexpected_message);
153+
check_only_log(get_logger("vunit_lib:com"),
154+
"Got unexpected message unexpected message", failure);
155+
unmock(get_logger("vunit_lib:com"));
156+
148157
end if;
149158

150159
wait for 100 ns;

0 commit comments

Comments
 (0)