CARLETON UNIVERSITY Deparment of Electronics ELEC 267 Switching Circuits January 9, 24 Laboratory. Overview; A 4-Bit Binary Comparator Take a 4-bit binary number X, for example. This number is made of bits which we will call X 3 X 2 X X. Thus X 3 =, X 2 =, X =, X =. The full number is written in boldface, the individual bits are written with a subscript. A binary comparator compares two binary numbers nd Y. It can tell if X is larger, smaller, or equal to Y. The comparator in this lab will compare two 4-bit nonnegative binary numbers, and displays the result on two lights called Lx and Ly.. FIGURE : A block diagram of the circuit, showing the meanings of Lx and Ly, and some example comparisions X 3 X 2 X X COMPARAT Y 2 Y Y 4 DATA BITS LEAST SIGNIFC BIT LEAST SIGNIFC BIT Lx Ly Lx Ly X = Y X > Y X < Y never happens Examples X Y X 3 X 2 X X Y 2 Y Y Lx Ly This comparator is designed by breaking the circuit into subcircuits or blocks. Each block does a small part of the job. They can be made identical, which will save design work. Each subcircuit will compare two 2- bit numbers, say and Y a. The outputs will be two -bit numbers a and a.. FIGURE 2: Subcircuit or block Y a X 3 X 2 X X Y 2 Y Y COMP ba a a b Y ab = Y a > Y a < Y a Unused Output COMP 32 X 32 2 COMP 32 Lx Ly COMP X Y X 32 2 Complete block diagram to compare two 4-bit numbers. All three blocks can be made identical. However it turns out that COMP 32 can be made simpler than the other two. J.Knight, January 9, 4 SWITCHING CIRCUITS Lab -
J.Knight, January 9, 4 SWITCHING CIRCUITS Lab-2 These outputs have been carefully chosen so that the outputs of two comparators like COMP 32 and COMP, shown below, can be themselves compared with an identical subcircuit COMP 32. The output of this third block will be the desired output to lights Lx and Ly FIGURE 3: Examples:. X 3 = X 2 = = Y 2 = X = X = Y = Y = X 3 = X 2 = = Y 2 = X = X = Y = Y = COMP 32 X 32 = 2 = COMP X = Y = COMP 32 X 32 = 2 = COMP X = Y = COMP 32 X 32 = 2 = Lx Ly COMP 32 X 32 = 2 = Lx Ly Prelab This must be prepared prior to the scheduled lab session. It will be checked near the start of the lab. The prelab is the basis for the design part of the lab report. However it usually need considerable cleaning up and editing for the final report.. Complete the comparison algorithm, written like a computer program, for the generic subcircuit for the iterative comparator. Generic means for arbitrary inputs like and Y a rather than for specific inputs like X 2 X and Y 2 Y Y a Algorithm for one block of the comparator circuit. Inputs:, Y a, Outputs: a, a If ( > Y a ) Then a =; a ----- If - - - - - - - COMP ba a a.2 Complete the truth table, Fig. 4 (p. 3), for the generic comparator subcircuit, relating the inputs to the outputs. The inputs in the figure are in binary order. You may want to arrange them so the terms with no outputs are at the bottom., as shown in Fig. 5 (p. 3) Lab -2 SWITCHING CIRCUITS J.Knight, January 9, 24
FIGURE 4: Incomplete the truth table for the generic comparator subcircuit. COMP ba a a Ya b Y ab = Y a > Y a < Y a Unused Output inputs outputs Y a a a Boolean function to get a output for this particular line of inputs a a Comparison as 2-bit binary numbers. = Y a Y a < Y a Y a < Y a Y a < Y a Y a > Y a = Y a Y a < Y a Y a < Y a - - - - - - - - - - - - - - - - - - - - - -.3 Find the logical equations relating,, Y a to a, a. To do this note for the partial table that a = for:,,, Y a =,,, or,,, or,,, or,,, or,,,... If,,, Y a =,,, then Y a = = If,,, Y a =,,, then Y a = = If,,, Y a =,,, then Y a = = If,,, Y a =,,, then Y a = = If,,, Y a =,,, then Y a = = With Boolean ( ) and (+) : a = Y a + Y a + Y a + Y a + Y a... () Complete the logic equation for the full truth table..4 Simplify the logic equation to reduce its size. For example,in partial expression (),the 2nd, 3rd, 4th and 5rd terms have two common variables, and. Considering only those four terms gives - Y a + Y a + Y a + Y a. = Y a + Y a + Y a + Y a = ( Y a + Y a + Y a + Y a ) = ( (Y a + Y a ) + (Y a + Y a )) (2) = you do the rest FIGURE 5: Rearrangement of part of Fig. 4 so the a = terms are all at the top and handy. inputs outputs Y a a a - Expression to generate a Y a Y a Y a Y a Y a Y a All other inputs J.Knight,January 9, 4 SWITCHING CIRCUITS Lab -3
J.Knight, January 9, 4 SWITCHING CIRCUITS Lab-4 Since X+X=X, one can reuse terms that were included in the previous reduction. Note the st and 3rd terms have two common letters. We need to include the st term in the final expression. The 3rd term can be reused - Y a + Y a = Y a ( + ) (3) FIGURE 6: = you do the rest Simplify the complete equations for a and a. a and a can be reduced to 6 letters each. Y a.5 From the equations one can draw a schematic diagram using, and INVERT gates. Fig. 6 shows the schematic for expression (2) ed with (3). Draw a schematic of a circuit to implement the complete equations for a and a. using, and INVERT gates..6 When drawing a theoretical circuit for a logic equation, one typically uses and gates. In practice, N and N gates are much easier to build. Thus real logic gets built with NS and Ns. On the Tektron logic board, used in the lab, the available gates are mostly Ns and Ns. The board contains only four 2-input s and four 2-input s. These are barely enough s and s for one comparator block. However you can easily implement your circuits using N gates, and perhaps N gates as described below. Use the diagram for the Tektron Logic Lab to complete the list of the number of gates of each type. Expression (2) ed with (3). This is only part of the circuit. for a. One way of implementing the complete circuit for a. It allows using a dual 2-input - gate. 2-input 3-input 2-input 2-input X 4 avaliable 3 avaliable 4 avaliable 4 avaliable 4 avaliable dual 2-input -N.7 There is a very important theorem, called DeMorgan s theorem ( Fig. 7) that will soon be done in the lectures. It proves that an N gate is equivalent to an gate with both its inputs inverted. The top of the following figure shows the two equivalent forms for N and for N. The lower part of Fig. 7 shows how to implement circuits made of operations followed by, using only N gates. Fig. 8 shows some more ways of using Ns and Ns instead of s and s....8 Revise the circuit for the generic comparator subcircuit using only gates which are plentiful in the Tektron Logic Lab. The same circuit is used for both of the COMP 32 and COMP blocks in Fig. 2. Be sure there are enough gates of the right types to build two subcircuits. The lower COMP 32 block will turns out to be simpler because it never gets some inputs. Lab -4 SWITCHING CIRCUITS J.Knight, January 9, 24
FIGURE 7: A B N C A B N C D E N F D E N F A B = C = A + B D + E = F = D E By using DeMorgan on the N gate symbol, one gets another equally valid symbol.- Both the with a negated output and the with negated inputs are equally valid symbols for a N gate. Ns with 3 or more inputs convert to an with 3 or more inverted inputs. In the same way, the N gate has two equally valid forms. X W U V Z = X W + U V X W U V N N N Z = X W + U V X W U V N N N Z = X W + U V Placing inverting circles back-to-back makes it possible to add negating circles to the outputs of the s, and the inputs of the, without changing the circuit function. This changes all three gates to N gates. FIGURE 8: Conversion of Fig. 6b to more common gates using DeMorgan s theorem. N N N N.9 Consider the lower block COMP 32. From the table in part X 3 X 2 X X Fig., observe that the output X 32, 2 =, never comes out Y 2 Y of block COMP 32 Thus in rows where X 32, 2 =, in the Y table for COMP 32, one can write down any output one wants; it will never happen. It turns out that the COMP 32 COMP 32 COMP circuit is smaller if these outputs are made 2,X 32 =,. X 32 X Y We call such outputs (for inputs that never happen) don t 32 Y care outputs. We could have made these outputs, or if we had wanted to, but making them gives a smaller circuit. COMP 32 X 32 2 The truth table of part Fig. 4 has been partially redone in Fig. 9 to apply to COMP 32 under the conditions that X 32, 2 =, and/or X, Y =, never happens. Thus the corresponding outputs have been made,. J.Knight,January 9, 4 SWITCHING CIRCUITS Lab -5
J.Knight, January 9, 4 SWITCHING CIRCUITS Lab-6 FIGURE 9:. Part of the truth table for COMP 32 with don t care outputs made,. X 32 X 2 Y X 32 2 Comparison as Y a a a 2-bit binary. = Y a Y a < Y a Y a < Y a Y a < Y a Y a > Y a make these outputs, Never happens =Y a Y a < Y a - - - - - a a make these outputs, Never happens =Y a - - - - - - - - - -. Minimize the logic equation for COMP 32 so X 32 uses an, two s, and some inverters. 2 uses the same. Write the equations.. Draw a circuit for COMP 32 using s s and inverters..2 Redraw the circuit using only gates available on the logic trainer, which were not previously used..3 The complete circuit you are about to build is likely larger than anything you have wired before. It is essential to plan it systematically. We strongly suggest the following Take the schematic diagrams of the generic subcircuit using the gates available on the logic trainer. Make sure it is uncrowded and neat without scratched out lines, or bubbles, s changed to s by scratching over the top, ditto marks, etc. Write the equation for the subcircuit underneath it. Use a separate sheet of paper from the wiring diagrams described next. Take the diagram of the Tektron logic lab. Select the gates you will use for each subcircuit. Draw a balloon around the gates in each block or, as done on the right, each half-block. Fill in the detailed wiring within the subcircuit. Use textual names to show the input and output signals entering or leaving your balloon, rather than the wires. If you show too many long wires your drawing will be so cluttered it will become useless. However the short wires inside the balloons are best drawn as lines. Y a Y a X 3 X 3 X 2 a = + Y a ( + ) COMP 32(X) X 32 a COMP ba (Y) a X 3 Y ab COMP 32(Y) Try using different colors. X 2 balloon Y 2 X 3 Lab -6 SWITCHING CIRCUITS J.Knight, January 9, 24
.4 The bottom block COMP 32 is simpler. Again be sure you have a good clear schematic using the available gates. Then add the wiring to the Tektron layout sheet. END OF PRELAB Constructing Your Circuit. The typical student is psychologically unprepared for the fact that they could make a wiring mistake. They tend to wire the complete circuit and then test it. We suggest you build and test the circuit in parts. Debugging five gates is far easier than debugging twenty. 2.5 Choose four switches for the X input and four for the Y input. Choose lights for X 32 = L x and 2 = L y, the final output. Choose two other pairs of lights to display X 32-2, and X -Y.. 2.6 Before wiring, make sure the wires you use look clean on the ends. Also push each lead firmly into the hole. Grip the lead by the metal tip and give it a very slight ( degree) twist after inserting 2.7 Construct COMP : Wire the subcircuit. Wire X and Y to the switches. Wire X and Y to the switches. Wire X and Y their two lights. Test the subcircuit COMP. SWITCH OUTPUTS LAMP INPUTS X 32 2 X Y 2 3 4 5 6 7 8 X3 X2 X X Y3 Y2 Y Y Lx Ly 9 Y X X X COMP X Y X Y 3 7 Y X 4 X 8 Y 9 2.8 Construct COMP 32 in the same way. Test it too! 2.9 Construct COMP 32. Do not be in a hurry to connect it to the other blocks. First: Wire X 32 and 2 to two spare switches such as such as 8 and 9, to aid debugging. There are no more spare switches, but you can temporarily wire X and Y to the push buttons. J.Knight,January 9, 4 SWITCHING CIRCUITS Lab -7
J.Knight, January 9, 4 SWITCHING CIRCUITS Lab-8 Wire outputs X 32 and 2 to the L x and L y lights respectively. You can now test the subcircuit COMP 32. Remember the don t care inputs should give output PULSE OUTPUTS temporary connections 2.2 Remove the temporary connections and wire the complete comparator as it should be. 2.2 Debugging: Sometimes the plastic connection boards are loose in the connector in wooden frame. Push the heel of your hand on the plastic on the side of the board and push them in. If you are really having trouble it may be useful to use two trainers. Place them side by side and connect the GROUND pins by a lead. This will give you some extra debugging lights, and some less cluttered space. Check out and Clean Up 2 3 X 32 X X 32 COMP 32 Y 2 2 Lx Ly When your circuit works, demonstrate it to the teaching assistant. After demonstrating clean up your board, sort the leads, and put them back in their box. We have a contract with Lord Voldemont to deal with students who do not clean up. 9 Lab -8 SWITCHING CIRCUITS J.Knight, January 9, 24
Partial Layout of The Tektron Logic Lab. You should not need the JK flip-flops and RS latches which were omitted. PULSE OUTPUTS 2 3 CONSTANT OUTPUTS TEKTRON COMPUTER LOGIC LAB SWITCH OUTPUTS LAMP INPUTS 2 3 4 5 6 7 8 9 J.Knight, January 9, 4 Lab -9 DIGITAL ELECTRONICS
Partial Layout of The Tektron Logic Lab. You should not need the JK flip-flops and RS latches which were omitted. PULSE OUTPUTS 2 3 CONSTANT OUTPUTS TEKTRON COMPUTER LOGIC LAB SWITCH OUTPUTS LAMP INPUTS 2 3 4 5 6 7 8 9 J.Knight, January 9, 4 Lab - DIGITAL ELECTRONICS