题解 | #状态机与时钟分频#

状态机与时钟分频

https://www.nowcoder.com/practice/25d694a351b748d9808065beb6120025

`timescale 1ns/1ns

module huawei7(
	input wire clk  ,
	input wire rst  ,
	output reg clk_out
);

//*************code***********//
reg [1:0] cnt;
always@(posedge clk or negedge rst)
	if(!rst) cnt <= 2'b0;
	else if(cnt==2'b11) cnt <= 2'b0;
	else if(cnt!=2'b11) cnt <= cnt+1'b1;

always@(posedge clk or negedge rst)
	if(!rst) clk_out <= 1'b0;
	else if(cnt==2'b0) clk_out <= 1'b1;
	else clk_out<=1'b0;



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

全部评论

相关推荐

无感c:春招不是早就结束了吗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务