0% found this document useful (0 votes)
27 views27 pages

01 DigitalNumericalFormats

Uploaded by

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

01 DigitalNumericalFormats

Uploaded by

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

Digital Signal Processing

Numerical Representation

Fabrizio Frescura
DSP LAB
Dipartimento di Ingegneria Elettronica e
dell’Informazione - Perugia
What a DSP is
• Digital signal processing is defined as:
The science concerned with the
representation of signals by sequences
of numbers and the subsequent
processing of these number sequences

• Processing involves either extracting


certain parameters from a signal or
transforming it into a new domain
• Processors that perform such
operations in real time are known as
Digital Signal Processors
NUMERICAL REPRESENTATION AND IMPLEMENTATION ISSUES IN FIXED POINT DSPS

• Main DSPs type: Floating Point and Fixed Point


• Fixed Point numbers
– Finite precision numbers
– Negative binary numbers
– Overflow and underflow
– Dynamic range in Fixed Point DSPs
– Look-up tables
– A fixed-point DSP toolbox in Matlab
• Floating Point numbers
– Principles of Floating Point
– The IEEE Floating Point Standard
DSPs Types
• DSP processors can be categorised into two distinct groups: floating-point and
fixed-point. Each has a different architecture which is beneficial for different
applications.

• Fixed-point DSP processors represent a number in a fixed range with finite


precision. For example, a 16 bit processor will give ± 215 range and a precision
of 1in 32768. The earliest DSPs were based around this technology and for the
majority of applications today.
• Other application (Digital Audio) adopt 24 bits
• The price advantage of fixed point 16 bit processors is significant.

16/24 bits

S Integer Number (or Fixed point)


DSPs Types
• Floating-point DSP processors are much more recent.
• They express numbers as a mantissa lying between +1.0 and -1.0 combined
with a scaling function called the exponent. This method of representation
gives a greater dynamic range and therefore reduces the chance of overflow.
• Signal processing algorithms are much easier to implement on floating-point
processors and are therefore more suited to optimising high level language
compilers.
• However, this type of processor tends to be slower and more expensive than
its fixed-point counterpart.

32 bits

S Exponent Mantissa
Fixed Point Numbers
• An ordinary decimal number with which everyone is familiar consists of a
string of decimal digits and, possibly, a decimal point.

Decimal Point

10 i

• The choice of 10 as the base for exponentiation, called the radix, is


made because base 10 numbers are used
Fixed Point Numbers
• In DSPs base 2 is used so:

N = bD….. b2 b1 b0 . b-1 b-2 …….. b- (B - (D + 1))


Fractional point (fixed position)

D
N  i
b 2 i

i  ( B  ( D 1))

• B is the number of bits used in general 15, 23, 31


• Why not 16, 24, 32?
Exercise
• Given a number X1.F1
– What happens to number value when we move the
fractional point towards left?
– What happens to number value when we move the
fractional point towards right?
– What is the “Equivalent Integer” of the FP number?
– Assuming to “represent“ a real number X with
• 0 <= X < 1
• Which is the “best” 8 bit format?
• Which is the granularity (resolution) of such a format?
Exercise
• Given a number X1.F1
– What happens with a left shift ?
– What happens with a right shift ?
– How we could do a division by 2 with rounding ?

• Given two numbers: X1.F1 and X2.F2


– Which is the sum of the two numbers ?
– Which is the product?
– Which is the difference?
Negative Fixed Point Numbers
• Three main systems for representing negative numbers have
been used in digital CPUs:
• The first one is called signed magnitude. In this system the
leftmost bit is the sign bit (0 is + and 1 is -) and the remaining
bits hold the absolute magnitude of the number.
• The second system, called one's complement, also has a sign
bit with 0 used for plus and 1 for minus. To negate a number,
replace each 1 by a 0 and each 0 by a 1. This holds for the sign
bit as well. One's complement is obsolete.
Negative Fixed Point Numbers
• The third system, called two's complement, also has a sign bit that is 0 for plus and 1 for minus.
• Negating a number is a two step process.
– First, each 1 is replaced by a 0 and each 0 by a 1, just as in one's complement.
– Second, 1 is added to the result.

