// 4ビット・ジョンソン・カウンタ(同期リセット) module johnson_cnt( ck, res, q ); input ck, res; output [3:0] q; reg [3:0] q; always @( posedge ck ) begin if ( res ) q <= 4'h0; else begin q <= q << 1; q[0] <= ~q[3]; end end endmodule