next up previous
Next: More Logic Design Up: CSE 372: Digital Logic/Computer Previous: Preface

Logic Design Basics

 

Purpose

The appendix covering logic design principles in P&H is relatively short and of shallow depth. This laboratory provides greater detail and fills in some of the gaps left by the cursory treatment this material is given in the text. Therefore, we begin by adding to the material discussed in the required reading.

Required Reading

P&H, Appendix B, Sections 1-3.

Preparatory Exercises

  1. Show that there are tex2html_wrap_inline574 entries in a truth table for a function with n inputs. (Hint: Use induction.)
  2. Exercise B.2
  3. Another theorem of boolean algebra is the combining theorem:

    displaymath572

    1. Make a truth table showing that the first equivalence is true. Display values for tex2html_wrap_inline578 .
    2. Use the laws of Boolean algebra on page B-6 to show that the second equivalence is true. (Hint: To show this equivalence to be true, start with left-hand-side expression, and reduce to the right-hand-side expression using the laws.) Please cite the laws used.
  4. Exercise B.6
  5. Exercise B.11
  6. Exercise B.12

Discussion

More on Logic Gates

The brief discussion in P&H on logic gates introduces the symbols for the basic AND, OR, and NOT (inverter) gates. There are more gates, however, although the functions they represent should not be foreign to a student in computer science. The standard symbols for 2-input NAND, NOR, XOR and XNOR are depicted in Figure gif.

   figure53
Figure: More logic gate representations.

Can gates have more than two inputs? Yes, but only if it makes sense, which is of course subjective. Generally, only the AND, OR, NAND and NOR gates can have two or more inputs. The logic functions for these gates are simply extended to more inputs (e.g. ANDing three inputs is easily defined) whereas the XOR or XNOR of more than two logic inputs does not make much sense. To draw the ``multi-input'' gates, just add more input lines.

Figure B.2 shows two simple logic circuits; notice that the inputs and outputs are labeled with variable names. If an input to a logic device is always one or always zero (high or low, respectively) then we simply write '1' or '0' at the input, rather than a variable name. A logic input is said to be ``active high'' when it performs a specified action it is high or '1' (using a positive-logic convention is assumed in this discussion). Similarly, we can have active low inputs as well. For example, we shall see later that some more complex devices such as decoders generally have ``enable'' inputs, which can be asserted active high or low. We shall assume that an input is active high unless otherwise specified. If we wish to indicate that an input is active low, we put a prefix of / in front of the name.

Karnaugh Maps

Page B-10 mentions the concept of two-level representation, which are implemented in two ways: sum-of-products (SOP) and product-of-sums (POS). We shall deal exclusively with the SOP representation, for convenience, unless otherwise noted. Read over the example on page B-11. The equation for D is an SOP expression derived directly from the truth table. Our engineering intuitions might prompt us to ask two questions at this point:

It is not always necessary to achieve a minimal solution. In case of PLAs, specifically the programmable type called ``PALs,'' using generalized gates facilitates the implementation of arbitrary functions, but the tradeoff is more gates. Still, it is important to understand how to minimize gates in the event that is necessary to do so.

One technique for gate reduction is through the use of Karnaugh maps, which graphically represent the values in a truth table. Figure gif shows the Karnaugh maps (also know as ``K-maps'') for 2-,3-, and 4-variable functions.

   figure71
Figure: K-maps for 2-, 3-, and 4-variable logic functions.

The labeling may seem a bit strange, but it does serve several purposes:

What does all this complicated business get us in return? To see, we shall do an example. Look at the truth table below, for a 3-variable logic function with an output F. Notice the numbering of the truth table from '0' to '7'. Figure gif is the 3-variable K-map for this truth table.

   figure81
Figure: Example truth table and K-map.

Now reason for the funny ordering comes to light -- each cell is different from an adjacent cell by one variable! So what? Recall the combining theorem from the Preparatory Exercises section. If we use the general form of this theorem by considering A to be a logic function itself, then min-terms can be combined into a simpler form. Look at cell numbers 5 and 7. The two min-terms that they correspond to in the overall SOP expression are:

