SlideShare una empresa de Scribd logo
1 de 21
Descargar para leer sin conexión
Fixed-point arithmetic
David Barina
May 23, 2014
David Barina Fixed-point May 23, 2014 1 / 21
Integer
1 1 1 1
1 0 0 0
0 1 1 1
0 0 0 0
15
7
8
0
…
…
1 1 1 1
1 0 0 0
0 1 1 1
0 0 0 0
−1
7
−8
0
…
…
David Barina Fixed-point May 23, 2014 2 / 21
Floating point
a × 2b
sign exponent (8 bits) fraction (23 bits)
02331
0 0 1 1 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = 0.15625
30 22 (bit index)
David Barina Fixed-point May 23, 2014 3 / 21
Fixed point
1 1 1 1
1 0 0 0
0 1 1 1
0 0 0 0
−0.0625
7.9375
−8.0000
0.0000
…
…
1 1 1 1
0 0 0 0
1 1 1 1
0 0 0 0
1 1 1 1
1 0 0 0
0 1 1 1
0 0 0 0
15.9375
7.9375
8.0000
0.0000
…
…
1 1 1 1
0 0 0 0
1 1 1 1
0 0 0 0
David Barina Fixed-point May 23, 2014 4 / 21
Benefits
Advantages
instructions for the integer arithmetic are sufficient
no need for FP instructions (FPU, SSE)
constant resolution in the whole range
higher accuracy (small dynamic ranges)
Drawbacks
limited range
overflow
less accuracy (greater dynamic ranges)
David Barina Fixed-point May 23, 2014 5 / 21
Notation
Qm.n
Q3.4 1 sign bit, 3 integer, 4 fractional bits
Q1.30 32 bits in total
Q15.16 32 bits in total
David Barina Fixed-point May 23, 2014 6 / 21
Examples
type name bits resolution range
INT integer 32 1 ±231 ≈ ±2.1 × 109
FP single 32 2−23 ≈ 1.2 × 10−7 ±2128 ≈ ±3.4 × 1038
FX Q15.16 32 2−16 ≈ 1.5 × 10−5 ±215 ≈ ±3.2 × 104
FX Q1.30 32 2−30 ≈ 9.3 × 10−10 ±2
David Barina Fixed-point May 23, 2014 7 / 21
Conversion (Qm.n)
INT → FX
y = x << n;
FX → INT
k = 1 << (n-1);
y = (x + k) >> n;
FP → FX
#include <math.h>
y = round( x * (1 << n) );
FX → FP
y = (double)x / (1 << n);
David Barina Fixed-point May 23, 2014 8 / 21
Rounding (Qm.n)
Truncation
int floor(int x) {
return x & ˜((1<<n)-1);
}
Ceiling
int ceil(int x) {
return floor(x + ((1<<n)-1));
}
Rounding
int round(int x) {
return floor(x + (1<<(n-1)));
}
David Barina Fixed-point May 23, 2014 9 / 21
Operations (Qm.n)
Zero
z = 0;
Unit
z = 1 << n;
One half
z = 1 << (n-1);
Negation
z = -x;
Absolute value
z = abs(x);
David Barina Fixed-point May 23, 2014 10 / 21
Operations (Qm.n)
Addition
z = x + y;
Subtraction
z = x - y;
Multiplication by an integer
z = x * i;
Multiplication
k = 1 << (n-1);
z = ( x * y + k ) >> n;
Division
z = (x << n) / y;
David Barina Fixed-point May 23, 2014 11 / 21
Multiplication (Q15.16)
Multiply a.b × c.d
uint32_t result_low = (b * d);
uint32_t result_mid = (a * d) + (b * c);
uint32_t result_high = (a * c);
uint32_t result = (result_high << 16) + result_mid
+ (result_low >> 16);
David Barina Fixed-point May 23, 2014 12 / 21
Trick
Division by a constant
a/b → a × c c = 1/b
z = a / 5;
// 1/5 = 0.2 = 858993459 in Q31.32
z = (a * 858993459) >> 32;
David Barina Fixed-point May 23, 2014 13 / 21
Functions
Sine by Taylor series [libfixmath]
sin(x) = x −
x3
3!
+
x5
5!
−
x7
!7
+
x9
!9
−
x11
11!
Sine by polynomial [Fixmath]
16 segments, polynomial of degree 4, Remez alg.
sin(x) = c0 + c1x1
+ c2x2
+ c3x3
+ c4x4
David Barina Fixed-point May 23, 2014 14 / 21
Functions
Inverse square root [Fixmath]
y = 1/
√
x
Newton’s method
x → a × 2b
y = y (3 − a y2
)/2
Square root [Fixmath]
x → a × 2b
c = 1/
√
a × a =
√
a
y ← c × 2b/2
David Barina Fixed-point May 23, 2014 15 / 21
Functions
Square root [libfixmath]
abacus algorithm
while (one != 0) {
if (x >= y + one) {
x = x - (y + one);
y = y + 2 * one;
}
y /= 2;
one /= 4;
}
David Barina Fixed-point May 23, 2014 16 / 21
Functions
Reciprocal value [Fixmath]
y = 1/x
Newton’s method
x → a × 2b
y = y (2 − ay)
Division
z = x/y =⇒ z = x × (1/y)
David Barina Fixed-point May 23, 2014 17 / 21
Functions
Exponential function [libfixmath]
x > 0 =⇒ e−x = 1/ex
ex
=
∞
n=0
xn
n!
Natural logarithm [libfixmath]
Newton’s method
y = y +
x − ey
ey
David Barina Fixed-point May 23, 2014 18 / 21
Functions
Base-2 logarithm [libfixmath]
y = log2(x) |Qm.n
y = 0;
while( x >= 2 ) {
x /= 2;
y++;
}
for_each(n) {
x *= x;
y *= 2;
if( x >= 2 ) {
x /= 2;
y++;
}
}
David Barina Fixed-point May 23, 2014 19 / 21
Functions
Base-2 logarithm [Fixmath]
y = log2(1 + x)
16 segments, polynomial of degree 4/11, Remez alg.
Base-2 exponential [Fixmath]
y = 2x
1/32 segments, polynomial of degree 7/3, Remez alg.
David Barina Fixed-point May 23, 2014 20 / 21
Libraries
libfixmath http://code.google.com/p/libfixmath/
Fixmath http://savannah.nongnu.org/projects/fixmath/
David Barina Fixed-point May 23, 2014 21 / 21

