cse140: components and design techniques for digital ... · pdf filecse140: components and...

68
CSE140: Components and Design Techniques CSE140: Components and Design Techniques for Digital Systems Introduction Tajana Simunic Rosing 1

Upload: dangcong

Post on 12-Mar-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

CSE140: Components and Design Techniques CSE140: Components and Design Techniques for Digital Systems

Introduction

Tajana Simunic Rosing

1

Welcome to CSE 140!

• Course time: T/Th 2-3:20pm, WLH 2205• Discussion session: M 11-11:50pm WLH 2205• Discussion session: M 11-11:50pm, WLH 2205• Instructor: Tajana Simunic Rosing

• Email: [email protected]; please put CSE140 in the subject line• Ph. 858 534-4868• Office Hours: Tu/Th 1-2pm CSE 2118• Office Hours: Tu/Th 1-2pm, CSE 2118

• Instructor’s Assistant: Sheila Manalo – Email: [email protected]– Phone: (858) 534-8873

• TA: Raid Ayoub• TA: Raid Ayoub– Email: [email protected]– Office hours: WF: 10:00am-12:00pm

• TA: Chun Chen Liu– Email: chl084@ucsd edu– Email: [email protected]– Office hours: TBA

• Class Website:– http://www.cse.ucsd.edu/classes/sp08/cse140/

• Grades: http://webct ucsd edu

2

Grades: http://webct.ucsd.edu

Course Descriptionp• Prerequisites:

– CSE 20 or Math 15A, and CSE 30. – CSE 140L must be taken concurrently

• Objective:– Introduce digital components and system design conceptsIntroduce digital components and system design concepts

• Grading– Homeworks (~8): 15%

• Lowest grade on the HW will be dropped• Lowest grade on the HW will be dropped• HW picked up at beginning of the class, 0 pts if late

– Two midterms: 25% each• No makeup exams; exceptions only forNo makeup exams; exceptions only for

– Documented illness (signed doctor’s statement), death in the family– Final exam: 35%

• Regrade requests: turn in a written request at the end of the

3

g q qclass where your work (HW or exam) is returned

Textbook and Recommended Readingsg• Required textbook:

– Contemporary Logic DesignContemporary Logic Design by R. Katz & G. Borriello

• Recommended textbook:– Digital Design by F. Vahid

• Lecture slides are derived from

4

the slides designed for both books

Why Study Digital Design?y y g g• Look “under the hood” of computers

– Become a better programmer when p gaware of hardware resource issues

• Everyday devices becoming digitalEnables:– Enables:

• Better devices: Better sound recorders, cameras, cars, cell phones, medical devices,...devices,...

• New devices: Video games, PDAs, ...– Known as “embedded systems”

• Thousands of new devices every year• Thousands of new devices every year• Designers needed: Potential career

PortableSatellites DVD

playersVideo

recordersMusical

instruments

51995

music players

1997 1999

Cell phones

2001 2003

Cameras TVs ???

2005 2007

Implementing Digital Systems: Programming Microprocessors Vs Designing Digital CircuitsMicroprocessors Vs. Designing Digital Circuits

Desired motion-at-night detectorProgrammed

microprocessorCustom designed

digital circuit

I3I4

I2I1I0

P3P4

P2P1P0

I5I6I7

P5P6P7

6

Digital Design: When Microprocessors Aren’t Good EnoughEnough

• With microprocessors so easy, cheap, and available, why design a digital circuit?

Micro-processor

Image Sensor

Execution time

design a digital circuit?– Microprocessor may be too

slow– Or too big, power hungry, or

(a)

p

(Read,Compress,and Store)Memory

costly

(b)Sample digital camera task execution times (in seconds) on a microprocessor versus a digital

Readcircuit

Compresscircuit

Image Sensor

seconds) on a microprocessor versus a digital circuit: Memory Store

circuit

Compressi it

Image Sensor Readi it

Task Microprocessor Custom Digital Circuit

(c)

circuit

Microprocessor(Store)Memory

circuitRead 5 0.1

Compress 8 0.5

Store 1 0.8

7

