?? led.vhd
字號:
--** 數碼管演示實驗
--文件名:led.vhd
--功 能:分別點亮數碼管和發光二極管
--說 明:分為兩種顯示模式:
-- 1.只點亮數碼管;
-- 2.只點亮發光二極管;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity led is
Port (clk : in std_logic;
cs : out std_logic_vector(1 downto 0); --發光二極管和數碼管的片選信號;
led : out std_logic_vector(7 downto 0); --輸出8位LED數據;
shift : out std_logic_vector(3 downto 0)); --數碼管位選信號;
end led;
architecture Behavioral of led is
signal clk_shift : std_logic; --1Hz;
begin
process(clk) --分頻器;
variable cnt : integer range 0 to 50000000;
begin
if clk'event and clk='1' then cnt:=cnt+1;
if cnt<25000000 then clk_shift<='1';
elsif cnt<50000000 then clk_shift<='0';
else cnt:=0;clk_shift<='0';
end if;
end if;
end process;
process(clk_shift)
variable cnt : std_logic_vector(2 downto 0);
begin
if clk_shift'event and clk_shift='1' then
cnt:=cnt+1;
if cnt="001" then
cs<="11";
shift<="1111";
led<="11111111"; --發光二極管、數碼管全滅;
elsif cnt="010" then
cs<="00";
shift<="1111";
led<="11111111"; --數碼管上顯示 "8.";
elsif cnt="011" then
cs<="10";
shift<="0111";
led<="00000000"; --數碼管上顯示 "8.";
elsif cnt="100" then
cs<="10";
shift<="1011";
led<="00000000"; --數碼管上顯示 "8.";
elsif cnt="101" then
cs<="10";
shift<="1101";
led<="00000000"; --數碼管上顯示 "8.";
elsif cnt="110" then
cs<="10";
shift<="1110";
led<="00000000"; --數碼管上顯示 "8.";
elsif cnt="111" then
cs<="01";
shift<="1111"; --發光二極管全亮;
led<="00000000";
end if;
end if;
end process;
end Behavioral;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -