csse132 introduc0on to computer systems
play

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


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

  2. Today: ¡Basic ¡computa0onal ¡structures ¡ ¢ Helpful ¡structures ¡ § Decoder/encoder ¡ § Mul.plexor/demul.plexor ¡ § Sign ¡extender ¡ ¢ ALU ¡ § ALU ¡control ¡ § Zero ¡detector ¡ § Set ¡less ¡than ¡ 2

  3. Decoder/encoder ¡ ¢ Outputs ¡unique ¡signal ¡based ¡on ¡input ¡ § Inputs: ¡state ¡of ¡systems ¡ § Output: ¡unique ¡representa.ve ¡code ¡ § 2 ¡inputs ¡= ¡2 2 ¡outputs ¡ ¢ Encoder ¡reverses ¡the ¡process ¡ EN 0 A EN 1 B EN 2 EN 3 igure 8-22 3

  4. Mul0plexor ¡ ¢ Select ¡single ¡data ¡stream ¡from ¡mul0ple ¡channels ¡ § Mul.ple ¡data ¡inputs ¡ § Single ¡data ¡output ¡ § Control ¡S ¡selects ¡single ¡data ¡stream ¡ 0 7 S 2 S 1 S 0 Y S 2 S 1 S 0 0 0 0 D 0 D 0 0 0 1 D 1 D 1 0 1 0 D 2 D 2 Output 0 1 1 D 3 D 3 Y D 4 1 0 0 D 4 D 5 1 0 1 D 5 D 6 1 1 0 D 6 D 7 1 1 1 D 7 4

  5. Demul0plexor ¡ ¢ Outputs ¡data ¡to ¡one ¡of ¡mul0ple ¡data ¡channels ¡ § Single ¡data ¡input ¡ § Mul.ple ¡data ¡outputs ¡ § Control ¡S ¡selects ¡data ¡output ¡ D 0 S 1 S 1 S 0 Data D 0 D 1 D 2 D 3 0 0 0 0 0 0 0 0 0 1 1 0 0 0 D 1 0 1 0 0 0 0 0 S 0 0 1 1 0 1 0 0 1 0 0 0 0 0 0 D 2 1 0 1 0 0 1 0 1 1 0 0 0 0 0 1 1 1 0 0 0 1 D 3 Data 5

  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? ¡ 6

  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 ¡ 7

  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 ¡ 8

  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 ¡ 9

  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 a 0 Result 1 b 10

  11. 1 ¡bit ¡ALU ¡ ¢ Add ¡in ¡ADD ¡ § We’ll ¡use ¡a ¡full ¡adder ¡ § Inputs ¡A, ¡B, ¡C in ¡ § Outputs ¡S, ¡C out ¡ § S ¡= ¡AB’C in ’+A’BC in ’+A’B’C in +ABC in ¡ § C out ¡= ¡AB+BC in +AC in ¡ 11

  12. 1 ¡bit ¡ALU ¡ ¢ Add ¡in ¡ADD ¡ § We’ll ¡use ¡a ¡full ¡adder ¡ § Inputs ¡A, ¡B, ¡C in ¡ § Outputs ¡S, ¡C out ¡ Operation § S ¡= ¡AB’C in ’+A’BC in ’+A’B’C in +ABC in ¡ CarryIn § C out ¡= ¡AB+BC in +AC in ¡ a 0 ¢ Need ¡to ¡expand ¡mux ¡ 1 Result 2 1 b CarryOut 12

  13. Wider ¡ALU ¡ ¢ Can ¡link ¡1 ¡bit ¡ALUs ¡together ¡to ¡form ¡large ¡ALU ¡ § 32 ¡bit ¡example ¡ Operation CarryIn CarryIn a0 ALU0 Result0 b0 CarryOut CarryIn a1 ALU1 Result1 b1 CarryOut CarryIn a2 ALU2 Result2 b2 CarryOut . . . . . . . . . CarryIn a31 ALU31 Result31 b31 13

  14. Subtract ¡ ¢ Given ¡that ¡1 ¡bit ¡ALUs ¡form ¡larger ¡ALUs, ¡implement ¡ subtract ¡ Operation § Remember ¡Two’s ¡complement! ¡ CarryIn § -­‑x ¡= ¡(~x)+1 ¡ ¢ What ¡do ¡we ¡need? ¡ CarryIn a0 ALU0 Result0 b0 CarryOut CarryIn a1 Operation ALU1 Result1 CarryIn b1 CarryOut a 0 CarryIn a2 ALU2 Result2 b2 CarryOut 1 Result . . . . . . . . . 2 1 b CarryIn a31 ALU31 Result31 b31 CarryOut 14

  15. Subtract ¡ ¢ Given ¡that ¡1 ¡bit ¡ALUs ¡form ¡larger ¡ALUs, ¡implement ¡ subtract ¡ Operation § Remember ¡Two’s ¡complement! ¡ CarryIn § -­‑x ¡= ¡(~x)+1 ¡ ¢ What ¡do ¡we ¡need? ¡ CarryIn a0 ALU0 Result0 b0 § Invert ¡B ¡or ¡A ¡ CarryOut § Add ¡1 ¡to ¡LSB ¡ CarryIn a1 Operation ALU1 Result1 CarryIn b1 CarryOut a 0 CarryIn a2 ALU2 Result2 b2 CarryOut 1 Result . . . . . . . . . 2 1 b CarryIn a31 ALU31 Result31 b31 CarryOut 15

  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 Operation CarryIn a 0 1 Result b 0 2 1 1 CarryOut 16

  17. Subtract ¡ ¢ Add ¡1 ¡to ¡LSB ¡ § If ¡opera.on ¡is ¡subtract ¡ Operation § Set ¡LSB ¡carry ¡in ¡to ¡1 ¡ CarryIn § Set ¡ALU ¡op ¡to ¡+ ¡ CarryIn a0 ALU0 Result0 b0 ¢ This ¡incredible ¡convenience ¡is ¡ CarryOut why ¡most ¡computers ¡use ¡ CarryIn a1 two’s ¡complement ¡ ALU1 Result1 b1 CarryOut CarryIn a2 ALU2 Result2 b2 CarryOut . . . . . . . . . CarryIn a31 ALU31 Result31 b31 17

  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 ¡ 18

  19. Other ¡opera0ons ¡ ¢ Could ¡add ¡more ¡opera0ons ¡ § NOR ¡(invert ¡A) ¡ § ShiMing ¡(special ¡hardware) ¡ § Many ¡others… ¡ ALU ¡with ¡NOR ¡support ¡ Ainvert Operation Binvert CarryIn a 0 0 1 1 Result b 0 2 � 1 CarryOut 19

  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 ¡ 20

  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 ¡ 21

  22. Operation Ainvert Binvert CarryIn Set ¡less ¡than ¡ a 0 0 1 1 ¢ If ¡A ¡< ¡B ¡ Result b 0 2 � § R ¡= ¡0x00…01 ¡ 1 Less 3 ¢ If ¡not ¡A ¡< ¡B ¡(i.e. ¡A ¡>= ¡B) ¡ § R ¡= ¡0x00….00 ¡ CarryOut ¢ How ¡to ¡do ¡this? ¡ Operation Ainvert Binvert CarryIn § Add ¡new ¡input ¡‘less’ ¡ a 0 0 § Can ¡0 ¡to ¡result ¡mux ¡ 1 1 § Add ¡new ¡output ¡‘set’ ¡to ¡MSB ¡ALU ¡ Result b 0 § Output ¡MSB ¡result ¡ 2 � 1 § Use ¡later ¡ Less 3 Set Overflow Overflow detection 22

  23. Set ¡less ¡than ¡ Operation Binvert Ainvert CarryIn ¢ If ¡A ¡< ¡B ¡ a0 CarryIn Result0 § R ¡= ¡0x00…01 ¡ b0 ALU0 Less ¢ If ¡not ¡A ¡< ¡B ¡(i.e. ¡A ¡>= ¡B) ¡ CarryOut § R ¡= ¡0x00….00 ¡ a1 CarryIn Result1 b1 ALU1 0 Less ¢ How ¡to ¡do ¡this? ¡ CarryOut § Set ¡ALUs ¡to ¡subtract ¡ a2 CarryIn Result2 § MSB ¡‘set’ ¡is ¡now ¡sign ¡bit ¡ b2 ALU2 0 Less § Pass ¡MSB ¡‘set’ ¡to ¡LSB ¡‘less’ ¡ CarryOut § Set ¡all ¡other ¡‘less’ ¡to ¡0 ¡ . . . . . . . . . . . . . . . . CarryIn . . CarryIn Result31 a31 Set b31 ALU31 0 Less Overflow 23

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend