📄 display_6_led.vhd
字号:
--display_6_led.vhd
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity display_6_led is
port(din0: in std_logic_vector(3 downto 0);
din1: in std_logic_vector(3 downto 0);
din2: in std_logic_vector(3 downto 0);
din3: in std_logic_vector(3 downto 0);
din4: in std_logic_vector(3 downto 0);
din5: in std_logic_vector(3 downto 0);
clk: in std_logic;
led_sa: out std_logic;
led_sb: out std_logic;
led_sc: out std_logic;
led_a: out std_logic;
led_b: out std_logic;
led_c: out std_logic;
led_d: out std_logic;
led_e: out std_logic;
led_f: out std_logic;
led_g: out std_logic;
led_dp: out std_logic);
end display_6_led ;
architecture behave of display_6_led is
signal q:std_logic_vector(5 downto 0);
signal seg:std_logic_vector(6 downto 0);
signal sel:std_logic_vector(2 downto 0);
signal num:std_logic_vector(3 downto 0);
signal s:std_logic_vector(2 downto 0);
begin
s<=q(5 downto 3);
led_sa<=sel(0);
led_sb<=sel(1);
led_sc<=sel(2);
led_a<=seg(0);
led_b<=seg(1);
led_c<=seg(2);
led_d<=seg(3);
led_e<=seg(4);
led_f<=seg(5);
led_g<=seg(6);
led_dp<='0';
process(clk)
begin
if clk'event and clk='1' then
if q="111111" then
q<="000000";
else
q<=q+'1';
end if;
end if;
end process;
process(din0,din1,din2,din3,din4,din5,sel,clk)
begin
if clk'event and clk='1' then
if s="000" then
sel<="000";
num<=din0;
elsif s="001" then
sel<="001";
num<=din1;
elsif s="010" then
sel<="010";
num<=din2;
elsif s="011" then
sel<="011";
num<=din3;
elsif s="100" then
sel<="100";
num<=din4;
elsif s="101" then
sel<="101";
num<=din5;
else
sel<="111";
num<="XXXX";
end if;
end if;
end process;
seg<="0111111" when num=0 else
"0000110" when num=1 else
"1011011" when num=2 else
"1001111" when num=3 else
"1100110" when num=4 else
"1101101" when num=5 else
"1111101" when num=6 else
"0000111" when num=7 else
"1111111" when num=8 else
"1101111" when num=9 else
"1110111" when num=10 else
"1111100" when num=11 else
"0111011" when num=12 else
"1011110" when num=13 else
"1111001" when num=14 else
"1110001" when num=15 else
"0000000";
end behave;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -