Some LRM Help

T

Tricky

I would like to know if Im breaking the LRM, because Modelsim throws
me this error :

Error: AWEP_upsampler_TB.vhd(109): Method cannot have a formal
parameter of an access type.


type img_ptr is access image_grey_2d_t;

type source_img_t is protected
procedure setup; --This procedure should be called once at the
start of simulation
procedure create_new_image;
procedure get_source_img( variable source : out img_ptr ); --this
is where the error points to.
end protected source_img_t;

The error occurs when source is decalred as out or inout, or when it's
a function that returns a pointer. Can protected type variables really
not have pointers in them, when normal procedures can?

I was trying to do it this way to save me having copies of the same
array in separate processes.

Thanks in advance
 
T

Tricky

Yes you are breaking the LRM. From the VHDL 2002 LRM:

"Each subprogram specified within a given protected type declaration
defines an abstract operation, called a
method, ... . Such formal
parameters must not be of an access type or a file type; moreover, they
must not have a subelement that is an
access type or a file type. Additionally, in the case of a function
subprogram, the return type of the function
must not be of an access type or file type; moreover, it must not have a
subelement that is an access type or a
file type."

Whenever I've used protected types, I've ended up going back to a plain
VHDL package, which is more flexible (though not as encapsulated).

You can still hide implementation details in a package body to some extent,

regards
Alan

--
Alan Fitch
Senior Consultant

Doulos – Developing Design Know-how
VHDL * Verilog * SystemVerilog * SystemC * PSL * Perl * Tcl/Tk * Project
Services

Doulos Ltd. Church Hatch, 22 Marketing Place, Ringwood, Hampshire, BH24
1AW, UK
Tel:  + 44 (0)1425 471223               Email: (e-mail address removed)
Fax:  +44 (0)1425 471573                http://www.doulos.com

Thats a shame - dont quite understand why that rule is there. Anyway,
work around is not very hard.

Personally, I like encapsulating things up into protected types. For
some things I have, without the protected types, I would need shared
(unprotected) variables to get all the functions to work, and thats
technically breaking the 2002 LRM. One example that works nicely in a
protected type is a string tokeniser.
 
J

JimLewis

If returning pointers is allowed, then the mutual exclusive access to
the protected type is no longer guaranteed - you simply dereference
the pointer and grab a value.

Have you tried to create the data structure inside the protected
type? This is what I do with my scoreboards and memories.

Cheers,
Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top