818+电子琴程序设计与仿真摘要:文中介绍了电子琴系统的整体设计,并基于超高速硬件描述语言VHDL在Xilinx公司的SpartanⅡ系列的2sc200PQ208-,分别是控制输入电路、FPGA、显示电路和扬声器电路。其中FPGA模块的设计是整个电子琴系统设计的核心内容。四个模块的有机组合完成了电子琴自动演奏的功能。文中还详细介绍了FPGA功能模块的原理及其工作时序仿真图。本产品的特点是成本较低,性能稳定,精度高,有一定的开发价值。关键词:现场可编程逻辑器件FPGA超高速硬件描述语言VHDL电子琴系统自动演奏电子琴VHDL程序包含有:顶层程序、音阶发生器程序、数控分频模块程序和自动演奏模块程序。(1)顶层VHDL程序--文件名:--功能:顶层文件--最后修改日期:libraryIEEE;use;use;use;entitytopisPort(clk32MHz:instd_logic;--32MHz系统时钟handTOauto:instd_logic;--键盘输入/自动演奏code1:outstd_logic_vector(6downto0);--音符显示信号index1:instd_logic_vector(7downto0);--键盘输入信号high1:outstd_logic;--高低音节信号spkout:outstd_logic);--音频信号endtop;ponentautomusicPort(clk:instd_logic;Auto:instd_logic;index2:instd_logic_vector(7downto0);index0:outstd_logic_vector(7downto0));ponenttonePort(index:instd_logic_vector(7downto0);code:outstd_logic_vector(6downto0);high:outstd_logic;tone0:outintegerrange0to2047);ponentspeakerPort(clk1:instd_logic;tone1:inintegerrange0to2047;spks:outstd_logic);ponent;signaltone2:integerrange0to2047;signalindx:std_logic_vector(7downto0);beginu0:automusicportmap(clk=>clk32MHZ,index2=>index1,index0=>indx,Auto=>handtoAuto);u1:toneportmap(index=>indx,tone0=>tone2,code=>code1,high=>high1);u2:speakerportmap(clk1=>clk32MHZ,tone1=>tone2,spks=>spkout);endBehavioral;(2)仿真。--文件名:。--功能:libraryIEEE;use;use;use;entitytoneisPort(index:instd_logic_vector(7downto0);--音符输入信号code:outstd_logic_vector(6downto0);--音符显示信号high:outstd_logic;--高低音显示信号tone0:outintegerrange0to2047);--音符的分频系数endtone;architectureBehavioraloftoneisbeginsearch:process(index)--此进程完成音符到音符的分频系数译码,音符的显示,高低音阶begincaseindexiswhen"00000001"=>tone0<=773;code<="1001111";high<='1';when"00000010"=>tone0<=912;code<="0010010";high<='1';when"00000100"=>tone0<=1036;code<="0000110";high<='1';when"00001000"=>tone0<=1116;code<="1001100";high<='1';when"00010000"=>tone0<=1197;code<="0100100";high<='1';when"00100000"=>tone0<=1290;code<="0100000";high<='0';when"01000000"=>tone0<=1372;code<="0001111";high<='0';when"10000000"=>
818 电子琴程序设计与仿真模板 来自淘豆网www.taodocs.com转载请标明出处.