Multiplexers
Registered 1-Bit 2:1 MUX (Packed din[1:0])
Registered 2:1 mux with packed 2-bit din bus, active-high enable, and active-low reset.
About this block
Simulate it in the Verilog IDE
Registered 1-Bit 2:1 MUX (Packed din[1:0]) is a Verilog reference block in the Multiplexers catalog. Multiplexers, demultiplexers, and data-path selectors. Marked Easy: a small block you can read, simulate, and synthesize in one sitting.
The mux_2to1 module is a registered 2-to-1 multiplexer featuring an active-high enable signal and an asynchronous active-low reset. It selects between two data inputs (din[0] or din[1]) based on the sel signal. The selection is only active when en is high; otherwise, the output is forced to zero. The output is registered on the positive edge of the clock, ensuring clean timing analysis and suitability for clock domain crossing applications.
### Key Features
- Registered Output: Output changes only on the positive edge of
clk, simplifying timing closure. - Asynchronous Reset:
rst_nforcesdoutto 0 immediately when low. - Active-High Enable:
enallows for power gating or conditional data flow control. - Simple Interface: Minimal port count for easy integration.
This IP provides a robust, registered 2-to-1 multiplexer with an active-high enable signal and an asynchronous active-low reset. The output is registered on the positive edge of the clock, ensuring clean timing analysis and suitability for clock domain crossing applications. The module is fully verified via a self-checking testbench covering all functional states including reset behavior, enable gating, and data selection.
- Choose Open in IDE. RTL Studio loads the packaged workspace for Registered 1-Bit 2:1 MUX (Packed din[1:0]).
- Read the Verilog module in the editor. The catalog line for this block: Registered 2:1 mux with packed 2-bit din bus, active-high enable, and active-low reset.
- 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 Name | Direction | Width | Description |
|---|---|---|---|
clk | Input | 1 | Clock input (positive edge triggered) |
rst_n | Input | 1 | Asynchronous active-low reset |
din | Input | 2 | Data inputs [1:0] |
sel | Input | 1 | Select signal (0 selects din[0], 1 selects din[1]) |
en | Input | 1 | Enable signal (active high) |
dout | Output | 1 | Multiplexed output |
Integration
### Instantiation
To integrate this module into your design, use the following Verilog template:
### File Structure
Verification
The provided testbench (tb_mux_2to1.v) is a self-checking testbench that verifies:
- Reset Behavior: Output is zero immediately after reset deassertion.
- Enable Control: Output is zero when enable is low, regardless of inputs.
- Data Selection: Output correctly follows
din[sel]when enable is high.
### Running Simulation
- Ensure you have a Verilog simulator installed (e.g., Icarus Verilog, ModelSim, or Vivado).
- Compile the design and testbench:
- Run the simulation:
- Check the log output for the following pass messages:
* TC1 PASS - Reset check passed * TC2 PASS - Enable low check passed * TC3-TC8 PASS - Data selection checks passed * INFO: PASS
A VCD file (sim/dump.vcd) is generated for waveform debugging.
More in Multiplexers
- 4:1 Priority Mux (One-Hot Select) — L1 Upgrade
- Combinational 16:1 MUX (32-Bit Datapath)
- Combinational 32-Bit 2:1 MUX
- Combinational 4:1 MUX (3-Bit Datapath)
- Combinational 4:1 MUX (8-Bit Datapath, Enable)
- Combinational 8:1 MUX (32-Bit Datapath, Enable)
- Glitch-Free 2:1 Clock Mux
- One-Hot Select Mux 8:1 — L1 Upgrade
- Registered 16:1 MUX (32-Bit Datapath, Active-Low Enable)
- Registered 8-Bit 2:1 MUX with Enable