File Exchange

image thumbnail

How to Write Custom Simulink Data Type Rules in MATLAB

version 1.0.0.0 (1.89 MB) by

Write custom data type rules as MATLAB functions, and other automatic data type propagation policies

8 Downloads

Updated

View License

Simulink models often begin life using purely double-precision data. As the fidelity of the model increases to include specifications of the embedded system it will be deployed on, more floating-point and fixed-point data types are often needed. Manually specifying all these data types for optimal numerical performance and system efficiency while continuing to evolve the design is time consuming and error prone.
Data type automation aims to reduce this cost. You can save time, reduce effort, apply policies, and maintain correctness by adding rules to the model to ensure data types match across signals. Construct signals with the right properties so they produce errors when your rules are violated.

This document explains how you can write your own data type rules as MATLAB functions and integrate them into your Simulink model’s data type propagation process.

Writing your own rule is the highest level of customization and requires the most expertise and resources. There are a few simpler alternatives you should consider first. Simpler out-of-the-box methods may be more compatible with the entire MathWorks tool chain (such as verification and validation products), while highly customized methods may not be completely understood by such tools.

This document describes solutions for automating data type rules in order of increasing complexity. The first section contains simple and widely capable methods. The second contains advanced techniques requiring a greater level of investment.

1. Simple techniques
a. Back-propagation
b. The Data Type Duplicate block
c. The Signal Specification block
2. More sophisticated and custom techniques
a. The Data Type Propagation block
b. Mask-controlled data type rules
c. MATLAB-authored custom data type rules

The licenses required for the demonstration models in this document are Simulink and Fixed-Point Designer. The models were tested with R2018a and may work with some earlier releases as well.

Comments and Ratings (0)

MATLAB Release Compatibility
Created with R2018a
Compatible with any release
Platform Compatibility
Windows macOS Linux

MATLAB Online Live Editor Challenge

Win cash prizes and have your live script featured on our website

Learn more

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video