(9)Exams/ece241 2014 q7b

1.1 目录

(1)目录

(2)题目要求

(3)原理

(4)代码

1.2 题目要求

From a 1000 Hz clock, derive a 1 Hz signal, called OneHertz, 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, the OneHertz signal 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. Enable must be high for the counter to run. Reset is synchronous and set high to force the counter to zero. All counters in your circuit must directly use the same 1000 Hz signal.

翻译:就是题目中给你一个1000hz的时钟,然后让你生成一个1hz的时钟(1hz时钟的名字就是OneHertz),题目中给了一个bcd计数器这个计数器,你要驱动这个给的bcd计数器去生成一个1hz的计数器。时钟为1000hz就是一个周期1ms,1hz代表一个周期1s,所以我们只需要计数1000个时钟周期就可以生成周期为1s的OneHertz信号。

“c_enable[0]用于最快的计数器,c_enable[2]用于最慢的计数器”这句话的意思c_enable[0]负责1000个数的个位计数,c_enable[1]负责1000个数的十位计数,c_enable[2]负责1000个数的百位计数

module bcdcount (
	input clk,//就是1000hz的时钟
	input reset,
	input enable,//使能信号,为高电平时才进行计数
	output reg [3:0] Q//Q就是bcd计数器当前的计数值
);

1.3 原理

我们使用3个bcd计数器分别计数1000个数(0-999)的个位,十位,百位就可以了.当个位,十位,百位为3个9时就代表计数1000次,这时使OneHertz变为高电平就可以生成1hz的信号。

1.4 代码

module top_module (
    input clk,//1000hz的时钟
    input reset,
    output OneHertz,
    output [2:0] c_enable
); //
    wire [3:0]Q1,Q2,Q3;//Q1,Q2,Q3分别代表个位,十位,百位的计数器输出
    always@(*)
        if(reset)begin
            c_enable<=0;
            OneHertz<=0;end
    	else
            begin
                c_enable[0]<=1;
                c_enable[1]<=(Q1==9&&c_enable[0])? 1:0;//0~9是十个数,因此十位计数器只有当个位为9的时候才开始运行一次
                c_enable[2]<=(Q2==9&&c_enable[1])? 1:0;//因此百位计数器只有当十位为9的时候才开始运行一次
                OneHertz<=(Q1==9&&Q2==9&&Q3==9)?1:0;//当为999时,其实已经有0~999一共1000个数字了,此时为1s。 
            //1000HZ就是代表clk的周期为1ms。
            end
    bcdcount counter0 (clk, reset, c_enable[0],Q1);
    bcdcount counter1 (clk, reset, c_enable[1],Q2);
    bcdcount counter2 (clk, reset, c_enable[2],Q3);

endmodule

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一只准备起飞的小菜鸟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值