1、在主控器内部也共有四个模块,既三角波模块,正弦波模块,方波模块和一个控制模块,通过编程可以分别设计这四个模块。了【】图3 CPLD内部控制原理图2.3.1.1 三角波模块 三角波模块是在设计时置一变量作为工作状态标志,在此变量全为0时,当检测到时钟的上升沿时进行加同一个数操作,全为0时,进行减同一个数操作。由于A/D转换采用12位的ADC7545芯片,且设64个时钟为一个三角波周期,输出每次加/减8。设计程序如下:LIBRARY IEEE。USE IEEE.STD_LOGIC_1164.ALL。USE IEEE.STD_LOGIC_UNSIGNED.ALL。ENTITY delta IS PO
2、RT(clk,reset:IN STD_LOGIC。q:OUT STD_LOGIC_VECTOR(7 DOWNTO 0)。END delta 。ARCHITECTURE behave OF delta ISBEGINPROCESS(clk,reset)VARIABLE tmp: STD_LOGIC_VECTOR(7 DOWNTO 0)。VARIABLE a: STD_LOGIC。 IF reset=0THEN tmp:=”00000000”。ELSIF clkEVENT AND clk=1THENIF a=0 THENIF tmp=”11111110”THEN=”11111111”。 a:=1
3、。ELSE=tmp+1。 - 递增运算 END IF。 ELSE IF tmp=”00000001”THEN=0。 =tmp-1。 -递减运算 q=tmp。 END PROCESS。END behave。2.3.1.2 正弦波模块 正弦波模块是对一个正弦波周期分为64个采样点,然后量化为8位2进制数据,最大值为255,最小值为0,由此得到正弦波表,经D/A转换得到波形。设计程序为:ENTITY sin ISPORT(clk,clr:d:OUTINTEGERRANGE 0 TO 255)。END sin。ARCHITECTURE behave OF sin ISPROCESS(clk,clr)
4、INTEGERRANGE 0 TO 63。 IF clr=0THENDd=254。 WHEN 02=252。 WHEN 03=249。WHEN 04=245。 WHEN 05=239。WHEN 06=233。 WHEN 07=225。WHEN 08=217。 WHEN 09=207。WHEN 10=197。 WHEN 11=186。WHEN 12=174。 WHEN 13=162。WHEN 14=150。 WHEN 15=137。WHEN 16=124。 WHEN 17=112。WHEN 18=99。 WHEN 19=87。WHEN 20=75。 WHEN 21=64。 WHEN 22=53。
5、 WHEN 23=43。WHEN 24=34。 WHEN 25=26。WHEN 26=19。 WHEN 27=13。WHEN 28=8。 WHEN 29=4。WHEN 30=1。 WHEN 31=WHEN 32= WHEN 33=WHEN 34= WHEN 35=WHEN 36= WHEN 37=WHEN 38= WHEN 39=WHEN 40= WHEN 41= WHEN 42= WHEN 43=WHEN 44= WHEN 45=WHEN 46= WHEN 47=WHEN 48= WHEN 49=WHEN 50= WHEN 51=WHEN 52= WHEN 53=WHEN 54= WHEN
6、55=WHEN 56= WHEN 57=WHEN 58= WHEN 59=WHEN 60= WHEN 61=WHEN 62= WHEN 63= END CASE。2.3.1.3 方波模块 方波模块设计是交替送出全0和全1,并以32个延时实现,64个时钟为一个周期。ENTITY square IS PORT(clk,clr:END square。ARCHITECTURE behave OF square IS SIGNAL a:BIT。 PROCESS(clk,clr)VARIABLE cnt: INTEGER 。 IF clr=0 THEN a ELSIF clkEVENT AND clk=1
7、THEN IF cnt63 THEN cnt:=cnt+1。Cnt:=NOT a 。END PROCESS。PROCESS(clk,a) IF clkEVENT AND clk=1THEN IF a=1 THENq q =d0。 -三角波形出 WHEN “01”=d1。 -正弦波输出 WHEN “10”=d2。 -方波形输出 WHEN OTHERS=NULL。2.3.2 D/A转换模块 图4 D/A转换电路电路中,AD7545将波形数据转换为模拟信号;LF353进行信号滤波和整形。2.3.3 晶振电路模块 图5 晶振电路在此电路中,通过12M的石英晶体和电容及74LS04来产生12MHz的频率
8、电路。2.3.4 电源模块图6电源原理图在此电路中,220V电压经变压器到整流桥能产生直流电压,再通过电容滤波,通过7805和7905来产生稳定的+5V和-5V电压。2.4 设计验证图7三角波仿真图图8 正弦波仿真图9 方波仿真图2.5 印制电路板设计 图10 系统原理图图11 PCB板图图12 3D图3 结束语本文介绍了一种基于CPLD的信号器的设计方案,用VHDL语言来设计主控器部分,并用D/A转换将数字信号转换成模拟信号用示波器显示出波形。主控器部分采用MAX+PLUSII进行仿真,仿真结果验证了设计的正确性。致谢在作者设计的过程中,指导老师陈卫兵给予了大力支持,陈老师认真负责的工作态度
9、,严谨的治学精神和深厚的理论水平使作者受益匪浅。在此表示感谢!参考文献1 李国洪,沈明山.可编程器件EDA技术与实践M. 北京:机械工业出版社,20042 王金明.Verilog HDL程序设计教程M. 北京:人民邮电出版社,20043 潘松、黄继业.EDA技术实用教程M. 北京:科学出版社,20024 徐惠民,安德宁. 数字逻辑设计与VHDL描述M. 北京:机械工业出版社,20025 杜建国. Verilog HDL 硬件描述语言M. 北京:国防工业出版社, 2004.16 廖裕平,陆瑞强.数字电路设计使用MAX+plus IIM. 北京:清华大学出版社,2001Signal Generat
10、or Design Based on CPLDName:Liu Zhiyi Student Number:200440602115 Advisor:Chen Weibing Abstract: This article gives a signal generator design using CPLD as themain controller. As a result of using EDA technique, the design proposal hasmany advantages such as of fastworking speed, small size in hardw
11、are, high reliability.Keywords:Signal Generator。 VHDL。 EDA。版权申明本文部分内容,包括文字、图片、以及设计等在网上搜集整理。版权为潘宏亮个人所有This article includes some parts, including text, pictures, and design. Copyright is Pan Hongliangs personal ownership.用户可将本文的内容或服务用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯本网站及相关权利人的合法权利
12、。除此以外,将本文任何内容或服务用于其他用途时,须征得本人及相关权利人的书面许可,并支付报酬。Users may use the contents or services of this article for personal study, research or appreciation, and other non-commercial or non-profit purposes, but at the same time, they shall abide by the provisions of copyright law and other relevant laws, and
13、shall not infringe upon the legitimate rights of this website and its relevant obligees. In addition, when any content or service of this article is used for other purposes, written permission and remuneration shall be obtained from the person concerned and the relevant obligee.转载或引用本文内容必须是以新闻性或资料性公
14、共免费信息为使用目的的合理、善意引用,不得对本文内容原意进行曲解、修改,并自负版权等法律责任。Reproduction or quotation of the content of this article must be reasonable and good-faith citation for the use of news or informative public free information. It shall not misinterpret or modify the original intention of the content of this article, and shall bear legal liability such as copyright.
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1