📄 display.vhd
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all;
entity display is
port(
clk: in std_logic;
data: in std_logic_vector (15 downto 0);
s_over: in std_logic;
sel: out std_logic_vector (5 downto 0);
leds: out std_logic_vector (7 downto 0);
over: out std_logic
);
end display;
architecture behaver of display is
signal templeds: std_logic_vector (3 downto 0); -- 8 led lamp ctl
begin
process (clk,s_over) -- overflow flag
begin
-- if s_over'event and s_over='1' then
-- over
-- if reset='0'
-- if clk'event and clk='1' then
if s_over='1' then
over<='1';
else
over<='0';
end if;
-- end if;
end process;
process (clk) -- sel controler
variable tempi: integer range 0 to 5;
begin
if clk'event and clk='1' then
if tempi<3 then -- use 4bits
tempi:=tempi+1;
else
tempi:=0;
end if;
end if;
case tempi is
when 0 => sel<="011111"; templeds<=data(7 downto 4); -- 101111
when 1 => sel<="101111"; templeds<=data(11 downto 8); -- 110111
when 2 => sel<="110111"; templeds<=data(15 downto 12); -- 111011
when 3 => sel<="111011"; templeds<=data(3 downto 0); -- 011111
when 4 => sel<="111101";
when 5 => sel<="111110";
when others => sel<="111111";
end case;
end process;
process (clk) -- for displaying on 8_leds
begin
if clk'event and clk='1' then
case templeds is
when "0000" => leds(7 downto 0)<="00111111";
when "0001" => leds(7 downto 0)<="00000110";
when "0010" => leds(7 downto 0)<="01011011";
when "0011" => leds(7 downto 0)<="01001111";
when "0100" => leds(7 downto 0)<="01100110";
when "0101" => leds(7 downto 0)<="01101101";
when "0110" => leds(7 downto 0)<="01111101";
when "0111" => leds(7 downto 0)<="00000111";
when "1000" => leds(7 downto 0)<="01111111";
when "1001" => leds(7 downto 0)<="01101111";
when "1010" => leds(7 downto 0)<="01110111";
when "1011" => leds(7 downto 0)<="01111100";
when "1100" => leds(7 downto 0)<="00111001";
when "1101" => leds(7 downto 0)<="01011110";
when "1110" => leds(7 downto 0)<="01111001";
when "1111" => leds(7 downto 0)<="01110001";
when others => leds(7 downto 0)<="10000000";
end case;
end if;
end process;
end behaver;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -