📄 lcd.vhd
字号:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity lcd is
Port (clk:in std_logic;
sw:in std_logic_vector(7 downto 0);
l :out std_logic_vector(6 downto 0);
a :out std_logic_vector(3 downto 0));
end lcd;
architecture Behavioral of lcd is
signal b:std_logic_vector(3 downto 0);
signal count:std_logic_vector(1 downto 0);
signal ll:std_logic_vector(6 downto 0);
signal lll:std_logic_vector(6 downto 0);
signal fclk:std_logic;
signal fcount:std_logic_vector(3 downto 0);
begin
process(clk)
begin
if clk'event and clk='1' then
fcount<=fcount+1;
end if;
end process;
fclk<=fcount(3);
process(fclk)
begin
if fclk'event and fclk='1' then
count<=count+1;
end if;
end process;
process(count)
begin
case count is
when "00" => a<="0001";l<=ll;
when "01" => a<="0010";l<=lll;
--when "10" => a<="0100";
--when "11" => a<="1000";
when others=> a<="0000";
end case;
end process;
process(sw)
begin
case sw(3 downto 0) is
when "0000" =>ll<="0000001";--0
when "0001" =>ll<=not"0110000";--1
when "0010" =>ll<=not"1101101";--2
when "0011" =>ll<=not"1111001";--3
when "0100" =>ll<=not"0110011";--4
when "0101" =>ll<=not"1011011";--5
when "0110" =>ll<=not"1011111";--6
when "0111" =>ll<=not"1110000";--7
when "1000" =>ll<=not"1111111";--8
when "1001" =>ll<=not"1111011";--9
when "1010" =>ll<=not"1110111";--a
when "1011" =>ll<=not"0011111";--b
when "1100" =>ll<=not"1001110";--c
when "1101" =>ll<=not"0111101";--d
when "1110" =>ll<=not"1001111";--e
when "1111" =>ll<=not"1000111";--f
when others =>ll<=not"0000000";
end case;
end process;
process(sw)
begin
case sw(7 downto 4) is
when "0000" =>lll<="0000001";--0
when "0001" =>lll<=not"0110000";--1
when "0010" =>lll<=not"1101101";--2
when "0011" =>lll<=not"1111001";--3
when "0100" =>lll<=not"0110011";--4
when "0101" =>lll<=not"1011011";--5
when "0110" =>lll<=not"1011111";--6
when "0111" =>lll<=not"1110000";--7
when "1000" =>lll<=not"1111111";--8
when "1001" =>lll<=not"1111011";--9
when "1010" =>lll<=not"1110111";--a
when "1011" =>lll<=not"0011111";--b
when "1100" =>lll<=not"1001110";--c
when "1101" =>lll<=not"0111101";--d
when "1110" =>lll<=not"1001111";--e
when "1111" =>lll<=not"1000111";--f
when others =>lll<=not"0000000";
end case;
end process;
end Behavioral;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -