A barrel shifter uses a matrix of switches to select where each input bit ends up, as this Wikipedia diagram shows. Each diagonal control line selects a particular shift amount. But for a 32-bit processor, the matrix becomes very large. 3/11
Top-level
A barrel shifter uses a matrix of switches to select where each input bit ends up, as this Wikipedia diagram shows. Each diagonal control line selects a particular shift amount. But for a 32-bit processor, the matrix becomes very large. 3/11 9 comments
Here's how the 386's barrel shifter looks on the die. Two values enter at the bottom from the registers and are latched. The shift matrix is in the middle with diagonal control lines selecting the shift. Above, a circuit shifts by 0 to 3 positions, producing the output. 5/11 At each position in the matrix, a transistor is the switch between an input line and an output line. This photo shows eight of the tiny transistors. 6/11 This photo shows part of the shift matrix with the sloping polysilicon control lines (green) and transistors (dark boxes). The diagram shows how three of the control lines are wired. 7/11 This circuit shifts from 0 to 3 bits. It passes the input bit straight through or sends it two positions to the right. Next, it passes that bit straight through or passes it one position to the right. Thus each bit is shifted right 0 to 3 positions. 8/11 At the input to the shifter, latch circuits hold the two input words from the register file. The circuit can also swap the two values. The photos show the circuit on the die. Left shows the metal layers; right shows the underlying silicon with the transistors. 9/11 There are complications, of course. The matrix outputs 37 bits, not 32, for reasons. Supporting bytes and 16-bit shifts needs more circuitry as does rotating through the carry. For more on the 386's barrel shifter, see my blog post: https://www.righto.com/2023/12/386-barrel-shifter.html 10/11 |
The 386 uses a hybrid approach: a smaller matrix shifts, but only by a multiple of 4 bits. A second circuit applies a shift of 0 to 3 bits. In combination, the circuits shift by an arbitrary amount. This approach saves circuitry. 4/11