Combinational Logic Elements

Computer Organization and Digital Design 2nd Semester

Combinational logic circuits produce outputs based only on current inputs. They do not have memory.


1. Decoder

alt text

  • Converts binary input into maximum of m = 2n or less unique output lines.
  • Common types: 2-to-4, 3-to-8 decoders.
  • Example: Used in memory address decoding.

2-to-4 Decoder

alt text alt text

3-to-8 Decoder

alt text

Decoder expansion

  • Each minterm → one AND gate
  • Large decoders → need many-input ANDs (not practical)
  • Use small decoders → build big decoder (hierarchical)
  • Final AND gates → only 2 inputs
  • ANDs implement minterms

Example:-alt text

alt text

Implementing logic functions using a decoder

alt text

2. Encoder

alt text Opposite of Decoding:

  • m-bit input → n-bit output (n ≤ m ≤ 2ⁿ)
  • Input: one-hot (only one 1)

4-to-2 encoder

alt text

8-to-3 line encoder (octal-to-binary encoder)

alt text

Decimal to BCD encoder

alt text

Priority encoder

alt text

Example application:

  • Positional encoder alt text

3. Multiplexer (MUX)

alt text

  • Selects one of many input lines and forwards it to a single output.
  • Controlled using select lines.

2 input MUX

alt text

4-to-1 MUX

alt text

Difference between Multiplexer, Decoder, and Encoder

FeatureMultiplexer (MUX)DecoderEncoder
PurposeSelects one input to pass to outputConverts binary input to 1-hot outputConverts 1-hot input to binary output
InputsMultiple data inputs, select linesn input lines2ⁿ input lines
OutputsSingle output2ⁿ output linesn output lines
Control SignalsSelect linesInput acts as selectNo select; active input only
DirectionMany → 1n → 2ⁿ2ⁿ → n
Example UseData routingAddress decodingPriority coding

4. Digital Buffers

Single input digital buffer

alt text

Three state (Tri State buffer)

alt text

Tri-state Buffer:

  • 2 logic levels (0,1), 3 output levels (0,1, High-Z)
  • EN=0 → High-Z (acts like open circuit)
  • Used to isolate output from bus
  • Allows multiple devices to share same bus
  • Common in data buses (e.g., computer peripherals)

Tri-state Digital Buffer Data Bus Control

alt text

Tri-state Digital Buffer Control

alt text

  • allowing only one set of data to pass either a logic “1” or logic “0” output state onto the bus
  • all the other tri-state outputs connected to the same bus lines are disabled by being placed in their high impedance Hi-Z state.

There are four types of tri-state buffers:

    1. Active High tri-state buffer
    1. Active high inverting tri-state buffer
    1. Active Low tri-state buffer
    1. Active low inverting tri-state buffer

Tri-state buffer - active high variants

alt text

Tri-state buffer - active low variants

alt text

5. Comparator

  • Compares two binary numbers.

alt text

Types of Comparators

  1. Equality Comparator

    • Single output
    • Output HIGH if A = B, else LOW
  2. Magnitude Comparator

    • Three outputs:
      • A < B
      • A = B
      • A > B

1-bit magnitude comparator

alt text

2-bit magnitude comparator

  1. Designing alt text

  2. Realizing alt text

N-bit magnitude comparator

alt text

6. Adders, Subtractors, and ALUs

Adders:

  • Do binary addition
  • Inputs: two or more binary numbers
  • Outputs: SUM and CARRY (Cout)

Half Adder: Adds two bits.

alt text

Full Adder: Adds three bits (including carry-in).

  • Has an additional input bit C in to represent a carry-in bit coming from a previous addition step alt text alt text

Full adder implementation with half adders

alt text

Ripple Carry Adder

  • Uses n full adders connected in series
  • Carry ripples from LSB to MSB (right to left)
4-bit ripple carry adder

alt text

  • Disadvantage: output will not be valid until any carry-input has “rippled” through every full adder in the chain

Carry Lookahead Adder (CLA)

alt text

  • Speeds up addition by computing carries in parallel
  • No need to wait for ripple from LSB to MSB
  • At each bit:
    1. Generate carry (from xi and yi)
    2. Propagate carry (pass carry-in to carry-out)

alt text

  • 3 levels of delay:
    1. Generate & propagate signals
    2. Carry lookahead (sum-of-products)
  • Faster than ripple carry due to parallel carry logic

Subtractors:

  • A – B = A + 2’s complement of B
  • 2’s complement: B’ + 1
  • Circuit: Adder + inverters on B inputs
  • Set input carry C0 = 1

4-bit Adder-Subtractor

alt text

Overflow:

  • Happens when result > range of bits
  • Common in signed binary addition/subtraction
  • Detected when:
    • Two positives → negative result
    • Two negatives → positive result
  • Example alt text

ALUs (Arithmetic Logic Units):

  • Perform arithmetic and logical operations.
  • Core component of a CPU.

alt text

  • Basic ALU Architecture alt text

7. Lookup Tables (LUTs)

  • Memory-based way to implement logic
  • Store outputs for all input combinations
  • Inputs = address, output = stored value
  • No need for logic gates
  • Can be cascaded for complex functions

Half adder using LUTs

alt text

Multiplexers as LUTs

alt text

Uses of LUTs:

  1. PLDs: Used in FPGAs/CPLDs to build custom logic
  2. Speed: Precomputed outputs → faster than gate-based logic
  3. Simplifies complex functions → fewer gates
  4. Function approximation → for math/nonlinear functions