SlideShare une entreprise Scribd logo
1  sur  21
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

BOOLEAN ALGEBRA AND LOGIC GATE
BOOLEAN ALGEBRA AND LOGIC GATE BOOLEAN ALGEBRA AND LOGIC GATE
BOOLEAN ALGEBRA AND LOGIC GATE Tamim Tanvir
 
Booth's Multiplication Algorithm.pptx
Booth's Multiplication Algorithm.pptxBooth's Multiplication Algorithm.pptx
Booth's Multiplication Algorithm.pptxSMohiuddin1
 
Binary division restoration and non restoration algorithm
Binary division restoration and non restoration algorithmBinary division restoration and non restoration algorithm
Binary division restoration and non restoration algorithmPrasenjit Dey
 
Digital Logic & Design (DLD) presentation
Digital Logic & Design (DLD) presentationDigital Logic & Design (DLD) presentation
Digital Logic & Design (DLD) presentationfoyez ahammad
 
10 Instruction Sets Characteristics
10  Instruction  Sets Characteristics10  Instruction  Sets Characteristics
10 Instruction Sets CharacteristicsJeanie Delos Arcos
 
Fixed Point Theorems
Fixed Point TheoremsFixed Point Theorems
Fixed Point TheoremsNikhil Simha
 
Ch4 Boolean Algebra And Logic Simplication1
Ch4 Boolean Algebra And Logic Simplication1Ch4 Boolean Algebra And Logic Simplication1
Ch4 Boolean Algebra And Logic Simplication1Qundeel
 
1.ripple carry adder, full adder implementation using half adder.
1.ripple carry adder, full adder implementation using half adder.1.ripple carry adder, full adder implementation using half adder.
1.ripple carry adder, full adder implementation using half adder.MdFazleRabbi18
 
Carry look ahead adder
Carry look ahead adderCarry look ahead adder
Carry look ahead adderdragonpradeep
 
Digital logic gates and Boolean algebra
Digital logic gates and Boolean algebraDigital logic gates and Boolean algebra
Digital logic gates and Boolean algebraSARITHA REDDY
 
Digital Signal Processing[ECEG-3171]-Ch1_L02
Digital Signal Processing[ECEG-3171]-Ch1_L02Digital Signal Processing[ECEG-3171]-Ch1_L02
Digital Signal Processing[ECEG-3171]-Ch1_L02Rediet Moges
 
Register in Digital Logic
Register in Digital LogicRegister in Digital Logic
Register in Digital LogicISMT College
 
Difference between combinational and
Difference between combinational andDifference between combinational and
Difference between combinational andDamodar Panigrahy
 
Fixed point and floating-point numbers
Fixed point and  floating-point numbersFixed point and  floating-point numbers
Fixed point and floating-point numbersMOHAN MOHAN
 
Sequential circuit design
Sequential circuit designSequential circuit design
Sequential circuit designSatya P. Joshi
 
Programmable peripheral interface 8255
Programmable peripheral interface 8255Programmable peripheral interface 8255
Programmable peripheral interface 8255Marajulislam3
 

Tendances (20)

BOOLEAN ALGEBRA AND LOGIC GATE
BOOLEAN ALGEBRA AND LOGIC GATE BOOLEAN ALGEBRA AND LOGIC GATE
BOOLEAN ALGEBRA AND LOGIC GATE
 
Booth's Multiplication Algorithm.pptx
Booth's Multiplication Algorithm.pptxBooth's Multiplication Algorithm.pptx
Booth's Multiplication Algorithm.pptx
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
Binary division restoration and non restoration algorithm
Binary division restoration and non restoration algorithmBinary division restoration and non restoration algorithm
Binary division restoration and non restoration algorithm
 
Counters
Counters Counters
Counters
 
Digital Logic & Design (DLD) presentation
Digital Logic & Design (DLD) presentationDigital Logic & Design (DLD) presentation
Digital Logic & Design (DLD) presentation
 
Boolean Algebra
Boolean AlgebraBoolean Algebra
Boolean Algebra
 
10 Instruction Sets Characteristics
10  Instruction  Sets Characteristics10  Instruction  Sets Characteristics
10 Instruction Sets Characteristics
 
Fixed Point Theorems
Fixed Point TheoremsFixed Point Theorems
Fixed Point Theorems
 
Ch4 Boolean Algebra And Logic Simplication1
Ch4 Boolean Algebra And Logic Simplication1Ch4 Boolean Algebra And Logic Simplication1
Ch4 Boolean Algebra And Logic Simplication1
 
