Basic Logic Functions and Truth Tables

Basic Logic Functions and Truth Tables

Basic Logic Function

A digital circuit represents and manipulates information encoded as electric signals that can assume one of two voltages: logic high (Vdd) or logic low (GND). Here we will dig further into the workings of digital circuits now that you have a better foundation for understanding.

A digital circuit requires a power supply that can produce these two voltages, and these same supply voltages are also used to encode information in the form of two-state, or binary signals. Thus, if a given circuit node is at Vdd, then that signal is said to carry a logic '1'; if the node is at GND, then the node carries a logic '0'. The components in digital circuits are simple on/off switches that can pass logic '1' and logic '0' signals from one circuit node to another. Most typically, these switches are arranged to combine input signals to produce an output signal according to basic logic relationships. For example, one well-known logic circuit is an AND gate that combines two input signals to produce an output that is the logic AND of the inputs (i.e., if both input1 and input2 are a '1', then the output is a '1').

The three primary logic relationships, AND, OR, and NOT (or inversion) can be used to express any logical relationship between any number of variables. These simple logic functions form the basis for all digital electronic devices—from a simple microwave oven controller to a desktop PC. We can write a collection of logic equations of the form $F=A\cdot B$ (F equals A and B) that use these three relationships to specify the behavior of any given digital system. Pause a moment and think about this: any digital system, up to and including a highly complex computer system, can be built entirely of devices that do no more than implement these three simple functions. Figure 1 below illustrates logic function notations.

Figure 1. Logic function notations.

As engineers, we must address two primary concerns: how to express a given requirement or problem statement in terms of these simple logic relationships; and how to build electronic devices (or circuits) that can be used to implement these relationships in real devices.

Logic equations provide an abstract model of actual logic circuits. They are used to show how an output logic signal should be driven in response to changes on one or more input signals. The equal sign ('=') is typically used as an assignment operator to indicate how information should flow through a logic circuit. For example, the simple logic equation 'F = A' specifies that the output signal F should be assigned whatever voltage is currently on signal A. But this does not necessarily imply that F and A are the same circuit node—in fact most of the time, the use of a logic equation to specify circuit behavior implies that the inputs and outputs are separated by a circuit component. In digital circuits, circuit components act like one-way gates. Thus, the logic equation 'F = A' dictates that a change on the signal A will result in a change on the signal F, but a change on F will not result in a change on A. Because of this directionality, assignment operators that indicate direction, such as 'F = A', are often used.

Most logic equations specify an output signal that is some function of input signals. For example, the logic equation $F=A\cdot B$ specifies a logic circuit whose output will be driven to a '1' only when both inputs are driven to a '1'. In Fig. 2 below are six common logical functions written as conventional logic equations. The AND relationship, $F=A\cdot B$, can be written without an operator between the A and B (but more properly, a dot ($\cdot$) should be placed between the variables to make the relationship clear). The OR relationship uses the plus sign, and the NOT or inversion relationship is shown by placing a bar over the inverted variable or by placing a single quote character after the variable or quantity to be inverted (two possible notations are shown for several relationships).

Figure 2. Logic equations.

Compound logic expressions can be built from these basic functions. For example, an output might be need to be driven to a '1' if input signals A and B are both at '1' , or if input C is '0', or if C is '1' at the same time that A is '0'. This relationship can be concisely written as $F = A\cdot B + \overline{C} +\overline{A}\cdot C$.

Truth Tables

A truth table is the primary tool for capturing logical relationships in a concise and universally understood format. All possible combinations of inputs are shown in rows on the left of a truth table, and outputs are shown on the right. A truth table with N inputs requires $2^N$ rows to list all possible input combinations. A '0' or '1' in an output column of a given row specifies the behavior of the logic relationship for the combination of inputs shown in the adjacent row. For example, a truth table with two inputs, A and B, will require $2^2$, or 4 rows to list all possible combinations: '0 0', '0 1', '1 0', and '1 1'. For the ANDing operation, the output is “true” only when both inputs are true, so the rightmost column would have a '1' only in the last row. For the ORing operation, the truth table would have a '0' only in the first row.

