Divide by Two Clock Generator
The simplest clock divider is one flip-flop whose inverted output feeds its own input. It toggles on every edge, giving half the frequency at a 50% duty cycle.
The divider uses a single flip-flop that feeds its inverted output back into its own input. This ensures the output state alternates cleanly on every clock cycle without requiring external counters.
- Clock edge:
posedge clk_in - Reset type: Asynchronous
- Reset polarity: Active-low (
rst_n) - Output value on reset:
clk_outmust be0 - Priority rules: Asynchronous reset takes highest priority over clock edges
Cycle 1: rst_n=0 → clk_out=0
Cycle 2: rst_n=1, clk_in rises → clk_out=1
Cycle 3: rst_n=1, clk_in rises → clk_out=0
Cycle 4: rst_n=1, clk_in rises → clk_out=1
| Signal | Direction | Width | Description |
|---|---|---|---|
clk_in |
input | 1 | Positive-edge triggered source clock |
rst_n |
input | 1 | Asynchronous active-low reset; drives clk_out to 0 |
clk_out |
output | 1 | Divided clock output |
Constraints
- Clock edge must be
posedge clk_in. - Reset must be asynchronous and active-low.
clk_outmust be exactly0on reset.clk_outmust be a registered output directly driven by a flip-flop.- No combinational logic is permitted on the output clock path to avoid glitches.
Topics
Solve this problem
Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against the problem's testbench. You get the waveform back, not a stored answer.
This problem is part of Codiode Pro. The statement above is free to read.
The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.
Part of Clock Domain Crossing and Synchronization
Problem 5 of 36 in the Clock Domain Crossing and Synchronization track.
Related problems
Browse all problems · Verilog practice problems · Learning tracks