parameter IDLE = 3'h0;
parameter CS1 = 3'h1;
parameter CS2 = 3'h2;
reg [2:0] cs, ns;
reg cs_out1, cs_out2;
always @(posedge clk or negedge rstn) begin
if (~rstn) cs <= IDLE;
else cs <= ns;
end
always @(*) begin
ns = cs;
cs1_out = 1'b0;
cs2_out = 1'b0;
case (cs)
IDLE: if (start) ns = CS1;
CS1: begin
cs1_out = 1'b1;
if (cs1_move) ns = CS2;
end
CS2: begin
cs2_out = 1'b1;
if (cs2_move) ns = IDLE;
end
default: ns = IDLE;
endcase
end
状态机程序有很多,你在百度文库输入状态机,就有很多文章
不知道你的输入输出是什么,没法直接给你一个程序,你可以自己搜搜看看。