CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture...

27
Introduction to Digital Logic CS 64: Computer Organization and Design Logic Lecture #12 Ziad Matni Dept. of Computer Science, UCSB

Transcript of CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture...

Page 1: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

IntroductiontoDigitalLogic

CS64:ComputerOrganizationandDesignLogicLecture#12

ZiadMatni

Dept.ofComputerScience,UCSB

Page 2: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

Administrative

•  Lab#6isexercisesthatdonotrequireacomputer–  YouwillneedknowledgefromtheThu.lectureaswell–  Youare*excused*fromgoingtolabthisweek,butT.Aswillbetheretohelp,ifyouneedit

•  Lab#6willbedueendofdayFriday

•  Lab#7willbedifferent…!

2/27/18 Matni,CS64,Wi18 2

Page 3: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

LectureOutline

•  IntrotoBinary(Digital)LogicGates

•  TruthTableConstruction

•  LogicFunctionsandtheirSimplifications

•  TheLawsofBinaryLogic

2/27/18 Matni,CS64,Wi18 3

Page 4: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

Digitali.e.BinaryLogic

•  Electroniccircuitswhenusedincomputersareaseriesofswitches

•  2possiblestates:eitherON(1)andOFF(0)

•  Perfectforbinarylogicrepresentation!

2/27/18 Matni,CS64,Wi18 4

Page 5: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

BasicBuildingBlocksofDigitalLogic

•  Sameasthebitwiseoperators:ANDORXORNOTetc...

•  Weoftenrefertotheseas“logicgates”indigitaldesign

2/27/18 Matni,CS64,Wi18 5

Page 6: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

ElectronicCircuitLogicEquivalents

2/27/18 6

Page 7: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

GraphicalSymbolsandTruthTablesNOT

A Aor!A0 11 0

2/27/18 Matni,CS64,Wi18 7

Page 8: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

GraphicalSymbolsandTruthTablesANDandNAND

A B A.B0 0 00 1 01 0 01 1 1

2/27/18 Matni,CS64,Wi18 8

A B A.Bor!(A.B)

0 0 10 1 11 0 11 1 0

Page 9: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

GraphicalSymbolsandTruthTablesORandNOR

A B A+B0 0 00 1 11 0 11 1 1

2/27/18 Matni,CS64,Wi18 9

A B A+Bor!(A+B)

0 0 10 1 01 0 01 1 0

Page 10: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

GraphicalSymbolsandTruthTablesXOR

2/27/18 Matni,CS64,Wi18 10

A B A+B0 0 00 1 11 0 11 1 0

Page 11: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

ConstructingTruthTables

•  T.TscanbeappliedtoANYdigitalcircuit

•  TheyshowALLpossibleinputswithALLpossibleoutputs

•  NumberofentriesintheT.T.

=2N,whereNisthenumberofinputs

2/27/18 Matni,CS64,Wi18 11

Page 12: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

Example:ConstructingtheT.Tofa1-bitAdder

•  Recallthe1-bitadder:

•  3inputs:I1andI2andCI–  Input1,Input2,andCarry-In–  HowmanyentriesintheT.T.isthat?

•  2outputs:RandCO–  Result,andCarry-Out–  Youcanhavemultipleoutputs:eachwillstilldependonsomecombinationoftheinputs

2/27/18 Matni,CS64,Wi18 12

EXAMPLE:

1 1

0

0

1

Page 13: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

Example:ConstructingtheT.Tofa1-bitAdder

T.TConstructionTime!

2/27/18 Matni,CS64,Wi18 13

Page 14: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

Example:ConstructingtheT.Tofa1-bitAdder

# I1 I2 CI CO R0 0 0 0 0 01 0 0 1 0 12 0 1 0 0 13 0 1 1 1 04 1 0 0 0 15 1 0 1 1 06 1 1 0 1 07 1 1 1 1 1

2/27/18 Matni,CS64,Wi18 14

INPUTS OUTPUTS

Page 15: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

LogicFunctions•  AnoutputfunctionFcanbeseenasacombinationof1or

moreinputs•  Example:

F=A.B+C (allsinglebits)EquivalentinC/C++:

booleanf(booleana,booleanb,booleanc) { return((a&b)|c) }

2/27/18 Matni,CS64,Wi18 15

Page 16: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

ORandANDasSumandProduct•  Logicfunctionsareoftenexpressedwithbasiclogicbuilding

blocks,likeORsandANDsandNOTs,etc…

•  ORissometimesreferredtoas“logicalsum”–  Orsometimes“logicunion”–  Partlywhyit’ssymbolizedas“+”–  BUTIT’SNOTTHESAMEASNUMERICALADDITION!!!!!!

•  ANDas“logicalproduct”–  Orsometimes“logicdisjunction”–  Partlywhyit’ssymbolizedas“.”–  BUTIT’SNOTTHESAMEASNUMERICALMULTIPLICATION!!!!!!

2/27/18 Matni,CS64,Wi18 16

Page 17: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

Example

•  AXORBtakesthevalue“1”(i.e.isTRUE)ifandonlyif–  A=0,B=1 i.e.!A.BisTRUE,or–  A=1,B=0 i.e.A.!BisTRUE

•  Inotherwords, AXORB isTRUEiff(ifandonlyif) A!B+!ABisTRUE

A+B=!A.B+A.!BWhichcanalsobewrittenas:A.B+A.B

2/27/18 Matni,CS64,Wi18 17

A B A+B0 0 00 1 11 0 11 1 0

Page 18: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

RepresentingtheCircuitGraphically

A+B=!A.B+A.!B

Matni,CS64,Wi18

A B A+B0 0 00 1 11 0 11 1 0

Q:Doesittakeanytimeforaelectronicsignaltogothru3“layers”oflogicgates?

A:Ideally,NO,itallhappenssimultaneously.Inreality,OFCOURSEittakestime(it’scalledlatency)

A

A

B

B

A+B

Page 19: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

WhatisTheLogicalFunctionforTheHalfAdder?

# I1 I2 CO R0 0 0 0 01 0 1 0 12 1 0 0 13 1 1 1 0

2/27/18 Matni,CS64,Wi18 19

INPUTS OUTPUTS

CO=I1.I2R=I1+I2

HalfAdder1-bitadderthatdoesnothaveaCarry-In(Ci)bit.Thislogicblockhasonly21-bitinputsand21-bitoutputs

Ourattempttodescribetheoutputsasfunctions

oftheinputs:

Page 20: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

WhatisTheLogicalFunctionforAFull1-bitadder?

# I1 I2 CI CO R0 0 0 0 0 01 0 0 1 0 12 0 1 0 0 13 0 1 1 1 04 1 0 0 0 15 1 0 1 1 06 1 1 0 1 07 1 1 1 1 1

2/27/18 Matni,CS64,Wi18 20

INPUTS OUTPUTS

Ans.: CO=!I1.I2.CI+I1.!I2.CI+I1.I2.!CI+I1.I2.CI R=!I1.!I2.CI+!I1.I2.!CI+I1.!I2.!CI+I1.I2.CI

Page 21: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

MinimizationofBinaryLogic•  Why?

–  It’sWAYeasiertoreadandunderstand…:/–  Savesmemory(software)and/orphysicalspace(hardware)–  Runsfaster/performsbetter

•  Why?

•  Forexample,whenwedotheT.T.for(seedemoonboard): X=A.B+A.!B+B.!A,wefindthatitisthesameas

(savedourselvesabunchoflogicgates!)

2/27/18 Matni,CS64,Wi18 21

A+B

Page 22: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

UsingT.Tsvs.UsingLogicRules•  Inanefforttosimplifyalogicfunction,wedon’talways

havetouseT.Ts–wecanuselogicrulesinstead

Example:Whatarethefollowinglogicoutcomes?A.AA+A

A.1A+1

A.0A+0

2/27/18 Matni,CS64,Wi18 22

AAA10A

Page 23: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

UsingT.Tsvs.UsingLogicRules•  BinaryLogicworksinAssociativeways–  (A.B).C isthesameas A.(B.C)–  (A+B)+C isthesameas A+(B+C)

•  ItalsoworksinDistributiveways–  (A+B).C isthesameas:A.C+B.C–  (A+B).(A+C) isthesameas:

A.A+A.C+B.A+B.C=A+A.C+A.B+B.C=A+B.C

2/27/18 Matni,CS64,Wi18 23

Page 24: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

MoreExamplesofMinimizationa.k.aSimplification

•  Simplify: R =A.B+!A.B =(A+!A).B =B

•  Simplify: R =!ABCD+ABCD+!AB!CD+AB!CD

=BCD(A+!A)+!AB!CD+AB!CD =BCD+B!CD(!A+A) =BCD+B!CD =BD(C+!C) =BD

2/27/18 Matni,CS64,Wi18 24

Let’sverifyitwithatruth-table

Let’sverifyitwithatruth-table

Note:often,theANDdotsymbol(.)isomitted,butunderstoodtobethere(likewithmultiplicationdotsymbol)

Page 25: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

MoreSimplificationExercises

•  Simplify: R =!A!BC+!A!B!C+!ABC+!AB!C+A!BC =!A(C+!C)+!AB(C+!C)+A!BC =!A+!AB+A!BC =!A+A!BC

•  ReformulateusingonlyANDandNOTlogic:

R =!AC+!BC =C(!A+!B) =C.!(A.B) ßDeMorgan’sLaw

2/27/18 Matni,CS64,Wi18 25

Let’sverifyitwithatruth-table

Page 26: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

Important:LawsofBinaryLogic

2/27/18 Matni,CS64,Wi18 26

Page 27: CS 64: Computer Organization and Design Logic …– You will need knowledge from the Thu. lecture as well – You are *excused* from going to lab this week, but T.As will be there

2/27/18 Matni,CS64,Wi18 27