Question: create an i2std (integer to std_logic_vector) function similar to the one for i2v function in vhdl i2bv Integer to Bit_vector. In: integer, value and width.
create an i2std (integer to std_logic_vector) function similar to the one for i2v function in vhdl
i2bv Integer to Bit_vector. In: integer, value and width. Return: bit_vector, with right bit the most significant. FUNCTION i2bv (VAL, width : INTEGER) RETURN BIT_VECTOR IS VARIABLE result BIT_VECTOR (0 to width-i) .- (OTHERS=>'O'); VARIABLE bits INTEGER .- width; BEGIN IF (bits> 32) THEN bits := 32; ELSE ASSERT 2**bits > VAL REPORT Avoid overflow errors. "Value too big FOR BIT_VECTOR width" SEVERITY WARNING; END IFi FOR i IN 0 TO bits - IF ( (vall (2**i) ) result(i) END IF; END LOOP; RETURN (result); END i2bv;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
