0% found this document useful (0 votes)
17 views

EE200 - DLD - Chapter 01

Uploaded by

randomlyol123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

EE200 - DLD - Chapter 01

Uploaded by

randomlyol123
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

21-Oct-13

Recap: Analog Signal vs. Digital

Digital Logic Design

Chapter 1
Numbers System

Digital Logic Design - Chapter 1 2

Numbers Numbers
 Each number system is associated with a base or radix An1 An2  A1 A0 . A1 A2  Am1 Am

The decimal number system is said to be of base or radix 10



 The . is called the radix point
 A number in base r contains r digits 0,1,2,...,r-1
 Decimal (Base 10): 0,1,2,3,4,5,6,7,8,9  An 1 : most significant digit (msd)
 Numbers are usually expressed in positional notation  A m : least significant digit (lsd)
An1 An2  A1 A0 . A1 A2  Am1 Am (724.5)10  724.5  7 10 2  2 101  4 100  5 10 1
 A number is expressed as a power series in r with the general 1620.375  1103  6 10 2  2 101  3 10 1  7 10 2  5 10 3
form (312.4)5  3  52  1 51  2  50  4  51  (82.8)10
An 1r n1  An 2 r n2    A1r1  A0 r 0  A1r 1  A2 r 2
In addition to decimal, three number systems are important: Binary, Octal, and
   Am1r m1 Am r m
Hexadecimal

Digital Logic Design - Chapter 1 3 Digital Logic Design - Chapter 1 4

1
21-Oct-13

Decimal Number Representation Generic Number Representation


 Example: 90134 (base-10, used by Homo  90134
Sapien)  = 9*104 + 0*103 + 1*102 + 3*101 + 4*100
 = 90000 + 0 + 100 + 30 + 4  A4 A3 A2 A1 A0 for base-10 (or radix-10)
 = 9*104 + 0*103 + 1*102 + 3*101 + 4*100  = A4*104 + A3*103 + A2*102 + A1*101 + A0*100
 How did we get it?  (A is coefficient; b is base)
 Generalize for a given number N w/ base-b
10 90134 N = An-1 An-2 … A1 A0
10 9013 4 N = An-1*bn-1 + An-2*bn-2 + … + A2*b2 + A0*b0
10 901 3 **Note that A < b
10 90 1
9 0
Digital Logic Design - Chapter 1 5 Digital Logic Design - Chapter 1 6

Decimal Review Counting numbers with base-b


 Numbers consist of a bunch of digits, each with a weight:
0 10 20 90 100 0 10 20 70 100
1 6 2 . 3 7 5 Digits 1 11 21 91 101 1 11 21 71 101
100 10 1 1/10 1/100 1/1000 Weights
2 12 22 92 102 2 12 22 72 102
 The weights are powers of the base, which is 10 3 13 23 93 103 3 13 23 73 103
4 14 24 ….. 94 104 4 14 24 ….. 74 104
1 6 2 . 3 7 5 Digits
102 101 100 10-1 10-2 10-3 Weights
5 15 25 95 105 5 15 25 75 105
6 16 26 96 106 6 16 26 76 106
7 17 27 97 107 7 17 27 77 107
 To find the decimal value of a number, multiply each digit by its
weight and sum the products 8 18 28 98 108
9 19 29 99 109
(1 x 102) + (6 x 101) + (2 x 100) + (3 x 10-1) + (7 x 10-2) + (5 x 10-3) = 162.375

Base-10 How about Base-8

Digital Logic Design - Chapter 1 7 Digital Logic Design - Chapter 1 8

2
21-Oct-13

How about base-2 How about base-2

0 10 100 1000 0 10 100 1000


1 11 101 1001 1 11 101 1001
110 1010 110 1010
111 1011 111 1011
1100 1100
1101 1101
1110 1110
1111 1111

Digital Logic Design - Chapter 1 9 Digital Logic Design - Chapter 1 10

How about base-2 Information Representation: Binary Numbers

 Radix = 2; Digits Ai can only take one of two


0=0 10 = 2 100 = 4 1000 = 8 values (0 or 1)
1=1 11 = 3 101 = 5 1001 = 9  It is customary to refer to binary digits as bits
110 = 6 1010 = 10
111 = 7 1011 = 11
1100 = 12
1101 = 13
1110 = 14
1111 = 15

Binary = Decimal

Digital Logic Design - Chapter 1 11 Digital Logic Design - Chapter 1 12

3
21-Oct-13

