Module 04
Module 04
Module 04
4-1
Floating-Point, Integer and Fixed-Point
Two basic categories of
processors:
Floating-Point
Integer/Fixed-Point
What is the difference?
What are advantages /
disadvantages ?
Real-Time Control:
Most microcontrollers are Fixed-Point!
F2833x supports both worlds in
hardware!
4-2
Processor Types
Floating-Point Processors
Internal Hardware Unit to support Floating -
Point Operations
Examples: Intel’s Pentium Series , Texas
Instruments C6000 DSP
High dynamic range for numeric calculation
Usually more expensive
Integer / Fixed-Point Processors
Fixed-Point Arithmetic Unit
Almost all embedded controllers are fixed
point machines
Examples: all microcontroller families, e.g.
Freescale S12X, Infineon C166, Texas
Instruments MSP430, Atmel AVR
Lowest price per MIPS 4-3
Standard IEEE-754 Single Precision
Floating-Point
31 30 23 22 0
s eeeeeeee fffffffffffffffffffffff
1 bit sign 8 bit exponent 23 bit mantissa (fraction)
4-4
Floating-Point does not solve
everything!
Example: x = 10.0 (0x41200000)
+ y = 0.000000240 (0x3480D959)
z = 10.000000240 WRONG!
RIGHT?
You cannot represent 10.000000240 with
single-precision floating-point
0x412000000 = 10.000000000
10.000000240 can’t represent!
0x412000001 = 10.000001000
Binary Numbers
01102 = (0*8)+(1*4)+(1*2)+(0*1) = 610
111102 = (1*16)+(1*8)+(1*4)+(1*2)+(0*1) = 3010
4-6
Four-Bit Integer Multiplication
0100 4
x 1101 x -3
00000100
0000000
000100
+ 11100
11110100 -12
Accumulator 11110100
11110100
Data Memory ?
Is there another (superior) numbering system? 4-7
Binary Fractions
11 00 11 11
-1
• 1/2 1/4 1/8
4-8
Four-Bit IQ - Multiplication
0100
. 1/2
x 1101
. x - 3/8
00000100
0000000
000100
11100
11110100 -3/16
Accumulator 11110100
11110100
.
-2I + 2I-1 + … + 21 + 20 2-1 + 2-2 + … + 2-Q
“IQ” – Format
“I” INTEGER – Fraction
“Q” QUOTIENT – Fraction
4 - 10
IQ - Examples
I1Q3 – Format:
3 0
S fff
Most negative decimal number: -1.0 = 1.000 B
4 - 11
IQ - Examples
I3Q1 – Format:
3 0
SII f
Most negative decimal number: -4.0 = 100.0 B
4 - 12
IQ - Examples
I1Q31 – Format:
31 0
4 - 13
IQ - Examples
I8Q24 – Format:
31 0
4 - 14
IQ-Math can do better!
z = 10.000000240 (0x0A000004)
4 - 15
How is a fraction coded?
~1 ~ 32K 7FFF
½ 16K 4000
0
0 0000
*32768
–½ –16K C000
–1 –32K 8000
Fractions Integers Hex
4 - 17
Lab4: Fixed-point and Floating-point
Benchmark Multiply Operation
k=i*i
Test setup:
1. Integer multiply operation
2. Floating-Point multiply by Floating-Point Library
3. Floating-Point multiply by Floating-Point
Hardware unit
Benchmark result:
Fixed-point Floating-Point- Floating-Point-
Library Hardware
code size (words) 3 89 9
clock cycles (6.67 ns) 3 112 5
4 - 18