module seq_logic(
input wire clk, // 时钟输入
input wire rst, // 复位输入
input wire data_in, // 数据输入
output reg data_out // 数据输出
);
// 状态寄存器
reg [1:0] state;
always @(posedge clk) begin
if (rst) begin
state <= 2'b00; // 复位状态
end else begin
case (state)
2'b00: begin
if (data_in) begin
state <= 2'b01; // 状态转移
end
end
2'b01: begin
state <= 2'b10; // 状态转移
end
2'b10: begin
state <= 2'b00; // 状态转移
end
endcase
end
end
// 输出逻辑
always @(posedge clk) begin
case (state)
2'b00: begin
data_out <= 1'b0; // 输出逻辑
end
2'b01: begin
data_out <= 1'b1; // 输出逻辑
end
2'b10: begin
data_out <= 1'b0; // 输出逻辑
end
endcase
end
endmodule