• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Functional Verification
  3. Macro in `include compiler directive.

Stats

  • Locked Locked
  • Replies 6
  • Subscribers 66
  • Views 21574
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Macro in `include compiler directive.

VerificationMike
VerificationMike over 6 years ago

Hi there, SystemVerilog community,

I would like to run several instances of a simulation, each with a separate include file rom a different path. I would like to hand a +define+FILEPATH to the simulation and use the in the line, where I include the files. Now, what I have found out is, that an "include" directive cannot resolve macros. Is that correct? Is there a way around it? Do you have any suggestions?

Example with code:

call simulation with +define+FILEPATH "/.../..."

then use:

`include FILEPATH

-> can't be done.

Thank you for any help on this.

Michael

  • Cancel
  • StephenH
    StephenH over 6 years ago

    You really don't want to use a macro for this, as it would force you to recompile for each simulation. You should consider using the $value$plusarg() call to pass in a string at simulation time:

    xrun -R +rom_file=/path/to/rom_image.hex

    string romfile;
    initial begin
      if ($value$plusargs("rom_file=",romfile))
        $readmemh(....);
      else
        $fatal(1,"No ROM file specified");
    end

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Tudor Timi
    Tudor Timi over 6 years ago

    Haven't tried it out myself, but if you would want FILEPATH to be dereferenced as a define, you should write:  `include `FILEPATH  

    Still not sure if this will work

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Tudor Timi
    Tudor Timi over 6 years ago in reply to StephenH

    I think the op wanted to say "each file from a different path" and was not talking about preloading a ROM image.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • StephenH
    StephenH over 6 years ago in reply to Tudor Timi

    Good point Tudor, clearly I need more coffee ;-)

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • muffi
    muffi over 6 years ago

    Hi,

    The following works:

     > more test.sv
    `define FILEPATH ""
    //`include "foo.sv"
    `include  `FILEPATH
    module test;
      foo foo_i();
      initial begin
        $display("module test");
        $display("FILEPATH = %s", `FILEPATH);
      end
    endmodule

    > more foo.sv
    module foo;
      initial $display("module foo");
    endmodule

    > xrun -clean test.sv +define+FILEPATH='"foo.sv"'

    Log Snippet:

    xcelium> run
    module foo
    module test
    FILEPATH = foo.sv
    xmsim: *W,RNQUIE: Simulation is complete.
    xcelium> exit

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • VerificationMike
    VerificationMike over 6 years ago

    Hi everybody, thank you for your very quick help!

    I confirm muffi's code works for me, too.

    I made an interesting observation, though. I tried a similar line, that didn't work, which is why I came to this forum, in first place.

    What I literally had in my code was something like this:

    `include "/../../.."`FILEPATH"/../.."

    So, I actually just wanted to hand various directory names per external defines to the simulator. And this apparently cannot be done! So, macros, that would need to replaced inline, can't be resolved. Full paths given per macro, like in muffi's example work, though.

    I just wanted to share this with you. muffi's solution solves my issue, as I can hand over full paths in my flow.

    Again, thank you all!

    Michael

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information