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

占空比50%的奇数分频

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

`timescale 1ns/1ns

module odo_div_or
   (
    input    wire  rst ,
    input    wire  clk_in,
    output   wire  clk_out7
    );

//*************code***********//
reg [2:0] cnt;
always @(posedge clk_in or negedge rst or negedge clk_in) begin
    if(!rst) begin
        cnt <= 0;
    end
    else if (cnt >= 6) begin
        cnt <= 0;
    end
    else begin
        cnt <= cnt + 1'b1;
    end
end

reg clk_out7_reg;
always @(posedge clk_in or negedge rst or negedge clk_in) begin
    if(!rst) begin
        clk_out7_reg <= 0;
    end
    else if (cnt >= 6) begin
        clk_out7_reg <= ~clk_out7_reg;
    end
    else begin
        clk_out7_reg <= clk_out7_reg;
    end
end
assign clk_out7 = clk_out7_reg;
//*************code***********//
endmodule

全部评论

相关推荐

后来123321:别着急,我学院本大二,投了1100份,两个面试,其中一个还是我去线下招聘会投的简历,有时候这东西也得看运气
点赞 评论 收藏
分享
05-30 12:03
山西大学 C++
offer来了我跪着接:不是骗子,等到测评那一步就知道为啥这么高工资了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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