题解 | #占空比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;
reg        out7_1,out7_2;
always @(posedge clk_in or negedge rst) begin
    if(!rst)            cnt<=0;
    else if(cnt==3'd6)  cnt<=0;
    else                cnt<=cnt+1'b1;
end

always @(posedge clk_in or negedge rst) begin
    if(!rst)                        out7_1<=0;
    else if(cnt==3'd3||cnt==3'd6)   out7_1<=~out7_1;
end

always @(negedge clk_in or negedge rst) begin
    if(!rst)                        out7_2<=0;
    else if(cnt==3'd3||cnt==3'd6)   out7_2<=~out7_2;
end

assign clk_out7 = out7_1|out7_2;
//*************code***********//
endmodule
全部评论

相关推荐

10-28 17:30
已编辑
华东交通大学 Java
iori2333:这太正常了 我字节面了四五轮 没有一次是在官网投递 都是hr主动捞
秋招笔试记录
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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