Más contenido relacionado

La actualidad más candente

Partial fraction decomposition for inverse laplace transform
Partial fraction decomposition for inverse laplace transformPartial fraction decomposition for inverse laplace transform
Partial fraction decomposition for inverse laplace transformVishalsagar657
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languagesparmeet834
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computationBipul Roy Bpl
 
SOP POS, Minterm and Maxterm
SOP POS, Minterm and MaxtermSOP POS, Minterm and Maxterm
SOP POS, Minterm and MaxtermSelf-employed
 
Boolean Function SOP & POS
Boolean Function SOP &  POSBoolean Function SOP &  POS
Boolean Function SOP & POSGargiKhanna1
 
2. Fixed Point Iteration.pptx
2. Fixed Point Iteration.pptx2. Fixed Point Iteration.pptx
2. Fixed Point Iteration.pptxsaadhaq6
 
Chapter 3: Simplification of Boolean Function
Chapter 3: Simplification of Boolean FunctionChapter 3: Simplification of Boolean Function
Chapter 3: Simplification of Boolean FunctionEr. Nawaraj Bhandari
 
Digital Logic Circuits
Digital Logic CircuitsDigital Logic Circuits
Digital Logic Circuitssathish sak
 
Fourier analysis of signals and systems
Fourier analysis of signals and systemsFourier analysis of signals and systems
Fourier analysis of signals and systemsBabul Islam
 
Digital Logic & Design (DLD) presentation
Digital Logic & Design (DLD) presentationDigital Logic & Design (DLD) presentation
Digital Logic & Design (DLD) presentationfoyez ahammad
 
Lesson 11: Limits and Continuity
Lesson 11: Limits and ContinuityLesson 11: Limits and Continuity
Lesson 11: Limits and ContinuityMatthew Leingang
 
Line Segment Intersections
Line Segment IntersectionsLine Segment Intersections
Line Segment IntersectionsBenjamin Sach
 
Digital electronics
Digital electronicsDigital electronics
Digital electronicsnanishajieha
 
Chapter 06 boolean algebra
Chapter 06 boolean algebraChapter 06 boolean algebra
Chapter 06 boolean algebraIIUI
 

La actualidad más candente (20)

Partial fraction decomposition for inverse laplace transform
Partial fraction decomposition for inverse laplace transformPartial fraction decomposition for inverse laplace transform
Partial fraction decomposition for inverse laplace transform
 
