• 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. #ifdef #else #endif inside module instantiation in Veri...

Stats

  • Locked Locked
  • Replies 8
  • Subscribers 65
  • Views 22729
  • 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

#ifdef #else #endif inside module instantiation in Verilog

aarthymani
aarthymani over 7 years ago

Hi all, 

             I am trying to reverse engineer an open source verilog code for learning purpose. The code has some similar structure as below(please ignore my syntax errors) 

                         module tb_trail();

                              ....

                              test dut (

                                   .a(out)

                                   .b(in1) 

                                #ifdef TRAIL

                                     .c(in3) 

                                #else 

                                      .c(in4)

                                #endif 

                               );

             I have some basic knowledge in Verilog, and compiling it with INCISIVE. But when i try to compile the above module, I am getting error for missing either left or right parenthesis (*E,EXPLPA).

            Wondering, where is my mistake. Does INCISIVE(irun) supposed to understand those statements? is there a runtime option i need to specify to clear it? for your info, the definition for "TRAIL" is found with *.vh file  and I included it with -incdir option, and also added -vlog_ext +.vh to my run command

            Could someone help? 

Thanks in Advance! 

Aarthy 

                     

  • Cancel
Parents
  • TAM1
    TAM1 over 7 years ago

    It looks like the person who created your Verilog example was using the C preprocessor to handle his defines and macros. Your example shows #ifdef which will work for C. The Verilog preprocessor uses the "accent-grave" character or backwards-single-quote `. It is in the far upper-left of my keyboard. Try this:

    `ifdef TRIAL

      .c(in3),

    `else

      .c(in4),

    `endif

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • TAM1
    TAM1 over 7 years ago

    It looks like the person who created your Verilog example was using the C preprocessor to handle his defines and macros. Your example shows #ifdef which will work for C. The Verilog preprocessor uses the "accent-grave" character or backwards-single-quote `. It is in the far upper-left of my keyboard. Try this:

    `ifdef TRIAL

      .c(in3),

    `else

      .c(in4),

    `endif

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • StephenH
    StephenH over 7 years ago in reply to TAM1

    Good catch Tom, I've been writing C code all day and totally missed the # versus back-tick typo! Slight smile

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • StephenH
    StephenH over 7 years ago in reply to StephenH

    As ever though, this highlights why it's better to submit a runnable testcase rather than a broken code fragment that has multiple errors in it!

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • aarthymani
    aarthymani over 7 years ago in reply to StephenH

    Hi Stephen, 

              I totally understand. It is my mistake :( I will make sure I will post a bug free/no syntax error codes in future. The code is based on open source License, so I wasn't sure whether I can just like post anywhere.  I should have checked before posting my example.  :(

     

    Tom, Thanks for your response. I will change and try to simulate, will update here. 

    Thanks!

    Aarthy

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • aarthymani
    aarthymani over 7 years ago in reply to TAM1

    Hi Tom,

       Changing the " # " to " ` " does solve that missing parenthesis error.

       Thank you! 

    • 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