Block Diagram Simulation Data Type Determination
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Current methods for generating source code from block diagrams in technical computing environments, such as MATLAB/Simulink, fail to accurately determine the underlying basic data type of enumeration variables before compilation, leading to inefficiencies in memory allocation and data type determination during simulation.
Innovation Solution
A method and computer system that automatically generates source code from block diagrams by converting enumeration variables, storing their defined types, and using an auxiliary file to determine the byte width of the basic data type, allowing for accurate memory allocation and data type determination, and generating a variable description file for production software.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Measurement precision
If source code is generated from block diagrams with enumeration variables, then the program can be compiled and executed, but the underlying basic data type of enumeration variables cannot be determined before simulation
Solution Approach 1:
The patent performs preliminary determination of the basic data type for enumeration variables during the code generation phase, before simulation execution. The system analyzes the enumeration variable definitions in the generated source code, determines the appropriate basic data type (e.g., int8, int16, int32), and stores this information in advance. This eliminates the need for time-consuming data type determination during simulation setup, directly resolving the contradiction between measurement precision and time loss.
2Adaptability or versatility
If the C language standard is used for code generation, then compiler flexibility is maintained, but the choice of basic data type for enumeration variables is left to the compiler
Solution Approach 1:
The patent introduces an intermediary analysis step between code generation and simulation that determines the basic data type for enumeration variables. The system acts as a mediator that interprets the C language enumeration definitions and assigns specific basic data types based on the enumeration values' ranges and characteristics. This intermediary process maintains compiler flexibility while providing precise data type determination, resolving the contradiction between adaptability and measurement precision.
3Ease of operation
If enumeration variables are used in block diagrams, then code readability is improved, but memory allocation during simulation becomes inefficient
Solution Approach 1:
The patent performs preliminary determination of the basic data type for enumeration variables during the code generation phase, before simulation execution. The system analyzes the enumeration variable definitions in the generated source code, determines the appropriate basic data type (e.g., int8, int16, int32), and stores this information in advance. This eliminates the need for time-consuming data type determination during simulation setup, directly resolving the contradiction between measurement precision and time loss.
4Device complexity
If data type determination is delayed until simulation time, then code generation remains simple, but simulation accuracy and memory requirements are adversely affected
Solution Approach 1:
The patent performs preliminary determination of the basic data type for enumeration variables during the code generation phase, before simulation execution. The system analyzes the enumeration variable definitions in the generated source code, determines the appropriate basic data type (e.g., int8, int16, int32), and stores this information in advance. This eliminates the need for time-consuming data type determination during simulation setup, directly resolving the contradiction between measurement precision and time loss.
Data Source
AI summary
A method for simulating a program modeled as one or more blocks of a block diagram in a technical computing environment. A block diagram is opened in a model editor. Source code is generated for the one or more blocks of the block diagram using the code generator. The program is configured from the source code using a predefined compiler in order to generate a binary executable file, and the program is simulated, which comprises running at least one function in the auxiliary file in order to determine at least the width of a basic data type corresponding to the enumeration variable in the binary executable file, and allocating one or more variables based on the determined byte width in order to log the simulation results.


