Seperate file to hold constants??

K

kwaj

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?
 
J

jtw

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
 
G

Grigorios Angelis

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top