题解 | 状态机与时钟分频

状态机与时钟分频

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

`timescale 1ns/1ns

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

//*************code***********//
reg [2:0] cnt4;
reg [2:0] cnt4_N;

always@(*)
begin
	if(cnt4 == 3'd3)
		cnt4_N = 3'd0;
	else
		cnt4_N = cnt4 +3'd1;
end 

always@(posedge clk or negedge rst)
begin
	if(!rst)
		cnt4 <= 3'd0;
	else
		cnt4 <= cnt4_N;
end

always@(*)
begin
	if(cnt4 == 3'd1)
		clk_out = 1'd1;
	else
		clk_out = 1'd0;		
end

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

全部评论

相关推荐

迷茫的大四🐶:只有花了钱才能吃一堑长一智
点赞 评论 收藏
分享
牛客41077653...:想问一下华为池子是不是很大呀
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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