Number Examples with Different Bases Convert between different bases


 Decimal (base-10)  Others examples:  Convert a number base-x to base-y, e.g. (0100111)2 to (?)6
 First, convert from base-x to base-10 if x  10
 (982)10  base-9 = (1321)9  Then convert from base-10 to base-y
 Binary (base-2)  base-11 = (813)11
 (01111010110)2  base-17 = (36d)17 0100111 = 026 + 125 + 024 + 023 + 122 + 121 + 120 = 39

 Octal (base-8)
6 39
 (1726)8
 Hexadecimal (base-16) 6 6 3
 (3d6)16 1 0

 (0100111)2 = (103)6

Digital Logic Design - Chapter 1 13 Digital Logic Design - Chapter 1 14

Derive Numbers in Base-2 Converting Binary to Decimal


 Decimal (base-10)  Exercise  For example, here is
 (25)10 1101.01 in binary:
 Binary (base-2) 2 25 1 1 0 1 . 0 1 Bits
(11001)2 23 22 21 20 2-1 2-2 Weights (in base 10)
 2 12 1
2 6 0 210 : K (kilo); 220 : M (mega); 230 : G( giga )
2 3 0  The decimal value is:
1 1 (1 x 23) + (1 x 22) + (0 x 21) + (1 x 20) + (0 x 2-1) + (1 x 2-2) =

8 + 4 + 0 + 1 + 0 + 0.25 = 13.25

Digital Logic Design - Chapter 1 15 Digital Logic Design - Chapter 1 16

4
21-Oct-13

Converting Decimal to Binary Why does this work?


 To convert a decimal integer into binary, keep  This works for converting from decimal to any
dividing by 2 until the quotient is 0. Collect the base
remainders in reverse order  Why? Think about converting 162.375 from
 To convert a fraction, keep multiplying the fractional decimal to decimal
162 / 10 = 16 rem 2
part by 2 until it becomes 0. Collect the integer parts 16 / 10 = 1 rem 6
in forward order 1 / 10 = 0 rem 1
 Example: 162.375:  Each division strips off the rightmost digit (the
162 / 2 = 81 rem 0 0.375 x 2 = 0.750 remainder). The quotient represents the
81 / 2 = 40 rem 1 0.750 x 2 = 1.500 remaining digits in the number
40 / 2 = 20 rem 0 0.500 x 2 = 1.000  Similarly, to convert fractions, each multiplication
20 / 2 = 10 rem 0
10 / 2 =5 rem 0
strips off the leftmost digit (the integer part). The
5/2 =2 rem 1 fraction represents the remaining digits
2/2 =1 rem 0
1/2 =0 rem 1 0.375 x 10 = 3.750
0.750 x 10 = 7.500
 So, (162.375)10 = (10100010.011)2 0.500 x 10 = 5.000

Digital Logic Design - Chapter 1 17 Digital Logic Design - Chapter 1 18

Numbers with Different Bases


Octal and Hexadecimal Numbers
Decimal Binary Octal Hex
 The octal number system: Base-8 0 0000 0 0
 Eight digits: 0,1,2,3,4,5,6,7 1 0001 1 1
2 0010 2 2 You can convert between base-10
(127.4)8  1 82  2  81  7  80  4  81  (87.5)10
3 0011 3 3 base-8 and base-16 using techniques
 We use Base-16 (or Hex) a lot in computer world 4 0100 4 4
like the ones we just showed for
 Sixteen digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F 5 0101 5 5
converting between decimal and
 Ex: A 32-bit address can be written as 6 0110 6 6
binary
 0xfe8a7d20 (0x is an abbreviation of Hex) 7 0111 7 7
 Or in binary form 1111_1110_1000_1010_0111_1101_0010_0000 8 1000 10 8
9 1001 11 9
( B65F )16  11163  6 162  5 161  15 160  (46687)10 10 1010 12 A
11 1011 13 B
 For our purposes, base-8 and base-16 are most useful as a 12 1100 14 C
“shorthand” notation for binary numbers 13 1101 15 D
14 1110 16 E
15 1111 17 F

Digital Logic Design - Chapter 1 19 Digital Logic Design - Chapter 1 20

5
21-Oct-13

Binary and Octal Conversions Binary and Hex Conversions


 Converting from octal to binary: Replace each octal digit with  Converting from hex to binary: Replace each hex digit with its
its equivalent 3-bit binary sequence
equivalent 4-bit binary sequence
(673.12)8 = 6 7 3 . 1 2 261.3516 = 2 6 1 . 3 516
= 110 111 011 . 001 010 = 0010 0110 0001 . 0011 01012
= (110111011.001010) 2  Converting from binary to hex: Make groups of 4 bits, starting
 Converting from binary to octal: Make groups of 3 from the binary point. Add 0s to the ends of the number if
