赞
踩
目录
请编写一个模块,实现简易秒表的功能:具有两个输出,当输出端口second从1-60循环计数,每当second计数到60,输出端口minute加一,一直到minute=60,暂停计数。
模块的接口信号图如下:
模块的时序图如下:
请使用Verilog HDL实现以上功能,并编写testbench验证模块的功能
clk:系统时钟信号
rst_n:异步复位信号,低电平有效
second:6比特位宽,秒表的秒读数
minute:6比特位宽,秒表的分读数
- `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)
- if (!rst_n)
- begin
- minute <= 6'd0;
- end
- else if (second == 6'd60)
- begin
- minute <= minute+1;
- end
- else
- begin
- minute <= minute;
- end
-
- always @(posedge clk or negedge rst_n)
- if (!rst_n)
- begin
- second <= 6'd0;
- end
- else if(second == 6'd60)
- begin
- second <= 6'd1;
- end
- else if (minute == 60)
- second <= 0;
- else
- second <= second+1'd1;
- endmodule
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。