
6
Altera Corporation
Gate Functions
lpm_clshift
Parameterized Combinatorial Logic Shifter 
or Barrel Shifter 
The 
lpm_clshift
 function performs 
logical, rotational, or arithmetic 
combinatorial shifting. The direction and 
distance of the shifting are user-
controllable.
Ports
Parameters
Name
Type
Required
Description
data[]
Input
Input
Yes
Yes
Data to be shifted. This port is 
LPM_WIDTH
 wide.
Number of positions to shift 
data[]
 in the direction specified by the 
direction
 port. This port is 
LPM_WIDTHDIST
 wide.
Direction of shift. Low = left (toward the most significant bit (MSB)), high = right 
(toward the least significant bit (LSB)). Default value is 0 (low) = left (toward 
the MSB).
Shifted data. This port is 
LPM_WIDTH
 wide.
Logical or arithmetic underflow. If 
"ROTATE"
 is specified as the 
LPM_SHIFTTYPE
 parameter value and 
overflow
 and 
underflow
 are 
connected, the output of 
overflow
 and 
underflow
 will be undefined logic 
levels.
Logical or arithmetic overflow. If 
"ROTATE"
 is specified as the 
LPM_SHIFTTYPE
 parameter value and 
overflow
 and 
underflow
 are 
connected, the output of 
overflow
 and 
underflow
 will be undefined logic 
levels.
distance[]
direction
Input
No
result[]
Output
Output
Yes
No
underflow
overflow
Output
No
Name
Required
Value
Description
LPM_SHIFTTYPE
No
"LOGICAL"
"ROTATE"
"ARITHMETIC"
Integer > 1
Integer > 0
The sign bit is extended for 
"ARITHMETIC"
 right shifts. For 
a 
"LOGICAL"
 right shift, 0s are always shifted into the 
MSB or LSB. The default value is 
"LOGICAL"
.
Width of the 
data[]
 and 
result[]
 ports.
Width of the 
distance[]
 port. The 
distance[]
 port 
values normally range from 0, which is “no shift,” to 
(
LPM_WIDTH
 – 1), which is the maximum meaningful shift. 
The typical value assigned to 
LPM_WIDTHDIST
 is “the 
smallest integer not less than log
2
(
LPM_WIDTH
)” or 
ceil(log
2
(
LPM_WIDTH
)). Any 
distance[]
 port value 
greater than (
LPM_WIDTH
 – 1) results in an undefined logic 
level.
LPM_WIDTH
Yes
Yes
LPM_WIDTHDIST
data[]
distance[]
direction
result[]
underflow
overflow
LPM_CLSHIFT
LPM_SHIFTTYPE=
LPM_WIDTH=
LPM_WIDTHDIST=CEIL(LOG2(LPM_WIDTH))