xh.vhd
上传用户:jinxingdao
上传日期:2021-04-27
资源大小:415k
文件大小:1k
源码类别:

扫描程序

开发平台:

VHDL

  1. LIBRARY IEEE;
  2. USE IEEE.STD_LOGIC_1164.ALL;
  3. USE IEEE.STD_LOGIC_UNSIGNED.ALL;
  4. ENTITY xh IS
  5. PORT(clk,fw,en:IN STD_LOGIC;
  6.     BT:out std_logic_vector(3 downto 0);
  7. D1,D2,D3,D4:in STD_LOGIC_VECTOR(3 downto 0);
  8. DOUT:out std_logic_vector(6 downto 0));
  9. END xh;
  10. ARCHITECTURE  shuchu OF xh IS 
  11. SIGNAL STATE:STD_LOGIC_VECTOR(1 DOWNTO 0);
  12. SIGNAL data_out: STD_LOGIC_VECTOR(3 DOWNTO 0);
  13. begin
  14. PROCESS(CLK)is
  15.       BEGIN
  16.   IF  CLK'EVENT AND CLK='1'  THEN 
  17.    IF STATE="11"  THEN
  18.        STATE<="00";
  19.          else 
  20.             STATE<=STATE+'1';
  21.    END IF;
  22. END IF;
  23. END PROCESS;
  24. PROCESS(STATE)
  25. BEGIN
  26.    CASE STATE IS 
  27.             WHEN "00"  =>BT <="0001"; data_out <= D1;
  28.             WHEN "01"  =>BT <="0010"; data_out <= D2;
  29.             WHEN "10"  =>BT <="0100"; data_out <= D3;
  30.             WHEN "11"  =>BT <="1000"; data_out <= D4;
  31.             WHEN OTHERS=>NULL;
  32.           END CASE;
  33.    
  34.         CASE DATA_OUT IS
  35.           WHEN "0000"=>DOUT<="0111111";
  36.           WHEN "0001"=>DOUT<="0000110";
  37.           WHEN "0010"=>DOUT<="1011011";
  38.           WHEN "0011"=>DOUT<="1001111";
  39.           WHEN "0100"=>DOUT<="1100110";
  40.           WHEN "0101"=>DOUT<="1101101";
  41.           WHEN "0110"=>DOUT<="1111101";
  42.           WHEN "0111"=>DOUT<="0000111";
  43.           WHEN "1000"=>DOUT<="1111111";
  44.           WHEN "1001"=>DOUT<="1101111";
  45.           WHEN OTHERS=>DOUT<="ZZZZZZZ";
  46.         END CASE;
  47.   END PROCESS ;
  48.  END shuchu;
  49.