Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute...

44
ACCESS IC LAB Graduate Institute of Electronics Engineering, NTU CH1 Number Systems and Conversion CH1 Number Systems and Conversion Lecturer吳安宇 教授 Date2006/09/22

Transcript of Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute...

Page 1: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

ACCESS IC LAB

Graduate Institute of Electronics Engineering, NTU

CH1 Number Systems and ConversionCH1 Number Systems and Conversion

Lecturer:吳安宇 教授

Date:2006/09/22

Page 2: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.2

OutlineOutlineDigital Systems and Switching CircuitsNumber Systems and ConversionBinary ArithmeticRepresentation of Negative NumbersAddition of 2’s Complement NumbersAddition of 1’s Complement NumbersBinary Codes

Page 3: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.3

PurposePurposeDesign a switching network (Logic Function)

:Binary number{ }1,0∈iX { }1,0∈iZ

Input OutputSwitching

Circuits

……

……

X1X2

Xm

Z1Z2

Zm

Page 4: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.4

OutlineOutlineDigital Systems and Switching CircuitsNumber Systems and ConversionBinary ArithmeticRepresentation of Negative NumbersAddition of 2’s Complement NumbersAddition of 1’s Complement NumbersBinary Codes

Page 5: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.5

Number System and ConversionNumber System and ConversionDecimal (Base 10) Number (separated by decimal point):

953.7810(210.-1-2)

= 9*102 + 5*101 + 3*100 + 7*10-1 +8*10-2

Binary (Base 2) Number (separated by binary point):

1011.112(3210.-1-2)

= 1*23 + 0*22 + 1*21 + 1*20 + 1*2-1 + 1*2-2

= 8 + 0 +2 +1+1/2 +1/4= (11.75)10

Page 6: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.6

Generalized Representation of an Generalized Representation of an Positive integerPositive integer NN with with Base (Radix) RBase (Radix) R::

Name Decimal Binary Octal Hexadecimal

Radix 10 2 8 16

Digits 0,1,2,3,4,5,6,7,8,9 0,1 0,1,2,3,

4,5,6,7

0,1,2,3,4,5,6,7,8,9,A,B,

C,D,E,F

Firstseventeenpositiveintegers

012345678910111213141516

0110111001011101111000100110101011110011011110111110000

01234567101112131415161720

0123456789ABCDEF10

Page 7: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.7

Generalized Representation of an Positive Generalized Representation of an Positive integer N with Base (Radix) Rinteger N with Base (Radix) R::

N= (a4 a3 a2 a1 a0 . a-1 a-2 a-3)R= a4*R4 + a3*R3 + a2*R2 + a1*R1 + a0*R0

+ a-1*R-1 + a-2*R-2 + a-3*R-3

EX:R=8 , Digits = { 0,1,2,3,4,5,6,7 }(147.3)8 = 1*82 + 4*81 + 7*80 + 3*8-1

= (103.375)10

EX:R=16, Digits = { 0,1,2,...,A,B,C,D,E,F }(A2F)16 = 10*162 + 2*161 + F*160

= (2607)10

Page 8: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.8

Integer Conversion Using Integer Conversion Using ““Division MethodDivision Method”” (1/2)(1/2)

Page 9: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.9

Integer Conversion Using Integer Conversion Using ““Division MethodDivision Method”” (2/2)(2/2)

EX:Convert (53)10 to Binary no.

MSB

(53)10 = (110101)2

MSB

Page 10: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.10

Conversion of A Decimal Fraction Using Conversion of A Decimal Fraction Using ““Successive MultiplicationSuccessive Multiplication”” (1/3)(1/3)

Fi:Fraction Number

Page 11: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.11

Conversion of A Decimal Fraction Using Conversion of A Decimal Fraction Using ““Successive MultiplicationSuccessive Multiplication”” (2/3)(2/3)

EX:Convert (0.625)10 to Binary number

(0.625)10 = (0.101)2

MSB MSB

Page 12: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.12

EX:Convert (0.7)10 to Binary number

Repeated Process 0.8, 1.6, 1.2, 0.4, ….

(0.7)10 = 0.1 0110 0110 0110 …… (Base2)

No exact conversion !!!

Conversion of A Decimal Fraction Using Conversion of A Decimal Fraction Using ““Successive MultiplicationSuccessive Multiplication”” (3/3)(3/3)

Page 13: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.13

Conversion (1/2)Conversion (1/2)EX:Convert (231.3)4 to Base 7 number(231.3)4 = 2*42 + 3*41 + 1*40 + 3*4-1 = (45.75)10

Integer Fraction

(45.75)10= (63.51 51 51 ……)2

Page 14: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.14

Conversion (2/2)Conversion (2/2)Conversion from Binary (Base 2)

to Octal (Base 8)to Hexadecimal (Base 16)

(11010111110.0111 )2 = (3276.34)8

(11010111110.0011)2 = (6BE.3)16

3 2 7 6 3 4(補0)

6 B E 3Binary point ( R=2 )

Hexadecimal point

decimal point (R=10)

00

Page 15: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.15

OutlineOutlineDigital Systems and Switching CircuitsNumber Systems and ConversionBinary ArithmeticRepresentation of Negative NumbersAddition of 2’s Complement NumbersAddition of 1’s Complement NumbersBinary Codes

Page 16: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.16

Binary Arithmetic Binary Arithmetic ---- AdditionAdditionAddition

0 + 0 = 00 + 1 = 11 + 0 = 11 + 1 = 10 (sum 0 & carry 1)

EX:1111 (Carry)

Page 17: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.17

Binary Arithmetic Binary Arithmetic ---- SubtractionSubtractionSubtraction

0 – 0 = 01 – 0 = 11 – 1 = 00 – 1 = 1 (with borrow 1 from next column)

EX:

1111 (Borrow)

Page 18: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.18

Binary Arithmetic Binary Arithmetic ---- MultiplcationMultiplcationMultiplication

0 * 0 = 00 * 1 = 01 * 0 = 01 * 1 = 1

EX: (13)10

(11)10

copy of multiplicand if “1”

multiplicandmultiplier

Page 19: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.19

Binary Arithmetic Binary Arithmetic ---- DivisionDivisionDivision

Page 20: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.20

OutlineOutlineDigital Systems and Switching CircuitsNumber Systems and ConversionBinary ArithmeticRepresentation of Negative NumbersAddition of 2’s Complement NumbersAddition of 1’s Complement NumbersBinary Codes

Page 21: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.21

Signed Number RepresentationSigned Number Representation

S Magnitude

signed bit

bit bit bit bit bit bit bit bit

A computer “word”, wordlength n = 8 bits(other popular n = 16 bits, 32 bits)

Page 22: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.22

Singed Magnitude NumbersSinged Magnitude NumbersN = (an-1 an-2 ……a1 a0)r

N = ( s, an-2 ……a1 a0)2sm

EX:

N = -(13)10 = -(0,1101)2 = (1,1101)2sm

±

s = 0 if N 0

s = 1 if N 0≥≤

Signed magnitude

(2sm = Binary Singed Magnitude)

Page 23: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.23

Radix ComplementRadix ComplementDefinition: The “radix complement [N]” of a number (N)r is defined as:

N* (notation in textbook) = [N]r = rn – (N)r

where n is the number of digits (wordlength) in (N)r

The largest positive number (positive full scale) = rn-1 – 1The most negative number (negative full scale) = - rn-1

Page 24: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.24

22’’s Complements ComplementN* = [N]2 = 2n – (N)2

EX:2’s complement of (N)2 = (01100101)2

[N]2 = [01100101]2= 28 – (01100101)2= (100000000)2 – (01100101)2= (10011011)2

EX:show that (N)2 + [N]2 = 0011001011001101100000000

(carry)

+1 [N]2 = - (N)2

Page 25: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.25

22’’s Complements ComplementEX:check (N)2 = [ [N]2 ]2 (by yourself)

EX:2’s complement of (N)2 = (10110)2 for n=8

[N]2 = 28 – (10110)2= (100000000)2 – (00010110)2= (11101010)2

Page 26: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.26

22’’s Complements ComplementConvert (N)2 to [N]2:

Method 1

N = 0 1 1 0 0 1 0 1

[N]2 = 1 0 0 1 1 0 1 1

N = 1 1 0 1 0 1 0 0

[N]2 = 0 0 1 0 1 1 0 0

First nonzero digit

First nonzero digit

Page 27: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.27

22’’s Complements ComplementConvert (N)2 to [N]2:

Method 2

N = 0 1 1 0 0 1 0 1 1 0 0 1 1 0 1 0 complement the bits

1 add 11 0 0 1 1 0 1 1

⎩⎨⎧

→→

→1001

,kk aa Flip then Add 1

Page 28: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.28

22’’s Complements ComplementSigned Decimal Sign Magnitude

BinaryTwo’s Complement

SystemOne’s Complement

System

+15+14+13+12+11+10+9+8+7+6+5+4+3+2+10

0,11110,11100,11010,11000,10110,10100,10010,10000,01110,01100,01010,01000,00110,00100,00010,0000

(1,0000)

0,11110,11100,11010,11000,10110,10100,10010,10000,01110,01100,01010,01000,00110,00100,00010,0000

0,11110,11100,11010,11000,10110,10100,10010,10000,01110,01100,01010,01000,00110,00100,00010,0000

(1,1111)

for n = 5

Page 29: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.29

22’’s Complements ComplementSigned Decimal Sign Magnitude

BinaryTwo’s Complement

SystemOne’s Complement

System

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

1,00011,00101,00111,01001,01011,01101,01111,10001,10011,10101,10111,11001,11011,11101,1111--------

1,11111,11101,11011,11001,10111,10101,10011,10001,01111,01101,01011,01001,00111,00101,00011,0000

1,11101,11011,11001,10111,10101,10011,10001,01111,01101,01011,01001,00111,00101,00011,0000--------

for n = 5

Page 30: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.30

