ES 244: Digital Logic Design Chapter 1 Chapter 1: Introduction Uchechukwu Ofoegbu Temple University.

Post on 11-Jan-2016

219 views 1 download

transcript

ES 244: Digital Logic Design Chapter 1

Chapter 1: Introduction

Uchechukwu Ofoegbu

Temple University

ES 244: Digital Logic Design Chapter 1

Digital SignalsDigital Signals

• Digital Signals have two basic states:1 (logic “high”, or H, or “on”)

0 (logic “low”, or L, or “off”)

• Digital values are in a binary format. Binary means 2 states.

• A good example of binary is a light (only on or off)

ES 244: Digital Logic Design Chapter 1

BinaryBinary

Base 2 = Base 10

000 = 0001 = 1010 = 2011 = 3100 = 4101 = 5110 = 6111 = 7

In Binary, there are only 0’s and 1’s. These numbers are called “Base-2” ( Example: 0102)

Bin

ary

to D

eci

mal

We count in “Base-10” (0 to 9)

ES 244: Digital Logic Design Chapter 1

Binary as a VoltageBinary as a Voltage

• Voltages are used to represent logic values:

• A voltage present (called Vcc or Vdd) = 1

• Zero Volts or ground (called gnd or Vss) = 0

A simple switch can provide a logic high or a logic low.

ES 244: Digital Logic Design Chapter 1

A Simple SwitchA Simple Switch

• Here is a simple switch used to provide a logic value:

Vcc

Gnd, or 0

Vcc

Vcc, or 1

There are other ways to connect a switch.

ES 244: Digital Logic Design Chapter 1

Number systemsNumber systems

• Converting to decimal from binary:– Evaluate the power series

• Example

1 0 1 1 1 11 0 1 1 1 122

55 44 33 0022 11

0*20*2441*21*255 ++ 1*21*233 ++++ 1*21*222 ++

1*21*211 ++ 1*21*200 == 47471010

ES 244: Digital Logic Design Chapter 1

Number systemsNumber systems

• Convert to decimal from binary:– 1011011

a. 27

b. 91

c. 109

d. -109

e. 551

ES 244: Digital Logic Design Chapter 1

Review of Number systemsReview of Number systems

Memorize the first ten powers of twoMemorize the first ten powers of two

ES 244: Digital Logic Design Chapter 1

Copyright © 2008 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Review of Number systemsReview of Number systems

ES 244: Digital Logic Design Chapter 1

Number systemsNumber systems

• Converting to binary from decimal:– Divide the decimal number by 2 repeatedly.– The remainder gives the digits of the binary number

74674622

2222

22

2222

22

22

22373 R 0373 R 0

186 R 1186 R 1

93 R 093 R 0

46 R 146 R 1

23 R 023 R 0

11 R 111 R 1

5 R 15 R 1

22

2 R 12 R 1

1 R 01 R 0

1011101010101110101022

ES 244: Digital Logic Design Chapter 1

Number systemsNumber systems

• Convert to binary from decimal:

–65a.110101

b.101110

c.100001

d.100000

e.1000001

ES 244: Digital Logic Design Chapter 1

Hexadecimals – Base 16Hexadecimals – Base 16

• Shorthand for binary• Binary digits are grouped into 4

– Start at the least significant– If number of digits is not a multiple of 4, add zeros

• Each group is interpreted in decimal• Digits above 9 are represented by the first six letter of

the alphabet:– 10: A; 11: B; 12: C; 13: D; 14: E; 15: F

• Example:

1011101010101110101022 = 0010 1110 1010 = 0010 1110 101022

= 2EA= 2EA1616

ES 244: Digital Logic Design Chapter 1

Number systemsNumber systems

• Convert to hexadecimal from binary:

–1111111a.771

b.177

c.F7

d.7F

e.127

ES 244: Digital Logic Design Chapter 1

Hexadecimals – Base 16Hexadecimals – Base 16

• Converting to decimal from hex:– Evaluate the power series

• Example

2 E A 2 E A 1616

0022 11

14*1614*16112*162*1622 ++ 10*1610*1600++

== 7467461010

ES 244: Digital Logic Design Chapter 1

Number systemsNumber systems

• Convert to decimal from hexadecimal:

–65a.65

b.101

c.86

d.100001

e.41

ES 244: Digital Logic Design Chapter 1

Octals – Base 8Octals – Base 8

• Same steps as for conversion as binary and hexadecimal and any other base

• Converting to octal from decimal:– Divide the decimal number by 8 repeatedly.– The remainder gives the digits of the binary number

• Example: Convert 15310 to base 8.

ES 244: Digital Logic Design Chapter 1

Number systemsNumber systems

• Convert to octal from decimal:

15a.71

b.177

c.F7

d.17

e.27

ES 244: Digital Logic Design Chapter 1

