Docsity

Number Systems-Microcomputers-Lecture 01 Slides-Electrical and Computer Engineering, Slides of Microcomputers

Toggle sidebar
bg1
1
Microcomputers
Number Systems and
Digital Logic Review
Dr. Jeff Jackson Lecture 1-1Electrical & Computer Engineering – Microcomputers
Digital
Logic
Review
Outline
•Number systems and formats
–Common number systems
–Base Conversion
–
Inte
g
er re
p
resentation
gp
–Signed integer representation
–Binary coded decimal (BCD) representation
–Binary and Hex arithmetic
•Logic circuits/Boolean algebra
–Switch inputs
–NMOS and PMOS transistors and circuits
–Truth tables
–
Logic networks
Dr. Jeff Jackson Lecture 1-2Electrical & Computer Engineering – Microcomputers
–
Logic
networks
–Tri-state devices
–Basic combinatorial circuits
–Clock signals
–Storage elements
–Basic sequential circuits
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c

Partial preview of the text

Download Number Systems-Microcomputers-Lecture 01 Slides-Electrical and Computer Engineering and more Slides Microcomputers in PDF only on Docsity!

Microcomputers

Number Systems and

Digital Logic Review

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

Digital Logic Review

Outline

  • Number systems and formats
    • Common number systems
    • Base Conversion
    • Integer representationg p
    • Signed integer representation
    • Binary coded decimal (BCD) representation
    • Binary and Hex arithmetic
  • Logic circuits/Boolean algebra
    • Switch inputs
    • NMOS and PMOS transistors and circuits
    • Truth tables
    • Logic networks

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

  • Logic networks
  • Tri-state devices
  • Basic combinatorial circuits
  • Clock signals
  • Storage elements
  • Basic sequential circuits

Review of Number Systems and Formats

• Computers are based on devices that can take only

two states (0 or 1)

• A single 0 or 1 is called a bit (BinarA single 0 or 1 is called a bit (Binary Digit) Digit)

• Bits may be concatenated to represent many

different entities

  • Characters, integers, floating point numbers, etc.

• In general, n bits can represent 2

n

distinct entities

( l )

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

(values)

Review of Number Systems and Formats

• Example

• n=0 2

n

n

• n=1 2

n

• n=2 2

n

• n=3 2

n

• n=4 2

n

  • Strings of bits can be used to represent numbers, letters, etc.

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

g p , ,

  • Numbers are associated with bit combinations according to specific number formats.

Binary (Integer) Format

• example: base=10 number=

would be written as:

610 4 + 510^3 + 310^2 + 010^1 + 8*10^0

• But, computers are built on 2-state devices and

work with BINARY (i.e. BASE 2) numbers:

• example: base=2 number=

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

would be written as:

12^4 + 02^3 + 12^2 + 12^1 + 0*2^0

Number Systems

• To talk about binary data, we must first talk about

number systems

• The decimal n mber s stem (base 10)The decimal number system (base 10) you should o sho ld

be familiar with

  • A digit in base 10 ranges from 0 to 9.
  • A digit in base 2 ranges from 0 to 1 (binary number system). A digit in base 2 is also called a ‘bit’.
  • A digit in base R can range from 0 to R-

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

A digit in base R can range from 0 to R 1

  • A digit in Base 16 can range from 0 to 16- (0,1,2,3,4,5,5,6,7,8,9,A,B,C,D,E,F). Use letters A-F to represent values 10 to 15. Base 16 is also called Hexadecimal or just ‘Hex’.

Common Number Systems (BASES) Used In

Computers

BINARY OCTAL DECIMAL HEXADECIMAL (Base 2) (Base 8) (Base 10) (Base 16)

0 0 - 000 0 - 0000 0 - 0000 A - 1010 1 1 - 001 1 - 0001 1 - 0001 B - 1011 2 - 010 2 - 0010 2 - 0010 C - 1100 3 - 011 3 - 0011 3 - 0011 D - 1101 4 - 100 4 - 0100 4 - 0100 E - 1110 5 - 101 5 - 0101 5 - 0101 F - 1111 6 - 110 6 - 0110 6 - 0110 7 111 7 0111 7 0111

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

7 - 111 7 - 0111 7 - 0111 8 - 1000 8 - 1000 9 - 1001 9 - 1001

