Number Systems - Texas State University

Download Report

Transcript Number Systems - Texas State University

EE2420 – Digital Logic
Summer II 2013
Set 1: Number Systems
Hassan Salamy
Ingram School of Engineering
Texas State University
Course Objectives
2





This is the first class to actually understand how
computers really work.
You will understand how computers can do Arithmetic,
Store Data, Understand Data…
You will learn how to build digital systems that can
perform useful operations.
You will learn the hierarchy of design. Using a small
simple digital system to build a more sophisticated
systems.
You will have a hands on training.
Course objectives in depth
3

Ability to use and convert between different number systems including binary, hexadecimal
and octal.

Ability to apply Boolean algebra to digital systems

Develop an understanding of designing a digital logic circuit based system to achieve a
prescribed task.

Analyze and synthesize logic networks using traditional techniques such as K-maps and state
tables.

Combinatorial Logic: Analyze and design basic combinatorial logic systems, Develop simplify
and implement [with various types of gates] sum of products [SOP] and product of sums [POS]
expressions

Sequential Logic: Analyze and design of basic sequential logic systems, analyze various
circuits, including determination of waveforms and state diagrams, with SD, D, JK and T flipflops.

Develop an ability to conduct experiments, as well as analyze and interpret data.

Design and simulate digital systems using MULTISIM.

Discuss the operation of standard lab equipment, define the terminology used to define
specification, indicate typical specification values for standard lab equipment.
Course objectives in depth
4

Configure, operate, and debug an experimental set-up using standard lab equipment.

Design a system, component, or process to meet a set of specifications.

Design, conduct, and interpret a validation test.

Students are required to work in teams during the course laboratory component with each
member responsible for each project outcome.

Communicate effectively with team members regardless of technical discipline.

Preparation of formal written lab reports.
Lecture Objective
5

Number Systems: Representation and conversion.
Representing numbers: notation
6

Writing a number such as 158, assumes a decimal positional notation and
implies
1*102 + 5*101 + 8*100


More correctly, this should be written as 158ten or 15810 to be unambiguous.
However, most sources assume any number without a specified radix to be
decimal.
We can choose any positive integer two or larger to serve as the basis for an
unambiguous positional notation. The integer we choose is called the radix or
base.
Choosing a Radix
7







A system based on a radix of 10 is called decimal. This is what we are
commonly taught as children.
A number written without a radix appended as a subscript is assumed to be
decimal so 198 = 19810
A system based on a radix of 5 is called pental or quintinary. This is not
generally convenient for us.
A system based on a radix of 2 is called binary. This is very convenient for
computers since every coefficient can have exactly one of two values and can
correspond to the two states of a switch.
A system based on a radix of 4 is called quaternary.
A system based on a radix of 8 is called octal.
A system based on a radix of 16 is called hexadecimal.
Choosing a Radix
8

A few commonly used radii:














A system based on a radix of 2 is called binary. This is very common for computers.
A system based on a radix of 3 is called ternary or trinary.
A system based on a radix of 4 is called quaternary.
A system based on a radix of 5 is called quinary or pental.
A system based on a radix of 6 is called senary or heximal.
A system based on a radix of 7 is called septenary or septal.
A system based on a radix of 8 is called octonary or octal.
A system based on a radix of 9 is called nonary or nonal
A system based on a radix of 10 is called decimal. This is what we are commonly taught as
children. A number written without a radix appended as a subscript is assumed to be decimal so
158 = 15810
A system based on a radix of 12 is called duodecimal.
A system based on a radix of 16 is called hexadecimal.
A system based on a radix of 20 is called vigesimal.
A system based on a radix of 36 is called hexatridecimal.
A system based on a radix of 60 is called sexagesimal.
Representing numbers: history
9




By far the most common method people use for representing numbers is the
Hindu-Arabic positional notation based on integer powers-of-ten, commonly
referred to as a decimal system.
This is certainly not the only system in use, and there are many examples in our
everyday lives showing the historical influence of other number systems.
Ancient Egyptian culture used a system based on twelve. Sales of items in groups
by the dozen (twelve) and gross (twelve twelves or one hundred forty-four) come
from this tradition.
Babylonian culture used a system based on sixty, with subgroups of six and ten
having special meaning. Dividing hours into sixty minutes of sixty seconds each
and dividing circles into three hundred sixty degrees, i.e. six groups of sixty, both
derive from this tradition.
Positional Notation
10

Once we have chosen a radix R, we know the value of every digit in the number.

For base R RN RN-1…R3 R2 R1 R0 . R-1 R-2 R-3…

For base 10  10N 10N-1…103 102 101 100 . 10-1 10-2 10-3…

For base 2  2N 2N-1…23 22 21 20 . 2-1 2-2 2-3…

For base 5  5N 5N-1…53 52 51 50 . 5-1 5-2 5-3…

The point separating the positive and negative powers of the radix is called the radix
point. When the base is 10, this is called the decimal point.
Representing numbers: tools
11





One of the oldest tools for storing and manipulating numbers is the abacus.
An abacus is usually built as a framework with a number of beads strung on
parallel wires. Each wire represents one digit in a positional notation. Beads are
moved as far as possible to one end of the frame or the other. For our examples,
“down” will be the inactive side of the frame and “up” will be the active side.
Beads that are down will not be counted and beads that are up will be counted.
Stringing nine beads per wire allows each position to count from zero to nine
making a decimal abacus.
The simplest abacus would have one bead per wire counting zero or one for each
position. With two possible states this is a binary abacus.
Any integer within range can be represented by either abacus.
Decimal and binary abacus
example
12

