Johnson Counter
题目描述
请用Verilog实现4位约翰逊计数器(扭环形计数器),计数器的循环状态如下。
电路的接口如下图所示。
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/b6461ef14c30ec59fad06648638bb1e0.png)
`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