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

Discussion in 'VHDL' started by Pankaj, Aug 20, 2004.

  1. Pankaj

    Pankaj Guest

    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, Aug 20, 2004
    #1
    1. Advertising

  2. 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, Aug 20, 2004
    #2
    1. Advertising

  3. Pankaj

    anupam Guest

    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, Aug 23, 2004
    #3
    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. Replies:
    8
    Views:
    1,886
    Mike Treseler
    Feb 10, 2005
  2. Amal
    Replies:
    5
    Views:
    8,676
    Brandon
    Mar 8, 2006
  3. Replies:
    2
    Views:
    1,402
    JimLewis
    Mar 18, 2009
  4. Anne Onime
    Replies:
    4
    Views:
    1,741
    Charles Gardiner
    Mar 31, 2010
  5. XYZ
    Replies:
    11
    Views:
    4,092
Loading...

Share This Page