完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
补充内容 (2017-11-26 22:05): 计数器模块: module jishuqi(clk_1khz,reset,pause,MSL,MSH,SL,SH,ML,MH); input clk_1khz,reset,pause; reg clk_100hz_r; reg [2:0]cnt_clk; output reg[3:0]MSL; output reg[3:0]MSH; output reg[3:0]SL; output reg[3:0]SH; output reg[3:0]ML; output reg[3:0]MH; reg cnt_ms;//MSÏòS½øλ reg cnt_s;//SÏòM½øλ always@(posedge clk_1khz or negedge reset) begin if(!reset) begin cnt_clk<=1'b1; clk_100hz_r<=1'b0; end else begin if(cnt_clk==3'd5) begin cnt_clk<=1'b1; clk_100hz_r<=~clk_100hz_r; end else cnt_clk<=cnt_clk+1'b1; end end always@(posedge clk_100hz_r or negedge reset) begin if(!reset) begin MSL<=4'd0; MSH<=4'd0; cnt_ms<=1'b0; end else begin if(!pause) begin if(MSL==9) begin MSL<=4'd0; if(MSH==9) begin MSH<=4'd0; cnt_ms<=1'b1; end else begin MSH<=MSH+1'b1; cnt_ms<=1'b0; end end else begin MSL<=MSL+1'b1; cnt_ms<=1'b0; end end end end always@(posedge cnt_ms or negedge reset) begin if(!reset) begin SL<=4'd0; SH<=4'd0; cnt_s<=1'b0; end else begin if(!pause) begin if(SL==9) begin SL<=4'd0; if(SH==5) begin cnt_s<=1'b1; SH<=4'd0; end else begin cnt_s<=1'b0; SH<=SH+1'b1; end end else begin SL<=SL+1'b1; cnt_s<=1'b0; end end end end always@(posedge cnt_s or negedge reset) begin if(!reset) begin ML<=4'd0; MH<=4'd0; end else begin if(!pause) begin if(ML==9) begin ML<=4'd0; if(MH==5) begin MH<=4'd0; end else MH<=MH+1'b1; end else begin ML<=ML+1'b1; end end end end endmodule ........................................................... 数码管扫描模块: module segscan(clk_1khz,reset,MSL,MSH,SL,SH,ML,MH,sel,data,dp); input clk_1khz,reset; input [3:0]MH; input [3:0]ML; input [3:0]SL; input [3:0]SH; input [3:0]MSL; input [3:0]MSH; output reg [3:0]data;//????????????? output reg [5:0]sel;//???? output reg dp; reg [2:0]cnt; always@(posedge clk_1khz or negedge reset) begin if(!reset) cnt<=3'd1; else begin if(cnt==3'd6) cnt<=3'd1; else cnt<=cnt+1'b1; end end always@(posedge clk_1khz or negedge reset) begin if(!reset) sel<=6'b111111; else begin case(cnt) 3'b001:sel<=6'b111110; 3'b010:sel<=6'b111101; 3'b011:sel<=6'b111011; 3'b100:sel<=6'b110111; 3'b101:sel<=6'b101111; 3'b110:sel<=6'b011111; default:sel<=6'b111111; endcase end end always@(posedge clk_1khz) begin case(sel) 6'b111110:begin dp<=1'b1;end 6'b111101:begin dp<=1'b1;end 6'b111011:begin dp<=1'b0;end 6'b110111:begin dp<=1'b1;end 6'b101111:begin dp<=1'b1;end 6'b011111:begin dp<=1'b1;end default:begin dp<=1'b1;end endcase end always@(posedge clk_1khz) begin if(!reset) data<=4'b0; else begin case(cnt) 3'b110:begin data<=MH;end 3'b101:begin data<=ML;end 3'b100:begin data<=SH;end 3'b011:begin data<=SL;end 3'b010:begin data<=MSH;end 3'b001:begin data<=MSL;end default:begin data<=4'd0;end endcase end end endmodule ............................................................................. 段选模块: module decode4_7(clk_1khz,reset,data,decout); input clk_1khz,reset; input [3:0]data; output reg [6:0]decout; always@(negedge clk_1khz or negedge reset) begin if(!reset) decout<=7'b1000000; else begin case(data) 4'd0:decout<=1000000; 4'd1:decout<=1111001; 4'd2:decout<=0100100; 4'd3:decout<=0110000; 4'd4:decout<=0011001; 4'd5:decout<=0010010; 4'd6:decout<=0000010; 4'd7:decout<=1111000; 4'd8:decout<=0000000; 4'd9:decout<=0010000; default:decout<=7'b1000000; endcase end end endmodule ............................................................ 顶层: module shuzipaobiao_top (clk_in,rst,sw_onoff,sel,decout,dp); input clk_in,rst,sw_onoff; output wire[6:0]decout;//7λ¶ÎÑ¡ÊýÂë¹Ü output wire[5:0]sel;//λѡ output wire dp; wire [3:0]data; wire [3:0]MSL;wire [3:0]MSH;wire [3:0]SL;wire [3:0]SH;wire [3:0]ML;wire [3:0]MH; paobiao_fenpin fp(.clk_in(clk_in),.rst(rst),.clk_1khz(clk_1khz)); xiaodou xiao(.clk_1khz(clk_1khz),.rst(rst),.sw_onoff(sw_onoff),.reset(reset),.on_off(on_off)); jishuqi jishu(.clk_1khz(clk_1khz),.reset(reset),.pause(pause),.MSL(MSL),.MSH(MSH),.SL(SL),.SH(SH),.ML(ML),.MH(MH)); control_cnt cntrol(.clk_1khz(clk_1khz),.reset(reset),.on_off(on_off),.pause(pause)); segscan scan_tb(.clk_1khz(clk_1khz),.reset(reset),.MSL(MSL),.MSH(MSH),.SL(SL),.SH(SH),.ML(ML),.MH(MH),.sel(sel),.dp(dp),.data(data)); decode4_7 decode(.clk_1khz(clk_1khz),.reset(reset),.data(data),.decout(decout)); endmodule |
|
相关推荐
4个回答
|
|
话说你到底要看什么,显示不对吗,那你每次点亮一段,找出每段对应的引脚就行了
|
|
|
|
你这发的什么玩意
|
|
|
|
已经调好了,是译码不对,decout<=7'b......., 把位宽写上就行了
|
|
|
|
显示不对,现在已经弄好了。译码不对 |
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
1403 浏览 1 评论
助力AIoT应用:在米尔FPGA开发板上实现Tiny YOLO V4
1053 浏览 0 评论
2474 浏览 1 评论
2177 浏览 0 评论
矩阵4x4个按键,如何把识别结果按编号01-16(十进制)显示在两个七段数码管上?
2445 浏览 0 评论
1913 浏览 52 评论
6020 浏览 113 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-24 15:27 , Processed in 0.692735 second(s), Total 80, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号