全自动洗衣机的设计 Verilog程序(精品资料).doc

上传人:仙人指路1688 文档编号:4144482 上传时间:2023-04-07 格式:DOC 页数:7 大小:122KB
返回 下载 相关 举报
全自动洗衣机的设计 Verilog程序(精品资料).doc_第1页
第1页 / 共7页
全自动洗衣机的设计 Verilog程序(精品资料).doc_第2页
第2页 / 共7页
全自动洗衣机的设计 Verilog程序(精品资料).doc_第3页
第3页 / 共7页
全自动洗衣机的设计 Verilog程序(精品资料).doc_第4页
第4页 / 共7页
全自动洗衣机的设计 Verilog程序(精品资料).doc_第5页
第5页 / 共7页
点击查看更多>>
资源描述

《全自动洗衣机的设计 Verilog程序(精品资料).doc》由会员分享,可在线阅读,更多相关《全自动洗衣机的设计 Verilog程序(精品资料).doc(7页珍藏版)》请在三一办公上搜索。

1、数字逻辑课程设计报告姓 名: 学 号: 选课号: 103 班 号: A201 设计题目全自动洗衣机的设计设计要求设计全自动洗衣机控制器,为不同的洗衣阶段设置不同的时间。(洗衣阶段和时间自己定义)设计过程 设计方案:全自动洗衣机有9个工作状态:空闲(idle),第一次加水(water1),洗涤(wash),第一次排水(drain1),第二次加水(water2),漂洗(rinse),第二次排水(drein2),甩干(dry),响起音乐(music)。状态转移条件有以下2个:开始(start),复位(reset)。状态转移图: 注:方框内上方为状态机的状态,下方为状态机的输出。当按下reset键时,

2、洗衣机复位到初始状态,m=0,w=0,d=0,mu=0。当按下start按钮时,则进入water1状态,w=1,加水,历时5s。然后转移到下一个状态-洗涤,停止加水w=0,电机运转m=1,历时10s。再转移到下一个状态排水,电机停止运转m=0,开始排水d=1,历时5s直到甩干结束后,整个洗衣过程完成。然后洗衣机放出音乐,历时7s,提示用户洗衣完成。洗衣机回到初始状态。整个过程经历45s。源程序:module wash_machine(count,clk,reset,start,w,m,d,mu,state);input clk,reset,start;output w,m,d,mu,state

3、;output 3:0count;reg3:0 count;parameter idle=0,water1=1,wash=2,drain1=3,water2=4,rinse=5,drain2=6,dry=7,music=8;reg w,m,d,mu;reg 3:0 state;always (posedge clk) begin if(reset) begin w=0;m=0;d=0;mu=0; state=idle; end case(state) idle: if(start) begin w=1;m=0;d=0;mu=0; state=water1; end water1: if(cou

4、nt=4) /the time of water is 5s begin count=1d0; w=0;m=1;d=0;mu=0; state=wash; end else begin count=count+1; endwash: if(count=9) /the time of wash is 10s begin count=1d0; w=0;m=0;d=1;mu=0; state=drain1; end else begin count=count+1; end drain1: if(count=4) /the time of drain is 5s begin count=1d0; w

5、=1;m=0;d=0;mu=0; state=water2; end else begin count=count+1; end water2: if(count=4) /the time of water is 5s begin count=1d0; w=0;m=1;d=0;mu=0; state=rinse; end else begin count=count+1; end rinse: if(count=5) /the time of rinse is 6s begin count=1d0; w=0;m=0;d=1;mu=0; state=drain2; end else begin

6、count=count+1; end drain2: if(count=4) /the time of drain is 5s begin count=0; w=0;m=1;d=1;mu=0; state=dry; end else begin count=count+1; end dry: if(count=2) /the time of dry is 3s begin count=1d0; w=0;m=0;d=0;mu=1; state=music; end else begin count=count+1; end music: if(count=6) /the time of musi

7、c is 7s begin count=1d0; state=idle; w=0;m=0;d=0;mu=0; end else begin count=count+1; end endcase endendmodule仿真结果:设计结论设计结果分析: 按下reset键,洗衣机复位;按下start键,开始洗衣,直到洗衣完成。设计中遇到的问题:1、 每个状态无法持续,来了一个时钟就进入下一个状态了,没有判断我写的条件:例如:原来在water1的条件下,我写的是:water1: if(count(timewater-1) begin count=count+1; end else begin cou

8、nt=1d0; w=0;m=1;d=0;mu=0; state=wash;end结果就是下图所示:(错误的仿真结果)后来改成了: water1: if(count=4) begin count=1d0; w=0;m=1;d=0;mu=0; state=wash; end else begin count=count+1;end 原因是:if不是循环,只要条件满足就执行下去,不会再判断条件仍旧满足而再执行if里面的语句。设计心得: 1、学习并基本掌握了verilog HDL的写法,并会用verilog HDL语言设计有限状态机。会写计数器,并且在历经设计好的一段时间后跳到下一状态。2、实现经过一段时间后状态的跳转:在每个时钟上升沿到来时(always clk),先判断时间条件是否成立,成立的话就进入下一个状态,如果时间没有到的话,时间就加1,在下一个始终上升沿到来时再先判断,没到的话再加1,如此重复。3、这是写的第一个verilog程序,还是很有成就感!附:放大的仿真图:

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 办公文档 > 其他范文


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号