How can I declare local variables in a Verilog task or function?

Guest #5985465
Rate this post
• ▲ useful
▼ not useful
I'm writing a module called "lessThan" in Verilog and it has an integer 
parameter called "keyBits". This module has two input ports, each 
(keyBits) bits long, and one output port, one bit long. I'd like to 
write a task called "cielLog" that gives me the lowest integer that is 
greater than or equal to the log (base two) of "keyBits". The easiest 
way to do that is to create two local integer variables "exponent" and 
"power", initialize them to zero and one respectively, and then start 
incrementing (exponent), maintaining the invariant that two to the 
(exponent) power always equals (power). How do you declare local 
variables in a Verilog task or function?

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.