array of records

Discussion in 'VHDL' started by Salvatore Callea, Apr 13, 2004.

  1. Hallo,
    I've a little trouble with vhdl and I hope some one
    would help me.
    I've an array of records, such as:


    type pulse_timing is record
    delay : time;
    width : time;
    end record;

    type pulse_generator is array (1 to 2) of pulse_timing;


    How can I initialise it?
    I've tried through a constant:


    constant TG : pulse_generator(1 to 2) := (
    ( 6 ns, 50 ns),
    (31 ns, 10 ns)
    );


    but it doesn't work properly.
    Can anybody suggest to me how to proceed?

    Thanks in advance.
    Salvatore
     
    Salvatore Callea, Apr 13, 2004
    #1
    1. Advertising

  2. "Salvatore Callea" <> wrote in message
    news:Xns94CA665CDA69Acalleaslabenit@130.133.1.4...
    > Hallo,
    > I've a little trouble with vhdl and I hope some one
    > would help me.
    > I've an array of records, such as:
    >
    >
    > type pulse_timing is record
    > delay : time;
    > width : time;
    > end record;
    >
    > type pulse_generator is array (1 to 2) of pulse_timing;
    >
    >
    > How can I initialise it?
    > I've tried through a constant:
    >
    >
    > constant TG : pulse_generator(1 to 2) := (
    > ( 6 ns, 50 ns),
    > (31 ns, 10 ns)
    > );
    >
    >
    > but it doesn't work properly.
    > Can anybody suggest to me how to proceed?


    The array is declared as a constrained array. But in the constant
    declaration you try to handle it as un uncontrained array.

    Solutions:
    1)
    type pulse_generator is array (natural array <>) of pulse_timing;
    constant TG : pulse_generator(1 to 2) := ( ( 6 ns, 50 ns), (31 ns, 10
    ns) );

    or
    2)
    type pulse_generator is array (1 to 2) of pulse_timing;
    constant TG : pulse_generator := ( ( 6 ns, 50 ns), (31 ns, 10 ns) );

    Egbert Molenkamp
     
    Egbert Molenkamp, Apr 13, 2004
    #2
    1. Advertising

  3. Salvatore Callea wrote:
    > Hallo,
    > I've a little trouble with vhdl and I hope some one
    > would help me.
    > I've an array of records, such as:
    >
    >
    > type pulse_timing is record
    > delay : time;
    > width : time;
    > end record;
    >
    > type pulse_generator is array (1 to 2) of pulse_timing;
    >
    >
    > How can I initialise it?
    > I've tried through a constant:
    >
    >
    > constant TG : pulse_generator(1 to 2) := (
    > ( 6 ns, 50 ns),
    > (31 ns, 10 ns)
    > );
    >
    >
    > but it doesn't work properly.
    > Can anybody suggest to me how to proceed?
    >
    > Thanks in advance.
    > Salvatore


    Not all synthesis tools support record initialization using aggregates, as you
    are doing. You could try named association:

    constant TG : pulse_generator(1 to 2) := (
    (delay => 6 ns, width => 50 ns),
    (delay => 31 ns, width => 10 ns)
    )

    If that doesn't work, the following strategy can be used:
    Create a function, taking two time arguments and returning a record of type
    pulse_timing that is initialized using the arguments:

    function pulse_timing_init(delay: time;
    width: time) return pulse_timing is
    variable Result: pulse_timing;

    begin

    Result.delay := delay;
    Result.width := width;
    return Result;

    end pulse_timing_init;

    Then you can initialize the array using the function:

    pulse_generator := (pulse_timing_init(6 ns, 50 ns), pulse_timing_init(31 ns, 10
    ns));

    You could of course also define a constant that is initialized using the same
    strategy.

    Hope this works for you.

    Regards,
    Kris
     
    Kris Van Aken, Apr 13, 2004
    #3
  4. "Egbert Molenkamp" <> wrote in message
    news:c5g9cm$85l$...
    > Solutions:
    > 1)
    > type pulse_generator is array (natural array <>) of pulse_timing;

    this should be: ... (natural RANGE <>) ...
     
    Egbert Molenkamp, Apr 13, 2004
    #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. jtw
    Replies:
    1
    Views:
    623
    Mike Treseler
    Mar 9, 2006
  2. Luke Airig
    Replies:
    0
    Views:
    823
    Luke Airig
    Dec 31, 2003
  3. Replies:
    2
    Views:
    655
    Thomas Matthews
    Feb 27, 2007
  4. Dan

    Delete records or update records

    Dan, May 10, 2004, in forum: ASP General
    Replies:
    1
    Views:
    489
    Ray at
    May 10, 2004
  5. Replies:
    3
    Views:
    709
    Anthony Jones
    Nov 2, 2006
Loading...

Share This Page