0% found this document useful (0 votes)
16 views14 pages

Shifter

Uploaded by

匡政
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views14 pages

Shifter

Uploaded by

匡政
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

EECS 427

Lecture 11: Shifters / CAD5


Reading: 11.5

EECS 427 W07 Lecture 11 1


Shift types
• Logical
– Shift in 0s
– left shifts pretty much always logical
– Left shift is multiplication by 2n
• Rotate
– Useful in some coding and crypto applications
– Shift in the bits that were shifted out
– Data preserving
– Shifts can be rotates followed by bitwise mask

EECS 427 W07 Lecture 11 2


More shift types
• Arithmetic
– Shift “in” the high bit
– Sometimes use the carry control bit instead
– Useful for lots of things besides the obvious divide
by 2n (and round down)
– In particular, conditional generation of masks
based on sign of value
– Absolute value:
• rb = ra sra ra 15
• ra = ra xor rb
• ra = ra - rb

EECS 427 W07 Lecture 11 3


Shift Examples
• Arithmetic vs. logical shift (Start with 1101)
– Logical shift (baseline op for us)
• Logical shift right by 1: 0110 Shift in 0s for logical
• Logical shift right by 2: 0011 right shifts
• Logical shift left by 1: 1010
Shift in 0s for left shifts
• Logical shift left by 2: 0100
– Arithmetic shift (not baseline)
• Arithmetic left shifts same as logical
• Arithmetic right shift by 1: 1110 Repeat sign of MSB for
• Arithmetic right shift by 2: 1111 arithmetic right shifts

EECS 427 W07 Lecture 11 4


Barrel Shifter
A3
B3

Sh1
A2
B2

Sh2 : Data Wire


A1
B1 : Control Wire

Sh3
A0
B0

Requires decoding of
Sh0 Sh1 Sh2 Sh3
shift amount given in
Area Dominated by Wiring instruction word
EECS 427 W07 Lecture 11 5
4x4 barrel shifter
A3

A2

A1

A0

Sh0 Sh 1 S h2 Sh3
Only 1 shift B uffer
bit high at Widthbarrel ~ 2 pm N
any time
N is max shift width (15 for us), pm is metal pitch
EECS 427 W07 Lecture 11 6
Barrel Considerations
• Buffer should really have weak feedback (for
full swing)
• Shown choices for horiz / diagonal / vertical
lines not the only ones
• How to implement shifts in both directions?
– This turns out to be nice for barrel because one
direction only requires a triangle, and the two
triangles can be fit together to form a square
• Fast for A through, but B goes through
decoder
• Size becomes a problem at more bits

EECS 427 W07 Lecture 11 7


The Binary Shifter Concept
rgt nop left

Ai Ai Ai-1 rgt nop left Bi Bi-1


Bi
A1 A0 0 1 0 A1 A0

A1 A0 1 0 0 0 A1

A1 A0 0 0 1 A0 0

Ai-1 Bi-1

EECS 427 W07 Lecture 11 8


Thanks to: Irwin/Narayanan
Logarithmic Shifter
Sh1 Sh1 Sh2 Sh2 Sh4 Sh4

A3 B3

A2 B2

A1 B1

A0 B0

EECS 427 W07 Lecture 11 9


0-7 bit Logarithmic Shifter
1 2 4

A
3 Out3

A
2 Out2

A
1 Out1

A
0 Out0

K = log2N
EECS 427 W07 Lecture 11 10
Log Shifter Considerations
• Wiring pattern looks very similar to kogge-
stone adder
• No decoding needed
• How to handle both directions?
– Use binary shifters with connections in both
directions?
– Some way to avoid that?
• How to implement those small muxes?
– Use pass transistors like barrel shifter?

EECS 427 W07 Lecture 11 11


Other Spins on Shifters
• Log4 instead of log2 (cross between barrel / log)
– Advantage: Fewer stages of pass transistors
– Disadvantage: must re-encode the control bits
– Ex: 16 bits Æ 4 stages for log2 vs. only 2 stages for log4
• Rotate instruction – could be an ISA addition
– 11010101 Æ rotate right by 5 bits Æ 10101110
– Both shift directions can be rotations with appropriate
masking
• Reverse order shifters – do the big shifts first
– Helpful because the big shifts have larger wire capacitances
– Elmore delay is reduced by having large caps charged
through the least resistance (fewest pass transistors)

EECS 427 W07 Lecture 11 12


CAD5
• Logical “left shift” is only required instruction
• Shift amount could be negative though which
means right shift is hidden in there too.
• Log shifter is harder. Much less uniform, and
shifting in both directions is hard
• Size should be dominated by wiring, and will
“want” to be narrower than your bitslice width.
• Don’t give in! Keep to your bitslice width.

EECS 427 W07 Lecture 11 13


Shifter Summary
• Barrel shifters are area-intensive (though at
16 bits are probably no bigger) but have only
1 pass transistor per path
– Lots of junction capacitance though
• Log shifters are more versatile for wider data
• Lots of variations: log base, reverse order,
pass transistor vs. T-gate
• Don’t forget data dependent shifts and
dealing with shifts in both directions
EECS 427 W07 Lecture 11 14

You might also like