Compiler directives in a file list?

Is there a way to get conditional compilation in a file list? For instance, the following doesn’t work

ifdef FOO f1.v else

when fed to ncverilog (or irun) using the -f argument.

Of course, I can use cpp (#ifdef, #else, #endif) to create a file list for ncverilog/irun. Is there a way to do this with ncverilog itself?


A quick solution that would work in any simulator is to put filec.v in your file list:


`ifdef FOO
  `include "f1.v"
  `include "f2.v"

In reply to dave_59:

What do yo suggest in case i have library cells

i have lib.f which have:
-v cell_lib1.v
-v cell_lib2.v

now in each module the .f file includes a reference to this lib.f
-f lib.f

same for moduleB …

and in top level i have top.f
-f moduleA.f
-f moduleB.f

now the compiler parse the lib files for every module …
the simple solution was (if ifdef was supported) to add to lib.f something like
ifndef _lib_guard define _lib_guard
-v cell_lib1.v

what is suggested (beside to build top.f from the basic components) - is there automated flow which can be used?

In reply to Noam Elbaum:

The use of -v can be replaced with separately compiled libraries and tool specific options.

This Mentor/Siemens EDA sponsored public forum is not for discussing tool specific usage or issues. Please read your tool’s user manual or contact your tool vendor directly for support.