FPGA硬件电子琴

上传人:豆**** 文档编号:49663469 上传时间:2022-01-18 格式:DOC 页数:10 大小:83KB
收藏 版权申诉 举报 下载
FPGA硬件电子琴_第1页
第1页 / 共10页
FPGA硬件电子琴_第2页
第2页 / 共10页
FPGA硬件电子琴_第3页
第3页 / 共10页
资源描述:

《FPGA硬件电子琴》由会员分享,可在线阅读,更多相关《FPGA硬件电子琴(10页珍藏版)》请在装配图网上搜索。

1、精品文档,仅供学习与交流,如有侵权请联系网站删除课程设计报告(电子设计自动化)题 目硬件电子琴学 院信息科学与工程学院专 业电子科学与技术班 级08级2班姓 名闫志伟 洪丁达指导教师吴丽丽2010年6月25日电子琴的设计摘 要:用可编程逻辑器件(PLD)来完成该设计。核心是一数控分频器,对输入的脉冲进行分频,得到每个音阶对应的频率,由此实现简易电子琴的发音功能。电子琴可演奏由键盘输入的音阶,同时在数码管上显示对应音节的频率。本设计基于超高速硬件描述语言VHDL在Altera公司的Cyclone系列的EP2C5T144C8芯片上编程实现;经仿真,硬件测试和调试基本能够达到技术指标,实验结果和仿真

2、结果基本一致。关键词:PLD,VHDL,数控分频,电子琴 The Design of Electrical Organ Abstract:The design is accomplished with Programmable-Logic-Device (PLD). The core of it is a numerical control frequency divider, which can divide the input pulse into the corresponding frequency to the musical scale, so that it can achiev

3、e the sounding function of simple electronic organ. The organ can play the musical scale put in with a keyboard . The design is programmed with VHDL and realized in the chip of EP2C5T144C8 Cyclone series. It can basically reach the technique index after simulating, hardware debugging. The experiment

4、 result is consonant with the simulating result. Keywords:PLD, VHDL, numerical control frequency divider, electrical organ一 系统设计1、 设计要求 8个音阶,外部时钟信号12 MHz;能同步显示音阶频率。2 设计思路 通过可编程逻辑器件(PLD)和VHDL硬件描述语言来实现电子琴的基本要求。 设计的主体是数控分频器,对输入的频率按照与每个音阶对应的分频系数进行分频,得到各个音阶对应的频率分别在蜂鸣器和数码管上以声音和频率数值的形式作为输出。 3、系统组成及工作原理图1-2

5、-3-1为系统的工作原理框图。根据设计要求,提供的外部时钟信号为12MHz,所以在本设计中需要将其进行分频,以得到所需要的脉冲 。键盘编码器的作用是对键盘按键输入的信号进行检测,并且产生相应的分频系数。 音调发生器的主要部分是一个数控分频器,它由一个初值可预置的加法计数器构成,详细工作原理将在后文做介绍,当它接收到一个分频信号时,便对端口的12MHz的输入时钟信号进行分频,之后由扬声器输出对应的声调。频率计的作用是将各个音阶对应的分频之后的频率通过数码管显示出来。 分频置 数按键分频器12MHZ蜂 鸣 器4位测频器数码管显示图1-2-3-1 工作原理框图二 单元电路设计 1、 顶层模块的设计

6、VHDL采用的是自顶向下的设计方式,顶层模块由音调发生器(tonetaba)、数控分频器(speaker)和频率计(top)三个模块组成。图2-1-1即是顶层设计原理图。由键盘输入的信号,进行编码,输出的都是八位二进制数,对应音调发生器的输入。 图2-1-1 顶层设计原理图2、 音调发生器模块(tonetaba)的设计音调发生器的作用是产生获得音阶的分频预置值。当8位发声控制输入index中的某一位为高电平时,则对应某一音阶的数值将以端口tone输出,作为获得该音阶的分频预置值,该值作为数控分频器的输入,来对12MHz的脉冲进行分频,由此得到每个音阶相应的频率,例如输入index=000000

7、10,即对应的按键是2,产生的分频系数便是1702;同时由high1输出对应该音阶低音显示。各音阶所对应的频率:低音1低音2低音3低音4低音5低音6低音7261.63Hz293.67Hz329.63Hz349.23Hz391.99Hz440Hz493.88Hz高音1高音2高音3高音4高音5高音6高音71046.5Hz1174.66Hz1318.51Hz1396.92Hz1567.98Hz1760Hz1975.52HZ分频系数的计算:低音1的频率为261.6Hz,则分频系数=1911,同理可求其他频率的分频系数。创新点:利用按键8来区别高低音,当按键8为高电平时,按键1到7分别表示高音的1到7。

8、当按键8为低时,按键1到7为低音的1到7when 00000001 = tone=11101110111; high1 tone=11010100110; high1 tone=10111101100; high1 tone=10110010111; high1 tone=10011111011; high1 tone=10001110000; high1 tone=01111110100; high1 tone=00111011110; high1 tone=00110101001; high1 tone=00101111011; high1 tone=00101100101; high1

