一个比较简单的秒表计数器。
`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)
second <= 0;
else
second <= minute==60? 0:
second==60? 1:
second+1;
end
// 分
always@(posedge clk or negedge rst_n) begin
if(~rst_n)
minute <= 0;
else
minute <= minute==60? 60:
second==60? minute+1:
minute;
end
endmodule