主要内容

Extract Bits

Output selection of contiguous bits from input signal

  • Library:
  • Simulink / Logic and Bit Operations

    HDL编码器/逻辑和位操作

  • 提取位块

描述

TheExtract Bits块允许您从输入信号的存储整数值输出连续选择比特。使用提取物的比特parameter to define the method for selecting the output bits.

  • SelectUpper halfto output the half of the input bits that contain the most significant bit. If there is an odd number of bits in the input signal, the number of output bits is given by the equation

    number of output bits = ceil(number of input bits/2)
  • SelectLower halfto output the half of the input bits that contain the least significant bit. If there is an odd number of bits in the input signal, the number of output bits is given by the equation

    number of output bits = ceil(number of input bits/2)
  • Select范围从最重要的位开始to output a certain number of the most significant bits of the input signal. Specify the number of most significant bits to output in theNumber of bits范围。

  • SelectRange ending with least significant bit输出输入信号的某个数量的最低有效位。指定输出的最低有效位数Number of bits范围。

  • SelectRange of bits指示输入输出的一系列连续位位指数范围。你表明了范围[start end]format, and the indices of the input bits are labeled contiguously starting at 0 for the least significant bit.

在仿真期间,此块不会报告溢出警告的包裹。要报告这些警告,请参阅金宝appsimulink.restorediagnostic.reference page. The block does report errors due to wrap on overflow.

港口

输入

expand all

输入signal, specified as a scalar, vector, matrix, or N-D array. Floating-point inputs are passed through the block unchanged.布尔inputs are treated asuint8signals.

Note

在符号整数上执行位操作是困难的。您可以避免将输入信号的数据类型转换为无符号整数类型来避免困难。

Data Types:single|double|int8|INT16|INT32.|int64|uint8|uint16|uint32|uint64|Boolean|固定点

Output

expand all

Contiguous selection of extracted bits, specified as a scalar, vector, matrix, or N-D array. Floating-point inputs are passed through the block unchanged.

Data Types:single|double|int8|INT16|INT32.|int64|uint8|uint16|uint32|uint64|固定点

Parameters

expand all

Select the method for extracting bits from the input signal.

考虑在二进制文件中表示的输入信号110111001:

  • If you selectUpper half为了提取物的比特parameter, the output is11011在二进制中。

  • If you selectLower half为了提取物的比特parameter, the output is11001在二进制中。

  • If you select范围从最重要的位开始为了提取物的比特parameter, and specify3为了Number of bitsparameter, the output is110在二进制中。

  • If you selectRange ending with least significant bit为了提取物的比特parameter, and specify8为了Number of bitsparameter, the output is10111001在二进制中。

  • If you selectRange of bits为了提取物的比特parameter, and specify[4 7]为了位指数parameter, the output is1011在二进制中。

Programmatic Use

块参数:bitsToExtract
Type:character vector
Values:'Upper half' | 'Lower half' | 'Range starting with most significant bit' | 'Range ending with least significant bit' | 'Range of bits'
Default:'Upper half'

从输入信号中选择输出的位数。符号整数数据类型必须至少有两位。无符号数据整数类型可以与单个位短。

Dependencies

To enable this parameter, set提取物的比特to范围从最重要的位开始要么Range ending with least significant bit

Programmatic Use

块参数:numBits
Type:character vector
Values:positive integer
Default:'8'

Specify a contiguous range of bits of the input signal to output. Specify the range in[start end]format. The indices are assigned to the input bits starting with 0 at the least significant bit.

Dependencies

To enable this parameter, set提取物的比特toRange of bits

Programmatic Use

块参数:bitidxrange.
Type:character vector
Values:contiguous range
Default:'[0 7]'

Select the scaling mode to use on the output bit selection:

  • 当你选择Preserve fixed-point scaling, the fixed-point scaling of the input is used to determine the output scaling during the data type conversion.

  • 当你选择将位字段视为整数, the fixed-point scaling of the input is ignored, and only the stored integer is used to compute the output data type.

Programmatic Use

块参数:outscalingMode.
Type:character vector
Values:'保持固定点缩放'| 'Treat bit field as an integer'
Default:'保持固定点缩放'

块特征

Data Types

Boolean|double|固定点|整数|single

直接喂养

yes

Multidimensional Signals

yes

Variable-Size Signals

Zero-Crossing Detection

Extended Capabilities

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

PLC Code Generation
使用Simulink®PLCCoder™生成结构化文本代码。金宝app

Fixed-Point Conversion
使用固定点设计器™设计和模拟定点系统。

在R2006A之前介绍