Digital Signal Processing Reference
In-Depth Information
muli
fx
Multiply 2 fixed point types resulting in an integral type.
Example:
int mulik( Accum, Accum)
divi
fx
Divide an integral by a fixed point type resulting in an integral type.
Example:
int divir(int, Fract)
fx
divi
Divide 2 integral types resulting in a fixed point type.
Example:
long Accum lkdivi(long int, long int)
idiv
fx
Divide 2 fixed point types resulting in an integral type.
Example:
int idivr( Fract, Fract)
for
fx
in
r
,
lr
,
k
,
lk
,
ur
,
ulr
,
uk
,
ulk
abs
fx
Compute the absolute value of a fixed point type.
Example:
long Fract abslr(long Fract)
for
fx
in
hr
,
r
,
lr
,
hk
,
k
,
lk
round
fx
Round a fixed point value to a number of fractional bits given by an
int
parameter.
Example:
long Fract roundlr(long Fract, int)
countls
fx
Count the number of bits a fixed point value can be shifted without overflow.
Always returns an
int
.
Example:
int countlsr( Fract)
bits
fx
Compute an integral value with the same bit representation as a fixed point value.
Example:
int bitsr( Fract)
, where
int
is big enough
fx
bits
Compute a fixed point value with the same bit representation as an integral value.
Example:
Fract rbits(int)
, the inverse of
bitsr
strtofx
fx
Convert a string to a fixed point value.
Example:
short Fract strtofxhr(const char
*
restrict nptr, char
**
restrict endptr)
for
fx
in
hr
,
r
,
lr
,
hk
,
k
,
lk
,
uhr
,
ur
,
ulr
,
uhk
,
uk
,
ulk
Fig. 10
Various support functions as defined by Embedded C
Fig. 11
Additional
formatting letters for fixed
point types
Conversion specifiers Length modifiers
%r
(
signed
)
Fract h short
%R unsigned Fract llong
%k
(
signed
)
Accum
%K unsigned Accum
4
Memory Spaces
The C language only knows two memory spaces, one for data and one for code.
Embedded-C facilitates multiple memory spaces for data. As mentioned in Sect.
2
most DSPs can access two memories simultaneously. Embedded C supports such
architectures by allowing the programmer to locate objects in special memory
spaces, called
named memory spaces
. Although Embedded C has provisions to
declare new named memory spaces in the program code, few compilers will actually
support that and therefore a detailed description is omitted here.
Memory spaces must comply with one important rule: for any two memory
spaces, either both memory spaces are disjoint or one is a subset of the other. The
unqualified (generic) memory space should also always be supported. If this were
not the case regular portable C-code suddenly would be illegal C in the context of