2025-01-09 03:11 AM - last edited on 2025-01-09 05:26 AM by SofLit
Hi,
2025-01-09 04:51 AM
we are working on real time data, so scaling is not working for us
2025-01-09 07:17 AM
> 1 - I can do 2 16-bit signed fraction number multiply or divide and result should also be in 16-bit signed fraction.
In the same instruction? There isn't an instruction for that. You could make your own macro but it wouldn't be particularly fast, which seems like the goal here.
2025-01-09 08:11 PM
Please suggest alternative for it, as in other mcu we get this type of functionality
2025-01-09 10:08 PM
> define to convert any integer number (value less will be less than "1"
The only non-negative integer number less than 1 I know of, is 0.
Arm CMSIS-DSP is a library which supports a q15_t type calculations and conversions for 16-bit fraction numbers.
hth
KnarfB
2025-01-09 10:42 PM
> Arm CMSIS-DSP is a library which supports a q15_t type calculations and conversions for 16-bit fraction numbers.
Would have been my suggestion, too.
As a side note, this q<nn> datatypes are natively supported by almost all DSPs, usually in the single-instruction fashion the OP asks for.
Cortex M is not a platform otimized for realtime, high-throughput applications.
2025-01-09 11:58 PM
For multiplication, (a * b) >> 16 should do. For division - go figure your school task by yourself. ;)
2025-01-10 04:10 AM - edited 2025-01-10 04:11 AM
If the number you are dividing by (the divisor) is a constant, or one that changes less frequently than the numerator, then normal practice is to calculate k=1/d (where d = your divisor), save that value, then use: y = x*k (= x/d) as your real-time single cycle divide operation. You can of course wrap other scaling operations into this by using k = s / d, then y = k*x = s*x/d as a single cycle multiply and divide operation.