Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   VHDL (http://www.velocityreviews.com/forums/f18-vhdl.html)
-   -   Why cant protected types be elements in an array? (http://www.velocityreviews.com/forums/t693464-why-cant-protected-types-be-elements-in-an-array.html)

Tricky 08-03-2009 03:18 PM

Why cant protected types be elements in an array?
 
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?

Paul Uiterlinden 08-03-2009 05:24 PM

Re: Why cant protected types be elements in an array?
 
Tricky wrote:

> 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.

--
Paul Uiterlinden
www.aimvalley.nl
e-mail addres: remove the not.

JimLewis 08-04-2009 05:27 AM

Re: Why cant protected types be elements in an array?
 
On Aug 3, 8:18*am, Tricky <Trickyh...@gmail.com> wrote:
> 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


Tricky 08-04-2009 07:58 AM

Re: Why cant protected types be elements in an array?
 
On Aug 4, 6:27*am, JimLewis <J...@SynthWorks.com> wrote:
> On Aug 3, 8:18*am, Tricky <Trickyh...@gmail.com> wrote:
>
> > 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


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.


All times are GMT. The time now is 04:21 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.