1、题目
Build a counter that counts from 0 to 999, inclusive, with a period of 1000 cycles. The reset input is synchronous, and should reset the counter to 0.
2、代码
module top_module ( input clk, input reset, output [9:0] q); reg [9:0]cnt; always@(posedge clk)begin if(reset) cnt<=10'd0; else if(cnt==999) cnt<=10'd0; else cnt<=cnt+1; end assign q=cnt; endmodule