SCAN8_LINE.VHD
上传用户:dgjihui88
上传日期:2013-07-23
资源大小:43k
文件大小:4k
源码类别:
VHDL/FPGA/Verilog
开发平台:
MultiPlatform
- 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_LINE is
- Port (
- RESET : In STD_LOGIC;
- CLK_1M : In STD_LOGIC; -- 1MHz Clock
- TEST : In STD_LOGIC; -- '1' for test mode
- ID7 : In UNSIGNED (9 downto 0); -- 8-bit CODE + 2-bit MODE
- ID6 : In UNSIGNED (9 downto 0); -- MODE: 00 for タ盽家Α
- ID5 : In UNSIGNED (9 downto 0); -- 01 for はフ家Α
- ID4 : In UNSIGNED (9 downto 0); -- 10 for 皗脅家Α
- ID3 : In UNSIGNED (9 downto 0); -- 11 for OFF 家Α
- ID2 : In UNSIGNED (9 downto 0);
- ID1 : In UNSIGNED (9 downto 0);
- ID0 : In UNSIGNED (9 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);
- --SCAN_DIG : Out STD_LOGIC_VECTOR (7 downto 0);
- DISP_ID : Out UNSIGNED (7 downto 0)
- );
- end SCAN8_LINE;
- architecture BEHAVIORAL of SCAN8_LINE is
- signal div_05M : STD_LOGIC_VECTOR(19 downto 0);
- signal TEST_CLK_en : STD_LOGIC;
- 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);
- signal iMODE : UNSIGNED(1 downto 0);
- signal iBlink_CLK : STD_LOGIC;
- 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
- if SCAN_COUNT(2 downto 0) = "111" then -- rotate left 1 bit
- iSCAN_LINE <= iSCAN_LINE(6 downto 0) & iSCAN_LINE(7);
- end if;
- SCAN_COUNT <= SCAN_COUNT + 1;
- end if;
- end process;
- process(RESET,CLK_1M)
- begin
- if RESET = '1' then
- div_05M <= X"00000";
- iBlink_CLK <= '0'; -- ~2Hz clock
- elsif CLK_1M'event and CLK_1M = '1' then
- if TEST = '0' then -- Normal use,
- if div_05M(18) = '1' then
- div_05M <= X"00000";
- iBlink_CLK <= not iBlink_CLK;
- else
- div_05M <= div_05M + 1;
- end if;
- else -- Test Mode, CLK_2Hz = 1M/16
- iBlink_CLK <= TEST_CLK_en;
- end if;
- end if;
- end process;
- TEST_CLK_en <= '1' when SCAN_COUNT = "111111" else
- '0';
- iSCAN_DIGIT <= not SCAN_COUNT(2 downto 0);
- iSCAN_ROW <= CONV_UNSIGNED(CONV_INTEGER(SCAN_COUNT(5 downto 3)),3);
- SCAN_DIG <= iSCAN_DIGIT;
- --SCAN_DIG <= "01111111" when iSCAN_DIGIT = "111" else
- -- "10111111" when iSCAN_DIGIT = "110" else
- -- "11011111" when iSCAN_DIGIT = "101" else
- -- "11101111" when iSCAN_DIGIT = "100" else
- -- "11110111" when iSCAN_DIGIT = "011" else
- -- "11111011" when iSCAN_DIGIT = "010" else
- -- "11111101" when iSCAN_DIGIT = "001" else
- -- "11111110";
- iDISP_ID <= ID7(9 downto 2) when iSCAN_DIGIT = "111" else
- ID6(9 downto 2) when iSCAN_DIGIT = "110" else
- ID5(9 downto 2) when iSCAN_DIGIT = "101" else
- ID4(9 downto 2) when iSCAN_DIGIT = "100" else
- ID3(9 downto 2) when iSCAN_DIGIT = "011" else
- ID2(9 downto 2) when iSCAN_DIGIT = "010" else
- ID1(9 downto 2) when iSCAN_DIGIT = "001" else
- ID0(9 downto 2);
- iMODE <= ID7(1 downto 0) when iSCAN_DIGIT = "111" else
- ID6(1 downto 0) when iSCAN_DIGIT = "110" else
- ID5(1 downto 0) when iSCAN_DIGIT = "101" else
- ID4(1 downto 0) when iSCAN_DIGIT = "100" else
- ID3(1 downto 0) when iSCAN_DIGIT = "011" else
- ID2(1 downto 0) when iSCAN_DIGIT = "010" else
- ID1(1 downto 0) when iSCAN_DIGIT = "001" else
- ID0(1 downto 0);
- iSCAN_ADDR <= iDISP_ID & iSCAN_ROW;
- DISP_ID <= iDISP_ID;
- --SCAN_COL <= iFONT_CODE;
- SCAN_COL <= iFONT_CODE when iMODE = 0 else
- NOT iFONT_CODE when iMODE = 1 else
- --iFONT_CODE AND iBlink_CLK;
- iFONT_CODE when iMODE = 2 and iBlink_CLK = '1' else
- "00000000"; -- when iMODE = 3 or iBlink_CLK = 0
- SCAN_ROW <= iSCAN_LINE;
- FONT_ROM: CHAR_FONT
- Port Map (
- SCAN_ADDR => iSCAN_ADDR,
- FONT_CODE => iFONT_CODE );
- end BEHAVIORAL;