• For example, converting 6 to two's complement is done in two steps:


00000110 (+6)
11111001 (-6 in one's complement)
00000001 (add 1)
11111010 (-6 in two's complement)

• If a carry occurs from the leftmost bit, it is thrown away


Negative Binary Numbers
• Both signed magnitude and one's complement have two representations for zero: a plus zero, and a minus zero.
This situation is highly undesirable.
• The two's complement system does not have this problem because the two's complement of plus zero is also
plus zero.
00000000 (+0)
11111111 (-0 in one's complement)
00000001 (add 1)
100000000 (-0 in two's complement)
• The two's complement system does, however, have a different singularity. The bit pattern consisting of a 1
followed by all 0s is its own complement.
10000000 not allowed configuration for positive numbers
01111111 (one's complement)
00000001 (add 1)
10000000 (-128 in two's complement)
Negative Fixed Point Numbers
• The result is to make the range of
positive and negative numbers N = bD….. b2 b1 b0 . b-1 b-2 …….. b- (B - (D + 1))
unsymmetric; there is one negative
D 1
number with no positive counterpart.
• The reason for these problems is not N  bD 2  D  i
b 2 i

i  ( B  ( D 1))
hard to find: we want an encoding
system with two properties:
TWO’S COMPLEMENT PROPERTIES
1. Only one representation for zero.
2. Exactly as many positive
numbers as negative numbers.
• The problem is that any set of numbers 0 0000 0111 7
with as many positive as negative
numbers and only one zero has an odd
number of members, whereas m bits
allow an even number of bit patterns. -1 1111 1000 -8
Overflow and Underflow and dynamic range
N = bD….. b2 b1 b0 . b-1 b-2 …….. b- (B - (D + 1))
• Largest (positive) representable number:
D
M FP   1 2 i
If N>MFP the number is no more representable so
i  ( B  ( D 1)) overflow occour:

• Smallest (positive) representable number:


D
If |N|<NFP the number is
N FP 12  ( B  ( D 1))
  0 2
i  ( B  D )
i

no more representable
so underflow occour:
• For two’s complement numbers
D 1
the all 1s configuration is a
negative number (-1) so...
M FP   1 2 i

i  ( B  ( D 1))
Real-axe Representation with Fixed Point Numbers
B Bit Unsigned Format

0 NFP 2*NFP 3*NFP n*NFP MFP = (2B* NFP )-NFP

B Bit Signed Format: two's complement

-(2B-1* NFP ) -2*NFP -NFP 0 +NFP +2*NFP MFP = (2B-1* NFP )- NFP
Real-axe Representation with Fixed Point Numbers
Mfp

(2B-1)Nfp -2Nfp -Nfp 0 Nfp 2Nfp 3Nfp (2B-1-1)Nfp


Overflow and Underflow and dynamic range

N = bD….. b2 b1 b0 . b-1 b-2 …….. b- (B - (D + 1))


• The ratio between the Largest and the
(2 B  1) N FP
Smallest (different from 0) number D 20  log10
N FP
expressed in dB is the dynamic range:
• For example with 8 bit (integers) MFP=255 ; NFP=1 so
D=48dB
• As a general rule each bit in the Fixed point format allows 6
dB more in the signal dynamic range
• For Negative FP Numbers B 1 B 1
(2  1) N FP  (2 ) N FP
D 20  log10
N FP
Principles of Floating Point
• One way of separating the range from the precision is to
express numbers in the familiar scientific notation

e
n  f 10
• where f is called the fraction, or mantissa, and e is a
positive or negative integer called the exponent. The DSP
version of this notation is called floating point. Some
examples of numbers expressed in this form are:
3.14 = 0.314 x101 = 3.14 x100
0.000001 = 0.1 x10-5 = 1.0 x10-6
1941 = 0.1941 x104 = 1.941x x103
Principles of Floating Point
• The range is effectively determined by
the number of digits in the exponent
and the precision is determined by the
number of digits in the mantissa.
Because there is more than one way to
represent a given number, one form is
usually chosen as the standard. Mantissa Exponent
• To view the properties of this method
of representing numbers, consider a
Smaller number: +.100x10-99
representation, R, with a signed three-
digit fraction in the range 0.1 <= | f | < Largest number: +.999x10 +99

1 or zero and a signed two-digit


exponent.
Principles of Floating Point

The real line is divided up into seven regions:


1. Large negative numbers less than -0.999 x 10+99
2. Negative numbers between -0.999 x 10+99 and -0.100 x 10-99
3. Small negative numbers with magnitudes less than 0.100 x 10-99
4. Zero.
5. Small positive numbers with magnitudes less than 0.100 x 10-99
6. Positive numbers between 0.100 x 10-99 and 0.999 x 10+99
7. Large positive numbers greater than 0.999 x 10+99
Principles of Floating Point
• Another important difference between floating-point numbers and the real
numbers is their density. Between any two real numbers, x and y, is another
real number, no matter how close x is to y. This property comes from the fact
that for any distinct real numbers, x and y, z = (x + y)/2 is a real number
between them. The real numbers form a continuum.
• Floating-point numbers, in contrast, do not form a continuum.
• The spacing between adjacent expressible numbers is not constant throughout
region 2 or 6. The separation between +0.998 x 10+99 and +0.999 x 10+99 is vastly
more than the separation between +0.998 x 10+00 and +0.999 x 10+00.
• However, when the separation between a number and its successor is
expressed as a percentage of that number, there is no systematic variation
throughout region 2 or 6. In other words, the relative error introduced by
rounding is approximately the same for small numbers as large numbers.
Principles of Floating Point
• A variation of this representation is
used in DSPs.
• For efficiency, exponent is expressed
to base 2, rather than 10, in which
Mantissa Exponent
case the fraction consists of a string
of binary digits.
Our Model

• If the leftmost of these digits is zero,


32 bits all the digits can be shifted one place
to the left and the exponent
S Exponent Mantissa
decreased by 1, without changing the
value of the number.
DSP • A fraction with a nonzero leftmost
digit is said to be normalized.
Exercise
• Given two numbers: X1eE1 and X2eE2
– Which is the sum of the two numbers
– Which is the product?
– Which is the difference?
– Which is the ratio?
The IEEE Floating Point Standard 754
• Until about 1980, each manufacturer had its own floating-point format.
Needless to say, all were different. Worse yet, some of them actually did
arithmetic incorrectly because floating-point arithmetic has some
subtleties not obvious to the average hardware designer.
• To rectify this situation, in the late 1970s IEEE set up a committee to
standardize floating-point arithmetic, not only to permit floating-point
data to be exchanged among different machines, but to also to provide
hardware designers with a model known to be correct.
• The resulting work led to IEEE Standard 754 (IEEE, 1985). Most CPUs and
DSPs these days conform to the IEEE floating-point standard
The IEEE Floating Point Standard 754
• The standard defines three formats:
32 bits
– single precision (32 bits),
– double precision (64 bits), S Exponent Mantissa
– extended precision (80 bits).
1 8 23
• DSPs use mostly single precision, but some
DSP (es. TI C67x) provide also hardware
support for double precision
64 bits
• Both the single- and double-precision formats S Exponent Mantissa
use radix-2 for fractions and exponents.
1 11 52
The IEEE Floating Point Standard 754

Features of single and double precision formats


The IEEE Floating Point Standard 754

IEEE Numerical type and special configuration

You might also like