Clock Generators
Duty-Correct Divide-by-2 — L1 Upgrade — L2 Upgrade
Duty-correct divide-by-N using M/N ratio with enable and registered output.
About this block
Simulate it in the Verilog IDE
Duty-Correct Divide-by-2 — L1 Upgrade — L2 Upgrade is a Verilog reference block in the Clock Generators catalog. Clock dividers, gating, and clock distribution helpers. Marked Medium: more state or a wider datapath, still one workspace in the IDE.
This IP implements a configurable frequency divider with precise duty cycle control. It uses two independent counters to define the division ratio (M) and the high-time duration (N), ensuring a duty cycle of N/M.
Key features include:
- Configurable Division Ratio: Supports division ratios from 1 to 15.
- Precise Duty Cycle: Adjustable high-time from 1 to M cycles.
- Registered Output: Glitch-free output staging.
- Dynamic Control: Supports dynamic enable/disable.
The core logic utilizes two independent 4-bit counters:
- M Counter: Defines the total period length (1-15 cycles).
- N Counter: Defines the high-time duration (1-M cycles).
m(Period Divisor): Range 1-15n(High-Time Divisor): Range 1 tom- Critical:
nmust always be less than or equal tom.
- Choose Open in IDE. RTL Studio loads the packaged workspace for Duty-Correct Divide-by-2 — L1 Upgrade — L2 Upgrade.
- Read the Verilog module in the editor. The catalog line for this block: Duty-correct divide-by-N using M/N ratio with enable and registered output.
- 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.
Ports
| Port | Direction | Width | Description |
|---|---|---|---|
clk | Input | 1 | Clock input |
rst_n | Input | 1 | Active-low asynchronous reset |
en | Input | 1 | Enable signal (active high) |
m | Input | [3:0] | Period divisor (M). Range: 1-15 |
n | Input | [3:0] | High-time divisor (N). Range: 1-M |
clk_out | Output | 1 | Divided clock output |
busy | Output | 1 | Active high when en is asserted |
Architecture
The internal architecture consists of:
- Counter Logic: Two synchronous counters (
cnt_mandcnt_n) that increment on each clock cycle when enabled. - Duty Cycle Logic: Combinational logic comparing
cnt_mwithnto determine the output state. - Output Registration: Registered output (
out_reg) to ensure clean clock transitions.
Verification
The provided testbench (tb_duty_correct_div2_enable_registered_enable_div_used_mn.v) covers:
- Reset Behavior: Verifies
clk_outandbusyare low after reset. - Enable/Disable: Checks state transitions when enabling and disabling the divider.
- Duty Cycle Accuracy: Validates output waveforms for various M/N combinations.
### Running Simulation
To run the simulation:
- Open your preferred Verilog simulator (e.g., ModelSim, VCS, Xcelium).
- Compile the RTL and testbench files.
- Run the simulation.
### Expected Results
TC1 PASS: Reset checkTC2 PASS: Enable M=4 N=2TC3 PASS: Disable checkTC4 PASS: Enable M=8 N=2TC5 PASS: Enable M=2 N=2INFO: PASS
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
- Fractional Clock Divider with Jitter Control
- Fractional Clock Enable M/N — L2 Upgrade
- Glitch-Free Clock Select 2 — L2 Upgrade
- Integer Clock Divider
- Lost-Clock Detector — L2 Upgrade