📄 scan8.vhd
字号:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;
library work;
use work.my_package.all;
entity SCAN8 is
Port (RESET : In STD_LOGIC;
CLK_1M : In STD_LOGIC; -- 1MHz Clock
ID7 : In UNSIGNED (7 downto 0);
ID6 : In UNSIGNED (7 downto 0);
ID5 : In UNSIGNED (7 downto 0);
ID4 : In UNSIGNED (7 downto 0);
ID3 : In UNSIGNED (7 downto 0);
ID2 : In UNSIGNED (7 downto 0);
ID1 : In UNSIGNED (7 downto 0);
ID0 : In UNSIGNED (7 downto 0);
SCAN_COL : Out STD_LOGIC_VECTOR (7 downto 0);
SCAN_ROW : Out STD_LOGIC_VECTOR (7 downto 0);
SCAN_DIG : Out STD_LOGIC_VECTOR (2 downto 0);
DISP_ID : Out UNSIGNED (7 downto 0));
end SCAN8;
architecture BEHAVIORAL of SCAN8 is
signal SCAN_COUNT : STD_LOGIC_VECTOR(5 downto 0);
signal iSCAN_LINE : STD_LOGIC_VECTOR(7 downto 0);
signal iSCAN_DIGIT : STD_LOGIC_VECTOR(2 downto 0);
signal iSCAN_ROW : UNSIGNED(2 downto 0);
signal iFONT_CODE : STD_LOGIC_VECTOR(7 downto 0);
signal iSCAN_ADDR : UNSIGNED(10 downto 0);
signal iDISP_CODE : RAM_TYPE(7 downto 0);
signal iDISP_ID : UNSIGNED(7 downto 0);
component CHAR_FONT
Port (
SCAN_ADDR : In UNSIGNED (10 downto 0);
FONT_CODE : Out STD_LOGIC_VECTOR (7 downto 0)
);
end component;
begin
----------- 8 digit scan module ------------------------
process(RESET,CLK_1M)
begin
if RESET = '1' then
iSCAN_LINE <= "10000000";
SCAN_COUNT <= "111111"; -- Digit Count & Line Count
elsif CLK_1M'event and CLK_1M = '1' then
iSCAN_LINE <= iSCAN_LINE(6 downto 0) & iSCAN_LINE(7); -- rotate left 1 bit
SCAN_COUNT <= SCAN_COUNT + 1;
end if;
end process;
iSCAN_ROW <= CONV_UNSIGNED(CONV_INTEGER(SCAN_COUNT(2 downto 0)),3);
iSCAN_DIGIT <= not SCAN_COUNT(5 downto 3);
SCAN_DIG <= iSCAN_DIGIT;
iDISP_ID <= ID7 when iSCAN_DIGIT = "111" else
ID6 when iSCAN_DIGIT = "110" else
ID5 when iSCAN_DIGIT = "101" else
ID4 when iSCAN_DIGIT = "100" else
ID3 when iSCAN_DIGIT = "011" else
ID2 when iSCAN_DIGIT = "010" else
ID1 when iSCAN_DIGIT = "001" else
ID0;
iSCAN_ADDR <= iDISP_ID & iSCAN_ROW;
DISP_ID <= iDISP_ID;
SCAN_COL <= iFONT_CODE;
SCAN_ROW <= iSCAN_LINE;
FONT_ROM: CHAR_FONT
Port Map (
SCAN_ADDR => iSCAN_ADDR,
FONT_CODE => iFONT_CODE );
end BEHAVIORAL;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -