📄 xs.vhd
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_signed.all;
entity xs is
port(clk:in std_logic;
--st:in std_logic_vector(1 downto 0);
ho:out std_logic_vector(7 downto 0);
lo:out std_logic_vector(7 downto 0));
end xs;
architecture xs of xs is
signal cnt:std_logic_vector(9 downto 0):="0000000000";
signal count:std_logic_vector(1 downto 0):="00";
signal cou:std_logic_vector(2 downto 0):="000";
begin
process(clk)
begin
if(clk'event and clk='1')then
--if st="10" then
cnt<=cnt+1;
--else cnt<="0000000000";
--end if;
end if;
count(1 downto 0)<=cnt(9 downto 8);
cou(2 downto 0)<=cnt(2 downto 0);
case cou(2 downto 0) is
when"000"=>ho<="10000000";
when"001"=>ho<="01000000";
when"010"=>ho<="00100000";
when"011"=>ho<="00010000";
when"100"=>ho<="00001000";
when"101"=>ho<="00000100";
when"110"=>ho<="00000010";
when"111"=>ho<="00000001";
when others=>ho<="00000000";
end case;
if count="00"then --B
case cou(2 downto 0) is
when"000"=>lo<="11111111";
when"001"=>lo<="10000011";
when"010"=>lo<="10111101";
when"011"=>lo<="10111101";
when"100"=>lo<="10000011";
when"101"=>lo<="10111101";
when"110"=>lo<="10111101";
when"111"=>lo<="10000011";
when others=>lo<="11111111";
end case;
elsif count="01"then --U
case cou(2 downto 0) is
when"000"=>lo<="11111111";
when"001"=>lo<="10111101";
when"010"=>lo<="10111101";
when"011"=>lo<="10111101";
when"100"=>lo<="10111101";
when"101"=>lo<="10111101";
when"110"=>lo<="11000011";
when"111"=>lo<="11111111";
when others=>lo<="11111111";
end case;
elsif count="10"then --P
case cou(2 downto 0) is
when"000"=>lo<="11111111";
when"001"=>lo<="10000011";
when"010"=>lo<="10111101";
when"011"=>lo<="10111101";
when"100"=>lo<="10000011";
when"101"=>lo<="10111111";
when"110"=>lo<="10111111";
when"111"=>lo<="10111111";
when others=>lo<="11111111";
end case;
elsif count="11"then --T
case cou(2 downto 0) is
when"000"=>lo<="11111111";
when"001"=>lo<="10000011";
when"010"=>lo<="11101111";
when"011"=>lo<="11101111";
when"100"=>lo<="11101111";
when"101"=>lo<="11101111";
when"110"=>lo<="11101111";
when"111"=>lo<="11101111";
when others=>lo<="11111111";
end case;
else ho<="00000000";lo<="11111111";
end if;
end process;
end ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -