EDA实现电子琴的程序_第1页
EDA实现电子琴的程序_第2页
EDA实现电子琴的程序_第3页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、实验十五电子琴设计一、音名与频率的关系:音乐上的十二平均律规定:每两个八度音之间的频率相差一倍。在这两个八度音之 间,分成十二个半音,每两个相邻伴音的频率比为12 2。另外还规定,音若A的频率为 440Hz。音名B到C、E到F之间为半音,其余为全音。这样,可计算得从A (简谱的低音 6)到亦(简谱的高音6)之间每个音合的频率为:A (6): 440Hza (6): 880Hzal ( 6 ):1760HzB (7): 493.88Hzb (7): 987.76Hzc (1): 523.25Hzcl (1): 1046.50Hzd (2): 587.33Hzdl (2): 1174.66HzC

2、(3): 659.25Hzcl (3): 1318.51Hzf (4): 698.46Hzfl (4): 1396.92Hzg (5): 783.99Hzgl (5): 1567.98Hz二、设计要求:设计一个电于琴,要求能演奏音若A到al之间的全部音阶。按下一个键,则演奏该音 若,并用数码管显示音名,用发光二极管指示高、中、低音。三、设计提示:本实验由键盘编码,斉频输出译码器、分频器组成。取10MHz信号作为墓准。以荃准 频率除以上述频率,可得各音君频率的分频系数。注意,为了减少输出的偶次谐波成分, 呈后输出应为对称方波。斉频输出译码器实质上是一个多路选择器,根据键盘编码的输 出,选择音阶发

3、生器的不同的预晝数,分频后输出音频。分频器可以为加法计数器,以可以为减法计数器,计算预直数时稍有不同,应加以注 意。另外,应根据基准频率和输出频率,来确定计教器的位数。设计框图如下图所示:10MHz时钟扫描时钟. 按罕输入、预W数选择码r剧一 按键编m可预宜汁数器电于琴框图四、实验步骤1、启动1SE集成开发环境,创建工程并输入设计源文件。2、对设计进行时序仿真,分析设计的正确性。3、锁定引脚,完成设计实现过程。并在实验辑上连线,利用IMPACT进行程序下载。4、在实验箱上验证电于琴的功能,观察并记录实验结果五、实验报吿l. music的VHDL源程序:library iccc;use iccc

4、.std_logic_l 164.all;mtity music isport(kin: stdogic_vcctor(0 to 15);spk_out: out stdogic;lcd_out: out stdogic_vuctnr(6 d()yvnix)0);index: out std_logic_vcctor(2 down to 0);elk: in stdogic);end music;architecture stru of music iscomponent tone tabp()n(index : in INTEGER rany 0 to 15;toile : out INTE

5、GER range: 0 to 16#3fff#;code : out INTEGER range 0 to 15;high : out STD_LOGIQ_VECT()R(2 D()WNT() 0);end component;component tone genpori(elk : in STD_L()GIC;toile : in integer range 0 to 16#3ff阱;spks:mitSTD_L()GIC);end component;component hcx21cdport(hex : in integer range 0 to 15;led : out STD_L()

6、G】C_VECT()R(6 downs 0);end component;component keybordport(kin : in STD_L()GIC_VECT()R(O to 15);kout: out INTEGER range 0 to 15 );end component;signal kout: integer range 0 to 15;signal tone: INTEGER range 0 to 16#3fff#;signal digit: integer range 0 to 15;beginul: keybord port map (kin=>kin,k()ut

7、=>kout);u2: tone tab port map (indcx=>kout,t()nc=> toile,c(xlc=>digit,high=>indcx);u3: tonegen port map (elk=>dk,t()nc=>t<)iic,spks=>spk_()ut);u4: hcx21cd port map (hcx=>digit,lcd=>lcd_out);end stru;2. hcx21cd 的 VHPL 源程序library I EEE;use IEEESTD_L()GIC_1164加 1;entity

