0 votes
in Verilog by (200 points)

How do you implement a counter in Verilog?

2 Answers

0 votes
by (220 points)

A counter in Verilog is a combination of an adder and a register.

Example :

reg [ 5:0 ] counter ;

always @ ( posedge clock )
begin
counter <= counter + 1 ;
end
0 votes
by (220 points)

reg [DATA_WITH-1:0] counter = {(DATA_WIDTH){1'b0}};
always @(posedge clk) begin
if (rst) counter <= {(DATA_WIDTH){1'b0}};
else counter <= counter + 1;
end
Hardware Coder Community

© 2022 by Hardware Coder. User contributions are licensed under cc by-sa 4.0 with attribution required. Attribution means a link to the question, answer, user, etc on this site.

This site is owned and operated by Hardware Coder in McKinney, Texas.

Send Us A Message
About Us

By using this site, you agree to the following:

Privacy Policy
Terms and Conditions
DMCA Policy
Earnings Disclaimer
Legal Disclaimer

...