eqnarray87

Now here's the quick way to get the same answer: if we take a close look at the K-map, the area covering cells 5 and 7 are completely contained in the area bracketed by both A and C. So the product term is tex2html_wrap_inline600 . It is easier to see if we circle the adjacent cell pairs, as in Figure gif.

   figure92
Figure: Example K-map with min-terms circled.

In fact, we must circle all min-terms to include all possible ones. Notice that cells 1 and 5 are indeed adjacent, but what min-term does this correspond to? The area covering cells 1 and 5 are completely contained in the area bracketed by C and completely outside B. The product term is therefore tex2html_wrap_inline855 . The last min-term tex2html_wrap_inline857 cannot be reduced because it stands alone. Understand how to get the expression for that min-term by visual inspection!

So the truth table yields this final expression: tex2html_wrap_inline859 , which is significantly smaller than the expression for the four individual min-terms.

In general, the goal is to circle together as many terms as possible, specifically rectangular sets of size tex2html_wrap_inline574 cells contain 1s, taking into account wrap-around. Look at Figure gif and be sure to understand it (0s left out for simplicity):

   figure104
Figure: Example K-map with min-terms circled.

In our final example (Figure gif), we shall demonstrate two rules of thumb:

  1. find all cells that are only covered by one circle -- these must be included in the final answer;
  2. once all cells are covered with the largest possible circles, then the output function is complete.

   figure112
Figure: Example K-map with min-terms circled.

Notice that cells 2, 4, and 14 are all only covered by one circle. The result is cell 7 can be covered in one of two ways. either using the circle representing tex2html_wrap_inline863 or tex2html_wrap_inline865 . We should pick the former product term, because it has less variables. But we don't need both. It would be redundant.

K-maps and don't cares

The book states, ``don't cares are important because they make it easier to optimize the implementation of a logic function.'' We can indeed use them in our K-maps, with the simple rule: if including a don't care term in a circle reduces the number of product terms, use it; otherwise leave it alone. Look at the example starting on page B-16. Let's minimize the output function F with respect to the inputs tex2html_wrap_inline879 .

   figure121
Figure: Function F: without and with don't cares.

(See Figure gif.) The K-map on the left is derived from the truth table without don't cares. It cannot be reduced because there are no adjacent cells. However, the K-map on the right does possess don't care entries (marked as d's), and thus simplifies the logic greatly (to just B + C, in fact). Notice the don't care in cell 4 is not used, because it would require more logic than we need (or care about).

Design Exercises

  1. Design a circuit that outputs a '1' if the 4-bit input is composite, and a '0' if it is prime. (A prime number simply defined as a number that is divisible by one and itself, and one is not prime.) Show the following work:
    1. the truth table for this function (label the output C, and the inputs tex2html_wrap_inline887 where tex2html_wrap_inline889 is the most significant bit),
    2. the corresponding K-map with circled product terms using technique described above,
    3. the SOP expression derived from the K-map,
    4. a logic circuit that implements this expression, using inverters, ANDs and ORs of the 2- and/or 3-input variety.
  2. A real chip that implements digital logic functions can only have a limited number of inputs and outputs. For example, the chip that implements the 2-input NAND function has only four of these gates per chip; the 3-input NAND chip has three gates, the 4-input NAND chip has only two gates. Use DeMorgan's Laws, the laws on page B-6 and your imagination to re-engineer the solution for the previous question to use only 2-, 3-, and/or 4-input NAND gates. Show all work by starting with the SOP expression and working from there. There's no need to draw a new diagram. Count up how many gates and therefore chips were used. Try to minimize the number of gates.
  3. Use K-maps to implement a two-bit arithmetic adder (i.e. design a circuit). There should be four input lines (two two-bit numbers), and three output lines. Make sure to show all work clearly and neatly (truth tables, etc.)


next up previous
Next: More Logic Design Up: CSE 372: Digital Logic/Computer Previous: Preface