Simulink 中的迭代定点转换
定点工具在 Simulink® 模型中自动执行数据类型转换任务。该工具根据仿真、推导或设计范围收集模型对象的范围数据。在迭代定点转换工作流中,该工具会基于这些范围数据建议能够最大化精度和覆盖范围的定点数据类型。然后,您可以检查数据类型建议,并有选择地将它们应用于模型中的对象。如果不满足设计要求,您可以调整数据类型建议设置,可视化其效果,并进行迭代,直到系统满足您的要求。
要将模型中的数据类型转换为定点,请按照使用定点工具的迭代定点转换中的步骤操作。有关完整转换过程的示例,请参阅将浮点模型转换为定点模型。
DataTypeWorkflow.Converter
对象及其关联的对象函数是定点工具中迭代定点转换的命令行替代项。
工具
定点工具 | Convert a floating-point model to a fixed-point model |
函数
fxptdlg | Open the Fixed-Point Tool |
getUnsupportedFunctionsForSystem | List unsupported functions used by MATLAB Function blocks in the system under design (自 R2025a 起) |
类
DataTypeWorkflow.Converter | Create fixed-point converter object |
DataTypeWorkflow.findDecoupledSubsystems | Get a list of subsystems to replace with an approximation |
DataTypeWorkflow.ProposalSettings | Proposal settings object for data type proposals |
DataTypeWorkflow.FunctionReplacement | Object to store function replacements (自 R2025a 起) |
DataTypeWorkflow.Result | Object containing run result information |
DataTypeWorkflow.VerificationResult | Verification results after converting a system to fixed point |
主题
迭代定点转换工作流概述
- Data Type Conversion Overview
Convert data types in your model to fixed point in one of three ways. - Best Practices for Fixed-Point Conversion Workflow
Use best practices when converting a model to fixed point. - 使用定点工具的迭代定点转换
使用定点工具将系统从浮点转换为定点。
- 步骤 1: Prepare System for Conversion
- 步骤 2: Collect Ranges
- 步骤 3: Convert Data Types
- 步骤 4: Verify New Settings
- 步骤 5: Explore Additional Data Types
- 将浮点模型转换为定点模型
使用定点工具将浮点模型转换为定点。 - The Command-Line Interface for the Fixed-Point Tool
Learn the differences between the command-line interface workflow and the Fixed-Point Tool workflow.
准备转换系统
- Use the Fixed-Point Tool to Prepare a System for Conversion
Use the Fixed-Point Tool to check the system under design for compatibility with the conversion process. - 指定行为约束
使用信号容差和 Model Verification 模块来验证定点实现的行为。
收集范围
- 定点插桩和数据类型覆盖
用于收集模型范围信息的定点插桩和数据类型覆盖设置。 - Choosing a Range Collection Method
Choose from three methods for collecting ranges on which to base data type proposals. - How Range Analysis Works
Learn how the static analysis derives range information.
- Prevent the Fixed-Point Tool from Overriding Integer Data Types
Maintain integer data types in your model when using data type override.
建议数据类型
- How the Fixed-Point Tool Proposes Data Types
Learn how the Fixed-Point Tool proposes data types based on collected ranges and proposal settings. - Propose Data Types for Merged Simulation Ranges
Use the Fixed-Point Tool to merge results from multiple simulations, and propose data types based on the merged results. - How Hardware Implementation Settings Affect Data Type Proposals
Use the Fixed-Point Tool to propose word lengths for a model that implements a simple moving average algorithm.
转换数据类型
- Convert a Referenced Model to Fixed Point
Use the Fixed-Point Tool to log simulation minimum and maximum values for referenced models and propose data types based on a union of the collected ranges. - Bus Objects in the Fixed-Point Workflow
Learn how data type override behaves with bus objects, and how data types are determined for bus objects. - Autoscaling Data Objects Using the Fixed-Point Tool
Use the Fixed-Point Tool to convert a model that uses data objects for data type specification to fixed point. - Convert MATLAB Function Block to Fixed Point
Use the Fixed-Point Tool to convert a MATLAB® Function block to fixed-point.
验证结果
- Control Views in the Fixed-Point Tool
Information filtering, sorting, and analysis in the Fixed-Point Tool. - View Simulation Results
Use the Simulation Data Inspector to view simulation results and compare runs to verify your fixed-point design. - Explore Multiple Floating-Point to Fixed-Point Conversions
Iteratively explore different proposal settings to find the best floating point to fixed-point conversion. - Model Multiple Data Type Behaviors Using a Data Dictionary
Example showing how to use referenced data dictionaries to store multiple sets of data types for a model.
疑难解答
Blocks That Do Not Support Fixed-Point Data Types
Troubleshoot blocks that are not supported for fixed-point conversion.
Follow best practices and avoid unsupported MATLAB Function block features.
Best Practices for Working with Stateflow Charts in Automated Fixed-Point Conversion Workflows
Follow best practices for Stateflow® charts to avoid unexpected results.
Models That Might Cause Data Type Propagation Errors
Know which modeling practices could cause data type propagation errors after autoscaling.
Troubleshoot range analysis issues.
Avoid specifying conflicting design minimum and maximum values in your model.
Insufficient Design Range Information
Troubleshoot errors caused by insufficient design range information by providing additional input design minimum and maximum values.
Provide More Design Range Information
Troubleshoot insufficient design range information that prevents successful derived range analysis.
Troubleshoot Range Analysis of System Objects
Reconfigure a System object™, if necessary, so that ranges can be derived for the model.
The Fixed-Point Tool Did Not Propose Data Types
Troubleshoot when the Fixed-Point Tool does not propose data types.
示例说明如何用 Simulink.Parameter
对象替换结构体初始条件。
Data Type Propagation Errors After Applying Proposed Data Types
Troubleshoot when the Fixed-Point Tool proposes data types that are not compatible with the model.