ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

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