`timescale 1ns/1ns
module count_module(
input clk,
input rst_n,
output reg [5:0]second,
output reg [5:0]minute
);
//=========================================================================\\
//*****************************main code***********************************\\
//=========================================================================\\
always@(posedge clk or negedge rst_n)begin
if(!rst_n)
second <= 'd0 ;
else if(minute == 'd60)
second <= 'd0 ;
else if(second == 'd60)
second <= 'd1 ;
else
second <= second + 1'd1 ;
end
always@(posedge clk or negedge rst_n)begin
if(!rst_n)
minute <= 'd0 ;
else if(minute == 'd60)
minute <= 'd60 ;
else if(second == 'd60)
minute <= minute + 1'd1 ;
else
minute <= minute ;
end
endmodule
请编写一个模块,实现简易秒表的功能:具有两个输出,当输出端口second从1-60循环计数,每当second计数到60,输出端口minute加一,一直到minute=60,暂停计数。
虽然是1-60计数, 但是这里的时序 复位是从0开始

京公网安备 11010502036488号