1 / 20

Logical (or “bitwise”) Operations

Logical (or “bitwise”) Operations. Manipulating bits within words SHIFT AND OR. Logical (or “bitwise”) Operations SHIFT. Moving bits within word to left or right In C: << or >> operators Example: 0000 0000 0000 0000 0110 1111 0000 0000 two shifted left by eight, equals:

timberly
Download Presentation

Logical (or “bitwise”) Operations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Logical (or “bitwise”) Operations • Manipulating bits within words • SHIFT • AND • OR Ch.4 - Computer Arithmetic - II

  2. Logical (or “bitwise”) OperationsSHIFT • Moving bits within word to left or right • In C: << or >> operators • Example:0000 0000 0000 0000 0110 1111 0000 0000twoshifted left by eight, equals: 0000 0000 0110 1111 0000 0000 0000 0000two Ch.4 - Computer Arithmetic - II

  3. Machine Instruction Format (R) op – basic operation (opcode) rs – first register source operand [0-31] rt – second register source operand [0-31] rd – register destination operand [0-31] shamt – shift amount funct – function Ch.4 - Computer Arithmetic - II

  4. MIPS Instructions (Logical)(so far…) Ch.4 - Computer Arithmetic - II

  5. Logical (or “bitwise”) OperationsAND and OR • Bitwise logical “AND” and “OR” • In C: & and | operators • Examples:0110 1100two • 1100 0000two = 0100 0000two 0110 1100two + 1100 0000two = 1110 1100two Ch.4 - Computer Arithmetic - II

  6. Logical AND and OR AND OR a c b a c b Ch.4 - Computer Arithmetic - II

  7. MIPS Instructions (Logical)(so far…) Ch.4 - Computer Arithmetic - II

  8. Logical NOT and Multiplexor NOT Multiplexor (if d==0, c=a;else c=b) a c d a c b Ch.4 - Computer Arithmetic - II

  9. Arithmetic Logic Unit (ALU) • Part of CPU • Device implementing arithmetic (ADD, SUB) and logical (AND, OR) operations • Built out of logic (AND, OR, NOT) gates and multiplexors* * - multiplexors are themselves built out of logic gates Ch.4 - Computer Arithmetic - II

  10. The 32-bit ALU • Built out of 32 1-bit ALUs • 1-bit ALU • supports 1-bit AND, OR, NOT, ADD Ch.4 - Computer Arithmetic - II

  11. 1-bit AND/OR operation a result b Ch.4 - Computer Arithmetic - II

  12. 1-bit ADD CarryIn + a Sum b CarryOut Ch.4 - Computer Arithmetic - II

  13. 1-bit ADD Ch.4 - Computer Arithmetic - II

  14. 1-bit ADDCalculating CarryOut Logically CarryOut = (b • CarryIn) + (a • CarryIn) + (a • b) + (a • b • CarryIn) Ch.4 - Computer Arithmetic - II

  15. 1-bit ADDCalculating CarryOut CarryOut = (b • CarryIn) + (a • CarryIn) + (a • b) Ch.4 - Computer Arithmetic - II

  16. 1-bit ADDCalculating Sum Ch.4 - Computer Arithmetic - II

  17. 1-bit ALU CarryIn operation a 0 result 1 b + 2 CarryOut Ch.4 - Computer Arithmetic - II

  18. The 32-bit ALUPutting it all together… (ripple carry) a0 b0 a1 b1 a2 b2 … How long would this take to run? a31 b31 Ch.4 - Computer Arithmetic - II

  19. 1-bit SUBCalculating SUB from ADD Binvert CarryIn operation a 0 result 1 b + 2 CarryOut Ch.4 - Computer Arithmetic - II

  20. 32-bit SUB • Connect like before • CarryOuti = CarryIni+1 • Binvert also tied to CarryIn on 0th unit Ch.4 - Computer Arithmetic - II

More Related