What do you need to consider for code Generation, speaking of platforms.
code generation support of each block to be used should be checked
Execution Environment Components: You need to understand the execution environment components of the platform, such as the operating system, hardware architecture, and memory model. This information is essential to ensure that the generated code can run on the platform correctly.
Calculation cycle: The calculation cycle of the platform refers to the time required to execute a specific set of calculations. You need to understand the calculation cycle of the platform to optimize the generated code for speed and efficiency. If the step size is not correctly set to the clock cycle of the plattform it can lead to “overrun” certain calculations. (especially when step size is too small)
Sample time propagation: Sample time propagation refers to the process of propagating (übertragung) the sample time of one block to the rest of the blocks in a model. You need to ensure that the sample time propagation is correctly implemented in the generated code to avoid synchronization errors.
Data propagation: You also need to consider the data propagation (übertragung) within the model, especially when generating code for distributed systems. The generated code should ensure that data is propagated correctly between different components of the system.
Data types: The data types used in the model need to be compatible with the data types supported by the platform. You need to ensure that the generated code uses the appropriate data types to avoid compatibility issues.
Algebraic loops: Algebraic loops occur when a block's output depends on its input and its own output. The code generator does not produce code that solves algebraic loops
Draw a statemachine for a Fulesystem.
What types of statemachines do you know, describe them.
Mealy State Machine: In a Mealy state machine, the output of the state machine depends on both the current state and the input. The output is generated when a transition occurs from one state to another.
Example: Crosswalk
The stop output is always the inverse of the walk output, so if the walk output is 0, the stop output is 1, and if the walk output is 1, the stop output is 0.
stop
walk
0
1
Moore State Machine: In a Moore state machine, the output of the state machine depends only on the current state. The output is generated when the state machine enters a new state.
Example: Elevator
So in summary, the idle state outputs the default value of floor 1, while the moving state outputs the floor that the elevator is currently on. This is a characteristic of a Moore state machine, where the output is solely determined by the current state and not the inputs.
idle
floor 1
moving
What files are produced during the build process?
What has to be considered for the code generation of a Multiple/Single Top Level Model?
Single Top Level:
Generated code is highly coordinated and optimized
Dependencies of blocks/functions are clearly defined
Multiple Top Level:
Simulink is not aware of dependencies
Generated code is minimally coordinated and optimized
Reuse Code
Reentrant code is a type of code that can be executed by multiple programs or threads simultaneously, without interfering with each other's execution. This type of code is designed to be reusable and can be called by different programs or threads at the same time, without causing any conflicts or race conditions.
In other words, reentrant code is thread-safe and can be interrupted at any point in time to execute another instance of the same code. This is achieved by ensuring that each instance of the code uses its own local data and does not rely on any shared data or resources that may be modified by other instances of the same code.
Reentrant code is useful in situations where multiple programs or threads need to execute the same code simultaneously, such as in real-time systems, embedded systems, or multi-tasking environments. It allows for efficient use of system resources and can improve system performance by minimizing the time spent waiting for code execution to complete.
How does the build process for Codegeneration looks like from the model to the finished Code!
Define Storage classes for the inputs and outputs of the model
Auto
ExportedGlobal
ImportedExtern
ImportedExternPointer
Chosing the Target
target is an environment, hardware, or operating system on which your generated code will run
process of generating target‐specific code is controlled by a system target file, a template makefile, and a make command
Model compilation
Evaluation of Parameters, signal widths,
sample time, execution order => Model description
Code generation
Model Description transformed into target
specific code
Executable generation
Make file => instructs the make
system utility to compile and link
source code and required harness
programs, libaries. It can further
download the resulting executable image
What is the difference between ERT and GRT?
GRT (generic-real-time) and ERT (embedeed-real-tme) are two different code generation options in Simulink for implementing real-time systems.
GRT generates code suitable for non-real-time applications and is optimized for accuracy(floating-point), but does not provide real-time support (used for simulation where time is not critical).
ERT generates code specifically for real-time embedded systems (including task scheduling, interrupt handling, and synchronization), providing real-time support and being optimized for speed and fixed-point data types.
Last changed2 years ago