Positional Notation

• Value of number is determined by multiplying each

digit by a weight and then summing

• TheThe weight of each digit is a POWER of the BASE eight of each digit is a POWER of the BASE

and is determined by position

– 953.78 = 9 * 10^2 + 5 * 10^1 + 3 * 10^0 + 7 * 10-1^ + 8 * 10-

  • 0b1011.11 = 12 3 + 02^2 + 12^1 + 12^0 + 12-1^ + 12- = 8 + 0 + 2 + 1 + 0.5 + 0.

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

  • 0xA2F = 1016^2 + 216^1 + 15*16^0 = 10 * 256 + 2 * 16 + 15 * 1 = 2560 + 32 + 15 = 2607

Conversion Of Binary To Hexadecimal Or

Octal

• Group binary digits into groups of four and

assign each group a hexadecimal digit

0110 1011 0111 6 B 7

  • Binary-to-octal: 011 010 110 111 3 2 6 7
  • Hexadecimal-to-binary: A 1 9

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

A 1 9 1010 0001 1001

  • Octal-to-binary: 5 0 3 1 101 000 011 001

Negative Integer Representation

• Sign-magnitude format

  • Attach an extra bit to indicate the sign of the numberAtt h t bit t i di t th i f th b (0=+, 1=-)
  • example:

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

Negative Integer Representation

• 2's complement format

  • Negative numbers are assigned as follows: -b = 2b 2 n -bb
  • where b is the magnitude and n is the number of bits representing the number

• example: n=16 b=1234 10

(04D2)

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

= (04D2) 16

