Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

集成外部代码

使用自定义定点 S-Function 的外部代码集成

使用自定义定点 S-Function 集成外部代码。

函数

全部展开

转换数据类型

ssFxpConvertConvert value from one data type to another
ssFxpConvertFromRealWorldValueConvert value of data type double to another data type
ssFxpConvertToRealWorldValueConvert value of any data type to double

U32 位区域

ssFxpGetU32BitRegionReturn stored integer value for 32-bit region of real, scalar signal element
ssFxpGetU32BitRegionCompliantDetermine whether S-function is compliant with the U32 bit region interface
ssFxpSetU32BitRegionSet stored integer value for 32-bit region of real, scalar signal element
ssFxpSetU32BitRegionCompliantDeclare compliance with the U32 bit region interface for fixed-point data types with 33 or more bits

注册的数据类型信息

ssGetDataTypeBiasReturn bias of registered data type
ssGetDataTypeFixedExponentReturn exponent of slope of registered data type
ssGetDataTypeFracSlopeReturn fractional slope of registered data type
ssGetDataTypeFractionLengthReturn fraction length of registered data type with power-of-two scaling
ssGetDataTypeFxpContainWordLenReturn word length of storage container of registered data type
ssGetDataTypeFxpIsSignedDetermine whether fixed-point registered data type is signed or unsigned
ssGetDataTypeIsDoubleSingleorHalfDetermine whether registered data type is double, single, or half-precision data type (自 R2020b 起)
ssGetDataTypeFxpWordLengthReturn word length of fixed-point registered data type
ssGetDataTypeIsFixedPointDetermine whether registered data type is fixed-point data type
ssGetDataTypeIsFloatingPointDetermine whether registered data type is floating-point data type
ssGetDataTypeIsFxpFltApiCompatDetermine whether registered data type is supported by API for user-written fixed-point S-functions
ssGetDataTypeIsHalfPrecisionDetermine whether registered data type is half-precision data type (自 R2020b 起)
ssGetDataTypeIsScalingPow2Determine whether registered data type has power-of-two scaling
ssGetDataTypeIsScalingTrivialDetermine whether scaling of registered data type is slope = 1, bias = 0
ssGetDataTypeNumberOfChunksReturn number of chunks in multiword storage container of registered data type
ssGetDataTypeStorageContainCatReturn storage container category of registered data type
ssGetDataTypeStorageContainerSizeReturn storage container size of registered data type
ssGetDataTypeTotalSlopeReturn total slope of scaling of registered data type

记录仿真期间收集的信息

ssLogFixptInstrumentationRecord information collected during simulation

注册定点数据类型

ssRegisterDataTypeFxpSlopeBiasRegister data type with [Slope Bias] scaling and return its data type ID
ssRegisterDataTypeHalfPrecisionRegister half-precision data type and return its data type ID (自 R2020b 起)
ssRegisterDataTypeFxpScaledDoubleRegister scaled double data type with [Slope Bias] scaling specified in terms of fractional slope, fixed exponent, and bias, and return its data type ID
ssRegisterDataTypeFxpFSlopeFixExpBiasRegister fixed-point data type with [Slope Bias] scaling specified in terms of fractional slope, fixed exponent, and bias, and return its data type ID
ssRegisterDataTypeFxpBinaryPointRegister fixed-point data type with binary-point-only scaling and return its data type ID

主题

  • Data Type Support

    Lists the data types supported by the API and discusses the treatment of integers and data-type-overridden signals.

  • S-Function 的结构

    显示直接处理定点数据类型的 S-Function 的基本结构。

  • Storage Containers

    Discusses the containers used to hold signals in simulation and code generation.

  • Data Type IDs

    Describes the creation, assignment, and usage of data type IDs, including how to get and set information about data types in an S-function.

  • Overflow Handling and Rounding Methods

    Discusses the tokens you can use to define overflow handling and rounding methods in your fixed-point S-function, and describes the overflow logging structure.

  • 创建 MEX 文件

    描述为定点 S-Function 创建 MEX 文件所需的额外步骤。

  • Get the Input Port Data Type

    Within your S-function, you might need to know the data types of different ports, run-time parameters, and DWorks.

  • Set the Output Port Data Type

    You may want to set the data type of various ports, run-time parameters, or DWorks in your S-function.

  • Interpret an Input Value

    Suppose you need to get the value of the signal on your input port to use in your S-function.

  • Write an Output Value

    Suppose you need to write the value of the output signal to the output port in your S-function.

  • Determine Output Type Using the Input Type

    Using the data type of the input to your S-function to calculate the output data type.