Clock Generators
Integer Clock Divider
Parameterized integer clock divider with 50% duty cycle supporting even divisors from 2 to 255.
About this block
Simulate it in the Verilog IDE
Integer Clock Divider is a Verilog reference block in the Clock Generators catalog. Clock dividers, gating, and clock distribution helpers. Marked Easy: a small block you can read, simulate, and synthesize in one sitting.
A parameterized Verilog module implementing an integer clock divider with a strict 50% duty cycle. It supports divide-by-N ratios where N is an even integer between 2 and 255.
This module generates a divided clock signal from a main input clock. It uses a toggle flip-flop architecture driven by a counter to ensure symmetric high and low periods (50% duty cycle). It is designed for even divisors only. The module includes synchronous enable control and active-low asynchronous reset.
- Choose Open in IDE. RTL Studio loads the packaged workspace for Integer Clock Divider.
- Read the Verilog module in the editor. The catalog line for this block: Parameterized integer clock divider with 50% duty cycle supporting even divisors from 2 to 255.
- Run the packaged testbench with the in-browser Verilator simulator, then open the VCD in the waveform viewer.
- Run Yosys in the same IDE for a generic netlist. Sky130 liberty mapping is a separate Pro library option.
RTL Studio is the Verilog simulator and IDE around this block: Slang lint, Verilator, VCD waveforms, and Yosys, in the browser. Simulation guide · Yosys guide.
Features
- Parameterizable: Set division ratio via
DIVISORparameter (2 to 255, even numbers only). - 50% Duty Cycle: Guaranteed symmetric output for even divisors.
- Synchronous Enable:
ensignal allows clock gating. - Asynchronous Reset:
rst_ninitializes the counter and output. - Minimal Area: Simple toggle flip-flop design.
Interface
| Port | Direction | Width | Description |
|---|---|---|---|
clk | Input | 1 | Main clock input |
rst_n | Input | 1 | Active-low asynchronous reset |
en | Input | 1 | Synchronous enable signal |
clk_out | Output | 1 | Divided clock output |
Architecture
The design counts from 0 to DIVISOR - 1 on each active clock edge. When the counter reaches the maximum value, it resets to zero, and the output toggle flip-flop inverts its state. This results in an output period of DIVISOR * CLK_PERIOD.
Verification
The testbench (tb/tb_clock_divider_int.v) validates:
- Different divisors produce different frequencies.
- Reset initializes outputs to zero.
- Simulation completes without errors.
### Running Tests
More in Clock Generators
- 1-Cycle Data Delay
- 16-Bit DDS Phase Accumulator — L2 Upgrade
- 2:1 Clock Divider (Toggle Flip-Flop)
- 4-Phase Clock-Enable Sequencer — L1 Upgrade — L2 Upgrade
- Burst Enable for N Cycles — L1 Upgrade — L2 Upgrade
- CE Pulse Every N Cycles
- Clock Enable with Soft-Reset Stretch — L2 Upgrade
- Clock-Enable Divider (CE Pulse) — L1 Upgrade — L2 Upgrade
- Clock-Enable Stretcher N — L1 Upgrade — L2 Upgrade
- Divide-by-3 Clock (50% Duty)
- Dual-Edge DDR Sampler — L2 Upgrade
- Duty-Correct Divide-by-2 — L1 Upgrade — L2 Upgrade
- Fractional Clock Divider with Jitter Control
- Fractional Clock Enable M/N — L2 Upgrade
- Glitch-Free Clock Select 2 — L2 Upgrade
- Lost-Clock Detector — L2 Upgrade