设为首页收藏本站淘宝杂货铺

从F到0 - From F to 0

 找回密码
 注册已关闭
搜索
查看: 111|回复: 0
收起左侧

Quartus Verilog HDL/FPGA 实现 CD4026/74HC4026 7段共阴数码管显示的10进制计数器

[复制链接]
发表于 2023-11-22 10:05:43 | 显示全部楼层 |阅读模式
main.png
  1. module cd4026(        //7段共阴数码管显示的10进制计数器 VCC:Pin16 GND:Pin8
  2.         input CLK,        //计数时钟(上升沿触发) Pin1
  3.         input INH,        //低电平使能CLK信号 高电平禁止 Pin2
  4.         input DEI,        //高电平打开显示 低电平关闭 (不影响计数) Pin3
  5.         input MR,        //异步上升沿计数清零 Pin15
  6.         //静态共阴数码管段码A~G
  7.         output A,        //Pin10
  8.         output B,        //Pin12
  9.         output C,        //Pin13
  10.         output D,        //Pin9
  11.         output E,        //Pin11
  12.         output F,        //Pin6
  13.         output G,        //Pin7
  14.        
  15.         output CO,        //计数为9输出低电平,否则高电平 接下片的CLK Pin5
  16.         output DEO,        //DEO直通DEI 接下一片的DEI Pin4
  17.         output UCS        //计数为2输出低电平 否则高电平 Pin14
  18. );
  19. reg [3:0] count = 4'd0;        //计数寄存器 范围:0~9

  20. function [6:0] display;        //10进制7段共阴数码管段码查询
  21.         input [3:0] dec;                //[4位宽]10进制数字 范围:0~9
  22.         begin
  23.         case(dec)
  24.                 4'd0:display = 7'h3F;
  25.                 4'd1:display = 7'h06;
  26.                 4'd2:display = 7'h5B;
  27.                 4'd3:display = 7'h4F;
  28.                 4'd4:display = 7'h66;
  29.                 4'd5:display = 7'h6D;
  30.                 4'd6:display = 7'h7D;
  31.                 4'd7:display = 7'h07;
  32.                 4'd8:display = 7'h7F;
  33.                 4'd9:display = 7'h6F;
  34.                 default:display = 7'h00;
  35.         endcase
  36.         end
  37. endfunction

  38. assign {G,F,E,D,C,B,A} = DEI ? display(count) : 7'd0;
  39. assign CO = (count != 4'd9);
  40. assign DEO = DEI;
  41. assign UCS = (count != 4'd2);

  42. always @(posedge CLK or posedge MR) begin
  43.         if(MR) begin
  44.                 count <= 4'd0;
  45.         end else if(CLK && !INH) begin
  46.                 if(count >= 4'd9) begin
  47.                         count <= 4'd0;
  48.                 end else begin
  49.                         count <= count + 4'd1;
  50.                 end
  51.         end
  52. end
  53. endmodule

  54. module main(
  55.         input CLK,
  56.         input INH,
  57.         input DEI,
  58.         input MR,
  59.         output A,
  60.         output B,
  61.         output C,
  62.         output D,
  63.         output E,
  64.         output F,
  65.         output G,
  66.         output CO,
  67.         output DEO,
  68.         output UCS
  69. );

  70. cd4026 U1(
  71.         .CLK(CLK),
  72.         .INH(INH),
  73.         .DEI(DEI),
  74.         .MR(MR),
  75.         .A(A),
  76.         .B(B),
  77.         .C(C),
  78.         .D(D),
  79.         .E(E),
  80.         .F(F),
  81.         .G(G),
  82.         .CO(CO),
  83.         .DEO(DEO),
  84.         .UCS(UCS)
  85. );
  86. endmodule
复制代码

相关帖子

您需要登录后才可以回帖 登录 | 注册已关闭

本版积分规则

QQ|手机版|Archiver|从F到0 ( 蒙ICP备17002595号-1 )
蒙公网安备15010402000325号

腾讯云安全认证

GMT+8, 2024-4-27 17:18 , Processed in 1.908109 second(s), 22 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表