How to specify default value to a variable of unconstrained type INSIDE a VHDL procedure ?

P

Pankaj

Anyone know how to specify default value to a variable of
unconstrained type
INSIDE a VHDL procedure ?
For example,

type t_HEADER_LENGTH_array is array (natural range<>) of integer ; --
unbounded array of integers

procedure provision_EHI_RAM(
variable headerLength : t_HEADER_LENGTH_array (0 to
ci_NUMBERofHEADERS-1) := (14,2);
....)

compiles with error:
** Error: .\rtl\gbe_wan_tb_defn_pkg.vhd(2361): Parameter default
values do not conform between declarations in package header an
d body: 'headerlength'.

Thanks in advance !

Pankaj
 
J

Jonathan Bromley

Anyone know how to specify default value to a variable of
unconstrained type
INSIDE a VHDL procedure ?
For example,

type t_HEADER_LENGTH_array is array (natural range<>) of integer ;
-- unbounded array of integers

procedure provision_EHI_RAM(
variable headerLength : t_HEADER_LENGTH_array (0 to
ci_NUMBERofHEADERS-1) := (14,2);
...)

compiles with error:
** Error: .\rtl\gbe_wan_tb_defn_pkg.vhd(2361): Parameter default
values do not conform between declarations in package header an
d body: 'headerlength'.

That's not a local variable of the procedure; it's an input
parameter of class variable.

Input parameters of variable class are, as far as I know,
legal but useless. You can't change their values, because
they are of mode "in", so you might as well make the parameter
be of constant class, so that you can supply an expression
rather than a variable as the actual parameter.

If you take off the keyword "variable", and make sure that
the aparameter list is *exactly* the same in both the
package and package body, then it should be OK.

If you want a local variable of the procedure, visible only
within the procedure, that's easier: don't declare it in
the parameter list, but instead declare it in the procedure
body's declarative region:

(package)
procedure provision_EHI_RAM (...);

(package body)
procedure provision_EHI_RAM (...) is
variable headerLength: t_HEADER_LENGTH_array.......
begin
...
end;

Finally, I spy trouble ahead...
variable headerLength :
t_HEADER_LENGTH_array (0 to ci_NUMBERofHEADERS-1)
:= (14,2);

The variable initialisation will work correctly only if
ci_NUMBERofHEADERS) is exactly 2. Can you be sure of this?
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL, Verilog, SystemC, Perl, Tcl/Tk, Verification, Project Services

Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, BH24 1AW, UK
Tel: +44 (0)1425 471223 mail:[email protected]
Fax: +44 (0)1425 471573 Web: http://www.doulos.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.
 
A

anupam

Hi Pankaj,
You have to fix the NUMBERofHEADER here as 2 in a package entity. only
then u will be able to compile the same.
Anupam Garg
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top