|
Parameterized combinatorial logic shifter or barrel shifter megafunction. Altera® recommends using the lpm_clshift
function instead of any other type of shifter.
Altera also recommends instantiating this function as described in Using the MegaWizard® Plug-In Manager.
This topic contains the following information:
FUNCTION lpm_clshift (data[LPM_WIDTH-1..0], distance[LPM_WIDTHDIST-1..0], direction) WITH (LPM_WIDTH, LPM_WIDTHDIST, LPM_SHIFTTYPE) RETURNS (result[LPM_WIDTH-1..0], underflow, overflow);
COMPONENT lpm_clshift GENERIC (LPM_WIDTH: POSITIVE; LPM_WIDTHDIST: POSITIVE; LPM_SHIFTTYPE: STRING := "LOGICAL"; LPM_TYPE: STRING := "LPM_CLSHIFT"; LPM_HINT: STRING := "UNUSED"); PORT (data: IN STD_LOGIC_VECTOR(LPM_WIDTH-1 DOWNTO 0); distance: IN STD_LOGIC_VECTOR(LPM_WIDTHDIST-1 DOWNTO 0); direction: IN STD_LOGIC := '0'; result: OUT STD_LOGIC_VECTOR(LPM_WIDTH-1 DOWNTO 0); underflow, overflow: OUT STD_LOGIC); END COMPONENT;
LIBRARY lpm; USE lpm.lpm_components.all;
INPUT PORTS
Port Name | Required | Description | Comments |
---|---|---|---|
data[] |
Yes | Data to be shifted. | Input port LPM_WIDTH wide. |
distance[] |
Yes | Number of positions to shift data[]
in the direction specified by the direction port. |
Input port LPM_WIDTHDIST wide. |
direction |
No | Direction of shift. Low = left (toward the MSB), high = right (toward the LSB). | Default value is 0 (low) = left (toward the MSB). |
OUTPUT PORTS
Port Name | Required | Description | Comments |
---|---|---|---|
result[] |
Yes | Shifted data . |
Output port LPM_WIDTH wide. |
underflow |
No | 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 (X) logic levels. |
overflow |
No | 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 (X) logic levels. |
Parameter | Type | Required | Description |
---|---|---|---|
LPM_WIDTH |
Integer | Yes | Width of the data[] and result[]
ports. Any positive integer > 1. |
LPM_WIDTHDIST |
Integer | Yes | Width of the distance[] input port.
The LPM_WIDTHDIST parameter specifies the width of the distance
port. The values on the distance port 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-base-2(LPM_WIDTH )"
or [ log-base-2(LPM_WIDTH )] . Any value
on the distance port greater than LPM_WIDTH -1
results in an undefined (X) logic level. |
LPM_SHIFTTYPE |
String | No | Type of shifter: "LOGICAL" ,
"ROTATE" , "ARITHMETIC" , or
"UNUSED" .
If omitted, the default is "LOGICAL" . The sign bit
is extended for "ARITHMETIC" . For a "LOGICAL"
right shift, 0s are always shifted into the MSB. |
LPM_HINT |
String | No | Allows you to specify Altera-specific
parameters in VHDL Design Files (.vhd).
The default is "UNUSED" . |
LPM_TYPE |
String | No | Identifies the library of parameterized modules (LPM) entity name in VHDL Design Files. |
The lpm_clshift
megafunction acts like a barrel shifter. It contains entirely combinatorial logic.
Overflow occurs when the shifted result exceeds the precision of the result
bus. For "LOGICAL"
values, overflow occurs when any 1 has been shifted out. For "ARITHMETIC"
values, overflow occurs when a significant digit is shifted into or past the sign bit. Underflow occurs when the shifted result contains no significant digits.
Operation of the LOGICAL
shifter is illustrated in the following example, in which LPM_WIDTH
= 4:
Inputs | Outputs | ||||
---|---|---|---|---|---|
direction |
distance[ 1. .0] |
data[ 3. .0] |
overflow |
result[ 3. .0] |
underflow |
X | 0 | dcba | 0 | dcba | 0 |
0 | 1 | dcba | d | cba0 | 0 |
0 | 2 | dcba | d # c | ba00 | 0 |
0 | 3 | dcba | d # c # b | a000 | 0 |
1 | 1 | dcba | 0 | 0dcb | !d & !c & !b & a |
1 | 2 | dcba | 0 | 00dc | !d & !c & (b # a) |
1 | 3 | dcba | 0 | 000d | !d & (c # b # a) |
Operation of the ARITHMETIC
shifter is illustrated in the following example, in which LPM_WIDTH
= 4:
Inputs | Outputs | ||||
---|---|---|---|---|---|
direction |
distance[ 1. .0] |
data[ 3. .0] |
overflow |
result[ 3. .0] |
underflow |
X | 0 | dcba | 0 | dcba | 0 |
0 | 1 | 0cba | c | cba0 | 0 |
0 | 1 | 1cba | !c | cba0 | 0 |
0 | 2 | 0cba | c # b | ba00 | 0 |
0 | 2 | 1cba | c! # b! | ba00 | 0 |
0 | 3 | 0cba | c # b # a | a000 | 0 |
0 | 3 | 1cba | !c # !b # !a | a000 | 0 |
1 | 1 | 0cba | 0 | 00cb | !c & !b & a |
1 | 1 | 1cba | 0 | 11cb | c & b & !a |
1 | 2 | 0cba | 0 | 000c | !c & (b # a) |
1 | 2 | 1cba | 0 | 111c | c & (!b # !a) |
1 | 3 | 0cba | 0 | 0000 | (c # b # a) |
1 | 3 | 1cba | 0 | 1111 | (!c # !b # !a) |
Operation of the ROTATE
shifter is illustrated in the following example, in which LPM_WIDTH
= 4:
Inputs | Outputs | ||
---|---|---|---|
direction |
distance[ 1. .0] |
data[ 3. .0] |
result[ 3. .0] |
X | 0 | dcba | dcba |
0 | 1 | dcba | cbad |
0 | 2 | dcba | badc |
0 | 3 | dcba | adcb |
1 | 1 | dcba | adcb |
1 | 2 | dcba | badc |
1 | 3 | dcba | cbad |
The following table summarizes the resource usage for an lpm_clshift
function used to implement a 16-bit bidirectional arithmetic shifter. Logic cell usage scales slightly faster than linearly in proportion to shifter width.
Design Goals | Design Results | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
Numbers of shared expanders used are shown in parentheses ( ).
This topic prints best in Landscape orientation. |
- PLDWorld - |
|
Created by chm2web html help conversion utility. |