1. 用VHDL設計一個五位二進制如何轉換為十進制的程序
很簡單,VHDL裡面有一個二進制轉十進制函數CONV_IETEGER(),在UNSIGNED這個程序包里,打開它用就是了,程序如下,,,
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY TURN2_10 IS
PORT(A:IN STD_LOGIC_VECTOR(4 DOWNTO 0);
B:OUT INTEGER RANGE 0 TO 32);
END;
ARCHITECTURE ART OF TURN2_10 IS
BEGIN
B<=CONV_INTEGER(A);
END;