题解 | #Johnson Counter#
Johnson Counter
https://www.nowcoder.com/practice/7ee6e9ed687c40c3981d7586a65bc22d
`timescale 1ns/1ns module JC_counter( input clk , input rst_n, output reg [3:0] Q ); always @(posedge clk or negedge rst_n) begin if (~rst_n) begin Q <= 4'b0; end else begin Q <= {~Q[0], Q[3:1]}; end end endmodule
下一状态的最高位等于当前状态最低位取反,下一状态的其余位等于当前状态的高一位。