Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > array of records

Reply
Thread Tools

array of records

 
 
Salvatore Callea
Guest
Posts: n/a
 
      04-13-2004
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
 
Reply With Quote
 
 
 
 
Egbert Molenkamp
Guest
Posts: n/a
 
      04-13-2004

"Salvatore Callea" <(E-Mail Removed)> 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



 
Reply With Quote
 
 
 
 
Kris Van Aken
Guest
Posts: n/a
 
      04-13-2004
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

 
Reply With Quote
 
Egbert Molenkamp
Guest
Posts: n/a
 
      04-13-2004

"Egbert Molenkamp" <(E-Mail Removed)> wrote in message
news:c5g9cm$85l$(E-Mail Removed)...
> Solutions:
> 1)
> type pulse_generator is array (natural array <>) of pulse_timing;

this should be: ... (natural RANGE <>) ...


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to read from a file, stored the data in an array, and return number of records read back to main tyeung168@gmail.com C++ 2 02-27-2007 07:12 AM
Simple query returns 0 records in asp, but all records in vbscript masg0013@gmail.com ASP General 3 11-02-2006 09:23 AM
Inferring RAM from array of records jtw VHDL 1 03-09-2006 05:57 PM
Delete records or update records Dan ASP General 1 05-10-2004 01:25 PM
match muliple header records to associated detail records Luke Airig XML 0 12-31-2003 12:06 AM



Advertisments