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
0 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
0 useful
not useful
Function void foo(void);
 Int bar = 4;
Endfunction

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig