技师CPLD技术专题研修设计造作报告-VHDL数字时钟.docx_第1页
技师CPLD技术专题研修设计造作报告-VHDL数字时钟.docx_第2页
技师CPLD技术专题研修设计造作报告-VHDL数字时钟.docx_第3页
技师CPLD技术专题研修设计造作报告-VHDL数字时钟.docx_第4页
技师CPLD技术专题研修设计造作报告-VHDL数字时钟.docx_第5页
已阅读5页,还剩33页未读 继续免费阅读

下载本文档

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

文档简介

技师cpld技术专题研修设 计 制作 报告课题名称 vhdl数字时钟 专业班级 07电气技师(1)班 学生姓名 学 号 8 指导教师 指导教师 宁波技师学院电气技术系二零一二年 三月摘 要cpld全称为“复杂的可编程逻辑器件”在数字电子、dsp和通信等邻域中广泛应用。该课题最终要设计一个24小时制数字钟,要求能显示时,分,秒可以手动调整时和分并在整点还差5秒时报警。此次编程和调试软件是用“quartus ii 6.0”来完成的,利用该软件编制一8个数码管动态扫描电路,然后再其所对应的管脚处接相应的电器原件,最终完成的电路即为该电路。最终要把实物做出来并能够按照要求正常显示与报警。此课题所学知识与单片机又有所区别,在以往的教学中也是第一次接触,所以对于学生的知识是有很大的开拓。vhdl是超高速集成电路硬件描述语言。它在80年代的后期出现。最初是由美国国防部开发出来供美军用来提高设计的可靠性和缩减开发周期的一种使用范围较小的设计语言 。主要用于描述数字系统的结构,行为,功能和接口。除了含有许多具有硬件特征的语句外,vhdl的语言形式、描述风格以及语法是十分类似于一般的计算机高级语言。vhdl的程序结构特点是将一项工程设计,或称设计实体(可以是一个元件,一个电路模块或一个系统)分成外部(或称可视部分,及端口)和内部(或称不可视部分),既涉及实体的内部功能和算法完成部分。在对一个设计实体定义了外部界面后,一旦其内部开发完成后,其他的设计就可以直接调用这个实体。这种将设计实体分成内外部分的概念是vhdl系统设计的基本点。 关键词:vhdl;动态扫描显示;60进制计数;同步消抖目 录目录1引言52总体设计方案53硬件设计53.1电源电路设计53.2按键电路设计53.3数码管动态显示电路设计5(1)秒计数模块5(2)分计数模块5(3)时计数模块54软件设计54.1 5分频程序54.2 10分频程序54.3 100 分频程序54.4 24进制程序54.5 60进制程序54.5 24进制54.6.1 数码管显示54.6.2 数码管动态显示54.7 整点报时55调试5步骤1.5步骤2.5步骤3.5步骤45步骤55步骤656结论5致谢5参考文献5附录1cpld内部顶层原理图5附录2 cpld外部原理图5附录3 原程序55分频电路程序。510分频电路5100分频电路58位数码管扫描电路5秒60进制电路5分钟60进制电路5小时24进制电路5报时系统5led灯系统5附录4印刷线路图5附录5实物图5附录6元器件清单51引言 随着数字电子技术和芯片技术的发展,复杂的可编程逻辑器件的性能大幅度提高,成本不断减低,可编程逻辑器件供应商将进一步扩大可编程芯片的领地,将复杂的专用芯片挤向高端和超复杂应用。据ic insights的数据显示,cpld市场从1999年的29亿美元增长到去年的56亿美元,几乎翻了一番。 对该领域的发展产生重要的影响。matas预计这种高速增长局面以后很难出现,但可编程逻辑器件依然是集成电路中最具活力和前途的产业。 本设计是一个采用通用cpld 器件isplsi1032e 采用在系统编程技术构成数字钟控系统的基本过程,只要设计出印刷电路板即可使该系统成为实际产品。实践证明,在系统编程技术与新型可编程逻辑器件的结合,可以将一个复杂的数字系统大部分功能在一片cpld 器件内实现,这不仅简化了数字系统的设计过程,而且大大减少了系统所用器件的数量,提高了系统的可靠性与性价比。 2总体设计方案数字钟控系统结构框图如图1 所示,数字钟部分由秒、分、时计数电路,报警和调时电路等组成。八只led 数码管分别显示时、分、秒之间再隔个横杆。脉冲信号发生器提供秒脉冲和发声高频振荡源。整个系统除了系统控制开关、脉冲信号发生器、发声电路以及led 数码管外,其余部分(如虚线框内所示)全部在一片emp240t100c5 内实现。3硬件设计3.1电源电路设计因emp240t100c5芯片的输入电源要求为3.3v直流电,所以要设计一个对应的电源电路为此芯片供电,下图为电源电路的工作原理。3.2按键电路设计下图两个按钮分别为调分与调时的按钮,当按下按钮是对应位由低电位变成高电位,脉冲发生了变化,产生调时的作用。3.3数码管动态显示电路设计本系统的微处理器采用p89lpc932芯片,是lpc900系列单片机的其中一个,对于本次的课程设计这个芯片是最佳选择,可以根据它的可靠性设计。此数码管是用动态显示节省i/o口,应我们所使用的数码管为共阳级所以需要在每个驱动口加上一个三极管,这样就能保证它的正常运行。(1)秒计数模块秒计数器为一60 进制递增计数器,将cdu38 的输出端q6、q4、q3、q0 通过与门2 控制置数控制端ld,因为置数输入端d7d0 全部接“地”,所以当计数器从0 计数至59时,ld 端为高电平,为置数做好准备。同时进位输出cao(取自ld 端)也为高电平,可用做高位计数器的级连信号。当第60 个脉冲到来时,计数器置零,实现60 进制计数。如下图所示。 秒计数器子电路(2)分计数模块分计数器子电路如下图所示,分计数器也是一个60 进制递增计数器,其构成思路与秒计数器相同,不再赘述。在分计数子电路中为cdu38 输出端配接了两个输出高电平有效的bcd7 段显示译码子模块(ttl47gb),可直接驱动7 段显示led 数码管。输出高电平有效的bcd7 段显示译码子模块符号与用abelhdl 语言编写的子程序如图5 所示。图4 分计数器子电路图5 bcd7 段显示译码电路模块符号与子程序(3)时计数模块时计数器子电路如图6 所示,时计数器也是利用cdu38 通过“反馈置数”方式构成。采用12 小时计时制,q4、q1 经与门i19 和i11 接止ld端,计数之间采用同步级连方式,当q4 和q1 为“1”且进位输入端cai(接分计数输出cao)为高电平,此时对应时间为12 时59 分59 秒,这时cdu38 的ld 端为高平,d7d1接“地”,d0 接高电平,因此在下一个秒脉冲到来之时,时计数器数值为01(分、秒计数器均为00),实现12 进制计数。图6 时计数器子电路与门i18 的作用是当时间为为11 时59 分59 秒时经cao12 端输出一高电平,用来控制上下午(a/p)的转换。4软件设计cpld软件系统主要包括五分频、十分频、一百分频、二十四进制、六十进制、校时、校分等。在这里只选择五种作为简单的介绍,源代码见附录。4.1 5分频程序图4-1 5分频顶层元件图library ieee;-库名是ieeeuse ieee.std_logic_1164.all;-用到的是ieee库中以及logic_1164use ieee.std_logic_unsigned.all; -用到的是ieee库以及logic_unsigned资源 use ieee.std_logic_arith.all; -用到的是ieee库以及logic_arith资源entity fenpin5 is-实体描述fenpin5port(clk:in std_logic;-clk是输入端,时钟/清零信号rst:in std_logic;-rst是输入端,标准逻辑位型co:out std_logic -co 是输出端,标准逻辑位型);end fenpin5;-结束实体描述fen5architecture behave of fenpin5 is-定义fenpin5为结构体signal tem2:std_logic_vector(3 downto 0);-定义tem2是标准逻辑位向量begin process(clk,rst) -clk、rst的进程begin if(rst=0)then-如果复位脉冲为下降沿tem2=0000;-tem2清零 elsif clkevent and clk=1then -当clk脉冲为上升沿时if tem2=0100then -如果tem2为4tem2=0000; -那么tem2清零co=1; -脉冲信号进位else tem2=tem2+1; -加1co=0; -无进位信号输出end if; -结束if语句 end if; -结束if语句 end process; -结束进程end behave;4.2 10分频程序图4-2 10分频顶层元件图library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity fenpin10 is-实体描述fenpin10port(clk:in std_logic;-clk是输入端,时钟/清零信号rst:in std_logic;-rst是输入端,标准逻辑位型co:out std_logic-co 是输出端,标准逻辑位型);end fenpin10; architecture behave of fenpin10 is-定义fenpin10为结构体signal tem2:std_logic_vector(3 downto 0);-定义tem2是标准逻辑位向量beginprocess(clk,rst)-clk、rst的进程begin if(rst=0)then-当复位脉冲为下降沿时 tem2=0000;-tem2清零 elsif clkevent and clk=1 then-当来clk脉冲 if tem2=1001then-如果tem2为9tem2=0000;-那么tem2将清零co=1;-有进位输出elsetem2=tem2+1;-tem2加1co=0;-无进位输出end if;end if;end process;-结束进程end behave;4.3 100 分频程序library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity aa100 isport(clk:in std_logic;rst:in std_logic;co: out std_logic);end aa100;architecture art of aa100 issignal tem1: std_logic_vector(3 downto 0);signal tem2: std_logic_vector(3 downto 0);beginprocess (clk,rst)begin if(rst=0)thentem1=0000;tem2=0000;elsif clkevent and clk=1 thenif tem1=1001 then;当tem1积满十个脉冲时给tem2来个脉冲,tem1清零。 tem1=0000;if tem2=1001 then;当tem2积满十个脉冲,相当于100个脉冲时就给co来个脉冲。tem2清零。 tem2=0000; co=1;else tem2=tem2+1;脉冲加一。 co=0;co清零。 end if;else tem1=tem1+1; end if; end if; end process; end art; 4.4 24进制程序图4-4 24进制顶层元件图 library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity fen24 isport(clk:in std_logic;rst:in std_logic;qout1: out std_logic_vector(3 downto 0);qout2: out std_logic_vector(3 downto 0);co:out std_logic);end fen24;architecture behave of fen24 issignal tem1:std_logic_vector(3 downto 0);signal tem2:std_logic_vector(3 downto 0);beginprocess(clk,rst)begin if(rst=1)then-当rst(复位)等于1,输出进位脉冲则执行下一条语句 tem1=0000;-tem1输出为0 tem2=0000;-tem2输出为0 elsif clkevent and clk=1 then-当时钟信号为上升沿触发时 if (tem2=0010and tem1=0011)then-如果tem2为2,tem1为3,执行以下程序tem1=0000;-那么tem1和tem2就清零tem2=0000;co=1;-有输出进位else-否则co=0;-无输出进位if tem1=1001then-在不满足以上情况如果tem1加至9tem1=0000;-tem1则清零if tem2=1001then-如果tem2为9tem2=0000;-tem2则清零(此段为100进制)else-否则tem2=tem2+1;-tem2加1end if;-结束if语句else-否则tem1=tem1+1;-tem1加1end if;-结束if语句 end if;-结束if语句 end if;-结束if语句qout1=tem1;qout2=tem2;end process;-结束进程end behave;4.5 60进制程序4-5 60 进制顶层元件图library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity fen60 isport(clk:in std_logic;rst:in std_logic;qout1: out std_logic_vector(3 downto 0);qout2: out std_logic_vector(3 downto 0);co:out std_logic);end fen60;architecture behave of fen60 issignal tem1:std_logic_vector(3 downto 0);signal tem2:std_logic_vector(3 downto 0);beginprocess(clk,rst)begin if(rst=1)then -当ckr为上升沿时 tem1=0000; -tem1清零 tem2=0000; -tem2清零 elsif clkevent and clk=1 then -当时钟信号为上升沿时,执行以下句子 if tem1=1001then -如果tem1为9时tem1=0000; -则tem1清零if tem2=0101then -如果tem2为5时tem2=0000; -则tem2清零co=1; -输出进位脉冲else tem2=tem2+1; -tem2加1co=0; -无进位脉冲输出end if; -结束if语句else -否则 tem1=tem1+1; -个位加1end if; -结束if语句end if; -结束if语句qout1=tem1;qout2=tem2;end process; -结束进程end behave; 4.5 24进制library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity aa24 isport(clk:in std_logic;rst:in std_logic;qout1: out std_logic_vector(3 downto 0);qout2: out std_logic_vector(3 downto 0);co: out std_logic);end aa24;architecture art of aa24 issignal tem1: std_logic_vector(3 downto 0);signal tem2: std_logic_vector(3 downto 0);beginprocess (clk,rst)begin if(rst=1)thentem1=0000;tem2=0000;elsif clkevent and clk=1 thenif (tem2=0010 and tem1=0011) then tem1=0000; tem1=0000;co=1;elseco=0;if tem1=1001 then tem1=0000; if tem2=1001 then tem2=0000; else tem2=tem2+1; end if; else tem1=tem1+1; end if;end if; end if;qout1=tem1;qout2=tem2; end process; end art;4.6.1 数码管显示library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity led7 isport(qin: in std_logic_vector(3 downto 0);qout: out std_logic_vector(7 downto 0);end led7;architecture art of led7 isbeginwith qin selectqout=00000011 when 0000,-显示 0 10011111 when 0001,-显示 1 00100101 when 0010,-显示 2 00001101 when 0011,-显示 3 10011001 when 0100,-显示 4 01001001 when 0101,-显示 5 01000001 when 0110,-显示 6 00011111 when 0111,-显示 7 00000001 when 1000,-显示 8 00001001 when 1001,-显示 9 00010001 when 1010,-显示 a 11000001 when 1011,-显示 b 01100011 when 1100,-显示 c 10000101 when 1101,-显示 d 01100001 when 1110,-显示 e 11111101 when 1111,-显示 - 00000011 when others; end art;4.6.2 数码管动态显示library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity dtsm isport(clk : in std_logic;rst : in std_logic;qin1: in std_logic_vector(3 downto 0);qin2: in std_logic_vector(3 downto 0);qin3: in std_logic_vector(3 downto 0);qin4: in std_logic_vector(3 downto 0);qin5: in std_logic_vector(3 downto 0);qin6: in std_logic_vector(3 downto 0);qout: out std_logic_vector(3 downto 0);sel : out std_logic_vector(7 downto 0);end dtsm;architecture art of dtsm isbeginprocess(clk,rst)variable cnt:integer range 0 to 7;begin if(rst=1) then cnt:=0; sel=11111110; qoutqout=qin1; selqout=qin2; selqout=1111; selqout=qin3; selqout=qin4; selqout=1111; selqout=qin5; selqout=qin6; selqout=0000; sel=11111111;end case;end if;end process; end art;4.7 整点报时library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity zdbs isport(clk:in std_logic;rst:in std_logic;qqq : out std_logic;qin4: in std_logic_vector(3 downto 0);qin3: in std_logic_vector(3 downto 0);qin2: in std_logic_vector(3 downto 0);qin1: in std_logic_vector(3 downto 0);end zdbs;architecture art of zdbs isbeginprocess (clk,rst)begin if(rst=1)thenqqq=0;elsif (clkevent and clk=1) thenif (qin4=0101 and qin3=1001 and qin2=0101 and qin1=1001) then qqq=1;elseqqq=0; end if;end if; end process; end art;5调试步骤1.在quartus ii 6.0软件中制作一个8个数码管动态扫描电路,然后生成一个块如下图所示。步骤2.在quartus ii 6.0软件中把cpld内部顶层原理图画好管脚定义完再编译步骤3.根据原理图画出pcb图步骤4制作出pcb板步骤5利用下图的下载器把程序烧写进芯片中步骤6调试显示成功,当显示时间到整点还差5秒时报警响起。6结论本设计方案按照任务书的要求设计的数字钟总算结束了,让我学习到了我们平时上机没有的知识和操作,通过此次学习,在对eda工具有了一定的了解的期初上,对quartus ii 6.0软件也有了比较熟练的操作,为以后深入的学习打下了基础。本次实验的课题不是很难,用上了以前学过的数字电路与逻辑设计知识,它说明了wda这门课程并不是孤立的,是和其他很多课程都相通的,这为学习也增添了很多趣味,同时对平时学过的书本知识也是一个很好的实践机会。由于学校所提供的条件不足,没有对长距离的通信进行实际测试,有待在以后的工作学习中不断进步。致谢感谢党和国家对我的培养。感谢父母多年来对我的付出。感谢老师对我的指导。感谢同学对我的帮助。感谢学校的工作人员、后勤人员。参考文献【1】 侯伯亨 李伯成 cpld原理及接口技术 西安电子科技大学出版社【2】 张友德等 cpld应用和实验 复旦大学出版社【3】 夏路易等 电路原理图与电路板设计北京希望电子出版社【4】 马忠梅等 c语言应用程序设计 北京航空航天大学出版社【5】 张志良 cpld原理与控制技术 机械工业出版社【6】 严蔚敏 数据结构 清华出版社【7】 王 闵 cpld组成原理 电子工业出版社【8】 方 敏 操作系统教程 电子科大出版社附录1cpld内部顶层原理图附录2 cpld外部原理图附录3 原程序5分频电路程序。library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity fenpin5 isport(clk:in std_logic;rst:in std_logic;co:out std_logic);end fenpin5;architecture behave of fenpin5 issignal tem2:std_logic_vector(3 downto 0);beginprocess(clk,rst)begin if(rst=0)thentem2=0000; elsif clkevent and clk=1thenif tem2=0100thentem2=0000;co=1;elsetem2=tem2+1;co=0;end if; end if; end process;end behave;10分频电路library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity fenpin10 isport(clk:in std_logic;rst:in std_logic;co:out std_logic);end fenpin10;architecture behave of fenpin10 issignal tem2:std_logic_vector(3 downto 0);beginprocess(clk,rst)begin if(rst=0)then tem2=0000; elsif clkevent and clk=1 then if tem2=1001thentem2=0000;co=1;elsetem2=tem2+1;co=0;end if;end if;end process;end behave;100分频电路library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity fenpin100 isport(clk:in std_logic;rst:in std_logic;co:out std_logic);end fenpin100;architecture behave of fenpin100 issignal tem1:std_logic_vector(3 downto 0);signal tem2:std_logic_vector(3 downto 0);beginprocess(clk,rst)begin if(rst=0)then tem1=0000; tem2=0000; elsif clkevent and clk=1 then if tem1=1001thentem1=0000;if tem2=1001thentem2=0000;co=1;elsetem2=tem2+1;co=0;end if;elsetem1=tem1+1;end if; end if;end process;end behave;8位数码管扫描电路library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity sel isport(clk:in std_logic;rst:in std_logic;qin1:in std_logic_vector(3 downto 0);qin2:in std_logic_vector(3 downto 0);qin3:in std_logic_vector(3 downto 0);qin4:in std_logic_vector(3 downto 0);qin5:in std_logic_vector(3 downto 0);qin6:in std_logic_vector(3 downto 0);qout:out std_logic_vector(3 downto 0);sel :out std_logic_vector(7 downto 0);end sel;architecture behave of sel isbeginprocess(clk,rst)variable cnt:integer range 0 to 7;begin if(rst=1)thencnt:=0;sel=11111110;qoutqout=qin1; selqout=qin2; selqout=1111; selqout=qin3; selqout=qin4; selqout=1111; selqout=qin5; selqout=qin6; selqout=0000; sel=11111111;end case; end if;end process;end behave;秒60进制电路library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity fen60 isport(clk:in std_logic;rst:in std_logic;qout1: out std_logic_vector(3 downto 0);qout2: out std_logic_vector(3 downto 0);co:out std_logic);end fen60;architecture behave of fen60 issignal tem1:std_logic_vector(3 downto 0);signal tem2:std_logic_vector(3 downto 0);beginprocess(clk,rst)begin if(rst=1)then tem1=0000; tem2=0000; elsif clkevent and clk=1 then if tem1=1001thentem1=0000;if tem2=0101thentem2=0000;co=1;elsetem2=tem2+1;co=0;end if;elsetem1=tem1+1;end if;end if;qout1=tem1;qout2=tem2;end process;end behave;分钟60进制电路library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;use ieee.std_logic_arith.all;entity fen60 isport(clk:in std_logic;rst:in std_logic;qout1: out std_logic_vector(3 downto 0);qout2: out std_logic_vector(3 downto 0);co:out std_logic);end fen60;architecture behave of fen60 issignal tem1:std_logic_vector(3 downto 0);signal tem2:std_logic_vector(3 downto 0);beginprocess(clk,rst)begin if(rst=1)then tem1=0000; tem2=0000; elsif clkevent and clk=1 then i

温馨提示

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

评论

0/150

提交评论