Section 10.3 Logic Gates 1 Boolean algebra & circuits • Boolean algebra is used to model electronic circuitry – Each input & output of electronic device can be thought of as a member of the set {0,1} – Electronic devices made up of circuits – Each circuit can be designed using rules of Boolean algebra 2 Logic gates • Basic elements of circuits are called gates • Each type of gate implements a Boolean operation (e.g. Boolean product, Boolean sum, complement) • Combinational circuits or gating networks: – give output that depends only on input, not current state of circuit – have no memory capability 3 Elements of combinational circuits Inverter: accepts value of a Boolean variable as input and produces the complement as output OR gate: inputs are values of 2 or more Boolean variables; output is Boolean sum of their values 4 Elements of combinational circuits AND gate: inputs are values of 2 or more Boolean variables; output is Boolean product of their values AND gates and OR gates may have multiple inputs 5 Combinations of gates • Combinational circuits can be constructed using combinations of inverters, OR gates, and AND gates • In such circuit combinations, some gates may share inputs • Output from a gate may be used as input by another element 6 Example 1 Construct a circuit to produce the output: ( x y ) x 7 Example 2 Construct a circuit to produce the output: ( x y z )( x y z ) 8 Example 3 • We can use circuits to model various types of computational operations • For example, suppose a committee of 3 people decides issues for an organization; each one votes yes or no for each proposal that arises, and a proposal passes if it receives at least 2 yes votes 9 Example 3 • Let x, y and z represent the voters’ decisions - a value of 1 means a yes vote, and 0 means a no vote • We can design a circuit to output 1 when two or more of x, y and z are 1 by representing the Boolean function xy + xz + yz 10 Example 3 The resulting circuit looks like this: 11 Example 4 • Light fixtures may be controlled by more than one switch • Circuits for such fixtures must be designed so that flipping any switch in the circuit will turn the light on when it is off and off when it is on • We will look at such a circuit with 2 switches 12 Example 4 • We represent the two switches as Boolean variables x and y • When a switch is open, its value is 0, and 1 when it is closed • We need to define a function F(x,y)=1 when the light is on, 0 when it is off 13 Example 4 • Suppose the light is on if both switches are closed; then F(1,1) = 1 • Opening either switch turns the light off, so F(0,1) = F(1,0) = 0 • If one switch is open (and the light is off), opening the other switch will turn the light on, so F(0,0) = 1 • We can get these results if F(x,y) = xy + x y 14 Example 4 A three-way circuit can be designed in a similar fashion; for the three switches x,y,z the function F(x,y,z) = xyz x y z x yz x y z 15 Adders • Logic circuits can be used to carry out addition of two positive integers from their binary expansions • Such circuits form the basis of computer arithmetic • Half adder: a circuit that takes 2 bits as input, outputting a sum bit and a carry bit; a half adder is a multiple output circuit • A full adder computes the sum and carry bits when 2 bits and a carry are added 16 Half adder Table below shows the possible inputs and corresponding outputs of a half adder: x and y are the input bits, s is their sum, and c is the carry: x 1 1 0 0 y 1 0 1 0 s 0 1 1 0 c 1 0 0 0 From the table we can see that c = xy and s = x y x y or ( x y )( xy) 17 Half adder 18 Full adder Inputs to full adder are the bits x and y and the carry ci; outputs are the sum bit s and the new carry ci+1 x 1 1 1 1 0 0 0 0 y 1 1 0 0 1 1 0 0 ci 1 0 1 0 1 0 1 0 s 1 0 0 1 0 1 1 0 ci+1 1 1 1 0 1 0 0 0 The outputs of the full adder, which are the sum bit and the new carry, are given by the sum-of-products expansions: Sum: xyci x y ci x y ci x yci Carry: xyci xyci x yci x yci 19 Full adder A full adder can be built using half adders to produce the desired output: 20 Section 10.3 Logic Gates 21