VHDL的程序包
比如说,如下这个程序,UNSIGNED包的作用是什么呢?
- LIBRARY IEEE;
- USE IEEE.STD_LOGIC_1164.ALL;
- USE IEEE.STD_LOGIC_UNSIGNED.ALL;
- ENTITY JOYSTICK IS
- PORT(
- CLK: IN STD_LOGIC;
- RESET: IN STD_LOGIC;
- DATA: IN STD_LOGIC_VECTOR(4 DOWNTO 0);
- LED: OUT STD_LOGIC_VECTOR(3 DOWNTO 0)
- );
- END JOYSTICK;
- ARCHITECTURE LED OF JOYSTICK IS
- BEGIN
- process( DATA )
- begin
- if(DATA= "11110") then
- LED <= "0001";
- elsif(DATA= "11101") then
- LED <= "0010";
- elsif(DATA= "11011") then
- LED <= "0011";
- elsif(DATA= "10111") then
- LED <= "0100";
- elsif(DATA= "01111") then
- LED <= "0101";
- else LED <= "0000";
- end if;
- end process;
- END LED;
1)无符号数据类型(UNSIGNED TYPE)
UNSIGNED数据类型代表一个无符号的数值,在综合器中,这个数值被解释为一个二进制数,这个二进制数的最左位是其最高位。
2) 有符号数据类型(SIGNED TYPE)
SIGNED数据类型表示一个有符号的数值,综合器将其解释为补码,此数的最高位是符号位,例如:SIGNED(“0101”) 代表+5,5;SIGNED(“1101”) 代表-5。
VHDL定义了四个常用的程序包:
? std_logic_1164 (std_logic types & related functions),这个是标准逻辑类型和相关函数运算包
? std_logic_arith (arithmetic functions),这个是运算函数包
? std_logic_signed (signed arithmetic functions)这个是有符号数运算函数包
? std_logic_unsigned (unsigned rithmetic functions),这个是无符号数运算函数包
VHDL定义了四个常用的程序包:
? std_logic_1164 (std_logic types & related functions),这个是标准逻辑类型和相关函数运算包
? std_logic_arith (arithmetic functions),这个是运算函数包
? std_logic_signed (signed arithmetic functions)这个是有符号数运算函数包
? std_logic_unsigned (unsigned rithmetic functions),这个是无符号数运算函数包