Close Menu
VLSI Web
  • Home
    • About Us
    • Contact Us
    • Privacy Policy
  • Digital Design
    • Digital Circuits
    • Verilog
    • VHDL
    • System Verilog
    • UVM
  • VLSI Roles
    • RTL Design
    • Design Verification
    • Physical Design
    • DFT
    • STA
  • Interviews
  • Informative
  • VLSI Forge
Instagram LinkedIn WhatsApp Telegram
Instagram LinkedIn WhatsApp Telegram
VLSI Web
  • Home
    • About Us
    • Contact Us
    • Privacy Policy
  • Digital Design
    • Digital Circuits
    • Verilog
    • VHDL
    • System Verilog
    • UVM
  • VLSI Roles
    • RTL Design
    • Design Verification
    • Physical Design
    • DFT
    • STA
  • Interviews
  • Informative
  • VLSI Forge
VLSI Web
Digital Circuits

Counters and Clock Dividers in Verilog

Raju GorlaBy Raju Gorla2 September 2026Updated:11 October 2026No Comments3 Mins Read
Counters and clock dividers in Verilog
Share
Facebook Twitter LinkedIn Email Telegram WhatsApp

The short answer: a counter is a register that steps through a sequence of values on each clock edge: up, down, modulo-N, ring or Johnson. Each bit of a binary up counter toggles at half the rate of the one below it, so counters are also the basis of clock dividers. In real chips, though, it is usually better to generate a clock enable than a divided clock.

This post combines my older posts on counters and clock dividers.

  1. Counters as clock dividers
  2. Types of counters
  3. Verilog: a modulo-N counter
  4. Clock dividers, done safely
  5. Ripple vs synchronous counters

Table of Contents

  • Part 1: Counters as clock dividers
  • Part 2: Types of counters
  • Part 3: Verilog: a modulo-N counter
  • Part 4: Clock dividers, done safely
  • Part 5: Ripple vs synchronous counters
  • FAQ
    • How many flops does a modulo-10 counter need?
    • How do I make a divide-by-3 clock with 50% duty cycle?
    • What is a Johnson counter used for?
    • Why avoid ripple counters?

Part 1: Counters as clock dividers

A 3-bit up counter waveform showing divide-by-2, 4 and 8 outputs
Bit n of a binary counter divides the clock by 2^(n+1).

Part 2: Types of counters

Counter Sequence (4-bit) Notes
Binary up 0, 1, 2, … 15, 0 The default; adder plus register
Modulo-N 0 … N-1, 0 Compare and wrap, e.g. a BCD counter (N = 10)
Up/down Either direction Controlled by a direction input
Ring 0001, 0010, 0100, 1000 One-hot; N states with N flops
Johnson 0000, 0001, 0011, 0111, 1111, 1110, … 2N states with N flops
Gray One bit changes per step Used for pointers crossing clock domains

Part 3: Verilog: a modulo-N counter

module mod_n_counter #(parameter N = 10, W = 4) (
  input  wire         clk, rst_n, en,
  output reg  [W-1:0] count,
  output wire         wrap        // high on the last count
);
  assign wrap = en && (count == N-1);

  always @(posedge clk or negedge rst_n)
    if (!rst_n)    count <= {W{1'b0}};
    else if (wrap) count <= {W{1'b0}};
    else if (en)   count <= count + 1'b1;
endmodule

Part 4: Clock dividers, done safely

A divide-by-2 is just a flop that toggles every cycle. Odd divisions with a 50% duty cycle (divide-by-3, by-5) need logic on both clock edges. But generating new clocks from logic creates extra clock domains, skew and timing headaches.

My advice: in ASIC and FPGA RTL, prefer a clock enable. Keep everything on the original clock and use the counter’s wrap pulse as an enable for the slower logic. Real divided clocks should come from PLLs or dedicated clock-generation cells and be properly constrained.

Part 5: Ripple vs synchronous counters

A ripple (asynchronous) counter clocks each flop from the previous flop’s output. It is small, but each bit changes at a slightly different time, so the outputs glitch through invalid values. Synchronous counters, where every flop shares the same clock, are the standard in modern designs.

Practise this on VLSI Forge

I built VLSI Forge so you can write RTL in your browser, run it on a real simulator and check every signal in the waveform. Free, nothing to install.

Counter and sequential problems

FAQ

How many flops does a modulo-10 counter need?

Four, because 2^3 = 8 is too few and 2^4 = 16 is enough.

How do I make a divide-by-3 clock with 50% duty cycle?

Use a modulo-3 counter and combine flops clocked on the rising and falling edges. In most RTL, though, a clock enable is the better solution.

What is a Johnson counter used for?

Generating multi-phase timing signals; it gives 2N states from N flops and decodes easily.

Why avoid ripple counters?

Their outputs change at different times, causing glitches, and each stage adds a new clock domain for timing analysis.

Share. Facebook Twitter LinkedIn Email Telegram WhatsApp
Previous ArticleMealy vs Moore State Machines: Differences, Examples and Verilog
Next Article Registers and Shift Registers: SISO, SIPO, PISO and PIPO
Raju Gorla
  • Website

Related Posts

Digital Circuits

Registers and Shift Registers: SISO, SIPO, PISO and PIPO

3 September 2026
Digital Circuits

Mealy vs Moore State Machines: Differences, Examples and Verilog

1 September 2026
Digital Circuits

Synchronous vs Asynchronous Reset: Which to Use and Why

31 August 2026
Add A Comment
Leave A Reply Cancel Reply

Topics
  • Digital Circuits
  • Informative
  • Interview Questions
  • Physical Design
  • RTL Design
  • STA
  • System Verilog
  • UVM
  • Verilog
Instagram LinkedIn WhatsApp Telegram
  • About
  • Contact
  • Privacy Policy
  • VLSI Forge
  • Courses
  • Feedback
© 2026 VLSI Web

Type above and press Enter to search. Press Esc to cancel.