CSC116 Digital Logic

Digital LogicUnit 411 min read

Multiplexers, Demux, Decoders & Encoders: Design, Logic & Applications

Unit 4 of Digital Logic covers multiplexers (data selectors), demultiplexers (data distributors), decoders (minterm generators), and encoders (priority logic), including their truth tables, logic circuits, and real-world implementations in memory chips, traffic lights, and error detection.

TAKEAWAYS:

  • Multiplexers select one of n inputs to send to a single output based on m select lines, using the formula .
  • Demultiplexers do the reverse: take one input and route it to one of n outputs, controlled by m select lines.
  • Decoders convert n input lines into unique outputs (e.g., a 3-to-8 decoder has 8 outputs for 3 inputs).
  • Encoders prioritize inputs to generate a binary code (e.g., a 8-to-3 encoder converts 8 inputs into 3-bit binary).
  • Practical uses: Decoders drive LED displays (e.g., NTC bus timings), multiplexers reduce wiring in sensors (e.g., Daraz delivery tracking), and encoders detect errors in transactions (e.g., eSewa checksums).

1. Multiplexers (MUX): Data Selectors

A multiplexer (MUX) is a combinational circuit that selects one of n input lines and sends it to a single output line. It uses select lines (control inputs) to choose which input is active.

A \ B010110111213F = B' + B
K-map showing MUX output F = Σ(0,1,2,3) = B' + B

Key Concepts

  • Inputs: (data inputs).
  • Select Lines: (control inputs, where ).
  • Output: (binary value of select lines determines the chosen input).

Example: 4-to-1 MUX

flowchart LR
    A["D0"] --> B["MUX"]
    C["D1"] --> B
    D["D2"] --> B
    E["D3"] --> B
    F["S1"] --> B
    G["S0"] --> B
    B --> H["Y"]

Truth Table:

(Output)
0 0
0 1
1 0
1 1

Logic Expression

The output can be written as:

Applications

  • Real-World Example: Pathao’s Ride Allocation Pathao uses multiplexers to select the nearest driver’s location from multiple GPS inputs (e.g., 8 drivers → 3 select lines to pick the closest one).
    flowchart TD
        A["Driver 1 GPS"] --> B["MUX"]
        C["Driver 2 GPS"] --> B
        D["Driver 3 GPS"] --> B
        E["Select Lines"] --> B
        B --> F["Nearest Driver"]

2. Demultiplexers (DEMUX): Data Distributors

A demultiplexer (DEMUX) does the opposite of a MUX: it takes one input and routes it to one of n outputs based on select lines.

Key Concepts

  • Input: Single data line ().
  • Select Lines: (control which output is active).
  • Outputs: (only one output is active at a time).

Example: 1-to-4 DEMUX

flowchart LR
    A["I"] --> B["DEMUX"]
    F["S1"] --> B
    G["S0"] --> B
    B --> C["Y0"]
    B --> D["Y1"]
    B --> E["Y2"]
    B --> H["Y3"]

Truth Table:

0 0 I 0 0 0
0 1 0 I 0 0
1 0 0 0 I 0
1 1 0 0 0 I

Logic Expression

Each output is: For :

Applications

  • Real-World Example: NTC Bus Timing Signals NTC uses a 1-to-8 DEMUX to send control signals to different bus stops based on the route number (select lines).

3. Decoders: Minterm Generators

A decoder converts n input lines into unique outputs. Each output corresponds to a minterm of the inputs.

Key Concepts

  • Inputs: lines (e.g., 3 inputs → 8 outputs).
  • Outputs: lines, each representing a unique combination of inputs.
  • Enable Input: Some decoders have an active-low enable (E) to control all outputs.

Example: 3-to-8 Decoder

flowchart LR
    A["A2"] --> B["3-to-8 Decoder"]
    C["A1"] --> B
    D["A0"] --> B
    B --> E["Y0"]
    B --> F["Y1"]
    B --> G["Y2"]
    B --> H["Y3"]
    B --> I["Y4"]
    B --> J["Y5"]
    B --> K["Y6"]
    B --> L["Y7"]

Truth Table:

0 0 0 1 0 0 0 0 0 0 0
0 0 1 0 1 0 0 0 0 0 0
... ... ... ... ... ... ... ... ... ... ...

Logic Expression

Each output is:

Applications

  • Real-World Example: LED Display in eSewa Receipts A 3-to-8 decoder drives 8 LEDs to show transaction status (e.g., = "Payment Successful").
    flowchart TD
        A["Transaction Data"] --> B["3-to-8 Decoder"]
        B --> C["LED 0: Failed"]
        B --> D["LED 1: Pending"]
        B --> E["LED 2: Processing"]
        B --> F["LED 3: Success"]

4. Encoders: Priority Logic

An encoder does the reverse of a decoder: it converts active inputs into a binary code. It often includes priority logic (e.g., if multiple inputs are active, the highest-priority one is encoded).

Key Concepts

  • Inputs: lines (only one active at a time).
  • Outputs: lines (where ).
  • Priority: Higher inputs take precedence (e.g., > > ... > ).

