|
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY biaoding IS
PORT( rst,up,down: IN BIT;
DA: OUT STD_LOGIC_VECTOR(11 DOWNTO 0));
END biaoding;
ARCHITECTURE bEhAv OF biaoding IS
signal A:STD_LOGIC_VECTOR(3 DOWNTO 0);
BEGIN
PROCESS(rst,up,down)
VARIABLE Q:STD_LOGIC_VECTOR(11 DOWNTO 0);
BEGIN
IF( rst='1' )THEN A <= "0101";
ELSIF( up='1')THEN A <= A+1;
ELSIF( down='1' )THEN A <= A-1;
END IF;
case A IS
WHEN "0000"=> Q:="000000001000";
WHEN "0001"=> Q:="000110100000";
WHEN "0010"=> Q:="001100111000";
WHEN "0011"=> Q:="010011010000";
WHEN "0100"=> Q:="011001101000";
WHEN "0101"=> Q:="100000000000";
WHEN "0110"=> Q:="100110011000";
WHEN "0111"=> Q:="101100110000";
WHEN "1000"=> Q:="110011001000";
WHEN "1001"=> Q:="111001100000";
WHEN "1010"=> Q:="111111110111";
WHEN OTHERS=> NULL;
END case;
da <= Q ;
END PROCESS;
END bEhAv;
这样就可以了 |
|