Main Content

Data Type Conversion Inherited

Convert from one data type to another using inherited data type and scaling

  • Data Type Conversion Inherited block

Libraries:
Simulink / Signal Attributes

Description

The Data Type Conversion Inherited block converts one input to the data type and scaling of the other input. The first input is used as the reference signal. The second input, u, is converted to the reference type by inheriting the data type and scaling information. (For a description of the port order for various block orientations, see Identify Port Location on Rotated or Flipped Block.)

Inheriting the data type and scaling provides these advantages:

  • It makes reusing existing models easier.

  • It allows you to create new fixed-point models with less effort since you can avoid the detail of specifying the associated parameters.

Examples

expand all

This example shows three different methods of converting data types in your model using the Data Type Conversion and Data Type Conversion Inherited blocks. In this model, a Sine Wave block generates the input signal. The Sine Wave block only outputs double-precision data types, so to generate a sine wave with a data type of single, you must perform a data type conversion.

In the first row, the Data Type Conversion Inherited block uses the data type coming from the Constant block (single) as the reference data type, and converts the sine wave to single.

In the second row, the Data Type Conversion block has the Output data type set to single, and the sine wave is converted accordingly.

In the third row, the Data Type Conversion1 block has the Output data type set to Inherit: Inherit via back propagation. Because the downstream Gain2 block has a data type of single, the Data Type Conversion1 block converts the sine wave to a data type of single.

Ports

Input

expand all

Reference signal, defining the data type used to convert input signal u.

Data Types: single | double | half | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | enumerated

Input signal to convert to the reference data type, specified as a scalar, vector, matrix, or N-D array.

Data Types: single | double | half | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | enumerated

Output

expand all

Output is the input signal u, converted to the reference data type.

Data Types: single | double | half | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | Boolean | fixed point | enumerated

Parameters

expand all

Specify which type of input and output must be equal, in the context of fixed-point data representation.

  • Real World Value — Specifies the goal of making the Real World Value of the input equal to the Real World Value of the output.

  • Stored Integer — Specifies the goal of making the Stored Integer value of the input equal to the Stored Integer value of the output.

Programmatic Use

Block Parameter: ConvertRealWorld
Type: character vector
Values: 'Real World Value' | 'Stored Integer'
Default: 'Real World Value'

Specify the rounding mode for fixed-point operations. For more information, see Rounding Modes (Fixed-Point Designer).

Programmatic Use

Block Parameter: RndMeth
Type: character vector
Values: 'Ceiling' | 'Convergent' | 'Floor' | 'Nearest' | 'Round' | 'Simplest' | 'Zero'
Default: 'Floor'

When you select this check box, overflows saturate to the maximum or minimum value that the data type can represent. Otherwise, overflows wrap.

When you select this check box, saturation applies to every internal operation on the block, not just the output or result. In general, the code generation process can detect when overflow is not possible. In this case, the code generator does not produce saturation code.

Programmatic Use

Block Parameter: DoSatur
Type: character vector
Values: 'off' | 'on'
Default: 'off'

Block Characteristics

Data Types

Boolean | double | enumerated | fixed point | half | integer | single

Direct Feedthrough

yes

Multidimensional Signals

yes

Variable-Size Signals

yes

Zero-Crossing Detection

no

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.

Version History

Introduced before R2006a