Skip to content

Commit

Permalink
Added support for dict_t in com messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsAsplund committed May 31, 2022
1 parent 68cb6e8 commit c23790d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
17 changes: 17 additions & 0 deletions vunit/vhdl/com/src/com_types.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use work.logger_pkg.all;
use work.queue_pkg.all;
use work.queue_2008p_pkg.all;
use work.queue_pool_pkg.all;
use work.dict_pkg.all;

package com_types_pkg is

Expand Down Expand Up @@ -394,6 +395,11 @@ package com_types_pkg is
alias push_integer_array_t_ref is push_ref[msg_t, integer_array_t];
alias pop_integer_array_t_ref is pop_ref[msg_t return integer_array_t];

procedure push_ref(constant msg : msg_t; value : inout dict_t);
impure function pop_ref(msg : msg_t) return dict_t;
alias push_dict_t_ref is push_ref[msg_t, dict_t];
alias pop_dict_t_ref is pop_ref[msg_t return dict_t];

end package;

package body com_types_pkg is
Expand Down Expand Up @@ -854,4 +860,15 @@ package body com_types_pkg is
return pop_ref(msg.data);
end;

procedure push_ref(constant msg : msg_t; value : inout dict_t) is
begin
push_ref(msg.data, value);
end;

impure function pop_ref(msg : msg_t) return dict_t is
begin
return pop_ref(msg.data);
end;


end package body com_types_pkg;
9 changes: 9 additions & 0 deletions vunit/vhdl/com/test/tb_com_msg_building.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ context vunit_lib.com_context;
use vunit_lib.queue_pkg.all;
use vunit_lib.integer_vector_ptr_pkg.all;
use vunit_lib.integer_array_pkg.all;
use vunit_lib.dict_pkg.all;

library ieee;
use ieee.std_logic_1164.all;
Expand Down Expand Up @@ -39,6 +40,7 @@ begin
variable boolv : boolean_vector(0 to 1);
variable integer_vector_ptr, integer_vector_ptr_copy : integer_vector_ptr_t;
variable integer_array, integer_array_copy : integer_array_t;
variable dict : dict_t;

constant my_msg_type : msg_type_t := new_msg_type("my msg type");
begin
Expand Down Expand Up @@ -268,6 +270,13 @@ begin
push_integer_array_t_ref(msg, integer_array);
check(integer_array = null_integer_array);
check(pop_integer_array_t_ref(msg) = integer_array_copy);
elsif run("Test push and pop of dict_t") then
msg := new_msg;
dict := new_dict;
set_integer(dict, "key", 17);
push_dict_t_ref(msg, dict);
check(dict = null_dict);
check_equal(get_integer(pop_dict_t_ref(msg), "key"), 17);
elsif run("Test push and pop of msg_t") then
msg := new_msg;
msg2 := new_msg;
Expand Down

0 comments on commit c23790d

Please sign in to comment.