Boolean algebra & logic gates
Boolean algebra & logic gatesBoolean algebra & logic gates
Boolean algebra & logic gates
 
Quine Mc Cluskey Method
Quine Mc Cluskey MethodQuine Mc Cluskey Method
Quine Mc Cluskey Method
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languages
 
Regular expressions-Theory of computation
Regular expressions-Theory of computationRegular expressions-Theory of computation
Regular expressions-Theory of computation
 
Binary Number System and Codes
Binary Number System and CodesBinary Number System and Codes
Binary Number System and Codes
 
SOP POS, Minterm and Maxterm
SOP POS, Minterm and MaxtermSOP POS, Minterm and Maxterm
SOP POS, Minterm and Maxterm
 
STLD-Combinational logic design
STLD-Combinational  logic design STLD-Combinational  logic design
STLD-Combinational logic design
 
Boolean Function SOP & POS
Boolean Function SOP &  POSBoolean Function SOP &  POS
Boolean Function SOP & POS
 
2. Fixed Point Iteration.pptx
2. Fixed Point Iteration.pptx2. Fixed Point Iteration.pptx
2. Fixed Point Iteration.pptx
 
Chapter 3: Simplification of Boolean Function
Chapter 3: Simplification of Boolean FunctionChapter 3: Simplification of Boolean Function
Chapter 3: Simplification of Boolean Function
 
Digital Logic Circuits
Digital Logic CircuitsDigital Logic Circuits
Digital Logic Circuits
 
Fourier analysis of signals and systems
Fourier analysis of signals and systemsFourier analysis of signals and systems
Fourier analysis of signals and systems
 
Huffman codes
Huffman codesHuffman codes
Huffman codes
 
Digital Logic & Design (DLD) presentation
Digital Logic & Design (DLD) presentationDigital Logic & Design (DLD) presentation
Digital Logic & Design (DLD) presentation
 
Lesson 11: Limits and Continuity
Lesson 11: Limits and ContinuityLesson 11: Limits and Continuity
Lesson 11: Limits and Continuity
 
Line Segment Intersections
Line Segment IntersectionsLine Segment Intersections
Line Segment Intersections
 
Digital electronics
Digital electronicsDigital electronics
Digital electronics
 
Huffman Coding
Huffman CodingHuffman Coding
Huffman Coding
 
Chapter 06 boolean algebra
Chapter 06 boolean algebraChapter 06 boolean algebra
Chapter 06 boolean algebra
 

Destacado

Integer Representation
Integer RepresentationInteger Representation
Integer Representationgavhays
 
Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...
Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...
Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...Silicon Mentor
 
Decimal arithmetic in Processors
Decimal arithmetic in ProcessorsDecimal arithmetic in Processors
Decimal arithmetic in ProcessorsPeeyush Pashine
 
digital logic circuits, digital component floting and fixed point
digital logic circuits, digital component floting and fixed pointdigital logic circuits, digital component floting and fixed point
digital logic circuits, digital component floting and fixed pointRai University
 
Optimized Floating-point Complex number multiplier on FPGA
Optimized Floating-point Complex number multiplier on FPGAOptimized Floating-point Complex number multiplier on FPGA
Optimized Floating-point Complex number multiplier on FPGADr. Pushpa Kotipalli
 
Design and Implementation of High Speed Area Efficient Double Precision Float...
Design and Implementation of High Speed Area Efficient Double Precision Float...Design and Implementation of High Speed Area Efficient Double Precision Float...
Design and Implementation of High Speed Area Efficient Double Precision Float...IOSR Journals
 
Floating point units
Floating point unitsFloating point units
Floating point unitsdipugovind
 
Quick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representationQuick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representationRitu Ranjan Shrivastwa
 
Floating point ALU using VHDL implemented on FPGA
Floating point ALU using VHDL implemented on FPGAFloating point ALU using VHDL implemented on FPGA
Floating point ALU using VHDL implemented on FPGAAzhar Syed
 

Destacado (16)

06 floating point
06 floating point06 floating point
06 floating point
 
Integer Representation
Integer RepresentationInteger Representation
Integer Representation
 
Representation of Real Numbers
Representation of Real NumbersRepresentation of Real Numbers
Representation of Real Numbers
 
Exceptions in python
Exceptions in pythonExceptions in python
Exceptions in python
 
Class10
Class10Class10
Class10
 
Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...
Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...
Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...
 
Decimal arithmetic in Processors
Decimal arithmetic in ProcessorsDecimal arithmetic in Processors
Decimal arithmetic in Processors
 
