1 Chapter 4: Arithmetic for Computers (Part 1) CS 447 Jason Bakos.

Slides:



Advertisements
Similar presentations
Arithmetic in Computers Chapter 4 Arithmetic in Computers2 Outline Data representation integers Unsigned integers Signed integers Floating-points.
Advertisements

CSCE 212 Chapter 3: Arithmetic for Computers Instructor: Jason D. Bakos.
Arithmetic CPSC 321 Computer Architecture Andreas Klappenecker.
Arithmetic CPSC 321 Computer Architecture Andreas Klappenecker.
1 Lecture 4: Arithmetic for Computers (Part 3) CS 447 Jason Bakos.
1 Representing Numbers Using Bases Numbers in base 10 are called decimal numbers, they are composed of 10 numerals ( ספרות ) = 9* * *10.
Assembly Language and Computer Architecture Using C++ and Java
Chapter 4: Arithmetic for Computers (Part 1)
Assembly Language and Computer Architecture Using C++ and Java
Lec 17 Nov 2 Chapter 4 – CPU design data path design control logic design single-cycle CPU performance limitations of single cycle CPU multi-cycle CPU.
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
Arithmetic I CPSC 321 Andreas Klappenecker. Administrative Issues Office hours of TA Praveen Bhojwani: M 1:00pm-3:00pm.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
1  1998 Morgan Kaufmann Publishers Chapter Four Arithmetic for Computers.
1 Lecture 4: Arithmetic for Computers (Part 4) CS 447 Jason Bakos.
Chapter 3 Arithmetic for Computers. Arithmetic Where we've been: Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's.
More Basics of CPU Design Lecture for CPSC 5155 Edward Bosworth, Ph.D. Computer Science Department Columbus State University.
Computer Science 210 Computer Organization The Arithmetic Logic Unit.
+ CS 325: CS Hardware and Software Organization and Architecture Exam 1: Study Guide.
CS 105 Digital Logic Design
Arithmetic for Computers
Some material taken from Assembly Language for x86 Processors by Kip Irvine © Pearson Education, 2010 Slides revised 2/2/2014 by Patrick Kelley.
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
CMPE 325 Computer Architecture II Cem Ergün Eastern Mediterranean University Integer Representation and the ALU.
1 CHAPTER 4: PART I ARITHMETIC FOR COMPUTERS. 2 The MIPS ALU We’ll be working with the MIPS instruction set architecture –similar to other architectures.
1 CS/COE0447 Computer Organization & Assembly Language Chapter 3.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Logic Circuits I.
Machine Instruction Characteristics
COMPUTER ORGANIZATIONS CSNB123 May 2014Systems and Networking1.
Topic: Arithmetic Circuits Course: Digital Systems Slide no. 1 Chapter # 5: Arithmetic Circuits.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Logic Circuits I.
ECEN 248 Lab 4: Multiplexer Based Arithmetic Logic Unit
CS Data representation 1 Ch. 2.1 Data Representation Unsigned and Signed Integers – representation, addition, subtraction.
DIGITAL CIRCUITS David Kauchak CS52 – Fall 2015.
Arithmetic Logic Unit (ALU) Anna Kurek CS 147 Spring 2008.
CDA 3101 Fall 2013 Introduction to Computer Organization The Arithmetic Logic Unit (ALU) and MIPS ALU Support 20 September 2013.
ECE 445 – Computer Organization
1 Arithmetic I Instructor: Mozafar Bag-Mohammadi Ilam University.
Computer Arithmetic See Stallings Chapter 9 Sep 10, 2009
1 Lecture 10: Floating Point, Digital Design Today’s topics:  FP arithmetic  Intro to Boolean functions.
Monday, January 14 Homework #1 is posted on the website Homework #1 is posted on the website Due before class, Jan. 16 Due before class, Jan. 16.
1. Building A CPU  We’ve built a small ALU l Add, Subtract, SLT, And, Or l Could figure out Multiply and Divide  What about the rest l How do.
Logic Design / Processor and Control Units Tony Diep.
1 ELEN 033 Lecture 4 Chapter 4 of Text (COD2E) Chapters 3 and 4 of Goodman and Miller book.
Addition, Subtraction, Logic Operations and ALU Design
What is a program? A sequence of steps
CPU Overview Computer Organization II 1 February 2009 © McQuain & Ribbens Introduction CPU performance factors – Instruction count n Determined.
CMPUT Computer Organization and Architecture I1 CMPUT229 - Fall 2003 Topic6: Logic, Multiply and Divide Operations José Nelson Amaral.
CS 3843 Computer Organization Prof. Qi Tian Fall 2013
Computer Arthmetic Chapter Four P&H. Data Representation Why do we not encode numbers as strings of ASCII digits inside computers? What is overflow when.
9/23/2004Comp 120 Fall September Chapter 4 – Arithmetic and its implementation Assignments 5,6 and 7 posted to the class web page.
1 CPTR 220 Computer Organization Computer Architecture Assembly Programming.
Invitation to Computer Science, C++ Version, Fourth Edition
CHAPTER 9 COMPUTER ARITHMETIC - ALU
Introduction CPU performance factors
Morgan Kaufmann Publishers
Lecture 10: Floating Point, Digital Design
CSCE 212 Chapter 5 The Processor: Datapath and Control
Arithmetic Logical Unit
ECEG-3202 Computer Architecture and Organization
ECEG-3202 Computer Architecture and Organization
COMS 361 Computer Organization
ECEG-3202 Computer Architecture and Organization
MIPS Assembly.
Digital Circuits and Logic
Computer Architecture Assembly Language
Presentation transcript:

