Generic package

Discussion in 'VHDL' started by patrick.melet@dmradiocom.fr, Sep 12, 2006.

  1. Guest

    hi,

    is it possible to define a package with a generic option

    i would like to have this :

    package decoder is

    generic (N : natural)

    type POLY_TAB is array(0 to N) of std_logic_vector(7 downto 0);
    ....


    thanks
     
    , Sep 12, 2006
    #1
    1. Advertising

  2. KJ Guest

    <> wrote in message
    news:...
    > hi,
    >
    > is it possible to define a package with a generic option
    >
    > i would like to have this :
    >
    > package decoder is
    >
    > generic (N : natural)
    >
    > type POLY_TAB is array(0 to N) of std_logic_vector(7 downto 0);
    > ...
    >


    The short answer is 'no you can't put the generic in the package'. But the
    following might work for you instead...

    package decoder is
    type POLY_TAB is array(natural range <>) of std_logic_vector(7 downto 0);
    end package decoder;

    Now type 'POLY_TAB' is an unconstrained array. At some point you'll want to
    use it and you would declare a signal as...

    signal My_Poly_Tab: POLY_TAB(0 to 5);

    KJ
     
    KJ, Sep 12, 2006
    #2
    1. Advertising

  3. Andy Guest

    For now, KJ's approach is a close as you can get. But I believe the
    next balloted revision of VHDL is due to have generic packages. Then
    the vendors will have to update their tools to support it...

    Andy


    KJ wrote:
    > <> wrote in message
    > news:...
    > > hi,
    > >
    > > is it possible to define a package with a generic option
    > >
    > > i would like to have this :
    > >
    > > package decoder is
    > >
    > > generic (N : natural)
    > >
    > > type POLY_TAB is array(0 to N) of std_logic_vector(7 downto 0);
    > > ...
    > >

    >
    > The short answer is 'no you can't put the generic in the package'. But the
    > following might work for you instead...
    >
    > package decoder is
    > type POLY_TAB is array(natural range <>) of std_logic_vector(7 downto 0);
    > end package decoder;
    >
    > Now type 'POLY_TAB' is an unconstrained array. At some point you'll want to
    > use it and you would declare a signal as...
    >
    > signal My_Poly_Tab: POLY_TAB(0 to 5);
    >
    > KJ
     
    Andy, Sep 12, 2006
    #3
  4. Guest

    thank you KJ

    the solution you give works fine....
     
    , Sep 12, 2006
    #4
  5. David Bishop Guest

    wrote:
    > hi,
    >
    > is it possible to define a package with a generic option
    >
    > i would like to have this :
    >
    > package decoder is
    >
    > generic (N : natural)
    >
    > type POLY_TAB is array(0 to N) of std_logic_vector(7 downto 0);
    > ...


    It turns out that this is a feature of VHDL-2006.

    Take a look at the code at:
    http://www.vhdl.org/vhdl-200x/vhdl-200x-ft/files.html
     
    David Bishop, Sep 13, 2006
    #5
    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. MB
    Replies:
    1
    Views:
    738
  2. Murat Tasan
    Replies:
    1
    Views:
    8,097
    Chaitanya
    Feb 3, 2009
  3. Replies:
    2
    Views:
    457
  4. Olaf Petzold

    Generic entities in package

    Olaf Petzold, Apr 6, 2007, in forum: VHDL
    Replies:
    1
    Views:
    450
    Mike Treseler
    Apr 6, 2007
  5. minlearn
    Replies:
    2
    Views:
    476
    red floyd
    Mar 13, 2009
Loading...

Share This Page