码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • [HDLBits] Countbcd


    Build a 4-digit BCD (binary-coded decimal) counter. Each decimal digit is encoded using 4 bits: q[3:0] is the ones digit, q[7:4] is the tens digit, etc. For digits [3:1], also output an enable signal indicating when each of the upper three digits should be incremented.

    You may want to instantiate or modify some one-digit decade counters.

    1. module top_module (
    2. input clk,
    3. input reset, // Synchronous active-high reset
    4. output [3:1] ena,
    5. output [15:0] q);
    6. wire ena0;
    7. always@(posedge clk) begin
    8. if(reset)
    9. ena0=1;
    10. end
    11. bcd1 counter1(clk,reset,ena0,q[3:0]);
    12. assign ena[1]=(q[3:0]==4'h9);
    13. bcd1 counter2(clk,reset,ena[1],q[7:4]);
    14. assign ena[2]=(q[7:0]==8'h99);//这里必须是8‘h99,因为是16进制的99才进位
    15. bcd1 counter3(clk,reset,ena[2],q[11:8]);
    16. assign ena[3]=(q[11:0]==12'h999);
    17. bcd1 counter4(clk,reset,ena[3],q[15:12]);
    18. endmodule
    19. module bcd1 (
    20. input clk,
    21. input reset, // Synchronous active-high reset
    22. input ena,//表示下一级传来的标志位,若标志位为1说明这一级该+1了
    23. output [3:0] q);
    24. always@(posedge clk) begin
    25. if(reset)
    26. q<=4'b0;
    27. else if(ena) begin
    28. if(q==9)
    29. q<=0;
    30. else
    31. q<=q+1;
    32. end
    33. else;
    34. end
    35. endmodule

  • 相关阅读:
    虚拟机双网卡设置(外网+内网)
    SpringBoot SpringBoot 原理篇 2 自定义starter 2.7 开启yml 提示功能
    Spring注解驱动之自定义组件中如何注入Spring底层的组件
    element el-input 二次封装
    Leetcode—515.在每个树行中找最大值【中等】
    【无标题】光伏逆变器的IEC62109测试,逆变器IEC62109测试项目
    数据库实验五:数据库编程
    你应该知道的 Python 自动化脚本
    安防行业商业供应链系统:加速企业数字化升级,助推供应链平台一体化协同发展
    砥砺的前行|基于labview的机器视觉图像处理(七)——图像双边处理自适应亮度
  • 原文地址:https://blog.csdn.net/m0_66480474/article/details/133151368
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号