Skip to content
Digital Electronic Systems

Combinational logic: multiplexers, decoders, comparators and hazards

The multiplexer and its universality, demultiplexers, decoders and priority encoders, comparators, static hazards with an example and the consensus term, description in Verilog.

A combinational network is a circuit whose output depends only on its inputs at that instant, with no memory. Some combinational blocks occur so often that they are standard components: multiplexers, decoders, encoders, adders, comparators. In this lesson we look at them and discover a problem that truth tables hide: spurious transitions caused by delays.

The multiplexer

A 2^n:1 multiplexer (MUX) picks one of 2^n inputs and routes it to the output, according to n select signals.

Four-input multiplexer with its truth table
The trapezoid symbol has four data inputs I0-I3 on the left, the output Y on the right and two select inputs S1 and S0 at the bottom. The table shows that the binary number S1S0 indicates which input is routed to the output.

For the 4:1:

    \[ Y = \overline{S_1}\,\overline{S_0}\,I_0 + \overline{S_1}S_0I_1 + S_1\overline{S_0}I_2 + S_1S_0I_3 \]

Each term is active for a single combination of the selects. The multiplexer is a universal block: tying the data inputs to constants 0 and 1, a MUX with n selects implements any function of n variables, just by writing the truth table column on the inputs. This is exactly how the look-up tables (LUTs) of FPGAs work.

The demultiplexer does the reverse: it routes one input to one of 2^n outputs.

Decoders and encoders

  • An n-to-2^n decoder activates just one of its outputs, the one whose number is given by the inputs: each output is a minterm. It is used to select one of many devices (the right memory chip based on the address, the row of a memory array) and to drive seven-segment displays.
  • An encoder does the inverse: given which of 2^n lines is active, it produces its number. The priority encoder also handles several active lines, returning the most important one: it is the heart of interrupt controllers.

Adders and comparators

The full adder and the ripple-carry and carry-lookahead adders are in the Computer Architecture lesson on arithmetic. An equality comparator between two n-bit words compares the bits in pairs with XNOR gates and ANDs the results: A = B if all bits match. A magnitude comparator (A \gt B) is obtained with a subtraction and a check of the sign or carry.

Spurious transitions

The truth table describes the network in steady state, but gates have delays, and different paths from input to output can have different delays.

Example. f = AB + \overline{A}C, with B = C = 1: the function is always 1, whatever A. When A goes from 1 to 0, the term AB goes to 0 immediately, while \overline{A}C goes to 1 only after the delay of the inverter producing \overline{A}. For an instant both terms are 0, and the output has a brief pulse to 0 (a glitch). This is a static hazard.

On the Karnaugh map the hazard is easy to see: the two groups AB and \overline{A}C are adjacent but do not overlap, and the move from one to the other is not covered. Adding the consensus term BC, which covers the transition, removes the hazard: f = AB + \overline{A}C + BC is logically identical but glitch-free.

In synchronous circuits (next lessons) combinational glitches are usually harmless, because flip-flops read the outputs only on the clock edge, once they have settled. They are dangerous, however, when the combinational output directly drives something edge-sensitive: a clock, an asynchronous reset input, an interrupt. Rule of thumb: never use the output of a combinational network as a clock.

Networks in practice

Today almost nobody draws combinational networks gate by gate. The behaviour is described in a hardware description language, for example assign y = sel[1] ? (sel[0] ? i3 : i2) : (sel[0] ? i1 : i0); in Verilog, and the synthesis tool chooses the implementation with the cells of the available technology, also checking the delays. Understanding the basic blocks is still essential to read the results, estimate area and delay and find bugs.

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
0
Would love your thoughts, please comment.x
()
x