blob: 1eb678eeea2374eccf6f1b98cc49895c60d20cea (
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
package pkg_c is
type byte_vector_access_t is access string;
type extbuf_access_t is access string(1 to integer'high);
impure function
get_addr(
id : integer
) return extbuf_access_t;
attribute foreign of get_addr : function is "VHPIDIRECT get_addr";
impure function
get_baddr(
id : integer
) return byte_vector_access_t;
attribute foreign of get_baddr : function is "VHPIDIRECT get_baddr";
procedure
set(
index : natural;
value : natural
);
impure function
get(
index : natural
) return natural;
end pkg_c;
package body pkg_c is
impure function
get_addr(
id : integer
) return extbuf_access_t is begin
assert false report "VHPI get_addr" severity failure;
end;
impure function
get_baddr(
id : integer
) return byte_vector_access_t is begin
assert false report "VHPI get_baddr" severity failure;
end;
procedure
set(
index : natural;
value : natural
) is
variable a : extbuf_access_t := get_addr(0);
variable b : byte_vector_access_t := get_baddr(0);
variable c : byte_vector_access_t(1 to integer'high) := get_baddr(0);
begin
a(index+1) := character'val(value);
--b(index+1) := character'val(value);
c(index+1) := character'val(value);
end;
impure function
get(
index : natural
) return natural is
variable a : extbuf_access_t := get_addr(0);
variable b : byte_vector_access_t := get_baddr(0);
variable c : byte_vector_access_t(1 to integer'high) := get_baddr(0);
begin
return character'pos(a(index+1));
--return character'pos(b(index+1));
return character'pos(c(index+1));
end;
end pkg_c;
|