You are on page 1of 43

Chapter 1

Fundamentos de Electrnica Digital


Adaptado de:
Digital Design and Computer Architecture, 2nd Edition
David Money Harris and Sarah L. Harris

Chapter 1 <1>

Chapter 1 :: Topics

Background
The Game Plan
The Art of Managing Complexity
The Digital Abstraction
Number Systems
Logic Gates
Logic Levels
CMOS Transistors
Power Consumption

Chapter 1 <2>

Background
Microprocessors have revolutionized our world
Cell phones, Internet, rapid advances in medicine, etc.

The semiconductor industry has grown from $21


billion in 1985 to $300 billion in 2011

Chapter 1 <3>

Abstraction
Hiding details when
they arent important

programs

device drivers

focus of this course

instructions
registers
datapaths
controllers
adders
memories
AND gates
NOT gates
amplifiers
filters
transistors
diodes
electrons

Chapter 1 <4>

The Digital Abstraction


Most physical variables are continuous
Voltage on a wire
Frequency of an oscillation
Position of a mass

Digital abstraction considers discrete


subset of values

Chapter 1 <5>

Digital Discipline: Binary Values


Two discrete values:
1s and 0s
1, TRUE, HIGH, H
0, FALSE, LOW, L

1 and 0: voltage levels, rotating gears, fluid


levels, etc.
Digital circuits use voltage levels to represent
1 and 0
Bit: Binary digit

Chapter 1 <6>

Number Systems
Decimal numbers
1's column
10's column
100's column
1000's column

5374 10 =

Binary numbers

1's column
2's column
4's column
8's column

11012 =

Chapter 1 <7>

Number Systems
Decimal numbers
1's column
10's column
100's column

1000's column

5374 10 = 5 103 + 3 102 + 7 101 + 4 100


five
thousands

three
hundreds

seven
tens

four
ones

Binary numbers
1's column
2's column
4's column

8's column

11012 = 1 23 + 1 22 + 0 21 + 1 20 = 1310
one
eight

one
four

no
two

Chapter 1 <8>

one
one

Powers of Two

20 =
21 =
22 =
23 =
24 =
25 =
26 =
27 =

28 =
29 =
210 =
211 =
212 =
213 =
214 =
215 =
Chapter 1 <9>

Powers of Two

28 = 256
20 = 1
29 = 512
21 = 2
210 = 1024
22 = 4
211 = 2048
23 = 8
212 = 4096
24 = 16
213 = 8192
25 = 32
214 = 16384
26 = 64
215 = 32768
27 = 128
Handy to memorize up to 210
Chapter 1 <10>

Estimating Powers of Two


What is the value of 224?

How many values can a 32-bit variable


represent?

Chapter 1 <11>

Estimating Powers of Two


What is the value of 224?
- 24 220 16 million
How many values can a 32-bit variable
represent?
-22 230 4 billion

Chapter 1 <12>

Number Conversion
Decimal to binary conversion:
Convert 100112 to decimal

Decimal to binary conversion:


Convert 4710 to binary

Chapter 1 <13>

Number Conversion
Decimal to binary conversion:
Convert 100112 to decimal
161 + 80 + 40 + 21 + 11 = 1910

Decimal to binary conversion:


Convert 4710 to binary
321 + 160 + 81 + 41 + 21 + 11 = 1011112

Chapter 1 <14>

Binary Values and Range


N-digit decimal number
How many values?
Range?
Example: 3-digit decimal number:

N-bit binary number


How many values?
Range:
Example: 3-digit binary number:

Chapter 1 <15>

Binary Values and Range


N-digit decimal number
How many values? 10N
Range? [0, 10N - 1]
Example: 3-digit decimal number:
103 = 1000 possible values
Range: [0, 999]

N-bit binary number


How many values? 2N
Range: [0, 2N - 1]
Example: 3-digit binary number:
23 = 8 possible values
Range: [0, 7] = [0002 to 1112]

Chapter 1 <16>

Hexadecimal Numbers
Hex Digit

Decimal Equivalent

10

11

12

13

14

15

Binary Equivalent

Chapter 1 <17>

Hexadecimal Numbers
Hex Digit

Decimal Equivalent

Binary Equivalent

0000

0001

0010

0011

0100

0101

0110

0111

1000

1001

10

1010

11

1011

12

1100

13

1101

14

1110

15

1111
Chapter 1 <18>

Bits, Bytes, Nibbles


Bits

10010110
most
significant
bit

Bytes & Nibbles

least
significant
bit
byte

10010110
nibble

Bytes

CEBF9AD7
most
significant
byte

least
significant
byte

Chapter 1 <19>

Addition
Decimal

Binary

11
3734
+ 5168
8902

carries

11
1011
+ 0011
1110

carries

Chapter 1 <20>

Binary Addition Examples


Add the following
4-bit binary
numbers

Add the following


4-bit binary
numbers

1001
+ 0101

1011
+ 0110

Chapter 1 <21>

Binary Addition Examples


Add the following
4-bit binary
numbers

Add the following


4-bit binary
numbers
Overflow!

1
1001
+ 0101
1110