1.ripple carry adder, full adder implementation using half adder.
1.ripple carry adder, full adder implementation using half adder.1.ripple carry adder, full adder implementation using half adder.
1.ripple carry adder, full adder implementation using half adder.
 
Carry look ahead adder
Carry look ahead adderCarry look ahead adder
Carry look ahead adder
 
Digital logic gates and Boolean algebra
Digital logic gates and Boolean algebraDigital logic gates and Boolean algebra
Digital logic gates and Boolean algebra
 
Digital Signal Processing[ECEG-3171]-Ch1_L02
Digital Signal Processing[ECEG-3171]-Ch1_L02Digital Signal Processing[ECEG-3171]-Ch1_L02
Digital Signal Processing[ECEG-3171]-Ch1_L02
 
Register in Digital Logic
Register in Digital LogicRegister in Digital Logic
Register in Digital Logic
 
Difference between combinational and
Difference between combinational andDifference between combinational and
Difference between combinational and
 
Fixed point and floating-point numbers
Fixed point and  floating-point numbersFixed point and  floating-point numbers
Fixed point and floating-point numbers
 
BOOLEAN ALGEBRA & LOGIC GATE
BOOLEAN ALGEBRA & LOGIC GATEBOOLEAN ALGEBRA & LOGIC GATE
BOOLEAN ALGEBRA & LOGIC GATE
 
Sequential circuit design
Sequential circuit designSequential circuit design
Sequential circuit design
 
Programmable peripheral interface 8255
Programmable peripheral interface 8255Programmable peripheral interface 8255
Programmable peripheral interface 8255
 

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Plus 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
 

Plus 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
 

Dernier

Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )aarthirajkumar25
 
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
 
Forensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdfForensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdfrohankumarsinghrore1
 
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
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPirithiRaju
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksSérgio Sacani
 
SAMASTIPUR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICE
SAMASTIPUR CALL GIRL 7857803690  LOW PRICE  ESCORT SERVICESAMASTIPUR CALL GIRL 7857803690  LOW PRICE  ESCORT SERVICE
SAMASTIPUR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICEayushi9330
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...RohitNehra6
 
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
 
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
 
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...Lokesh Kothari
 
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...Sérgio Sacani
 
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
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bSérgio Sacani
 
Seismic Method Estimate velocity from seismic data.pptx
Seismic Method Estimate velocity from seismic  data.pptxSeismic Method Estimate velocity from seismic  data.pptx
Seismic Method Estimate velocity from seismic data.pptxAlMamun560346
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Sérgio Sacani
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPirithiRaju
 
Creating and Analyzing Definitive Screening Designs
Creating and Analyzing Definitive Screening DesignsCreating and Analyzing Definitive Screening Designs
Creating and Analyzing Definitive Screening DesignsNurulAfiqah307317
 
Bacterial Identification and Classifications
Bacterial Identification and ClassificationsBacterial Identification and Classifications
Bacterial Identification and ClassificationsAreesha Ahmad
 
Isotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoIsotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoSérgio Sacani
 

Dernier (20)

Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )Recombination DNA Technology (Nucleic Acid Hybridization )
Recombination DNA Technology (Nucleic Acid Hybridization )
 
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
 
Forensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdfForensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdf
 
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...
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disks
 
SAMASTIPUR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICE
SAMASTIPUR CALL GIRL 7857803690  LOW PRICE  ESCORT SERVICESAMASTIPUR CALL GIRL 7857803690  LOW PRICE  ESCORT SERVICE
SAMASTIPUR CALL GIRL 7857803690 LOW PRICE ESCORT SERVICE
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...
 
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
 
Zoology 4th semester series (krishna).pdf
Zoology 4th semester series (krishna).pdfZoology 4th semester series (krishna).pdf
Zoology 4th semester series (krishna).pdf
 
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
 
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
PossibleEoarcheanRecordsoftheGeomagneticFieldPreservedintheIsuaSupracrustalBe...
 
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...
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
 
Seismic Method Estimate velocity from seismic data.pptx
Seismic Method Estimate velocity from seismic  data.pptxSeismic Method Estimate velocity from seismic  data.pptx
Seismic Method Estimate velocity from seismic data.pptx
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
 
Creating and Analyzing Definitive Screening Designs
Creating and Analyzing Definitive Screening DesignsCreating and Analyzing Definitive Screening Designs
Creating and Analyzing Definitive Screening Designs
 
Bacterial Identification and Classifications
Bacterial Identification and ClassificationsBacterial Identification and Classifications
Bacterial Identification and Classifications
 
Isotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoIsotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on Io
 

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