Example: 8-to-3 Encoder

flowchart LR
    A["I0"] --> B["8-to-3 Encoder"]
    C["I1"] --> B
    D["I2"] --> B
    E["I3"] --> B
    F["I4"] --> B
    G["I5"] --> B
    H["I6"] --> B
    I["I7"] --> B
    B --> J["A2"]
    B --> K["A1"]
    B --> L["A0"]

Truth Table (Priority Logic):

1 0 0 0 0 0 0 0 1 1 1
0 1 0 0 0 0 0 0 1 1 0
... ... ... ... ... ... ... ... ... ... ...

Logic Expression

For (priority for to ):

Applications

  • Real-World Example: Khalti Transaction Error Detection An 8-to-3 encoder checks for invalid transaction inputs (e.g., if = "Duplicate Payment" is active, it encodes to ).

5. Comparisons: MUX vs. DEMUX vs. Decoder vs. Encoder

Feature Multiplexer (MUX) Demultiplexer (DEMUX) Decoder Encoder
Function Selects 1 input → 1 output 1 input → Selects 1 output inputs → outputs inputs → outputs
Inputs Multiple data + select lines 1 data + select lines inputs inputs
Outputs 1 output Multiple outputs outputs outputs
Example Use Sensor data selection Bus stop signals LED displays Priority interrupt handling

6. Implementing Boolean Functions

Decoders and MUX can implement any Boolean function. Here’s how:

Example: Implement using a 4-to-1 MUX

  1. Identify minterms: .
  2. Assign inputs:
    • (unused),
    • (for ),
    • (for ),
    • (for ),
    • (for ).
  3. Select lines: (since 4 inputs need 2 select lines).

Circuit:

flowchart LR
    A["D0=0"] --> B["MUX"]
    C["D1=1"] --> B
    D["D2=1"] --> B
    E["D3=1"] --> B
    F["D4=1"] --> B
    G["S1"] --> B
    H["S0"] --> B
    B --> I["F"]

Example: Implement using a 3-to-8 Decoder

  1. Connect minterms to outputs:
    • (for ),
    • (for ),
    • (for ),
    • (for ).
  2. Other outputs: Tie to 0.

Circuit:

Y1Y2Y4A2A1A0
3-to-8 Decoder implementing F = Σ(0, 3, 5, 7) with tied outputs

7. Practical Design: 5x32 Decoder using Smaller Decoders

Problem: Design a 5x32 decoder using 3x8 decoders with enable and a 2x4 decoder.

Solution:

  1. Break down: 5 inputs → 32 outputs.
    • Use 4 select lines for 16 outputs, but we need 32.
    • Step 1: Use a 2x4 decoder to enable two 3x8 decoders.
    • Step 2: Each 3x8 decoder covers 8 outputs, totaling 16. Repeat for the other 16.

Block Diagram:

flowchart TD
    A["A4"] --> B["2-to-4 Decoder"]
    C["A3"] --> B
    B --> D["Enable 3x8 Decoder 1"]
    B --> E["Enable 3x8 Decoder 2"]
    D --> F["3x8 Decoder 1"]
    E --> G["3x8 Decoder 2"]
    F --> H["Y0-Y7"]
    G --> I["Y8-Y15"]
    A["A2"] --> F
    A["A1"] --> F
    A["A0"] --> F
    A["A2"] --> G
    A["A1"] --> G
    A["A0"] --> G

## In the Real World

  1. eSewa Transaction Validation

    • Decoder Use: A 3-to-8 decoder checks transaction status codes (e.g., = "Refund Initiated").
    • Encoder Use: An 8-to-3 encoder prioritizes error codes (e.g., = "Server Down" overrides = "Low Balance").
  2. Daraz Order Fulfillment

    • Multiplexer Use: A 16-to-1 MUX selects the fastest delivery route from 16 GPS inputs based on traffic data (select lines = ).
  3. NTC Bus Timing System

    • Demultiplexer Use: A 1-to-8 DEMUX routes the bus arrival signal to the correct stop (select lines = bus route number).

## Exam Tip

  1. For MUX/DEMUX Questions:

    • Always draw the block diagram and truth table.
    • Label inputs/outputs clearly (e.g., to ).
    • Show the logic expression for the output.
  2. For Decoder/Encoder Questions:

    • Decoders: List all outputs and their minterms.
    • Encoders: Show priority logic (e.g., has highest priority).
    • Implementation: If asked to use a MUX/decoder for a Boolean function, map minterms to inputs/outputs.
  3. Common Pitfalls:

    • Forgetting the enable input in decoders.
    • Misassigning select lines in MUX/DEMUX (e.g., vs. ).
    • Not showing unused inputs tied to 0/1 in encoders.
  4. Past Exam Patterns:

    • Design questions: Always show block diagrams (no gate-level circuits unless asked).
    • Implementation questions: Use MUX/decoder/PLA as specified in the question.
    • Short notes: Define terms precisely (e.g., "A decoder converts inputs to outputs").

Based on the TU BSc CSIT syllabus for Digital Logic (CSC116), unit 4.

Discussion

Loading…