Digital Signal Processing 《ARM System developer’s Guide》Chapter-8

微处理器现在有足够的性能去处理实时的数字信号。你一定对MP3,数码相机和数字电话非常熟悉了。处理数字信号需要很高的memory bandwidths和fast multiply accumulate operations。在本章你将学会如何最大化ARM在DSP应用程序上的性能。

传统的嵌入式设备上,包含了两种处理器。第一种是microcontroller用于处理用户接口,另一种是单独的DSP处理器,would manipulate(操作处理) digitized signals such as audio。而如今,两者合二为一,如此一来能有效减少能源的消耗。

由于其high data bandwidth and performance requirement,我们经常需要手动编写DSP汇编代码。然后我们控制register allocation和instruction scheduling去获得更好的性能。本章不涉及到DPS算法的实现。所以我们着眼于能适用于所有DPS算法的通用例子和规则。

8.1讲述我们如何在ARM上表示信号的基础问题,这样才知道如何处理它。 8.2是编写ARM的DPS算法的通用规则。
Filtering 可能是信号处理最常用的操作。It can be used to remove noise, to analyze signals, or in signal compression. We look at audio filtering in detail in Sections 8.3 and 8.4. Another very common algorithm is the Discrete Fourier Transform(DFT)(离散傅里叶变换), which converts asignal from a time representation to a frequency representation or vice versa. We look at the DFT in Section 8.5.

8.1 Representing a Digital Signal

在处理数字信号之前,我们需要选择一种信号的表现形式。我们如何使用ARM处理器中的integer来描述信号呢?Throughout this chapter we will use the notations(标记) x t and x[t ] to denote(表示) the value of a signal x at time t. The first notatio(标记)n is often clearer in equations(方程式) and formula(公式). The second notation is used in programming examples as it is closer to the C style of array notation.

8.1.1 Choosing a Representaion

In an analogue(模拟) signal x[t ], the index t and the value x are both continuous real variables. To convert(转换) an analogue signal to a digital signal, we must choose a finite number of sampling(取样) points ti and a digital representation for the sample values x[ti].

figure 8.1
Figure 8.1 shows a sine wave signal digitized at the sampling points 0, 1, 2, 3, and so on.Signals like this are typical in audio processing, where x[t ] represents the tth audio sample.
例如CD播放器,采样率是44,100HZ,就是每秒44,100个样本。

选择x[t]表达方式有两个注意点:
1. 信号的动态范围—M = max|x[t ]| over all t = 0, 1, 2, 3 . . .(8.1)定义了信号的最大波动(fluctuation).在这个example里,我们使M=1 volt。
2. 表达方式的精准度(accuracy)—例如:精准度在100 parts per million(白万分之100),那么x[t]的误差要在E = M × 0. 0001 = 0. 0001 volts (8.2)以内。

我们可以采用浮点数形式来表达x[t],这符合我们的要求,而可以使用C类型float。然而ARM在硬件上不支持float,所以浮点数形式会非常的慢。

最好的办法是使用定点表达式(fixed-point representation).使用integer来表达fractional(分数) value by scaling(划分) the fraction(小数部分)
例如:最大误差为0.0001volt,我们仅仅需要每个表达的值间隔0.0002volt。这建议我们使用下列表达式来表示x[t]:
X [t ] = round_to_nearest _integer(5000 × x[t ])
实际上我们更倾向于使用power of 2进行scaling,这样我们可以使用shift(移位)来进行multiplicationdivision。这种情况下比5000更大的power of 2是2^13 = 8192,因此表达式如下:
X [t ] = round_to_nearest _integer(2 k x[t ])

In a fixed-point representation we represent each signal value by an integer and use the same scaling for the whole signal. This differs from a floating-point representation, where each signal value x[t ] has its own scaling called the exponent(幂) dependent upon t.

传统观念浮点数比fixed point更精准,这是错误的!对于相同数目bit,fixed point更精准,而floating-point以更低的精准度为代价拥有更搞得动态范围。For example, if you use a 32-bit integer to hold afixed-point value scaled to full range, then the maximum error in a representation is 2^−32。However, single-precision 32-bit floating-point values give a relative error of 2^−24(比定点形式低) .The single-precision floating-point mantissa(尾数) is 24 bits. The leading 1 of the mantissa is not stored, so 23 bits of storage are actually used。2^(32-24) = 256,因此fixed-point精度是float-point的256倍。The 8-bit floating-point exponent(幂) is of little use when you are interested in maximum error rather than relative accuracy.

summary

When maximum error is important,fixed-pointrepresentation is best。If you require a large dynamic range, then floating point is better.
你也可以使用如下的形式,比fixed point拥有更大的动态范围,同时也比floating point更具效率。

8.1.1.1Saturating Fixed-Point Representation

Suppose the maximum value of the signal is not known, but there is a clear range in which the vast majority of samples lie. In this case you can use a fixed-point representation based on the common range. You then saturate(饱和) or clip(修剪) any out-of-range samples to the closest available sample in the normal range. This approach gives greater accuracy at the expense of some distortion(失真) of very loud signals.
See Section 7.7 for hints(建议) on efficient saturation.

8.1.1.2Block-Floating Representation

When small sample values are close to large sample values, they are usually less important. In this case, you can divide the signal into blocks or frames of samples. You can use a different fixed-point scaling on each block or frame according to the strength of the signal in that block or frame.

This is similar to floating point except that we associate a single exponent(幂) with a whole frame rather than a single sample. You can use efficient fixed-point operations to operate on the samples within the frame, and you only need costly, exponent-related operations when comparing values among frames.

8.1.1.3Logarithmic Representation

Suppose your signal x[t ] has a large dynamic range. Suppose also that multiplication operations are far more frequent than addition. Then you can use a base-two logarithmic representation. For this representation we consider the related signal y[t ]:
y[t ] = log 2 (x[t ])

Represent y[t ] using a fixed-point format. Replace operations of the form
x[a] = x[b] × x[c] by y[a] = y[b] + y[c]

and operations of the form
x[a] = x[b] + x[c] by y[a] = y[b] + log 2 (1 + 2^(y[c]−y[b]))

In the second case we arrange that y[c] ≤ y[b]. Calculate the function f (x) = log 2 (1 + 2^x )by using lookup tables and/or interpolation(插入,篡改).
See Section 7.5 for efficient implementations of log 2 (x) and 2^x .

8.1.2 Operating on values Stored in Fixed-Point Format

Suppose now that we have chosen a Qk fixed-point representation for the signal x[t ].
In other words, we have an array of integers X [t ] such that

X[t]=the closet integer to(2kx[t])

Equivalently(相当地), if we write the integer X [t ] in binary notation, and insert a binary point between bits k and k − 1, then we have the value of x[t ]. For example, in Figure 8.2, the fixed-point value 0x6000 at Q15 represents 0.11 in binary, or 3/4 = 0.75 in decimal.
figure 8.2

The following subsections cover the basic operations of addition, subtraction, multiplication, division, and square root as applied to fixed-point signals. (接下来的章节覆盖了定点数信号的基础操作如:加减乘除和平方根)

There are several concepts that apply to all fixed-point operations(这里是适用于所有定点数操作的概念):

  • Rounding on right shift(循环右移). When you perform a right shift to divide by a power of two, the shift rounds towards −∞ rather than rounding to the nearest integer. For a more accurate answer use the operation y = (x + (1<<(shift − 1))) >> shift instead. This will round to the nearest integer with 0.5 rounded up. (这将要以0.5的数值围拢靠近最近的整数)
    To implement this efficiently, see Section 7.7.3.
  • Rounding on divide. For an unsigned divide, calculate y = (x + (d>>1))/d rather than y = x/d. This gives a rounded(全面的结果) result.
    如:计算11/2用该公式就会四舍五入为6,原来的公式结果为5
  • Headroom. The headroom of a fixed point representation is the ratio(比率) of the maximum magnitude(数量) that can be stored in the integer to the maximum magnitude that will occur(可能出现的最大数量).
    For example, suppose you use a 16-bit integer to store a Q13 representation of an audio signal that can range between −1 and +1. Then there is a headroom of four times or two bits(4倍或者2位的headroom). You can double a sample value twice without risk of overflowing the 16-bit container integer(你可以加倍样本值,而不需要担心溢出16bit整数容器的风险).
  • Conversion(转换) of Q representation. If X [t ] is a Qn representation of x[t ], then
    X [t ] << k is a Q(n + k) representation of x[t ] (8.9)
    X [t ] >> k is a Q(n − k) representation of x[t ] (8.10)
    For the following sections we fix signals x[t ], c[t ], and y[t ]. Let X [t ], C[t ], Y [t ] denote(表示) their Qn, Qm, Qd fixed-point representations, respectively.

8.1.3 Addition and Subtraction of Fixed-Point Signals

The general case is to convert the signal equation

y[t]=x[t]+c[t]   (8.11)

into fixed-point format; that is, approximately(大约):
Y[t]=2dy[t]=2d(x[t]+c[t])=2dnX[t]+2dmC[t]   (8.12)

or in integer C:
Y[t]=(X[t]<<(dn))+(C[t]<<(dm))





暂时省略大部分内容,等下学期学DSP的时候再学习

8.1.7 Summary: How to Represent a Digital Signal

To choose a representation for a signal value, use the following criteria:

  • Use a floating-point representation for prototyping algorithms. Do not use floating point in applications where speed is critical. Most ARM implementations do not include hardware floating-point support.
  • Use a fixed-point representation for DSP applications where speed is critical with moderate(一般的) dynamic range. The ARM cores provide good support for 8-, 16- and 32-bit fixed-point DSP.
  • For applications requiring speed and high dynamic range, use a block-floating or logarithmic representation.

table 8.2
able 8.2 summarizes how you can implement standard operations in fixed-point arithmetic. It assumes there are three signals x[t], c[t], y[t], that have Qn, Qm, Qd representations X[t], C[t], Y[t], respectively. In other words:

X[t]=2nx[t],C[t]=2mc[t],Y[t]=2dy[t]

to the nearest integer.

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
在线阅读本书, , Over the last ten years, the ARM architecture has become one of the most pervasive architectures in the world, with more than 2 billion ARM-based processors embedded in products ranging from cell phones to automotive braking systems. A world-wide community of ARM developers in semiconductor and product design companies includes software developers, system designers and hardware engineers. To date no book has directly addressed their need to develop the system and software for an ARM-based system. This text fills that gap. This book provides a comprehensive description of the operation of the ARM core from a developer's perspective with a clear emphasis on software. It demonstrates not only how to write efficient ARM software in C and assembly but also how to optimize code. Example code throughout the book can be integrated into commercial products or used as templates to enable quick creation of productive software. The book covers both the ARM and Thumb instruction sets, covers Intel's XScale Processors, outlines distinctions among the versions of the ARM architecture, demonstrates how to implement DSP algorithms, explains exception and interrupt handling, describes the cache technologies that surround the ARM cores as well as the most efficient memory management techniques. A final chapter looks forward to the future of the ARM architecture considering ARMv6, the latest change to the instruction set, which has been designed to improve the DSP and media processing capabilities of the architecture., , * No other book describes the ARM core from a system and software perspective. * Author team combines extensive ARM software engineering experience with an in-depth knowledge of ARM developer needs. * Practical, executable code is fully explained in the book and available on the publisher's Website. * Includes a simple embedded operating system.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

猎羽

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值