CSSE132 Introduc0on to Computer Systems 11 : Basic - - PowerPoint PPT Presentation

csse132 introduc0on to computer systems
SMART_READER_LITE
LIVE PREVIEW

CSSE132 Introduc0on to Computer Systems 11 : Basic - - PowerPoint PPT Presentation

CSSE132 Introduc0on to Computer Systems 11 : Basic computa.onal structures March 20, 2013 1 Today: Basic computa0onal structures Helpful structures


slide-1
SLIDE 1

1

CSSE132 ¡ Introduc0on ¡to ¡Computer ¡Systems ¡

11 ¡: ¡Basic ¡computa.onal ¡structures ¡ March ¡20, ¡2013 ¡

slide-2
SLIDE 2

2

Today: ¡Basic ¡computa0onal ¡structures ¡

¢ Helpful ¡structures ¡

§ Decoder/encoder ¡ § Mul.plexor/demul.plexor ¡ § Sign ¡extender ¡

¢ ALU ¡

§ ALU ¡control ¡ § Zero ¡detector ¡ § Set ¡less ¡than ¡

slide-3
SLIDE 3

3

Decoder/encoder ¡

¢ Outputs ¡unique ¡signal ¡based ¡on ¡input ¡

§ Inputs: ¡state ¡of ¡systems ¡ § Output: ¡unique ¡representa.ve ¡code ¡ § 2 ¡inputs ¡= ¡22 ¡outputs ¡

¢ Encoder ¡reverses ¡the ¡process ¡

igure 8-22 A B EN0 EN1 EN2 EN3

slide-4
SLIDE 4

4

Mul0plexor ¡

¢ Select ¡single ¡data ¡stream ¡from ¡mul0ple ¡channels ¡

§ Mul.ple ¡data ¡inputs ¡ § Single ¡data ¡output ¡ § Control ¡S ¡selects ¡single ¡data ¡stream ¡

7

S2 S1 S0 D0 D1 D2 D3 Y D4 D5 D6 D7

Output

S2 S1 S0 Y D0 1 D1 1 D2 1 1 D3 1 D4 1 1 D5 1 1 D6 1 1 1 D7

slide-5
SLIDE 5

5

Demul0plexor ¡

¢ Outputs ¡data ¡to ¡one ¡of ¡mul0ple ¡data ¡channels ¡

§ Single ¡data ¡input ¡ § Mul.ple ¡data ¡outputs ¡ § Control ¡S ¡selects ¡data ¡output ¡

S1 S0 D0 D1 D2 D3 Data

S1 S0 Data D0 D1 D2 D3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

slide-6
SLIDE 6

6

Sign ¡extender ¡

¢ CPUs ¡work ¡with ¡signed ¡numbers ¡

§ Word ¡size ¡or ¡smaller ¡ § OMen ¡need ¡to ¡convert ¡to ¡word ¡size ¡

¢ Need ¡to ¡duplicate ¡(extend) ¡sign ¡bit ¡

§ Preserves ¡original ¡number ¡in ¡larger ¡container ¡

¢ How ¡to ¡do ¡this? ¡

slide-7
SLIDE 7

7

Sign ¡extender ¡

¢ CPUs ¡work ¡with ¡signed ¡numbers ¡

§ Word ¡size ¡or ¡smaller ¡ § OMen ¡need ¡to ¡convert ¡to ¡word ¡size ¡

¢ Need ¡to ¡duplicate ¡(extend) ¡sign ¡bit ¡

§ Preserves ¡original ¡number ¡in ¡larger ¡container ¡

¢ How ¡to ¡do ¡this? ¡

§ Just ¡connect ¡MSB ¡input ¡to ¡sign ¡extend ¡bits! ¡ § Only ¡need ¡wires ¡

slide-8
SLIDE 8

8

ALU ¡

¢ Arithme0c ¡Logic ¡Unit ¡

§ Responsible ¡for ¡all ¡computa.ons ¡in ¡computer ¡ § Supported ¡opera.ons ¡

§ AND ¡ § OR ¡ § Add ¡ § Subtract ¡ § Is ¡less ¡than ¡ § Is ¡equal ¡ § Others: ¡NOT, ¡NOR, ¡NAND… ¡

§ Design ¡is ¡similar ¡to ¡adder ¡

§ Start ¡with ¡1 ¡bit ¡ALU, ¡expand ¡

slide-9
SLIDE 9

9

1 ¡bit ¡ALU ¡

¢ Start ¡with ¡AND ¡and ¡OR ¡opera0ons ¡

§ Inputs ¡A ¡and ¡B ¡ § Select ¡opera.on ¡by ¡control ¡signal ¡OP ¡ § Single ¡output ¡R ¡

¢ Hint: ¡a ¡mul0plexor ¡will ¡help! ¡

§ Op ¡0 ¡= ¡AND ¡ § Op ¡1 ¡= ¡OR ¡

slide-10
SLIDE 10

10

1 ¡bit ¡ALU ¡

