题解 | 时钟分频(偶数)

时钟分频(偶数)

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

`timescale 1ns/1ns

module even_div
    (
    input     wire rst ,
    input     wire clk_in,
    output    reg clk_out2,
    output    reg clk_out4,
    output    reg clk_out8
    );
//2分频
always@(posedge clk_in or negedge rst)begin
    if(!rst)begin
        clk_out2 <= 1'b0;
    end
    else begin
        clk_out2 <= ~clk_out2;
    end
end
//4分频
always@(posedge clk_out2 or negedge rst)begin
    if(!rst)begin
        clk_out4 <= 1'b0;
    end
    else begin
        clk_out4 <= ~clk_out4;
    end
end
//8分频
always@(posedge clk_out4 or negedge rst)begin
    if(!rst)begin
        clk_out8 <= 1'b0;
    end
    else begin
        clk_out8 <= ~clk_out8;
    end
end
endmodule

全部评论

相关推荐

有气魄的马来熊在摸鱼:我爱vivo 马上换手机 vivo我爱你!!!
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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