RTL Studio Open IDE

Multiplexers

Glitch-Free 2:1 Clock Mux

A glitch-free 2:1 clock multiplexer that synchronizes selection signals to prevent output glitches during clock source switching.

About this block

Simulate it in the Verilog IDE

Mediumverilogsimsyn

Glitch-Free 2:1 Clock Mux is a Verilog reference block in the Multiplexers catalog. Multiplexers, demultiplexers, and data-path selectors. Marked Medium: more state or a wider datapath, still one workspace in the IDE.

This IP provides a glitch-free 2:1 clock multiplexer designed for seamless switching between two clock sources without generating output glitches. It is critical for clock domain crossing and maintaining low-power design integrity by preventing race conditions and metastability issues during clock source transitions.

  1. Choose Open in IDE. RTL Studio loads the packaged workspace for Glitch-Free 2:1 Clock Mux.
  2. Read the Verilog module in the editor. The catalog line for this block: A glitch-free 2:1 clock multiplexer that synchronizes selection signals to prevent output glitches during clock source switching.
  3. Run the packaged testbench with the in-browser Verilator simulator, then open the VCD in the waveform viewer.
  4. 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

  • Glitch-Free Operation: Ensures no glitches on clk_out during switching.
  • Dual Clock Support: Supports two independent clock inputs (clk_a, clk_b).
  • Synchronous Selection: Uses synchronous selection logic to avoid metastability.
  • Race Condition Prevention: Implements gating logic to prevent output glitches.
  • Verified: Verified with Icarus Verilog simulation.
  • Simple Interface: Minimal port list for easy integration.

Ports

Port NameDirectionWidthDescription
clk_aInput1Primary clock input
clk_bInput1Secondary clock input
selInput1Selection control signal (0 selects A, 1 selects B)
clk_outOutput1Muxed clock output

Architecture

The module synchronizes the selection signal to both clock domains independently. It uses registered selection values (sel_sync_a and sel_sync_b) to ensure stable gating. The output is generated using combinational logic on gated clocks, ensuring that the clock enable signals are stable before the clock edge occurs.

Verification

The testbench verifies correct selection behavior under various conditions:

  • Switching from clock A to B.
  • Switching from clock B to A.
  • Rapid switching scenarios.

### Running Simulation

  1. Ensure Icarus Verilog is installed.
  2. Run the simulation script (if provided) or execute:

### Expected Results

After running the simulation, the Log panel should show:

  • INFO: Starting TC1 - Select A
  • INFO: TC1 PASS - clk_out follows clk_a
  • INFO: Starting TC2 - Switch to B
  • INFO: TC2 PASS - clk_out follows clk_b
  • INFO: Starting TC3 - Switch to A
  • INFO: TC3 PASS - clk_out follows clk_a
  • INFO: Starting TC4 - Rapid Switch
  • INFO: TC4 PASS - Rapid switching completed
Test CaseDescriptionResult
TC1Select APASS
TC2Switch to BPASS
TC3Switch to APASS
TC4Rapid SwitchPASS

More in Multiplexers

All Multiplexers blocks