digital logic circuits, digital component floting and fixed point
digital logic circuits, digital component floting and fixed pointdigital logic circuits, digital component floting and fixed point
digital logic circuits, digital component floting and fixed point
 
Optimized Floating-point Complex number multiplier on FPGA
Optimized Floating-point Complex number multiplier on FPGAOptimized Floating-point Complex number multiplier on FPGA
Optimized Floating-point Complex number multiplier on FPGA
 
Design and Implementation of High Speed Area Efficient Double Precision Float...
Design and Implementation of High Speed Area Efficient Double Precision Float...Design and Implementation of High Speed Area Efficient Double Precision Float...
Design and Implementation of High Speed Area Efficient Double Precision Float...
 
Data representation
Data representationData representation
Data representation
 
Floating point units
Floating point unitsFloating point units
Floating point units
 
Quick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representationQuick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representation
 
Floating point ALU using VHDL implemented on FPGA
Floating point ALU using VHDL implemented on FPGAFloating point ALU using VHDL implemented on FPGA
Floating point ALU using VHDL implemented on FPGA
 
Computer arithmetic
Computer arithmeticComputer arithmetic
Computer arithmetic
 
Sampling design
Sampling designSampling design
Sampling design
 

Similar a Fixed-point arithmetic

Bit Twiddling Hacks: Integers
Bit Twiddling Hacks: IntegersBit Twiddling Hacks: Integers
Bit Twiddling Hacks: IntegersDavid Bařina
 
Solution Manual : Chapter - 06 Application of the Definite Integral in Geomet...
Solution Manual : Chapter - 06 Application of the Definite Integral in Geomet...Solution Manual : Chapter - 06 Application of the Definite Integral in Geomet...
Solution Manual : Chapter - 06 Application of the Definite Integral in Geomet...Hareem Aslam
 
Calculo purcell 9 ed solucionario
Calculo  purcell  9 ed   solucionarioCalculo  purcell  9 ed   solucionario
Calculo purcell 9 ed solucionarioLuis Manuel Leon
 
51541 0131469657 ism-0
51541 0131469657 ism-051541 0131469657 ism-0
51541 0131469657 ism-0Ani_Agustina
 
Gaussian quadratures
Gaussian quadraturesGaussian quadratures
Gaussian quadraturesTarun Gehlot
 
Formulario Geometria Analitica
Formulario Geometria AnaliticaFormulario Geometria Analitica
Formulario Geometria AnaliticaAntonio Guasco
 
College algebra real mathematics real people 7th edition larson solutions manual
College algebra real mathematics real people 7th edition larson solutions manualCollege algebra real mathematics real people 7th edition larson solutions manual
College algebra real mathematics real people 7th edition larson solutions manualJohnstonTBL
 
Application of derivatives 2 maxima and minima
Application of derivatives 2  maxima and minimaApplication of derivatives 2  maxima and minima
Application of derivatives 2 maxima and minimasudersana viswanathan
 
1st period exam review(w)
1st period exam review(w)1st period exam review(w)
1st period exam review(w)Joshua Gerrard
 
Strategic Intervention Materials
Strategic Intervention MaterialsStrategic Intervention Materials
Strategic Intervention MaterialsBrian Mary
 
Solution Manual Engineering Signals and Systems by Ulaby & Yagle
Solution Manual Engineering Signals and Systems by Ulaby & YagleSolution Manual Engineering Signals and Systems by Ulaby & Yagle
Solution Manual Engineering Signals and Systems by Ulaby & Yaglespaceradar35
 
