文档详情

Verilog10进制计数器电路.doc

发布:2017-06-08约1.44千字共3页下载文档
文本预览下载声明
练习 设计一个10进制计数器电路,把10进制计数器的计数结果送到一位数码管显示,要求计数器的计数频率为1Hz。系统时钟为25MHz,要求系统同步复位,高电平有效。完成电路设计框图,各模块仿真以及系统功能仿真和下载编程。 分频器: module fenpin25(clk,rst,clk_1hz); input clk; input rst; output clk_1hz; reg clk_1hz; reg [23:0] cnt; always@(posedge clk or posedge rst) begin if(rst==1b1) cnt=24d0; else if(cnt=begin cnt=24d0; clk_1hz=~clk_1hz; end else cnt=cnt+1; end endmodule 十进制计数器: module cnt10(rst,clk,cnt); input rst,clk; output [3:0] cnt; reg [3:0] cnt; always@(posedge clk) begin if(rst==1b0) cnt=4b000; else if(cnt==4d9) cnt=4b000; else cnt=cnt+1; end endmodule 十进制计数器仿真波形图: LED译码器: module qiduan(cnt,led,scan); input [3:0] cnt; output [6:0] led; output [3:0] scan; reg [6:0] led; wire [3:0] scan; assign scan=4b0001; always@(cnt) begin case(cnt) 4b0001:led=7b0000110; 4b0010:led=7b1011011; 4b0011:led=7b1001111; 4b0100:led=7b1100110; 4b0101:led=7b1101101; 4b0110:led=7b1111100; 4b0111:led=7b0000111; 4b1000:led=7b1111111; 4b1001:led=7b1101111; 4b1010:led=7b1110111; default:led=7b0111111; endcase end endmodule LED译码器仿真波形图: 顶层电路Verilog HDL代码: module cnt10led(rst,clk,led,scan); input rst; input clk; output [6:0] led; output [3:0] scan; wire [3:0] cnt; wire [6:0] led; wire [3:0] scan; fenpin25 u0(.clk(clk),.rst(rst),.clk_1hz(clk_1hz)); cnt10 u1(.clk(clk_1hz),.rst(rst),.cnt(cnt)); qiduan u2(.cnt(cnt),.led(led),.scan(scan)); endmodule 框图:
显示全部
相似文档