(
see Figure 1.13)
. Behaviors are the best representation for understanding a design at its highest level of abstraction, perhaps during the earliest stages of the design. On the other hand, switches may be the most appropriate representation if you are implementing the design directly as an integrated circuit. We will cover each of these representations in considerably more detail in subsequent chapters.
(
a logic 1 voltage)
to the control point, the switch is closed, tying together the two connection terminals. Setting false (
a logic 0 voltage)
on the switch control causes the switch to open, cutting the connection between the terminals. We call such switches normally open: the switch is open until the control point becomes true.Switches can represent logic clauses by associating the logic clause with the control point of the switch. A normally open switch is closed when the clause associated with the control point is true. We say that the clause is asserted. The switch is open, and the connection path is broken, when the clause is false. In this case, we say that the clause is unasserted. Normally closed switches work in a complementary fashion.
Switch Representation of Logic Statements Switch circuits suggest a possible implementation of the switching networks presented in the previous section. The network computes a logical function by routing "true" through the switches, controlled by logic clauses.
Let's illustrate the concept with the example of the car in the garage. Figure 1.15 gives a switching network for determining whether it is safe to back the car out. The three conditions, car in garage, garage door open, and car running, control the switching elements. The input to the network is "true"; the output is true only when all three conditions are true. In this case, a closed switch path exists from the true input to the output.
But what happens if the car is not in the garage (
or the garage door isn't open or the car isn't running)
? Then the path between true and the output is broken. What is the output value in this case? Actually, it has no value-it is said to be floating.
Floating outputs are not desirable in logic networks. We really should have a way to force the output to false when the car can't be backed out. Every switch output should have a path to true and a complementary path to false.
This is shown in Figure 1.16 for the implementations of AND and OR operations. Note how placing normally open switches in series yields an AND. When A and B are true, the switches close and a path is established from true to the output. If either A or B is false, the path to true is broken, and one of the parallel normally closed switches establishes a connection from false to the output.
In the OR implementation, the parallel and series connections of the switches are reversed. If either A or B is true, one or both of the normally open switches will close, making a connection between true and the output. If both A and B are false, this path is broken, and a new path is made between false and the output.
The capabilities of switching networks go well beyond modeling such simple logic connectives. They can be used to implement many unusual digital functions, as we shall see in Chapter 4. In particular, there is a class of functions that can best be visualized in terms of directing inputs to outputs through a maze of switches. These are excellent candidates for direct implementation by transistor switches. For some examples, see Exercise 1.8.
Let's consider a simple circuit with two binary inputs that generates sum and carry outputs (
there is no carry-in input)
. This circuit is called a half adder. Its truth table is shown in Figure 1.17. The network has two inputs, A and B, and two outputs, Sum and Carry. Thus the table has four columns, one for each input and output, and four rows, for each of the 22 unique binary combinations of the inputs.
Figure 1.18 shows the truth table for the full adder, a circuit with two data inputs A and B, a carry-in input Cin, and the Sum and Cout outputs of the half adder. The three inputs have 23 unique binary combinations, leading to a truth table with eight rows.
Truth tables are fine for describing functions with a modest number of inputs. But for large numbers of inputs, the truth table grows too large. An alternative representation writes the function as an expression over logic operations and inputs. We look at this next.
(
Y OR NOT Y)
is the same as X, since Y OR NOT Y is always true. The procedures you will learn for optimizing combinational and sequential networks are based on the principles of Boolean algebra, and thus Boolean expressions are often used as input to computer-aided design tools.(
inversion, negation)
of X as one of X', !X, /X, or \X. The OR operation is -written as X +
Y, X # Y, or X | Y. X AND Y is written as X & Y, X Y, or more simply X Y. Although there are certain analogies between OR and PLUS and between AND and MULTIPLY, the logic operations are not the same as the arithmetic operations.Equivalence of Boolean Expressions and Truth Tables A Boolean expression can be readily derived from a truth table and vice versa. In fact, Boolean expressions and truth tables convey exactly the same information.
Let's consider the structure of a truth table, with one column for each input variable and a column for the expression's output. Each row in which the output column is a 1 contributes a single ANDed term of the input variables to the Boolean expression. This is called a product term, because of the analogy between AND and MULTIPLY. Looking at the row, we see that if the column associated with variable X has a 0 in it, the expression is part of the ANDed term. Otherwise the expression X is part of the term. Variables in their asserted (
X)
or complemented (
)
forms are called literals.
There is one product term for each row with a 1 in the output column. All such product terms are ORed together to complete the expression. A Boolean expression written in this form is called a sum of products.
Example Deriving Expressions from Truth Tables Let's go back to Figure 1.17 and Figure 1.18, the truth tables for the half adder and the full adder, respectively. Each output column leads to a new Boolean expression, but defined over the same variables associated with the input columns. The Boolean expressions for the half adder's Sum and Carry outputs can be written as:
The half adder Sum is 1 in two rows: A =
1, B =
0 and A =
0, B =
1. The half adder Carry is 1 in only one row: A =
1, B =
1.
The truth table for the full adder is considerably more complex. Both Sum and Cout have four rows with 1's in the output columns. The two functions are written as
As we shall see in Chapter 2, we can exploit Boolean algebra to simplify Boolean expressions. By applying some of the simplification theorems of Boolean algebra, we can reduce the expression for the full adder's Cout output to the following:
Such simplified forms reduce the amount of gates, transistors, wires, and so on, needed to implement the expression. Simplification is an extremely valuable tool.
You can use a truth table to verify that the simplified expression just obtained is equivalent to the original. Start with a truth table with filled-in input columns but empty output columns. Then find all rows of the truth table for which the product terms are true, and enter a 1 in the associated output column. For example, the term A Cin is true wherever A =
1 and Cin =
1, independent of the value of B. A Cin spans two truth table rows: A =
1, B =
0, Cin =
1 and A =
1, B =
1, Cin =
1.
Figure 1.19 shows the filled-in truth table and indicates the rows spanned by each of the terms. Since the resulting truth table is the same as that of the original expression (
see Figure 1.18)
, the two expressions must have the same behavior.
(
NOT)
, AND, and OR functions, whose corresponding gate-level representations are given in Figure 1.20. Logic gates are formed internally from transistor switches (
see Exercise 1.12)
. Correspondence Between Boolean Expressions and Gate Networks Every Boolean expression has a corresponding implementation in terms of interconnected gates. This is called a schematic. Schematics are one of the ways that we capture the structural view of a design, that is, how the design is constructed from the composition of primitive components. In this case, the composition is accomplished by physically wiring the gates together.
This leads us to some new terminology. A collection of wires that always carry the same electrical signal, because they are physically connected, is called a net. The tabulation of gate inputs and outputs and the nets to which they are connected is called the netlist.
Example Schematics for the Half and Full Adder A schematic for the half adder is shown in Figure 1.21. The inputs are labeled at the left of the figure as A and B. The outputs are at the right, labeled Sum and Carry. Sum is the OR of two ANDed terms, and this maps directly onto the three gates as shown in the schematic. Similarly, Carry is described in terms of a single AND operation and thus maps onto a single AND gate. The figure also shows two different nets, labeled Net 1 and Net 2. The former corresponds to the set of wires carrying the input signal A; the latter are the wires carrying signal B.
The full adder's schematic is given in Figure 1.22(
a)
. Each of the outputs is the OR of four 3-variable product terms. The OR operator is mapped into a four-input OR gate, while each product term becomes a three-input AND gate. Each connection in the schematic represents a physical wire among the components. Therefore, there can be a real implementation advantage, in terms of the resources and the time it takes to implement the network, in reducing the number of gates and using gates with fewer inputs.
Figure 1.22(
b)
shows an alternative implementation of the Cout function using fewer gate and wires. The design procedures in the next chapter will help you find the simplest, easiest to implement gate-level representation of a Boolean function.
Schematics Rules of Composition The fan-in of a logic gate is its number of inputs. The schematics examples in Figures 1.21 and 1.22 show gates with fan-ins of 1, 2, 3, and 4. The fan-out of a gate is the number of inputs to which the gate's output is connected. The schematics examples have many gates with fan-outs of 1, that is, gates whose output connects to exactly one input of another gate. However, some signals have much greater fan-out. For example, signal A in the full adder schematic connects to six different gate inputs (
one NOT and five AND gates)
.
The schematic representation places no limits on the fan-ins and fan-outs. Nevertheless, fan-in and fan-out are restricted by the underlying technology from which the logic gates are constructed. It is difficult to find OR gates with greater than 8 inputs, or technologies that allow gates to fan out to more than 10 or 20 other gates. A particular technology will impose a set of rules of composition on fan-ins and fan-outs to ensure proper electrical behavior of gates. In Chapter 3 you will learn how to compute the maximum allowable fan-out of a gate.
(
0 or 1)
of multiple signal traces are represented by the Y axis. Time | |
---|---|
0-50 | A is 0, B is 0 |
51-100 | A is 0, B is 1 |
101-150 | A is 1, B is 0 |
151-200 | A is 1, B is 1 |
Example Tracing Propagation Delays in the Half Adder Looking in particular at time step 51, the B input changes from 0 to 1. Twenty time units later, the Sum output changes from 0 to 1. Why does this happen?
Figure 1.24 shows a logic circuit instrumented with probes on every one of the circuit's nets. The probes display the current logic value on a par-ticular net. The nets with changing values are highlighted in the figure.
Let's examine the sequence of events and the detailed propagation of signals more closely, using Figure 1.24. Figure 1.24(
a)
shows the initial input conditions (
A and B are both 0)
and the values of all internal nets.
The situation immediately after B changes from 0 to 1 is shown in Figure 1.24(
b)
. The set of wires attached to the input switch now carry a 1. At this point, the topmost AND gate has both of its inputs set to 1. One gate delay (
10 time units)
later, the output of this gate will change from 0 to 1. This is shown in Figure 1.24(
c)
.
Now one of the inputs to the OR gate is 1. After another 10-time-unit gate delay, the Sum output changes from 0 to 1 (
see Figure 1.24(
d))
. Since the propagated signal passes through two gates, the logic incurs two gate delays, or a delay of 20 time units, as shown in the waveform of Figure 1.23. The propagation path that determines the delay through the circuit is called the critical path.
Glitches Propagation delays are highly pattern sensitive. Their duration depends on the specific input combinations and how these cause different propagation paths to become critical within the network. It takes 30 time units (
three gate delays)
for Sum to change after Y changes at time step 151. Did you notice the strange behavior in the Sum waveform between time steps 120 and 130? The input combination is 1 and 0, but for a short time Sum actually generates a zero output! This behavior is called a glitch, a short time during which the output goes through a logic value that is not its steady-state value. This can lead to anomalous behavior if you are not careful. You will learn how to design circuits to avoid glitches in Chapter 3.
Example Full Adder Block Diagram Figure 1.25 shows how two instances of the same building block, the half adder, can be used to implement a full adder. As you can see from the output waveforms of Figure 1.26, the composed circuit behaves like the full adder constructed directly from logic gates.
Compare the waveforms to the truth table of Figure 1.18. For the most part, the truth table is mirrored in the waveforms, with slight timing variations. The Sum waveform also includes some glitches, highlighted in the figure.
The block diagram representation reduces the complexity of a design to more manageable units. Rather than dealing with the full complexity of the full adder schematic and its 13 gates, you need only understand the much simpler half adder (
just six gates)
and its simple composition to implement the full adder.
Waveforms capture the timing relationships between input and output signals. But they are not always the best way to understand the abstract function being implemented. This is where behavioral representations play an important role. We examine them next.
MODULE half_adder;
A, B, Sum, Carry PIN 1, 2, 3, 4;
TRUTH_TABLE ([A, B] -> [Sum, Carry]) [0, 0] -> [0, 0]; [0, 1] -> [1, 0]; [1, 0] -> [1, 0]; [1, 1] -> [0, 1];
END half_adder;The specification is nothing more than a tabulation of conditions on inputs A and B and the corresponding output values that should be associated with Sum and Carry.
MODULE half_adder;
A, B, Sum, Carry PIN 1, 2, 3, 4;
EQUATIONS Sum = (A & !B) # (!A & B); Carry = A & B;
END half_adder;Here, & is the AND operator, ! is negation, and # is OR.
-- ***** inverter gate model ***** -- external ports ENTITY inverter_gate; PORT (A: IN BIT; Z: OUT BIT); END inverter_gate;
-- internal behavior ARCHITECTURE behavioral OF inverter_gate IS BEGIN Z <= NOT A AFTER 10 ns; END behavioral;
-- ***** and gate model ***** -- external ports ENTITY and_gate; PORT (A, B: IN BIT; Z: OUT BIT); END and_gate;
-- internal behavior ARCHITECTURE behavioral OF and_gate IS BEGIN Z <= A AND B AFTER 10 ns; END behavioral;
-- ***** or gate model ***** -- external ports ENTITY or_gate; PORT (A, B: IN BIT; Z: OUT BIT); END or_gate;
-- internal behavior ARCHITECTURE behavioral OF or_gate IS BEGIN Z <= A OR B AFTER 10 ns; END behavioral;
-- ***** half adder model ***** -- external ports ENTITY half_adder; PORT (A, B: INPUT; Sum, Carry: OUTPUT); END half_adder;
-- internal structure ARCHITECTURE structural of half_adder IS -- component types to use COMPONENT inverter_gate PORT (A: IN BIT; Z: OUT BIT); END COMPONENT; COMPONENT and_gate PORT (A, B: IN BIT; Z: OUT BIT); END COMPONENT; COMPONENT or_gate PORT (A, B: IN BIT; Z: OUT BIT); END COMPONENT;
-- internal signal wires SIGNAL s1, s2, s3, s4: BIT; BEGIN -- one line for each gate, describing its -- type and its connections i1: inverter_gate PORT MAP (A, s1); i2: inverter_gate PORT MAP (B, s2); a1: and_gate PORT MAP (B, s1, s3); a2: and_gate PORT MAP (A, s2, s4); a3: and_gate PORT MAP (A, B, Carry); o1: or_gate PORT MAP (s3, s4, Sum); END structural;The entity declarations declare the block diagram characteristics of a component-that is, the way it looks to the outside world. The architecture declarations define the internal operation. Usually these are written in a form that looks much like programming statements. The inverter, AND, and OR behaviors are so simple that they do not do justice to VHDL's capability of expressing hardware behavior. This definition of the half adder is entirely structural: it is merely a textual form of specifying the schematic, shown in Figure 1.27.
[Top] [Next] [Prev]