Automated Code Generation for Control Design Function Separation
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing control design products require labor-intensive rewriting of code to separate output and update functions in legacy blocks of dynamic systems, making static analysis and simulation inefficient.
Innovation Solution
An automated code generation process that converts step functions in graphical models into separate output and update functions, using liveness analysis and algorithmic differentiation to generate optimized code for control analysis and design.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If manual code rewriting is used to separate output and update functions in legacy blocks, then control analysis and design can be performed, but the process becomes labor intensive and time consuming
Solution Approach 1:
The system performs automatic function separation through code generation, allowing the legacy blocks to self-transform into the required format without manual intervention. The code generation tool automatically analyzes legacy block code, identifies output and update functions, and generates separated function code, eliminating the need for manual rewriting while maintaining control analysis capability
Solution Approach 2:
The manual mechanical process of code rewriting is replaced with an automated computational system. The code generation tool uses algorithmic analysis and automatic code transformation to substitute the labor-intensive manual rewriting process, significantly reducing time consumption while achieving the same function separation objective
2Ease of manufacture
If complete separation of output and update functions is required for static analysis, then control design products can be used, but legacy blocks require extensive code modification
Solution Approach 1:
The code generation tool automatically segments legacy block code into distinct output and update functions based on functional analysis. It identifies and separates the output computation logic from the state update logic, generating properly structured code that meets static analysis requirements without requiring manual code restructuring
Solution Approach 2:
The code generation tool acts as an intermediary between legacy blocks and control design products. It transforms legacy code into an intermediate format with separated functions that is compatible with static analysis requirements, serving as a bridge that eliminates the need for direct manual code modification while ensuring compatibility
3Productivity
If automated code generation is used to separate functions, then manual rewriting effort is reduced, but the generation process must accurately identify and separate functions
Solution Approach 1:
The code generation process incorporates feedback mechanisms where the generated code is verified against the original legacy block functionality. The system analyzes the generated separated functions to ensure they maintain the same behavior as the original block, providing automatic validation that ensures both efficiency and accuracy in function separation
Solution Approach 2:
The system performs preliminary analysis of legacy block code structure and logic before generating separated functions. It pre-identifies output and update function boundaries, pre-processes the code to understand data flows and dependencies, and then generates the separated functions based on this preliminary understanding, ensuring both efficiency and functional accuracy
Data Source
AI summary
A method, performed by a computer device, includes obtaining an in-memory representation of computer code from a block step method of an executable model in a modeling application, wherein the computer code in-memory representation includes one or more variables. The method also includes identifying, from the one or more variables, a subset of persistent variables and determining if any of the one or more variables in the subset of persistent variables are state variables. When none of the subset of persistent variables are state variables, a block output method is generated based on the computer code in-memory representation and the one or more variables. When the subset of persistent variables includes a state variable, both the block output method and a block update method are generated based on the computer code in-memory representation and the one or more variables.


