欢迎来到天天文库
浏览记录
ID:20487906
大小:104.50 KB
页数:6页
时间:2018-10-13
《电子琴程序设计及仿真》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、程序设计与仿真电子琴VHDL程序包含有:顶层程序、音阶发生器程序、数控分频模块程序和自动演奏模块程序。1.顶层程序与仿真(1)顶层VHDL程序--文件名:top.vhd--功能:顶层文件--最后修改日期:2004.3.20libraryIEEE;useIEEE.STD_LOGIC_1164.ALL;useIEEE.STD_LOGIC_ARITH.ALL;useIEEE.STD_LOGIC_UNSIGNED.ALL;entitytopisPort(clk32MHz:instd_logic;--32MHz系统时钟
2、handTOauto:instd_logic;--键盘输入/自动演奏code1:outstd_logic_vector(6downto0);--音符显示信号index1:instd_logic_vector(7downto0);--键盘输入信号high1:outstd_logic;--高低音节信号spkout:outstd_logic);--音频信号endtop;architectureBehavioraloftopiscomponentautomusicPort(clk:instd_logic;Auto:i
3、nstd_logic;index2:instd_logic_vector(7downto0);index0:outstd_logic_vector(7downto0));endcomponent;componenttonePort(index:instd_logic_vector(7downto0);code:outstd_logic_vector(6downto0);high:outstd_logic;tone0:outintegerrange0to2047);endcomponent;components
4、peakerPort(clk1:instd_logic;tone1:inintegerrange0to2047;spks:outstd_logic);endcomponent;signaltone2:integerrange0to2047;signalindx:std_logic_vector(7downto0);beginu0:automusicportmap(clk=>clk32MHZ,index2=>index1,index0=>indx,Auto=>handtoAuto);u1:toneportmap
5、(index=>indx,tone0=>tone2,code=>code1,high=>high1);u2:speakerportmap(clk1=>clk32MHZ,tone1=>tone2,spks=>spkout);endBehavioral;(2)仿真顶层文件仿真图如图8.18.2所示。图8.18.2顶层文件仿真图2.音阶发生器程序与仿真(1)音阶发生器VHDL程序--文件名:tone.vhd。--功能:libraryIEEE;useIEEE.STD_LOGIC_1164.ALL;useIEEE.ST
6、D_LOGIC_ARITH.ALL;useIEEE.STD_LOGIC_UNSIGNED.ALL;entitytoneisPort(index:instd_logic_vector(7downto0);--音符输入信号code:outstd_logic_vector(6downto0);--音符显示信号high:outstd_logic;--高低音显示信号tone0:outintegerrange0to2047);--音符的分频系数endtone;architectureBehavioraloftoneisb
7、eginsearch: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<=111
8、6;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"100000
此文档下载收益归作者所有