Four-bit counter

Source: Internet
Author: User

1 Synchronous Reset

Asynchronous reset refers to the reset is not controlled by the clock, but other operations are still related to CLK; synchronous reset means reset signal and clock synchronization.

24-bit counter circuit running flowchart

1) Counter Verilog code

' Timescale 1ns/1ns
Module COUNT4 (OUT,RESET,CLK);
Input RESET,CLK;
Output[3:0] out;
Reg[3:0] out;

Always @ (Posedge CLK)
Begin
if (reset)
out<=0; Synchronous reset
Else
Out<=out+1 ' B1; Count
End
Endmodule

2) testbench test file

' Timescale 1 NS/1 NS
Module COUNT4_VLG_TST ();
/*make a reset that pulses once.*/
Reg Reset=0;
Initial
Begin
#2 reset = 1; Reset
#3 reset = 0; Start Count
#24 reset = 1; Reset
#2 reset = 0; Start Count
#48 reset = 1; Reset
#1 reset = 0; Start Count
#60 reset = 1; Reset
#3 reset = 0; Start Count
#100 $stop;
End
/*make a regular pulsing closk*/
Parameter clk_period = 4;
Reg CLK;
Initial
CLK = 0;
Always # (CLK_PERIOD/2)
CLK = ~CLK;
Wire[3:0] out;
Count4 i1 (. CLK (CLK),. Out),. reset (reset);

Endmodule

Four-bit counter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.