三亩地 三亩地SAN MU DI · CODE DIARY
ARTICLE DETAIL

日记详情

真实记录编程学习的某一天,欢迎挑你感兴趣的翻一翻。

verilog HDLBits刷题[Building Larger Circuits]“Exams/review2015 count1k”---Counter with period 1000

verilog HDLBits刷题[Building Larger Circuits]“Exams/review2015 count1k”---Counter with period 1000

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
← 返回列表