题解 | #简易秒表#

简易秒表

https://www.nowcoder.com/practice/6493ca8c7b67499f918e1fa33b4cdeda

`timescale 1ns/1ns

module count_module(
	input clk,
	input rst_n,

    output reg [5:0]second,
    output reg [5:0]minute
	);
	
always @(posedge clk or negedge rst_n) begin
	if(!rst_n) begin
		second <= 6'b0;
	end
	else if(minute != 6'd60) begin
		second <= (second == 6'd60) ? 6'd1 : second + 1'b1;
	end
	else if(minute == 6'd60) begin
		second <= 6'd0;
	end
end

always @(posedge clk or negedge rst_n) begin
	if(!rst_n) begin
		minute <= 6'd0;
	end
	else if(second == 6'd60) begin
		minute <= minute + 1'b1;
	end
end
	
endmodule

全部评论

相关推荐

hso_:哈哈哈哈哈哈我没offer一样在同一道题开喷了
投递深圳同为数码等公司10个岗位
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
11-27 10:28
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务