Fixed-Point Blockset    
Gateway In

Convert a Simulink data type to a Fixed-Point Blockset data type

Library

Data Type

Description

The Gateway In block is a masked S-function that converts a built-in Simulink data type to a Fixed-Point Blockset data type.

The Input and Output to have equal parameter list controls how the input is processed. The possible values are Real World Value and Stored Integer. In terms of the general encoding scheme described in Scaling, Real World Value treats the input as V = SQ + B where S is the slope and B is the bias. V is used to produce Q = (V - B)/S, which is stored in the output. Stored Integer treats the input as a stored integer, Q. The value of Q is directly used to produce the output. In this mode, the input and output are identical except that the input is a raw integer lacking proper scaling information. In both modes, the output data type includes the scaling information needed to correctly interpret the signal as a real-world value.

For a detailed description of all other block parameters, refer to Block Parameters.

Parameters and Dialog Box

Input and Output to have equal
Specify the type of value that the input and output are to have equal.
Output data type and scaling
Specify the output data type and scaling via the dialog box, or inherit the data type and scaling by backpropagation.
Output data type
Any data type supported by the Fixed-Point Blockset.
Output scaling
Set the output scaling using radix point-only or [Slope Bias] scaling. These scaling modes are available only for generalized fixed-point data types.
Lock output scaling so autoscaling tool can't change it
If selected, Output scaling is locked. This feature is available only for generalized fixed-point output.
Round toward
Rounding mode for fixed-point output.
Saturate to max or min when overflows occur
If selected, fixed-point overflows saturate.

Examples

This example uses the Gateway In block to help you understand the difference between a real-world value and a stored integer. Consider the two fixed-point models shown below.

In the top model, the Gateway In block treats the input as a real-world value, and maps that value to an 8-bit signed generalized fixed-point data type with a scaling of 2-2. If the value is output from the Gateway Out block as a real-world value, then the scaling and data type information is retained and the output value is 001111.00, or 15. If the value is output from the Gateway Out block as a stored integer, then the scaling and data type information is not retained and the stored integer is interpreted as 00111100, or 60.

In the bottom model, the Gateway In block treats the input as a stored integer, and the data type and scaling information is not applied. If the value is output from the Gateway Out block as a real-world value, then the scaling and data type information is applied to the stored integer, and the output value is 000011.11, or 3.75. If the value is output from the Gateway Out block as a stored integer, then you get back the original input value of 15.

The model shown below illustrates how a summation operation applies to real-world values and stored integers, and how scaling information is dealt with in generated code.

Note that the summation operation produces the correct result when the Gateway Out block outputs a real-world value. This is because the specified scaling information is applied to the stored integer value. However, when the Gateway Out block outputs a stored integer value, then the summation operation produces an unexpected result due to the absence of scaling information.

If you generate code for the above model, then the code captures the appropriate scaling information. The code for the Sum block is shown below. The inputs to this block are tagged with the specified scaling information so that the necessary shifts are performed for the summation operation.

Characteristics

Input Port
Any built-in Simulink data type
Output Port
Any data type supported by the blockset
Direct Feedthrough
Yes
Scalar Expansion
No

See Also

Gateway In Inherited


  Gain Gateway In Inherited