ddca_ch1 - class1 (1)

Upload: yerhard-lalangui-fernandez

Post on 06-Jul-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    1/43

    C 1

     

     

    , 2

    C 1

    D H . H

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    2/43

    C 1

    •   •  

    •  

    •   •  

    •  

    •  

    •   •  

    C 1 ::

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    3/43

    C 1

    •  

     –  C , I, , .

    •   $21 1985 $300 2011

    B

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    4/43

    C 1

    H

       f  o  c  u  s

      o   f   t

       h   i  s

      c  o  u  r  s  e

    programs

    device drivers

    instructionsregisters

    datapathscontrollers

    addersmemories

    AND gatesNOT gates

    amplifiers

    filters

    transistorsdiodes

    electrons

    A

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    5/43

    C 1

    •  

     –    –  F

     –  

    •  D  

    D A

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    6/43

    C 1

    •    –  1 0

     –  1, E, HIGH, H –  0, FAE, ,

    •  1 0 , , , .

    •  D   1 0

    •       

    D D: B

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    7/43

    C 1

    537410

     =

    1  0 '   s  c  ol   umn

    1  0  0 '   s 

     c  ol   umn

    1  0  0  0 

    '   s  c  ol   umn

    1 '   s  c  o

    l   umn

      11012 =

    2 '   s  c  ol   u

    mn

    4 '   s  c  ol   u

    mn

     8 '   s  c  ol   u

    mn

    1 '   s  c  ol   u

    mn

    • Decimal numbers

    • Binary numbers

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    8/43

    C 1

    537410

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

    thousands

    1  0 '   s  c  ol   umn

    1  0  0 '   s 

     c  ol   umn

    1  0  0  0 '   s  c  ol   umn

    threehundreds

    seventens

    fourones

    1 '   s  c  o

    l   umn

    11012 = 1 × 23 + 1 × 22 + 0 × 21 + 1 × 20 = 13

    10oneeight

    2 '   s  c  ol   u

    mn

    4 '   s  c  ol   u

    mn

     8 '   s  c  ol   u

    mn

    onefour

    notwo

    oneone

    1 '   s  c  ol   u

    mn

    • Decimal numbers

    • Binary numbers

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    9/43

    C 1

    • 20 =

    • 21 =

    • 22 =

    • 23 =

    • 24 =

    • 25 =

    • 26

    =• 27 =

    • 28 =

    • 29 =

    • 210 =

    • 211 =

    • 212 =

    • 213 =

    • 214

    =• 215 =

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    10/43

    C 1

    • 20 = 1

    • 21 = 2

    • 22 = 4

    • 23 = 8

    • 24 = 16

    • 25 = 32

    • 26

    = 64• 27 = 128

    • Handy to memorize up to 210

    • 28 = 256

    • 29 = 512

    • 210 = 1024

    • 211 = 2048

    • 212 = 4096

    • 213 = 8192

    • 214

    = 16384• 215 = 32768

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    11/43

    C 1

    •   224?

    •  H 32

    ?

    E

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    12/43

    C 1

    •   224?

     24 × 220 ≈ 16

    •  H 32

    ?22 × 230 ≈ 4

    E

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    13/43

    C 1

    • Decimal to binary conversion:– Convert 100112 to decimal

    • Decimal to binary conversion:– Convert 4710 to binary

    C

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    14/43

    C 1

    • Decimal to binary conversion:– Convert 100112 to decimal

    – 16×1 + 8×0 + 4×0 + 2×1 + 1×1 = 1910

    • Decimal to binary conversion:– Convert 4710 to binary

    – 32×1 + 16×0 + 8×1 + 4×1 + 2×1 + 1×1 = 1011112

    C

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    15/43

    C 1

    •    –  H ?

     –  ? –  E: 3 :

    •    –  H ?

     –  : –  E: 3 :

    B

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    16/43

    C 1

    •    –  H ? 10 

     –  ? 0, 10 

    1 –  E: 3 :

    •   103 1000 •   0,

    •    –  H ? 2 

     –  : 0, 2  1

     –  E: 3 :•   23 •   0, 0002  1112

    B

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    17/43

    C 1

    Hex Digit Decimal Equivalent Binary Equivalent

    0 0

    1 1

    2 2

    3 3

    4 4

    5 5

    6 6

    7 7

    8 8

    9 9

    A 10

    B 11C 12

    D 13

    E 14

    F 15

    H

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    18/43

    C 1

    Hex Digit Decimal Equivalent Binary Equivalent

    0 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

    H

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    19/43

    C 1

    •   B

    •  B &

    •   B

    10010110nibble

    byte

    CEBF9AD7least

    significantbyte

    mostsignificant

    byte

    10010110least

    significantbit

    most

    significantbit

    B, B,

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    20/43

    C 1

    37345168+

    8902

    carries11

    10110011+

    1110

     11 carries

    • Decimal

    • Binary

    A

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    21/43

    C 1

    1001

    0101+

    10110110+

    • Add the following

    4-bit binary

    numbers

    • Add the following

    4-bit binary

    numbers

    B A E

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    22/43

    C 1

    1001

    0101+1110

    1

    10110110+

    10001

    111

    • Add the following

    4-bit binary

    numbers

    • Add the following

    4-bit binary

    numbers

    Overflow!

    B A E

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    23/43

    C 1

    1001

    0101+1110

    1

    10110110+

    10001

    111

    • Substract the

    following 4-bit

    binary numbers

    • Substract the

    following 4-bit

    binary numbers

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    24/43

    C 1

    • Sign/Magnitude Numbers

    • Two’s Complement Numbers

    B

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    25/43

    C 1

    • 1 sign bit,  N -1 magnitude bits

    • Sign bit is the most significant (left-most) bit

    – Positive number: sign bit = 0

    – Negative number: sign bit = 1

    • Example, 4-bit sign/mag representations of ± 6:+6 =

    - 6 =

    • Range of an  N -bit sign/magnitude number:

    { }

    1

    1 2 2 1 0

    2

    0

    : , , , ,

    ( 1) 2n

     N N 

    n

    a   i

    i

    i

    a a a a a

     A a−

    − −

    =

    = − ∑

    L

    /

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    26/43

    C 1

    • 1 sign bit,  N -1 magnitude bits

    • Sign bit is the most significant (left-most) bit

    – Positive number: sign bit = 0

    – Negative number: sign bit = 1

    • Example, 4-bit sign/mag representations of ± 6:+6 = 0110

    - 6 = 1110

    • Range of an  N -bit sign/magnitude number:[-(2N-1-1), 2N-1-1]

    { }

    1

    1 2 2 1 0

    2

    0

    : , , , ,

    ( 1) 2n

     N N 

    n

    a   i

    i

    i

    a a a a a

     A a−

    − −

    =

    = − ∑

    L

    /

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    27/43

    C 1

    • Problems:

    – Addition doesn’t work, for example -6 + 6:

    1110

    + 0110

    10100 (wrong!)

    – Two representations of 0 (± 0):

    1000

    0000

    /

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    28/43

    C 1

    • Don’t have same problems as sign/magnitude

    numbers:– Addition works

    – Single representation for 0

    C

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    29/43

    C 1

    ( )

    21

    1

    02 2

    n

    n i

    n i

    i A a a

    =

    = − +∑

    • MSB has value of -2 N -1

    • Most positive 4-bit number:

    • Most negative 4-bit number:

    • The most significant bit still indicates the sign

    (1 = negative, 0 = positive)• Range of an  N -bit two’s comp number:

    C

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    30/43

    C 1

    ( )

    21

    1

    02 2

    n

    n i

    n i

    i A a a

    =

    = − +∑

    • Msb has value of -2 N -1

    • Most positive 4-bit number: 0111

    • Most negative 4-bit number: 1000

    • The most significant bit still indicates the sign

    (1 = negative, 0 = positive)• Range of an  N -bit two’s comp number:

    [-(2N-1), 2N-1-1]

    C

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    31/43

    C 1

    • Flip the sign of a two’s complement number

    • Method:

    1. Invert the bits

    2. Add 1

    • Example: Flip the sign of 310 = 00112

    C

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    32/43

    C 1

    • Flip the sign of a two’s complement number

    • Method:

    1. Invert the bits

    2. Add 1

    • Example: Flip the sign of 310 = 001121. 1100

    2. + 1

    1101 = -310

    C

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    33/43

    C 1

    • Take the two’s complement of 610 = 01102

    • What is the decimal value of 10012?

    C E

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    34/43

    C 1

    • Take the two’s complement of 610 = 011021. 1001

    2. + 1

    10102 = -610

    • What is the decimal value of the two’s

    complement number 10012?

    1. 01102. + 1

    01112 = 710, so 10012 = -710

    C E

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    35/43

    C 1

    +01101010

    +11100011

    • Add 6 + (-6) using two’s complement

    numbers

    • Add -2 + 3 using two’s complement numbers

    C A

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    36/43

    C 1

    +01101010

    10000

    111

    +11100011

    10001

    111

    • Add 6 + (-6) using two’s complement

    numbers

    • Add -2 + 3 using two’s complement numbers

    C A

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    37/43

    C 1 Copyright © 2012 Elsevier

    • Extend number from  N  to  M bits ( M >  N ) :

    – Sign-extension

    – Zero-extension

    I B

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    38/43

    C 1

    • Sign bit copied to msb’s

    • Number value is same

    • Example 1:

    – 4-bit representation of 3 = 0011

    – 8-bit sign-extended value: 00000011

    • Example 2:

    – 4-bit representation of -5 = 1011

    – 8-bit sign-extended value: 11111011

    E

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    39/43

    C 1

    • Zeros copied to msb’s

    • Value changes for negative numbers

    • Example 1:

    – 4-bit value = 00112 = 310

    – 8-bit zero-extended value: 00000011 = 310

    • Example 2:

    – 4-bit value = 1011 = -510

    – 8-bit zero-extended value: 00001011 = 1110

    E

    C

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    40/43

    C 1

    -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

    Number System Range

    Unsigned [0, 2 N -1]

    Sign/Magnitude [-(2

     N -1

    -1), 2

     N -1

    -1]Two’s Complement [-2 N -1, 2 N -1-1]

    For example, 4-bit representation:

    C

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    41/43

     E: 4 (  )

    Value Sign-and-Magnitude

    1sComp.

    2sComp.

    +7 0111 0111 0111

    +6 0110 0110 0110+5 0101 0101 0101+4 0100 0100 0100+3 0011 0011 0011+2 0010 0010 0010

    +1 0001 0001 0001+0 0000 0000 0000

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    42/43

      E: 4 ( )

    Value Sign-and-Magnitude

    1sComp.

    2sComp.

    -0 1000 1111 --1 1001 1110 1111-2 1010 1101 1110-3 1011 1100 1101-4 1100 1011 1100-5 1101 1010 1011

    -6 1110 1001 1010-7 1111 1000 1001-8 - - 1000

  • 8/18/2019 DDCA_Ch1 - Class1 (1)

    43/43

    E:1. For 2’s complement binary numbers, the range of 

    values for 5-bit numbers is

    a. 0 to 31 b. -8 to +7 c. -8 to +8

    d. -15 to +15 e. -16 to +15

    2. In a 6-bit 2’s complement binary number system,what is the decimal value represented by (100100)2s?

    a. -4 b. 36 c. -36 d. -27 e. -28

    2