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

被折叠的 条评论
为什么被折叠?



