Skip to Main Content Skip to Search
Product Documentation

Bitwise Operators

Overview of Bitwise Operator Blocks

The Bitwise Operator sublibrary provides commonly used operations on bits and bit fields.

All Bitwise Operator blocks support:

Bitwise Operator blocks do not currently support:

To open the Bitwise Operators sublibrary, double-click its icon
in the hdldemolib window. Alternatively, you can open the Bitwise Operators sublibrary directly by typing the following command at the MATLAB prompt:

hdldemolib_bitops

The following figure shows the Bitwise Operators sublibrary.

Bit Concat

Description

The Bit Concat block concatenates up to 128 input words into a single output. The input port labeled L designates the lowest-order input word; the port labeled H designates the highest-order input word. The right-left ordering of words in the output follows the low-high ordering of input signals.

The operation of the block depends on the number and dimensions of the inputs, as follows:

Data Type Support

HDL Implementation and Implementation Parameters

Implementation: default

Implementation Parameters: InputPipeline, OutputPipeline

Parameters and Dialog Box

Number of Inputs: Enter an integer specifying the number of input signals. The number of input ports displayed on the block updates when Number of Inputs changes.

Bit Reduce

Description

The Bit Reduce block performs a selected bit reduction operation (AND, OR, or XOR) on all the bits of the input signal, reducing it to a single-bit result.

Data Type Support

HDL Implementation and Implementation Parameters

Implementation: default

Implementation Parameters: InputPipeline, OutputPipeline

Parameters and Dialog Box

Reduction Mode

Default: AND

Specifies the reduction operation, as follows:

Bit Rotate

Description

The Bit Rotate block rotates the input signal left or right by a specified number of bit positions.

Data Type Support

HDL Implementation and Implementation Parameters

Implementation: default

Implementation Parameters: InputPipeline, OutputPipeline

Parameters and Dialog Box

Rotate Mode: Specifies direction of rotation, either left or right.

Default: Rotate Left

Rotate Length: Specifies the number of bits to be rotated. Rotate Length must be greater than or equal to zero.

Default: 0

Bit Shift

Description

The Bit Shift block performs a logical or arithmetic shift on the input signal.

Data Type Support

HDL Implementation and Implementation Parameters

Implementation: default

Implementation Parameters: InputPipeline, OutputPipeline

Parameters and Dialog Box

Shift Mode

Default: Shift Left Logical

Specifies the type and direction of shift, as follows:

Shift Length

Default: 0

Specifies the number of bits to be shifted. Shift Length must be greater than or equal to zero.

Bit Slice

Description

The Bit Slice block returns a field of consecutive bits from the input signal. The lower and upper boundaries of the bit field are specified by zero-based indices entered in the LSB Position and MSB Position parameters.

Data Type Support

HDL Implementation and Implementation Parameters

Implementation: default

Implementation Parameters: InputPipeline, OutputPipeline

Parameters and Dialog Box

MSB Position

Default: 7

Specifies the bit position (zero-based) of the most significant bit (MSB) of the field to be extracted.

For an input word size WS, LSB Position and MSB Position should satisfy the following constraints:

WS > MSB Position >= LSB Position >= 0; 

The word length of the output is computed as (MSB Position - LSB Position) + 1.

LSB Position

Default: 0

Specifies the bit position (zero-based) of the least significant bit (LSB) of the field to be extracted.

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS