EXPERIMENT 12: DIGITAL LOGIC CIRCUITS The purpose of this experiment is to gain some experience in the use of digital logic circuits. These circuits are used extensively in computers and all types of electronic instrumentation, including physics experiments. All of the integrated circuits (ICs) we will use are members of the Transistor-Transistor Logic (TTL) family and its improved variants. The circuits are a mixture of chips from the 74LS00 series ( Low-power Schottky, introduced 1976) and 74HCT00 series ( High-speed CMOS, TTL compatible, introduced 1982), and are in the form of 14-pin dual-inline epoxy packages (DIPs). Background on 7400-Series Digital Logic 1. 7400-series TTL chips operate from a single DC power supply of V CC = +5 volts±5% (+5 V ± 10% for 74HCT). They can be destroyed if the supply voltage is raised above above +7.0 V or made negative even briefly (below 0.5 V for 74HCT). TTL logic levels for 7400 series ICs. Here are logic output and input levels: +4.75 V: Supply voltage V CC ; also max. allowed input voltage. +2.40 V: V OH, min. output voltage for logical one @ 0.4 ma. +2.00 V: V IH, min. input voltage for logical one @ 0.04 ma max. I IN. +1.30 V: V S, threshold voltage (typical value varies). +0.80 V: V IL, max. input voltage for logical zero @ -1.6 ma max. I SINK. +0.40 V: V OL, max. output voltage for logical zero @ -16 ma. 0.00 V: Ground; also min. allowed input voltage. 2. The delay in passing a signal through one NAND gate, called the propagation delay, is typically about 10 ns for 74LS and 74HCT TTL logic. 3. Unless you are not using an entire gate or section of a TTL logic chip, all of its unused inputs must be connected to low or high. (Compare with a CMOS logic chip, which must have all its inputs connected to something, or the chip might destroy itself!) 4. 7400 series inputs source a maximum of 1.6 ma if held low or sink a maximum 0f 40 µa if held high; the outputs can sink 16 ma while maintaining their guaranteed low output voltage, and supply 0.4 ma at their guaranteed high output voltage. This allows up to ten inputs to be connected to one output, for a fanout of ten. This is not strictly true; unconnected TTL inputs will float to logical high, and a circuit designed with floating inputs might appear to work, but such designs will not operate reliably. For more on why, see Section 9.06 of Horowitz and Hill, The Art of Electronics second edition, where they describe leaving digital inputs unconnected as foolish and dangerous.
5. The 7400 ( commercial ) series of TTL ICs have an operating case temperature range of 0 C to +70 C; 54xx devices are military grade, with an operating temperature range of 55 C to +125 C. Many commercial CMOS logic series have a larger temperature range than the normal commercial rating, but you need to check the individual manufacturer s data sheet. Some devices are rated for an industrial temperature range of 40 C to +85 C. (Note that even this may be inadequate for some under-the-hood automotive applications.) Apparatus All of the digital circuits needed for the next two laboratories have been incorporated into prewired logic boards. The integrated circuits are mounted in DIP sockets inside the chassis of the logic board, with the inputs and outputs wired to external connectors. The +4.75 volt power supply is also located inside the chassis. The ground and DC power leads are permanently wired to the DIP sockets. The ground wire is large (22 gauge) to reduce its inductance and noise. The DC power line is bypassed to ground at several points by low-inductance disc ceramic capacitors. This reduces the spikes in the supply voltage caused by the rapid switching of currents in the ICs. Each logic board contains the following circuits: 16 2-input NAND gates 3 3-input NAND gates 10 indicator LEDs 4 push-button switches 8 JK flip-flops 1 4-bit adder 1 UART 4 toggle switches (note: NOR gates with 2-8 inputs are readily available. You get NAND gates only as an exercise in DeMorgan s theorem.) Please note the following information about our logic boards: 1. Grey connectors indicate inputs. 74LS TTL inputs have a very non-linear impedance (2 kω near 0 V and 20 kω near +4 V) and may be connected to any voltage between 0 and +4.75 V. 74HCT inputs are CMOS, and draw extremely small currents; they may be connected to voltages up to 1.5 V above V CC or below ground without trouble. 2. Green connectors indicate outputs. To prevent damage by accidental shorting, a 47 Ω resistor has been placed in series with each output. Each output can drive several inputs to logical one or zero; the number of inputs you can connect one output to is called the fanout of a logic circuit. Typical fanouts for modern TTL ICs are around 10; the use of protection resistors on our board limits its fanout to 4. 2
3. Light emitting diodes (LEDs) driven by internal buffer circuits can be used to indicate the digital voltage level at various points in the circuit: LED on indicates logical one, while LED off indicates logical zero. 4. Push-button and toggle switches can be used to provide logical one or logical zero inputs for other circuits on the board. 5. Pull-up resistors inside the board connect any floating (otherwise unconnected) inputs to high (logical one). (This means you don t have to worry about connecting floating inputs.) Laboratory Exercises Perform the exercises outlined below. As you go through the individual operations, it should become apparent how simple digital circuits can be combined to perform more complex operations. Do not introduce any external voltages into the logic board. 1. Experimentally verify the truth table for a 3-input NAND gate. 2. Use 2-input NAND gates to construct circuits that perform the following logical functions. In each case, draw the circuit diagram and experimentally verify the truth table. (a) 2-input AND gate: A AND B = A B. (b) 2-input OR gate: A OR B = A + B. (c) 2-input NOR gate: A NOR B = A + B. (d) 2-input XOR gate: A XOR B = A B. 3. Use NAND gates to construct circuits that perform the following functions. In each case, try to minimize the total number of gates, using 3-input NANDs wherever possible. Draw your circuits and write out at least a portion of the truth table (at least 8 states for each circuit; you can also use Don t Care states to simplify the table). (a) (A B) + C (b) ((A B) + C) D (c) (A B) + (C D) (d) (A B C) + D + E. 4. A comparator is a circuit that compares the values of two numbers A and B and outputs a one if A = B or a zero if A B. Consider a 2-bit comparator; such a circuit must have 4 inputs, one for each bit of each number. Let A 1 and A 0 be the most and least significant bit of A, respectively, and similarly for B 1 and B 0. (a) Write down a logical expression for C in terms of A 0, A 1, B 0, and B 1. (If you get stuck, it might help to write out a truth table.) 3
Inputs Outputs A 0 B 0 C 0 S 0 0 0 0 0 0 1 0 1 1 0 0 1 1 1 1 0 Table 1: Truth table for a half adder. A 0 C 0 HA B 0 S 0 Figure 1: A block schematic symbol for a half adder. (b) Design a circuit that uses only 2- and 3-input NAND gates to perform a 2-bit comparison. Draw its schematic in your lab notebook. (c) Build the circuit you designed, and verify that it does what you designed it to do. (Hint: The XOR circuit from part 2d is pretty close to a 1-bit comparator compare the truth tables! You will need two such circuits, one for the first bit and another for the second bit.) 5. A basic circuit for adding two bits, called a half adder, has the truth table shown in Table 1. A half adder will add bits A 0 and B 0 to produce their sum S 0 and a carry bit C 0. (a) Write down logical expressions for S 0 and C 0 in terms of A 0 and B 0. (b) Design a half adder circuit using only 2- and 3-input NAND gates. (c) Build your half adder design, and verify that it produces the truth table shown in Table 1. 6. The circuit shown in Figure 2 is referred to as a full adder. A chain of N full adders can add two N-bit numbers A and B one bit at a time, starting from the least significant digit, giving their N-bit sum. In each full addition step it combines three inputs, A n, the nth bit from A B n, the nth bit from B C n 1, the carry bit from the previous step and generates two outputs, S n, the nth bit of the sum of A and B C n, a carry bit for the next step. The full adder is an extremely important and useful circuit found in every digital calculator and computer. (a) What should you do with the carry input to the LSB of an N-bit adder? 4
A n B n at least two C n C n 1 A n B n C n 1 at least one just one A n B n C n 1 all three S n Figure 2: A full adder built with NAND gates. Labels describe the functions of blocks. B 3 A 3 B 2 A 2 B 1 A 1 B 0 A 0 C 3 C 2 C 1 C 0 FA FA FA FA C in C out S 3 S 2 S 1 S 0 Figure 3: A block diagram of a 4-bit adder built from full adders. (b) For the last addition in an N-bit sum, the final carry bit C N 1 is also called the overflow bit. Why? (c) Write down the truth table for a full adder. You may reference Figure 2, or you can start from the functional definition of a full adder. 7. The 4-bit adder on the logic board is a single chip (a 74LS283 IC) that performs the function of four full-adder circuits like the one in Figure 2. A schematic diagram of four full adders connected to form a single 4-bit adder with carry is shown in Figure 3. Notice that the carry input and the carry output allow you to connect N of these chips together to obtain a 4N-bit adder. Use the 4-bit adder to add the following pairs of decimal numbers: 5
(a) 6 + 7. (b) 13 + 5. (c) 11 + 14. Next, try using the adder to add signed numbers. Use two s complement form for negative numbers [( 3) = 1101 2 ], which will restrict our signed adder to the range 8 to +7 (we are using 4-bit words, so we can only represent 16 distinct numbers). Add the following pairs of decimal numbers: (d) ( 3) + 5. (e) 3 + ( 5). (f) ( 2) + ( 3). Observe what happens if you try to use just the most significant bit to indicate the sign [( 3) = 1011 2 ], called sign-and-magnitude representation. Why is two s complement the preferred representation for negative numbers? 8. (Optional.) Design a circuit which returns the two s complement negation of its input, a 4-bit number. You may use all of the circuits available on the logic board. If you feel like it, build and test this circuit. 9. (Optional.) A multiplexer is a very useful circuit which has two sets of inputs: address lines A and data lines D, along with a single output Q. The address lines choose which data line is copied to the output. The number d of data lines is at most 2 a. (a) Write down the truth table for a 2-input multiplexer with address line A and data lines D 0 and D 1 : Q = D 1 if A is high or Q = D 0 if A is low. (b) Design, build, and test a 2-input multiplexer circuit. (c) Design, build, and test a 4-input multiplexer circuit. 10. (Optional.) Using the oscilloscope s single-shot trigger mode, measure the propagation delay of a NAND gate. 11. (Optional.) Make a ring oscillator with 7 NAND gates connected in series as inverters. Measure the frequency with your oscilloscope and calculate the propagation delay per gate from this. References http://www.ti.com/lit/ds/symlink/sn74s00.pdf http://www.ti.com/lit/ds/symlink/sn74ls283.pdf 6