Seperate file to hold constants??

K

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
 
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" <k.otengNOSPAM@student.unsw.edu.auNOSPAM> wrote in message
news:c26bme$lb7$1@tomahawk.unsw.edu.au...
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
 
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" <k.otengNOSPAM@student.unsw.edu.auNOSPAM> wrote in message
news:c26bme$lb7$1@tomahawk.unsw.edu.au...
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
 

Welcome to EDABoard.com

Sponsor

Back
Top