What will we learn in this class?• The language of logic design

– Boolean algebra logic minimization state timing CAD toolsBoolean algebra, logic minimization, state, timing, CAD tools

• The concept of state in digital systems– analogous to variables and program counters in software systems

• How to specify/simulate/compile/realize our designs (140L)– hardware description languages– tools to simulate the workings of our designs– tools to simulate the workings of our designs– logic compilers to synthesize the hardware blocks of our designs– mapping onto programmable hardware

• Contrast with software design– sequential and parallel implementations– specify algorithm as well as computing/storage resources it will use

8

specify algorithm as well as computing/storage resources it will use

A quick history lessonq y• 1850: George Boole invents Boolean algebra

– maps logical propositions to symbols– permits manipulation of logic statements using mathematics

• 1938: Claude Shannon links Boolean algebra to switches– his Masters’ thesishis Masters thesis

• 1945: John von Neumann develops the first stored program computer

its switching elements are vacuum tubes (a big advance from relays)– its switching elements are vacuum tubes (a big advance from relays)

• 1946: ENIAC . . . The world’s first completely electronic computer– 18,000 vacuum tubes– several hundred multiplications per minute

• 1947: Shockley, Brittain, and Bardeen invent the transistor– replaces vacuum tubes

9

– enable integration of multiple devices into one package– gateway to modern electronics

What is logic design?g g• What is design?

• What is logic design?

10

Computation: abstract vs. implementationp p• Up to now, computation has been abstract (paper, programs)• This class is about physically implementing computation using physical

devices that use voltages to represent digital values• Basic units of computation:

– Representation: 0, 1 – Assignment x=y– Data operations x+y-5– Control

• Sequential statements a;b;c• Conditionals if x==1 then y• Loops for (i=1; i<10; i++)• Procedures a; proc (…); b;

• We will study how each of these can be implemented in hardware

11

Outline• What we will cover in the next few lectures:

– Number representationsAnalog vs Digital• Analog vs. Digital

• Digital representations:– Binary– Hexadecimal

O t l– Octal• Binary addition and subtraction• Binary multiplication, division

– Switches, MOS transistors, Logic gates• What is a switch• How a transistor operates• Building logic gates out of transistors• Building larger functions from logic gates• Building larger functions from logic gates

– Boolean algebra• Properties• How Boolean algebra can be used to design logic circuits

12

CSE140: Components and Design Techniques CSE140: Components and Design Techniques for Digital Systems

Number representations &Binary arithmeticBinary arithmetic

Tajana Simunic Rosing

13

What Does “Digital” Mean?g• Analog signal

– Infinite possible valuesE l i

• Digital signal– Finite possible values

E b tt d• Ex: voltage on a wire created by microphone

Sound waves

th

• Ex: button pressed on a keypad

i h

which movesthe magnet,

move themembrane, 3 421

2 digital signal

e e

microphone

which createscurrent in the nearby wire

analog signal

4Possible values:1 00 1 01 2 0000009

Possible values:0 1 2 3 4

valu

e

valu

e0123

1.00, 1.01, 2.0000009, ... infinite possibilities

0, 1, 2, 3, or 4.That’s it.

14

time time0

Digital Signals with Only Two Values: Binaryg g y y

• Binary digital signal -- only twopossible values

e

One Binary digIT is a BIT

Popular because it is easy storing a single

valu

e

10bit, and simple to operate using two values

(0,1) with transistorstime

0

15

Example of Digitization Benefitp g• Analog signal (e.g., audio)

may lose quality– Voltage levels not Vo

lts

23

ansm

issi

onl p

hone

)

23

saved/copied/transmitted perfectly

• Digitized version enables near-perfect save/cpy/trn.

time01 original signal

leng

thy

tra(e

.g, c

ell

time01 received signal

How fix -- higher, lower, ?01 10 11 10 11– “Sample” voltage at

particular rate, save sample using bit encoding

– Voltage levels still not kept

g

rans

mis

sion

ell p

hone

)

01 10 11 10 11

Volts

digitized signal1

a2d

1perfectly

– But we can distinguish 0s from 1s le

ngth

y tr

(e.g

, cedigitized signal

time01

timeCan fix -- easily distinguish 0s

01

01 10 11 10 11

Volts

23

d2aLet bit encoding be: 1 V: “01”2 V: “10”3 V: “11”

and 1s, restoreDigitized signal notperfect re-creation,but higher sampling

t d bit

16time

V

012rate and more bits per

encoding brings closer.

Digitized Audio: Compression Benefitg p• Digitized audio can be

compressedExample compression scheme:

00 --> 000000000001 > 1111111111

– e.g., MP3s– A CD can hold about 20

songs uncompressed, 0000000000 0000000000 0000001111 1111111111

01 --> 11111111111X --> X

g pbut about 200 compressed

• Compression also done

0000000000 0000000000 0000001111 1111111111

Compression also done on digitized pictures (jpeg), movies (mpeg), and moreand more

• Digitization has many other benefits too

17

How Do We Encode Data as Binary for Our Digital System?System?

• Some inputs inherently binary 0

button

1

analogphenomena

binary– Button: not pressed (0),

pressed (1)• Some inputs inherently

green blackbluered

0 00

sensors andother inputs

electricsignal digital

data Some inputs inherently digital– Just need encoding in

binarylti b tt i t

red

0 10

green blackblue

green blackblueredDigital System

A2Ddigital

data

– e.g., multi-button input: encode red=001, blue=010, ...

• Some inputs analog

1 00

green blackbluered

air 33 degrees

Digital System

D2A

digitaldata

digitaldata

Some inputs analog– Need analog-to-digital

conversiontemperature

sensoractuators andother outputs

electricsignal

180 0 1 10 0 0 0

How to Encode Text: ASCII, Unicode• ASCII: 7- (or 8-) bit

encoding of each letter, 10100101010011

RS

Symbol Encoding

11100101110011

r

Symbol Encoding

g ,number, or symbol

• Unicode: Increasingly pop lar 16 bit bit encoding

10100111010100100110010011101000101

STLNE

11100111110100110110011011101100101

stlnepopular 16-bit bit encoding

– Encodes characters from various world languages

011000001011100001001

0.<tab>

011100101000010100000

9!

<space>

What does this ASCII bit sequence represent?1010010 1000101 1010011 1010100

19

How to Encode Numbers: Binary Numbersy• Each position represents a

quantity; symbol in position means how many of that quantity– Base ten (decimal)

104 103 102

5 2 3

101 100• Ten symbols: 0, 1, 2, ..., 8, and 9• More than 9 -- next position

– So each position power of 10N thi i l b t b 10

104 103 102 101 100

• Nothing special about base 10 --used because we have 10 fingers

– Base two (binary) 1 0 1( y)• Two symbols: 0 and 1• More than 1 -- next position

– So each position power of 2

24 23 22 21 20

20

How to Encode Numbers: Binary Numbersy

• Working with binary numbers– In base ten, helps to know

powers of 10• one, ten, hundred, thousand, ten

th d

24 23 22 21 2029 28 27 26 25

512 256 128 64 32 16 8 4 2 1

thousand, ...– In base two, helps to know

powers of 2

21

Converting from Decimal to Binary Numbers: Subtraction Method (Easy for Humans)Method (Easy for Humans)

• Goal– Get the binary weights to add up to– Get the binary weights to add up to

the decimal quantity• Work from left to right

• Subtraction method:12481632

– To make the job easier, we just subtract a selected binary weight from the (remaining) quantity

• Then we have a new remainingThen, we have a new remaining quantity, and we start again (from the present binary position)

• Stop when remaining quantity is 0

22

Converting from Decimal to Binary Numbers: Division Method (Good for Computers)Method (Good for Computers)

• Divide decimal number by 2 and insert remainder into new binary number.– Continue dividing quotient by 2 until the quotient is 0.

• Example: Convert decimal number 12 to binaryDecimal Number Binary Numberec a u be a y u be

23

Bases Sixteen & Eightg

• Base sixteen– nice because each position represents four4 3 2

8 A F

1 0 nice because each position represents four base two positions

– Used as compact means to write binary numbers

– Basic digits: 0-9, A-F

164 163 162

8

1000 1010 1111

A F

161 160

– Known as hexadecimal, or just hex• Base eight

– Used in some digital designs– Each position represents three base two

iti

000000010010

012

hex binary

100010011010

89A

hex binary

positions– Basic digits: 0-7

00100011010001010110

23456

10101011110011011110

ABCDE Write 11110000 in hex

01117 1111F

Write 11110000 in octal

24

Write 11110000 in octal

Sign and magnitudeg g• One bit dedicate to sign (positive or negative)

– sign: 0 = positive (or zero), 1 = negative

• Rest represent the absolute value or magnitude– three low order bits: 0 (000) thru 7 (111)

• Range for n bits

000011111110

1101 0010

0001

+0+1

+2–5

–6

–7Range for n bits– +/– 2n–1 –1 (two representations for 0)

• Cumbersome addition/subtraction t it d

0011

1011

1101

1100

0100

0010+3

+4–3

–4– must compare magnitudes

to determine sign of result

0111

10101001

10000110

0101+5

+60

–1

–2

25

+7–0

1s complementp• If N is a positive number, then the negative of N (its 1s complement or

N' ) is N' = (2n– 1) – N (n= total # bits); higher order -> sign bit• Shortcut: bit wise complement (7->-7 0111->1000

• Subtraction implemented by 1s complement and then addition• Problem: two representations of zerop

000011111110 0001

+0

+1

2

–1

–0

0011

1110

1101

1100

0010

0001 +2

+3–3

–2

0111

1011

10101001

10000110

0101

0100 +4

+5–5

–4

26

01111000 +6

+7–7

–6

2s complementp• 1s complement with negative numbers shifted one position clockwise

– only one representation for 0, high-order bit -> sign bit, more negative #sIf N i iti b th th ti f N (it 2 l t• If N is a positive number, then the negative of N (its 2s complement or N* ) is N* = 2n – N

– Shortcut: bit-wise complement plus 17 > 7 : 0111 > 1000 + 1 = 1001 ( 7) +0–1– 7 -> -7 : 0111 -> 1000 + 1 = 1001 (-7)

– -7 -> 7: 1001 -> 0110 + 1 = 0111 (7) +1

+2–3

–2 000011111110

1101 0010

0001

+3

+4–5

–4 0011

1011

1101

1100

10100100

0010

+5

+6–7

–6

0111

10101001

10000110

0101

27

+7–8

2s complement addition and subtractionp• Simple addition and subtraction

– makes 2s complement the unanimous choice for integers in computers

• Check overflow conditions:– Add two positive numbers and get a negative, or two negative and get

positive

4

+ 3

– 4

+ (– 3)

7 – 7

4

– 3

– 4

+ 3

281 – 1

Overflow• Sometimes result can’t be represented with given number

of bits– Either too large magnitude of positive or negative– e.g., 4-bit two’s complement addition of 0111+0001 (7+1=8). But

4-bit two’s complement can’t represent number >74 bit two s complement can t represent number >7• 0111+0001 = 1000 WRONG answer, 1000 in two’s complement is -

8, not +8– Adder/subtractor should indicate when overflow has occurred soAdder/subtractor should indicate when overflow has occurred, so

result can be discarded

29

Detecting Overflow: Method 1g• Assuming 4-bit two’s complement numbers, can detect overflow by

detecting when the two numbers’ sign bits are the same but are different from the result’s sign bitdifferent from the result s sign bit– If the two numbers’ sign bits are different, overflow is impossible

• Adding a positive and negative can’t exceed largest magnitude positive or negative

• Simple circuit– overflow = a3’b3’s3 + a3b3s3’– Include “overflow” output bit on adder/subtractor

sign bits

0 1 1 1

+ 00 0 1

sign bits

1 1 1 1

+ 01 0 0

1 0 0 0

+ 10 1 1

1 0 0 0overflow

(a)

0 1 1 1overflow

(b)

1 1 1 1no overflow

(c)

30

If the numbers’ sign bits have the same value, whichdiffers from the result’s sign bit, overflow has occurred.

Detecting Overflow: Method 2g• Even simpler method: Detect difference between carry-in to sign bit

and carry-out from sign bitYields simpler circ it o erflo c3 or c4• Yields simpler circuit: overflow = c3 xor c4

0 1 11 1 1

1

+ 00 0 1

1 1 10 0 0

1

+ 01 0 0

1 0 00 0 0

0

+ 10 1 1

10 010 0 0overflow

(a)

0 1 1 1overflow

(b)

1 1 1 1no overflow

(c)( ) ( ) ( )

If the carry into the sign bit column differs from thecarry out of that column, overflow has occurred.

31

Multiplicationp• Generalized representation of multiplication by hand

32

Division• Repeated subtraction

– Set quotient to 0Example: • Dividend: 101; Divisor: 10

– Repeat while dividend >= divisor

• Subtract divisor from dividendAdd 1 to quotient

Dividend Quotient101 - 0 +

Dividend: 101; Divisor: 10

• Add 1 to quotient– When dividend < divisor:

• Reminder = dividend• Quotient is correct

101 010 111 - 1 +10 1Quotient is correct 10 11 10

33

Summary of number representationy p• Conversion between basis

– DecimalBi– Binary

– Octal– Hex

• Addition & subtraction in binary• Addition & subtraction in binary– Overflow detection

• Multiplication– Partial products– Partial products

• For demo see: http://courses.cs.vt.edu/~cs1104/BuildingBlocks/multiply.010.html

• Division– Repeated subtraction

• For demo see: http://courses.cs.vt.edu/~cs1104/BuildingBlocks/Binary.Divide.html

34

CSE140: Components and Design Techniques for Digital Systems

Combinational circuit building blocks:Switches and gates

Tajana Simunic Rosing

35

Combinational Circuit Introduction

Digital circuit

Combinational

digital circuit

1a

b

1F0

• We’ll start with a simple form of circuit:– Combinational circuit

A digital circ it hose o tp ts depend solel on

g

1a

b

?F0

• A digital circuit whose outputs depend solely on the present combination of the circuit inputs’ values

• Built out of simple components: switches andSequential

digital circuit

36

Built out of simple components: switches and gates

g

Switches• Electronic switches are the basis of

binary digital circuitsy g– Electrical terminology

• Voltage: Difference in electric potential between two points

4.5 A4 5 A 9V

+–p– Analogous to water pressure

• Current: Flow of charged particles– Analogous to water flow

4.5 A

2 ohms

• Resistance: Tendency of wire to resist current flow

– Analogous to water pipe diameterV I * R (Oh ’ L )

4.5 A

0V 9V

• V = I * R (Ohm’s Law)

37

Switches• A switch has three parts

– Source input, and output• Current wants to flow from source “off”

controlinput

Current wants to flow from source input to output

– Control input• Voltage that controls whether that

“ ”

outputsourceinput

controlinput

current can flow

• The amazing shrinking switch– 1930s: Relays

“on”

outputsourceinput

input

(b)– 1940s: Vacuum tubes– 1950s: Discrete transistor– 1960s: Integrated circuits (ICs)

(b)

• Initially just a few transistors on IC• Then tens, hundreds, thousands...

relay vacuum tube

discrete transistor

IC

38

quarter(to see the relative size)

The CMOS Circuit• CMOS circuit

– Consists of N and PMOS transistors– Both N and PMOS are similar to basic switches– Rp ~ 3 Rn => PMOS in series is much slower than NMOS

A positivevoltage here

...attracts electrons here,turning the channel

gateoxide

voltage here... turning the channelbetween source and drain

into aconductor. 01gate

nMOS

source drainoxide IC package

does notconduct

conducts

(a) IC 1gate

pMOS0

Silicon -- not quite a conductor or insulator:Semiconductor

39

does notconduct

conductsSemiconductor

MOS networks

X what is the relationship

between x and y?

3v

Y 0 volts

x y

3 volts0 volts

3 volts0v 0 volts

3 volts

40

Two input networksp

3

X Y

what is the relationship

between x, y and z?

3v

Zx y z1 z2

l

0v

Z1

X Y 0 volts

3 volts

0 volts

0 volts

0 volts

3 volts3v

X Y

0 volts

3 volts

3 volts

3 voltsZ2

410v

Relating Boolean Algebra to Digital Designg g g gBooleanalgebra

(mid-1800s)

Boole’s intent: formalizehuman thought Fx

xy F

ORNOT

Fxy

AND

Symbol

Switches(1930s)

x0011

y0101

F0001

x0011

y0101

F0111

x01

F10

Truth tableFor telephoneswitching and other

electronic uses

Shannon (1938)Showed applicationof Boolean algebrato design of switch-

based circuits x

1

Transistori it

1y

x

1

F = x’ F’

Digital design

x

0

F= x or ycircuit

0

xy0

• Implement logic operators using transistors– Call those implementations logic gates

1

x y

F’

1

F=x & y

420

y

x 0

NOT/OR/AND Logic Gate Timing Diagramsg g g

0

1x

1

0x

1

1

0x

11

0

time

F

y

F1

0

0y

F1

0

0

timetime time

43

More Gatesxy

xy FF

NORNAND XOR XNOR1

x y

1

xNAND NOR

x001

y010

F100

x001

y010

F011

x001

y010

F100

x001

y010

F111

Fx

yx

y

y

F

• NAND: Opposite of AND (“NOT AND”)• NOR: Opposite of OR (“NOT OR”)

11

01

01

11

01

10

11

01

00

11

01

10 0 0

• NOR: Opposite of OR ( NOT OR )• XOR: Exactly 1 input is 1, for 2-input

XOR. (For more inputs -- odd number of 1s)

• XNOR: Opposite of XOR (“NOT XOR”)

44

CMOS Example• The rules:

– NMOS connects to GND, PMOS to power supply Vdd, p pp y– Duality of NMOS and PMOS – Rp ~ 3 Rn => PMOS in series is much slower than NMOS in series

Implement Z sing CMOS Z (A + BC)’• Implement Z using CMOS: Z = (A + BC)’

45

Another CMOS Example• Implement F using CMOS: F=A*(B+C)

46

Completeness of NANDp• Any logic function can be implemented using just NAND

gates. Likewise for NOR. Why?g y– Need AND, OR and NOT

47

Building Circuits Using Gatesg g

• Motion-in-dark example

48

Example: Converting a Logic Equation to a Circuit of Logic Gates of Logic Gates

• Convert the following equation to logic gates: F = a AND NOT( b OR NOT(c) )F = a AND NOT( b OR NOT(c) )

49

Another example• More than one way to map expressions to gates

e.g., Z = A’ • B’ • (C + D) = (A’ • (B’ • (C + D)))g , ( ) ( ( ( )))– Use only two input gates, or using also three input gates

50

Waveform view of logic functionsg• Just a sideways truth table

– but note how edges don’t line up exactly

time

g p y– it takes time for a gate to switch its output!

time

51change in Y takes time to "propagate" through gates

Example: Seat Belt Warning Light Systemp g g y

• Design circuit for warning lightS• Sensors– s=1: seat belt fastened– k=1: key inserted

p=1: person in the seat– p=1: person in the seat• Capture logic equation

– What are conditions for warning light to go on?g t to go o

• Convert equation to circuit

52

Converting to Logic Equationsg g q• Q1. A fire sprinkler system should spray water if high

heat is sensed and the system is set to enabled.a

y– Let variable h represent “high heat is sensed,” e represent

“enabled,” and F represent “spraying water.” – Answer: F =Answer: F

• Q2. A car alarm should sound if the alarm is enabled, and either the car is shaken or the door is opened. – Let a represent “alarm is enabled,” s represent “car is shaken,” d

represent “door is opened,” and F represent “alarm sounds.” – Answer: F =

53

CSE140: Components and Design Techniques CSE140: Components and Design Techniques for Digital Systems

Boolean algebra

Tajana Simunic Rosing

54

Boolean Algebra and its Relation to Digital Circuitsg g• To understand the benefits of “logic gates” vs. switches, we should first

understand Boolean algebra• “Traditional” algebra

– Variable represent real numbers– Operators operate on variables, return real numbersp p ,

• An algebraic structure consists of– a set of elements B

binary operations { + • }– binary operations { + , • }– and a unary operation { ’ }– such that the following axioms hold:

1. the set B contains at least two elements: a, b2. closure: a + b is in B a • b is in B3. commutativity: a + b = b + a a • b = b • a4. associativity: a + (b + c) = (a + b) + c a • (b • c) = (a • b) • c

55

5. identity: a + 0 = a a • 1 = a6. distributivity: a + (b • c) = (a + b) • (a + c) a • (b + c) = (a • b) + (a • c)7. complementarity: a + a’ = 1 a • a’ = 0

Boolean algebrag• Boolean Algebra

– B = {0, 1} { , }– Variables represent 0 or 1 only– Operators return 0 or 1 only

Basic operators

a0011

b0101

AND0001 a b OR– Basic operators

• • is logical AND: a AND b returns 1 only when both a=1 and b=1• + is logical OR: a OR b returns 1 if either (or both) a=1 or b=1

’ is logical NOT: NOT a returns the opposite of a (1 if a=0 0 if a=1)

1 1 1 a0011

b0101

OR0111

• ’ is logical NOT: NOT a returns the opposite of a (1 if a=0, 0 if a=1) – All algebraic axioms hold a

01

NOT10

56

Axioms and theorems of Boolean algebrag• identity

1. X + 0 = X 1D. X • 1 = X• null

2. X + 1 = 1 2D. X • 0 = 0• idempotency:

3. X + X = X 3D. X • X = X• involution:

4. (X’)’ = X• complementarity:

5. X + X’ = 1 5D. X • X’ = 0• commutativity:y

6. X + Y = Y + X 6D. X • Y = Y • X• associativity:

7. (X + Y) + Z = X + (Y + Z) 7D. (X • Y) • Z = X • (Y • Z)

57

( ) ( ) ( ) ( )

Axioms and theorems of Boolean algebra (cont’d)• distributivity:

8. X • (Y + Z) = (X • Y) + (X • Z) 8D. X + (Y • Z) = (X + Y) • (X + Z)

• uniting:9. X • Y + X • Y’ = X 9D. (X + Y) • (X + Y’) = X

• absorption:10. X + X • Y = X 10D. X • (X + Y) = X11. (X + Y’) • Y = X • Y 11D. (X • Y’) + Y = X + Y

• factoring:12. (X + Y) • (X’ + Z) = 12D. X • Y + X’ • Z =

X • Z + X’ • Y (X + Z) • (X’ + Y)• concensus:

13. (X • Y) + (Y • Z) + (X’ • Z) = 13D. (X + Y) • (Y + Z) • (X’ + Z) =X • Y + X’ • Z (X + Y) • (X’ + Z)

58

Axioms and theorems of Boolean algebra (cont’d)

• de Morgan’s:g14. (X + Y + ...)’ = X’ • Y’ • ...14D. (X • Y • ...)’ = X’ + Y’ +

...li d d M ’• generalized de Morgan’s:

15. f’(X1,X2,...,Xn,0,1,+,•) = f(X1’,X2’,...,Xn’,1,0,•,+)

• establishes relationship between • and +

59

Axioms and theorems of Boolean algebra (cont’d)• Duality

– a dual of a Boolean expression is derived by replacing • by +, + by •, 0 by 1, and 1 by 0, and leaving variables unchanged

– any theorem that can be proven is thus also proven for its dual!– a meta-theorem (a theorem about theorems)

• duality:16. X + Y + ... ⇔ X • Y • ...

• generalized duality:generalized duality:17. f (X1,X2,...,Xn,0,1,+,•) ⇔ f(X1,X2,...,Xn,1,0,•,+)

Diff t th d M ’ L• Different than deMorgan’s Law– this is a statement about theorems– this is not a way to manipulate (re-write) expressions

60

Proving theoremsg• Using the axioms of Boolean algebra:

– e.g., prove the theorem: X • Y + X • Y’ = Xg , p

distributivity (8) X • Y + X • Y’ = X • (Y + Y’)complementarity (5) X • (Y + Y’) = X • (1)p y ( ) ( ) ( )identity (1D) X • (1) = X

– e.g., prove the theorem: X + X • Y = X

identity (1D) X + X • Y = X • 1 + X • Yidentity (1D) X + X • Y = X • 1 + X • Ydistributivity (8) X • 1 + X • Y = X • (1 + Y)identity (2) X • (1 + Y) = X • (1)identity (1D) X • (1) = X

61

Proving theorems exampleg p• Prove the following using the laws of Boolean algebra:

– (X • Y) + (Y • Z) + (X’ • Z) = X • Y + X’ • Z( ) ( ) ( )

(X • Y) + (Y • Z) + (X’ • Z)

identity (X • Y) + (1) • (Y • Z) + (X’ • Z)

complementarity (X • Y) + (X’ + X) • (Y • Z) + (X’ • Z)

distributivity (X • Y) + (X’ • Y • Z) + (X • Y • Z) + (X’ • Z)

commutativity (X • Y) + (X • Y • Z) + (X’ • Y • Z) + (X’ • Z)

factoring (X • Y) • (1 + Z) + (X’ • Z) • (1 + Y)

null (X • Y) • (1) + (X’ • Z) • (1)

62identity (X • Y) + (X’ • Z)

Proving theorems (perfect induction)g (p )• Using perfect induction (complete truth table):

– e.g., de Morgan’s:

X Y X’ Y’ (X + Y)’ X’ • Y’

g , g

(X + Y)’ = X’ • Y’NOR is equivalent to AND with inputs complemented

X Y X Y (X + Y) X • Y0 0 1 10 1 1 01 0 0 11 1 0 0

(X • Y)’ = X’ + Y’NAND is equivalent to OR

X Y X’ Y’ (X • Y)’ X’ + Y’0 0 1 10 1 1 01 0 0 1with inputs complemented 1 0 0 11 1 0 0

63

A simple example: 1-bit binary adderp p y• Inputs: A, B, Carry-in• Outputs: Sum Carry-out A A A A A

CinCout

Outputs: Sum, Carry out A A A A AB B B B B

S S S S S

AB

Cout

SA B Cin Cout S

CinCout0 0 0

0 0 10 1 00 1 11 0 01 0 11 1 01 1 1

64

Boolean Algebra Operator Precedenceg p• Evaluate the following Boolean equations, assuming a=1, b=1, c=0, d=1.

– Q1. F = a * b + c. • Answer: F =Answer: F

– Q2. F = ab + c.• Answer: F =

– Q3. F = ab’. • Answer: F =

a

– Q4. F = (ac)’. • Answer: F =

– Q5. F = (a + b’) * c + d’.Q5. F (a b ) c d . • Answer: F =

65

Example that Applies Boolean Algebra Propertiesp pp g p• Want automatic door opener

circuit (e.g., for grocery store)• Found inexpensive chip that

computes:– Output: f=1 opens door– Inputs:

• p=1: person detectedh 1 it h f i h ld

• f = c’hp + c’hp’ + c’h’p– Can we use it?

• h=1: switch forcing hold open• c=1: key forcing closed

– Want open door when• h=1 and c=0, or,• h=0 and p=1 and c=0

66

Boolean Algebra: Additional Propertiesg pAircraft lavatory sign example

• Behavior • Alternative: Instead of lighting “Available ” light• Three lavatories, each with

sensor (a, b, c), equals 1 if door locked

• Light “Available” sign (S) if any lavatory available

• Instead of lighting “Available,” light “Occupied”

any lavatory available• Equation and circuit

67

Summaryy• What we covered thus far:

– Number representationsp– Switches, MOS transistors, Logic gates– Boolean algebra

Supplement: NMOS and PMOS transistor characteristics– Supplement: NMOS and PMOS transistor characteristics

• What is next:– Combinatorial logic:

• Representations• Minimization• Implementations

68