logic design...digital systems • digital discipline –discrete voltages instead of continuous...

Post on 17-Mar-2020

1 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

NumberSystems

LogicDesign

DigitalSystems

• Digitaldiscipline– Discretevoltagesinsteadofcontinuous– Simplertodesignthananalogcircuits• canbuildmoresophisticatedsystems

– Digitalsystemsreplacinganalogpredecessors• i.e.,digitalcameras,digitaltelevision,cellphones,CDs

2

TheDigitalAbstraction

• Mostphysicalvariablesarecontinuous– Voltageonawire– Frequencyofanoscillation– Positionofamass

• Digitalabstractionconsidersdiscretesubsetofvalues

3

TheAnalyticalEngine

• DesignedbyCharlesBabbagefrom1834–1871– Consideredtobethefirstdigitalcomputer

• Builtfrommechanicalgears,whereeachgearrepresentedadiscretevalue(0-9)– Babbagediedbeforeitwasfinished

4

DigitalDiscipline:BinaryValues

•  Twodiscretevalues:– 1’sand0’s– 1,TRUE,HIGH– 0,FALSE,LOW

•  1and0:voltagelevels,rotatinggears,fluidlevels,etc.•  Digitalcircuitsusevoltagelevelstorepresent1and0•  Bit:Binarydigit

5

•  Introducedbinaryvariables•  Introducedthethreefundamentallogic operations: AND, OR, andNOT

GeorgeBoole,1815-1864

6

NumberSystems

•  Decimalnumbers

•  Binarynumbers

537410 = 5 × 103 + 3 × 102 + 7 × 101 + 4 × 100

fivethousands

10's column

100's column

1000's column

threehundreds

seventens

fourones

1's column

11012 = 1 × 23 + 1 × 22 + 0 × 21 + 1 × 20 = 1310oneeight

2's column

4's column

8's column

onefour

notwo

oneone

1's column

7

•  20=1•  21=2•  22=4•  23=8•  24=16•  25=32•  26=64•  27=128

•  28=256•  29=512•  210=1024•  211=2048•  212=4096•  213=8192•  214=16384•  215=32768

PowersofTwo

8

•  Binarytodecimalconversion:–  Convert100112todecimal

•  Decimaltobinaryconversion:–  Convert4710tobinary

NumberConversion

9

•  Binarytodecimalconversion:–  Convert100112todecimal–  16×1+8×0+4×0+2×1+1×1=1910

•  Decimaltobinaryconversion:–  Convert4710tobinary–  32×1+16×0+8×1+4×1+2×1+1×1=1011112

NumberConversion

10

•  Twomethods:o  Method1:Findthelargestpowerof2thatfits,

subtractandrepeato  Method2:Repeatedlydivideby2,remaindergoes

innextmostsignificantbit

DecimaltoBinaryConversion

11

Method1:Findthelargestpowerof2thatfits,subtractandrepeat5310

Method2:Repeatedlydivideby2,remaindergoesinnextmostsignificantbit5310

DecimaltoBinaryConversion

12

Method1:Findthelargestpowerof2thatfits,subtractandrepeat5310 32×153-32=21 16×121-16=5 4×15-4=1 1×1

=1101012Method2:Repeatedlydivideby2,remaindergoesinnextmostsignificantbit

5310= 53/2=26R1 26/2=13R0

13/2=6R1 6/2=3R0 3/2=1R1 1/2=0R1 =1101012

DecimaltoBinaryConversion

13

Anotherexample:Convert7510tobinary.7510=64+8+2+1=10010112

or

75/2 =37R137/2 =18 R118/2 =9 R09/2 =4 R14/2 =2 R02/2 =1 R01/2 =0 R1

DecimaltoBinaryConversion

14

BinaryValuesandRange

•  N-digitdecimalnumber– Howmanyvalues?– Range?– Example:3-digitdecimalnumber:

•  N-bitbinarynumber– Howmanyvalues?– Range:– Example:3-digitbinarynumber:

15

BinaryValuesandRange

•  N-digitdecimalnumber– Howmanyvalues?10N– Range?[0,10N-1]– Example:3-digitdecimalnumber:•  103=1000possiblevalues• Range:[0,999]

•  N-bitbinarynumber– Howmanyvalues?2N– Range:[0,2N-1]– Example:3-digitbinarynumber:•  23=8possiblevalues• Range:[0,7]=[0002to1112]

16

HexDigit DecimalEquivalent BinaryEquivalent0 0 0000

1 1 0001

2 2 0010

3 3 0011

4 4 0100

5 5 0101

6 6 0110

7 7 0111

8 8 1000

9 9 1001

A 10 1010

B 11 1011

C 12 1100

D 13 1101

E 14 1110

F 15 1111

HexadecimalNumbers

Shorthandforbinary(Base16)

17

•  Hexadecimaltobinaryconversion:–  Convert4AF16(alsowritten0x4AF)tobinary

•  Hexadecimaltodecimalconversion:–  Convert0x4AFtodecimal

HexadecimaltoBinaryConversion

18

•  Hexadecimaltobinaryconversion:–  Convert4AF16(alsowritten0x4AF)tobinary–  0100101011112

•  Hexadecimaltodecimalconversion:–  Convert4AF16todecimal–  162×4+161×10+160×15=119910

HexadecimaltoBinaryConversion

19

Bits,Bytes,Nibbles…

• Bits• Bytes&Nibbles• Bytes

10010110nibble

byte

CEBF9AD7least

significantbyte

mostsignificantbyte

10010110least

significantbit

mostsignificant

bit

20

LargePowersofTwo

• 210=1kilo ≈1000(1024)• 220=1mega ≈1million(1,048,576)• 230=1giga≈1billion(1,073,741,824)

21

EstimatingPowersofTwo

• Whatisthevalueof224?• Howmanyvaluescana32-bitvariablerepresent?

22

EstimatingPowersofTwo

• Whatisthevalueof224?24×220≈16million• Howmanyvaluescana32-bitvariablerepresent?22×230≈4billion

23

Addition

•  Decimal

•  Binary

37345168+

10110011+

24

Addition

•  Decimal

•  Binary

37345168+8902

carries 11

10110011+1110

11 carries

25

BinaryAdditionExamples

•  Addthefollowing4-bitbinarynumbers

•  Addthefollowing4-bitbinarynumbers

10010101+

10110110+

26

BinaryAdditionExamples

•  Addthefollowing4-bitbinarynumbers

•  Addthefollowing4-bitbinarynumbers

10010101+1110

1

10110110+10001

111

Overflow!27

•  Digitalsystemsoperateonafixednumberofbits

• Overflow:whenresultistoobigtofitintheavailablenumberofbits

Overflow

28

• Wehavetworepresentation:•  Sign/MagnitudeNumbers•  Two’sComplementNumbers

SignedBinaryNumbers

29

•  1signbit,N-1magnitudebits

•  Signbitisthemostsignificant(left-most)bit–  Positivenumber:signbit=0–  Negativenumber:signbit=1

Sign/MagnitudeNumbers

30

•  Example,4-bitsign/magrepresentationsof±6:+6=0110

-6=1110•  RangeofanN-bitsign/magnitudenumber: [-(2N-1-1),2N-1-1]

Sign/MagnitudeNumbers

31

Problems:•  Additiondoesn’twork,forexample-6+6:

1110+011010100(wrong!)

•  Tworepresentationsof0(±0):

10000000

Sign/MagnitudeNumbers

32

•  Don’thavesameproblemsassign/magnitudenumbers:– Additionworks– Singlerepresentationfor0

Two’sComplementNumbers

33

•  msbhasvalueof-2N-1

•  Mostpositive4-bitnumber:0111•  Mostnegative4-bitnumber:1000•  Themostsignificantbitstillindicatesthesign(1=negative,0=positive)

•  RangeofanN-bittwo’scomplementnumber:[-(2N-1),2N-1-1]

+

Two’sComplementNumbers

34

•  “TakingtheTwo’scomplement”flipsthesignofatwo’scomplementnumber

•  Method:1.  Invertthebits2.  Add1

•  Example:Flipthesignof310=001121.   11002.   +11101=-310

“TakingtheTwo’sComplement”

35

•  Takethetwo’scomplementof610=01102

•  Whatisthedecimalvalueofthetwo’scomplementnumber10012?

Two’sComplementExamples

36

•  Takethetwo’scomplementof610=011021.  10012.  +110102=-610

•  Whatisthedecimalvalueofthetwo’scomplementnumber10012?

1.  01102.  +101112=710,so10012=-710

Two’sComplementExamples

37

•  Add6+(-6)usingtwo’scomplementnumbers

•  Add-2+3usingtwo’scomplementnumbers

Two’sComplementAddition

+01101010

+11100011

38

•  Add6+(-6)usingtwo’scomplementnumbers

•  Add-2+3usingtwo’scomplementnumbers

Two’sComplementAddition

+0110101010000

111

+1110001110001

111

39

IncreasingBitWidth

ExtendnumberfromNtoMbits(M>N):–  Sign-extension–  Zero-extension

40

•  Signbitcopiedtomsb’s•  Numbervalueissame

•  Example1:–  4-bitrepresentationof3=0011–  8-bitsign-extendedvalue:00000011

•  Example2:–  4-bitrepresentationof-5=1011–  8-bitsign-extendedvalue:11111011

Sign-Extension

41

•  Zeroscopiedtomsb’s•  Valuechangesfornegativenumbers

•  Example1:–  4-bitvalue=0011=310–  8-bitzero-extendedvalue:00000011=310

•  Example2:–  4-bitvalue=1011=-510–  8-bitzero-extendedvalue:00001011=1110

Zero-Extension

42

NumberSystemComparison

NumberSystem RangeUnsigned [0,2N-1]

Sign/Magnitude [-(2N-1-1),2N-1-1]

Two’sComplement [-2N-1,2N-1-1]

Forexample,4-bitrepresentation:

-8

1000 1001

-7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

1010 1011 1100 1101 1110 1111 0000 0001 0010 0011 0100 0101 0110 0111 Two's Complement

10001001101010111100110111101111

00000001 0010 0011 0100 0101 0110 0111

1000 1001 1010 1011 1100 1101 1110 11110000 0001 0010 0011 0100 0101 0110 0111

Sign/Magnitude

Unsigned

43

top related