Programmable Right Shift [TM]
Time-multiplexed programmable bitwise right shift operation. Shifts all bits of the input binary number to the right by a dynamically programmable amount via the SHIFT input port. Supports both logical (zero-fill) and arithmetic (sign-extend) shifting modes. Configurable maximum shift and TM factors from 2 to 32. Optionally latched output (configurable latency: 0 or 1 clock cycle).
Introduction
This block performs a programmable right shift operation on time-multiplexed (TM) data streams. Unlike fixed shift operations, the shift amount is dynamically controlled via the integer SHIFT input port, allowing runtime flexibility.
Each bit of the input is shifted right by the amount specified on the SHIFT port (0 to Max Shift). The vacant leftmost positions are filled with either:
- Zeros (logical shift, Preserve Sign = false)
- Sign bit (arithmetic shift, Preserve Sign = true)
The shift operation can be:
- Combinational (zero latency, Latch Output = false)
- Registered (1 clock cycle latency, Latch Output = true)
$$ \mathrm{OUT}(n) = \mathrm{IN}(n) \gg \mathrm{SHIFT}(n), $$
where SHIFT is the runtime-configurable shift amount. The TM Factor property determines how many parallel samples are processed per clock cycle.
Pin Description
Input Width × TM Factor
Each TM phase receives its corresponding slice of the input bus.
Shift amount control (integer input). Specifies how many bit positions to shift right. Range: 0 to Max Shift (configurable property) Type: Integer (non-TM, applies to all TM phases)
Values outside [0, Max Shift] may produce undefined results.
Clock input for registered output mode. Only used when Latch Output = true. Defaults to acquisition clock (CLK_ACQ).
On rising edge, the shifted result is latched to OUT.
Reset input for registered output mode. Only used when Latch Output = true. Defaults to global reset.
When asserted, clears the output register to zero.
Right-shifted output, always TM (same factor as IN).
Width: Input Width × TM Factor (same as IN)
Latency:
- 0 cycles if Latch Output = false (combinational)
- 1 cycle if Latch Output = true (registered)
Properties
Set the input word size in bits per phase
Number of bits per input sample ($N_\text{in}$). Range: 1 – 128. Each TM phase processes samples of this width. Output width is always equal to input width.Default: 8
Range: 1 – 128
Set the time multiplexing factor (number of phases)
Time-multiplexing factor (number of parallel phases). Allowed values: 2, 4, 8, 16, 32 (up to 32). Higher values increase throughput proportionally but consume more FPGA resources (one barrel shifter instance per TM phase).Default: 4
Range: 2 – 32
Maximum shift value
Maximum allowed shift amount ($S_\text{max}$). Range: 1 – 16. The SHIFT input must be in the range [0, Max Shift].
Larger Max Shift values require more FPGA resources (wider barrel shifter). Choose the smallest value that meets your application needs.
Default: 4
Range: 1 – 16
If true, performs arithmetic shift (sign extend); if false, performs logical shift (zero extend)
Shift mode selector (boolean).
- false (default): Logical shift (zero-fill leftmost bits)
- true: Arithmetic shift (sign-extend leftmost bits)
Enable Preserve Sign when working with signed two’s complement numbers to maintain correct signed division behavior.
Default: False
If true, output is registered (latched)
Output register control (boolean).
- false (default): Combinational output, zero latency
- true: Registered output, 1 clock cycle latency
Enable latching when:
- Timing closure is difficult
- Pipelining is needed for high-speed operation
- Synchronous output alignment is required
Default: False
Functional description
The component implements a programmable barrel shifter (right shift) in VHDL, replicated N times (where N = TM Factor) to support time-multiplexed data streams.
For each TM phase, the operation is:
$$ y[i] = x[i] \gg s, $$
where:
- $x[i]$ → input sample at phase $i$
- $y[i]$ → output sample at phase $i$
- $s$ → shift amount from SHIFT input (0 to Max Shift)
Shift modes
The Preserve Sign property determines the fill behavior:
-
Preserve Sign = false (Logical shift):
- Vacant MSBs filled with zeros
- Equivalent to unsigned division: $y = \lfloor x / 2^s \rfloor$
-
Preserve Sign = true (Arithmetic shift):
- Vacant MSBs filled with the sign bit (MSB of input)
- Preserves sign for two’s complement numbers
- Equivalent to signed division: $y = \lfloor x / 2^s \rfloor$ (signed)
Dynamic shift control
- SHIFT port: Integer input specifying the shift amount (range: 0 to Max Shift)
- Barrel shifter: Efficiently implements any shift from 0 to Max Shift
- Same width: Output width always equals input width
Latency modes
The block offers two latency configurations via the Latch Output property:
-
Latch Output = false (default):
- Purely combinational logic
- Latency = 0 clock cycles
- Output changes immediately with inputs
-
Latch Output = true:
- Output is registered (latched) on CLK rising edge
- Latency = 1 clock cycle
- Provides timing closure for high-speed designs
- RESET clears the output register
Example (Logical shift)
Given an 8-bit input and Max Shift = 4, Preserve Sign = false:
- Input =
11010110, SHIFT = 0 → Output =11010110(no shift) - Input =
11010110, SHIFT = 2 → Output =00110101(shift right 2, zero-fill) - Input =
11010110, SHIFT = 4 → Output =00001101(shift right 4)
Example (Arithmetic shift)
Given an 8-bit input and Max Shift = 4, Preserve Sign = true:
- Input =
11010110(negative), SHIFT = 2 → Output =11110101(sign-extended) - Input =
01010110(positive), SHIFT = 2 → Output =00010101(zero-filled)
Mathematical background
- Logical shift: $x \gg s = \lfloor x / 2^s \rfloor$ (unsigned division)
- Arithmetic shift: $x \gg_{\text{arith}} s = \lfloor x / 2^s \rfloor$ (signed division, two’s complement)
This is commonly used for:
- Dynamic scaling and attenuation in signal processing
- Runtime-configurable division by powers of 2
- Adaptive fixed-point arithmetic
- Building configurable DSP and arithmetic pipelines
Timing
The component latency depends on the Latch Output property:
| Property | Latch Output = false | Latch Output = true |
|---|---|---|
| Programmable Right Shift TM | 0 | 1 |
All TM phases are processed in parallel within the same clock cycle.
Typical use cases
- Variable-gain attenuation (divide by 2^N)
- Adaptive fixed-point rescaling
- Dynamic bit field extraction with configurable alignment
- Building configurable DSP pipelines
- Barrel shifter components in ALUs
Waveform example
Example with TM Factor = 4, Max Shift = 4, Input = 4-bit values, SHIFT = 2, Preserve Sign = false, Latch Output = false.
Note: With Latch Output = false, output is immediate (combinational). Values in hex: 0xC » 2 = 0x3, 0xF » 2 = 0x3, 0xA » 2 = 0x2, 0x7 » 2 = 0x1.