展开全部
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY seg70 IS
PORT (
clk : IN std_logic; --clk 50MHZ
rst : IN std_logic; --REST
dataout : OUT std_logic_vector(7 DOWNTO 0); --各段数据输出
en : OUT std_logic_vector(7 DOWNTO 0)); --COM使能输出
END seg70;
ARCHITECTURE arch OF seg70 IS
signal cnt_scan : std_logic_vector(15 downto 0 ); --计数器分频用
signal data4 : std_logic_vector(2 downto 0);
signal dataout_xhdl1 : std_logic_vector(7 downto 0);
signal en_xhdl : std_logic_vector(7 downto 0);
begin
dataout<=dataout_xhdl1;
en<=en_xhdl;
process(clk,rst)
begin
if(rst='0')then
cnt_scan<="0000000000000000";
elsif(clk'event and clk='1')then
cnt_scan<=cnt_scan+1; --计数器累加
end if;
end process;
process(cnt_scan(15 downto 13)) --计数器分频
begin
case cnt_scan(15 downto 13) is --这里有8种状态,一个状态的时间间隔是一样的。
when"000"=> en_xhdl<="11111110"; --每一次轮流选择一排点阵灯
when"001"=> en_xhdl<="11111101";
when"010"=> en_xhdl<="11111011";
when"011"=> en_xhdl<="11110111";
when"100"=> en_xhdl<="11101111";
when"101"=> en_xhdl<="11011111";
when"110"=> en_xhdl<="10111111";
when"111"=> en_xhdl<="01111111";
when others=> en_xhdl<="11111110";
end case;
end process;
process(en_xhdl)
begin
case en_xhdl is --每一选择一排灯,同时还要给点阵的数据端口送数据
when "11111110"=> data4<="000";
when "11111101"=> data4<="001";
when "11111011"=> data4<="010";
when "11110111"=> data4<="011";
when "11101111"=> data4<="100";
when "11011111"=> data4<="101";
when "10111111"=> data4<="110";
when "01111111"=> data4<="111";
when others => data4<="111";
end case;
end process;
process(data4)
begin
case data4 is
--给点阵的数据端口送数据
--点阵数据口对应的管脚为1时,那个点不会亮。
--当点阵数据口对应的管脚为0时,那个点会亮。
--下面是一个汉字“正”的点阵码,就是利用点阵的亮和不亮形成对比显示出来的。
WHEN "000" =>
dataout_xhdl1 <= "11111111"; --第一行
WHEN "001" =>
dataout_xhdl1 <= "00000000";
WHEN "010" =>
dataout_xhdl1 <= "11101011";
WHEN "011" =>
dataout_xhdl1 <= "10001011";
WHEN "100" =>
dataout_xhdl1 <= "11101011";
WHEN "101" =>
dataout_xhdl1 <= "11101111";
WHEN "110" =>
dataout_xhdl1 <= "10000001";
WHEN "111" =>
dataout_xhdl1 <= "11111111"; --第八行
WHEN OTHERS =>
dataout_xhdl1 <= "00000011";
END CASE;
END PROCESS;
end arch;
8*8 LED显示正字
你根据这个来改成0-F显示啊,程序看懂就行。再加个状态机,就可以顺序循环显示了
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY seg70 IS
PORT (
clk : IN std_logic; --clk 50MHZ
rst : IN std_logic; --REST
dataout : OUT std_logic_vector(7 DOWNTO 0); --各段数据输出
en : OUT std_logic_vector(7 DOWNTO 0)); --COM使能输出
END seg70;
ARCHITECTURE arch OF seg70 IS
signal cnt_scan : std_logic_vector(15 downto 0 ); --计数器分频用
signal data4 : std_logic_vector(2 downto 0);
signal dataout_xhdl1 : std_logic_vector(7 downto 0);
signal en_xhdl : std_logic_vector(7 downto 0);
begin
dataout<=dataout_xhdl1;
en<=en_xhdl;
process(clk,rst)
begin
if(rst='0')then
cnt_scan<="0000000000000000";
elsif(clk'event and clk='1')then
cnt_scan<=cnt_scan+1; --计数器累加
end if;
end process;
process(cnt_scan(15 downto 13)) --计数器分频
begin
case cnt_scan(15 downto 13) is --这里有8种状态,一个状态的时间间隔是一样的。
when"000"=> en_xhdl<="11111110"; --每一次轮流选择一排点阵灯
when"001"=> en_xhdl<="11111101";
when"010"=> en_xhdl<="11111011";
when"011"=> en_xhdl<="11110111";
when"100"=> en_xhdl<="11101111";
when"101"=> en_xhdl<="11011111";
when"110"=> en_xhdl<="10111111";
when"111"=> en_xhdl<="01111111";
when others=> en_xhdl<="11111110";
end case;
end process;
process(en_xhdl)
begin
case en_xhdl is --每一选择一排灯,同时还要给点阵的数据端口送数据
when "11111110"=> data4<="000";
when "11111101"=> data4<="001";
when "11111011"=> data4<="010";
when "11110111"=> data4<="011";
when "11101111"=> data4<="100";
when "11011111"=> data4<="101";
when "10111111"=> data4<="110";
when "01111111"=> data4<="111";
when others => data4<="111";
end case;
end process;
process(data4)
begin
case data4 is
--给点阵的数据端口送数据
--点阵数据口对应的管脚为1时,那个点不会亮。
--当点阵数据口对应的管脚为0时,那个点会亮。
--下面是一个汉字“正”的点阵码,就是利用点阵的亮和不亮形成对比显示出来的。
WHEN "000" =>
dataout_xhdl1 <= "11111111"; --第一行
WHEN "001" =>
dataout_xhdl1 <= "00000000";
WHEN "010" =>
dataout_xhdl1 <= "11101011";
WHEN "011" =>
dataout_xhdl1 <= "10001011";
WHEN "100" =>
dataout_xhdl1 <= "11101011";
WHEN "101" =>
dataout_xhdl1 <= "11101111";
WHEN "110" =>
dataout_xhdl1 <= "10000001";
WHEN "111" =>
dataout_xhdl1 <= "11111111"; --第八行
WHEN OTHERS =>
dataout_xhdl1 <= "00000011";
END CASE;
END PROCESS;
end arch;
8*8 LED显示正字
你根据这个来改成0-F显示啊,程序看懂就行。再加个状态机,就可以顺序循环显示了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询