Write a VHDL function that converts a 5bit bitvector to an i

Write a VHDL function that converts a 5-bit bit_vector to an integer. Note that the integer value of the binary number a4 a3 a2 a1 a0 can be computed as

((((0 + a4)*2 + a3)*2 + a2)*2 + a1)*2 + a0

How much simulated time will it take for your function to execute?

Solution

part 1) VHDL function:

REPLACE THE TERMS BEFORE EXCUTING

NAME=MINE

STD-LOGIC-VECTOR= STD_LOGIC_VECTOR

NUM=NUMB

library ieee;

use ieee.std-logic-1164.all;

package NAME is

function CONVERT (IN PUT : std-logic-vector (4 down to 0)) return

in teger;

end NAME;

package body NAME is

function CONVERT (IN PUT : std-logic-vector (4 down to 0)) return

in teger is

variable NUM:in teger;

begin

NUM := 0;

For’I’ in 4 down to 0 loop

if (IN PUT(‘I’) /= \'0\' and IN PUT(‘I’) /= \'1\') then    % it is

report \"Invalid bit provided in input.\";

return NUM;

     else

if IN PUT(I) = \'1\' then NUM := NUM + 1;

end if;

NUM := NUM * 2;

end if;

end loop;

end CONVERT;

end NAME;

Write a VHDL function that converts a 5-bit bit_vector to an integer. Note that the integer value of the binary number a4 a3 a2 a1 a0 can be computed as ((((0 +
Write a VHDL function that converts a 5-bit bit_vector to an integer. Note that the integer value of the binary number a4 a3 a2 a1 a0 can be computed as ((((0 +

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site