Download - Section 10.3
1
Section 10.3
Logic Gates
2
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
3
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
4
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
5
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
6
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
7
Example 1
Construct a circuit to produce the output: xyx )(
8
Example 2
Construct a circuit to produce the output:
))(( zyxzyx
9
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
10
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
11
Example 3
The resulting circuit looks like this:
12
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
13
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
14
• 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 +
Example 4
yx
15
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) = zyxzyxzyxxyz
16
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
17
Half adder
Table below shows the possible inputs and correspondingoutputs of a half adder: x and y are the input bits, s is theirsum, and c is the carry:
x y s c1 1 0 11 0 1 00 1 1 00 0 0 0
From the table we can see that c = xyand s = yxyx or ))(( xyyx
18
Half adder
19
Full adderInputs to full adder are the bits x and y and the carry ci; outputsare the sum bit s and the new carry ci+1
x y ci s ci+1
1 1 1 1 11 1 0 0 11 0 1 0 11 0 0 1 00 1 1 0 10 1 0 1 00 0 1 1 00 0 0 0 0
The outputs of the full adder, which arethe sum bit and the new carry, are givenby the sum-of-products expansions:
iiii cyxcyxcyxxyc Sum:
Carry: iiii ycxcyxcxyxyc
20
Full adder
A full adder can be built using half adders to produce the desired output:
21
Section 10.3
Logic Gates