Extract a range of bits from a value
Library
Logic and Bit Operations
Description
The Bit Slice block allows the element-wise extraction of a contiguous set of bits from the input values. The extracted bits are returned as unsigned fixed point values of an all-integer range, and you specify the width of the specified extraction range. The block dialog box allows you to specify the range of bits using one of these methods:
- Bottom bit + width - You specify the bottom bit and the number of bits to be extracted (Slice width).
- Top bit + width - You specify the top bit and the number of bits to be extracted (Slice width).
- Top and bottom bit - You specify the top and bottom bits and the number of bits to be extracted is implied.
The top and bottom bit specifications have multiple ways of specifying the position in relation to either the Least Significant Bit (LSB), the Binary Point of a fixed-point value, or the Most Significant Bit (MSB). In case of integer inputs the Binary Point and Least Significant Bit options are equivalent. Offsets to specify the position relative to these anchors can be positive or negative. However, an error will occur during simulation and/or code generation if the extraction range lies outside of the input type bit range.
Data Type Support
The Bit Slice block accepts any real-valued integer or fixed-point type of any dimension N ≤ 2. Floating point values and complex numeric types are not supported.
The output data type is always a real-valued unsigned fixed-point type with integer-only range. The output data has the same width as the extraction range you specify.
The output dimensions are the same as the input dimensions.
Parameters
- Specify range as
- The
Specify range as
parameter specifies the extraction range. - Slice width
- Specifies the width of the bit range to be extracted.
Slice width
is only enabled if theSpecify range as
parameter is set toTop bit + width
orBottom bit + width
. - Bit position relative to
- Defines the basis for offset specifications in both Top of bit
range and
Bottom of bit range
sections of the block dialog box.Following are the settings for the
Bit position relative to
parameter. - With offset
- Specifies the offset to be applied to the basis specified by the corresponding
Bit position relative to
parameter. TheWith offset
parameter is available in both Top of bit range and Bottom of bit range sections of the block dialog box.