题解 | #时钟分频(偶数)#

时钟分频(偶数)

https://www.nowcoder.com/practice/49a7277c203a4ddd956fa385e687a72e

`timescale 1ns/1ns

module even_div
    (
    input     wire rst ,
    input     wire clk_in,
    output    wire clk_out2,
    output    wire clk_out4,
    output    wire clk_out8
    );
//*************code***********//
////////////cnt///////////////
reg [3:0]cnt;
always@(posedge clk_in or negedge rst)begin
    if(!rst)
    cnt <= 'd0;
    else if(cnt == 8)
    cnt <= 4'd1;
    else
    cnt <= cnt+1;
end
assign clk_out2=(cnt==1||cnt==3||cnt==5||cnt==7)?1:0;
assign clk_out4=(cnt==1||cnt==2||cnt==5||cnt==6)?1:0;
assign clk_out8=(cnt==1||cnt==2||cnt==3||cnt==4)?1:0;

//*************code***********//
endmodule

全部评论

相关推荐

黑皮白袜臭脚体育生:春节刚过就开卷吗?哈基馆,你这家伙......
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务