您好,欢迎访问三七文档
数字系统设计与硬件描述语言期末考试作业题目:洗衣机控制器的设计学院:电子信息工程学院专业:电子信息工程学号:3011204295姓名:邹雪强2013-11-06设计原理及功能介绍以EDA技术的基本理论为指导,用EDA方法去设计并完成特定功能的电子电路的仿真、调试,本设计为基于VHDL的EDA设计——洗衣机控制器的设计,同时要掌握常用仿真开发软件,比如:QuartusII和MaxplusII等EDA常用软件(本次试用使用的软件为QuartusII9.1)。基本要求:可选择工作模式;可设定工作时间;具有报警功能等。--2设计指标:控制洗衣机作如下运转:定时启动正转20秒暂停10秒反转20秒暂停10秒定时未到回到“正转20秒暂停10秒……”,定时到则停止;若定时到,则停机发出音响警报信号;用两个数码管显示洗涤的预置时间(分钟数),按倒计时方式对洗涤过程作计时显示,直到时间到停机;洗涤过程由“开始”信号开始;三只LED灯表示“正转”、“反转”、“暂停”三个状态。原理:洗衣机控制器的设计主要是定时器的设计,由一片FPGA和外围电路构成了电器控制部分。FPGA接收键盘的控制命令,控制洗衣机的进水、排水、水位和洗衣机的工作状态、并控制显示工作状态以及设定直流电机速度、正反转控制、制动控制、起停控制和运动状态控制。对FPGA芯片的编程采用模块化的VHDL进行设计,设计分为三层实现,顶层实现整个芯片的功能。顶层和中间层多数是由VHDL的元件例化语句实现。中间层由运行模式选择、洗涤模式选择、定时器、显示控制、键盘扫描、水位控制以及对直流电机控制板进行速度设定、正反转控制、启停控制等模块组成,它们分别调用底层模块。用LED显示正转20秒,暂停10秒,反转20秒,暂停10秒,60秒为一周期。总之洗衣机控制器设计的关键是计数器和定时器的设计。洗衣机控制器电路由五部分组成:1预置时间和编码电路:定时洗涤时间2减法计数器:计时3时序控制电路:控制洗涤过程的正转、暂停和反转4译码器:译出Q1Q2=00时,为暂停,Q1Q2=10时,为正转,Q1Q2=01时为反转5数码管显示:显示电路显示时间--3程序源代码及说明洗衣机控制器的源程序如下:一数码管显示libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityshowtimeisport(remain_time:instd_logic_vector(3downto0);cp:instd_logic;a,b,c,d,e,f,g:outstd_logic);endshowtime;architecturertlofshowtimeissignaltemp:std_logic_vector(6downto0);beginprocess(remain_time)begincaseremain_timeiswhen0000=temp=1111110;when0001=temp=0110000;when0010=temp=1101101;when0011=temp=1111001;when0100=temp=0010011;when0101=temp=1011011;when0110=temp=1011111;when0111=temp=1110000;when1000=temp=1111111;when1001=temp=1111011;whenothers=null;endcase;endprocess;a=temp(6);b=temp(5);c=temp(4);d=temp(3);e=temp(2);f=temp(1);g=temp(0);endrtl;二时序电路——控制洗衣机按20秒正转,停十秒。20秒反转,停十秒的顺序运行,直到时间结束信号的到来:libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;--4entityshixuisport(cp,en,rd:instd_logic;q1,q2:outstd_logic--00为停机,10为正转,01为反转);endshixu;architecturertlofshixuisbeginprocess(cp)variablestate:std_logic;--0代表正转,1代表反转variablewash_time:integer:=21;variablewait_time:integer:=9;beginif(en='0')thenwash_time:=21;Q1='0';Q2='0';--停机状态elseif(cp'eventandcp='1')thenif(rd='1')thenif(wash_time0)thenwash_time:=wash_time-1;wait_time:=9;--等待时间恢复elseif(wait_time0)--运行时间结束,等待时间未到thenwait_time:=wait_time-1;--等待时间减1elsewash_time:=20;--等待时间结束,继续运行state:=notstate;endif;endif;if(wash_time=0)thenQ1='0';Q2='0';--暂停elseif(state='0')--正转thenQ1='1';Q2='0';elseQ1='0';Q2='1';--反转endif;endif;elseQ1='0';Q2='0';--暂停endif;endif;endif;endprocess;endrtl;三预置时间与编码寄存电路,将输入的1-6分钟编为BCD码libraryieee;--5useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitysettimeisport(load:instd_logic;k:instd_logic_vector(5downto0);o:outstd_logic_vector(3downto0));endsettime;architecturertlofsettimeissignalp1:std_logic_vector(3downto0);beginprocess(k)begincasekis--将时间分钟when100000=p1=0001;when010000=p1=0010;when001000=p1=0011;when000100=p1=0100;when000010=p1=0101;when000001=p1=0110;whenothers=p1=0000;endcase;endprocess;o=p1;endrtl;[4]、将时序电路的信号翻译为暂停,正转,反转libraryieee;useieee.std_logic_1164.all;entitydecoderisport(Q1,Q2:instd_logic;REV,RUN,PAUSE:outstd_logic--rev反转,run正转,pause暂停);enddecoder;architecturertlofdecoderisbeginREV=Q2;RUN=Q1;PAUSE=not(Q1ORQ2);endrtl;--6[5]、-十进制BCD码减法计数器,实现输入的为分钟数,每隔60秒计数器减1libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitycounterisport(clk,start:instd_logic;k:inSTD_LOGIC_VECTOR(3downto0);time_remain:BUFFERSTD_LOGIC_VECTOR(3DOWNTO0);time_is_up:outstd_logic);endcounter;architecturertlofcounterisbeginprocess(clk)variabletime_second:integer:=0;beginif(clk'eventandclk='1')thenif(start='0')thentime_remain=k;time_second:=0;elseif(time_second=0)thenif(time_remain0)--防止时间无限计数thentime_remain=time_remain-1;time_second:=59;endif;elseif(time_remain=0)--时间是否结束的判定thentime_is_up='0';elsetime_is_up='1';time_second:=time_second-1;--秒表计数的实现endif;endif;endif;endif;endprocess;--7endrtl;[6]、元件声明与例化libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;PACKAGEmy_componetsIsCOMPONENTshowtimeIsport(remain_time:instd_logic_vector(3downto0);cp:instd_logic;a,b,c,d,e,f,g:outstd_logic);endCOMPONENT;COMPONENTshixuisport(cp,en,rd:instd_logic;q1,q2:outstd_logic--00为停机,10为正转,01为反转);endCOMPONENT;COMPONENTsettimeisport(load:instd_logic;k:instd_logic_vector(5downto0);o:outstd_logic_vector(3downto0));endCOMPONENT;COMPONENTdecoderisport(Q1,Q2:instd_logic;REV,RUN,PAUSE:outstd_logic--rev反转,run正转,pause暂停);endCOMPONENT;COMPONENTcounterisport(clk,start:instd_logic;k:inSTD_LOGIC_VECTOR(3downto0);time_remain:BUFFERSTD_LOGIC_VECTOR(3DOWNTO0);time_is_up:outstd_logic);endCOMPONENT;Endmy_componets;--8libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;usework.my_componets.all;entityxiyijiisport(clk,start,clk_fast:instd_logic;load:instd_logic;k:instd_logic_vector(5downto0);REV,RUN,PAUSE:outstd_logic;--rev反转,run正转,pause暂停rd:bufferstd_logic;a,b,c,d,e,f,g:outstd_logic);--q1为低位endxiyiji;architecturexiyijiofxiyijiissignalx,y,t:std_logic;signalz,j:std_logic_vector(3downto0);beginU1:settimeportmap(load,k,z);U2:counterportmap(clk,start,z,j,rd);U3:shixuportmap(clk,start,
本文标题:洗衣机控制器的设计
链接地址:https://www.777doc.com/doc-2356887 .html