Figure 3. Truth tables and logic functions for AND and OR equations

In engineering, our goal is to produce electric circuits that can implement the behavior specified for any given logic relationship. For example, a design might require a warning light to be illuminated whenever sensor A outputs a logic '1', but only if sensor B also outputs a logic '1' at the same time. In this example, perhaps the warning light is in an automobile dashboard, sensor A is a thermometer that outputs a '1' if the temperature is above 90C, and sensor B outputs a '1' if the coolant level is too low. If the coolant level ever becomes too low while the engine temperature too high, the circuit should “assert” its output, in order to do some work (like illuminating the warning light). We apply the same term to inputs—the AND relationship in this example may be stated as “the output F is asserted when the inputs A and B are both asserted”.

Some input signals to logic circuits might normally be a '0', changing to '1' only when some input device or circuit is activated (like the push buttons on the Basys™ board). Other input signals might normally be at '1', changing to '0' only when an input device is activated. In either case, we can use the term “asserted” to indicate the input is producing a signal at either LLV or LHV in response to some action. Using this definition, an asserted signal at LHV is said to be asserted high, and an asserted signal at LLV is said to be asserted low. An asserted high signal at LLV is said to be “not asserted”, and an asserted low signal at LHV is said to be “not asserted”. The same signal definitions are also applied to output signals from logic circuits. If a logic circuit produces a LHV when its inputs are asserted, its output is said to be asserted high, and if a circuit produces a LLV at its output, the output is said to be asserted low.

Represent Basic Logic Operations in Circuits

An example of a circuit that can implement the operation $F=A\cdot B$ is shown in the diagram in Fig. 4. When the switches are both closed, the output F is connected directly to GND, and so F it is at LLV. But when one switch or the other is left open, no direct path to GND exists and the output is “pulled high” (to LHV, or VDD, or logic '1') by the resistor. The operation of the circuit is concisely described as follows:

  • If both switches are open, then F = VDD (or LHV);
  • If one switch is open and the other closed, then F = VDD (or LHV);
  • If both switches are closed, then F = GND (or LLV);
Figure 4. Series circuit.

If we assume that placing VDD (or logic '1') on a switch's input causes it to close, and placing GND (or logic '0') on a switch causes it to open, then we can complete a truth table that clearly shows the behavior of the circuit network under all conditions.

The series circuit can show both the AND relationship and the OR relationship: F is LLV if SW1 and SW2 are closed; and F is LHV (or VDD) if SW1 or SW2 are open. All logic circuits illustrate this property of duality, which simply means that any given logic circuit can be interpreted as performing and AND'ing relationship or an OR'ing relationship, depending on how the inputs and outputs are interpreted.

A parallel circuit can also be used to implement the function $F=A\cdot B$ or $F = A + B$. This circuit uses a parallel configuration instead of the series configuration shown in the above figure. Here again, we assume that Vdd closes a switch and 0V opens a switch. This circuit, like that of the figure above, can demonstrate either the AND relationship or the OR relationship depending on how the input and output signals are interpreted—F is LLV (or GND) if SW1 and SW2 are open, and F is LHV if SW1 or SW2 are closed.

Figure 5. Parallel circuit.

Note that in both cases in Fig. 5 above, the physical circuit always behaves the same way, but the behavior can be interpreted as OR-like, or as AND-like. As will be seen in later work, which interpretation is used is a matter of convenience.

Important Ideas

  • The components in digital circuits are simple on/off switches that can pass logic '1' and logic '0' signals from one circuit node to another.
  • The three primary logic relationships, AND, OR, and NOT (or inversion) can be used to express any logical relationship between any number of variables. These simple logic functions form the basis for all digital electronic devices—from a simple microwave oven controller to a desktop PC.
  • A truth table is the primary tool for capturing logical relationships in a concise and universally understood format. All possible combinations of inputs are shown in rows on the left of a truth table, and outputs are shown on the right.

  • Other product and company names mentioned herein are trademarks or trade names of their respective companies. © 2014 Digilent Inc. All rights reserved.