课程设计论文基于VHDL语言的流水灯设计_第1页
课程设计论文基于VHDL语言的流水灯设计_第2页
课程设计论文基于VHDL语言的流水灯设计_第3页
课程设计论文基于VHDL语言的流水灯设计_第4页
课程设计论文基于VHDL语言的流水灯设计_第5页
已阅读5页,还剩10页未读 继续免费阅读

下载本文档

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

文档简介

1、滨江学院课程论文(可编程器件原理与应用)题目 基于vhdl语言的流水灯设计 学生姓名 学 号 院 系 滨江学院 专 业 电子与信息工程 指导教师 二零一零年十二月三十日1、 任务:采用altera公司的epm7128slc84-10芯片,通过vhdl语言设计一个流水灯电路。流水灯样式必须大于3种,且可以通过按键调节显示样式;可以通过按键调节流水灯变化快慢;当前流水灯样式和变化速度能够通过数码管显示出来;(附加:具有按键声)2、 设计框图(框图说明)速度按键样式按键按键控制模块速度控制样式选择译码和扫描数码显示彩灯显示1000hz信号100hz信号蜂鸣器1mhz周期信号经过2个100分频,得到1

2、00hz,再经过1个10分频得到10hz信号,传给速度控制模块,得到需要的速度周期信号,然后传给样式选择模块,样式选择模块直接输出彩灯样式;控制模块通过接受两个按键信号,同时控制速度控制模块和样式选择模块;译码扫描模块通过判断控制模块,扫描数码管显示当前彩灯样式和彩灯变化速度;按键信号通过延时模块输出按键发生信号。三、原理图(cpld内部原理说明)从原理图中可以看到,一共有8种模块,d触发器的作用是对按钮进行消抖,除d触发器之外的7个模块功能及作用如下:f100和f10分别是100和10的分频器,speed模块的作用是对彩灯变化速度进行控制,而style_switch模块的作用是对彩灯样式进行

3、调节。control模块接收按键信号对样式和速度进行总的控制。show模块是对速度值和样式值进行译码并进行扫描数码管,将当前样式和速度状态显示出来。delay模块则是对按键声的延时。四、各个模块设计(波形仿真)1.f100模块功能:100分频波形仿真:vhdl代码:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity f100 is -100分频port(clk:in std_logic; sec:out std_logic);end entity f100;architecture ge

4、tsec of f100 issignal secout : std_logic :=1;beginprocess(clk) isvariable count100: integer range 0 to 50;beginif clkevent and clk=1 thencount100:=count100+1;if count100=50 thensecout=not secout;count100:=0;end if;end if;end process;sec=secout;end architecture getsec;2.f10模块功能:10分频波形仿真:vhdl代码:librar

5、y ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity f10 is -10分频port(clk:in std_logic; sec:out std_logic);end entity f10;architecture getsec of f10 issignal secout : std_logic :=1;beginprocess(clk) isvariable count10: integer range 0 to 5;beginif clkevent and clk=1 thencount10:

6、=count10+1;if count10=5 thensecout=not secout;count10:=0;end if;end if;end process;sec=secout;end architecture getsec;3.speed模块功能:根据date输入端的数值大小,产生不同频率的周期信号,从而达到控制彩灯变化速率的目的。波形仿真:vhdl代码:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity speed is -速度控制port(clk,clr:in std_l

7、ogic;date:in std_logic_vector(1 downto 0); spd_out:out std_logic);end entity speed;architecture arch of speed issignal spd_num:std_logic_vector(1 downto 0):=00;signal num:std_logic_vector(1 downto 0):=00;signal out_temp : std_logic :=0;beginprocess(clk,clr) isbeginspd_num = 3-date;if clr=1 thennum =

8、 00;spd_num = 3-date;out_temp =spd_num thennum=00;out_temp=not out_temp;elsenum=num+1;end if;end if;end if;end process;spd_out=out_temp;end architecture arch;4. style_switch模块功能:根据date输入端的数值大小,输出不同的彩灯样式波形仿真:vhdl代码:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity style_

