📄 move_phase.vhd
字号:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity move_phase is
Port ( clk4:in std_logic;
sw1,sw2:in std_logic;
--sign1:in std_logic;
bcd00_4,bcd10_4,bcd20_4,bcd30_4:in integer range 0
to 10;
shift_4:out std_logic_vector(3 downto 0);
lcd_4:out std_logic_vector(7 downto 0));
end move_phase;
architecture Behavioral of move_phase is
signal sign1: std_logic;
begin
process(clk4,sw1,sw2,sign1)
variable count : integer range 0 to 499999;
variable counter : integer range 0 to 3;
variable counter1 : integer range 0 to 4999999;
variable counter2 : integer range 0 to 4999999;
variable wx:std_logic_vector(3 downto 0);
variable y : integer range 0 to 11;
begin
if rising_edge(clk4) then
if count<=124999 then y:=bcd00_4; count:=count+1; shift_4<="0111";
wx:="0111";
elsif count<=249999 then y:=bcd10_4; count:=count+1; shift_4<="1011";
wx:="1011";
elsif count<=374999 then y:=bcd20_4; count:=count+1; shift_4<="1101";
wx:="1101";
elsif count<499999 then y:=bcd30_4; count:=count+1; shift_4<="1110";
wx:="1110";
elsif count=499999 then y:=bcd30_4; count:=0; shift_4<="1110";
wx:="1110";
end if;
end if;
case y is
when 0 => if sw1='1' then
if wx="0111" then lcd_4<="00000010";
else lcd_4<="00000011";
end if;
else
if sw2='1' then
if wx="1101" then lcd_4<="00000010";
else lcd_4<="00000011";
end if;
else
if sign1='1' then
if wx="1011" then
lcd_4<="00000010";
else lcd_4<="00000011";
end if;
else
if wx="0111" then
lcd_4<="00000010";
else lcd_4<="00000011";
end if;
end if;
end if;
end if;
when 1 => if sw1='1' then
if wx="0111" then lcd_4<="10011110";
else lcd_4<="10011111";
end if;
else
if sw2='1' then
if wx="1101" then lcd_4<="10011110";
else lcd_4<="10011111";
end if;
else
if sign1='1' then
if wx="1011" then
lcd_4<="10011110";
else lcd_4<="10011111";
end if;
else
if wx="0111" then
lcd_4<="10011110";
else lcd_4<="10011111";
end if;
end if;
end if;
end if;
when 2 => if sw1='1' then
if wx="0111" then lcd_4<="00100100";
else lcd_4<="00100101";
end if;
else
if sw2='1' then
if wx="1101" then lcd_4<="00100100";
else lcd_4<="00100101";
end if;
else
if sign1='1' then
if wx="1011" then
lcd_4<="00100100";
else lcd_4<="00100101";
end if;
else
if wx="0111" then
lcd_4<="00100100";
else lcd_4<="00100101";
end if;
end if;
end if;
end if;
when 3 => if sw1='1' then
if wx="0111" then lcd_4<="00001100";
else lcd_4<="00001101";
end if;
else
if sw2='1' then
if wx="1101" then lcd_4<="00001100";
else lcd_4<="00001101";
end if;
else
if sign1='1' then
if wx="1011" then
lcd_4<="00001100";
else lcd_4<="00001101";
end if;
else
if wx="0111" then
lcd_4<="00001100";
else lcd_4<="00001101";
end if;
end if;
end if;
end if;
when 4 => if sw1='1' then
if wx="0111" then lcd_4<="10011000";
else lcd_4<="10011001";
end if;
else
if sw2='1' then
if wx="1101" then lcd_4<="10011000";
else lcd_4<="10011001";
end if;
else
if sign1='1' then
if wx="1011" then
lcd_4<="10011000";
else lcd_4<="10011001";
end if;
else
if wx="0111" then
lcd_4<="10011000";
else lcd_4<="10011001";
end if;
end if;
end if;
end if;
when 5 => if sw1='1' then
if wx="0111" then lcd_4<="01001000";
else lcd_4<="01001001";
end if;
else
if sw2='1' then
if wx="1101" then lcd_4<="01001000";
else lcd_4<="01001001";
end if;
else
if sign1='1' then
if wx="1011" then
lcd_4<="01001000";
else lcd_4<="01001001";
end if;
else
if wx="0111" then
lcd_4<="01001000";
else lcd_4<="01001001";
end if;
end if;
end if;
end if;
when 6 => if sw1='1' then
if wx="0111" then lcd_4<="01000000";
else lcd_4<="01000001";
end if;
else
if sw2='1' then
if wx="1101" then lcd_4<="01000000";
else lcd_4<="01000001";
end if;
else
if sign1='1' then
if wx="1011" then
lcd_4<="01000000";
else lcd_4<="01000001";
end if;
else
if wx="0111" then
lcd_4<="01000000";
else lcd_4<="01000001";
end if;
end if;
end if;
end if;
when 7 => if sw1='1' then
if wx="0111" then lcd_4<="00011110";
else lcd_4<="00011111";
end if;
else
if sw2='1' then
if wx="1101" then lcd_4<="00011110";
else lcd_4<="00011111";
end if;
else
if sign1='1' then
if wx="1011" then
lcd_4<="00011110";
else lcd_4<="00011111";
end if;
else
if wx="0111" then
lcd_4<="00011110";
else lcd_4<="00011111";
end if;
end if;
end if;
end if;
when 8 => if sw1='1' then
if wx="0111" then lcd_4<="00000000";
else lcd_4<="00000001";
end if;
else
if sw2='1' then
if wx="1101" then lcd_4<="00000000";
else lcd_4<="00000001";
end if;
else
if sign1='1' then
if wx="1011" then
lcd_4<="00000000";
else lcd_4<="00000001";
end if;
else
if wx="0111" then
lcd_4<="00000000";
else lcd_4<="00000001";
end if;
end if;
end if;
end if;
when 9 => if sw1='1' then
if wx="0111" then lcd_4<="00001000";
else lcd_4<="00001001";
end if;
else
if sw2='1' then
if wx="1101" then lcd_4<="00001000";
else lcd_4<="00001001";
end if;
else
if sign1='1' then
if wx="1011" then
lcd_4<="00001000";
else lcd_4<="00001001";
end if;
else
if wx="0111" then
lcd_4<="00001000";
else lcd_4<="00001001";
end if;
end if;
end if;
end if;
when others => lcd_4<="11111111";
end case;
end process;
end Behavioral;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -