22
Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 Fundamentals of Computing Computer Logic

Embed Size (px)

Citation preview

Page 1: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1Fundamentals of Computing

Computer Logic

Page 2: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 (2004-2005)

CS1: Week 18

What’s Logic?Truth TablesSimple Logic Gates Simple Logic Circuits Other Logic Gates Other Logic Circuits

Page 3: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 (2004-2005)

What’s Logic? “The grand aim of all science is to cover the greatest number of empirical facts by

logical deduction from the smallest number of hypotheses or axioms.” Albert Einstein (1879 - 1955)

“Against logic there is no armor like ignorance.” Laurence J. Peter (1919 - 1988)

“A page of history is worth a pound of logic.” Oliver Wendell Holmes Jr. (1841 - 1935)

“Logic is like the sword--those who appeal to it shall perish by it.” Samuel Butler (1835 - 1902)

“Somebody who thinks logically is a nice contrast to the real world.” The Law of Thumb

“Insanity is often the logic of an accurate mind overtaxed.” Oliver Wendell Holmes (1809 - 1894)

Page 4: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 (2004-2005)

It’s Logical, Captain... Logic is concerned with conditions Conditions are either achieved or not achieved There are two states used within logic:

True False

This could also be thought on as: ON and OFF 1 and 0 YES and NO

Page 5: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 (2004-2005)

It’s Logical, Captain... Logic is used in a variety of situations, most

importantly: Real life situations Inside the computer

To perform logical and arithmetic functions Real life logical situations:

There’s a buzzer in your car that sounds when the headlights are on and the door is open

The fire alarm installed in your home will go off if it senses heat or smoke

If I’m not tired then I will go to the pub tonight

Page 6: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 (2004-2005)

Logic Gates Each logic gate has it’s own features:

Symbol Boolean Algebraic Expression Truth Table

Gates can be used to build logic circuits Nothing to do with Bill GATES Even more thankfully, nothing to do with Gareth GATES Each gate has a number of inputs and outputs

Usually multiple inputs and ONE output Circuits can be created to perform situation testing and

produce and output

Page 7: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 (2004-2005)

Truth Tables Truth tables are used to represent the

functionality of a logic gate or circuit Truth tables are constructed by analysing all

possible combinations of values that can be sent to a logic gate or circuit All possible outputs are then calculated

Truth tables allow us to show the functionality of a logic gate or circuit

We can also derive expressions and simplify complex circuits by analysing the truth tables More on that next week

Page 8: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 (2004-2005)

Boolean Algebra Named after George Boole

English Mathematician

Provides a method to express functions and transforms using logical variables Commonly letters of the alphabet

A, B, D, X, Y, Z, etc. E.g.- X + Y = Z

Logic gates and circuits work on the principles of Boolean logic In the computer TRUE or FALSE is represented by a high or low

voltage 1 or 0

Page 9: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 (2004-2005)

AND Gate Two or more inputs All inputs must be true to produce

a true output E.g.- A AND B must be true

All other combinations between inputs result in a false output

Boolean expression for AND gate with 2 inputs (X AND Y): X•Y

X Y OUT0 0 00 1 01 0 01 1 1

Page 10: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 (2004-2005)

OR Gate Two or more inputs At least one input must be true to

produce a true output E.g.- A OR B must be true

Both inputs being true result in a true output Boolean expression for OR

gate with 2 inputs (X OR Y): X+Y

X Y OUT0 0 00 1 11 0 11 1 1

Page 11: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 (2004-2005)

NOT Gate Usually only one input The value of the input is inverted

TRUE becomes FALSE FALSE becomes TRUE

E.g.- A is NOT true/false Boolean expression for OR gate with 1 input

(X): X Sometimes ~X X OUT

0 11 0

Page 12: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 (2004-2005)

Simple Logic Circuits Circuits comprise of one or more logic gates Gates are joined together Usually the process flow moves left to right Truth tables can be constructed for circuits

Helped by deriving Boolean algebra expressions for gates and the output of the circuit

Circuits are used to construct useful logical processes

The computer (CPU) is a complex logic circuit

Page 13: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 (2004-2005)

Simple Logic Circuits E.g.-

A B OUT0 0 10 1 01 0 01 1 1

What’s the truth table?

Page 14: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 (2004-2005)

What’s the truth table?

Simple Logic Circuits E.g.-

OUTPUT= A+B + A•B

A B A+B A•B ~(A+B)~(A+B) + A•B0 0 0 0 1 10 1 1 0 0 01 0 1 0 0 01 1 1 1 0 1

Page 15: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 (2004-2005)

NAND Gate NAND

NOT AND Two or more inputs If all inputs are true then output is false (0) All other combinations between inputs result in a true

output Boolean expression for NAND

gate with 2 inputs (X NAND Y): X•Y

X Y OUT0 0 10 1 11 0 11 1 0

Page 16: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 (2004-2005)

NOR Gate NOR

NOT OR Two or more inputs At least one input must be true to produce a false (0)

output If both inputs are false then output

becomes true Boolean expression for NOR

gate with 2 inputs (X NOR Y): X+Y

X Y OUT0 0 10 1 01 0 01 1 0

Page 17: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 (2004-2005)

XOR Gate XOR

Exclusive OR Sometimes EOR

Two or more inputs Inputs must be different to produce a true output Both inputs being true or false

result in a false output Boolean expression for XOR

gate with 2 inputs (X XOR Y): X•Y + X•Y

X Y OUT0 0 00 1 11 0 11 1 0

Page 18: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 (2004-2005)

XNOR Gate XNOR

Exclusive NOR Two or more inputs One input must be true to produce a false output and

both inputs must be different Both inputs being true or false

result in a true output Boolean expression for XNOR

gate with 2 inputs (X XNOR Y): X•Y + X•Y

X Y OUT0 0 10 1 01 0 01 1 1

Page 19: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 (2004-2005)

Other Logic Circuits Simplify last circuit using NOR gate

Becomes:

Page 20: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 (2004-2005)

Other Logic Circuits E.g.-

OUTPUT= X•Y + (Y•Z + Y•Z)

X

Y

Z

Page 21: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 (2004-2005)

Other Logic Circuits E.g.-

XY

Z

X Y Z ~(X•Y) Y•~Z + ~Y•Z ~(~(X•Y) + (Y•~Z + ~Y•Z))

0 0 0 1 0 0

0 0 1 1 1 0

0 1 0 1 1 0

0 1 1 1 0 0

1 0 0 1 0 0

1 0 1 1 1 0

1 1 0 0 1 0

1 1 1 0 0 1

Page 22: Computer Systems 1 Fundamentals of Computing Computer Logic

Computer Systems 1 (2004-2005)

Do you know anything now? What’s Logic?

Conditions Truth Tables Simple Logic Gates

AND OR NOT

Simple Logic Circuits Other Logic Gates

NAND NOR XOR XNOR

Other Logic Circuits