111
1011
+ 0110
10001
Chapter 1 <22>

Substraction
Substract the
following 4-bit
binary numbers

1
1001
+ 0101
1110

Substract the
following 4-bit
binary numbers

111
1011
+ 0110
10001
Chapter 1 <23>

Signed Binary Numbers


Sign/Magnitude Numbers
Twos Complement Numbers

Chapter 1 <24>

Sign/Magnitude Numbers
1 sign bit, N-1 magnitude bits
Sign bit is the most significant (left-most) bit
Positive number: sign bit = 0 A : {a N 1 , a N 2 ,L a2 , a1 , a0 }
n 2
Negative number: sign bit = 1
a
i

A = ( 1)

n 1

a 2
i

i =0

Example, 4-bit sign/mag representations of 6:


+6 =
-6=

Range of an N-bit sign/magnitude number:

Chapter 1 <25>

Sign/Magnitude Numbers
1 sign bit, N-1 magnitude bits
Sign bit is the most significant (left-most) bit
Positive number: sign bit = 0 A : {a N 1 , a N 2 ,L a2 , a1 , a0 }
n 2
Negative number: sign bit = 1
a
i

A = ( 1)

n 1

a 2
i

i =0

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]

Chapter 1 <26>

Sign/Magnitude Numbers
Problems:
Addition doesnt work, for example -6 + 6:

1110
+ 0110
10100 (wrong!)
Two representations of 0 ( 0):

1000
0000
Chapter 1 <27>

Twos Complement Numbers


Dont have same problems as sign/magnitude
numbers:
Addition works
Single representation for 0

Chapter 1 <28>

Twos Complement Numbers


MSB has value of -2N-1
n 2

A = an 1 ( 2n 1 ) + ai 2i
i =0

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 twos comp number:
Chapter 1 <29>

Twos Complement Numbers


Msb has value of -2N-1
n 2

A = an 1 ( 2n 1 ) + ai 2i
i =0

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 twos comp number:
[-(2N-1), 2N-1-1]
Chapter 1 <30>

Taking the Twos Complement


Flip the sign of a twos complement number
Method:
1. Invert the bits
2. Add 1

Example: Flip the sign of 310 = 00112

Chapter 1 <31>

Taking the Twos Complement


Flip the sign of a twos complement number
Method:
1. Invert the bits
2. Add 1

Example: Flip the sign of 310 = 00112


1. 1100
2. + 1
1101 = -310

Chapter 1 <32>

Twos Complement Examples


Take the twos complement of 610 = 01102

What is the decimal value of 10012?

Chapter 1 <33>

Twos Complement Examples


Take the twos complement of 610 = 01102
1. 1001
2. + 1
10102 = -610

What is the decimal value of the twos


complement number 10012?
1. 0110
2. + 1
01112 = 710, so 10012 = -710
Chapter 1 <34>

Twos Complement Addition


Add 6 + (-6) using twos complement
numbers
0110
+ 1010
Add -2 + 3 using twos complement numbers

1110
+ 0011
Chapter 1 <35>

Twos Complement Addition


Add 6 + (-6) using twos complement
numbers
111
0110
+ 1010
10000
Add -2 + 3 using twos complement numbers

111
1110
+ 0011
10001
Chapter 1 <36>

Increasing Bit Width

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


Sign-extension
Zero-extension

Copyright 2012 Elsevier

Chapter 1 <37>

Sign-Extension

Sign bit copied to msbs


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

Chapter 1 <38>

Zero-Extension

Zeros copied to msbs


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

Chapter 1 <39>

Number System Comparison


Number System

Range

Unsigned

[0, 2N-1]

Sign/Magnitude

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

Twos Complement

[-2N-1, 2N-1-1]

For example, 4-bit representation:


-8

-7

-6

-5

-4

-3

-2

-1

Unsigned

11

12

13

14

15

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

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

1111 1110 1101 1100 1011 1010 1001

10

0000
1000

0001 0010 0011 0100 0101 0110 0111

Chapter 1 <40>

Two's Complement
Sign/Magnitude

Comparisons of Sign-and-Magnitude
and Complements
 Example: 4-bit signed number (positive values)
Value

Sign-andMagnitude

1s
Comp.

2s
Comp.

+7
+6
+5
+4
+3
+2
+1
+0

0111
0110
0101
0100
0011
0010
0001
0000

0111
0110
0101
0100
0011
0010
0001
0000

0111
0110
0101
0100
0011
0010
0001
0000

Comparisons of Sign-and-Magnitude
and Complements
 Example: 4-bit signed number (negative values)
Value

Sign-andMagnitude

1s
Comp.

2s
Comp.

-0
-1
-2
-3
-4
-5
-6
-7
-8

1000
1001
1010
1011
1100
1101
1110
1111
-

1111
1110
1101
1100
1011
1010
1001
1000
-

1111
1110
1101
1100
1011
1010
1001
1000

Exercise:
2m

1. For 2s 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 2s complement binary number system,


what is the decimal value represented by (100100)2s?
a. -4

b. 36

c. -36

d. -27

e. -28

You might also like