103
Both abacuses represent one hundred fifty-eight
102
101
100
128
64
32
16
8
4
2
1
27
26
25
24
23
22
21
20
1
0
0
1
1
1
1
0
128 + 16 + 8 + 4 + 2 = 158
0
1
5
8
Why computers use binary
13





The reason computers use binary formats for numbers is quite simple.
The electronics from which computers are made act like switches.
These switches have exactly two useful states: “on” or “off”
This is exactly analogous to the binary abacus where the single bead
per wire is either “up” or “down”
For the abacus, we let a “down” bead represent zero and an “up”
bead represent one. For the electronic switches, we typically let an
“off” switch represent a zero and an “on” switch represent a one.
Just as the abacus has a fixed number of wires limiting the range of
numbers that can be represented, computers have a fixed number of
switches similarly limiting the range of numbers that can be stored.
How high can computers count?
14




Consider the 8-bit binary abacus below. With two possible values per wire and
eight wires it can represent exactly 256 (28) different numbers.
A computer using eight switches to form a byte can represent exactly 256 (28)
different numbers.
If we treat the bits, either beads or switches, as zeros and ones multipled by the
corresponding powers-of-two, the 8-bit byte can represent any integer number
from 0 to 255.
In general, N bits can count from 0 to (2N – 1)
128
64
32
16
8
4
2
1
27
26
25
24
23
22
21
20
1
0
0
1
1
1
1
0
128 + 16 + 8 + 4 + 2 = 158
Counting in Binary
15
















00002 = 0*23+0*22+0*21+0*20 = 0+0+0+0 = 010
00012 = 0*23+0*22+0*21+1*20 = 0+0+0+1 = 110
00102 = 0*23+0*22+1*21+0*20 = 0+0+2+0 = 210
00112 = 0*23+0*22+1*21+1*20 = 0+0+2+1 = 310
01002 = 0*23+1*22+0*21+0*20 = 0+4+0+0 = 410
01012 = 0*23+1*22+0*21+1*20 = 0+4+0+1 = 510
01102 = 0*23+1*22+1*21+0*20 = 0+4+2+0 = 610
01112 = 0*23+1*22+1*21+1*20 = 0+4+2+1 = 710
10002 = 1*23+0*22+0*21+0*20 = 8+0+0+0 = 810
10012 = 1*23+0*22+0*21+1*20 = 8+0+0+1 = 910
10102 = 1*23+0*22+1*21+0*20 = 8+0+2+0 = 1010
10112 = 1*23+0*22+1*21+1*20 = 8+0+2+1 = 1110
11002 = 1*23+1*22+0*21+0*20 = 8+4+0+0 = 1210
11012 = 1*23+1*22+0*21+1*20 = 8+4+0+1 = 1310
11102 = 1*23+1*22+1*21+0*20 = 8+4+2+0 = 1410
11112 = 1*23+1*22+1*21+1*20 = 8+4+2+1 = 1510
Converting Decimal to Binary
16

198/2 = 99 remainder 0  remainder is coefficient of 20

99/2 = 49 remainder 1  remainder is coefficient of 21

49/2 = 24 remainder 1  remainder is coefficient of 22

24/2 = 12 remainder 0  remainder is coefficient of 23

12/2 = 6 remainder 0  remainder is coefficient of 24

6/2 = 3 remainder 0  remainder is coefficient of 25

3/2 = 1 remainder 1  remainder is coefficient of 26

1/2 = 0 remainder 1  remainder is coefficient of 27

Since last quotient was 0, no additional powers of 2 are required.

Converting to any base from decimal can be accomplished similarly by dividing
by the desired radix
Hexadecimal
17





For bases 10 or less, we can use the Arabic numerals
(0,1,2,3,4,5,6,7,8,9) for the coefficients of the radix
positions.
For bases greater than 10, we need additional
symbols.
We generally use the English alphabet (A,B,C,D,E,F,G…)
as additional symbols.
We most commonly see this with radix 16
(hexadecimal) for which we use A-F in the following
manner:
A16=1010, B16=1110, C16=1210, D16=1310, E16=1410,
F16=1510
Converting Decimal to Hexadecimal
18




198/16 = 12 remainder 6  remainder is
coefficient of 160
12/16 = 0 remainder 12  remainder is
coefficient of 161
Since C16=1210
19810 = C616
Converting Binary to a power-of-two Radix
19






There is a special relationship between binary (base 2) and quaternary (base
4), octal (base 8), and hexadecimal (base 16)
Whenever one radix is an integer power of another radix, a special
relationship exists
Among our commonly used bases 4=22, 8=23, 16=24 so we can use the special
relationship.
Since 4=22, every two binary digits exactly corresponds to one quaternary
digit
Since 8=23, every three binary digits exactly corresponds to one octal digit
Since 16=24, every four binary digits exactly corresponds to one hexadecimal
digit
Quick conversion among power-of-two bases
20

Group each two binary digits to form one quaternary digit

110001102 = (112)(002)(012)(102)4 = 30124

Group each three binary digits to form one octal digit

Pad with zeros on the left as necessary to form complete groups

110001102 = (0112)(0002)(1102)8 = 3068

Group each four binary digits to form one hexadecimal digit

110001102 = (11002)(01102)16 = C616