Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

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

 
Thread Tools Search this Thread
Old 08-20-2004, 04:41 PM   #1
Default How to specify default value to a variable of unconstrained type INSIDE a VHDL procedure ?


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


Pankaj
  Reply With Quote
Old 08-20-2004, 05:37 PM   #2
Jonathan Bromley
 
Posts: n/a
Default Re: How to specify default value to a variable of unconstrained type INSIDE a VHDL procedure ?
On 20 Aug 2004 08:41:07 -0700, (Pankaj) wrote:

>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:
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.


Jonathan Bromley
  Reply With Quote
Old 08-23-2004, 05:36 AM   #3
anupam
 
Posts: n/a
Default Re: How to specify default value to a variable of unconstrained type
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



anupam
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Eclipse - Axis2 - Java Webservices Error amanjsingh Software 1 10-09-2007 09:03 AM
Need help on Modelsim VHDL syntax? ASAP:) kaji General Help Related Topics 0 03-14-2007 10:43 PM
Need help on a Modelsim VHDL Syntax? ASAP:) kaji Software 0 03-14-2007 10:43 PM
Need Help on a Modelsim VHDL Syntax....ASAP:) kaji Hardware 0 03-14-2007 10:41 PM
Spoke to Spoke Enhanced Config (ASA-PIX) NEED HELP ASAP!! T-Mak Hardware 1 10-27-2006 11:56 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46