bits,starting from binary point. Add 0s to ends of number if needed. Convert each bit group to its corresponding hex digit
needed. Convert each bit group to its corresponding octal
10110100.0010112 = 1011 0100 . 0010 11002
digit.
10110100.0010112 = 010 110 100 . 001 0112 = B 4 . 2 C16
= 2 6 4 . 1 38
Hex Binary Hex Binary Hex Binary Hex Binary
Octal Binary Octal Binary
0 0000 4 0100 8 1000 C 1100
0 000 4 100
1 0001 5 0101 9 1001 D 1101
1 001 5 101
2 0010 6 0110 A 1010 E 1110
2 010 6 110 3 0011 7 0111 B 1011 F 1111
3 011 7 111
Digital Logic Design - Chapter 1 21 Digital Logic Design - Chapter 1 22

Information Representation (cont.) Numeric Codes


 Various Codes used in Computer Industry
 Number-only representation
 BCD (4 bits per decimal number)
 Alpha-numeric representation
 ASCII (7 bits)
 Unicode (16 bit)

Digital Logic Design - Chapter 1 23 Digital Logic Design - Chapter 1 24

6
21-Oct-13

Negative Number Representation Sign-magnitude


 Options  Use the most significant bit (MSB) +0 000
 Sign-magnitude to indicate the sign +1 001
 0: positive, 1: negative
 One’s Complement
 Problem +2 010
 Two’s Complement (we use this in this course)
 Representing zeros?
+3 011
 Do not work in computation
-3 111
-2 110
-1 101
-0 100

Digital Logic Design - Chapter 1 25 Digital Logic Design - Chapter 1 26

One’s Complement Two’s Complement


 Complement (flip) each bit in a +0 000  Complement (flip) each bit in a
binary number binary number and add 1, with
+1 001 overflow ignored
 Problem
 Representing zeros? +2 010  Work in computation perfectly
 Do not always work in computation
 Ex: 111 + 001 = 000  Incorrect ! +3 011
-3 100
3 011 -3 101
-2 101
One’s complement One’s complement
-1 110 100 010

0 111 Add 1 Add 1


-3 101 3 011

Digital Logic Design - Chapter 1 27 Digital Logic Design - Chapter 1 28

7
21-Oct-13

Two’s Complement Two’s Complement


 Complement (flip) each bit in a 0 000  Complement (flip) each bit in a 0 000
binary number and adding 1, with binary number and adding 1, with
overflow ignored +1 001 overflow ignored +1 001
 Work in computation perfectly -1 111  Work in computation perfectly -1 111
 We will use it in this course !  We will use it in this course !
+2 010 +2 010
-2 110 -2 110
100 100
+3 011 +3 011
One’s complement One’s complement
011 -3 101 011 -3 101
The same 100 represents MSB = 1 for negative
Add 1 both 4 and -4 ?? 100 Add 1 Number, thus 100 -4 100
which is no good represents -4
100 100

Digital Logic Design - Chapter 1 29 Digital Logic Design - Chapter 1 30

Range of Numbers Binary Arithmetic


 An N-bit number
N
 Unsigned: 0 .. (2 -1)
N-1 N-1
 Signed: -2 .. (2 -1)
 Example: 4-bit

0000 (0) Unsigned numbers 1111 (15)

1000 (-8) 0111 (7)


Signed numbers

Digital Logic Design - Chapter 1 31 Digital Logic Design - Chapter 1 32

8
21-Oct-13

Binary Arithmetic: Multiplication Binary Computation

010001 (17=16+1)
001011 (11=8+2+1)
---------------
011100 (28=16+8+4)

(7.5)10 = (111.10)2 Q3.2 Unsigned arithmetic Signed arithmetic (w/ 2’s complement)
111.10 010001 (17=16+1) 010001 (17=16+1)
10.1 (2.5)10 = (10.1)2 Q2.1 101011 (43=32+8+2+1) 101011 (-21: 2’s complement=010101=21)
11110 (18.75)10 = (10010.110)2 Q5.3 --------------- ---------------
111100 (60=32+16+8+4) 111100 (2’s complement=000100=4, i.e. -4)
00000x
11110xx
10010110

Digital Logic Design - Chapter 1 33 Digital Logic Design - Chapter 1 34

Binary Computation
Unsigned arithmetic
101111 (47)
The carry is 011111 (31)
discarded ---------------
001110 (78?? Due to overflow, note that
78 cannot be represented
by a 6-bit unsigned number)

Signed arithmetic (w/ 2’s complement)


101111 (-17 since 2’s complement=010001)
The carry is 011111 (31)
discarded ---------------
001110 (14)

Digital Logic Design - Chapter 1 35

You might also like