当前位置: 首页 > news >正文

verilog HDLBits刷题[Counters]“Exams/ece241 ”---Counter 1000

一、题目

From a 1000 Hz clock, derive a 1 Hz signal, calledOneHertz, that could be used to drive an Enable signal for a set of hour/minute/second counters to create a digital wall clock. Since we want the clock to count once per second, theOneHertzsignal must be asserted for exactly one cycle each second. Build the frequency divider using modulo-10 (BCD) counters and as few other gates as possible. Also output the enable signals from each of the BCD counters you use (c_enable[0] for the fastest counter, c_enable[2] for the slowest).

The following BCD counter is provided for you.Enablemust be high for the counter to run.Resetis synchronous and set high to force the counter to zero. All counters in your circuit must directly use the same 1000 Hz signal.

module bcdcount ( input clk, input reset, input enable, output reg [3:0] Q );

Module Declaration

module top_module ( input clk, input reset, output OneHertz, output [2:0] c_enable );

二、分析

子模块为10进制BCD码计数,每个计数器从0计数到9.将1000Hz分频为1Hz,可以使用三个计数器,分别计数个位,十位,百位,个位计满了十位开始计数,十位也计满了后百位开始计数。每个计数器的使能,表示该计数器开启计数。

三、代码实现

module top_module ( input clk, input reset, output OneHertz, output [2:0] c_enable ); // wire [3:0] q0,q1,q2; assign c_enable={q1==4'd9&&q0==4'd9,q0==4'd9,1'b1}; assign OneHertz = {q2 == 4'd9 && q1 == 4'd9 && q0 == 4'd9}; bcdcount counter0 (clk, reset, c_enable[0],q0); bcdcount counter1 (clk, reset, c_enable[1],q1); bcdcount counter2 (clk, reset, c_enable[2],q2); endmodule 或者 module top_module ( input clk, input reset, output OneHertz, output [2:0] c_enable ); // wire [3:0]cnt0,cnt1,cnt2;//分别是个位,十位,百位的计算器 bcdcount counter0 (clk, reset, c_enable[0],cnt0); bcdcount counter1 (clk, reset, c_enable[1],cnt1); bcdcount counter2 (clk, reset, c_enable[2],cnt2); assign c_enable[0]=1'b1;//个位的计算器一直在运行 assign c_enable[1]=(cnt0==4'd9)&c_enable[0];//个位计满并且还在计数时十位的计数器开始运行 assign c_enable[2]=(cnt0==4'd9&cnt1==4'd9)&c_enable[1];//个位数计满、十位计满并且还在计数时,百位的计数器开始运行 assign OneHertz=(cnt0==4'd9&cnt1==4'd9&cnt2==4'd9);//个十百位都计满9,即999,则为1Hz endmodule

四、时序

http://www.cnnetsun.cn/news/3607377.html

相关文章:

  • 法律AI智能体架构设计与性能调优实战
  • ping和traceroute
  • 软考全科目学习资料完全免费分享
  • Cortex-M4 FPU硬件浮点单元:原理、配置与嵌入式实时系统优化实践
  • TM4C129XNCZAD实战:PWM、QEI与ADC模块协同构建高精度电机控制系统
  • 电池电量计核心术语解析:从SOC到Qmax,构建精准电池管理知识体系
  • Agentic自主进化机制:合成数据与强化学习的实践
  • 【Springboot毕设全套源码+文档】基于springboot电脑商城系统的设计与实现(丰富项目+远程调试+讲解+定制)
  • Windows转发Linux系统的X11(二):By MobaXterm
  • 电子合同ROI深度解析:制造业年省142万,三年累计节省410万
  • 【Rust自学】14.3. 使用pub use导出方便使用的API
  • INT4 通俗完整讲解
  • 多智能体协作系统架构设计:从理论到框架选型实战
  • Dify工作流版本迁移灾难复盘:一次升级导致服务中断47分钟,我们用这4个自动化回滚方案止损
  • 嘎嘎降AI和率零哪个更适合本科论文:2026年本科论文降AI工具实测深度对比
  • 同一户型,7种AI引擎输出对比:实测Diffusion vs LDM vs 3DGS在软装纹理还原度上的13.8%关键差距
  • 律师整理拜访客户笔录难?2026年5款录音转文字工具帮你快速成文
  • 《AI 渐进编程》之二十一:Agent 不光要交代码,还要交证据包
  • 深入解析C2000 ePWM死区与故障保护机制,构建可靠电力电子系统
  • 当一个小白拿到了香橙派 AIpro
  • AI 写完了代码,你却还在发呆?用 Claude Code Hooks 给 AI 装上“下班铃“
  • 【PyTorch】with torch.no_grad() 详解
  • 如何基于小型工控机与openwrt打造家用软路由
  • 麒麟信安登录央视, 深度展现为中国信息安全铸“魂”之路
  • 【模拟IC学习笔记】 PSS和Pnoise仿真
  • PairLIE论文阅读笔记
  • AI生成音乐版权雷区全扫描,律师+音频工程师双视角解析:93%创作者不知的4类侵权高发场景
  • Qt 定时器放在线程中执行,支持随时开始和停止定时器。
  • AI模型优化与多模态学习实战指南
  • 动态住宅代理使用指南:粘性会话 vs. 每次请求轮换 IP,如何选择?