Mathmatics (Algebra,inequalities, Sequences, variation and indices
Mathmatics (Algebra,inequalities, Sequences, variation and indicesMathmatics (Algebra,inequalities, Sequences, variation and indices
Mathmatics (Algebra,inequalities, Sequences, variation and indicesSneha Gori
 
51542 0131469657 ism-1
51542 0131469657 ism-151542 0131469657 ism-1
51542 0131469657 ism-1Ani_Agustina
 
College algebra in context 5th edition harshbarger solutions manual
College algebra in context 5th edition harshbarger solutions manualCollege algebra in context 5th edition harshbarger solutions manual
College algebra in context 5th edition harshbarger solutions manualAnnuzzi19
 
sim-140907230908-phpapp01.pptx
sim-140907230908-phpapp01.pptxsim-140907230908-phpapp01.pptx
sim-140907230908-phpapp01.pptxJeffreyEnriquez10
 

Similar a Fixed-point arithmetic (20)

Bit Twiddling Hacks: Integers
Bit Twiddling Hacks: IntegersBit Twiddling Hacks: Integers
Bit Twiddling Hacks: Integers
 
Solution Manual : Chapter - 06 Application of the Definite Integral in Geomet...
Solution Manual : Chapter - 06 Application of the Definite Integral in Geomet...Solution Manual : Chapter - 06 Application of the Definite Integral in Geomet...
Solution Manual : Chapter - 06 Application of the Definite Integral in Geomet...
 
02 basics i-handout
02 basics i-handout02 basics i-handout
02 basics i-handout
 
Calculo purcell 9 ed solucionario
Calculo  purcell  9 ed   solucionarioCalculo  purcell  9 ed   solucionario
Calculo purcell 9 ed solucionario
 
51541 0131469657 ism-0
51541 0131469657 ism-051541 0131469657 ism-0
51541 0131469657 ism-0
 
Gaussian quadratures
Gaussian quadraturesGaussian quadratures
Gaussian quadratures
 
Formulario Geometria Analitica
Formulario Geometria AnaliticaFormulario Geometria Analitica
Formulario Geometria Analitica
 
College algebra real mathematics real people 7th edition larson solutions manual
College algebra real mathematics real people 7th edition larson solutions manualCollege algebra real mathematics real people 7th edition larson solutions manual
College algebra real mathematics real people 7th edition larson solutions manual
 
Application of derivatives 2 maxima and minima
Application of derivatives 2  maxima and minimaApplication of derivatives 2  maxima and minima
Application of derivatives 2 maxima and minima
 
Numerical Methods and Analysis
Numerical Methods and AnalysisNumerical Methods and Analysis
Numerical Methods and Analysis
 
1st period exam review(w)
1st period exam review(w)1st period exam review(w)
1st period exam review(w)
 
Leidy rivadeneira deber_1
Leidy rivadeneira deber_1Leidy rivadeneira deber_1
Leidy rivadeneira deber_1
 
Strategic Intervention Materials
Strategic Intervention MaterialsStrategic Intervention Materials
Strategic Intervention Materials
 
Solution Manual Engineering Signals and Systems by Ulaby & Yagle
Solution Manual Engineering Signals and Systems by Ulaby & YagleSolution Manual Engineering Signals and Systems by Ulaby & Yagle
Solution Manual Engineering Signals and Systems by Ulaby & Yagle
 
Mathmatics (Algebra,inequalities, Sequences, variation and indices
Mathmatics (Algebra,inequalities, Sequences, variation and indicesMathmatics (Algebra,inequalities, Sequences, variation and indices
Mathmatics (Algebra,inequalities, Sequences, variation and indices
 
51542 0131469657 ism-1
51542 0131469657 ism-151542 0131469657 ism-1
51542 0131469657 ism-1
 
College algebra in context 5th edition harshbarger solutions manual
College algebra in context 5th edition harshbarger solutions manualCollege algebra in context 5th edition harshbarger solutions manual
College algebra in context 5th edition harshbarger solutions manual
 
Sample question paper 2 with solution
Sample question paper 2 with solutionSample question paper 2 with solution
Sample question paper 2 with solution
 
sim-140907230908-phpapp01.pptx
sim-140907230908-phpapp01.pptxsim-140907230908-phpapp01.pptx
sim-140907230908-phpapp01.pptx
 
Gr 11 equations
Gr 11   equationsGr 11   equations
Gr 11 equations
 

Más de David Bařina

Lossy Light Field Compression
Lossy Light Field CompressionLossy Light Field Compression
Lossy Light Field CompressionDavid Bařina
 
Mathematical curiosities
Mathematical curiositiesMathematical curiosities
Mathematical curiositiesDavid Bařina
 
New Transforms for JPEG Format
New Transforms for JPEG FormatNew Transforms for JPEG Format
New Transforms for JPEG FormatDavid Bařina
 
Discrete Wavelet Transforms on Parallel Architectures
Discrete Wavelet Transforms on Parallel ArchitecturesDiscrete Wavelet Transforms on Parallel Architectures
Discrete Wavelet Transforms on Parallel ArchitecturesDavid Bařina
 
Parallel Implementation of the 2-D Discrete Wavelet Transform
Parallel Implementation of the 2-D Discrete Wavelet TransformParallel Implementation of the 2-D Discrete Wavelet Transform
Parallel Implementation of the 2-D Discrete Wavelet TransformDavid Bařina
 
Parallel Wavelet Schemes for Images
Parallel Wavelet Schemes for ImagesParallel Wavelet Schemes for Images
Parallel Wavelet Schemes for ImagesDavid Bařina
 
Single-Loop Software Architecture for JPEG 2000
Single-Loop Software Architecture for JPEG 2000Single-Loop Software Architecture for JPEG 2000
Single-Loop Software Architecture for JPEG 2000David Bařina
 
Lifting Scheme Cores for Wavelet Transform
Lifting Scheme Cores for Wavelet TransformLifting Scheme Cores for Wavelet Transform
Lifting Scheme Cores for Wavelet TransformDavid Bařina
 
Real-Time 3-D Wavelet Lifting
Real-Time 3-D Wavelet LiftingReal-Time 3-D Wavelet Lifting
Real-Time 3-D Wavelet LiftingDavid Bařina
 
IIR aproximace Gaussovy funkce
IIR aproximace Gaussovy funkceIIR aproximace Gaussovy funkce
IIR aproximace Gaussovy funkceDavid Bařina
 
Akcelerace DWT pomocí SIMD
Akcelerace DWT pomocí SIMDAkcelerace DWT pomocí SIMD
Akcelerace DWT pomocí SIMDDavid Bařina
 
Wavelet Lifting on Application Specific Vector Processor
Wavelet Lifting on Application Specific Vector ProcessorWavelet Lifting on Application Specific Vector Processor
Wavelet Lifting on Application Specific Vector ProcessorDavid Bařina
 

Más de David Bařina (19)

CCSDS 122.0
CCSDS 122.0CCSDS 122.0
CCSDS 122.0
 
Lossy Light Field Compression
Lossy Light Field CompressionLossy Light Field Compression
Lossy Light Field Compression
 
Mathematical curiosities
Mathematical curiositiesMathematical curiosities
Mathematical curiosities
 
C/C++ tricks
C/C++ tricksC/C++ tricks
C/C++ tricks
 
New Transforms for JPEG Format
New Transforms for JPEG FormatNew Transforms for JPEG Format
New Transforms for JPEG Format
 
JPEG
JPEGJPEG
JPEG
 
Discrete Wavelet Transforms on Parallel Architectures
Discrete Wavelet Transforms on Parallel ArchitecturesDiscrete Wavelet Transforms on Parallel Architectures
Discrete Wavelet Transforms on Parallel Architectures
 
Parallel Implementation of the 2-D Discrete Wavelet Transform
Parallel Implementation of the 2-D Discrete Wavelet TransformParallel Implementation of the 2-D Discrete Wavelet Transform
Parallel Implementation of the 2-D Discrete Wavelet Transform
 
Parallel Wavelet Schemes for Images
Parallel Wavelet Schemes for ImagesParallel Wavelet Schemes for Images
Parallel Wavelet Schemes for Images
 
Single-Loop Software Architecture for JPEG 2000
Single-Loop Software Architecture for JPEG 2000Single-Loop Software Architecture for JPEG 2000
Single-Loop Software Architecture for JPEG 2000
 
Lifting Scheme Cores for Wavelet Transform
Lifting Scheme Cores for Wavelet TransformLifting Scheme Cores for Wavelet Transform
Lifting Scheme Cores for Wavelet Transform
 
Real-Time 3-D Wavelet Lifting
Real-Time 3-D Wavelet LiftingReal-Time 3-D Wavelet Lifting
Real-Time 3-D Wavelet Lifting
 
Wavelet News
Wavelet NewsWavelet News
Wavelet News
 
IIR aproximace Gaussovy funkce
IIR aproximace Gaussovy funkceIIR aproximace Gaussovy funkce
IIR aproximace Gaussovy funkce
 
Akcelerace DWT pomocí SIMD
Akcelerace DWT pomocí SIMDAkcelerace DWT pomocí SIMD
Akcelerace DWT pomocí SIMD
 
Wavelet Lifting on Application Specific Vector Processor
Wavelet Lifting on Application Specific Vector ProcessorWavelet Lifting on Application Specific Vector Processor
Wavelet Lifting on Application Specific Vector Processor
 
GStreamer
GStreamerGStreamer
GStreamer
 
FFmpeg
FFmpegFFmpeg
FFmpeg
 
Wavelets @ CPU
Wavelets @ CPUWavelets @ CPU
Wavelets @ CPU
 

Último

All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...Sérgio Sacani
 
GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)Areesha Ahmad
 
Zoology 4th semester series (krishna).pdf
Zoology 4th semester series (krishna).pdfZoology 4th semester series (krishna).pdf
Zoology 4th semester series (krishna).pdfSumit Kumar yadav
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxgindu3009
 
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSpermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSarthak Sekhar Mondal
 
Chromatin Structure | EUCHROMATIN | HETEROCHROMATIN
Chromatin Structure | EUCHROMATIN | HETEROCHROMATINChromatin Structure | EUCHROMATIN | HETEROCHROMATIN
Chromatin Structure | EUCHROMATIN | HETEROCHROMATINsankalpkumarsahoo174
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Lokesh Kothari
 
Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTSérgio Sacani
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxUmerFayaz5
 
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 60009654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000Sapana Sha
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsSérgio Sacani
 
VIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PVIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PPRINCE C P
 
fundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomologyfundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomologyDrAnita Sharma
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfmuntazimhurra
 
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticsPulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticssakshisoni2385
 
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...ssifa0344
 
DIFFERENCE IN BACK CROSS AND TEST CROSS
DIFFERENCE IN  BACK CROSS AND TEST CROSSDIFFERENCE IN  BACK CROSS AND TEST CROSS
DIFFERENCE IN BACK CROSS AND TEST CROSSLeenakshiTyagi
 
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisRaman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisDiwakar Mishra
 

Último (20)

All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
 
GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)
 
Zoology 4th semester series (krishna).pdf
Zoology 4th semester series (krishna).pdfZoology 4th semester series (krishna).pdf
Zoology 4th semester series (krishna).pdf
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
 
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatidSpermiogenesis or Spermateleosis or metamorphosis of spermatid
Spermiogenesis or Spermateleosis or metamorphosis of spermatid
 
Chromatin Structure | EUCHROMATIN | HETEROCHROMATIN
Chromatin Structure | EUCHROMATIN | HETEROCHROMATINChromatin Structure | EUCHROMATIN | HETEROCHROMATIN
Chromatin Structure | EUCHROMATIN | HETEROCHROMATIN
 
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
Labelling Requirements and Label Claims for Dietary Supplements and Recommend...
 
Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOST
 
Animal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptxAnimal Communication- Auditory and Visual.pptx
Animal Communication- Auditory and Visual.pptx
 
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 60009654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
 
VIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PVIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C P
 
CELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdfCELL -Structural and Functional unit of life.pdf
CELL -Structural and Functional unit of life.pdf
 
fundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomologyfundamental of entomology all in one topics of entomology
fundamental of entomology all in one topics of entomology
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdf
 
The Philosophy of Science
The Philosophy of ScienceThe Philosophy of Science
The Philosophy of Science
 
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticsPulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
 
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
 
DIFFERENCE IN BACK CROSS AND TEST CROSS
DIFFERENCE IN  BACK CROSS AND TEST CROSSDIFFERENCE IN  BACK CROSS AND TEST CROSS
DIFFERENCE IN BACK CROSS AND TEST CROSS
 
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral AnalysisRaman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
Raman spectroscopy.pptx M Pharm, M Sc, Advanced Spectral Analysis
 

Fixed-point arithmetic

  • 1. Fixed-point arithmetic David Barina May 23, 2014 David Barina Fixed-point May 23, 2014 1 / 21
  • 2. Integer 1 1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 15 7 8 0 … … 1 1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 −1 7 −8 0 … … David Barina Fixed-point May 23, 2014 2 / 21
  • 3. Floating point a × 2b sign exponent (8 bits) fraction (23 bits) 02331 0 0 1 1 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = 0.15625 30 22 (bit index) David Barina Fixed-point May 23, 2014 3 / 21
  • 4. Fixed point 1 1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 −0.0625 7.9375 −8.0000 0.0000 … … 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 15.9375 7.9375 8.0000 0.0000 … … 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 David Barina Fixed-point May 23, 2014 4 / 21
  • 5. Benefits Advantages instructions for the integer arithmetic are sufficient no need for FP instructions (FPU, SSE) constant resolution in the whole range higher accuracy (small dynamic ranges) Drawbacks limited range overflow less accuracy (greater dynamic ranges) David Barina Fixed-point May 23, 2014 5 / 21
  • 6. Notation Qm.n Q3.4 1 sign bit, 3 integer, 4 fractional bits Q1.30 32 bits in total Q15.16 32 bits in total David Barina Fixed-point May 23, 2014 6 / 21
  • 7. Examples type name bits resolution range INT integer 32 1 ±231 ≈ ±2.1 × 109 FP single 32 2−23 ≈ 1.2 × 10−7 ±2128 ≈ ±3.4 × 1038 FX Q15.16 32 2−16 ≈ 1.5 × 10−5 ±215 ≈ ±3.2 × 104 FX Q1.30 32 2−30 ≈ 9.3 × 10−10 ±2 David Barina Fixed-point May 23, 2014 7 / 21
  • 8. Conversion (Qm.n) INT → FX y = x << n; FX → INT k = 1 << (n-1); y = (x + k) >> n; FP → FX #include <math.h> y = round( x * (1 << n) ); FX → FP y = (double)x / (1 << n); David Barina Fixed-point May 23, 2014 8 / 21
  • 9. Rounding (Qm.n) Truncation int floor(int x) { return x & ˜((1<<n)-1); } Ceiling int ceil(int x) { return floor(x + ((1<<n)-1)); } Rounding int round(int x) { return floor(x + (1<<(n-1))); } David Barina Fixed-point May 23, 2014 9 / 21
  • 10. Operations (Qm.n) Zero z = 0; Unit z = 1 << n; One half z = 1 << (n-1); Negation z = -x; Absolute value z = abs(x); David Barina Fixed-point May 23, 2014 10 / 21
  • 11. Operations (Qm.n) Addition z = x + y; Subtraction z = x - y; Multiplication by an integer z = x * i; Multiplication k = 1 << (n-1); z = ( x * y + k ) >> n; Division z = (x << n) / y; David Barina Fixed-point May 23, 2014 11 / 21
  • 12. Multiplication (Q15.16) Multiply a.b × c.d uint32_t result_low = (b * d); uint32_t result_mid = (a * d) + (b * c); uint32_t result_high = (a * c); uint32_t result = (result_high << 16) + result_mid + (result_low >> 16); David Barina Fixed-point May 23, 2014 12 / 21
  • 13. Trick Division by a constant a/b → a × c c = 1/b z = a / 5; // 1/5 = 0.2 = 858993459 in Q31.32 z = (a * 858993459) >> 32; David Barina Fixed-point May 23, 2014 13 / 21
  • 14. Functions Sine by Taylor series [libfixmath] sin(x) = x − x3 3! + x5 5! − x7 !7 + x9 !9 − x11 11! Sine by polynomial [Fixmath] 16 segments, polynomial of degree 4, Remez alg. sin(x) = c0 + c1x1 + c2x2 + c3x3 + c4x4 David Barina Fixed-point May 23, 2014 14 / 21
  • 15. Functions Inverse square root [Fixmath] y = 1/ √ x Newton’s method x → a × 2b y = y (3 − a y2 )/2 Square root [Fixmath] x → a × 2b c = 1/ √ a × a = √ a y ← c × 2b/2 David Barina Fixed-point May 23, 2014 15 / 21
  • 16. Functions Square root [libfixmath] abacus algorithm while (one != 0) { if (x >= y + one) { x = x - (y + one); y = y + 2 * one; } y /= 2; one /= 4; } David Barina Fixed-point May 23, 2014 16 / 21
  • 17. Functions Reciprocal value [Fixmath] y = 1/x Newton’s method x → a × 2b y = y (2 − ay) Division z = x/y =⇒ z = x × (1/y) David Barina Fixed-point May 23, 2014 17 / 21
  • 18. Functions Exponential function [libfixmath] x > 0 =⇒ e−x = 1/ex ex = ∞ n=0 xn n! Natural logarithm [libfixmath] Newton’s method y = y + x − ey ey David Barina Fixed-point May 23, 2014 18 / 21
  • 19. Functions Base-2 logarithm [libfixmath] y = log2(x) |Qm.n y = 0; while( x >= 2 ) { x /= 2; y++; } for_each(n) { x *= x; y *= 2; if( x >= 2 ) { x /= 2; y++; } } David Barina Fixed-point May 23, 2014 19 / 21
  • 20. Functions Base-2 logarithm [Fixmath] y = log2(1 + x) 16 segments, polynomial of degree 4/11, Remez alg. Base-2 exponential [Fixmath] y = 2x 1/32 segments, polynomial of degree 7/3, Remez alg. David Barina Fixed-point May 23, 2014 20 / 21