题解 | #简易秒表#

简易秒表

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'd0;
        end 
        else begin
            if(second == 6'd60) // 从1 加到60 
                second <= 6'd1;
            else 
                second <= second + 1'b1;
                         
        end 
    end 

     always @(posedge clk or negedge rst_n)begin
         if(!rst_n)begin
            minute <= 6'd0;
        end 
        else begin
            if(minute == 6'd60) // 60分钟到了 
                minute <= 6'd1;
            else begin
                if(second == 6'd60)//一分钟到了
                    minute <= minute + 1'b1;
                else 
                    minute <= minute;       
            end                 
        end 
    end 
    
    
endmodule

全部评论

相关推荐

这不纯纯作弊了吗😢😢😢
编程界菜鸡:信这个的这辈子有了,这智商你靠啥都没用
你找工作的时候用AI吗?
点赞 评论 收藏
分享
程序员小白条:你是沟通了900个,不是投了900份简历,你能投900份,意味着对面都要回复你900次,你早就找到实习了,没亮点就是这样的,别局限地区,时间投的也要早,现在都要7月了
点赞 评论 收藏
分享
小叮当411:应该是1-3个月吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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