I've a statement in verilog looking like integer level = log(N)
(Where N is a parameter and level is to be determined) But I understand I cannot do complex math statements in verilog, so I'm wondering if there is an alternative solution to the above problem?
Any feedback appreciated!
If it is a logarithm base 2 you are trying to do, you can use the built-in function $clog2() .
In Verilog: == tests logical equality (tests for 1 and 0, all other will result in x) === tests 4-state logical equality (tests for 1, 0, z and x)
Verilog Arithmetic OperatorsThe result will be 1 if the second operand of a power operator is 0 (a0). An example of how arithmetic operators are used is given below. ncsim> run Add + = 54 Sub - = 36 Mul * = 149 Div / = 5 Mod % = 0 Pow ** = 81 ncsim: *W,RNQUIE: Simulation is complete.
If it is a logarithm base 2 you are trying to do, you can use the built-in function $clog2()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With