Shift Registers, Shifters and Multipliers
In questa pagina 4
In questa pagina 3
Together with the adder (AddersHalf adder and full adder, generate-propagate-delete decomposition, the ripple-carry adder and its linear worst-case delay, the adder-subtractor, and the fast structures carry-lookahead, carry-bypass, carry-select and square-root carry-select with their delay formulas and optimal block sizes.Adders →), these are the other basic circuits of an arithmetic-logic unit (Arithmetic Logic UnitRole of the ALU, its inputs and the N Z C V flags, the 1-bit ALU built from AND, OR, a full adder and a multiplexer, the N-bit ALU with subtraction, NOR, set-less-than, zero and overflow detection, comparators, bus sharing with tri-state outputs, and the other computation units.Arithmetic Logic Unit →).
Shift register
Definition (shift register). A cascade of D registers with the same clock: the output of each is the input of the next, so at every clock edge the data advances by one position. The first register receives the serial input; the last gives the serial output.
Example. 4 bits, starting at , serial input entering from the right (shift left): . (Entering from the left and shifting right: .)
- Serial input, parallel output: converts bits received one at a time into a word (serial reception).
- Parallel input, serial output: the opposite (transmission); a multiplexer at the input of each register chooses between the parallel datum (load) and the output of the previous register (shift).
- Other uses: delay lines, FIFOs, sequence generators.
- Shifting left or right is multiplication or division by 2 (Binary ArithmeticBinary addition and two's complement subtraction, overflow for unsigned (carry) and signed (sign change) numbers, the N Z C V flags, multiplication by shifts and additions, Booth's algorithm with a worked example, division, and logical, arithmetic and rotate shifts.Binary Arithmetic →).
Hold constraint. Two registers are directly connected (), so (also in the presence of clock skew) is critical: registers are built to satisfy it, or delays are inserted. In FPGAs shift registers up to 32 bits are built directly in the LUTs.
Shifters
Definition (shift and rotate). A shifter moves the bits of a word by positions. For a word :
- logical shift left (LSL): bits move toward the MSB, enters from the right: multiplies by (without overflow);
- logical shift right (LSR): enters from the left: divides an unsigned number by ;
- arithmetic shift right (ASR): the sign bit is replicated from the left: divides a two's complement number by (rounding toward );
- rotation (ROL, ROR): bits leaving one side re-enter from the other.
Examples (8 bits). , LSL by : . , ASR by : ; LSR by would give , wrong for a signed number. Rotate right of by : . : logical (), arithmetic ().
Barrel shifter. A shifter by one position (a multiplexer per bit) is not enough for variable shifts. The barrel shifter uses levels of multiplexers: level shifts by positions if bit of the shift amount is . For : three levels (shifts of , , ) cover every from to ; for levels and are active. Cost: multiplexers; delay: multiplexer delays, independent of . In ARM the barrel shifter sits in front of the second ALU input, so a shift costs no extra cycle.
Multipliers
Definition (product as a sum of shifted partial products). The product of two unsigned -bit numbers has bits. For each bit of the multiplier form a partial product (one AND per bit), shifted by positions, and add them all.
Example ( bits), , :
1011 A (11)
x 1101 B (13)
------
1011 bit B0 = 1: A
0000 bit B1 = 0: zero, shifted by 1
1011 bit B2 = 1: A shifted by 2
1011 bit B3 = 1: A shifted by 3
--------
10001111 = 143Formula (array multiplier: cells and delay). AND gates generate the partial products and a matrix of full adders sums the rows (the carry of each row propagates to the next). For : AND gates and full adders. The critical path crosses about cells: linear in with area .
Example. , ps, ps: about ps.
Alternatives.
- Wallace tree (carry-save): partial products are reduced by levels of full adders used as 3:2 compressors (three bits in, two out) down to two rows; the last step is a fast adder. Delay .
- Booth: handles two's complement directly; the radix-4 version groups the multiplier in bit pairs and halves the number of partial products (algorithm in Binary ArithmeticBinary addition and two's complement subtraction, overflow for unsigned (carry) and signed (sign change) numbers, the N Z C V flags, multiplication by shifts and additions, Booth's algorithm with a worked example, division, and logical, arithmetic and rotate shifts.Binary Arithmetic →).
- Sequential (shift-and-add): one adder and an accumulating register; at each cycle add if , then shift. cycles, minimum area.
- Dedicated DSP blocks: FPGAs contain hardware multipliers ( bits with pre-adder and accumulator), much faster than logic-built ones.
Common mistakes
- Using logical right shift on a signed number (the sign is lost): use arithmetic shift.
- Forgetting that an -bit by -bit product needs bits.
- Saying the array multiplier is : that is the Wallace tree (with a fast final adder).
- Forgetting the hold constraint between directly connected registers.
Versione ripasso
Shift register
D registers in cascade; each edge the data advances one position. Example: with serial input . Serial-parallel conversion; parallel-serial with a load/shift multiplexer; delay lines, FIFOs. Direct connection: need .
Shifters
- LSL multiplies by ; LSR divides unsigned (0 enters); ASR divides two's complement (sign replicated); rotation re-inserts the bits.
- ASR 1 ; LSR would give (wrong).
- Barrel shifter: levels of multiplexers, level shifts by if bit of is 1; multiplexers; delay independent of (: levels and ). In ARM it precedes the second ALU input.
Multipliers
- Product of -bit numbers: bits; sum of partial products shifted by . Example ().
- Array: AND, full adders; , linear in , area (: 16 AND, 12 full adders).
- Wallace tree: 3:2 compressors (carry-save) down to two rows, then a fast adder: .
- Booth (Binary ArithmeticBinary addition and two's complement subtraction, overflow for unsigned (carry) and signed (sign change) numbers, the N Z C V flags, multiplication by shifts and additions, Booth's algorithm with a worked example, division, and logical, arithmetic and rotate shifts.Binary Arithmetic →): radix-4 halves the partial products, handles two's complement.
- Sequential shift-and-add: one adder, cycles, minimum area.
- DSP blocks: dedicated hardware multipliers in FPGAs.
Common mistakes: LSR on signed numbers; forgetting the -bit product; array multiplier is not .