• 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. Parameterized macros in sv

Stats

  • Locked Locked
  • Replies 4
  • Subscribers 65
  • Views 15658
  • 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

Parameterized macros in sv

jzingman
jzingman over 14 years ago

I'm trying to write what I thought was a fairly simple macro in sv:

 `define DISPLAY  (value) `"INFO:    %0t value = %0x (%m)`", `$time, value

invoked by

  $display (`DISPLAY(bitcnt));

When I try it, I get a lot of error messages:

      $display(`DISPLAY(out_bitcnt));
                      |
ncvlog: *E,EXPRPA (flex_ssi_model.vi,432|22): expecting a right parenthesis (')') [10.2.2][14(IEEE)].
(`define macro: DISPLAY [flex_ssi_model.vi line 19], `include file: flex_ssi_model.vi line 432, file: ./flex_ssi_model.sv line 18)
      $display(`DISPLAY(out_bitcnt));
                      |
ncvlog: *E,EXPCPD (flex_ssi_model.vi,432|22): expecting a valid compiler directive [16(IEEE)].
(`define macro: DISPLAY [flex_ssi_model.vi line 19], `include file: flex_ssi_model.vi line 432, file: ./flex_ssi_model.sv line 18)

 Am I missing something obvious?  I'm running IUS92-s030 in Linux64 using the ncvlog/ncelab flow. The errors are in the ncvlog step.

 Thanks

 Jonathan Zingman

  • Cancel
Parents
  • Shalom B
    Shalom B over 14 years ago

    Hi,

     Regarding the space after the macro name, the LRM says, "If formal arguments are used, the list of formal argument names shall be enclosed in parentheses following the name of the macro... The left parenthesis shall follow the text macro name immediately, with no space in between." That is how the compiler knows that the left parenthesis begins an argument list, and is not part of the macro text.

    You are correct, though, that you need `", but not for the reason you state. You need `" so that "value" will be substituted by the argument value.

    Regards,

    Shalom

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Shalom B
    Shalom B over 14 years ago

    Hi,

     Regarding the space after the macro name, the LRM says, "If formal arguments are used, the list of formal argument names shall be enclosed in parentheses following the name of the macro... The left parenthesis shall follow the text macro name immediately, with no space in between." That is how the compiler knows that the left parenthesis begins an argument list, and is not part of the macro text.

    You are correct, though, that you need `", but not for the reason you state. You need `" so that "value" will be substituted by the argument value.

    Regards,

    Shalom

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

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