Components / Arithmetic
Shifter Component in Logisim
Shifts an N-bit data input A left or right by the binary shift distance on pin sh (Logical Left, Logical Right, or Arithmetic Right).
| Library | Arithmetic |
|---|---|
| Type name | Shifter |
| Pins and defaults | a A (-40, -10), dist sh (-40, 10), out0 Out (0, 0), width 4 (1..32), shiftKind ll/lr/ar |
How the Shifter Works in Logisim
The Shifter shifts an N-bit input bus A (upper-left pin) by the number of bit positions specified on the lower-left shift distance pin (sh, whose width is ceil(log2(N)) bits—for example, 2 bits for a 4-bit Shifter or 3 bits for an 8-bit Shifter).
The Shift Kind (shiftKind) attribute selects the shift mode: Logical Left (ll, shifts bits toward MSB and fills low bits with 0, multiplying by 2^sh), Logical Right (lr, shifts toward LSB and fills high bits with 0), or Arithmetic Right (ar, shifts toward LSB while preserving the two's complement sign bit).
Tip: Note that the shift distance pin (sh) has a smaller bit width than A (for a 4-bit Shifter, sh is a 2-bit pin accepting distances 0 to 3).
Shifter Pins & Pinout
| Pin | Direction | Width | Location & Role |
|---|---|---|---|
| a (A) | Input (Upper-left) | 1–32 bits (default 4) | Offset (-40, -10). N-bit data word to shift. |
| dist (sh) | Input (Lower-left) | ceil(log2(N)) bits | Offset (-40, 10). Unsigned shift distance (2 bits for width=4). |
| out0 (Out) | Output (Right edge) | 1–32 bits (default 4) | Offset (0, 0). Shifted N-bit result. |
Shifter Truth Table & Behavior
| Shift Kind (shiftKind) | Operation | Result for A = 1100, sh = 1 |
|---|---|---|
| ll (Logical Left) | A << sh (fill LSB with 0) | 1000 (0x8) |
| lr (Logical Right) | A >>> sh (fill MSB with 0) | 0110 (0x6) |
| ar (Arithmetic Right) | A >> sh (copy sign bit) | 1110 (0xE, signed -2) |