Assignment
Assignment
input clk,
input rst,
input cancel,
input coin1,
input coin2,
input select1,
input select2,
input select3,
);
reg [4:0]state,next_state;
reg [2:0]coincount;
parameter idle=5'b00000,s1=5'b00001,s2=5'b00010,s3=5'b00011,
s4=5'b00100,s5=5'b00101,s6=5'b00110,s7=5'b00111,
s8=5'b01000,s9=5'b01001,s10=5'b01010,s11=5'b01011,s12=5'b01100,s13=5'b01101,
s14=5'b01110,s15=5'b01111,s16=5'b10000,s17=5'b10001;
begin
state<=idle;
end
else
begin
state<=next_state;
end
end
always @(*)
begin
case(state)
idle:begin
coincount=0;
end
s1:begin
end
s2:begin
change<=2'b00; product<=1'b0;return<=2'b00;
if(coincount>3)
else if(cancel)
end
s3:begin
next_state<=s2;
end
s4:begin
next_state<=s2;
end
s5:begin
next_state<=s2;
end
s6:begin
change<=1'b0;product<=1'b0;
return<=coincount;
next_state<=idle;
end
s7:begin
change<=1'b0;product<=1'b0;return<=2'b00;
next_state<=s8;
end
s8:begin
change<=1'b0;product<=1'b0;return<=2'b00;
if(coincount>2)
else if(cancel)
end
s9:begin
change<=coincount-3;product<=1'b1;
next_state<=s8;
end
s10:begin
change<=1'b0; coincount=coincount+2; product<=1'b0;
next_state<=s8;
end
s11:begin
next_state<=s8;
end
s12:begin
next_state<=s13;
end
s13:begin
change<=1'b0; product<=1'b0;
if(coincount>4)
else if(cancel)
end
s14:begin
change<=coincount-5; product<=1'b1;
next_state<=s13;
end
s15:begin
next_state<=s13;
end
s16:begin
change<=1'b0;coincount<=coincount+2; product<=1'b0;
next_state<=s13;
end
endcase
end
endmodule