基于数码管显示的彩灯控制器.docx_第1页
基于数码管显示的彩灯控制器.docx_第2页
基于数码管显示的彩灯控制器.docx_第3页
基于数码管显示的彩灯控制器.docx_第4页
基于数码管显示的彩灯控制器.docx_第5页
已阅读5页,还剩12页未读 继续免费阅读

下载本文档

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

文档简介

eda原理及应用课程设计报告 课题名称: 基于数码管显示的彩灯控制器 院 系: 机电工程学院 专 业: 电子信息工程 学生姓名: 陈纳爽 学生学号: 201033285123 彩灯及数码管显示控制摘 要随着科技的发展 , 在现代生活中, 彩灯作为一种景观应用越来越多。而在电子电路设计领域中,电子设计自动化(eda)工具已成为主要的设计手段,vhdl语言则是eda的关键技术之一,它采用自顶向下的设计方法,即从系统总体要求出发,自上至下地将设计任务分解为不同的功能模块,最后将各功能模块连接形成顶层模块,完成系统硬件的整体设计。本文介绍了基于eda技的多路彩灯控制器的设计与分析。在max+plusii环境下采用vhdl语言实现,论述了基于vhdl语言和fpga芯片的数字系统设计思想和实现过程。电子设计自动化技术eda的发展给电子系统的设计带来了革命性的变化,eda软件设计工具,硬件描述语言,可编程逻辑器件使得eda技术的应用走向普及。fpga是新型的可编程逻辑器件,采用fpga进行产品开发可以灵活地进行模块配置,大大缩短了产品开发周期,也有利于产品向小型化,集成化的方向发展。关键词: vhdl 彩灯 仿真1、概述1.1、设计目的:设计一个彩灯控制器,使彩灯(led管)可以实现彩灯逐渐增多及两种不同频率的闪烁,有复位开关。整个系统有四个输入信号clk,option,fan,clr,三个输出信号控制俩个八路彩灯及数码管显示。option的高低电平控制彩灯闪烁的快慢,fan的高低电平控制彩灯的逐渐增多减少。1.2、设计要求:u 掌握fpga 的程序设计方法。 u 掌握硬件描述语言语法。 u 程序设计完成后要求在软件中实现功能仿真。2、系统设计2.1、设计原理:整个系统共有四个输入信号:基准时钟信号clk,系统清零信号(复位信号)clr,彩灯节奏快慢选择开关option;共有3个输出信号ledout7.0,shuguan6.0,doubleled7.0,分别用于控制彩灯及数码管的显示。据此,我们可将整个彩灯控制器cdkzq分为四大部分:彩灯花样控制部分、分频部分、定时部分和计数部分。当各个模块均完成上述操作之后,形成最后的彩灯显示系统,并且进行仿真。仿真通过,即可下载到指定的fpga芯片里面,并进行实际连线,进行最后的硬件测试。把分频部分的不同频率的时钟信号cp输送到计数部分 ,从而控制彩灯闪烁速度的快慢 ,定时部分控制每种速度维持的时间长短。原理图模块原理图管脚图22、设计方案:在电路中以 1 代表灯亮,以 0 代表灯灭,由 0、1按不同的规律组合代表不同的灯光图案,同时使其选择不同的频率,从而实现多种图案多种频率的花样功能显示。在该电路中只需简单的修改程序就可以灵活地调整彩灯图案和变化方式。下面就以一个彩灯控制系统的实现为例进行简单说明。此彩灯控制系统设定有两种花样变化 。彩灯图案状态变换的速度有快、慢两种。3、程序仿真图start compilation先编译generate functional simulation netlist然后生成功能仿真网络表assignmentssettingsimulation setting设置成功能仿真然后新建一个vector waveform file 通过viewutility windows-node finder 把输入输出管脚添加进波形仿真图里 点击start simulation得到仿真图waveform1:4、实验结果分析实验表明 ,此设计方法能够满足多种不同花样彩灯的变化要求 ,并且该方法便于扩展不同变化模式的彩灯花样,同时又实现了彩灯的两种不同频率的闪烁。如果不按任何按键时候,灯就按四种花样顺序循环跑,如果按下某个键再松开,比如按下c键然后松开,那么不管之前灯跑到哪个花样,按键后灯就会从c代表的花样处开始跑,然后是d花样,然后是a花样,依次循环。但是a,b,c,d认为是按下会弹起的按键,因为这个程序里,如果一直按着按键不松手,会导致灯只是反复跑一个花样。比如按着b键不松手,那么就会反复跑b花样。还有不能允许同时按下两个键,三个键,4个键,也就是说,同一时刻abcd只能有一个是高电平,否则会出错,因为这个程序并没有防错机制。5、心得体会本次设计的课题是彩灯控制器的设计,当拿到这个课题的时候经过分析就知道关键是计数器和分频器的使用,分频的方法有很多种,对于同一种功能的实现,用vhdl可以采用多种方式进行描述,每种方式之间各有优劣,本次设计只采用了其中较简单的一种,应尽量用最简洁的语言写出所需功能的程序。通过这次课程设计对技术有了更进一步的熟悉,vhdl语言和语言等其他语言还是有很大的区别。vhdl是eda技术的重要组成部分,其具有与具体硬件电路无关和与设计平台无关的特性,并且具有良好的电路行为描述和系统描述的能力,并在语言易读性和层次化、结构化设计方面,表现了强大的生命力和应用潜力。其主要的也是最大的优点就在于设计者可以专心致力于其功能的实现,而不需要对不影响功能的与工艺有关的因素花费过多的时间和精力。在实际操作中发现设计和课本上的知识有很大联系,但又高于课本,一个简单的原理要把它应用以及和其他功能综合起来就有些困难。通过设计也巩固了我们的书本知识以及通过借阅书籍和上网查找资料,也丰富了自己对的了解。6、致谢7、参考文献1 周润景.基于quartus的fpga/cpld数字系统设计实例m.电子工业出版社.2007,82 潘松 黄继业. eda技术实用教程(第二版).北京:科学出版社,2006.93 林明权 马维旻 vhdl数字控制系统设计范例.电子工业出版社2003,14 褚振勇. fpga设计及应用(第三版)m.西安电子科技大学出版社.2012,48、附录彩灯显示控制器的源程序library ieee;use ieee.std_logic_1164.all; use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;- uncomment the following library declaration if instantiating- any xilinx primitives in this code.-library unisim;-use unisim.vcomponents.all;entity colorled is port ( clk : in std_logic; clr : in std_logic; option : in std_logic; fan:in std_logic; ledout:out std_logic_vector(7 downto 0); shuma:out std_logic_vector(6 downto 0); doubleled:out std_logic_vector(7 downto 0);end colorled;architecture rtl of colorled iscomponent timer isport( clk : in std_logic; clr : in std_logic;option : in std_logic;fan:in std_logic;fanout:out std_logic;clkout : out std_logic);end component timer;component shower isport( clk : in std_logic; clr : in std_logic;fanin:in std_logic;ledout:out std_logic_vector (7 downto 0);shuma:out std_logic_vector(6 downto 0);doubleled:out std_logic_vector(7 downto 0);end component shower;signal clk_tmp:std_logic;signal fan_tmp:std_logic;beginu1:timer port map(clk,clr,option,fan,fan_tmp,clk_tmp);u2:shower port map(clk_tmp,clr,fan_tmp,ledout,shuma,doubleled);end rtl;以上为顶层文件代码以下为分频计数模块及彩灯显示控制模块的代码library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;- uncomment the following library declaration if instantiating- any xilinx primitives in this code.-library unisim;-use unisim.vcomponents.all;entity timer is port ( clk : in std_logic;-时钟 clr : in std_logic;-复位 fan:in std_logic; fanout:out std_logic; option : in std_logic;-快慢分频 clkout : out std_logic);-输出时钟end timer;architecture rtl of timer issignal clk_tmp:std_logic;signal fan_tmp:std_logic;-signal counter:std_logic_vector(1 downto 0);-计数器signal counter:integer range 0 to 16000000;beginprocess(clk,clr,option)begin if clr=1 then clk_tmp=0; counter=0; elsif clkevent and clk=1 then if option=0 then -四分频 if counter=16000000 then counter=0; clk_tmp=not clk_tmp;else counter=counter+1;end if; else -八分频 if counter=8000000 then counter=0; clk_tmp=not clk_tmp;else counter=counter+1;end if; end if; end if;end process;-begin- if clr=1 then- clk_tmp=0;- counter=00;- elsif clkevent and clk=1 then- if option=0 then -四分频- if counter=01 then- counter=00;- clk_tmp=not clk_tmp;-else- counter=counter+1;-end if;- else -八分频- if counter=11 then- counter=00;- clk_tmp=not clk_tmp;-else- counter=counter+1;-end if;- end if;- end if;-end process;clkout=clk_tmp; -输出分频时钟fan_tmp=fan;fanout=fan_tmp;end rtl;library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_arith.all;use ieee.std_logic_unsigned.all;- uncomment the following library declaration if instantiating- any xilinx primitives in this code.-library unisim;-use unisim.vcomponents.all;entity shower is port ( clk : in std_logic; clr : in std_logic; fanin:in std_logic; ledout:out std_logic_vector (7 downto 0); shuma:out std_logic_vector(6 downto 0); -8位彩灯输出 doubleled:out std_logic_vector(7 downto 0);end shower;architecture rtl of shower istype states is (s0,s1,s2,s3,s4,s5,s6,s7); -moore状态signal state:states;beginprocess(clk,clr,fanin)begin if clr=1 then state=s0; ledout=00000000; doubleled=00000000; shuma if fanin=1 then state=s7; ledout=11111110; doubleled=11111110; shuma=1111001; else state=s1; ledout=00000000; doubleled=00000000; shuma if fanin=1 then state=s0; ledout=00000000; doubleled=00000000; shuma=0000000; else state=s2; ledout=10000000; doubleled=10000000; shuma if fanin=1 then state=s1; ledout=10000000; doubleled=10000000; shuma=1111000; else state=s3; ledout=11000000; doubleled=11000000; shuma if fanin=1 then state=s2; ledout=11000000; doubleled=11000000; shuma=

温馨提示

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

评论

0/150

提交评论