Posts Tagged ‘dsp break’
DSP Value Lives in Coefficient Tables, Not Instructions
A DSP is the hardest common processor to disassemble. Delayed branches mean the instruction after a jump executes before the jump takes effect. Parallel-issue encodings mean one instruction word carries two or three operations. Circular buffers are addressed by modulo hardware that is invisible in the code. Pipelining means a load may take effect several instructions after it appears.
All of that is true, and all of it is largely irrelevant to the commercial question, because the value of a DSP product is almost never in its instruction stream. It is in the tables the instructions read.
Where the value sits
Consider what a DSP product actually sells. An audio processor sells a particular filter response and a particular dynamic behaviour. A modem sells a particular modulation and a particular equaliser. A voice codec sells a particular codebook and a particular excitation model. A motor drive sells a particular current loop and a particular observer.
In every one of those, the algorithm is published and the differentiation is in the numbers. The filter order, the coefficient values, the codebook entries, the window shape: those are the product. The instructions that multiply and accumulate them are the same instructions every competitor uses.
| DSP product | Published | Proprietary |
|---|---|---|
| Audio equaliser | Biquad structure | Coefficient values |
| Echo canceller | NLMS structure | Step size, filter length, double-talk detector |
| Voice codec | CELP family | Codebook contents, LPC quantiser tables |
| Modem | OFDM or QAM | Equaliser taps, carrier recovery loop constants |
| Motor drive | Field-oriented control | Observer gains, current loop tuning |
The right-hand column is data. It lives in memory, it is read by the code rather than computed by it, and it can be extracted without understanding a single instruction.
Why the tables are readable
A coefficient table has properties that no other data in a DSP image has, and those properties make it findable.
Its values are in the numeric range the algorithm requires. A Q15 fixed-point filter has coefficients between −32768 and 32767, with most of them small — a low-pass filter’s taps decay away from the centre. A floating-point filter has coefficients with exponents in a narrow band. Either way, the distribution is distinctive and unlike the surrounding code or the surrounding state variables.
Its structure is regular. A filter with n taps is n consecutive words. A cascade of second-order sections is 5 or 6 words per section, repeated. A codebook is a large block of fixed-length entries. Structure of that kind survives any amount of obfuscation, because the algorithm needs it.
| Table | Structural signature | Typical size |
|---|---|---|
| FIR taps | Symmetric if linear phase, decaying | 16–512 words |
| Biquad cascade | Repeating 5-word groups | 5 × number of sections |
| FFT twiddles | Sinusoidal, quarter-wave symmetry | 2^(n−1) words |
| Window table | Smooth monotonic or bell shape | Equal to FFT size |
| Codebook | Large block, fixed entry length | Kilobytes |
| Quantiser levels | Monotonic, non-uniform spacing | 16–256 entries |
The first row’s symmetry is the strongest single signal in the entire image. A linear-phase FIR has coefficients that satisfy h[k] = h[n−1−k], and that palindrome appears nowhere else in a firmware image. Finding a run of words that reads the same forwards and backwards, of a length that is a power of two or a multiple of eight, identifies a filter with near certainty.
Recovering the function from the data
Once a table is located, the function it implements follows from its shape, and this is where the analysis is genuinely satisfying.
A symmetric run of 64 values with a small DC sum is a low-pass filter with 64 taps. Its cutoff can be estimated from the ratio of the first tap to the sum, and its transition width from the number of taps. A run of 65 values with a large centre and alternating signs is a band-pass or a differentiator. A cascade of 5-word groups with poles close to the unit circle is a resonant filter bank.
| Shape | Function | What it implies |
|---|---|---|
| Symmetric, all positive, sum = 1 | Low-pass FIR | Cutoff from tap count |
| Antisymmetric | Differentiator or Hilbert | Linear phase, odd length |
| Alternating signs, centre peak | Band-pass | Centre frequency from sign changes |
| Small group with denominator terms | IIR section | Pole radius from denominator |
| Monotonic decreasing | Window or taper | Window family from the curve |
The pole radius is the number that matters most in an IIR section, because it sets the stability margin and the resonance. Extracting the denominator coefficients of a second-order section gives the pole locations directly, and the pole locations are the design.
What cannot be recovered
Two things limit the technique, and both are worth stating before a quotation.
The structure is not in the table. Knowing that a filter has 64 symmetric taps and a particular response tells you what it does, not how the code around it handles state, saturation, rounding or denormal. Those details matter for bit-exact reproduction, and they have to be recovered from the code, which is the hard part that this approach was trying to avoid.
The other limit is that not all DSP value is in tables. A control loop whose behaviour comes from its structure rather than its constants — an adaptive filter, a neural accelerator, a model-predictive controller — has little to extract from data and everything to extract from code. Those are the cases where the instruction stream matters, and where the delayed branches and parallel encodings become a real obstacle.
| Asset type | Recoverable from data | Needs code analysis |
|---|---|---|
| Fixed filter | Yes | No |
| Filter bank | Yes | Partly |
| Codec codebook | Yes | Yes, for the excitation model |
| Adaptive filter | Constants only | Yes |
| Control loop | Gains only | Yes |
| Neural accelerator | Weights only | Yes, for the graph |
Where the instruction stream is still required
The table-first approach has a boundary, and it is set by how much of the device’s behaviour is arithmetic and how much is housekeeping.
Bit-exact reproduction needs the arithmetic details: the order of accumulation, the rounding mode at each step, the saturation behaviour when a value exceeds the range, and the treatment of denormals. Those are not in the coefficients, and they are the reason two implementations of the same filter with the same taps can differ in the last bit.
| Detail | Where it lives | Why it matters |
|---|---|---|
| Accumulator width | The instruction and the register | Overflow behaviour |
| Rounding mode | An instruction or a shift sequence | Last-bit errors accumulate |
| Saturation points | Conditional instructions | Clipping behaviour |
| Denormal handling | A library routine or a hardware mode | Tails and silence |
| State initialisation | The startup code | First samples after reset |
For a customer who needs the output to match sample for sample — a codec interoperating with a deployed fleet, an instrument reproducing a certification measurement — those details have to be recovered from the code even when the coefficients came from the data. That is a narrower job than full disassembly: it means reading the inner loop of each filter, not the whole program.
For a customer who needs the function to be close enough — an equaliser whose response is within a decibel, a controller whose loop is retuned — the coefficients alone are sufficient and the code can be left unread.
The verification that makes it a deliverable
A coefficient table is a hypothesis until it is verified. The verification is a numerical simulation: build the structure implied by the table in a modelling tool, apply an impulse, and compare the response against a measurement taken from the real device.
The measurement is straightforward. An audio device can be driven with a swept sine and its output recorded. A motor drive can be stepped and its current response captured. A modem can be fed a known symbol sequence and its decisions logged. In each case the measured response is compared against the simulated one, and agreement to within the device’s own noise floor confirms the extraction.
| Verification | Input | Agreement criterion |
|---|---|---|
| Impulse response | Single-sample impulse | Tap values match |
| Frequency response | Swept sine | Magnitude and phase within 1 dB |
| Step response | Step at the input | Settling within the noise floor |
| Symbol decisions | Known sequence | Bit-exact or within the coding gain |
Where the service fits
The work at this layer is a data extraction and a numerical verification, and it produces a coefficient set, a structure description, and a simulation that the customer can run. It does not produce readable DSP source, and customers who need that are pointed at the code analysis route instead.
The mechanics of getting the image in the first place are the ones in extracting MCU code, and where the device holds its program in an external memory the read is the one in extracting IC flash. Where the DSP is a soft core inside an FPGA, the configuration is a bitstream and the situation is the one described in FPGA cracking.
What we decline is a request to reverse a DSP program into maintainable C. The instruction stream can be disassembled, and the delayed slots and parallel encodings can be resolved, but the result is a listing that reproduces the arithmetic and explains nothing. Where the customer’s actual need is to reproduce a function, the tables are the shorter path and the honest one.