pass parameter to `include

M

Matt Freel

Guest
Is there anyway to pass a parameter to `include? I'm trying to do the
following

parameter DEFFILE = "file.txt";

`include DEFFILE;

This gives me errors though.... Anyone have any ideas?
 
Hi Matt,

`include is preprocessor option hence you can not change it runtime or
elaboration time.
So the parameter has to be constant during compilation.
It really can not take parameter as input because parameters can be
overridden during instantiation.

You can incorporate some kind of programablity using `define, `ifdef,
`ifndef etc.. combining with command line parameter
+define+macro=value etc.

--Abhijit
"Matt Freel" <me@don't.bother> wrote in message news:<bnmn8j$98i$1@msunews.cl.msu.edu>...
Is there anyway to pass a parameter to `include? I'm trying to do the
following

parameter DEFFILE = "file.txt";

`include DEFFILE;

This gives me errors though.... Anyone have any ideas?
 
I'm guessing this doesn't work because preprocessor directives like
`include are processed before module instantiation and parameter
evaluation. But have you tried something like this?

`include `INCFILE

and then define INCFILE on the command line like this:
+define+INCFILE=\"file1.txt\"

You have to escape the quotes so that they become part of INCFILE.

-cb
 
"Matt Freel" <me@don't.bother> wrote in message news:<bnmn8j$98i$1@msunews.cl.msu.edu>...
Is there anyway to pass a parameter to `include? I'm trying to do the
following
Parameter? No. Parameter values aren't known until the design is
elaborated. `include happens before the design is even parsed. Think
of `include as part of a preprocessor pass before compilation really
starts, and which feeds its output into the compiler itself.

The only things that could be referenced by `include are macros,
since those are also processed at the same early time. Some tools
may allow you to use a macro as an argument to `include. Depending
on what you are trying to do, this may be sufficient.
 
The only way I know how to parameterize the include file is to change
the directory the file is in (I don't know how to parameterize the
include file name). There should be a simulator command line argument
that sets the include search path, for example, ncverilog
+incdir+<dirs>

Then, in your code, you would still have:
`include file.txt;

But, the command line argument would tell it which directory to look
for file.txt.

Hope this helps.


"Matt Freel" <me@don't.bother> wrote in message news:<bnmn8j$98i$1@msunews.cl.msu.edu>...
Is there anyway to pass a parameter to `include? I'm trying to do the
following

parameter DEFFILE = "file.txt";

`include DEFFILE;

This gives me errors though.... Anyone have any ideas?
 

Welcome to EDABoard.com

Sponsor

Back
Top