22’’s Complements ComplementEX:2’s complement of –(13)10 for n = 8

(13)10 = (1011)2 = (00001101)2-(00001101)2 = [00001101]2 = (11110011)2

EX:(n=8) Determine the decimal no. of N=(1,111,1010)2

1111010 (?) (-6)0000110 (6)

Page 31: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.31

Radix Complement ArithmeticRadix Complement ArithmeticEX:compute (9)10 + (5)10 for 5-bit 2’s complement

0 1 0 0 1 (+9)+ 0 0 1 0 1 (+5)

0 1 1 1 0 (+14)EX:compute (12)10 + (7)10

0 1 1 0 0 (+12)+ 0 0 1 1 1 (+7)

1 0 0 1 1 (-13)EX:compute (12)10 – (5)10 = (12) + (-5)

0 1 1 0 0 (+12)+ 1 1 0 1 1 (2’s complement of (5)2)1 0 0 1 1 1 (+7)

discard the carry

Add two positive no. and obtain a negative no.(overflow occurs!)

Page 32: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.32

Radix Complement ArithmeticRadix Complement ArithmeticEX:(-9) – (5) = (-9) + (-5)

9 = 0 1 0 0 1 -9 = 1 0 1 1 15 = 0 0 1 0 1 -5 = 1 1 0 1 1

1 0 1 1 1 (-9)+ 1 1 0 1 1 (-5)1 1 0 0 1 0 (-14)

discard (why?)EX:(-12) – (5) = (-12) + (-5)

1 0 1 0 0 (-12)+ 1 1 0 1 1 (-5)1 0 1 1 1 1 (+15) (overflow occurs)

Page 33: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.33

11’’s & 2s & 2’’s Complements Complement2’s complement is the main streamCheck SIGN for the overflow!

(+) + (+) (-)

(-) + (-) (+)overflow!!

Page 34: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.34

Overflow ConditionOverflow Condition

A B A+B A-B

+ + - ˇ x

+ - x - ˇ

- + x +ˇ

- - + ˇ x

ˇ:overflowx :no overflow

Page 35: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.35

Diminished Radix ComplementDiminished Radix Complement1’s complement

EX: 1 0 1 1 0 1 0 0 (N)2

0 1 0 0 1 0 1 1 1’s complement of (N)2

⎩⎨⎧

→→

→1001

,kk aa

Page 36: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.36

Addition of 1Addition of 1’’s Complement Numberss Complement Numbers“End-around carry” :

Instead of discarding the last carry (as in 2’s complement), it is added to the n-bit sum in the position furthest to the right.

Page 37: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.37

Addition of 1Addition of 1’’s Complement Numberss Complement NumbersAddition of positive & negative numbers(a)

+5 0101-6 1001-1 1110 (correct)

(b)-5 1010+6 0110+1 1 0000

1 (end-around carry)0001 (correct, no overflow)

Page 38: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.38

Addition of 1Addition of 1’’s Complement Numberss Complement NumbersAdding two negative numbers(a)

-3 1100-4 1011-7 1 0111

1 (end-around carry)1000 (-7) (correct, no overflow)

(b) -5 1010-6 1001

-11 1 00111 (end-around carry)

0100 (wrong, overflow!!)

Page 39: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.39

Addition of 1Addition of 1’’s Complement Numberss Complement NumbersEX:Addition for a word-length of 8(a) (-11) + (-20) in 1’s complement

+11 = 00001011 (-11) = 11110100+20 = 00010100 (-20) = 11101011

(1)11011111 1

(+31) 00011111 11100000 (-31)

(b) (-8) + (+19) in 2’s complement11111000 (-8)00010011 (+19)

(1)00001011 (+11)discard the last carry

Page 40: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.40

OutlineOutlineDigital Systems and Switching CircuitsNumber Systems and ConversionBinary ArithmeticRepresentation of Negative NumbersAddition of 2’s Complement NumbersAddition of 1’s Complement NumbersBinary Codes

Page 41: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.41

Binary CodesBinary CodesBCD (Binary Coded Decimal) codesEX: 1 9 8 9

0001 1001 1000 1001

0: 00001: 00012: 00103: 00114: 0100

5: 01016: 01107: 01118: 10009: 1001

Page 42: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.42

Binary CodesBinary CodesASCII codeskeyboard computer

Character Binary Code Hexadecimal Code

Digital

1000100110100111001111101001111010011000011101100

4469676974616C

Encode the word Digital in ASCII code, representing each character by two hexadecimal digits

Page 43: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.43

ASCII Code (Table 1ASCII Code (Table 1--3 on p.22)3 on p.22)

Page 44: Lecturer 吳安宇教授access.ee.ntu.edu.tw/course/logic_design_95first... · Graduate Institute of Electronics Engineering, NTU 台灣大學吳安宇教授 pp.3 Purpose Design a

Graduate Institute of Electronics Engineering, NTU

台灣大學 吳安宇 教授 pp.44

Binary Codes for Decimal DigitsBinary Codes for Decimal Digits