always @(*) begin case(current_state) S0: next_state = s ? S1 : S0; S1: next_state = S1; default:next_state = S0; endcase end
always @(posedge clk) begin if(reset)begin current_state <= S0; end elsebegin current_state <= next_state; end end
always @(posedge clk) begin if(reset)begin counter <= 2'd0; end elseif(counter == 2'd2) begin counter <= 2'd0; end elseif(current_state == S1) begin counter <= counter + 1'd1; end end
always @(posedge clk) begin if(reset) begin num_one <= 1'd0; end elsebegin if(counter == 2'd0)begin num_one <= w ? 1'd1 : 1'd0; end elseif(current_state == S1) begin num_one <= w ? (num_one+1'd1) : num_one; end end end
parameter A = 3'd0, B = 3'd1, C=3'd2; parameter D = 3'd3, E = 3'd4, F=3'd5; reg [2:0] current_state, next_state;
always @(*) begin case(current_state) A: next_state = w ? A : B; B: next_state = w ? D : C; C: next_state = w ? D : E; D: next_state = w ? A : F; E: next_state = w ? D : E; F: next_state = w ? D : C; default:next_state = A; endcase end
always @(posedge clk) begin if(reset)begin current_state <= A; end elsebegin current_state <= next_state; end end
assign z = (current_state == E | current_state == F);