Search code examples
system-verilogmodelsim

Automatically including a file in all system verilog files


I have adopted a bunch of .sv files from a colleague and each one fails to compile since it is missing the `defined environment variables stored in a file called "globals.sv". Adding the line

`include "globals.sv"

to the top of every file would work but is there a ModelSim command line tag that I can use to automatically include this file for every .sv at compile time? I have to re-run the files with a "globals2.sv" and "globals3.sv" and it would be much easier to be able to include all the files at once. I am imagining a command such as:

vlog -env_variables globals.sv -c *.sv
vlog -env_variables globals2.sv -c *.sv

that would compile each .sv file with the variable definitions in globals.sv.

Any help you could give would be appreciated!


Solution

  • The best thing for you to do would be to write a script that adds the `include globals.sv to the beginning of every *.sv file. Then the code would work on any simulator.

    There is a vlog option called -mfcu which compiles all the files as if they were included into one big file (Multi File Compilation Unit). So you can do something like

    vlog -mfcu globals.sv rtl/*.sv
    vlog -mfcu globals2.sv tb/*.sv