Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Verilog Tutorial 14: How to design a 1×8 demultiplexer and an 8×1 multiplexer in Verilog

By Ashutosh Bhatt June 8, 2025

Note: it’s recommended to follow this VHDL tutorial series in order, starting with the first tutorial. Follow the full series here.

In the previous Verilog Tutorial – 13, we learned how to design a 3×8 decoder and an 8×3 encoder in VHDL.

In this tutorial, we’ll:

  1. Write a Verilog program to build circuits for a 1×8 demultiplexer and an 8×1 multiplexer
  2. Verify the output waveform of program (digital circuit) with truth table of these multiplexer and demultiplexer circuits

The 1×8 Demultiplexer circuit

Truth table

Next, let’s write the Verilog program, compile and simulate it, and get the output in a waveform. We’ll also verify the output waveforms with the given truth table.

First, it’s important to review the step-by-step procedure provided in VHDL Tutorial – 3. In that tutorial, we learn how to design a project, edit and compile a program, create a waveform file, simulate the program, and generate the final output waveforms.

Verilog program

Gate-level modeling:

module demux18(o1,o2,o3,o4,o5,o6,o7,o8,D,s0,s1,s2);
 input  i,s0,s1,s2;
 output o1,o2,o3,o4,o5,o6,o7,o8;
 wire not_s0,not_s1,not_s2;
not(not_s0,s0);
not(not_s1,s1);
not(not_s2,s2);
and(o1,not_s0,not_s1,not_s2,i);
and(o2,s0,not_s1,not_s2,i);
and(o3,not_s0,s1,not_s2,i);
and(o4,s0,s1,not_s2,i);
and(o5,not_s0,not_s1,s2,i);
and(o6,s0,not_s1,s2,i);
and(o7,not_s0,s1,s2,i);
and(o8,s0,s1,s2,i);
endmodule

Dataflow modeling:

module demux18(o1,o2,o3,o4,o5,o6,o7,o8,D,s0,s1,s2);
 input  i,s0,s1,s2;
 output o1,o2,o3,o4,o5,o6,o7,o8;

assign o1 = ~s0 & ~s1 & ~s2 & i;
assign o2 = s0 & ~s1 & ~s2 & i;
assign o3 = ~s0 & s1 & ~s2 & i;
assign o4 = s0 & s1 & ~s2 & i;
assign o5 = ~s0 & ~s1 & s2 & i;
assign o6= s0 & ~s1 & s2 & i;
assign o7 = ~s0 & s1 & s2 & i;
assign o8 = s0 & s1 & s2 & i;
endmodule

Now, compile the above program, creating a waveform file with all of the necessary inputs and outputs that are listed, and simulate the project. 

Here are the results…

Waveform simulation

As shown above, the 8×1 multiplexer can be understood by examining the select lines and corresponding outputs. When the select lines (S2, S1, S0) are set to ‘001,’ input I₀ is routed to the output, resulting in ‘O₁ = 0.’

Similarly, when the select lines are ‘101,’ input I₅ is selected, and the output becomes ‘O₅ = 1.’ You can also verify other combinations of the select lines by observing how each input is connected to its corresponding output.

Next, let’s build the 8×1 multiplexer circuit. 

The 8×1 multiplexer circuit

Verilog program:

Gate-level modeling:

module mux81(o, D0, D1, D2, D3, D4, D5, D6, D7, S0, S1, S2);
  input  D0, D1, D2, D3, D4, D5, D6, D7, S0, S1, S2;
  output o;
  wire o1,o2,o3,o4,o5,o6,o7,o8,x,y,z;
not(x,S0);
not(y,S1);
not(z,S2);
and(o1,x,y,z,D0);
and(o2,S0,y,z,D1);
and(o3,x,S1,z,D2);
and(o4,S0,S1,z,D3);
and(o5,x,y,S2,D4);
and(o6,S0,y,S2,D5);
and(o7,x,S1,S2,D6);
and(o8,S0,S1,S2,D7);
or(o,o1,o2,o3,o4,o5,o6,o7,o8);
endmodule

Dataflow modeling:

module mux81(o, D0, D1, D2, D3, D4, D5, D6, D7, S0, S1, S2);
  input  D0, D1, D2, D3, D4, D5, D6, D7, S0, S1, S2;
  output o;
  wire o1,o2,o3,o4,o5,o6,o7,o8;
assign o1 = ~S0 & ~S1 & ~S2 & D0;
assign o2 = S0 & ~S1 & ~S2 & D1;
assign o3 = ~S0 & S1 & ~S2 & D2;
assign o4 = S0 & S1 & ~S2 & D3;
assign o5 = ~S0 & ~S1 & S2 & D4;
assign o6 = S0 & ~S1 & S2 & D5;
assign o7 = ~S0 & S1 & S2 & D6;
assign o8 = S0 & S1 & S2 & D7;
assign o = o1 | o2 | o3 | o4 | o5 | o6 | o7 | o8;
endmodule

Simulation waveform

As shown in the figure, when the select lines (S2, S1, S0) are set to “011” and “100,” the corresponding inputs d₃ = 1 and d₄ = 1 are passed to the output, resulting in o = 1. You can verify additional select line combinations using the truth table.

In the next tutorial, we’ll design the RS flip-flop and the clocked RS latch.

You may also like:


  • Verilog Tutorial 13: How to design a 3×8 decoder and…

  • Verilog Tutorial 12: How to design 8-bit parity generator and…

  • Verilog Tutorial 11: How to design half and full-subtractor circuits…

  • Verilog Tutorial 10: How to design half and full-adder circuits…

  • How to design a digital circuit for a Boolean equation…

  • How to use NOR as the universal gate in Verilog

  • What is Verilog, its features, and design flow?- Part 2

  • What are the fundamentals of Verilog programs?-Part 1

  • How to use NAND as a universal gate in Verilog

Filed Under: Tutorials, Uncategorized
Tagged With: demultiplexer, multiplexer, tutorial, verilog
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Reducing "shoot-through" in offline Full Bridge SMPS?
  • High Side current sensing
  • How to simulate power electronics converter in PSpice?
  • Voltage mode pushpull is a nonsense SMPS?
  • Layout IRN reduction in Comparator

RSS Electro-Tech-Online.com Discussions

  • Back to the old BASIC days
  • Parts required for a personal project
  • PIC KIT 3 not able to program dsPIC
  • Failure of polypropylene motor-run capacitors
  • Siemens large industrial PLC parts

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • What is AWS IoT Core and when should you use it?
  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe