0

I have a Verilog define like this:

`define NUM_BANKS 4

and if want to use it in the following code:

if (`NUM_BANKS > 1)
  do something ..
else
  do something else ..

Lint tool is complaining that this expression is going to always be evaluated to true.

2 Answers 2

1

After the `define is applied, the if will always evaulate 4 > 1. The compiler is giving an error, since the if will always be irrelevant.

I'd recommend either replacing your `define with a parameter (if you're looking to have it be changed by a higher-level module or instantiation), or use the compiler directives (http://www.csee.umbc.edu/portal/help/VHDL/verilog/compiler.html for example)

`define HASBANKS
`ifdef (HASBANKS)
...
`else
...
`endif
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Wilcroft, that's actually what I did to make it work. I typecasted the define into a parameter and then used the parameter in the if statement.
0

Lint is correct, since in your expression, 4 > 1 is always true. So if this is what you want, there is no problem.

Neo

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.