module cliff_classic (
output logic ds,
output logic rd,
input logic clk,
input logic go,
input logic rst_n,
input logic ws
);
enum logic [2:0] {
IDLE = 3'b000,
DLY = 3'b010,
DONE = 3'b001,
READ = 3'b110,
XXX = 'x
} state, nextstate;
always_comb begin
nextstate = XXX;
case (state)
IDLE: begin
if (go) begin
nextstate = READ;
end
else begin
nextstate = IDLE;
end
end
DLY : begin
if (ws) begin
nextstate = READ;
end
else begin
nextstate = DONE;
end
end
DONE: begin
begin
nextstate = IDLE;
end
end
READ: begin
begin
nextstate = DLY;
end
end
endcase
end
assign ds = state[0];
assign rd = state[1];
always_ff @(posedge clk or negedge rst_n) begin
if (!rst_n)
state <= IDLE;
else
state <= nextstate;
end
endmodule