Build a decade counter that counts from 0 through 9, inclusive, with a period of 10. The reset input is synchronous, and should reset the counter to 0.

module top_module (
input clk,
input reset, // Synchronous active-high reset
output [3:0] q);
always @ (posedge clk)
if(reset)
q <= 4'd0;
else if (q ==4'd9)
q <= 4'd0;
else
q <= q + 1'd1;
endmodule
该模块描述了一个4位计数器,它从0计数到9,当达到9时重置回0。输入包括时钟信号clk和同步复位信号reset。在时钟上升沿,如果复位为高,则计数值重置为0;若计数到达9,下个周期也会重置为0;否则,计数加1。
2287

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



