1、音乐数码管计时点阵流水灯设计可编程器件及数字系统设计音乐数码管计时点阵流水灯设计 目 录一 设计目的与任务 31 设计目的 32 设计任务 3二 设计方案 4三 设计实现 51音乐模块 52 数码管模块 83点阵模块 114流水灯模块 11四 实验结果及分析 12五 实习总结 13六 附录(程序或电路图) 14 一 设计目的与任务1 设计目的 爱情,是一个永远都很流行的元素,从古至今,亘古未变。而梁山伯与祝英台的爱情故事更是被视为爱情的典范,梁祝细腻地呈现这一段唯美彻骨、惊天动地的爱情。他们的情,感天动地,二人化成彩蝶翩翩飞舞。本作品古今结合,融合梁祝优美凄凉的音乐和变化的点阵,更有类似播放音
2、乐的数码管时钟和变化多样的十二个流水灯,更增加了现代的气息。本作品可以用来制作工艺品来表达爱人双方对对方的爱。在点阵上可以画出各种图案,并写上想说的话,独特而实用。2 设计任务 由于硬件原因,本应该用蜂鸣器发声的改用扬声器来发声。把扬声器,点阵,流水灯,数码管四部分组合在一起,完成以声音为核心的整体组合。其中,对音乐的编写需要计算来调频,并且对音乐有一定的基础。对点阵,有图案的变化,通过频率和画出的图案的变化,可以产生动画的效果,但是由于模块的限制只能大体显示这个意思。流水灯是通过一个计数器改变十二个灯亮的形式。数码管则是一个数字钟的前身,只有秒数和分钟数,因为现实中歌曲很少有超过一小时的。二
3、 设计方案 图11 先通过分频程序对声音进行分频,查找乐谱,使发出想要的音乐。然后通过数码管计时,产生音乐播放器的效果,并在后续连接点阵显示想要的文字和图案。并且通过计数器来控制流水灯。三 设计实现1音乐模块 音乐模块,就是用扬声器循环播放“梁祝”这首歌,是此次设计的核心所在。程序如下:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_ARITH.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;entity yinyue isport( clk:in std_logic; speaker:out st
4、d_logic);end yinyue;architecture bhv of yinyue issignal up:std_logic_vector(0 to 18);signal yin:integer range 0 to 17:=1;signal j:integer range 0 to 139:=1;signal shijian,jiange:integer range 0 to 20480;beginprocess(clk)beginif (clkevent and clk=1)thenif up=1111111111111111111then up=000000000000000
5、0000; j=j+1;else up=up+1;if j=70 then jyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinyinjiangejiangejiangejiangejiangejiangejiangejiangejia
6、ngejiangejiangejiangejiangejiangejiangespeaker=0;end case;if shijian=jiange then shijian=shijian+1;if shijian=jiange/2 then speaker=1;else speaker=0;end if;else shijian=0;end if;end if;end if;end process;end bhv;2 数码管模块简单计时装置,修改自数字钟,产生播放器的感觉,程序如下:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD
7、_LOGIC_ARITH.ALL;USE IEEE.STD_LOGIC_UNSIGNED.ALL;ENTITY jishi ISport(sel:buffer std_logic_vector(7 downto 0); seg:out std_logic_vector(6 downto 0);end jishi;architecture bhv of jishi issignal ff :std_logic_vector(20 downto 0);signal clk0:std_logic;signal aa,bb :std_logic_vector(5 downto 0);signal k
8、:std_logic_vector(2 downto 0);signal temp1,temp2:std_logic_vector(5 downto 0);signal result1,result2,co1,co2:std_logic_vector(3 downto 0);signal dd :std_logic_vector(2 downto 0);signal sum:std_logic_vector(3 downto 0);beginclk0=ff(20);p1:process(clk)beginif(clkevent and clk=1)thenff=ff+1;end if;end
9、process;process(clk0)beginif(clk0event and clk0=1)thenif aa=111011 then aa=000000; bb=bb+1; else bb=bb; aa=aa+1;end if; if bb=111011 then bb=000000; end if;end if;if aa10 thentemp1=aa;result1=temp1(3 downto 0);co19 and aa20)thentemp1=aa+6;result1=temp1(3 downto 0);co119 and aa30)thentemp1=aa+12;resu
10、lt1=temp1(3 downto 0);co129 and aa40)thentemp1=aa+18;result1=temp1(3 downto 0);co139 and aa50)thentemp1=aa+24;result1=temp1(3 downto 0);co149 and aa60)thentemp1=aa+30;result1=temp1(3 downto 0);co1=0101;end if;if bb10 thentemp2=bb;result2=temp2(3 downto 0);co29 and bb20)thentemp2=bb+6;result2=temp2(3
11、 downto 0);co219 and bb30)thentemp2=bb+12;result2=temp2(3 downto 0);co229 and bb40)thentemp2=bb+18;result2=temp2(3 downto 0);co239 and bb50)thentemp2=bb+24;result2=temp2(3 downto 0);co249 and bb60)thentemp2=bb+30;result2=temp2(3 downto 0);co2=0101;end if;end process; process(clk)beginif( clkevent an
12、d clk=1)thendd=dd+1;end if;end process;with dd select sel=10000000 when 000, 01000000 when 001, 00100000 when 010, 00010000 when 011, 00001000 when 100, 00000100 when 101, 00000010 when 110, 00000001 when 111;with dd select sum= co2 when000, result2 when001, 1010 when010, co1 when011, result1 when10
13、0, 0000when others; with sum select seg=1000000 when 0000, 1111001 when 0001, 0100100 when 0010, 0110000 when 0011, 0011001 when 0100, 0010010 when 0101, 0000010 when 0110, 1011000 when 0111, 0000000 when 1000, 0010000 when 1001, 0111111 when 1010, 1111111 when others;end bhv;3点阵模块 点阵模块,主要就是点阵循环跳动显示
14、心形(有大有小,动画的思想),还有蝴蝶形,还有“爱成蝶”三个字。(由于程序较长,且后面有附录,所以不在此显示。)4流水灯模块 流水灯模块,主要显示的就是12盏灯循环有规则亮灭,配合音乐,并不断变化,形成视觉上的效果。(由于程序较长,且后面有附录,所以不在此显示。)四 实验结果及分析 实验成品的效果是音乐在播放,同时数码管开始计时,点阵开始显示文字和图案,流水灯也开始按照各种形式来循环闪烁。除了音乐是上网查的一些音谱和学习了一下大体模式,其它的都是本次实习过程中做成功的程序的修改。在实验的过程中一共碰到了以下几个问题1、音乐模块中播放音乐开始使用蜂鸣器,但是总是发出类似蝉鸣的叫声,无论怎么改都不
15、好用;后来使用扬声器,开始时有杂音,十分不清晰,后来经过分析,造成这个问题的原因可能有两个:第一,分频不对,造成音调有高有低,播放的不成曲调。第二,扬声器有失真效应,造成播放的有杂音。发现原因后,又重新对分频进行了处理,然后换了一个新的扬声器,而后程序编译通过,终于可以正常播放音乐了。2、在加入各种模块的过程中,出现了逻辑单元不够用的现象,怎么改都不好用,后来经过多方修改,发现使用的if语句使用太多的缘故,更改了一些语句,终于逻辑单元的数目降下来了,编译通过了。3、点阵模块设计时,出现了只跳动前几个字的现象,而且每两个一停顿。最后还有一个全亮的,经过修改程序,发现其中的一个计数器的位数不够,还
16、有分频分的不对,是一个比0.5秒多一点的频率,修改成1秒,上述情况就解决了。五 实习总结 先总结一下自主设计,本次设计是我第一次用一门自己陌生的语言做的设计,做的不是很完善,只能说是一些基本模块的整合。关于音乐系统,因为时间和知识缺乏的关系,设计得很是简陋,远远达不到当今社会的需求,应该多加几首音乐,并且用加入音乐选择的功能,这样,现实性更强了,同时点阵的设计本来想加一个跳动与滚动的转化的,但是时间仓促,总是有错误,所以最后只能放弃,以后好好研究一下。 再总结一下整个小学期的实习,在短短的四个星期的日子里,学到很多很多的的东西,不仅可以巩固了以前所学过的知识,而且学到了很多在书本上所没有学到过
17、的知识。以焊电路板开始,以自主设计结束,每一次都感觉自己做的很难,一旦成功后,就会继续更难更复杂的东西。课程设计也由浅入深,在之前的基础之上灵活使用,不仅需要缜密的逻辑思维以及清醒的头脑,更需要很强的动手能力,使我懂得了理论与实际相结合是很重要的,只有理论知识是远远不够的,只有把所学的理论知识与实践相结合起来,从理论中得出结论,从而提高自己的实际动手能力和独立思考的能力。我会把这段经历当做一笔宝贵的财富,激励我不断前进。 六 附录(程序或电路图)LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;USE IEEE.STD_LOGIC_ARITH.ALL;USE I
18、EEE.STD_LOGIC_UNSIGNED.ALL;ENTITY YINYYUE ISport(clk:in std_logic; speaker:out std_logic; i1:out std_logic_vector(15 downto 0); i2:out std_logic_vector(15 downto 0); sel:buffer std_logic_vector(7 downto 0); seg:out std_logic_vector(6 downto 0); dout: out std_logic_vector(11 downto 0); end yinyyue;ar
19、chitecture bhv of yinyyue issignal up:std_logic_vector(0 to 18);signal yin:integer range 0 to 17:=1;signal j:integer range 0 to 139:=1;signal shijian,jiange:integer range 0 to 20480;signal a,e:std_logic;signal b: std_logic_vector(20 downto 0);signal c: std_logic_vector(3 downto 0);signal d: std_logi
20、c_vector(2 downto 0);signal i2a,i2b,i2c,i2d,i2e,i2f,i2g:std_logic_vector(15 downto 0);signal cl:std_logic_vector(20 downto 0);signal mm:integer range 0 to 15;signal clm:std_logic;signal nnn:integer range 0 to 31;signal y1: std_logic_vector(31 downto 0);signal x,y:std_logic_vector(15 downto 0);signal
21、 ff :std_logic_vector(20 downto 0);signal clk0:std_logic;signal aa,bb :std_logic_vector(5 downto 0);signal k :std_logic_vector(2 downto 0);signal temp1,temp2:std_logic_vector(5 downto 0);signal result1,result2,co1,co2:std_logic_vector(3 downto 0);signal dd :std_logic_vector(2 downto 0);signal sum:st
22、d_logic_vector(3 downto 0);signal cnt : std_logic_vector ( 7 downto 0); -variable count:integer RANGE 0 TO 7; signal count : std_logic_vector(5 DOWNTO 0); signal f:std_logic_vector(22 downto 0); signal clk1:std_logic;beginprocess(clk)begin if(clkevent and clk=1) then if(b2048000) then b=b+1; else b=
23、000000000000000000000;end if; end if; end process;e=1 when b=000000000000000000000 else 0;process(clk)begin if clkevent and clk=1 then c=c+1;end if;end process;process(e)begin if eevent and e=1 thenif d7 then d=d+1; else d=000;end if;end if;end process;with c selecti1=1000000000000000when0000, 01000
24、00000000000when0001, 0010000000000000when0010, 0001000000000000when0011, 0000100000000000when0100, 0000010000000000when0101, 0000001000000000when0110, 0000000100000000when0111, 0000000010000000when1000, 0000000001000000when1001, 0000000000100000when1010, 0000000000010000when1011, 0000000000001000when1100, 0000000000000100when1101, 0000000000000010when1110, 0000000000000001when1111;process(e)begincase c is
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1