logical or bitwise operations n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Logical (or “bitwise”) Operations PowerPoint Presentation
Download Presentation
Logical (or “bitwise”) Operations

Loading in 2 Seconds...

play fullscreen
1 / 20

Logical (or “bitwise”) Operations - PowerPoint PPT Presentation


  • 165 Views
  • Uploaded on

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:

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Logical (or “bitwise”) Operations' - timberly


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
logical or bitwise operations
Logical (or “bitwise”) Operations
  • Manipulating bits within words
    • SHIFT
    • AND
    • OR

Ch.4 - Computer Arithmetic - II

logical or bitwise operations shift
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

machine instruction format r
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

mips instructions logical so far
MIPS Instructions (Logical)(so far…)

Ch.4 - Computer Arithmetic - II

logical or bitwise operations and and or
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

logical and and or
Logical AND and OR

AND

OR

a

c

b

a

c

b

Ch.4 - Computer Arithmetic - II

mips instructions logical so far1
MIPS Instructions (Logical)(so far…)

Ch.4 - Computer Arithmetic - II

logical not and multiplexor
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

arithmetic logic unit alu
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

the 32 bit alu
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

1 bit and or
1-bit AND/OR

operation

a

result

b

Ch.4 - Computer Arithmetic - II

1 bit add
1-bit ADD

CarryIn

+

a

Sum

b

CarryOut

Ch.4 - Computer Arithmetic - II

1 bit add1
1-bit ADD

Ch.4 - Computer Arithmetic - II

1 bit add calculating carryout logically
1-bit ADDCalculating CarryOut Logically

CarryOut = (b • CarryIn)

+ (a • CarryIn)

+ (a • b)

+ (a • b • CarryIn)

Ch.4 - Computer Arithmetic - II

1 bit add calculating carryout
1-bit ADDCalculating CarryOut

CarryOut = (b • CarryIn)

+ (a • CarryIn)

+ (a • b)

Ch.4 - Computer Arithmetic - II

1 bit add calculating sum
1-bit ADDCalculating Sum

Ch.4 - Computer Arithmetic - II

1 bit alu
1-bit ALU

CarryIn

operation

a

0

result

1

b

+

2

CarryOut

Ch.4 - Computer Arithmetic - II

the 32 bit alu putting it all together ripple carry
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

1 bit sub calculating sub from add
1-bit SUBCalculating SUB from ADD

Binvert

CarryIn

operation

a

0

result

1

b

+

2

CarryOut

Ch.4 - Computer Arithmetic - II

32 bit sub
32-bit SUB
  • Connect like before
    • CarryOuti = CarryIni+1
  • Binvert also tied to CarryIn on 0th unit

Ch.4 - Computer Arithmetic - II