{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# 1240893538 - Overview of Lecture Binary number...

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

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 Binary Binary Decimal 0 0000 1 0001 2 0010 3 0011 Decimal 4 0100 5 0101 6 0110 7 0111 0 0 1 1 0 0 1 0 + 0 1 0 1 1 0 0 1 1 0 0 1 1 + 0 1 1 0 1 1 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

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

View Full Document
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 x invert all bits and add 1 x + ~ x = -1 (represented by 11…1) => x + ~ x + 1 = 0 and therefore ~ x + 1 = - x 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 0 1 1 1 1 0 1 0 + 0 0 0 1 1 0 0 1 1 1 0 1 1 + 1 1 1 0 1 1 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
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 One-Bit Full Adder 3-inputs and 2-outputs Truth Table 1-bit Full Adder COut CIn A B Sum Inputs Outputs Comments A B CIn Sum COut 0 0 0 0 0 0 + 0 + 0 = 00 0 0 1 0 1

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern