1240893538 - Overview of Lecture Binary number...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Computer Organization CDA 3103 Dr. Hassan Foroosh Dept. of Computer Science UCF © Copyright Hassan Foroosh 2004 Overview of Lecture ± Binary number representation and 2’s complement ± Addition in 2’s complement ± overflow ± ALU and adder ± full adder ± logical operations ± carry lookahead ± Multiplication Computer System Organization Processor Computer Control Datapath Memory Devices Input Output Arithmetic is here Arithmetic is here Binary Binary Decimal 0 0000 1 0001 2 0010 3 0011 Decimal 4 0100 5 0101 6 0110 7 0111 0011 0010 + 0101 1 + 0110 11 Introduction to Binary Numbers ± Value of digit i (LSB is digit 0) = digit x 2 i ± Addition examples: 3 + 2 = 5 3 + 3 = 6 ± Consider a 4-bit unsigned binary number
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2’s Complement Binary Decimal 0 0000 1 0001 2 0010 3 0011 0000 1111 1110 1101 Decimal 0 -1 -2 -3 Bitwise Inverse 1111 1110 1101 1100 4 0100 5 0101 6 0110 7 0111 1100 1011 1010 1001 -4 -5 -6 -7 1011 1010 1001 1000 1000 -8 0111 8 1000 Not a Positive Number! Two’s Complement Representation ± 2’s complement representation of negative numbers ± Bitwise inverse and add 1 ± MSB is always “1” for negative number => sign bit ± Biggest 4-bit number : 7 (2 n–1 –1) ± Smallest 4-bit number: -8 (–2 n-1 ) Two’s Complement ± Value of number (assuming 32-bits = b 31 b 30 .…b 0 ): -b 31 x 2 31 + b 30 x 2 30 +... +b 1 x 2 1 + b 0 x 2 0 ± 2’s complement ± to negate an n-bit number x : 2 n ± invert all bits and add 1 ± + ~ = -1 (represented by 11…1) => x + ~ 1 = 0 and therefore ~ + 1 = - ± Alternative integer representations ± sign-magnitude: sign bit + absolute value ± 1’s complement: invert each bit ± Disadvantages of alternatives ± +0, –0 ± arithmetic not as simple ± Advantage of alternatives ± max positive = max negative ± Two’s complement is the standard Two’s Complement Arithmetic ± Examples: 7 + (- 6) = 1 3 + (- 5) = -2 2’s Complement Binary Decimal 0 0000 1 0001 2 0010 3 0011 0000 1111 1110 1101 Decimal 0 -1 -2 -3 4 0100 5 0101 6 0110 7 0111 1100 1011 1010 1001 -4 -5 -6 -7 1000 -8 0111 1010 + 0001 1 0011 1011 + 1110 11 1 1 2’s Complement: Subtraction/Overflow ± Subtraction: add 2’s complement 5 – 7 = 5 +(–7) 7 – (–2) = 7 + (– – 2) = 7 + 2 ± Overflow => sum is too large to represent in precision ± Addition overflow ± sign of operands the same, and sign of result differs ± Subtraction overflow: A – B ± sign of operands different, and ± A positive: sign of result negative, or ± A negative: sign of result positive ± Interesting case: 0 – max negative
Background image of page 2
Requirements for MIPS Integer ALU ± ALU = Arithmetic Logical Unit ± implements integer arithmetic (2’s complement) and logical functions ± MIPS instructions (representative subset) ± add, subtract ± AND, OR ± set-less-than ± overflow detection ± Zero detect: useful for branches: ± beq = subtract followed by 0 test ± ALU = basic logic + control ± control actually determines what the ALU does ± Also need multiply, divide, shift (not covered) Functional Specification of the ALU ± ALU Control Lines (ALUop) Function 000 And 001 Or 010 Add 110 Subtract 111 Set-on-less-than ALU N N N A B Result Overflow Zero 3 ALUop COut A One-Bit ALU ± This 1-bit ALU will perform AND, OR, and ADD A B 1-bit Full Adder COut CIn Mux Result Full adder Inputs: Ai, Bi, Carry in Outputs: Sum, Carry out ALUop Select
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 11

1240893538 - Overview of Lecture Binary number...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online