题解 | #时钟切换#

时钟切换

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

`timescale 1ns/1ns

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

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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