动态扫描显示电路设计
设计8位动态扫描显示电路,8位显示字型自选。
要求写出代码,给出仿真波形。
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity scan is
port( CLK : in std_logic;
DATA : in std_logic_vector(31 downto 0);
POINT_CTL : in std_logic_vector(7 downto 0);
POINT_OUT : out std_logic;
--test output
TEST : out std_logic_vector(2 downto 0);
SEG_OUT : out std_logic_vector(6 downto 0);
SEG_CTL : out std_logic_vector(7 downto 0));
end scan;
architecture BHV of scan is
signal CNT : std_logic_vector(2 downto 0);
signal DATA_BUF : std_logic_vector(3 downto 0);
begin
COUNT : process(CLK)
begin
if rising_edge(CLK) then
CNT <= CNT + 1;
end if;
TEST <= CNT;
end process COUNT;
SELECT_SEG : process(CLK)
begin
if rising_edge(CLK) then
case CNT is
when "000" =>
SEG_CTL <= "11111110";
POINT_OUT <= POINT_CTL(0);
DATA_BUF <= DATA(3 downto 0);
when "001" =>
SEG_CTL <= "11111101";
POINT_OUT <= POINT_CTL(1);
DATA_BUF <= DATA(7 downto 4);
when "010" =>
SEG_CTL <= "11111011";
POINT_OUT <= POINT_CTL(2);
DATA_BUF <= DATA(11 downto 8);
when "011" =>
SEG_CTL <= "11110111";
POINT_OUT <= POINT_CTL(3);
DATA_BUF <= DATA(15 downto 12);
when "100" =>
SEG_CTL <= "11101111";
POINT_OUT <= POINT_CTL(4);
DATA_BUF <= DATA(19 downto 16);
when "101" =>
SEG_CTL <= "11011111";
POINT_OUT <= POINT_CTL(5);
DATA_BUF <= DATA(23 downto 20);
when "110" =>
SEG_CTL <= "10111111";
POINT_OUT <= POINT_CTL(6);
DATA_BUF <= DATA(27 downto 24);
when "111" =>
SEG_CTL <= "01111111";
POINT_OUT <= POINT_CTL(7);
DATA_BUF <= DATA(31 downto 28);
when others =>
null;
end case;
end if;
end process SELECT_SEG;
DISPLAY : process(DATA_BUF)
begin
--display 0-9
case DATA_BUF is
when "0000" =>
--display 0
SEG_OUT <= "1111110";
when "0001" =>
--display 1
SEG_OUT <= "0000110";
when "0010" =>
--display 2
SEG_OUT <= "1101101";
when "0011" =>
--display 3
SEG_OUT <= "1111001";
when "0100" =>
--display 4
SEG_OUT <= "0110011";
when "0101" =>
--display 5
SEG_OUT <= "1011011";
when "0110" =>
--display 6
SEG_OUT <= "1011111";
when "0111" =>
--display 7
SEG_OUT <= "1110000";
when "1000" =>
--display 8
SEG_OUT <= "1111111";
when "1001" =>
--display 9
SEG_OUT <= "1111011";
when others =>
null;
end case;
end process DISPLAY;
end BHV;
版权属于:moluuser
本文链接:https://archive.moluuser.com/archives/12/
本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。