题解 | #无占空比要去的奇数分频#

无占空比要去的奇数分频

https://www.nowcoder.com/practice/12d0615157a04e43bb7f41debc3cfa5b

//奇数分频3/5 占空比
`timescale 1ns/1ns

module odd_div (    
    input     wire rst ,
    input     wire clk_in,
    output    wire clk_out5
);
//*************code***********//
    reg [3:0]cnt;
    reg clk_out;

    always@(posedge clk_in  or negedge rst)
    begin
    if(!rst)begin
    cnt<=0;
    end
    else if(cnt==4)
    begin
    cnt<=0;
    end
    else begin
    cnt<=cnt+1;
    end
    end

    always@(posedge clk_in  or negedge rst)
    begin
    if(!rst)begin
    clk_out<=0;
    end
    else if(cnt==0|cnt==2)
    begin
    clk_out<=~clk_out;
    end
    else begin
    clk_out<=clk_out;
    end
    end

    assign clk_out5=clk_out;


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

全部评论

相关推荐

哞客37422655...:你猜为什么福利这么好还得一直追着你问
点赞 评论 收藏
分享
01-11 08:47
门头沟学院 Java
choumoduji...:读研的目的就是为了以最快的速度和最低的要求完成“学校”规定的毕业标准,而不是所谓课题组的要求
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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