Octals – Base 16Octals – Base 16

• Converting to decimal from hex:– Evaluate the power series

• Example

2 0 7 2 0 7 88

0022 11

0*80*8112*82*822 ++ 7*167*1600++

== 1351351010

ES 244: Digital Logic Design Chapter 1

Binary AdditionBinary Addition

• Add one digit at a time

• Obtain a sum and a carry

• Similar to decimal addition – but pay attention to the base

ES 244: Digital Logic Design Chapter 1

Binary AdditionBinary Addition

• Add the following binary number

• 10011+11111

a. 110010

b. 001100

c. 101110

d. 021120

e. 010011

ES 244: Digital Logic Design Chapter 1

Copyright © 2008 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Binary AdditionBinary Addition

ES 244: Digital Logic Design Chapter 1

Copyright © 2008 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

Binary AdditionBinary Addition

ES 244: Digital Logic Design Chapter 1

Signed NumbersSigned Numbers

• Signed numbers are mostly stored in two’s complements form

– Leading bit is 0 for positive numbers and 1 for negative

– For n bits, the range of numbers that can be stored is:

• -2n-1: 2n-1-1

• To derive the binary negative (two’s complement) of a number:

– Determine the magnitude (how many bits)

– Find the binary equivalent of the magnitude

– Complement each bit

– Add 1

ES 244: Digital Logic Design Chapter 1

Signed NumbersSigned Numbers

• Example:– Derive the 6-bit binary negative (two’s complement) of 17– Determine the magnitude (how many bits)

• 6bits

– Find the binary equivalent of the magnitude• 010001

– Complement each bit• 101110

– Add 1

• 101111

ES 244: Digital Logic Design Chapter 1

Copyright © 2008 The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

ES 244: Digital Logic Design Chapter 1

Signed NumbersSigned Numbers

• Derive the 5-bit binary negative (two’s complement) of 17

a. 0101111

b. 101111

c. 10000

d. 01111

e. 01110

ES 244: Digital Logic Design Chapter 1

OverflowOverflow

• This occurs when the sum is out of range

• Example: for 4-bit numbers, the range is [- 8:7]– Find the sum of +4 and +5– Find the sum of -4 and -5

• Addition of two numbers of the opposite sign never produces overflow

• Adding two same-signed numbers and obtaining a result of the opposite sign indicates overflow

ES 244: Digital Logic Design Chapter 1

OverflowOverflow

• For each of the following problems, enter A if the result is an overflow and B if it’s not. Assume the number of bits is 6

1. 15 + 17

2. -15 + 17

3. -15 -17

4. 2 - 3

ES 244: Digital Logic Design Chapter 1

Binary SubtractionBinary Subtraction

• Take the two complement of the second operand• Then add• For signed numbers:

– Ignore the carry-out of the higher order– If two numbers of the same sign are added, and a result of the

opposite sign is obtained, there’s an overflow– Ex: 7 – 5; -7 – 5

• For Unsigned number– A carry-out of zero in the higher-order bit indicates overflow– Ex: 5 - 7

ES 244: Digital Logic Design Chapter 1

Binary SubtractionBinary Subtraction

• What is the 5-bit binary representation of 8 -15

a. 10111

b. 11000

c. 01001

d. 11001

e. overflow

ES 244: Digital Logic Design Chapter 1

FractionsFractions

• Converting fractions to decimal from binary:

• Example

. 1 0 1 . 1 0 1 22

0*20*2-2-21*21*2-1-1 ++ 1*21*2-3-3++

== .625.6251010

...31

21

11

rarara

ES 244: Digital Logic Design Chapter 1

FractionsFractions

• Convert .01112 to decimal

a. .875

b. .375

c. .4375

d. .0700

e. 4.375

ES 244: Digital Logic Design Chapter 1

FractionsFractions

• Converting to binary from decimal:– Multiply the decimal number by 2 repeatedly.– Use the integer part as the next digit each time, and

then discard the integer– When the fraction part is zero, we have an exact

conversion– Add trailing zeros to obtain the desired size

– For some fractions, we never get an exact conversion because the fraction parts repeats, example: .3

.1.1.625*2 = 1.25.625*2 = 1.25

.25*2 = 0.50.25*2 = 0.50 .10.10

.101.101 .5*2 = 1.00.5*2 = 1.00

ES 244: Digital Logic Design Chapter 1

ExamplesExamples

• Convert the following to base 2 : .7510

a. .111000

b. .000011

c. .110000

d. .111111

e. .101000

ES 244: Digital Logic Design Chapter 1

Mixed NumbersMixed Numbers

• Covert the integer and the fraction separately• Example:

– 5.75 = 101.11

ES 244: Digital Logic Design Chapter 1

ExamplesExamples

• Convert the following to base 10 : 11.011002

a. 3.7500

b. 3.0300

