EmbDev.net

Forum: FPGA, VHDL & Verilog vhdl arrays- index


Author: felix (Guest)
Posted on:

Rate this post
0 useful
not useful
hi,

is there any predefined function in vhdl, that returns index of the bit 
that is set to '1' in a vector. thanks

Author: Markus F. (mfro)
Posted on:

Rate this post
0 useful
not useful
for i in slv'reverse_range loop
    if (slv(i) == '1') then
        firstSet <= i;
        exit;
    end if;
end loop;

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
0 useful
not useful
felix wrote:
> that returns index of the bit that is set to '1' in a vector.
(How) can you be sure that only 1 bit is set in the vector?

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