题解 | #时钟切换#

时钟切换

http://www.nowcoder.com/practice/1de5e9bf749244cb8e5908626cc36d36

`timescale 1ns/1ns

module huawei6(
    input wire clk0  ,
    input wire clk1  ,
    input wire rst  ,
    input wire sel ,
    output reg clk_out
);
//*************code***********//
reg ff1,ff2;
    always@(negedge clk0 or negedge rst) begin
        if(!rst)
            ff1 <= 0;
        else
            ff1 <= ~ff2&sel;
    end
    always@(negedge clk1 or negedge rst) begin
        if(!rst)
            ff2 <= 0;
        else
            ff2 <= ~ff1&~sel;
    end
    always@(*) clk_out = ff2&clk0 | ff1&clk1;

//*************code***********//
endmodule
全部评论

相关推荐

03-04 07:14
门头沟学院 C++
黑皮白袜臭脚体育生:老板:都给工作机会了还想要工资,哪来这么多好事
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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