题解 | #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  
);
reg [2:0]cnt;
always@(posedge clk or negedge rst_n)begin 
    if(!rst_n)
    cnt<=0;
    else if(cnt==7)
    cnt<=0;
    else 
    cnt<=cnt+1;
end
always@(posedge clk or negedge rst_n)begin 
    if(!rst_n)
     Q<=0;
     else if(cnt<=3)
     Q<={1'b1,Q[3:1]};
     else 
     Q<={1'b0,Q[3:1]};
end
endmodule

全部评论

相关推荐

那一天的Java_J...:他本来公司就是做这个的,不就是正常的游戏客户端和服务器开发,软硬件联动,有啥恶心不恶心的,提前告诉你就是怕你接受不了,接受不了就没必要再往后走流程浪费时间,虽然这公司是一坨。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务