Top Banner
DSP—Why So Hard? November 2010
53

DSP—Why So Hard?

Jan 05, 2016

Download

Documents

temima

DSP—Why So Hard?. November 2010. Who ?. [email protected] Design and sell processor cores and matching programming environments. Program strange algorithms onto stranger processors with the strangest tools. Customers NDAs Client lists. You. Why ?. - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: DSP—Why So Hard?

DSP—Why So Hard?

November 2010

Page 2: DSP—Why So Hard?

Who ? [email protected] Design and sell processor cores and matching

programming environments. Program strange algorithms onto stranger

processors with the strangest tools.

Customers NDAs Client lists.

You

Page 3: DSP—Why So Hard?

Why ?

People expensive, Silicon cheap. People slow, Silicon fast. People slow, Computers fast.

Programmer efficiency is everything, it gets you time to market which gets you the market.

Page 4: DSP—Why So Hard?

Why ?

Targets move, right up to the last minute. Never, ever build a fixed function device. Three stories.

Third party algorithms will have to be adopted whether public domain or highly secret.

Page 5: DSP—Why So Hard?

What is an audio signal?

Known bandwidth Known resolution Known number of channels

So why don’t I enumerate them

Page 6: DSP—Why So Hard?

Where ?

Large mixing consoles Cell Phones Hi Fi TVs iPod docs PCs etc.

Page 7: DSP—Why So Hard?

What processing do we want to do to the audio? Continuously varying value against time

Filtering Polynomial Non-linear Decisions DSP = Low Delay Not block structured

Page 8: DSP—Why So Hard?

What hardware resources are available?

Memory

Multipliers

Connections

Adders etc.

Page 9: DSP—Why So Hard?

Data types for DSP

See RBJ on headroom and floating point

Want a fixed point data type.

Word length, 16 – 32 etc. have nothing to do with audio, setup the word-length to suit the audio not a computer.

Page 10: DSP—Why So Hard?

Languages for DSP

C is not a DSP language, the data types are all wrong and it has no concept of time.

C++ could be a DSP language but it doesn’t want to be one, it too has no concept of time.

Page 11: DSP—Why So Hard?

Languages for DSP

With modern hardware design and compiler technology there is never a need for assembler. NEVER EVER.

Of course if you’re tied to old hardware for legacy code reasons you still might have to hack in assembler.

Page 12: DSP—Why So Hard?

Languages for DSP

main (…)

{ ASM(…);

ASM(…);

ASM(…);

}

/* This is not C. */

Page 13: DSP—Why So Hard?

Languages for DSP

main (…)

{ Clear_Acc();

MAC(…);

Store_Acc_to_Register(…);

}

/* This isn’t either. */

Page 14: DSP—Why So Hard?

Languages for DSP

main (…)

{ Multiply_by_Coefficient();

Biquad(…);

Do_FFT(…);

}

/* Neither is this. */

Page 15: DSP—Why So Hard?

Languages for DSP

Beware of ‘optional extensions’. They can become mandatory.

There is still at least one University teaching DSP using FORTRAN and assembler …

...sad to say they apologized about the FORTRAN.

Page 16: DSP—Why So Hard?

Languages for DSP

I don’t know the perfect DSP language.

But any high level language is better than any machine specific language.

Page 17: DSP—Why So Hard?

Multiple Memory Banks

If there are multiple memories then memory allocation is NOT the programmers job, the tool-chain should do this for you.

But it might be nice to be able to do some if you want to.

Page 18: DSP—Why So Hard?

Multiply-Add

Source level individual operations (add, multiply etc.) should be independent, hardware instructions can combine multiple operations (like Multiply-Add).

Make sure the operations in a combined instruction are exactly the same as those in individual instructions.

Page 19: DSP—Why So Hard?

Limiting

Whatever number system you use it will have a range, even floating point.

Limiting will be required after every operation that can exceed the range, multiply, add, subtract and absolute value.

This includes the multiply in a multiply-add.

-1 x -1 = -1 ????????

Page 20: DSP—Why So Hard?

Pipelines User should never have to think about

pipelines. Variable pipelines are wrong. Pipeline is not a panacea for timing

problems, it limits the processing in a loop. Pushing code through a branch. Using the pipe for parameter passing.

Page 21: DSP—Why So Hard?

Pipelines

Definition of pipeline length, count between the instruction that generates an item and an instruction that may use it.

Short circuiting the pipe. Useful, but not very useful.

Can unwind the execution by having pipeline-length prime relative to instruction count, but this adds to delay, which in turn adds to storage requirement.

Page 22: DSP—Why So Hard?

Branching

If you can find another way avoid branches.

If you have to have jumps and a pipeline keep it all away from the programmer.

If you do have jumps they’ll likely break the guaranteed timing.

Page 23: DSP—Why So Hard?

Conditional Execution

Conditional execution doesn’t break pipeline etc.

But you’ll need as many condition code stores as you have pipeline length.

Timing is identical for conditional execution and multiplexer.

Page 24: DSP—Why So Hard?

Multiplexer

y = (a < 0.0) ? b : c; Timing is identical for conditional

execution and multiplexer. With multiplexer you can use any variable

as a control so no condition code store is required.

y = (a <= 0.0) ? b : c;

Page 25: DSP—Why So Hard?

ABS

For simple bends in an input/output relationship, Absolute Value plus some Addition and Subtraction is more economical than most other methods.

Page 26: DSP—Why So Hard?

Truncation, Rounding, Dither and Noise Shaping For every instruction that needs it …

… and just for Output

Assume fixed point Floating point is hard

Page 27: DSP—Why So Hard?

Truncation, Rounding and Truncation Towards Zero!.

Truncation is easy but has DC offset Truncation Towards Zero! ½ LSB offset number systems Rounding wins and is not much more

complex.

Page 28: DSP—Why So Hard?

Dither

How do we make it? Truly random, pseudo random, hash? What colour do we want it to be? What PDF do we want? Make sure it’s un-correlated. Want repeatability for test. Problems with infinite gain components. Rounding wins.

Page 29: DSP—Why So Hard?

Noise shaping

What shape? What order? Want repeatability for test. Problems with infinite gain components. Rounding wins.

Make sure your instruction set can do dither and noise shaping.

Page 30: DSP—Why So Hard?

Coefficient Interpolation

Coefficients as a sampled system SRC called interpolation HW or SW, 2-3 instructions to feed one. Only in exceptional circumstances is it

worth a hardware solution. Linear is possible, first order filter is easy

and works for many applications.

Page 31: DSP—Why So Hard?

Coefficient Synchronization

Coefficient synchronisation. Lots of people ignore it or treat it on a per

use basis. Can be done for linear or first order filters

with ease. This is really a synchronous sampling

problem.

Page 32: DSP—Why So Hard?

CoefficientSynchronization, Synchronization

J i t t e r

Page 33: DSP—Why So Hard?

Scaling, multiprocessors, synchronisation & segmentation

Not all solutions fit in a single processor. Automatic segmentation of programs

across multiple processors is possible. But it is hard. If the processors are not identical, and

identically connected it’s very, very hard.

Page 34: DSP—Why So Hard?

Scaling, multiprocessors, synchronisation & segmentation If you have multiple processors and no

branches then you can run them in lockstep, many examples.

For data transfer between processors simply send from one processor and receive by the other at the same time.

Disastrous for assembler, easy for compiler.

Page 35: DSP—Why So Hard?

Scaling, multiprocessors, synchronisation & segmentation How do you connect multiple processors,

series or parallel? If you chose either then you can’t do some

algorithms. Use mesh or router instead. Small routers are actually cheap and

relatively easy to generate code for. Multiple processors I/O, dedicated

processor connections or is I/O a full member of the clan?

Page 36: DSP—Why So Hard?

Constant folding and common code removal. Easy in a compiler, often missed by an assembly

language programmer. Keep everything as source until the last possible

moment. That way common parts can be taken advantage

of, constants, but more importantly data and instructions.

Leads to documentation of library functions requiring “at most X data memories and Y instructions”.

Page 37: DSP—Why So Hard?

Libraries

Binary libraries don’t work well with pipelined processors, the cost of getting into or out of them is usually to great.

A binary library (like a dll) is NOT a secure method of distributing intellectual property.

Encrypted source going through a trusted tool-chain to generate encrypted binaries is the way to go.

Page 38: DSP—Why So Hard?

Hardware with problems….

Let’s just have one continuous data type (and maybe one integer type).

Different widths for different memories makes horrible problems.

Private instruction sets and ‘Useful’ instructions.

Page 39: DSP—Why So Hard?

Hardware with problems….

Do not chisel a digital analogue of an analogue circuit out of digits.

Sample rate to silicon clock ratio

Page 40: DSP—Why So Hard?

Hardware with problems….

Bi-quad coefficient ranges. Feedback coefficients ranges need to be

big enough. Feed-forward coefficient ranges are not

limited, they can get big. If there’s nowhere in your system to make gain, you’re in trouble.

Page 41: DSP—Why So Hard?

Hardware with problems….

The accumulator is dead. When hardware was expensive and DSP engineers were cheap it made sense to get performance this way, but that is no longer true.

Most of today’s algorithms aren’t sums of products anyway.

And it makes a high level description difficult.

Page 42: DSP—Why So Hard?

Hardware with problems….

Double precision is probably not the right thing for LF filters.

Choosing the right filter structure and adding a few bits is a financially better solution.

Page 43: DSP—Why So Hard?

Hardware with problems….

If you must have an accumulator make sure you can load and store it!

Page 44: DSP—Why So Hard?

Hardware with problems….

Shifting is required to get gain into the system.

There are few reasons for a shift of greater than 2^7 and very few for more than 2^15.

Shift after the multiplier, it’s the only place where there are the bits to shift.

Shift in the wrong place is common.

Page 45: DSP—Why So Hard?

Hardware with problems….

If a standard 5 coefficient bi-quad takes more than 5 instructions there’s something wrong.

A simple Z-1 delay, and cascades thereof should not consume instructions.

Simple rotating memory, and language support.

Page 46: DSP—Why So Hard?

Hardware with problems….

A pipeline needs to be started cleanly. This is not always easy.

Page 47: DSP—Why So Hard?

Debuggnig

Source level debugging is perfectly standard in almost every general purpose processor toolset, why is it missing from DSP toolsets?

Page 48: DSP—Why So Hard?

Debuggnig

If you do add a debugger, remember that the objects you are processing are signals, thus they vary with time.

A numerical display of a signal is generally useless, like using a DVM to analyse audio, necessary but not sufficient.

Provide a scope and signal generator.

Page 49: DSP—Why So Hard?

Debuggnig

Debugging Input or Output is a signal.

Easiest done by the instruction NOT the location.

Page 50: DSP—Why So Hard?

How do we make DSP easier?

Get the algorithm away from the hardware

Use DSP that is compiler compatible

Page 51: DSP—Why So Hard?

DSP – Why So Hard?

ProgramOnlySignals.Easy?Yes!

Page 52: DSP—Why So Hard?

Program Only Signals. Easy? Yes!

Page 53: DSP—Why So Hard?

DSP—Made Easy!

November 2010