Docsity

Pipelined MIPS Processor - Computer Architecture - Lecture Slides, Slides of Computer Science

Partial preview of the text

Download Pipelined MIPS Processor - Computer Architecture - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

Arithmetic I

CPSC 350

What happened so far?

  • We learned the basics of the MIPS assembly

language

  • We briefly touched upon the translation to

machine language

  • We formulated our goal, namely the

implementation of a MIPS processor.

Welcome to the Future!

The execution of machine instructions can

follow, for example, the steps:

  • Instruction fetch
  • Instruction decode and register read
  • Execute opn. or calculate an address
  • Access operand in data memory
  • Write the result into a register

Pipelined MIPS Processor

We concentrate first on the arithmetic-logic unit

Computer Arithmetic

Unsigned Numbers

  • 32 bits are available
  • Range 0..2 32 -
  • 11012 = 2^3 +2 2 +2 0 = 13 10
  • Upper bound 2 32 –1 = 4,294,967,

Number representations

What signed integer number

representations do you know?

Signed Numbers

  • Sign-magnitude representation
    • MSB represents sign, 31bits for magnitude
  • One’s complement
    • Use 0..2 31 -1 for non-negative range
    • Invert all bits for negative numbers
  • Two’s complement
    • Same as one’s complement except
    • negative numbers are obtained by inverting all bits and adding 1

Two’s Complement

Suppose we want to express -30 as an 8bit integer in two’s complement representation.

30 = 0001 1110 (^2)

Invert the bits to obtain the negative number:

1110 0001 (^2)

Add one:

-30 = 1110 0010 (^2)

Advantages and Disadvantages

  • sign-magnitude representation
  • one’s complement representation
  • two’s complement representation

Two’s complement

  • The unsigned sum of an n-bit number and its

negative yields?

  • Example with 3 bits:
    • (^011 )
    • (^101 )
    • 1000 2 = 2 n^ => negate(x) = 2n-x
  • Explain one’s complement

MIPS 32bit signed numbers

0000 0000 0000 0000 0000 0000 0000 0000two = 0ten 0000 0000 0000 0000 0000 0000 0000 0001two = +1ten 0000 0000 0000 0000 0000 0000 0000 0010two = +2ten ... 0111 1111 1111 1111 1111 1111 1111 1110two = +2,147,483,646ten 0111 1111 1111 1111 1111 1111 1111 1111two = +2,147,483,647ten 1000 0000 0000 0000 0000 0000 0000 0000two = –2,147,483,648ten 1000 0000 0000 0000 0000 0000 0000 0001two = –2,147,483,647ten 1000 0000 0000 0000 0000 0000 0000 0010two = –2,147,483,646ten ... 1111 1111 1111 1111 1111 1111 1111 1101two = –3ten 1111 1111 1111 1111 1111 1111 1111 1110two = –2ten 1111 1111 1111 1111 1111 1111 1111 1111two = –1ten

Conversions

  • Suppose that you have 3bit two’s complement

number

  • Convert into a 6bit two’s complement number
    • 111101 2 = -
  • Replicate most significant bit!

Comparisons

What can go wrong if you accidentally

compare unsigned with signed numbers?