Multiplexers
Combinational 4:1 MUX (3-Bit Datapath)
Combinational 4:1 mux with four 3-bit inputs and a 2-bit select.
About this block
Simulate it in the Verilog IDE
Combinational 4:1 MUX (3-Bit Datapath) 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.
A fully synthesizable, latch-free 4-to-1 multiplexer with 3-bit data inputs and 2-bit select lines.
This IP core implements a 4-to-1 multiplexer designed for high reliability and ease of synthesis. It supports 3-bit wide data paths controlled by a 2-bit selector signal. The design uses a case statement with a default case to ensure no latches are inferred, making it suitable for both FPGA and ASIC flows. It has been verified against all 16 select combinations and dynamic input change scenarios.
- Choose Open in IDE. RTL Studio loads the packaged workspace for Combinational 4:1 MUX (3-Bit Datapath).
- Read the Verilog module in the editor. The catalog line for this block: Combinational 4:1 mux with four 3-bit inputs and a 2-bit select.
- 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
- Data Width: 3 bits
- Select Width: 2 bits
- Logic Type: Fully combinational, latch-free
- Language: Verilog-2001
- Verification: Self-checking testbench included
Ports
| Port Name | Direction | Width | Description |
|---|---|---|---|
d0 | Input | 3 | Data input 0 |
d1 | Input | 3 | Data input 1 |
d2 | Input | 3 | Data input 2 |
d3 | Input | 3 | Data input 3 |
sel | Input | 2 | Select lines |
y | Output | 3 | Multiplexed output |
Architecture
The module uses a combinational always @(*) block with a case statement. A default case is provided to assign 0 to the output register if an undefined select value occurs, preventing latch inference.
Verification
The included testbench (tb_mux_4to1.v) performs the following checks:
- Static Selection: Verifies output matches the selected input for all 16 combinations of
sel. - Dynamic Changes: Verifies correct output when data inputs change while
selremains constant. - Self-Checking: Counts errors and displays pass/fail status for each test case.
All test cases are designed to pass successfully under normal operating conditions.
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 (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 1-Bit 2:1 MUX (Packed din[1:0])
- Registered 16:1 MUX (32-Bit Datapath, Active-Low Enable)
- Registered 8-Bit 2:1 MUX with Enable