Johnson Counter
题目描述
请用Verilog实现4位约翰逊计数器(扭环形计数器),计数器的循环状态如下。
电路的接口如下图所示。

`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)
Q <= 'd0;
else
Q <= {~Q[0], Q[3:1]};
end
endmodule