9、tone=00100111110; high1 tone=00100011100; high1 tone=00011111101; high1null;3 、 数控分频模块(speaker)的设计数控分频模块的目的是对基准脉冲分频,得到1,2,3,4,5,6,7七个音符对应频率。该模块的VHDL描述中包含了三个进程。首先对12MHz的基准脉冲进行12分频得到1MHz的脉冲,然后按照tone输入的分频系数对1MHz的脉冲再次分频,得到的便是所需要的频率。而第三个进程的作用是在音调输出时再进行二分频,将脉冲展宽,以使扬声器有足够功率发音。十二分频:divideclk : process(clk)

10、variable count4 :std_logic_vector( 3 downto 0); begin preclk11 then preclk=1; count4:=0000; elsif clkevent and clk=1 then count4:=count4 + 1; end if; end process;按分频系数进行分频:genspks: process(preclk,tone) variable count11 :std_logic_vector (10 downto 0); begin if preclkevent and preclk=1 then count11:=

11、count11+1;fullspks=0; if count11=tone then fullspks=1; count11:=00000000000; end if; end if; end process;二分频使输出有足够大的功率发声:delayspks: process(fullspks) variable count2 :std_logic; begin if fullspksevent and fullspks =1then count2:=not count2; if count2=1 then spks=1; else spksfdin, tone=tone1, high1=o

12、_high); u2: speaker port map ( clk=fclk12, tone=tone1, spks=o_dout); u3: testctl port map ( clk=fclk1, cnt_en=en1, rst_cnt=rst1, load=ld); u4: cnt10 port map ( clk1=o_dout, en=en1, rst=rst1, cq=fd( 3 downto 0), cout=d1); u5: cnt10 port map ( clk1=d1, en=en1, rst=rst1, cq=fd( 7 downto 4), cout=d2); u

13、6: cnt10 port map (clk1=d2, en=en1, rst =rst1, cq=fd(11 downto 8), cout=d3); u7: cnt10 port map (clk1=d3, en=en1, rst=rst1, cq=fd(15 downto 12); u8: reg16 port map (load=ld, din=fd, dout=fout); end;2.音调发生模块程序:library ieee;use ieee.std_logic_1164.all;entity tonetaba is port (index :in std_logic_vecto

14、r (7 downto 0); high1: out std_logic;-gaoyin tone: out std_logic_vector (10 downto 0); end; architecture one of tonetaba is begin search: process(index) begin case index is when 00000001 = tone=11101110111; high1 tone=11010100110; high1 tone=10111101100; high1 tone=10110010111; high1 tone=1001111101

15、1; high1 tone=10001110000; high1 tone=01111110100; high1 tone=00111011110; high1 tone=00110101001; high1 tone=00101111011; high1 tone=00101100101; high1 tone=00100111110; high1 tone=00100011100; high1 tone=00011111101; high1null; end case; end process; end; 3.分频模块:library ieee;use ieee.std_logic_116

16、4.all;use ieee.std_logic_unsigned.all;entity speaker is port( clk: in std_logic; tone: in std_logic_vector(10 downto 0); spks: out std_logic ); end; architecture one of speaker is signal fullspks: std_logic; signal preclk : std_logic; begin divideclk : process(clk) variable count4 :std_logic_vector(

17、 3 downto 0); begin preclk11 then preclk=1; count4:=0000; elsif clkevent and clk=1 then count4:=count4 + 1; end if; end process; genspks: process(preclk,tone) variable count11 :std_logic_vector (10 downto 0); begin if preclkevent and preclk=1 then count11:=count11+1;fullspks=0; if count11=tone then

18、fullspks=1; count11:=00000000000; end if; end if; end process; delayspks: process(fullspks) variable count2 :std_logic; begin if fullspksevent and fullspks =1then count2:=not count2; if count2=1 then spks=1; else spks0); elsif clk1event and clk1=1 then if en=1 then if cqi10 then cqi :=cqi+1; if cqi=

19、10 then cout0); else cout=0; end if; end if;end if; end if; cq=cqi; end process; end behav;(2)测频控制器: LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY TESTCTL IS PORT ( CLK : IN STD_LOGIC; - 1Hz CNT_EN,RST_CNT,LOAD : OUT STD_LOGIC); END TESTCTL;ARCHITECTURE behav OF TES

20、TCTL IS SIGNAL DIV2CLK : STD_LOGIC;BEGIN PROCESS( CLK ) BEGIN IF CLKEVENT AND CLK = 1 THEN DIV2CLK = NOT DIV2CLK; END IF; END PROCESS; PROCESS (CLK, DIV2CLK) BEGIN IF CLK=0 AND Div2CLK=0 -zhi hou qing 0THEN RST_CNT = 1; ELSE RST_CNT = 0; END IF; END PROCESS; LOAD = NOT DIV2CLK ; CNT_EN = DIV2CLK;END

21、 behav;(3)锁存器:library ieee;use ieee.std_logic_1164.all;entity REG16 is port ( load : in std_logic; din: in std_logic_vector(15 downto 0); dout: out std_logic_vector(15 downto 0) );end REG16; architecture behav of REG16 isbegin process(load,din)begin if loadevent and load=1 then dout=din; end if;end process;end behav;

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

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!