《VHDL洗衣机设计(37页).doc》由会员分享,可在线阅读,更多相关《VHDL洗衣机设计(37页).doc(37页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、-EDA课程实训报告一、实训课题:洗衣机控制器的设计二、设计的内容及要求:1设计一个洗衣机控制器,要求为:1) 洗衣机控制器可以驱动洗衣机进行洗涤、漂洗或烘干;2) 洗衣机控制器可以设置洗衣机的工作时间,工作时间最短1分钟,最长30分钟,在工作过程中,工作时间以倒计时显示,若时间为0洗衣机停止工作;3) 洗衣机在待机状态时,洗衣机控制器可以设置洗衣机的工作方式和工作时间;4) 可以暂停或停止洗衣机工作;5) 利用四个数码管显示洗衣机待机时的设置时间和工作时的运行时间,利用一位数码管显示洗衣机待机时所设置的工作方式运行时的工作方式;6)利用三个LED分别表示驱动洗衣机进行洗涤、漂洗或烘干。2洗衣
2、机控制器可以划分为状态机模块、计时器模块、设置模块和显示选择模块。在QuartusII中输入各个模块的代码,编译综合,仿真,完成各个模块的软件设计;4把各个模块组合起来,综合编译,仿真,完成整个交通灯控制器系统的软件设计;5. 选择电路方案锁定管脚,把程序下载到实验箱中,利用实验箱进行硬件实现;6. 完成实训报告。实训报告包括:1) 设计的任务和要求;2) 模块的划分和系统总框图;3) 各个模块的实现,包括模块的作用,模块的输入与输出情况,模块状态图,模块的代码以及注释,模块的波形图;4) 系统的实现,包括系统总原理图,系统的波形图;5) 管脚的锁定关系;三设计思路:u 状态切换有限状态机u
3、按定时时间及时 定时计数器u 显示时间 数码管译码驱动器u 接收设置时间时间设置键盘扫描器u 接收设置模式 模式设置键盘扫描器u 切换显示运行时间和设置时间二路选择器u 切换显示运行模式和设置模式二路选择器整体设计示意图:四系统组成以及系统各部分的设计: 1.状态机的设计: 状态机要完成的功能:l 能设置工作模式;l 控制洗涤、漂洗、干衣的驱动输出;l 能启动、暂停、停止洗衣机控制器;l 能重启、暂停和停止定时器;l 能接收定时器的到时标志;l 能使能键盘扫描计数器;l 能控制二路选择器。 状态图分析设计如下: 模块设计图如下:状态机仿真图如下:2. 定时器设计:定时器的功能:l 能通过使能端
4、暂停和允许定时器工作;l 能停止并复位定时器;l 能进行定时;l 能输出定时标志 模块设计图如下: 定时器波形图如下: 3.时间设置: 时间设置键盘扫描器的功能:l 能响应按键;l 能在使能端的控制下工作 模式设计图如下: 波形图如下: 4.模式设置: 模式设置键盘扫描器的功能:预设工作模式,”000”为待机,”001”为洗涤,”010”为漂洗,”022”为干衣,”100”为暂停模式设计图如下:波形图如下: 5. 二路选择器 二路选择器的功能:设置显示运行时间还是设置时间,显示运行模式还是设置模式。模式设计图如下:整体结构图:整体波形图:五下载时选择的开发系统模式以及管脚1.管教配置:2. 实
5、验电路结构图:附录代码:1.状态机LIBRARY ieee;USE ieee.std_logic_1164.all;ENTITY SHELL_WASHMACHINE ISPORT (CLK,modein0,modein1,modein2,pause,start,stop,tcin: IN std_logic;ken,modeout0,modeout1,modeout2,sel,ten,tstop,wout0,wout1,wout2 : OUT std_logic);END;ARCHITECTURE BEHAVIOR OF SHELL_WASHMACHINE ISTYPE type_sreg I
6、S (dry,ready,rinse,waitup,wash);SIGNAL sreg, next_sreg : type_sreg;SIGNAL next_ken,next_modeout0,next_modeout1,next_modeout2,next_sel,next_ten,next_tstop,next_wout0,next_wout1,next_wout2 : std_logic;SIGNAL modeout : std_logic_vector (2 DOWNTO 0);SIGNAL wout : std_logic_vector (2 DOWNTO 0);BEGINPROCE
7、SS (CLK, stop, next_sreg, next_ken, next_sel, next_ten, next_tstop, next_modeout2, next_modeout1, next_modeout0, next_wout2, next_wout1, next_wout0)BEGINIF ( stop=1 ) THENsreg = ready;sel = 0;ken = 1;ten = 1;tstop = 1;modeout2 = 0;modeout1 = 0;modeout0 = 0;wout2 = 0;wout1 = 0;wout0 = 0;ELSIF CLK=1 A
8、ND CLKevent THENsreg = 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;END IF;END PROCESS;PROCESS (sreg,modein0,modein1,modein2,pause,start,tc
9、in,modeout,wout)BEGINnext_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_sregIF ( pause=0 AND tcin=0 ) THENnext_sreg=dry;next
10、_ten=1;next_tstop=0;next_ken=0;next_sel=1;modeout = (std_logic_vector(011);wout = (std_logic_vector(100);END IF;IF ( tcin=0 AND pause=1 ) THENnext_sreg=waitup;next_ten=0;next_tstop=0;next_ken=0;next_sel=1;modeout = (std_logic_vector(100);wout = (std_logic_vector(000);END IF;IF ( tcin=1 ) THENnext_sr
11、eg=ready;next_ten=1;next_tstop=1;next_ken=1;next_sel=0;modeout = (std_logic_vector(000);wout IF ( modein1=0 AND modein0=0 ) OR ( modein2=1 ) OR ( start=0 ) THENnext_sreg=ready;next_ten=1;next_tstop=1;next_ken=1;next_sel=0;modeout = (std_logic_vector(000);wout = (std_logic_vector(000);END IF;IF ( mod
12、ein0=1 AND modein1=1 AND modein2=0 AND start=1 ) THENnext_sreg=dry;next_ten=1;next_tstop=0;next_ken=0;next_sel=1;modeout = (std_logic_vector(011);wout = (std_logic_vector(100);END IF;IF ( modein0=0 AND modein1=1 AND modein2=0 AND start=1 ) THENnext_sreg=rinse;next_ten=1;next_tstop=0;next_ken=0;next_
13、sel=1;modeout = (std_logic_vector(010);wout = (std_logic_vector(010);END IF;IF ( modein0=1 AND modein1=0 AND modein2=0 AND start=1 ) THENnext_sreg=wash;next_ten=1;next_tstop=0;next_ken=0;next_sel=1;modeout = (std_logic_vector(001);wout IF ( pause=0 AND tcin=0 ) THENnext_sreg=rinse;next_ten=1;next_ts
14、top=0;next_ken=0;next_sel=1;modeout = (std_logic_vector(010);wout = (std_logic_vector(010);END IF;IF ( tcin=0 AND pause=1 ) THENnext_sreg=waitup;next_ten=0;next_tstop=0;next_ken=0;next_sel=1;modeout = (std_logic_vector(100);wout = (std_logic_vector(000);END IF;IF ( tcin=1 ) THENnext_sreg=ready;next_
15、ten=1;next_tstop=1;next_ken=1;next_sel=0;modeout = (std_logic_vector(000);wout IF ( modein1=0 AND modein0=0 ) OR ( modein2=1 ) OR ( pause=1 ) THENnext_sreg=waitup;next_ten=0;next_tstop=0;next_ken=0;next_sel=1;modeout = (std_logic_vector(100);wout = (std_logic_vector(000);END IF;IF ( modein0=1 AND mo
16、dein1=1 AND modein2=0 AND pause=0 ) THENnext_sreg=dry;next_ten=1;next_tstop=0;next_ken=0;next_sel=1;modeout = (std_logic_vector(011);wout = (std_logic_vector(100);END IF;IF ( modein0=0 AND modein1=1 AND modein2=0 AND pause=0 ) THENnext_sreg=rinse;next_ten=1;next_tstop=0;next_ken=0;next_sel=1;modeout
17、 = (std_logic_vector(010);wout = (std_logic_vector(010);END IF;IF ( modein0=1 AND modein1=0 AND modein2=0 AND pause=0 ) THENnext_sreg=wash;next_ten=1;next_tstop=0;next_ken=0;next_sel=1;modeout = (std_logic_vector(001);wout IF ( pause=0 AND tcin=0 ) THENnext_sreg=wash;next_ten=1;next_tstop=0;next_ken
18、=0;next_sel=1;modeout = (std_logic_vector(001);wout = (std_logic_vector(001);END IF;IF ( tcin=0 AND pause=1 ) THENnext_sreg=waitup;next_ten=0;next_tstop=0;next_ken=0;next_sel=1;modeout = (std_logic_vector(100);wout = (std_logic_vector(000);END IF;IF ( tcin=1 ) THENnext_sreg=ready;next_ten=1;next_tst
19、op=1;next_ken=1;next_sel=0;modeout = (std_logic_vector(000);wout END CASE;next_modeout2 = modeout(2);next_modeout1 = modeout(1);next_modeout0 = modeout(0);next_wout2 = wout(2);next_wout1 = wout(1);next_wout0 CLK,modein0=modein(0),modein1=modein(1),modein2=modein(2),pause=pause,start=start,stop=stop,
20、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);END BEHAVIOR; 2 定时器: library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity dingshi is port(clk,ten,tstop:in std_logic; ims:in
21、std_logic_vector(3 downto 0); iss:in std_logic_vector(3 downto 0); img:in std_logic_vector(3 downto 0); isg:in std_logic_vector(3 downto 0); cin:out std_logic; omg, osg:buffer std_logic_vector(3 downto 0); oms:buffer std_logic_vector(3 downto 0); oss:buffer std_logic_vector(3 downto 0) ); end; archi
22、tecture cml of dingshi isbegin PROCESS(clk, ten, tstop) BEGIN IF ten=1 THEN IF tstop=1 THEN osg0000 OR omg0000 OR oms0000 THEN osg=1001; ELSE osg=0000; END IF; ELSE osg=osg-1; END IF; END IF; END IF; END PROCESS; PROCESS(clk, ten, tstop, osg) BEGIN IF ten=1 THEN IF tstop=1 THEN oss0000 OR oms0000 TH
23、EN oss=0101; ELSE oss=0000; END IF; ELSE oss=oss-1; END IF; END IF; END IF; END IF; END PROCESS; PROCESS(clk, ten, tstop, osg, oss) BEGIN IF ten=1 THEN IF tstop=1 THEN omg0 THEN omg=1001; ELSE omg=0000; END IF; ELSE omg=omg-1; END IF; END IF; END IF; END IF; END PROCESS; PROCESS(clk, ten, tstop, osg
24、, oss, omg) BEGIN IF ten=1 THEN IF tstop=1 THEN oms=ims; ELSIF clkEVENT AND clk=1 THEN IF omg=0 and osg=0 and oss=0 THEN IF oms=0 THEN oms=0000; ELSE oms=oms-1; END IF; END IF; END IF; END IF; END PROCESS; PROCESS(clk, ten, tstop, osg, oss, omg, oms) BEGIN IF ten=1 THEN IF tstop=0 THEN IF clkEVENT A
25、ND clk=1 THEN IF oms=0 AND omg=0 AND oss=0 AND osg=1 THEN cin=1; ELSE cin=0; END IF; END IF; END IF; END IF; END PROCESS; END cml; 3.时间设置:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity key ISport( kin: in std_logic; ken: in std_logic; ims,iss,img,isg: buffer std_logi
26、c_vector(3 downto 0); end key;ARCHITECTURE cml OF key ISBEGIN PROCESS(kin, ken) BEGIN IF ken=1 THEN IF kinEVENT AND kin=1 THEN IF isg=1001 THEN isg=0000; ELSE isg=isg+1; END IF; END IF; END IF; END PROCESS; PROCESS(kin, ken, isg) BEGIN IF ken=1 THEN IF kinEVENT AND kin=1 THEN IF isg=9 THEN IF iss=01
27、01 THEN iss=0000; ELSE iss=iss+1; END IF; END IF; END IF; END IF; END PROCESS; PROCESS(kin, ken, isg, iss) BEGIN IF ken=1 THEN IF kinEVENT AND kin=1 THEN IF iss=0101 AND isg=1001 THEN IF img=1001 THEN img=0000; ELSE img=img+1; END IF; END IF; END IF; END IF; END PROCESS; PROCESS(kin, ken, isg, iss,
28、img) BEGIN IF ken=1 THEN IF kinEVENT AND kin=1 THEN IF img=1001 AND iss=0101 AND isg=1001 THEN IF ims=0010 THEN ims=0000; ELSE ims=ims+1; END IF; END IF; END IF; END IF; END PROCESS; END cml;4.模式设置:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity mode isport(kin :in st
29、d_logic;ken :in std_logic;modeset:buffer std_logic_vector(2 downto 0);LED:OUT STD_LOGIC_VECTOR(2 DOWNTO 0);end mode;architecture cml of mode issignal a: std_logic_vector(2 downto 0);signal k: std_logic;beginprocess(kin,ken) beginif ken=1 then if rising_edge(kin) then if a=100 thena=000;elsea=a+1;end
30、 if;end if;end if;end process;modesetLEDLEDLEDLED=000; end case ; end process;end cml;5.二路选择器:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity mulsel isport(ims:in std_logic_vector(3 downto 0);iss:in std_logic_vector(3 downto 0);img:in std_logic_vector(3 downto 0);isg:
31、in std_logic_vector(3 downto 0);oms:in std_logic_vector(3 downto 0);oss:in std_logic_vector(3 downto 0);omg:in std_logic_vector(3 downto 0);osg:in std_logic_vector(3 downto 0);msdis:out std_logic_vector(3 downto 0);mgdis:out std_logic_vector(3 downto 0);isdis:out std_logic_vector(3 downto 0);igdis:o
32、ut std_logic_vector(3 downto 0);modedis:out std_logic_vector(2 downto 0);modeset:in std_logic_vector(2 downto 0);modeout:in std_logic_vector(2 downto 0);sel:in std_logic);end mulsel;architecture cml of mulsel isbeginprocess(sel,ims,iss,isg,oms,isg,oss,omg,osg) begin if sel=1 thenmsdis=oms;mgdis=omg;isdis=oss;igdis=osg;mode