Guest
Hello everybody, I have question here about bit'pos. I saw this
function from a place.
function bt_to_natural(bv: in bit_vector) return natural is
variable result : natural:=0;
begin
for index in bv'range loop
result :=result*2+bit'pos(bv(index));
end loop;
return result;
end bv_to_natural;
I am searching the bit'pos on the internet. And I found one
explaination is :
signal 'pos is return the position (number) of the input.
bit' pos('0') would return 0; bit'pos('1') would return 1;
I am a little bit confused about it. I think 'pos should be the
position of the bit. But I take my definition into above function. I
cannot figure it out.
Is there anybody to help me figure it out? Could you give a real
example for me? For example how to convert 10101010 to the integer.
Many thanks.
Zhi
function from a place.
function bt_to_natural(bv: in bit_vector) return natural is
variable result : natural:=0;
begin
for index in bv'range loop
result :=result*2+bit'pos(bv(index));
end loop;
return result;
end bv_to_natural;
I am searching the bit'pos on the internet. And I found one
explaination is :
signal 'pos is return the position (number) of the input.
bit' pos('0') would return 0; bit'pos('1') would return 1;
I am a little bit confused about it. I think 'pos should be the
position of the bit. But I take my definition into above function. I
cannot figure it out.
Is there anybody to help me figure it out? Could you give a real
example for me? For example how to convert 10101010 to the integer.
Many thanks.
Zhi