aboutsummaryrefslogtreecommitdiffstats
path: root/testsuite/gna/issue2250/ent.vhdl
blob: c640e4b3ad07b9b6932380001229375d351078a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

package test_pkg is
  generic (type t_element;
           function to_string_element(element : t_element) return string
           );
end package;

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity test is
end entity test;
architecture beh of test is
  type t_record is record
    address : std_logic_vector(7 downto 0);
    data    : std_logic_vector(7 downto 0);
  end record t_record;

  function record_to_string(
    constant rec_data : t_record
  ) return string is
  begin
    return "address: " & to_string(rec_data.address) & ", data: " & to_string(rec_data.data);
  end function record_to_string;

  package record_pkg is new work.test_pkg
  generic map (t_element         => t_record,
               to_string_element => record_to_string);

  use record_pkg.all;

begin
  process
    variable v_input : t_record := (x"AA", x"BB");
  begin
    report "Val is " & to_string_element(v_input) severity note;
    wait;
  end process;

end architecture beh;