题解 | #占空比50%的奇数分频#

占空比50%的奇数分频

https://www.nowcoder.com/practice/ccfba5e5785f4b3f9d7ac19ab13d6b31

`timescale 1ns/1ns


module odo_div_or
  #(parameter N = 7)
   (
    input    wire  rst ,
    input    wire  clk_in,
    output   wire  clk_out7
    );

    reg [2:0] cnt;
    always@(posedge clk_in or negedge rst)begin
        if(!rst)
            cnt <= 3'd0;
        else
            cnt <= (cnt == 3'd6) ? 3'd0 : cnt + 1'b1;
    end

    wire clk_tmp1 = cnt >= 3'd3;

    reg clk_tmp2;
    always@(negedge clk_in or negedge rst)begin
        if(!rst)
            clk_tmp2 <= 1'b0;
        else
            clk_tmp2 <= clk_tmp1;
    end

    assign clk_out7 = clk_tmp1 & clk_tmp2;

endmodule

思路:

全部评论

相关推荐

牛客76783384...:字节:不要放箭,活捉赵子龙
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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