EmbDev.net

Forum: FPGA, VHDL & Verilog How can I declare local variables in a Verilog task or function?


von Kevin Simonson (Guest)


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?

von Hallo (Guest)


Rate this post
useful
not useful
Function void foo(void);
 Int bar = 4;
Endfunction

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.