Why cant protected types be elements in an array?

T

Tricky

I just stumbled accross this, and wondered why they cannot be elements
in an array? I thought I could get around this by making an array of
pointers to a protected type, but it appears you're not allowed to
make pointers to them either.

Is there a good reason for this?
 
P

Paul Uiterlinden

Tricky said:
I just stumbled accross this, and wondered why they cannot be elements
in an array? I thought I could get around this by making an array of
pointers to a protected type, but it appears you're not allowed to
make pointers to them either.

Ah yes, I too stumbled across this very recently. I had created a fifo
(behavioral code) and then wanted to create a one dimensional array of
fifos. I was quite surprised I could not do that. I have solved it to
dynamically allocate the array internally in the protected type.
Is there a good reason for this?

I have no idea. The only thing I do know is that it severly recsticts the
use of (the otherwise very nice) protected types.
 
J

JimLewis

I just stumbled accross this, and wondered why they cannot be elements
in an array? I thought I could get around this by making an array of
pointers to a protected type, but it appears you're not allowed to
make pointers to them either.

Is there a good reason for this?

Relatively speaking protected types are a new feature.

Are you willing to post more details on what you
are trying to do?

The array of FIFOs that Paul would like to do sounds interesting.

I would also like to be able to initialize data structures
within the protected type - kind of like a constructor for
classes - but I was thinking I wanted something more like
a generic as a more general mechanism.

Long term, I would like to see protected types turn into
classes - however to do things like this we need user
support in voicing the feature request.

Best,
Jim
 
T

Tricky

Relatively speaking protected types are a new feature.

Are you willing to post more details on what you
are trying to do?

The array of FIFOs that Paul would like to do sounds interesting.

I would also like to be able to initialize data structures
within the protected type - kind of like a constructor for
classes - but I was thinking I wanted something more like
a generic as a more general mechanism.

Long term, I would like to see protected types turn into
classes - however to do things like this we need user
support in voicing the feature request.

Best,
Jim

I suppose it boils down to how much code you like to write.

The only situation I can think where an array would be useful could
probably be worked around with generate loops, but then you're going
to have seperate processes running where you could just use one
process containing a for loop.

eg:


process
type pattern_gen_array_t is array(0 to N-1) of pattern_gen_t;

variable pattern_gens : pattern_gen_array_t;
begin

wait until rising_edge(clk);
for i in pattern_gens'range loop
pattern_gens(i).get_next_pixel( sigs => stim(i));
end loop;

end process;

instead of:

pattern_gens_gen : for i in 0 to N-1 generate


process
variable pattern_gen : pattern_gen_t;
begin

wait until rising_edge(clk);
pattern_gen.get_next_pixel(sigs => stim(i));

end process;

end generate pattern_gens_gen;


Actually, I can see the 2nd method as alot more useful when you are
reacting to output's from a UUT as you could separate out all of the
elements in an output array, rather than reacting to the entire array
each time one 1 of them changes.


So nothing Im really frustrated I cant do - I was just a bit surprised
when I found I couldnt do method 1.
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top