EDA课程设计(论文)-简易乐器演奏器.doc_第1页
EDA课程设计(论文)-简易乐器演奏器.doc_第2页
EDA课程设计(论文)-简易乐器演奏器.doc_第3页
EDA课程设计(论文)-简易乐器演奏器.doc_第4页
EDA课程设计(论文)-简易乐器演奏器.doc_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

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

文档简介

课程设计说明书1 引言随着电子技术的飞速发展,微电子技术的进步主要表现在大规模集成电路加工技术即半导体工艺技术的发展上,使得表征半导体的工艺水平的线宽已经达到了60nm,并在不断地缩小,面在硅片单位面积上,集成了更多的晶体管。集成电路设计正在不断地向超大规模,极低功耗和超高速的方向发展,电子产品的功能越来越强大,体积越来越小,功耗越来越低。同时,利用可编程逻辑器件和eda 技术使设计方法发生了质的变化。把以前“电路设计+硬件搭试+调试焊接”转化为“功能设计+软件模拟+仿真下载”。利用eda 开发平台,采用可编程逻辑器件cpldfpga 使硬件的功能可通过编程来实现,这种新的基于芯片的设计方法能够使设计者有更多机会充分发挥创造性思维,实现多种复杂数字逻辑系统的功能,将原来由电路板设计完成的工作放到芯片的设计中进行,减少了连线和体积,提高了集成度,降低了干扰,大大减轻了电路设计和pcb设计的工作量和难度,增强了设计的灵活性,有效地提高了工作效率,增加了系统的可靠性和稳定性,提高了技术指标。这些技术使得各种电子产品迅速的进入了我们的生活,我们处在一个被电子产品深度包围的时代,在一个普通老百姓的家里,衣食住行,每一个产品的诞生都离不开eda技术,从彩色电视机,到智能冰箱,到全自动洗衣机,电饭煲,到微波炉,电磁炉,电子琴,再到个人随身用的手机,mp3音乐播放器都需要eda技术提供支持。本文应用vhdl硬件描述语言,设计一个乐曲硬件演奏电路,它能将一首预先设置存储好的乐曲自动播放出来,除此之外,也能够通过按键的方式输入音符,使其具备简易电子琴的功能。通过此项研究,能够深切的体会利用eda工具开发的优越性,在此基础上,对乐曲硬件演奏电路功能进行丰富,具体一定的社会实用性。2 eda技术2.1 简介eda技术是在电子cad技术基础上发展起来的计算机软件系统,是指以计算机为工作平台,融合了应用电子技术、计算机技术、信息处理及智能化技术的最新成果,进行电子产品的自动设计。 利用eda工具,电子设计师可以从概念、算法、协议等开始设计电子系统,大量工作可以通过计算机完成,并可以将电子产品从电路设计、性能分析到设计出ic版图或pcb版图的整个过程的计算机上自动处理完成。现在对eda的概念或范畴用得很宽。包括在机械、电子、通信、航空航天、化工、矿产、生物、医学、军事等各个领域,都有eda的应用。目前eda技术已在各大公司、企事业单位和科研教学部门广泛使用。例如在飞机制造过程中,从设计、性能测试及特性分析直到飞行模拟,都可能涉及到eda技术。本文所指的eda技术,主要针对电子电路设计、pcb设计和ic设计。2.2 硬件描述语言vhdl 2.2.1 vhdl的简介 vhdl的英文全名是very-high-speed integrated circuit hardwaredescription language,诞生于1982年。1987年底,vhdl被ieee和美国国防部确认为标准硬件描述语言。vhdl语言是一种用于电路设计的高级语言,主要用于描述数字系统的结构,行为,功能和接口。除了含有许多具有硬件特征的语句外,vhdl的语言形式和描述风格与句法是十分类似于一般的计算机高级语言。vhdl的程序结构特点是将一项工程设计,或称设计实体(可以是一个元件,一个电路模块或一个系统)分成外部(或称可是部分,及端口)和内部(或称不可视部分),既涉及实体的内部功能和算法完成部分。在对一个设计实体定义了外部界面后,一旦其内部开发完成后,其他的设计就可以直接调用这个实体。2.2.2 vhdl语言的特点 功能强大、设计灵活。支持广泛、易于修改。强大的系统硬件描述能力。独立于器件的设计、与工艺无关。很强的移植能力。2.2.3 vhdl的设计流程 用vhdl语言设计电路的流程:在用vhdl语言来设计电路时,主要的过程是这样的:(1)使用文本编辑器输入设计源文件。(2)使用编译工具编译源文件。vhdl的编译器有很多,active公司,modelsim公司,synplicity公司,synopsys公司,veribest公司等都有自己的编译器。(3)功能仿真。对于某些人而言,仿真这一步似乎是可有可无的。但是对于一个可靠的设计而言,任何设计最好都进行仿真,以保证设计的可靠性。另外,对于作为一个独立的设计项目而言,仿真文件的提供足可以证明你设计的完整性。 (4)综合。综合的目的是在于将设计的源文件由语言转换为实际的电路。这一部分的最终目的是生成门电路级的网表(netlist)。(5)布局、布线。这一步的目的是生成用于烧写的编程文件。在这一步,将用到第(4)步生成的网表并根据cpld/fpg厂商的器件容量,结构等进行布局、布线。这就好像在设计pcb时的布局布线一样。先将各个设计中的门根据网表的内容和器件的结构放在器件的特定部位。然后,在根据网表中提供的各门的连接,把各个门的输入输出连接起来。(6)最后仿真。这一步主要是为了确定设计在经过布局布线之后,是不是还满足原本的设计要求。3 简易电子琴设计过程3.1简易电子琴的工作原理 音乐产生原理及硬件设计由于一首音乐是许多不同的音阶组成的,而每个音阶对应着不同的频率,这样我们就可以利用不同的频率的组合,即可构成我们所想要的音乐了,当然对于单片机来产生不同的频率非常方便,我们可以利用单片机的定时/计数器来产生这样方波频率信号,因此,我们只要把一首歌曲的音阶对应频率关系弄正确即可。该电子琴可以实现两个功能,用按键cs来选择不同功能,第一种功能是用手动即通过按键的形式输入不同音名,第二种功能是音乐发生器,可以自动重复播放儿童歌曲“种太阳”音乐。当cs为高电平1时,选择功能二,当cs为低电平0时,选择功能一。3.2简易电子琴的工作流程图 开始按键按下是否成功to初始化并开中断允放to中断识别按键功能根据按键功能,装入音符t到to中启动to工作按键释放是否成功?停止to工作3.3简易电子琴中各模块的设计 系统内部结构图如图3.1所示图3.13.3.1分频器fpq1模块1.分频器1的程序library ieee;use ieee.std_logic_1164.all;entity fpq1 isport(clk12:in std_logic; clk1:buffer std_logic);end fpq1;architecture bhv of fpq1 isbeginprocess(clk12)variable count:integer range 0 to 1200;beginif clk12event and clk12=1 thencount:=count+1;if count=1200 thenclk1=not clk1;count:=0;end if;end if;end process;end bhv;2.分频器1的仿真图 3.3.2分频器fpq2模块程序1.分频器2的程序library ieee;use ieee.std_logic_1164.all;entity fpq2 isport(clk1:in std_logic; clk2:buffer std_logic);end fpq2;architecture bhv of fpq2 isbeginprocess(clk1)variable count:integer range 0 to 500;beginif clk1event and clk1=1 thencount:=count+1;if count=500 thenclk2toneindextoneindextoneindex=null;end case;end process;end bhv;3.3.2乐曲自动演奏notetabs模块程序library ieee;use ieee.std_logic_1164.all;entity notetabs isport(clk:in std_logic; toneindex2:out std_logic_vector(3 downto 0);end notetabs;architecture one of notetabs issignal counter:integer range 0 to 138;beginprocess(clk)beginif counter=138 thencounter=0;elsif clkevent and clk=1thencountertoneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2toneindex2null;end case;end process;end one;3.3.3按键tone模块程序library ieee;use ieee.std_logic_1164.all;entity tone isport(key:in std_logic_vector(6 downto 0);toneindex1:out std_logic_vector(3 downto 0);end;architecture one of tone isbeginsearch:process(key)begin case key iswhen0000001=toneindex1toneindex1toneindex1toneindex1toneindex1toneindex1toneindex1toneindex1 tone=11111111111 ; code=0000; high tone=01100000101 ; code=0001; high tone=01110010000 ; code=0010; high tone=10000001100 ; code=0011; high tone=10001011100 ; code=0100; high tone=10010101101 ; code=0101; high tone=10100001010 ; code=0110; high tone=10101011100 ; code=0111; high tone=10110000010 ; code=0001; high tone=10111001000 ; code=0010; high tone=11000000110 ; code=0011; high tone=11001010110 ; code=0101; high tone=11010000100 ; code=0110; high tone=11011000000 ; code=0001; high null; end case; end process;end;3.3.5speaker模块程序:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity speakera isport ( clk :in std_logic; tone : in std_logic_vector(10 downto 0); spk : out std_logic);end;architecture one of speakera issignal preclk, fullspk :std_logic;beginprocess(clk)variable count4 :integer range 0 to 16 ;beginpreclk = 0; - 将clk进行16分频,preclk为clk的16分频if count4=16 then preclk = 1; count4 := 0;elsif clkevent and clk = 1 then count4 := count4 + 1; end if;end process;genspk: process(preclk, tone)- 11位可预置计数器variable count11 : std_logic_vector(10 downto 0);beginif preclkevent and preclk = 1 thenif count11 = 11111111111 then count11 := tone ;fullspk = 1; else count11 := count11 + 1; fullspk= 0; end if;end if;end process; process(fullspk)-将输出再2分频,展宽脉冲,使扬声器有足够功率发音 variable count2 : std_logic;beginif fullspkevent and fullspk= 1 then count2 := not count2;if count2 = 1 then spk= 1;else spk= 0; end if; end if;end process;end;3.3.6 顶层设计顶层keshe模块程序library ieee;use ieee.std_logic_1164.all;entity keshe isport(clk12:in std_logic;key:in std_logic_vector(6 downto 0);cs:in std_logic;code1:out std_logic_vector(3 downto 0);high1:out std_logic;spkout:out std_logic);end;architecture bhv of keshe iscomponent toneport(key:in std_logic_vector(6 downto 0);toneindex1:out std_logic_vector(3 downto 0);end component;component notetabsport( clk:in std_logic; toneindex2:out std_logic_vector(3 downto 0);end component;component bmuxport(index1:in std_logic_vector(3 downto 0);index2:in std_logic_vector(3 downto 0);cs :in std_logic;toneindex:out std_logic_vector(3 downto 0);end component;component tonetabaport ( index : in std_logic_vector(3 downto 0) ; code :out std_logic_vector(3 downto 0) ; high: out std_logic; tone :out std_logic_vector(10 downto 0) );end component;component speakeraport ( clk :in std_logic; tone : in std_logic_vector(10 downto 0); spk : out std_logic);end component;component fpq1port(clk12:in std_logic; clk1:buffer std_logic);end component;component fpq2port(clk1:in std_logic; clk2:buffer std_logic);end component;signal toneindex1:std_logic_vector(3 downto 0);signal toneindex2:std_logic_vector(3 downto 0);signal toneindex:std_logic_vector(3 downto 0);signal tone1:std_logic_vector(10 downto 0);signal clk:std_logic;signal clk1:std_logic;beginu0:fpq1 port map(clk12,clk);u1:fpq2 port map(clk,clk1);u2:tone port map(key,toneindex1);u3:notetabs port map(clk1,toneindex2);u4:bmux port map(toneindex1,toneindex2,cs,toneindex);u5:tonetaba port map(toneindex,code1,high1,tone1);u6:speakera port map(clk12,tone1,spkout);end;4编译、仿真、下载验证4.1编译过程1)建立顶层设计文件夹myedadzq在硬盘适当位置建立myedadzq文件夹中。注意:该文件夹的路径中不能包含汉字。路径中的所有目录和子目录的名称都必须符合vhdl的语法规则。2)子模块文件的设计打开quartusii

温馨提示

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

评论

0/150

提交评论