Shift Arithmetic
R2026bShift bits or binary point of signal
Libraries:
Simulink /
Logic and Bit Operations
HDL Coder /
Logic and Bit Operations
Description
The Shift Arithmetic block can shift the bits or the binary point of an input signal, or both.
For example, shifting the binary point on an input of data type sfix(8)
by two places to the right and left gives these decimal values.
| Shift Operation | Binary Value | Decimal Value |
|---|---|---|
No shift (original number) | 11001.011 | –6.625 |
Binary point shift right by two places | 1100101.1 | –26.5 |
Binary point shift left by two places | 110.01011 | –1.65625 |
This block performs arithmetic bit shifts on signed numbers. Therefore, the block recycles
the most significant bit for each bit shift. Shifting the bits on an input of data type
sfix(8) by two places to the right and left gives these decimal
values.
| Shift Operation | Binary Value | Decimal Value |
|---|---|---|
No shift (original number) | 11001.011 | –6.625 |
Bit shift right by two places | 11110.010 | –1.75 |
Bit shift left by two places | 00101.100 | 5.5 |
To shift in either direction, set the direction to
Bidirectional.
Examples
Ports
Input
Output
Parameters
Block Characteristics
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
Programmatic Use: Add Block
To add the block programmatically, use the add_block function with one of these library block paths as the source.
"simulink/Logic and Bit Operations/Shift Arithmetic"
"hdlsllib/Logic and Bit Operations/Shift Arithmetic"
Example: add_block("simulink/Logic and Bit Operations/Shift Arithmetic","myModel/myBlock",MakeNameUnique="on")
More About
Algorithms
Extended Capabilities
Version History
Introduced before R2006a








