Lec13 Shifter

  • Upload
    jbanful

  • View
    242

  • Download
    0

Embed Size (px)

Citation preview

  • 8/9/2019 Lec13 Shifter

    1/30

    ECE2030Introduction to Computer Engineering

    Lecture 13: Building Blocks forCombinational Logic (4 !"ifters#$ultipliers

    Prof. Hsien-Hsin Sean LeeProf. Hsien-Hsin Sean Lee

    School of Electrical and Computer EngineeringSchool of Electrical and Computer Engineering

    Georgia TechGeorgia Tech

  • 8/9/2019 Lec13 Shifter

    2/30

    Basic !"ifting

    % !"ift directions& Left (multipl' b' 2

    & ig"t (di)ide b' 2%*ake +oor )alue if t"e result is not an integer

    %,loor )alue of -- (or - is t"e greatestinteger number less t"an or e.ual to -#-# E/g/ 2 2

    32 2

    % !"ift t'pes& Logical (or unsigned& rit"metic (or signed

  • 8/9/2019 Lec13 Shifter

    3/30

    Logical !"ift

    % !"ift Left& $!B: !"ifted out

    & L!B: !"ifted in 5it" a 607

    & E8amples:

    % (11001011 99 1 10010110% (11001011 99 3 01011000

    % !"ift rig"t

    & $!B: !"ifted in 5it" a 607

    & L!B: !"ifted out

    & E8amples: (!ome I! use triple 67 for logical rig"ts"ift

    % (11001011 1 01100101

    % (11001011 3 00011001

  • 8/9/2019 Lec13 Shifter

    4/30

  • 8/9/2019 Lec13 Shifter

    5/30

    E8amples of rit"metic !"ift 1111 1011 rit"metic s"ift rig"tb' 1

    1111 1101

    1111 1011 rit"metic s"ift leftb' 1

    1111 0110

    1011 1111 ( > rit"metic s"ift leftb' 1 (i/e/ 82

    0111 1110 ( ?12> 130 > rit"metic s"ift leftb' 1 (i/e/ 82

    1000 0100 ( 124 ?132 @)er+o5 ;

    @)er+o5

  • 8/9/2019 Lec13 Shifter

    6/30

    4bit Logical !"ifter

    !1 !0 A3 A2 A1 A0

    0 - 3 2 1 0

    1 0 0 3 2 1

    1 1 2 1 0 0

    3 2 1 0

    A3 A2 A1 A0

    !!

    !0

    !1

    L

    101010

    001201111

    101301212

    201313

    ASSASD

    ASSASSASD

    ASSASSASD

    ASSASD

    +=

    ++=

    ++=

    +=

  • 8/9/2019 Lec13 Shifter

    7/30

    4bit Logical !"ifter using 4to1 $u8

    4to1 $u8

    00 01 10 11s1

    s0

    !1 !0 A3 A2 A1 A0

    0 - 3 2 1 0

    1 0 0 3 2 1

    1 1 2 1 0 0

    A3

    23

    4to1 $u8

    00 01 10 11s1

    s0

    A2

    1

    4to1 $u8

    00 01 10 11s1

    s0

    A1

    0

    4to1 $u8

    00 01 10 11s1

    s0

    A0

    !1

    !0

    ig"t !"ift

    Left !"ift

  • 8/9/2019 Lec13 Shifter

    8/30

    4bit rit"metic !"ifter 5 4to1 $u8

    4to1 $u8

    00 01 10 11s1

    s0

    !1 !0 A3 A2 A1 A0

    0 - 3 2 1 0

    1 0 33 3 2 1

    1 1 2 1 0 0

    A3

    23

    4to1 $u8

    00 01 10 11s1

    s0

    A2

    1

    4to1 $u8

    00 01 10 11s1

    s0

    A1

    0

    4to1 $u8

    00 01 10 11s1

    s0

    A0

    !1

    !0

    ig"t !"ift

    Left !"ift

  • 8/9/2019 Lec13 Shifter

    9/30

    4bit rit"metic !"ifter 5 4to1 $u8

    4to1 $u8

    00 01 10 11s1

    s0

    !1 !0 A3 A2 A1 A0

    0 - 3 2 1 0

    1 0 33 3 2 1

    1 1 2 1 0 0

    A3

    23

    4to1 $u8

    00 01 10 11s1

    s0

    A2

    1

    4to1 $u8

    00 01 10 11s1

    s0

    A1

    0

    4to1 $u8

    00 01 10 11s1

    s0

    A0

    !1

    !0

    ig"t !"ift

    Left !"ift@)er+o5@)er+o5

  • 8/9/2019 Lec13 Shifter

    10/30

    4bit rit"metic !"ifter 5 4to1 $u8

    4to1 $u8

    00 01 10 11s1

    s0

    !1 !0 A3 A2 A1 A0

    0 - 3 2 1 0

    1 0 33 3 2 1

    1 1 2 1 0 0

    A3

    23

    4to1 $u8

    00 01 10 11s1

    s0

    A2

    1

    4to1 $u8

    00 01 10 11s1

    s0

    A1

    0

    4to1 $u8

    00 01 10 11s1

    s0

    A0

    !1

    !0

    ig"t !"ift

    Left !"ift@)er+o5@)er+o5

  • 8/9/2019 Lec13 Shifter

    11/30

    otator

    S1 S0 D3 D2 D1 D0

    0 0 3 2 1 0

    0 1 0 3 2 1

    1 0 1 0 3 2

    1 1 2 1 0 3

    4to1 $u8

    00 01 10 11

    s1s0

    A3

    23

    4to1 $u8

    00 01 10 11

    s1s0

    A2

    1

    4to1 $u8

    00 01 10 11

    s1s0

    A1

    0

    4to1 $u8

    00 01 10 11

    s1s0

    A0

    !1

    !0

  • 8/9/2019 Lec13 Shifter

    12/30

    Barrel !"ifter

    S2 S1 S0 D3 D2 D1 D00 0 0 3 2 1 0

    0 0 1 3 3 2 1

    0 1 0 3 3 3 2

    0 1 1 3 3 3 3

    1 0 0 3 2 1 0

    1 0 1 2 1 0 0

    1 1 0 1 0 0 0

    1 1 1 0 0 0 0

    !"ift multiple bitsmultiple bits at a time

    Left !"ift

    ig"t !"ift

  • 8/9/2019 Lec13 Shifter

    13/30

    Barrel !"ifter Aesign 5 $u8 (A3

    S2 S1 S0 D3

    D2

    D1

    D0

    0 0 0 3 2 1 0

    0 0 1 3 3 2 1

    0 1 0 3 3 3 2

    0 1 1 3 3 3 3

    1 0 0 3 2 1 0

    1 0 1 2 1 0 0

    1 1 0 1 0 0 0

    1 1 1 0 0 0 0

    4to1 $u8

    00 01 10 11s1

    s0

    00 01 10 11s1s0

    4to1 $u8

    23to31$u8

    23to31

    $u8

    1

    0 A3

    3

    3 2 1 0

    !0

    !1

    !2

    eplicate and c"ange 5iring of t"e t5o 4to1 $u8es for A2# A1 an

  • 8/9/2019 Lec13 Shifter

    14/30

    Barrel !"ifter Aesign lternati)e (1>bit

    23!"ifter

    22!"ifter

    21!"ifter

    20!"ifter

    Leftig"t

    !3

    !2

    !1

    !0

    1>

    1>

    1>

    1>

    (S3 S2 S1 S0) specifes the shit amount in binary(S3 S2 S1 S0) specifes the shit amount in binary

    1>Output NumberOutput Number

    Input NumberInput Number

  • 8/9/2019 Lec13 Shifter

    15/30

    Barrel !"ifter Aesign 5 n$@!,E*

    A3

    A2

    A1

    A0

    3

    !0

    (o !"ift

    !1 !2 !3

    2

    1

    0!3

    !2

    !1

  • 8/9/2019 Lec13 Shifter

    16/30

    333

    Barrel !"ifter Aesign 5 n$@!,E*

    A3

    A2

    A1

    A0

    3

    !0

    (o !"ift

    !1 !2!2 !3

    2

    1

    0!3

    !2!2

    !1

    3

    2

  • 8/9/2019 Lec13 Shifter

    17/30

    Barrel !"ifter Aesign 5 n$@!,E*

    A3

    A2

    A1

    A0

    3

    !0

    (o !"ift

    !1!1 !2 !3

    2

    1

    0!3

    !2

    !1!1

    3

    3

    2

    1

  • 8/9/2019 Lec13 Shifter

    18/30

  • 8/9/2019 Lec13 Shifter

    19/30

  • 8/9/2019 Lec13 Shifter

    20/30

  • 8/9/2019 Lec13 Shifter

    21/30

    4bit D

    a0 b0

    CinCout

    !um

    B

    !u"" #$$er!u"" #$$er

    a0b0

  • 8/9/2019 Lec13 Shifter

    22/30

    Dropagation Aela'

    a0 b0

    D0

    a1 b0

    a0 b1

    0

    D1

    a2 b0

    a1 b1

    a0 b2

    0

    D2

    a3 b0

    a2 b1

    a1 b2

    a0 b3

    0

    D3

    a3 b1

    a2 b2

    a1 b3

    0

    D4

    a3 b2

    a2 b3

    D

    a3 b3

    D>D

    1122

    33

    33

    44

    44

    >>

    >>==

    484Aela' = adders

    =8=Aela' 20 adder

  • 8/9/2019 Lec13 Shifter

    23/30

  • 8/9/2019 Lec13 Shifter

    24/30

    Dropagation Aela' of Carr'!a)e $ultiplier

    a0 b0

    D0

    a3 b1

    a2 b2

    a1 b3

    a3 b2

    a2 b3

    D

    a3 b3

    D

    a1 b0

    a0 b1

    0

    D1

    11

    22

    33 33

    >>

    484

    Aela' > adders

    =8=Aela' 14 adders

    a2 b0

    a1 b1

    a0 b2

    0

    D2

    11

    22

    a3 b0

    a2 b1

    a1 b2

    a0 b3

    0

    D3

    11

    22

    33

    440

    D> D4

  • 8/9/2019 Lec13 Shifter

    25/30

    !igned Binar' $ultipl'

    F"en t"e $ultiplicand is negati)eF"en t"e $ultiplicand is negati)e

    11101 (-3)

    01001 (+9)

    --------------------

    11111101

    00

    11101

    -------------------- 11100101

    $aintain t"e sign bits of t"epartial product

  • 8/9/2019 Lec13 Shifter

    26/30

    !igned Binar' $ultipl'

    F"en t"e $ultiplier is negati)eF"en t"e $ultiplier is negati)e

    01001 (+9)

    11101 (-3)

    --------------------

    01001 01001

    --------------------

    0101101

    01001

    --------------------

    01110101

    10111

    --------------------

    111100101 (-27)

    t t"e last step# 2Gscomplement t"e multiplicandbefore adding

  • 8/9/2019 Lec13 Shifter

    27/30

    !igned Binar' $ultipl'

    F"en bot" t"e $ultiplicand and $ultiplier are negatF"en bot" t"e $ultiplicand and $ultiplier are negat

    10111 (-9)

    11101 (-3)

    --------------------

    1110111 10111

    --------------------

    11010011

    10111

    --------------------

    110001011

    01001

    --------------------

    000011011(+27)

    t t"e last step# 2Gscomplement t"e multiplicandbefore adding

    $aintain t"e sign bits of t"epartial product

  • 8/9/2019 Lec13 Shifter

    28/30

    $ore E8amples (1

    1111 1010 (-6)

    0000 0101 (+5)

    --------------------

    111111 1010

    111110 10

    --------------------

    1110 0010 (-30)

    ssume =bit numbers

  • 8/9/2019 Lec13 Shifter

    29/30

    $ore E8amples (2

    0011 (+3)

    1110 (-2)

    --------------------

    0 0110

    00 11

    --------------------

    01 0010

    110 1

    -------------------- 1010 (-6)

    ssume 4bit numbers

  • 8/9/2019 Lec13 Shifter

    30/30

    $ore E8amples (3

    1111 1100 (-4)

    1110 0000 (-32)

    --------------------

    111111 1000 0000

    11 1111 00

    --------------------

    111 1110 1000 0000

    000 0010 0

    -------------------- 000 0000 1000 0000 (+128)

    ssume =bit numbers