题解 | #简易秒表#

简易秒表

http://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@(negedge rst_n or posedge clk)begin
        if(~rst_n)
            second <= 0;
        else if(minute==60)
            second <= 0;
        else
            second <= second==60? 1: second+1;
    end
    
    always@(negedge rst_n or posedge clk)begin
        if(~rst_n)
            minute <= 0;
        else minute <= second==60? minute+1: minute;
    end
    
	
	
endmodule
全部评论

相关推荐

07-03 16:13
嘉应学院 Python
xiaolihuam...:很明显骗子,如果是hr直接约你面试了,哪用得着内推,如果是员工的话,你得多优秀,一线员工直接加你微信,
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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