`timescale 1ns/100ps module johnson_counter (clk, aclr, ena, johnson_code); parameter Width = 4; input clk, aclr, ena; output [Width-1:0] johnson_code; reg [Width-1:0] johnson_code; integer i,j; always @(posedge clk or negedge aclr) if (aclr==1'b0) begin johnson_code <= 0; end else begin if (ena==1'b1) begin johnson_code <= {johnson_code[Width-2:0],!(johnson_code[Width-1])}; end //enabled end //sequential update endmodule