题解 | #简易秒表#
简易秒表
https://www.nowcoder.com/practice/6493ca8c7b67499f918e1fa33b4cdeda
需要一个标志位,控制分钟60之后,秒表不增加
`timescale 1ns/1ns module count_module( input clk, input rst_n, output reg [5:0]second, output reg [5:0]minute ); reg flag; always @(posedge clk or negedge rst_n) begin if(!rst_n) begin minute <= 6'd0; second <= 6'd0; flag <= 1'd0; end else if (second == 6'd60) begin minute <= minute + 1'd1; second <= 6'd1; flag <= flag; end else if (minute == 6'd60) begin second <= 6'd0; flag <= 1'd1; end else if(!flag) begin second <= second + 6'd1; minute <= minute; end end endmodule