我有个实验基于FPGA的键盘扫描的设计我现在程序有了 但是不知道要定义那几个模块 求高手帮我做一下Quartus仿真设计 程序后贴 --* 4x4标准键盘板读取并点亮开发板上相应led --* Filename: keyboard4_4 --* 扫描键盘,译码并点亮开发板上相应led library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity keyboard4_4 is port( rst : in std_logic; clk : in std_logic; keyin : in std_logic_vector(3 downto 0); scan : out std_logic_vector(3 downto 0); leds : out std_logic_vector(3 downto 0) ); end keyboard4_4; architecture keyboard4_4_arch of keyboard4_4 is signal clkfrq : std_logic; signal cntscn : std_logic_vector(1 downto 0); signal scnlin : std_logic_vector(3 downto 0); signal cntfrq : std_logic_vector(14 downto 0); --signal cntfrq : std_logic_vector(3 downto 0); signal lednum : std_logic_vector(7 downto 0); begin process(rst,clk, clkfrq) begin if rst = '0' then clkfrq <= '0'; cntfrq <= (others=>'0'); elsif clk'event and clk = '1' then if cntfrq = "110000110101000" then if cntfrq = "1111" then cntfrq <= (others => '0'); clkfrq <= not clkfrq; else cntfrq <= cntfrq + 1; end if; end if; end process; process(rst,clkfrq) begin if rst = '0' then cntscn <= "00"; elsif clkfrq'event and clkfrq = '1' then if cntscn = "11" then cntscn <= "00"; else cntscn <= cntscn+1; end if; case cntscn is when "00" => scnlin <= "0001"; when "01" => scnlin <= "0010"; when "10" => scnlin <= "0100"; when "11" => scnlin <= "1000"; when others => null; end case; end if; end process; -- 根据按键点亮相应的leds process(rst, clkfrq) begin if(rst = '0' ) then leds <= "1111"; elsif clkfrq'event and clkfrq = '0' then case lednum is when "00010001" => leds <= "0000"; when "00010010" => leds <= "0001"; when "00010100" => leds <= "0010"; when "00011000" => leds <= "0011"; when "00100001" => leds <= "0100"; when "00100010" => leds <= "0101"; when "00100100" => leds <= "0110"; when "00101000" => leds <= "0111"; when "01000001" => leds <= "1000"; when "01000010" => leds <= "1001"; when "01000100" => leds <= "1010"; when "01001000" => leds <= "1011"; when "10000001" => leds <= "1100"; when "10000010" => leds <= "1101"; when "10000100" => leds <= "1110"; when "10001000" => leds <= "1111"; ; when others => null; end case; end if; end process; scan <= scnlin; lednum <= scnlin&keyin