Auto_sale.v
module auto_sale(
input clk,
input asy_rst,
input [1:0]i_dat,
output reg o_money,
output reg o_goods
);
parameter S0=2'b00;
parameter S1=2'b01;
parameter S2=2'b10;
reg [1:0] curr_s;
reg [1:0] next_s;
always @(posedge clk or posedge asy_rst)
begin
if(asy_rst)
curr_s <= S0;
else
curr_s <= next_s;
end
always @(*)
begin
next_s = 'dx;
case(curr_s)
S0: if(i_dat == 2'b00) next_s = S0;
else if(i_dat == 2'b01) next_s = S1;
else if(i_dat == 2'b10) next_s = S2;
else next_s = S0;
S1: if(i_dat == 2'b00) next_s = S1;
else if(i_dat == 2'b01) next_s = S2;
else if(i_dat == 2'b10) next_s = S0;
else next_s = S1;
S2: if(i_dat == 2'b00) next_s = S2;
else if(i_dat == 2'b01) next_s = S0;
else if(i_dat == 2'b10) next_s = S0;
else next_s = S2;
default: next_s = S0;
endcase
end
评论0
最新资源