Seperate file to hold constants??

Discussion in 'VHDL' started by kwaj, Mar 4, 2004.

  1. kwaj

    kwaj Guest

    I was wondering if there was a way to set up a seperate file to hold
    constants, which could be used in my main program file?

    I figured creating a file titled 'constantsAll.vhdl' and putting the
    following constant in that file,

    >'variable int: ineteger := 24';


    which I would access be a

    >use constantAll


    in my main program would suffice. But this doesn't seem to work. Any ideas?

    --
    - Kwaj
     
    kwaj, Mar 4, 2004
    #1
    1. Advertising

  2. kwaj

    jtw Guest

    In file constant_package.vhd define your constants as follows:

    constant this_constant : integer := 24;

    If this file is compiled into your work directory, then in the files where
    you use this constant,
    you would have (prior to entity):

    use work.constant_package_name.all;

    If you do an appropriate keyword search on the internet, I'm sure you will
    find plenty of examples.

    Jason

    "kwaj" <> wrote in message
    news:c26bme$lb7$...
    > I was wondering if there was a way to set up a seperate file to hold
    > constants, which could be used in my main program file?
    >
    > I figured creating a file titled 'constantsAll.vhdl' and putting the
    > following constant in that file,
    >
    > >'variable int: ineteger := 24';

    >
    > which I would access be a
    >
    > >use constantAll

    >
    > in my main program would suffice. But this doesn't seem to work. Any

    ideas?
    >
    > --
    > - Kwaj
     
    jtw, Mar 4, 2004
    #2
    1. Advertising

  3. What you actually need is a package.

    File my_package.vhd:

    package my_package is --- Within the package you declare constants,
    type, subtypes, functions, and procedures

    constant my_constant : integer := 24;

    end my_package;
    package body my_package is --- Within the package body you describe
    functions, and procedures

    end my_package;

    You now need to compile this file before all others.

    Suppose you compile it in library "work" then other files can use constants,
    type, subtypes, functions, and procedures specified in the package file by
    referencing it.

    File other_file:

    library work;
    use work.my_package.all;

    Hope this answers your question.

    To be honest though, any VHDL book would have provided you with the
    answer... maybe you need to read around a bit more (?)

    Greg

    "kwaj" <> wrote in message
    news:c26bme$lb7$...
    > I was wondering if there was a way to set up a seperate file to hold
    > constants, which could be used in my main program file?
    >
    > I figured creating a file titled 'constantsAll.vhdl' and putting the
    > following constant in that file,
    >
    > >'variable int: ineteger := 24';

    >
    > which I would access be a
    >
    > >use constantAll

    >
    > in my main program would suffice. But this doesn't seem to work. Any

    ideas?
    >
    > --
    > - Kwaj
    >
    >
     
    Grigorios Angelis, Mar 4, 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. anupam
    Replies:
    2
    Views:
    970
  2. Eric
    Replies:
    2
    Views:
    2,110
    Patrice
    Jun 1, 2004
  3. RC
    Replies:
    1
    Views:
    456
    Eliyahu Goldin
    May 16, 2005
  4. DrUg13
    Replies:
    1
    Views:
    495
    DrUg13
    Feb 10, 2004
  5. moondaddy
    Replies:
    2
    Views:
    606
    Steven Cheng[MSFT]
    Oct 16, 2006
Loading...

Share This Page