¢ Start ¡with ¡AND ¡and ¡OR ¡opera0ons ¡

§ Inputs ¡A ¡and ¡B ¡ § Select ¡opera.on ¡by ¡control ¡signal ¡OP ¡ § Single ¡output ¡R ¡

Operation 1 Result a b

slide-11
SLIDE 11

11

1 ¡bit ¡ALU ¡

¢ Add ¡in ¡ADD ¡

§ We’ll ¡use ¡a ¡full ¡adder ¡ § Inputs ¡A, ¡B, ¡Cin ¡ § Outputs ¡S, ¡Cout ¡ § S ¡= ¡AB’Cin’+A’BCin’+A’B’Cin+ABCin ¡ § Cout ¡= ¡AB+BCin+ACin ¡

slide-12
SLIDE 12

12

1 ¡bit ¡ALU ¡

¢ Add ¡in ¡ADD ¡

§ We’ll ¡use ¡a ¡full ¡adder ¡ § Inputs ¡A, ¡B, ¡Cin ¡ § Outputs ¡S, ¡Cout ¡ § S ¡= ¡AB’Cin’+A’BCin’+A’B’Cin+ABCin ¡ § Cout ¡= ¡AB+BCin+ACin ¡

¢ Need ¡to ¡expand ¡mux ¡

a b CarryIn CarryOut Operation 1 2 1 Result

slide-13
SLIDE 13

13

Wider ¡ALU ¡

¢ Can ¡link ¡1 ¡bit ¡ALUs ¡together ¡to ¡form ¡large ¡ALU ¡

§ 32 ¡bit ¡example ¡

a0 Operation CarryIn ALU0 CarryOut b0 CarryIn a1 CarryIn ALU1 CarryOut b1 Result0 Result1 a2 CarryIn ALU2 CarryOut b2 a31 CarryIn ALU31 b31 Result2 Result31 . . . . . . . . .

slide-14
SLIDE 14

14

Subtract ¡

¢ Given ¡that ¡1 ¡bit ¡ALUs ¡form ¡larger ¡ALUs, ¡implement ¡

subtract ¡

§ Remember ¡Two’s ¡complement! ¡

§ -­‑x ¡= ¡(~x)+1 ¡

¢ What ¡do ¡we ¡need? ¡

a0 Operation CarryIn ALU0 CarryOut b0 CarryIn a1 CarryIn ALU1 CarryOut b1 Result0 Result1 a2 CarryIn ALU2 CarryOut b2 a31 CarryIn ALU31 b31 Result2 Result31 . . . . . . . . . a b CarryIn CarryOut Operation 1 2 1 Result

slide-15
SLIDE 15

15

Subtract ¡

¢ Given ¡that ¡1 ¡bit ¡ALUs ¡form ¡larger ¡ALUs, ¡implement ¡

subtract ¡

§ Remember ¡Two’s ¡complement! ¡

§ -­‑x ¡= ¡(~x)+1 ¡

¢ What ¡do ¡we ¡need? ¡

§ Invert ¡B ¡or ¡A ¡ § Add ¡1 ¡to ¡LSB ¡

a0 Operation CarryIn ALU0 CarryOut b0 CarryIn a1 CarryIn ALU1 CarryOut b1 Result0 Result1 a2 CarryIn ALU2 CarryOut b2 a31 CarryIn ALU31 b31 Result2 Result31 . . . . . . . . . a b CarryIn CarryOut Operation 1 2 1 Result

slide-16
SLIDE 16

16

Subtract ¡

¢ Invert ¡B ¡

§ S.ll ¡need ¡to ¡use ¡adder, ¡so ¡don’t ¡expand ¡mux ¡(keep ¡using ¡+ ¡op) ¡ § Add ¡control ¡line ¡to ¡select ¡inverted ¡B ¡

Binvert a b CarryIn CarryOut Operation 1 2 1 Result 1

slide-17
SLIDE 17

17

Subtract ¡

¢ Add ¡1 ¡to ¡LSB ¡

§ If ¡opera.on ¡is ¡subtract ¡

§ Set ¡LSB ¡carry ¡in ¡to ¡1 ¡ § Set ¡ALU ¡op ¡to ¡+ ¡

¢ This ¡incredible ¡convenience ¡is ¡

why ¡most ¡computers ¡use ¡ two’s ¡complement ¡

a0 Operation CarryIn ALU0 CarryOut b0 CarryIn a1 CarryIn ALU1 CarryOut b1 Result0 Result1 a2 CarryIn ALU2 CarryOut b2 a31 CarryIn ALU31 b31 Result2 Result31 . . . . . . . . .

slide-18
SLIDE 18

18

Equal ¡

¢ Add ¡1bit ¡‘zero’ ¡output ¡to ¡ALU ¡

§ Set ¡to ¡1 ¡when ¡A ¡and ¡B ¡are ¡equal ¡

¢ How ¡to ¡do? ¡

