完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
想让两个数码管0-F循环点亮,数码管点亮顺序是0-5-6-。。。-F-1-2-3,可能出问题在哪了,求指导`timescale 1ns / 1ps
module led_seg7_3( clk,rst_n, sm_cs1_n,sm_cs2_n, sm_db ); input clk; //时钟 50MHZ input rst_n; output sm_cs1_n,sm_cs2_n; output[6:0] sm_db;//7段数码管(不包括小数点) reg[24:0] cnt;//计数器,最大可以计数到2的25次方*20ns=640ms always @ (posedge clk or negedge rst_n) if(!rst_n) cnt <= 25`d0; else cnt <= cnt+1`b1; reg[3:0] num; //显示数值 always @ (posedge clk or negedge rst_n) if(!rst_n) num <= 4`d0; else if (cnt == 24`hfffff) num <= num+1`b1; //每640ms增一 //------------------------------------------------------------------------------- /* 共阴极 :不带小数点 ;0, 1, 2, 3, 4, 5, 6, 7, db 3fh,06h,5bh,4fh,66h,6dh,7dh,07h ;8, 9, a, b, c, d, e, f , 灭 db 7fh,6fh,77h,7ch,39h,5eh,79h,71h,00h*/ /* 共阳极 :不带小数点 ;0, 1, 2, 3, 4, 5, 6, 7, db c0h,f9h,a4h,b0h,99h,92h,82h,f8h ;8, 9, a, b, c, d, e, f , 灭 db 80h,90h,88h,83h,c6h,a1h,86h,8eh,ffh*/ parameter seg0 = 7'hc0, seg1 = 7'hf9, seg2 = 7'ha4, seg3 = 7'hb0, seg4 = 7'h99, seg5 = 7'h92, seg6 = 7'h82, seg7 = 7'hf8, seg8 = 7'h80, seg9 = 7'h90, sega = 7'h88, segb = 7'h83, segc = 7'hc6, segd = 7'ha1, sege = 7'h86, segf = 7'h8e; reg[6:0] sm_dbr; always @ (num) case (num) 4`h0: sm_dbr <= seg0; 4'h1: sm_dbr <= seg1; 4'h2: sm_dbr <= seg2; 4'h3: sm_dbr <= seg3; 4'h4: sm_dbr <= seg4; 4'h5: sm_dbr <= seg5; 4'h6: sm_dbr <= seg6; 4'h7: sm_dbr <= seg7; 4'h8: sm_dbr <= seg8; 4'h9: sm_dbr <= seg9; 4'ha: sm_dbr <= sega; 4'hb: sm_dbr <= segb; 4'hc: sm_dbr <= segc; 4'hd: sm_dbr <= segd; 4'he: sm_dbr <= sege; 4'hf: sm_dbr <= segf; default: ; endcase assign sm_db = sm_dbr; assign sm_cs1_n = 1'b0; //数码管1常开 assign sm_cs2_n = 1'b0; //数码管2常开 endmodule |
|
相关推荐
1个回答
|
|
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
1583 浏览 1 评论
助力AIoT应用:在米尔FPGA开发板上实现Tiny YOLO V4
1082 浏览 0 评论
2657 浏览 1 评论
2347 浏览 0 评论
矩阵4x4个按键,如何把识别结果按编号01-16(十进制)显示在两个七段数码管上?
2620 浏览 0 评论
2048 浏览 55 评论
6041 浏览 113 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-30 09:57 , Processed in 1.069392 second(s), Total 72, Slave 54 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号