Exams/ece241 2014 q7b

该文描述了如何使用模10BCD计数器和门电路从1000Hz时钟生成1Hz的OneHertz信号,这个信号用于驱动小时/分钟/秒计数器,创建一个每秒计数一次的数字挂钟。电路包括三个级联的计数器,每个计数器的使能信号由前一级的计数状态决定,最终当三个计数器均达到最大值时,输出OneHertz信号。

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.

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

从 1000 Hz 时钟中,导出一个 1 Hz 信号,称为 OneHertz,可用于驱动一组小时/分钟/秒计数器的使能信号以创建数字挂钟。由于我们希望时钟每秒计数一次,因此必须每秒正好对OneHertz信号进行一个周期的置位。使用模 10 (BCD) 计数器和尽可能少的其他门构建分频器。同时从您使用的每个 BCD 计数器输出使能信号(最快的计数器c_enable[0],最慢的计数器c_enable[2])。

为您提供了以下 BCD 计数器。启用必须为高电平,计数器才能运行。复位是同步的,并设置为高以强制计数器为零。电路中的所有计数器必须直接使用相同的 1000 Hz 信号。

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

module top_module (
    input clk,
    input reset,
    output OneHertz,
    output [2:0] c_enable
); //
    wire [3:0] q1, q2, q3;
    always@ (*)
        if(reset) begin
            c_enable <= 3'b0;
            OneHertz <= 1'b0;
        end
    	else begin
            c_enable[0] <= 1'b1;
            c_enable[1] <= (q1 == 4'd9) ? 1'b1 : 1'b0;
            c_enable[2] <= ((q1 == 4'd9) && (q2 == 4'd9)) ? 1'b1 : 1'b0;
            OneHertz <= ((q1 == 4'd9) && (q2 == 4'd9) && (q3 == 4'd9)) ? 1'b1 : 1'b0;
        end
            
    
    bcdcount counter0 (
        .clk(clk), 
        .reset(reset), 
        .enable(1'b1), 
        .Q(q1)
    );
   bcdcount counter1 (
        .clk(clk), 
        .reset(reset), 
       .enable( c_enable[1]), 
       .Q(q2)
    );
    bcdcount counter2 (
        .clk(clk), 
        .reset(reset), 
        .enable(c_enable[2]), 
        .Q(q3)
    );

endmodule

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

eachanm

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

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

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

打赏作者

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

抵扣说明:

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

余额充值