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

从F到0 - From F to 0

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

Quartus Verilog HDL/FPGA 实现用3个LED演示二进制累加 (带复位按键,低电平点亮)

[复制链接]
发表于 2022-1-21 21:56:01 | 显示全部楼层 |阅读模式
main.png
  1. module main(
  2.         input clk,                        //50Mhz 时钟输入 Pin17
  3.         input rst,                        //复位 Pin144 (低电平按下)
  4.         output led1,                //LED Pin3 (低电平点亮)
  5.         output led2,                //LED Pin7
  6.         output led3                        //LED Pin9
  7. );

  8. reg [31:0] tmp = 0;
  9. reg [2:0] tmp2 = 0;
  10. assign led1 = !tmp2[0];
  11. assign led2 = !tmp2[1];
  12. assign led3 = !tmp2[2];
  13. always @(posedge clk) begin                //CLK上升沿触发
  14.         if(!rst) begin
  15.                 tmp = 0;
  16.                 tmp2 = 0;
  17.         end else begin
  18.         tmp = tmp + 1;                //计数加1
  19.                 if (tmp == 25000000) begin                //2500万个CLK上升沿 (半秒)
  20.                         tmp = 0;
  21.                         tmp2 = tmp2 + 1;
  22.                 end
  23.         end
  24. end
  25. endmodule
复制代码

相关帖子

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

本版积分规则

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

腾讯云安全认证

GMT+8, 2024-4-27 12:19 , Processed in 0.969055 second(s), 22 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

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