数字逻辑课程设计报告 姓 名: 学 号: 选课号: 103 班 号: A 201 设计题目 全自动洗衣机的设计 设计要求 设计全自动洗衣机控制器,为不同的洗衣阶段设置不同的时间。(洗衣阶段和时间自己定义) 设计过程 设计方案: 全自动洗衣机有9 个工作状态:空闲(idle),第一次加水(water1),洗涤(wash),第一次排水(drain1),第二次加水(water2),漂洗(rinse ),第二次排水(drein2),甩干(dry),响起音乐(music)。 状态转移条件有以下2 个:开始(start),复位(reset)。 状态转移图: 注:方框内上方为状态机的状态,下方为状态机的输出。 当按下reset 键时,洗衣机复位到初始状态,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; output [3:0]count; reg[3: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(count==4) //the time of water is 5s begin count<=1'd0; w<=0;m<=1;d<=0;mu<=0; state<=wash; end else begin count<=count+1; end wash: if(count==9) //the time of wash is 10s begin count<=1'd0; 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<=1'd0; w <=1;m<=0;d<=0;;mu<=0; state<=w ater2; end else begin count<=count+1; end w ater2: if(count==4) //the time of w ater is 5s begin count<=1'd0; w <=0;m<=1;d<=0;mu<=0; state<=rinse; end else begin count<=count+1; end rin...