9、switch is -样式选择port(clk,clr:in std_logic;date:in std_logic_vector(1 downto 0);style_out:out std_logic_vector(14 downto 0);end entity style_switch;architecture arch of style_switch issignal style_num:std_logic_vector(1 downto 0);signal style_over:std_logic:=0;beginprocess(clk,clr) isvariable temp: in

10、teger range 0 to 7;beginif clr=1 thentemp:=0;style_num = 00;elseif clkevent and clk=1 thenif date=00 thenif style_over=1 thenstyle_num=style_num+1;end if ;elsestyle_num case temp iswhen 0 = style_out style_out style_out style_out style_out 3 thenstyle_over=1;temp:=0;elsestyle_over case temp iswhen 0

11、 = style_out style_out style_out style_out style_out style_out style_out 5 thenstyle_over=1;temp:=0;elsestyle_over case temp iswhen 0 = style_out style_out style_out style_out style_out style_out style_out 5 thenstyle_over=1;temp:=0;elsestyle_over case temp iswhen 0 = style_out style_out style_out s

12、tyle_out style_out style_out style_out 5 thenstyle_over=1;temp:=0;elsestyle_over style_out =111111111111111;end case;end if;end if;end process;end architecture arch;5. control模块功能:接收按键信号,调节彩灯样式和变化速度值波形仿真:vhdl代码:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity control i

13、s 控制模块port(key_speed,key_style:in std_logic;speed_out,style_out:out std_logic_vector(1 downto 0);end entity control;architecture arch of control issignal speed_num:std_logic_vector(1 downto 0);signal style_num:std_logic_vector(1 downto 0);beginprocess(key_speed) isbeginif key_speedevent and key_spee

14、d=1 thenspeed_num=speed_num+1;end if;end process;process(key_style) isbeginif key_styleevent and key_style=1 thenstyle_num=style_num+1;end if ;end process;speed_out=speed_num;style_out duan duan duan duan duan=1111111;end case;wei duan duan duan duan duan=1111111;end case;wei=01;end if;temp:=temp+1;

15、end if;end process;end architecture arch;7.delay模块功能:按键按下之后,蜂鸣器鸣叫延时波形仿真:vhdl代码:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity delay is -蜂鸣器延时port(clk,con:in std_logic; d_out:out std_logic);end entity delay;architecture arch of delay issignal num:std_logic_vector(1 do

16、wnto 0):=00;beginprocess(clk,con) isbeginif con=1 thennum=01;d_out=1;elseif clkevent and clk=1 thenif num/=00 thennum=num-1;elsed_out=0;end if;end if;end if;end process;end architecture arch;五、结果为验证所设计程序是否正确,将程序下载进行硬件测试。在max+plus开发环境中进行管脚锁定,连接好下载线,然后将目标文件下载到器件中。经过测试,流水灯样式一共有4种,第0种样式为样式1、2、3的综合,且可以通过

17、按键调节显示样式;通过按键能够调节流水灯变化快慢,速度0为最慢速度,而速度3为最快速度;当前流水灯样式和变化速度也能够通过数码管显示出来;同时为了突出按键效果,按键被按下时,蜂鸣器能够发出鸣叫声。六、总结(包括体会和制作过程 1000字)经过一周的努力终于完成流水灯的设计,流水灯是由七个部分组成,其中包括分频器、速度控制器、样式选择器、总控制器、显示器、按钮、蜂鸣器组成。由1个四位数码管构成的显示屏可以正常显示当前彩灯样式和变化速度,并且可以通过按钮进行调节彩灯样式和变化速度,经过仿真测试各个功能键工作正常,并且能够发出蜂鸣声,达到了设计要求。在设计过程中,也遇到了许多问题,但通过查阅资料,上

18、网百度,问题都得到了解决。例如:在同一个进程中,如果有两个或两个以上敏感信号,那么只能使用一个event事件;在一个实体中,如果有两个或两个以上的进程,那么在各自的进程中,不能对同一个信号进行赋值;信号和变量的区别在于,信号在进程之外进行定义,而变量只能在某个进程中进行定义,在多进程执行的时候,外部进程不能使用本进程的变量。还有一个最为重要的问题就是,需要考虑资源量,一个芯片中可以下载进去的程序大小是有限的,在程序设计的时候尽量少申请变量和信号,对于信号和变量,位数能少则少,这样生成的模块资源才不会占用很大。通过这次eda试验设计,我感觉自己设计的流水灯功能虽然很简单,但从中我获得了许多。至少说又学会了一门vhdl语言,学会了max-plus ii的使用,包括模块设计,波形仿真以及原理图的设计同时,我也深深的体会到,eda和单

温馨提示

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

评论

0/150

提交评论