1 Chapter 4: Arithmetic for Computers (Part 1) CS 447 Jason Bakos

2 Notes on Project 1 There are two different ways the following two words can be stored in a computer memory… –word1.byte0,1,2,3 –word2.half0,1 One way is big-endian, where the word is stored in memory in its original order… –word1: –word2: Another way is little-endian, where the word is stored in memory in reverse order… –word1: –word2: Of course, this affects the way in which the lw instruction works…

3 Notes on Project 1 MIPS uses the endian-style that the architecture underneath it uses –Intel uses little-endian, so we need to deal with that –This affects assignment 1 because the input data is stored as a series of bytes –If you use lw’s on your data set, the values will be loaded into your dest. register in reverse order –Hint: Try the lb/sb instruction This instruction will load/store a byte from an unaligned address and perform the translation for you

4 Notes on Project 1 Hint: Use SPIM’s breakpoint and single- step features to help debug your program –Also, make sure you use the registers and memory/stack displays Hint: You may want to temporarily store your input set into a word array for sorting Make sure you check Appendix A for additional useful instructions that I didn’t cover in class Make sure you comment your code!

5 Goals of Chapter 4 Data representation Hardware mechanisms for performing arithmetic on data Hardware implications on the instruction set design

6 Review of Binary Representation Binary/Hex -> Decimal conversion Decimal -> Binary/Hex conversion Least/Most significant bits Highest representable number/maximum number of unique representable symbols Two’s compliment representation –One’s compliment –Finding signed number ranges (-2 n-1 to 2 n-1 -1) –Doing arithmetic with two’s compliment Sign extending with load half/byte –Unsigned loads Signed/unsigned comparison

7 Binary Addition/Subtraction Binary subtraction works exactly like addition, except the second operand is converted to two’s compliment Overflow in signed arithmetic occurs under the following conditions: OperationOperand AOperand BResult A+BPositive Negative A+BNegative Positive A-BPositiveNegative A-BNegativePositive

8 What Happens When Overflow Occurs? MIPS detects overflow with an exception/interrupt When an interrupt occurs, a branch occurs to code in the kernel at address where special registers (BadVAddr, Status, Cause, and EPC) are used to handle the interrupt SPIM has a simple interrupt handler built-in that deals with interrupts We may come back to interrupts later

9 Review of Shift and Logical Operations MIPS has operations for SLL, SRL, and SRA –We covered this in the last chapter MIPS implements bit-wise AND, OR, and XOR logical operations –These operations perform a bit-by-bit parallel logical operation on two registers –In C, use > for arithmetic shifts, and &, |, ^, and ~ for bitwise and, or, xor, and NOT, respectively

10 Review of Logic Operations The three main parts of a CPU –ALU (Arithmetic and Logic Unit) Performs all logical, arithmetic, and shift operations –CU (Control Unit) Controls the CPU – performs load/store, branch, and instruction fetch –Registers Physical storage locations for data

11 Review of Logic Operations In this chapter, our goal is to learn how the ALU is implemented The ALU is entirely constructed using boolean functions as hardware building blocks –The 3 basic digital logic building blocks can be used to construct any digital logic system: AND, OR, and NOT –These functions can be directly implemented using electric circuits (wires and transistors)

12 Review of Logic Operations These “combinational” logic devices can be assembled to create a much more complex digital logic system ABA AND B ABA OR B Anot A 01 10

13 Review of Logic Operations We need another device to build an ALU… This is called a multiplexor… it implements an if-then-else in hardware ABDC (out) 0000 (a) 0010 (b) 0100 (a) 0111 (b) 1001 (a) 1010 (b) 1101 (a) 1111 (b)

14 A 1-bit ALU Perform logic operations in parellel and mux the output Next, we want to include addition, so let’s build a single-bit adder –Called a full adder

15 Full Adder From the following table, we can construct the circuit for a full adder and link multiple full adders together to form a multi-bit adder –We can also add this input to our ALU –How do we give subtraction ability to our adder? –How do we detect overflow and zero results? InputsOutputsComments ABCarryInCarryOutSum = = = = = = = =11