c. 3.1875

d. 3.0300

e. 3.3750

ES 244: Digital Logic Design Chapter 1

Mixed NumbersMixed Numbers

• Computer storage– The standard notation (IEEE Standard 754) for 32 bit numbers

is:• A sign bit: 1 for negative and 0 for positive

• An 8-bit exponent – Stored as the binary version of 127+exponent– Can store -126:127 as 1:254

• 23 bits for the significant digits

• The first significant digit is always a binary 1 so this is not stored

• Example: -27.875

• 27.875 = 11011.111 = 1.1011111*24

One sign bit – 1 if –ve, 0 otherwiseOne sign bit – 1 if –ve, 0 otherwise

8 exponent bits8 exponent bits 32 bits for significant digits32 bits for significant digits

11 10000111000011 1011111000000000000000010111110000000000000000

ES 244: Digital Logic Design Chapter 1

Computer StorageComputer Storage

• How would the number 2.1 be stored in IEEE Standard 754 for 32 bit numbers

a. 1 10000001 01100110011001100110000

b. 0 10000000 00001100110011001100110

c. 0 00000001 10000110011001100110011

d. 1 10000000 10000000000000000000000

e. Can’t be stored

ES 244: Digital Logic Design Chapter 1

Logic GatesLogic Gates

• Basic Digital logic is based on 3 primary functions (the basic gates):

– AND

– OR

– NOT

ES 244: Digital Logic Design Chapter 1

The AND functionThe AND function

• The AND function:– If all the inputs are high is the output

is high

– If any input is low, the output is low

• “If this input AND this input are high, the output is high”

ES 244: Digital Logic Design Chapter 1

AND Logic SymbolAND Logic Symbol

InputsOutput

If both inputs are 1, the output is 1

If any input is 0, the output is 0

ES 244: Digital Logic Design Chapter 1

AND Logic SymbolAND Logic Symbol

InputsOutput

Determine the output

0

00

ES 244: Digital Logic Design Chapter 1

AND Logic SymbolAND Logic Symbol

Inputs Output

Determine the output

0

10

ES 244: Digital Logic Design Chapter 1

AND Logic SymbolAND Logic Symbol

InputsOutput

Determine the output

1

11

ES 244: Digital Logic Design Chapter 1

AND Truth TableAND Truth Table

• To help understand the function of a digital device, a Truth Table is used:

Input Output

0 0 0

0 1 0

1 0 0

1 1 1

AND Function

Every possible input combination

ES 244: Digital Logic Design Chapter 1

AND GatesAND Gates

• It is possible to have AND gates with more than 2 inputs. The same logic rules apply – “if any input…”

ES 244: Digital Logic Design Chapter 1

The OR functionThe OR function

• The OR function:– if any input is high, the output is

high

– if all inputs are low, the output is low

• “If this input OR this input is high, the output is high”

ES 244: Digital Logic Design Chapter 1

OR Logic SymbolOR Logic Symbol

InputsOutput

If any input is 1, the output is 1

If all inputs are 0, the output is 0

ES 244: Digital Logic Design Chapter 1

OR Logic SymbolOR Logic Symbol

Inputs

Output

Determine the output

0

0

0

ES 244: Digital Logic Design Chapter 1

OR Logic SymbolOR Logic Symbol

Inputs

Output

Determine the output

0

1

1

ES 244: Digital Logic Design Chapter 1

OR Logic SymbolOR Logic Symbol

InputsOutput

Determine the output

1

1

1

ES 244: Digital Logic Design Chapter 1

OR Truth TableOR Truth Table

• Truth Table

Input Output

0 0 0

0 1 1

1 0 1

1 1 1

OR Function

ES 244: Digital Logic Design Chapter 1

The NOT functionThe NOT function

• The NOT function:– If any input is high, the output is low

– If any input is low, the output is high

• “The output is the opposite state of the input”

• The NOT function is often called INVERTER

ES 244: Digital Logic Design Chapter 1

NOT Logic SymbolNOT Logic Symbol

InputOutput

If the input is 1, the output is 0

If the input is 0, the output is 1

ES 244: Digital Logic Design Chapter 1

NOT Logic SymbolNOT Logic Symbol

Input

Output

Determine the output

0 1

ES 244: Digital Logic Design Chapter 1

NOT Logic SymbolNOT Logic Symbol

Input Output

Determine the output

1 0

ES 244: Digital Logic Design Chapter 1

OR (written as +)1a + b (read a OR b) is 1 if and only if a = 1 or b = 1 or both

AND (written as or simply two variables catenated)a b = ab (read a AND b) is 1 if and only if a = 1 and b = 1.

NOT (written)a (read NOT a) is 1 if and only if a = 0

SummarySummary

ES 244: Digital Logic Design Chapter 1

HomeworkHomework

• Exercises 2,3,9,14