array of records

S

Salvatore Callea

Guest
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" <callea.sREMOVEME@laben.it> 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
 
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
 
"Egbert Molenkamp" <remove_funny_molenkam@cs.utwente.nl> wrote in message
news:c5g9cm$85l$1@ares.cs.utwente.nl...
Solutions:
1)
type pulse_generator is array (natural array <>) of pulse_timing;
this should be: ... (natural RANGE <>) ...
 

Welcome to EDABoard.com

Sponsor

Back
Top