EmbDev.net

Forum: FPGA, VHDL & Verilog How can I make array length the logarithm of an input parameter in Verilog?


von Kevin S. (kvnsmnsn)


Rate this post
0 useful
not useful
The Verilog module I want to write has a parameter that is an integer, 
and I need to create an array of integers whose length is the ceiling of 
(smallest integer greater than or equal to) the log (base two) of that 
parameter. Does anyone know how I can do that in Verilog?

von Vancouver (Guest)


Rate this post
0 useful
not useful
So why not simply writing a log_2() function in verilog and use this in 
the declaration of the integer array? There are plenty examples for 
doing so,
e.g. 
https://www.edaboard.com/showthread.php?177879-how-to-calculate-log2(n)-in-verilog

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