Why cant protected types be elements in an array?

Discussion in 'VHDL' started by Tricky, Aug 3, 2009.

  1. Tricky

    Tricky Guest

    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?
    Tricky, Aug 3, 2009
    #1
    1. Advertising

  2. 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.
    Paul Uiterlinden, Aug 3, 2009
    #2
    1. Advertising

  3. Tricky

    JimLewis Guest

    On Aug 3, 8:18 am, 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.
    >
    > 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
    JimLewis, Aug 4, 2009
    #3
  4. Tricky

    Tricky Guest

    On Aug 4, 6:27 am, JimLewis <> wrote:
    > On Aug 3, 8:18 am, 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.

    >
    > > 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.
    Tricky, Aug 4, 2009
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Klemt
    Replies:
    2
    Views:
    556
    Andreas Klemt
    Jul 5, 2003
  2. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    875
    Mark Rae
    Dec 21, 2006
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,804
    Smokey Grindel
    Dec 2, 2006
  4. Nagaraj
    Replies:
    1
    Views:
    852
    Lionel B
    Mar 1, 2007
  5. Tricky
    Replies:
    1
    Views:
    833
    JimLewis
    Feb 10, 2012
Loading...

Share This Page