8、 hcx21cd isporl(hex : in integer range 0 to 15;led : out STD_L()G】C_VECT()R(6 downto 0) );end hcx21cd;architecture rtl of hcx21cd issignal data : std_l(>gic_vcct()r(6 donito 0);beginlcd<=n()t data;with hex selectdata<= M1111001M when 1,H0100100H when 2,-2H0110(X)0H when 3, -3H0011001H when

9、4, -4n0010010H when 5, -5H0000010n when 6,-6H1111000n when 7, -7”0000000” when 8,-8H0010000H when 9, -9n0001000H when 10, -AHOOOOOHH when 11, -bH1000110n when 12, CH0100(X)r, when 13,H00()0110H when 14, 一EH0001110H when 15, -F n 1000000” when others; -0end rd;3. keybord 的 VHPL 源程序library 1EE E;use 1

10、EE ESTD_L()GIC_1164 加 1;entity kcvbord isJJporl(kin : in STD_L()GIC_VECT()R(O to 15);kout: out INTEGER range 0 to 15);end kcvbord;architecture rtl of kcvbord isJsignal data:std_l()gic_vcclor(0 to 15);begindata<=kin;proccss(data)beginif data(0)=*0* then kout<=0;clsif data(l)=,0, then kout<=l

11、;clsif data(2)=,0* then kout<=2;clsif data(3)=,0, then kout<=3;clsif data(4)=,0* then kout<=4;clsif data(5)=V then kout<=5;clsif data(6)=,0* then kout<=6;clsif data(7)=,0, then kout<=7;clsif data(8)=,0* then kout<=8;clsif data(9)=,0, then kout<=9;clsif data(10)=l0, then kout&

12、lt;=10;clsif data(ll)=,0, then kout<=l 1;clsif data(12)=l0, then kout<=12;clsif data(13)=t0> then kout<=13;clsif data(14)=,0f then kout<=14;clsif data(15)=l0, then kout<=15;else NULL;end if;end process;end rd;4. tonegtn 的 VHPL 源程序library I EEE;use IEEESTD_L()GIC_1164如 1;entity tone

13、gen isport(elk : in STD_L()GIC;toile : in integer range 0 to 16#3fff;spks:outSTD_LOGIC);end tonegrn;architecture rtl of tonegen issignal fLillspks:std_logic;begingcnspks:pr()ccss(clk,t()nc)variable countl4: integer range 0 to 16#3fff#;std()gic_vuctx)r(O to 13); beginif elk event and clk=*r thenifcou

14、ntl4=16#3Ff倂 then ”111111111111111” thencountl4:=tonc;fullspks<=*r;elsec()untl4:=countl 4+1 ;fullspks<=tOt;end if;end if;end process;dclayspks:proccss(fullspks)variable c()unt2:std_logic;beginif fullspks'event and fullspks=,r thencount2:=not count2;end if;spks<=count2;end process;end rt

15、l;5. tonctab 的 VHDL 源程序library IEEE;use IEEESTD_L()GIC_1164加 1;entity tone tab isport(index : in INTEGER ran使 0 to 15; tone : out INTEGER rangu 0 to 16#3fff#;code : out INTEGER r;uigc 0 to 15;high : out STD_LOGIQ_VECT()R(2 D()TNT() 0);end tonctab;architecture rtl of tone tab isbeginproccss(indcx)beg

16、incase index iswhen 0 =>i()nc<=5021;codc<=6;hi<=H100H;when 1 =>tonc<=6262;code<=7;hi<=M 100M;when 2 = > tone <=6829;code <=1 ;hi <=H010u;when 3 =>tone<=7872;codc<=2;hi<=,t010u;when 4 =>t()nc<=8801;codc<=3;hi<=,010H;when 5 =>ionc<=9226

17、;codc<=4;hi<=M010H;when 6 =>i()nc<=10007;c()dc<=5;high<=H01()H;when 7 =>tonc<=10703;code<=6;hii<=,010H;when 8 =>tonc<=l 1323;codc<=7;high<=H010H;when 9 =>tonc<= 11607;codc<=1 ;high<=M001H;when 10 =>tone<=12129;code<=2;high<=H00r,;when

18、 11 => tonc<=12593;c()dc<=3;high<=H001H;when 12 =>t()nc<=12805;codc<=4;high<=H001H;when 13 =>tone<=13196;codc<=5;high<=H00rf;when 14 =>tonc<=13544;c()dc<=6;high<=M001n;when 15 => t()nc<=16383;c()dc<=0;high<=H001H; when ()THERS=>NULL;end case;end process;end rtl;实验记录:1、设计记录表,记录引脚锁定与连线情况。ISE软件实验箱端口合称芯片引脚号IO类型编号elkB4InputJOIindcx<0>F9Output1013indcx<l>E9Output1014indcx<2>DllOutput1015kin<0>A4Input102kin<l>05Input103kin<2>C5Input104kin<3>A6Input105kin&l

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论