MA 3260 Lecture 0 - Boolean Algebras (cont.) Friday, October 9, 208. Objectives: Boolean algebras on { 0, }. Before we move on, I wanted to give you a taste of what the connection between Boolean algebra and computers might look like. In simplistic terms, a computer is a bunch of switches wired together with a clock sending out pulses of electricity through this network. What follows is my simplistic understanding of how this could work. More sophisticated components would make this work better, but my version should convey the basic idea. The transistor. Your basic old-fashioned transistor is made out of a material called a semiconductor, originally silicon or germanium, as I remember my community college professor telling me. The semiconductor could be contaminated with something to give it a small positive or negative charge. Then three tiny pieces of this stuff are joined together so that a positive piece is sandwiched between two negative pieces to form an NPN transistor, or a negative piece is sandwiched between two positives to make a PNP transistor. We also have wires attached to each of the three pieces, as shown below. OK. So we somehow wire up the transistor so that there are voltages across the wires. The + s and s are relative, but there is a small voltage from the bottom wire to the one on the right, and a larger voltage from the left wire to the right wire. Current will tend to flow from the s to the + s, with a larger current coming from the left wire. A transistor is a very odd device called an amplifier. If you modulate/fluctuate the voltage on the bottom wire (with a microphone, for example), then the current from the left wire will modulate the same way, but with greater amplitude. With a bunch of transistors, you can take the tiny oscillating current/voltage produced by a microphone and amplify it into large oscillating currents/voltages that power speakers. It turns out that transistors have another interesting property that makes them good for computers. If the voltage from the bottom wire is small enough (0.7 volts for silicon and 0.3 volts for germanium, as I remember), the transistor shuts down, and no current flows through either wire. This makes a transistor a switch controlled by that bottom wire. And Gate. Very roughly, applying a voltage to that bottom wire allows current to flow through the entire transistor. Putting two transistors in series, as shown below, requires voltages on both bottom wires to allow current to flow. If x is one input voltage and y is the second, then the output would correspond to x y (i.e. x and y). Since the power is just there to make things work, we don t need to show it in our diagrams, so we ll use the symbol on the right to represent AND in a circuit diagram.
MA 3260 Lecture 0 - Boolean Algebras (cont.) 2 Or Gate. Wiring two transistors in parallel, as shown below, allows current to flow if there is voltage on at least one of the bottom wires. The output here, therefore, would be x y (i.e. x or y). The circuit symbol for OR is also shown. Not Gate. I don t quite understand the wiring of a Not Gate, which would allow current to flow, if there is not a voltage on the input wire. I believe you need to exploit the concept of a voltage drop across a resistance to make the voltages work out right. I think you put the power voltage on the bottom wire and the input voltage on the left, but I m not at all sure. You can do it, though. The symbol for a NOT gate is shown below. Wiring the gates together. Once you have a gate, you can wire the output voltage to the input of another transistor or gate. For example, consider the Boolean expression () [(x y) x. ] Here, x y will be our notation for x or y. We ll use the symbol x y for x and y, and we ll also use x for not x. The expression [ (x y) x ] corresponds to the circuit diagram In the circuit, we can apply a voltage (or not) at the inputs x and y, and voltages will be propagated through the diagram. For example, suppose x is on, and y is off. This would result in x y being on, and there will be a voltage coming out of the OR gate. The inputs to the AND gate, therefore, will both be on, so the output of the AND gate will on. The input, then, into the NOT gate is on, so the output will be off. If we interpret the existence of a voltage as a, and the lack of a voltage being a 0, the input x = and y = 0 results in an output of [(x y) x ] = 0. Other inputs will result in possibly different outputs, of course. The s, s, and s acting on the 0 s and s form a Boolean algebra, so we can manipulate the expression [ (x y) x ] using the rules of Boolean algebra. For example, an application of DeMorgan s laws says that (2) [(x y) x ] = (x y) x = ( x y) x.
MA 3260 Lecture 0 - Boolean Algebras (cont.) 3 All three of these expressions are equivalent, and so the corresponding circuits will do the same thing. The third expression, ( x y) x corresponds to the following circuit, which give exactly the same outputs as the one above. Addition of binary numbers using circuits Interpreting off s and on s as 0 s and s allows us to do arithmetic with these Boolean circuits. Let me first do a quick review (or explanation) of binary number notation. Binary is another name for the base 2 number system. We typically use base 0. In base 0, the first digit on the right has place value or 0 0, the second digit has place value 0 or 0, the third digit has place value 00 or 0 2, etc. For example, (3) 37 = 3 0 2 + 0 + 7 0 0 = 300 + 0 + 7. In base 2, the place values are powers of 2. For example, (4) 0 2 = 2 3 + 2 2 + 0 2 + 2 0 = 8 + 4 + 0 + = 3. I would like to create a circuit that give outputs that correspond to addition of binary numbers. In regular arithmetic, an addition problem might look like (5) We would start on the right adding 2 and 9 to get, which is 0 +, and the 0 gets carried as a in the 0 s column. (6) Next, we would have (7) Then (8) and finally (9) 2 2 2 2 2
MA 3260 Lecture 0 - Boolean Algebras (cont.) 4 So what would this look like in base 2? Pretty much the same, except that we ll carry 2 s instead of 0 s. For example, consider (0) 0 + 0 Again, starting on the right, + = 0 in base 2. We ll put a 0 in the s column, and carry a 2 as a in the 2 s column. () Continuing on, we get (2) then (3) and then (4) 0 + 0 0 0 + 0 0 0 0 + 0 0 0 0 0 + 0 0 0 0 In designing our addition circuit, we ll need to figure out how to add three single-digit binary numbers, and to carry. Adding two single-digit binary numbers. Our circuit needs to display the following pattern (5) 0 + 0 = 0 0 + = + 0 = + = 0 First off, we ll have two inputs, the two numbers to be added, and we ll have two outputs, the 2 s digit of the output and the s digit of the output. In other words, we want (6) x y 2 s digit s digit 0 0 0 0 0 0 0 0 0 Now, keep in mind that computers do nothing more than input 0 s and s and output 0 s and s. Our job is to make the outputs have a pattern that we want. So randomly guessing, let s consider x y and x y. (7) x y 2 s digit s digit x y x y 0 0 0 0 0 0 0 0 0 0 0 0 0
MA 3260 Lecture 0 - Boolean Algebras (cont.) 5 So now, we see that x y has the right pattern for the 2 s digit. One of our outputs, therefore, should be x y. I m going to add columns for (x y) and (x y) (x y), because I can see a pattern, (8) x y 2 s digit s digit x y x y (x y) (x y) (x y) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 and we can see that the last column is what we want for the s digit. I drew the circuits for this in class, and I don t feel like drawing it here. Adding three single-digit binary numbers. Now we have three inputs x, y, and z, and we have two outputs, the 2 s digit and the s digit. (9) x y z 2 s digit s digit 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 A brute force approach would take each row by itself. For example, the second row says that if we have x =, and y = 0 and z = 0, then the s digit should be a. By itself, that s x y z. The other s in the last column go with x y z, x y z, and x y z. We just want one of these things to happen. The s digit, therefore, must me (20) (x y z) ( x y z) ( x y z) (x y z). I believe this is equivalent to (2) ([(x y) (x y)] z ) ([(x y) (x y)] z ) You can do the 2 s digit similarly.. Add the following base-2 numbers. a. 0 2 + 000 2 b. 2 + 2 c. 000 2 + 0 2 d. 0 2 + 00 2 + 00 2 Homework 0 2. Rewrite the problems in Problem in base 0, and do them in base 0.