时序电路实验 一、实验设计与程序 module shop(Y,AB,R,Z,reset,clk); input reset,clk; //定义变量reset和时钟 input [1:0]AB; //投币金额 output Y,R,Z; //状态,出货标志,退币标志 reg [2:0]Y; reg R,Z; always @(posedge clk) //在上升沿有效 begin if(reset==0) //使用reset初始化 begin Y<=0; //初始化置成零 R<=0; Z<=0; end else //对Y进行当前状态判定并给出下一状态 begin case(Y