




已阅读5页,还剩1页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
摘要: 文中介绍了电子琴系统的整体设计,并基于超高速硬件描述语言VHDL在Xilinx公司的Spartan系列的2sc200PQ208-5芯片上编程实现.电子琴系统的设计包含四个模块,分别是控制输入电路、FPGA、显示电路和扬声器电路。其中FPGA模块的设计是整个电子琴系统设计的核心内容。四个模块的有机组合完成了电子琴自动演奏的功能。文中还详细介绍了FPGA功能模块的原理及其工作时序仿真图。本产品的特点是成本较低,性能稳定,精度高,有一定的开发价值。关键词: 现场可编程逻辑器件FPGA 超高速硬件描述语言VHDL 电子琴系统 自动演奏8.18.4程序设计与仿真电子琴VHDL程序包含有:顶层程序、音阶发生器程序、数控分频模块程序和自动演奏模块程序。1.顶层程序与仿真(1)顶层VHDL程序-文件名:top.vhd-功能:顶层文件-最后修改日期:2004.3.20library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity top isPort ( clk32MHz :in std_logic; -32MHz系统时钟handTOauto : in std_logic; -键盘输入/自动演奏code1 :out std_logic_vector(6 downto 0); -音符显示信号index1 :in std_logic_vector(7 downto 0); -键盘输入信号high1 :out std_logic; -高低音节信号spkout :out std_logic); -音频信号end top;architecture Behavioral of top iscomponent automusicPort ( clk :in std_logic; Auto: in std_logic; index2:in std_logic_vector(7 downto 0); index0 : out std_logic_vector(7 downto 0); end component;component tonePort ( index : in std_logic_vector(7 downto 0); code : out std_logic_vector(6 downto 0); high : out std_logic; tone0 : out integer range 0 to 2047);end component;component speakerPort ( clk1 : in std_logic;tone1 : in integer range 0 to 2047;spks : out std_logic);end component;signal tone2: integer range 0 to 2047;signal indx:std_logic_vector(7 downto 0);beginu0:automusic port map(clk=clk32MHZ,index2=index1,index0=indx,Auto=handtoAuto);u1: tone port map(index=indx,tone0=tone2,code=code1,high=high1);u2: speaker port map(clk1=clk32MHZ,tone1=tone2,spks=spkout);end Behavioral;(2)仿真顶层文件仿真图如图8.18.2所示。图8.18.2 顶层文件仿真图2. 音阶发生器程序与仿真(1) 音阶发生器VHDL程序-文件名:tone.vhd。-功能:library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity tone isPort ( index : in std_logic_vector(7 downto 0); -音符输入信号code : out std_logic_vector(6 downto 0); -音符显示信号high : out std_logic; -高低音显示信号tone0 : out integer range 0 to 2047); -音符的分频系数end tone;architecture Behavioral of tone isbeginsearch :process(index) -此进程完成音符到音符的分频系数译码,音符的显示,高低音阶begincase index iswhen 00000001 = tone0=773;code=1001111;high tone0=912;code=0010010;high tone0=1036;code=0000110;high tone0=1116;code=1001100;high tone0=1197;code=0100100;high tone0=1290;code=0100000;high tone0=1372;code=0001111;high tone0=1410;code=0000000;high tone0=2047;code=0000001;high=0;end case;end process;end Behavioral;(2)音阶发生器程序仿真音阶发生器程序仿真图如图8.18.3所示。图8.18.3 音阶发生器仿真图3. 数控分频模块程序与仿真(1) 数控分频模块VHDL程序-文件名:speaker.vhd。-功 能:实现数控分频。-最后修改日期:20004.3.19。library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity speaker isPort ( clk1 : in std_logic; -系统时钟tone1 : in integer range 0 to 30624; -音符分频系数spks : out std_logic); -驱动扬声器的音频信号end speaker;architecture Behavioral of speaker issignal preclk,fullspks:std_logic;beginpulse1:process(clk1) -此进程对系统时钟进行4分频variable count:integer range 0 to 8;beginif clk1event and clk1=1 then count:=count+1;if count=2 then preclk=1; elsif count=4 then preclk=0;count:=0;end if; end if;end process pulse1;genspks:process(preclk,tone1) -此进程按照tone1输入的分频系数对8MHz的脉冲再次分频,得到所需要的音符频率variable count11:integer range 0 to 30624;beginif preclkevent and preclk=1 thenif count11tone1 then count11:=count11+1;fullspks=1; else count11:=0;fullspks=0;end if;end if;end process;delaysps:process(fullspks) -此进程对fullspks进行2分频variable count2 :std_logic:=0;beginif fullspksevent and fullspks=1 then count2:=not count2;if count2=1 then spks=1;else spks=0;end if;end if;end process;end Behavioral;(2) 数控分频模块程序仿真数控分频模块程序仿真图如图8.18.4所示。图8.18.4 数控分频模块仿真图4. 自动演奏模块程序与仿真(1) 自动演奏模块VHDL程序-文件名:automusic.vhd-功 能:实现自动演奏功能。-最后修改日期:2004.3.19。library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_UNSIGNED.ALL;entity automusic isPort ( clk,Auto : in std_logic; -系统时钟;键盘输入/自动演奏index2 : in std_logic_vector(7 downto 0); -键盘输入信号index0 : out std_logic_vector(7 downto 0); -音符信号输出end automusic;architecture Behavioral of automusic issignal count0:integer range 0 to 31;-changesignal clk2:std_logic;beginpulse0:process(clk,Auto) -此进程完成对系统时钟8M的分频,得到4Hz的信号clk2variable count:integer range 0 to 8000000;beginif Auto=1 then count:=0;clk2=0;elsif clkevent and clk=1 then count:=count+1;if count=4000000(4) then clk2=1; elsif count=8000000 (8)then clk2=0;count:=0;end if; end if;end process;music:process(clk2) -此进程完成自动演奏部分曲的地址累加beginif clk2event and clk2=1 thenif count0=31 then count0=0;else count0 index0 index0 index0 index0 index0 index0 index0 index0 index0 index0index0 index0 index0 index0 index0 index0 index0 index0 index0 index0 index0 index0 index0 index0 index0 index0 index0 index0 index0 index
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 家政人员劳务合同范本
- 工厂租赁合同范本模板
- 个人贷款购房合同范本
- 产品研发合同范本模板
- 物联网服务合同范本
- 餐饮正规加盟合同范本
- 养殖鱼苗购销合同范本
- 减水剂代理合同范本
- 工装集成吊顶合同范本
- 年产24万吨环保粘合剂及1000吨锂电池正极粘结剂配套溶剂新建项目可行性研究报告模板-立项备案
- 骨质疏松诊治与中医药
- LY/T 2383-2014结构用木材强度等级
- GB/T 528-2009硫化橡胶或热塑性橡胶拉伸应力应变性能的测定
- GB/T 4950-2021锌合金牺牲阳极
- 中日关系历史
- GB/T 15171-1994软包装件密封性能试验方法
- 2023年江苏省中学生生物学竞赛(奥赛)初赛试题和答案
- 信息系统运维服务方案
- 化工试生产总结报告
- 导数与原函数的对称性 微专题课件-2023届高三数学一轮复习
- DB32-T 3129-2016适合机械化作业的单体钢架塑料大棚 技术规范-(高清现行)
评论
0/150
提交评论