📄 foption.vhd
字号:
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_signed.all;
ENTITY foption IS
PORT(
cp1:IN std_logic;
cp2:IN std_logic;
status:IN std_logic_vector(2 downto 0);
run:IN std_logic;
ps:IN std_logic;
sel:OUT std_logic_vector(2 downto 1);
seg:OUT std_logic_vector(6 downto 0);
sound:OUT std_logic;
o_status:OUT std_logic_vector(2 downto 0)
);
END;
ARCHITECTURE run of foption is
SIGNAL time1:std_logic_vector(3 downto 0);
SIGNAL time2:std_logic_vector(3 downto 0);
SIGNAL time:std_logic_vector(3 downto 0);
SIGNAL ts:std_logic;
SIGNAL selsig:std_logic_vector(2 downto 1);
SIGNAL segsig:std_logic_vector(6 downto 0);
SIGNAL s:std_logic_vector(2 downto 0);
SIGNAL sds:std_logic;
SIGNAL mt1:std_logic_vector(3 downto 0);
SIGNAL mt2:std_logic_vector(3 downto 0);
BEGIN
PROCESS(cp1)
BEGIN
IF(run='0')THEN
IF(status(2)='1')THEN mt2<="0010";mt1<="0000";
ELSE IF(status(1)='1')THEN mt2<="0001";mt1<="0101";
ELSE IF(status(0)='1')THEN mt2<="0001";mt1<="0000";
END IF;END IF;END IF;
s<=status;sds<='0';time1<=mt1;time2<=mt2;
-------------------------------------------------------------
ELSE
IF(cp1'event and cp1='1')THEN
IF(ps='0')THEN
IF(time1="0000")THEN
IF(time2="00")THEN
IF(s(2)='1')THEN
s(2)<='0';
ELSE IF(status(1)='1')THEN
s(1)<='0';
ELSE IF(status(0)='1')THEN
s(0)<='0';
END IF;END IF;END IF;
IF((s(2)and s(1))='1')THEN time2<="0001";time1<="0100";
ELSE IF((s(1)and s(0))='1')THEN time2<="0000";time1<="1001";
ELSE time2<="0000";time1<="0000";sds<='1';
END IF;END IF;
ELSE time2<=time2-1; time1<="1001";
END IF;
ELSE time1<=time1-1;
END IF;
END IF;
END IF;
END IF;
END PROCESS;
-------------------------------------
PROCESS(cp2)
BEGIN
IF(cp2'event and cp2='1')THEN
ts<=not ts;
IF(ts='0')THEN time<=time1;selsig<="10";
ELSE time<=time2;selsig<="01";
END IF;
END IF;
CASE time IS
WHEN"0000"=>segsig<="0111111";
WHEN"0001"=>segsig<="0000110";
WHEN"0010"=>segsig<="1011011";
WHEN"0011"=>segsig<="1001111";
WHEN"0100"=>segsig<="1100110";
WHEN"0101"=>segsig<="1101101";
WHEN"0110"=>segsig<="1111101";
WHEN"0111"=>segsig<="0000111";
WHEN"1000"=>segsig<="1111111";
WHEN"1001"=>segsig<="1101111";
WHEN OTHERS=>segsig<="ZZZZZZZ";
END CASE;
END PROCESS;
sel<=selsig;seg<=segsig;
o_status<=s;sound<=sds;
END;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -