From: Robert Bunschoten on
I designed a Simulink model that I now need to prepare for code generation. My problem is this: the target platform does not natively support floating point numbers (i.e. lacks an FPU) and the compiler does not include a floating point library so the only way to handle floats is to define an appropriate data structure along with the necessary operations to manipulate the underlying floating point number, that is, software emulation. A MATAB class encapsulating said structure and operations comes to mind but as far as I can tell from the official documentation and various web sources, Simulink does not support data types other than (a subset of) the built-in MATLAB data types, booleans, fixed point numbers and enums. I first considered using fixed point types and mimic floating point behavior by manipulating binary point scaling dynamically but Simulink complained at every turn and I
suppose this is a good thing because I tried some nasty tricks and it quickly got very messy. What I am looking for specifically is an elegant way to represent an alternative floating point type that I can use naturally like any regular (numeric) data type. Rather than wasting time trying to invent a means to accomplish this, I think it is wise to first ask: is it at all possible? Of course, given the limitations of the target platform, early on I considered choosing basic fixed point in lieu of default double precision but the model parameters and expected data require a type that accommodates floating point ranges. It is not that hard to redesign my model to propagate the mantissa and exponent parts separately and define custom blocks that emulate floating point operations. However, that is hardly a clean solution and I would need to invest a lot of time, by my estimate about the same
time it would take me to code the full algorithm in C directly so that kind of defeats the purpose of using Simulink to design a model that is target compatible and ready for code.
 | 
Pages: 1
Prev: Signal Reconstruction
Next: sample of ecg signal