T
Tricky
The following code is giving me the error: "Method cannot have a
parameter of an access type."
type A_t;
type a_ptr is access A_t;
type A_t is array(integer range <>) of integer;
type T is protected
procedure add( variable x : in A_ptr);
procedure remove;
impure function get( x, y : integer ) return integer;
end protected T;
type T is protected body
type A_array_t is array(0 to 9) of a_ptr;
variable A : a_array_t;
variable idx : integer := 0;
procedure add( variable x : in A_ptr) is
begin
if idx >= 10 then
report "No more room left. Will not add new array." severity
WARNING;
else
A(idx) := x;
idx := idx + 1;
end if;
end procedure add;
procedure remove is
begin
if idx = 0 then
report "No more data to remove." severity WARNING;
else
DEALLOCATE( A(idx) );
idx := idx - 1;
end if;
end procedure remove;
impure function get(x, y : integer) return integer is
begin
return a(x)(y);
end function get;
end protected body T;
This is a small test bit of VHDL to test out functionality of access
and protected types, not real code.
Essentiall, I want T to store multiple arrays of the same type with
different sizes. Is it possible to do what I am doing, or am I outside
the scope of VHDL?
parameter of an access type."
type A_t;
type a_ptr is access A_t;
type A_t is array(integer range <>) of integer;
type T is protected
procedure add( variable x : in A_ptr);
procedure remove;
impure function get( x, y : integer ) return integer;
end protected T;
type T is protected body
type A_array_t is array(0 to 9) of a_ptr;
variable A : a_array_t;
variable idx : integer := 0;
procedure add( variable x : in A_ptr) is
begin
if idx >= 10 then
report "No more room left. Will not add new array." severity
WARNING;
else
A(idx) := x;
idx := idx + 1;
end if;
end procedure add;
procedure remove is
begin
if idx = 0 then
report "No more data to remove." severity WARNING;
else
DEALLOCATE( A(idx) );
idx := idx - 1;
end if;
end procedure remove;
impure function get(x, y : integer) return integer is
begin
return a(x)(y);
end function get;
end protected body T;
This is a small test bit of VHDL to test out functionality of access
and protected types, not real code.
Essentiall, I want T to store multiple arrays of the same type with
different sizes. Is it possible to do what I am doing, or am I outside
the scope of VHDL?