Memory Estimation
As part of the code generation process the toolbox will also estimate the data memory usage of constants (Flash) and variables (RAM) of the generated solvers. Following the first example in Examples/Embedded_Examples.m in double precision:
------------------------------------------------
Data Memory Summary:
TOTAL: 3.932 KB
FLASH: 2.038 KB QP: 1.856 KB
RAM: 1.894 KB MPC: 2.076 KB
------------------------------------------------
As each constant/variable is generated by the autocoder, its size in bytes is recorded based on the requested architecture and precision, and summed to provide the estimates above. For example, inspecting the autogenerated jMPC_constants.c file:
// QP CONSTANTS
const realT H[9] = {
1,0.115770170132782652,0.0219960351628464348,
0.115770170132782652,0.445077608901849775,0.00576592055238192569,
0.0219960351628464348,0.00576592055238192569,0.419199848328891622};
The autocoder knows that a realT for the output architecture and precision is a 64 bit double precision number (for the example above), and thus constant H contributes 9 constants x 8 bytes = 72 bytes to the total Flash memory usage. Conversely global variables defined in e.g. jMPC_engine.c are added to the RAM total with the same formula.
A note on Flash vs RAM
It generally requires a bit of digging through the compiler output for an embedded system to determine where constants are stored. Sometimes, unless specific #pragma or compiler directives are used, constants will still end up in RAM. In fact, for the highest performance, this is what you want (Flash access times are generally much slower than RAM). For the TI C2000 platform used in the implementation example, there is no on-chip Flash memory and all constants are defined in RAM, and the initialized values loaded as part of the boot process of the processor from program memory. Therefore on this platform, the names "Flash" and "RAM" should really be interpreted as "Constants" and "Variables", or simply the total data memory estimated used to proxy the implementation size. It is up to the user to determine how constants and variables are stored on their system.
Additionally, remember the memory estimation above is only the data memory, and does not include the program (code/logic) memory size. This is highly compiler and optimization level dependent, and cannot be estimated by the toolbox.