Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Returns number of bits required to represent val in binary vector
- function bits_req(val : natural) return natural is
- variable res_v : natural; -- Result
- variable remain_v : natural; -- Remainder used in iteration
- begin
- res_v := 0;
- remain_v := val;
- while remain_v > 0 loop -- Iteration for each bit required
- res_v := res_v + 1;
- remain_v := remain_v / 2;
- end loop;
- return res_v;
- end function;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement