ジョンソン・カウンタ

module JohnsonCounter4(CLK, RESET_N, QOUT);
  input CLK;
  input RESET_N;
  output [3:0] QOUT;

  reg [3:0] q;

  always @(posedge CLK or negedge RESET_N) begin
    if(RESET_N == 0)
      q <= 4'b0001;
    else
      q <= {q[2:0], ~q[3]};
  end

  QOUT <= q;
endmodule