I have a vhdl design that needs adapting to different variants. It would be nice to be able to generate the configurations from a makefile. The makefile for the generation of one project is ready and working.
I want to avoid having different very similar files for different projects. The only differences between the projects are a couple of rows somewhere, and that one of them includes a bunch of vhdl files (and components) that the other one does not need.
I want to avoid having two different top level vhd files, for example. Instead I want to use conditionals inside the top file in order to include (or not) the other vhdl files and components, depending on project.
Do you have any suggestion as to how to do this?
I have tried to use an external pre-compiler (gcc's) but could not make it work. Furthermore I don't really want to force other developers to install gcc, or the vhdl files not to be usable from within the Xilinx IDE.
Edit: Adding an example
I have two products, A and B. I want to use the same files for both products, with conditionals to exclude some parts for product B, generate the configurations for different HW parts, and surely other things.
I want to generate the configs from the command line with:
make product_A
, and make product_B
.
If I put generates
in my vhdl to include/exclude code depending on the target, then xst needs to know what target is being built. The question is about how to pass the current target from the makefile to xst.
In C code compiling with gcc, I'd put in the source code:
#if defined(product_B)
...
#elsif defined(product_A)
...
#endif
, then set the define in the makefile:
product_A: source.c
gcc -Dproduct_A source.c
product_B: source.c
gcc -Dproduct_B source.c