EmbDev.net

Forum: FPGA, VHDL & Verilog vhdl arrays- index


von felix (Guest)


Rate this post
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

von Markus F. (mfro)


Rate this post
useful
not useful
1
for i in slv'reverse_range loop
2
    if (slv(i) == '1') then
3
        firstSet <= i;
4
        exit;
5
    end if;
6
end loop;

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
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?

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.