§ Subtract ¡A ¡and ¡B ¡ § If ¡all ¡bits ¡are ¡0, ¡must ¡be ¡equal! ¡ § OR ¡all ¡bits ¡ § Invert ¡result ¡

slide-19
SLIDE 19

19

Other ¡opera0ons ¡

¢ Could ¡add ¡more ¡opera0ons ¡

§ NOR ¡(invert ¡A) ¡ § ShiMing ¡(special ¡hardware) ¡ § Many ¡others… ¡

Binvert a b CarryIn CarryOut Operation 1 2

  • Result

1 Ainvert 1

ALU ¡with ¡NOR ¡support ¡

slide-20
SLIDE 20

20

Set ¡less ¡than ¡

¢ If ¡A ¡< ¡B ¡

§ R ¡= ¡0x00…01 ¡

¢ If ¡not ¡A ¡< ¡B ¡(i.e. ¡A ¡>= ¡B) ¡

§ R ¡= ¡0x00….00 ¡

¢ How ¡to ¡do ¡this? ¡

§ Subtract ¡is ¡useful ¡ § Sign-­‑bit ¡(MSB) ¡is ¡useful ¡ § Need ¡to ¡expand ¡mux ¡for ¡new ¡opera.on ¡

slide-21
SLIDE 21

21

Set ¡less ¡than ¡

¢ If ¡A ¡< ¡B ¡

§ R ¡= ¡0x00…01 ¡

¢ If ¡not ¡A ¡< ¡B ¡(i.e. ¡A ¡>= ¡B) ¡

§ R ¡= ¡0x00….00 ¡

¢ How ¡to ¡do ¡this? ¡

§ Set ¡LSB ¡to ¡MSB ¡(sign ¡bit) ¡ § Output ¡0 ¡for ¡all ¡other ¡bits ¡

slide-22
SLIDE 22

22

Set ¡less ¡than ¡

¢ If ¡A ¡< ¡B ¡

§ R ¡= ¡0x00…01 ¡

¢ If ¡not ¡A ¡< ¡B ¡(i.e. ¡A ¡>= ¡B) ¡

§ R ¡= ¡0x00….00 ¡

¢ How ¡to ¡do ¡this? ¡

§ Add ¡new ¡input ¡‘less’ ¡

§ Can ¡0 ¡to ¡result ¡mux ¡

§ Add ¡new ¡output ¡‘set’ ¡to ¡MSB ¡ALU ¡

§ Output ¡MSB ¡result ¡ § Use ¡later ¡

Binvert a b CarryIn CarryOut Operation 1 2

  • Result

1 Ainvert 1 3 Less Binvert a b CarryIn Operation 1 2

  • Result

1 3 Less Overflow detection Set Overflow Ainvert 1

slide-23
SLIDE 23

23

Set ¡less ¡than ¡

¢ If ¡A ¡< ¡B ¡

§ R ¡= ¡0x00…01 ¡

¢ If ¡not ¡A ¡< ¡B ¡(i.e. ¡A ¡>= ¡B) ¡

§ R ¡= ¡0x00….00 ¡

¢ How ¡to ¡do ¡this? ¡

§ Set ¡ALUs ¡to ¡subtract ¡

§ MSB ¡‘set’ ¡is ¡now ¡sign ¡bit ¡

§ Pass ¡MSB ¡‘set’ ¡to ¡LSB ¡‘less’ ¡ § Set ¡all ¡other ¡‘less’ ¡to ¡0 ¡

. . . a0 Operation CarryIn ALU0 Less CarryOut b0 CarryIn a1 CarryIn ALU1 Less CarryOut b1 Result0 Result1 a2 CarryIn ALU2 Less CarryOut b2 a31 CarryIn ALU31 Less b31 Result2 Result31 . . . . . . . . . Binvert . . . Ainvert Overflow . . . Set CarryIn

slide-24
SLIDE 24

24

Set ¡less ¡than ¡

¢ If ¡A ¡< ¡B ¡

§ R ¡= ¡0x00…01 ¡

¢ If ¡not ¡A ¡< ¡B ¡(i.e. ¡A ¡>= ¡B) ¡

§ R ¡= ¡0x00….00 ¡

¢ Result ¡

§ Subtract ¡results ¡in ¡< ¡0 ¡

§ Sign ¡bit ¡of ¡1 ¡is ¡sent ¡to ¡LSB ¡

§ Subtract ¡results ¡in ¡>= ¡0 ¡

§ Sign ¡bit ¡of ¡0 ¡is ¡sent ¡to ¡LSB ¡

§ All ¡other ¡bits ¡set ¡to ¡0 ¡

. . . a0 Operation CarryIn ALU0 Less CarryOut b0 CarryIn a1 CarryIn ALU1 Less CarryOut b1 Result0 Result1 a2 CarryIn ALU2 Less CarryOut b2 a31 CarryIn ALU31 Less b31 Result2 Result31 . . . . . . . . . Binvert . . . Ainvert Overflow . . . Set CarryIn