Verilog Code for 1 to 4 Demultiplexer
Advertisement
This page provides the Verilog source code for a 1 to 4 DEMUX (Demultiplexer). We’ll also cover the block diagram and truth table to help you understand how it works.
Block Diagram of 1 to 4 DEMUX
Here’s the block diagram illustrating the basic structure of a 1 to 4 DEMUX:

Truth Table of 1 to 4 DEMUX
The truth table below defines the behavior of the 1 to 4 DEMUX based on the select inputs:

1 to 4 DEMUX Verilog Code
Here’s the Verilog code for a 1 to 4 Demultiplexer:
module demux1_4(a_in, sel, y_out);
input a_in;
input [1:0] sel;
output [3:0] y_out;
reg [3:0] y_out;
always @(a_in, sel)
begin
case (sel)
2'b00: begin
y_out[0]=a_in;
y_out[1]= 1'b0;
y_out[2]= 1'b0;
y_out[3]=1'b0;
end
2'b01: begin
y_out[0]= 1'b0;
y_out[1]=a_in;
y_out[2]= 1'b0;
y_out[3]=1'b0;
end
2'b10: begin
y_out[0]= 1'b0;
y_out[1]=1'b0;
y_out[2]=a_in;
y_out[3]=1'b0;
end
2'b11: begin
y_out[0]= 1'b0;
y_out[1]= 1'b0;
y_out[2]=1'b0;
y_out[3]=a_in;
end
default: y_out=3'b000;
endcase
end
endmodule
Explore Verilog Logic Gates, Mux & Encoders
- Verilog HDL Code for All Logic Gates
- 2-to-4 Decoder (Verilog HDL Code)
- 4-to-1 Multiplexer and 1-to-4 Demultiplexer (Verilog Code)
- Verilog Code: 1-to-4 Demultiplexer
- 8-to-1 Multiplexer (Verilog HDL Code)
- 8-to-3 Encoder Without Priority (Verilog)
- 8-to-3 Priority Encoder (Verilog)
- 8-to-3 Priority Encoder (Verilog Code)
- 1-Bit and 4-Bit Comparator Design (Verilog)
Explore Verilog Flip-Flops, Counters & Registers
- T, D, SR, JK Flip Flop (Verilog HDL Code)
- D Flip Flop Synchronous Reset (Verilog)
- D Flip Flop Without Reset (Verilog)
- Verilog Code for Binary Up-Down Counter
- Verilog HDL: BCD & Gray Counters
- 4-bit Down Counter (Verilog Code Test Bench)
- 4-bit Binary Asynchronous Reset Counter (Verilog)
- 4-bit Binary Synchronous Reset Counter (Verilog)
- 4-bit BCD Asynchronous Reset Counter (Verilog)
- 4-bit BCD Synchronous Reset Counter (Verilog Code)
- 4-bit Mod-13 Counter (Verilog Code Test Bench)
- Shift Left / Shift Right Register (Verilog)
- Parallel Load Shift Left Register (Verilog Code)
- PRBS Generator (Verilog Code Test Bench)
Explore Verilog Math, Processing & Memory
- Full Adder (Verilog HDL Code)
- Verilog Code: Half Adder, Half Subtractor, Full Subtractor
- 32-Bit ALU (Verilog Code)
- RAM / ROM (Verilog Code)
- Asynchronous FIFO (Verilog Code Test Bench)
- Asynchronous FIFO Design (Verilog Code and Explanation)
- Mealy / Moore Machine (Verilog)
- Low Pass FIR Filter (Verilog Code)
- 4-bit Binary to Gray Counter Converter in Verilog
