⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 keyscan.vhd

📁 采用DDS技术的波形发生器(FPGA实现)
💻 VHD
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
--MCU与FPGA通信采用总线方式,其中,EN为使能端
entity keyscan is 
port(clk:in std_logic;
     mcuaddr:in std_logic_vector(1 downto 0);--地址信号
                                             --00为清零,01为频率字,10为相位字,11为选择波形输出
     EN:in std_logic;--使能信号,当MCU给与下降沿时,FPGA动作
     clear:out std_logic;
     sel_wave:out std_logic_vector(1 downto 0);
     fcw,pcw:out std_logic_vector(7 downto 0));--数据送至MCU内部
end;
architecture beh of keyscan is
signal tmp_fcw,tmp_pcw:std_logic_vector(7 downto 0);
signal tmp_sel:std_logic_vector(1 downto 0);
signal flag:std_logic;
begin
 
      process(clk,en,mcuaddr)--根据MCU给出的地址,给MCU送相应的数据
       begin
        if rising_edge(clk) then
         clear<='1';
         if en='0' then
          if flag='0' then
          case mcuaddr is
             when "00"=>clear<='0';tmp_fcw<=(others=>'0');tmp_pcw<=(others=>'0');tmp_sel<="00";
             when "01"=>clear<='0';tmp_fcw<=tmp_fcw+1;
             when "10"=>clear<='0';tmp_pcw<=tmp_pcw+1;
             when "11"=>tmp_sel<=tmp_sel+1;clear<='0';tmp_fcw<=(others=>'0');tmp_pcw<=(others=>'0');
             when others=>null;
          end case;
          flag<='1';
        end if;
      else flag<='0';
      end if;
     end if;
     end process;
fcw<=tmp_fcw;
pcw<=tmp_pcw;
sel_wave<=tmp_sel;
end;
     

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -