always @(*) begin case(current_state) NONE:begin next_state = in ? ONE : NONE; end ONE:begin next_state = in ? TWO : NONE; end TWO:begin next_state = in ? THREE : NONE; end THREE:begin next_state = in ? FOUR : NONE; end FOUR:begin next_state = in ? FIVE : NONE; end FIVE:begin next_state = in ? SIX : DISC; end SIX:begin next_state = in ? ERROR : FLAG; end DISC:begin next_state = in ? ONE : NONE; end FLAG:begin next_state = in ? ONE : NONE; end ERROR:begin next_state = in ? ERROR : NONE; end endcase end
always @(posedge clk) begin if(reset)begin current_state <= NONE; end elsebegin current_state <= next_state; end end
always @(posedge clk) begin if(reset)begin disc <= 1'd0; flag <= 1'd0; err <= 1'd0; end elsebegin case(next_state) DISC:begin disc <= 1'd1; flag <= 1'd0; err <= 1'd0; end FLAG:begin disc <= 1'd0; flag <= 1'd1; err <= 1'd0; end ERROR:begin disc <= 1'd0; flag <= 1'd0; err <= 1'd1; end default:begin disc <= 1'd0; flag <= 1'd0; err <= 1'd0; end endcase end end
always @(*) begin case(current_state) NONE:begin next_state = in ? DATA : NONE; end DATA:begin case(counter) 3'd5: next_state = in ? DATA : DISC; 3'd6: next_state = in ? ERROR : FLAG; default:next_state = in ? DATA : NONE; endcase end DISC:begin next_state = in ? DATA : NONE; end FLAG:begin next_state = in ? DATA : NONE; end ERROR:begin next_state = in ? ERROR : NONE; end endcase end
always @(posedge clk) begin if(reset)begin current_state <= NONE; end elsebegin current_state <= next_state; end end
always @(posedge clk) begin if(reset)begin disc <= 1'd0; flag <= 1'd0; err <= 1'd0; counter <= 3'd0; end elsebegin case(next_state) DATA:begin disc <= 1'd0; flag <= 1'd0; err <= 1'd0; counter <= counter + 1'd1; end DISC:begin disc <= 1'd1; flag <= 1'd0; err <= 1'd0; counter <= 3'd0; end FLAG:begin disc <= 1'd0; flag <= 1'd1; err <= 1'd0; counter <= 3'd0; end ERROR:begin disc <= 1'd0; flag <= 1'd0; err <= 1'd1; counter <= 3'd0; end default:begin disc <= 1'd0; flag <= 1'd0; err <= 1'd0; counter <= 3'd0; end endcase end end