VHDL洗衣机设计Word版.docx
《VHDL洗衣机设计Word版.docx》由会员分享,可在线阅读,更多相关《VHDL洗衣机设计Word版.docx(30页珍藏版)》请在冰豆网上搜索。
VHDL洗衣机设计Word版
EDA课程实训报告
一、实训课题:
洗衣机控制器的设计
二、设计的内容及要求:
1.设计一个洗衣机控制器,要求为:
1)洗衣机控制器可以驱动洗衣机进行洗涤、漂洗或烘干;
2)洗衣机控制器可以设置洗衣机的工作时间,工作时间最短1分钟,最长30分钟,在工作过程中,工作时间以倒计时显示,若时间为0洗衣机停止工作;
3)洗衣机在待机状态时,洗衣机控制器可以设置洗衣机的工作方式和工作时间;
4)可以暂停或停止洗衣机工作;
5)利用四个数码管显示洗衣机待机时的设置时间和工作时的运行时间,利用一位数码管显示洗衣机待机时所设置的工作方式运行时的工作方式;
6)利用三个LED分别表示驱动洗衣机进行洗涤、漂洗或烘干。
2.洗衣机控制器可以划分为状态机模块、计时器模块、设置模块和显示选择模块。
在QuartusII中输入各个模块的代码,编译综合,仿真,完成各个模块的软件设计;
4.把各个模块组合起来,综合编译,仿真,完成整个交通灯控制器系统的软件设计;
5.选择电路方案锁定管脚,把程序下载到实验箱中,利用实验箱进行硬件实现;
6.完成实训报告。
实训报告包括:
1)设计的任务和要求;
2)模块的划分和系统总框图;
3)各个模块的实现,包括模块的作用,模块的输入与输出情况,模块状态图,模块的代码以及注释,模块的波形图;
4)系统的实现,包括系统总原理图,系统的波形图;
5)管脚的锁定关系;
三.设计思路:
◆状态切换>>>有限状态机
◆按定时时间及时>>>定时计数器
◆显示时间>>>数码管译码驱动器
◆接收设置时间>>>时间设置键盘扫描器
◆接收设置模式>>>模式设置键盘扫描器
◆切换显示运行时间和设置时间>>>二路选择器
◆切换显示运行模式和设置模式>>>二路选择器
整体设计示意图:
四.系统组成以及系统各部分的设计:
1.状态机的设计:
状态机要完成的功能:
●能设置工作模式;
●控制洗涤、漂洗、干衣的驱动输出;
●能启动、暂停、停止洗衣机控制器;
●能重启、暂停和停止定时器;
●能接收定时器的到时标志;
●能使能键盘扫描计数器;
●能控制二路选择器。
状态图分析设计如下:
模块设计图如下:
状态机仿真图如下:
2.定时器设计:
定时器的功能:
●能通过使能端暂停和允许定时器工作;
●能停止并复位定时器;
●能进行定时;
●能输出定时标志
模块设计图如下:
定时器波形图如下:
3.时间设置:
时间设置键盘扫描器的功能:
●能响应按键;
●能在使能端的控制下工作
模式设计图如下:
波形图如下:
4.模式设置:
模式设置键盘扫描器的功能:
预设工作模式,”000”为待机,”001”为洗涤,”010”为漂洗,”022”为干衣,”100”为暂停
模式设计图如下:
波形图如下:
5.二路选择器
二路选择器的功能:
设置显示运行时间还是设置时间,显示运行模式还是设置模式。
模式设计图如下:
整体结构图:
整体波形图:
五.下载时选择的开发系统模式以及管脚
1.管教配置:
2.实验电路结构图:
附录
代码:
1.状态机
LIBRARYieee;
USEieee.std_logic_1164.all;
ENTITYSHELL_WASHMACHINEIS
PORT(CLK,modein0,modein1,modein2,pause,start,stop,tcin:
INstd_logic;
ken,modeout0,modeout1,modeout2,sel,ten,tstop,wout0,wout1,wout2:
OUT
std_logic);
END;
ARCHITECTUREBEHAVIOROFSHELL_WASHMACHINEIS
TYPEtype_sregIS(dry,ready,rinse,waitup,wash);
SIGNALsreg,next_sreg:
type_sreg;
SIGNALnext_ken,next_modeout0,next_modeout1,next_modeout2,next_sel,next_ten,
next_tstop,next_wout0,next_wout1,next_wout2:
std_logic;
SIGNALmodeout:
std_logic_vector(2DOWNTO0);
SIGNALwout:
std_logic_vector(2DOWNTO0);
BEGIN
PROCESS(CLK,stop,next_sreg,next_ken,next_sel,next_ten,next_tstop,
next_modeout2,next_modeout1,next_modeout0,next_wout2,next_wout1,
next_wout0)
BEGIN
IF(stop='1')THEN
sreg<=ready;
sel<='0';
ken<='1';
ten<='1';
tstop<='1';
modeout2<='0';
modeout1<='0';
modeout0<='0';
wout2<='0';
wout1<='0';
wout0<='0';
ELSIFCLK='1'ANDCLK'eventTHEN
sreg<=next_sreg;
ken<=next_ken;
sel<=next_sel;
ten<=next_ten;
tstop<=next_tstop;
modeout2<=next_modeout2;
modeout1<=next_modeout1;
modeout0<=next_modeout0;
wout2<=next_wout2;
wout1<=next_wout1;
wout0<=next_wout0;
ENDIF;
ENDPROCESS;
PROCESS(sreg,modein0,modein1,modein2,pause,start,tcin,modeout,wout)
BEGIN
next_ken<='0';next_modeout0<='0';next_modeout1<='0';next_modeout2
<='0';next_sel<='0';next_ten<='0';next_tstop<='0';next_wout0<=
'0';next_wout1<='0';next_wout2<='0';
modeout<=std_logic_vector'("000");wout<=std_logic_vector'("000");
next_sreg<=dry;
CASEsregIS
WHENdry=>
IF(pause='0'ANDtcin='0')THEN
next_sreg<=dry;
next_ten<='1';
next_tstop<='0';
next_ken<='0';
next_sel<='1';
modeout<=(std_logic_vector'("011"));
wout<=(std_logic_vector'("100"));
ENDIF;
IF(tcin='0'ANDpause='1')THEN
next_sreg<=waitup;
next_ten<='0';
next_tstop<='0';
next_ken<='0';
next_sel<='1';
modeout<=(std_logic_vector'("100"));
wout<=(std_logic_vector'("000"));
ENDIF;
IF(tcin='1')THEN
next_sreg<=ready;
next_ten<='1';
next_tstop<='1';
next_ken<='1';
next_sel<='0';
modeout<=(std_logic_vector'("000"));
wout<=(std_logic_vector'("000"));
ENDIF;
WHENready=>
IF(modein1='0'ANDmodein0='0')OR(modein2='1')OR(start='0')
THEN
next_sreg<=ready;
next_ten<='1';
next_tstop<='1';
next_ken<='1';
next_sel<='0';
modeout<=(std_logic_vector'("000"));
wout<=(std_logic_vector'("000"));
ENDIF;
IF(modein0='1'ANDmodein1='1'ANDmodein2='0'ANDstart='1')THEN
next_sreg<=dry;
next_ten<='1';
next_tstop<='0';
next_ken<='0';
next_sel<='1';
modeout<=(std_logic_vector'("011"));
wout<=(std_logic_vector'("100"));
ENDIF;
IF(modein0='0'ANDmodein1='1'ANDmodein2='0'ANDstart='1')THEN
next_sreg<=rinse;
next_ten<='1';
next_tstop<='0';
next_ken<='0';
next_sel<='1';
modeout<=(std_logic_vector'("010"));
wout<=(std_logic_vector'("010"));
ENDIF;
IF(modein0='1'ANDmodein1='0'ANDmodein2='0'ANDstart='1')THEN
next_sreg<=wash;
next_ten<='1';
next_tstop<='0';
next_ken<='0';
next_sel<='1';
modeout<=(std_logic_vector'("001"));
wout<=(std_logic_vector'("001"));
ENDIF;
WHENrinse=>
IF(pause='0'ANDtcin='0')THEN
next_sreg<=rinse;
next_ten<='1';
next_tstop<='0';
next_ken<='0';
next_sel<='1';
modeout<=(std_logic_vector'("010"));
wout<=(std_logic_vector'("010"));
ENDIF;
IF(tcin='0'ANDpause='1')THEN
next_sreg<=waitup;
next_ten<='0';
next_tstop<='0';
next_ken<='0';
next_sel<='1';
modeout<=(std_logic_vector'("100"));
wout<=(std_logic_vector'("000"));
ENDIF;
IF(tcin='1')THEN
next_sreg<=ready;
next_ten<='1';
next_tstop<='1';
next_ken<='1';
next_sel<='0';
modeout<=(std_logic_vector'("000"));
wout<=(std_logic_vector'("000"));
ENDIF;
WHENwaitup=>
IF(modein1='0'ANDmodein0='0')OR(modein2='1')OR(pause='1')
THEN
next_sreg<=waitup;
next_ten<='0';
next_tstop<='0';
next_ken<='0';
next_sel<='1';
modeout<=(std_logic_vector'("100"));
wout<=(std_logic_vector'("000"));
ENDIF;
IF(modein0='1'ANDmodein1='1'ANDmodein2='0'ANDpause='0')THEN
next_sreg<=dry;
next_ten<='1';
next_tstop<='0';
next_ken<='0';
next_sel<='1';
modeout<=(std_logic_vector'("011"));
wout<=(std_logic_vector'("100"));
ENDIF;
IF(modein0='0'ANDmodein1='1'ANDmodein2='0'ANDpause='0')THEN
next_sreg<=rinse;
next_ten<='1';
next_tstop<='0';
next_ken<='0';
next_sel<='1';
modeout<=(std_logic_vector'("010"));
wout<=(std_logic_vector'("010"));
ENDIF;
IF(modein0='1'ANDmodein1='0'ANDmodein2='0'ANDpause='0')THEN
next_sreg<=wash;
next_ten<='1';
next_tstop<='0';
next_ken<='0';
next_sel<='1';
modeout<=(std_logic_vector'("001"));
wout<=(std_logic_vector'("001"));
ENDIF;
WHENwash=>
IF(pause='0'ANDtcin='0')THEN
next_sreg<=wash;
next_ten<='1';
next_tstop<='0';
next_ken<='0';
next_sel<='1';
modeout<=(std_logic_vector'("001"));
wout<=(std_logic_vector'("001"));
ENDIF;
IF(tcin='0'ANDpause='1')THEN
next_sreg<=waitup;
next_ten<='0';
next_tstop<='0';
next_ken<='0';
next_sel<='1';
modeout<=(std_logic_vector'("100"));
wout<=(std_logic_vector'("000"));
ENDIF;
IF(tcin='1')THEN
next_sreg<=ready;
next_ten<='1';
next_tstop<='1';
next_ken<='1';
next_sel<='0';
modeout<=(std_logic_vector'("000"));
wout<=(std_logic_vector'("000"));
ENDIF;
WHENOTHERS=>
ENDCASE;
next_modeout2<=modeout
(2);
next_modeout1<=modeout
(1);
next_modeout0<=modeout(0);
next_wout2<=wout
(2);
next_wout1<=wout
(1);
next_wout0<=wout(0);
ENDPROCESS;
ENDBEHAVIOR;
LIBRARYieee;
USEieee.std_logic_1164.all;
ENTITYWASHMACHINEIS
PORT(modein:
INstd_logic_vector(2DOWNTO0);
modeout:
OUTstd_logic_vector(2DOWNTO0);
wout:
OUTstd_logic_vector(2DOWNTO0);
CLK,pause,start,stop,tcin:
INstd_logic;
ken,sel,ten,tstop:
OUTstd_logic);
END;
ARCHITECTUREBEHAVIOROFWASHMACHINEIS
COMPONENTSHELL_WASHMACHINE
PORT(CLK,modein0,modein1,modein2,pause,start,stop,tcin:
INstd_logic;
ken,modeout0,modeout1,modeout2,sel,ten,tstop,wout0,wout1,wout2:
OUT
std_logic);
ENDCOMPONENT;
BEGIN
SHELL1_WASHMACHINE:
SHELL_WASHMACHINEPORTMAP(CLK=>CLK,modein0=>modein(0)
modein1=>modein
(1),modein2=>modein
(2),pause=>pause,start=>start,stop=>stop,
tcin=>tcin,ken=>ken,modeout0=>modeout(0),modeout1=>modeout
(1),modeout2=>
modeout
(2),sel=>sel,ten=>ten,tstop=>tstop,wout0=>wout(0),wout1=>wout
(1),wout2
=>wout
(2));
ENDBEHAVIOR;
2.定时器:
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitydingshiis
port(clk,ten,tstop:
instd_logic;
ims:
instd_logic_vector(3downto0);
iss:
instd_logic_vector(3downto0);
img:
instd_logic_vector(3downto0);
isg:
instd_logic_vector(3downto0);
cin:
outstd_logic;
omg,osg:
bufferstd_logic_vector(3downto0);
oms:
bufferstd_logic_vector(3downto0);
oss:
bufferstd_logic_vector(3downto0));
end;
architecturecmlofdingshiis
begin
PROCESS(clk,ten,tstop)
BEGIN
IFten='1'THEN
IFtstop='1'THEN
osg<=isg;
ELSIFclk'EVENTANDclk='1'THEN
IFosg="0000"THEN
IFoss>"0000"ORomg>"0000"ORoms>"0000"THEN
osg<="1001";
ELSE
osg<="0000";
ENDIF;
ELSE
osg<=osg-1;
ENDIF;
ENDIF;
ENDIF;
ENDPROCESS;
PROCESS(clk,ten,tstop,osg)
BEGIN
IFten='1'THEN
IFtstop='1'THEN
oss<=iss;
ELSIFclk'EVENTANDclk='1'THEN
IFosg="0000"THEN
IFoss=0THEN
IFomg>"0000"ORoms>"0000"THEN
oss<="0101";
ELSE
oss<="0000";
ENDIF;
ELSE
oss<=oss-1