• -b (in 2's complement)

= (FB2E) 16

Negative Integer Representation

  • In general:
    • If n bits are used in the 2's complement number system, then from -2 n-1^ to 2 n-1^ -1 can be represented.
    • example:example: n=16n= integers from -2 16-1^ = - to 2 16-1^ -1 = 32767
  • Forming 2's complement numbers
  • 2 methods

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

  • Exchange all 1's and 0's and add 1
    • example: b=0101 (2 4 -1)-b = 1010 (1's complement)+ = 1011 (2's complement)
  • Exchange all 1's and 0's after the first 1

Binary Addition and Subtraction

The rules for binary arithmetic are:

The rules for binary subtraction are:

0 + 0 = 0, carry = 0 1 + 0 = 1, carry = 0 0 + 1 = 1, carry = 0

1 + 1 = 0, carry = 1

0 - 0 = 0, borrow = 0 1 - 0 = 1, borrow = 0 0 - 1 = 1, borrow = 1

1 - 1 = 0, borrow = 0

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

Borrows, Carries from digits to left of current of digit.

Binary subtraction, addition works just the same as decimal addition, subtraction.

Binary, Decimal addition

Decimal 0b 101011 0b 000001

Binary

from LSD to MSD: 7+4 = 1; with carry out of 1 to next column

  • 0b 000001

101100 From LSB to MSB: 1+1 = 0, carry of 1 1 (carry)+1+0 = 0, carry of 1 1 (carry)+0 + 0 = 1 no carry

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

to next column

1 (carry) + 3 + 1 = 5. answer = 51.

1 (carry)+0 + 0 = 1, no carry 1 +0 = 1 0 + 0 = 0 1 + 0 = 1 answer = % 101100

Subtraction

Decimal

900

Binary

0b 100

  • 001

     899 

0-1 = 9; with borrow of 1 from next column 0 1 (b ) 0 9 ith

  • 0b 001

     011 

0-1 = 1; with borrow of 1 from next column

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

0 -1 (borrow) - 0 = 9, with borrow of 1 9 - 1 (borrow) - 0 = 8. Answer = 899.

0 -1 (borrow) - 0 = 1, with borrow of 1 1 - 1 (borrow) - 0 = 0. Answer = % 011.

Hex Addition

0x3A 0 28

0x3A = 3 * 16 + 10

Decimal check.

  • 0x

0x

A+8 = 2; with carry out of 1 to next column

0x28 = 2 * 16 + 8 = 40 58 + 40 = 98

0x62 = 6 * 16 + 2

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

1 (carry) + 3 + 2 = 6. answer = 0x

0x62 6 16 + 2 = 96 + 2 = 98!!

Hex subtraction again

Why is 0x4 – 0x7 = 0xD with a borrow of 1?

The borrow has a weight equal to the BASE (in this case 16).

BORROW +0x4 – 0x7 = 16 + 4 - 7 = 20 - 7 = 13 = 0xD.

0xD is the result of the subtraction with the borrow

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

0xD is the result of the subtraction with the borrow.

Exactly the same thing happens in decimal. 3 - 8 = 5 with borrow of 1 borrow + 3 - 8 = 10 + 3 - 8 = 13 - 8 = 5.

Unsigned Overflow

In this class I will use 8 bit precision most of the time, 16 bit occasionally.

Overflow occurs when I add or subtract two numbers, and the correct result is a number that is outside of the range of allowable numbers for that precision. I can have both unsigned and signed overflow (more on signed numbers later)

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

8 bits -- unsigned integers 0 to 2 8 -1 or 0 to 255

16 bits -- unsigned integers 0 to 2^16 -1 or 0 to 65535

Unsigned Overflow Example

Assume 8 bit precision; i.e. I can’t store any more than 8 bits for each number. LetsLets addadd 255 + 1 = 256. 255 1 256. The number 256 is OUTSIDE the rangeThe number 256 is OUTSIDE the range of 0 to 255! What happens during the addition?

255 = 0x FF

  • 1 = 0x 01

256 /= 0x00 /= means Not Equal

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

0xF + 1 = 0, carry out 0xF + 1 (carry) + 0 = 0, carry out Carry out of MSB falls off end, No place to put it!!! Final answer is WRONG because could not store carry out.

Unsigned Overflow

A carry out of the Most Significant Digit (MSD) or Most Significant Bit (MSB) is an OVERFLOW indicator forg ( ) addition of UNSIGNED numbers. The correct result has overflowed the number range for that precision, and thus the result is incorrect. If we could STORE the carry out of the MSD, then the answer would be correct. But we are assuming it is f f

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

discarded because of fixed precision, so the bits we have left are the incorrect answer.

Representing ‘1’ and ‘0’

  • In the electrical world, two ways of representing ‘0’ and ‘1’ are (these are not the only ways): - Presence or absence of electrical current - Different Voltage levels
  • Different voltage levels are the most common
    • Usually 0v for logic ‘0’, some non-zero voltage for logic ‘1’ (I.e. > 3 volts)
  • Can interface external sources to digital systems in many ways

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

  • Switches, buttons, other human controlled input devices
  • Transducers (change a physical quantity like temperature into a digital quantity).

Switch Inputs

Vdd High True Vdd switch

Vdd is power supply voltage, typically 5V or 3 3V

L H

3.3V

Gnd is 0 V

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

Gnd Gnd

Switch open ( negated ) , output is L

Switch closed ( asserted ), output is H

Examples of high, low signals

Vdd Vdd Low True switch

H L

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

Gnd Gnd

Switch open (negated), output is H

Switch closed (asserted), output is L

CMOS transistors (P, N)

S: source G: gate

D: drain

transistor operation of P, N types is

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

Copyright 2005. Thomson/Delmar Learning, All rightsreserved.

yp complementary to each other

Logic gates and networks

• Each basic logic operation (AND, OR, NOT) can be

implemented resulting in a circuit element called a

logic gatelogic gate

• A logic gate has one or more inputs and one output

that is a function of its inputs

x 1 x 2 x

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

xn

x 1 x 2^ x^1 ^ x^2 x^1 ^ x^2 ^ ^ xn

AND gates

Logic gates and networks

x 1 xx 2

xn

x x (^1) x 1 + x 2 + + xn 2

x 1 + x 2

OR gates

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

x x

NOT gate

Logic gates and networks

• A larger circuit is implemented by a network of

gates

  • Called a logic network or logic circuitCalled a logic network or logic circuit

x 1 x 2 x 3^ f^ = x^1 + x^2 ^  x^3

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

Analysis of a logic network

• To determine the functional behavior of a logic

network, we can apply all possible input signals to it

x 1

x 2

1  1  0  0

f 0  0  0  1

1  1  0  1

0  0  1  1

0  1  0  1

A

B

Electrical & Computer Engineering – Microcomputers Dr. Jeff Jackson Lecture 1-

Network that implements f = x 1 + x 1  x 2