3 ms·
DSPs already do something like this, offering the option of saturating arithmetic operations, in addition to the normal modulo arithmetic. It's the operation t
by femto 3y ago
DSPs already do something like this, offering the option of saturating arithmetic operations, in addition to the normal modulo arithmetic. It's the operation that's special, not the representation in memory.
The normal way to do it is to use the "ETSI Basic Operator" library, which provides saturating arithmetic operations, among other things [1]. If the hardware supports saturated arithmetic the compiler maps the operations to the relevant instructions, otherwise it provides a software implementation.
Example:
Modulo arithmetic: int16_t a,b,c; a = b + c;
Saturating 16-bit arithmetic using ETSI: int16_t a,b,c; a = add(b, c);
[1] https://www.itu.int/rec/T-REC-G.191/en https://www.itu.int/rec/T-REC-G.191/en
- Stenzel 3y agoProcessors with saturating capabilities usually clip at 0x7FFFFFF and 0x80000000, so the clipping thing has no relation to the original topic. But in fixpoint DSP, 0x8000 (add trailing zeros if you like) is often the only possibility to achieve a multiplicative identity by using a = - b * 0x8000, with the negation part of the assembly instruction.