船舶控制:1正车指令;2倒车指令;档位(3前进+1,4后退+1,5停止);控制指令:(6驾控,7集控,8机控);9紧急停车;10越控;11消音;12试验;一共12个按键,帮忙把下面程序改一下会么?谢谢
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;
USE ieee.std_logic_unsigned.ALL;
ENTITY anjian IS
PORT(
pq:in std_logic_vector(1 to 12);
clk:in std_logic;
clr:in std_logic;
aa: out std_logic_vector(7 downto 0)
);
END anjian;
ARCHITECTURE anjian_encoder OF anjian IS
BEGIN
PROCESS(clk,clr)
BEGIN
IF (clk'event and clk='1')THEN
IF (clr='1' ) THEN
aa<="00000000";
ELSE
CASE pq IS
WHEN "100010000000"=> aa <="00010001";
WHEN "100001000000"=> aa <="00010010";
WHEN "100000100000"=> aa <="00010011";
WHEN "100000010000"=> aa <="00010100";
WHEN "100000001000"=> aa <="00010101";
WHEN "100000000100"=> aa <="00010110";
WHEN "100000000010"=> aa <="00010111";
WHEN "100000000001"=> aa <="00011000";
WHEN "010010000000"=>aa<="00100001";
WHEN "010001000000"=>aa<="00100010";
WHEN "010000100000"=>aa<="00100011";
WHEN "010000010000"=>aa<="00100100";
WHEN "010000001000"=>aa<="00100101";
WHEN "010000000100"=>aa<="00100110";
WHEN "010000000010"=>aa<="00100111";
WHEN "010000000001"=>aa<="00101000";
WHEN "001010000000"=>aa<="00110001";
WHEN "001001000000"=>aa<="00110010";
WHEN "001000100000"=>aa<="00110011";
WHEN "001000010000"=>aa<="00110100";
WHEN "001000001000"=>aa<="00110101";
WHEN "001000000100"=>aa<="00110110";
WHEN "001000000010"=>aa<="00110111";
WHEN "001000000001"=>aa<="00111000";
WHEN "000110000000"=>aa<="01000001";
WHEN "000101000000"=>aa<="01000010";
WHEN "000100100000"=>aa<="01000011";
WHEN "000100010000"=>aa<="01000100";
WHEN "000100001000"=>aa<="01000101";
WHEN "000100000100"=>aa<="01000110";
WHEN "000100000010"=>aa<="01000111";
WHEN "000100000001"=>aa<="01001000";
WHEN "110010000000"=>aa<="01010001";
WHEN "001101000000"=>aa<="01010010";
WHEN OTHERS =>aa<="00000000";
END CASE;
END IF;
END IF;
船舶控制:1正车指令;2倒车指令;档位(3前进+1,4后退+1,5停止);控制指令:(6驾控,7集控,8机控);9紧急停车;10越控;11消音;12试验;一共12个按键,帮忙把下面程序改一下会么?谢谢
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_arith.ALL;
USE ieee.std_logic_unsigned.ALL;
ENTITY anjian IS
PORT(
pq:in std_logic_vector(1 to 12);
clk:in std_logic;
clr:in std_logic;
aa: out std_logic_vector(7 downto 0)
);
END anjian;
ARCHITECTURE anjian_encoder OF anjian IS
BEGIN
PROCESS(clk,clr)
BEGIN
IF (clk'event and clk='1')THEN
IF (clr='1' ) THEN
aa<="00000000";
ELSE
CASE pq IS
WHEN "100010000000"=> aa <="00010001";
WHEN "100001000000"=> aa <="00010010";
WHEN "100000100000"=> aa <="00010011";
WHEN "100000010000"=> aa <="00010100";
WHEN "100000001000"=> aa <="00010101";
WHEN "100000000100"=> aa <="00010110";
WHEN "100000000010"=> aa <="00010111";
WHEN "100000000001"=> aa <="00011000";
WHEN "010010000000"=>aa<="00100001";
WHEN "010001000000"=>aa<="00100010";
WHEN "010000100000"=>aa<="00100011";
WHEN "010000010000"=>aa<="00100100";
WHEN "010000001000"=>aa<="00100101";
WHEN "010000000100"=>aa<="00100110";
WHEN "010000000010"=>aa<="00100111";
WHEN "010000000001"=>aa<="00101000";
WHEN "001010000000"=>aa<="00110001";
WHEN "001001000000"=>aa<="00110010";
WHEN "001000100000"=>aa<="00110011";
WHEN "001000010000"=>aa<="00110100";
WHEN "001000001000"=>aa<="00110101";
WHEN "001000000100"=>aa<="00110110";
WHEN "001000000010"=>aa<="00110111";
WHEN "001000000001"=>aa<="00111000";
WHEN "000110000000"=>aa<="01000001";
WHEN "000101000000"=>aa<="01000010";
WHEN "000100100000"=>aa<="01000011";
WHEN "000100010000"=>aa<="01000100";
WHEN "000100001000"=>aa<="01000101";
WHEN "000100000100"=>aa<="01000110";
WHEN "000100000010"=>aa<="01000111";
WHEN "000100000001"=>aa<="01001000";
WHEN "110010000000"=>aa<="01010001";
WHEN "001101000000"=>aa<="01010010";
WHEN OTHERS =>aa<="00000000";
END CASE;
END IF;
END IF;
一周热门 更多>