Rekenen en rekenschakelingen Ben Bruidegom AMSTEL Instituut FNWI UvA.

Slides:



Advertisements
Similar presentations
Abdullah Said Alkalbani University of Buraimi
Advertisements

- 1 - Using an SMT Solver and Craig Interpolation to Detect and Remove Redundant Linear Constraints in Representations of Non-Convex Polyhedra Christoph.
Register Transfer and Microoperations Part2
Binary Numbers.
Binary Numbers.
Binary Numbers.
8 October 2013Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
15 October 2013Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
1 Floating Point Representation and Arithmetic (see Patterson Chapter 4)
A Simple ALU Binary Logic.
B261 Systems Architecture
CS 105 Tour of the Black Holes of Computing
Monika Gope Lecturer IICT, KUET
Morgan Kaufmann Publishers Arithmetic for Computers
Arithmetic circuits  Binary addition  Binary Subtraction  Unsigned binary numbers  Sign-magnitude numbers  2 ’ S Complement representation  2 ’
Number Systems  binary, octal, and hexadecimal numbers  why used  conversions, including to/from decimal  negative binary numbers  floating point.
Nat 4/5 Computing Science Lesson 1: Binary
Binary Lesson 3 Hexadecimal. Counting to 15 Base Base Base 16 Base Base Base 16 Two Ten (Hex) Two Ten (Hex)
Binary Lesson 3 Hexadecimal. Counting to 15 Base Base Base 16 Base Base Base 16 Two Ten (Hex) Two Ten (Hex)
Digital Logic & Design Lecture No. 3. Number System Conversion Conversion between binary and octal can be carried out by inspection.  Each octal digit.
20 September How Computers Have Affected Society.
14-1 Bard, Gerstlauer, Valvano, Yerraballi EE 319K Introduction to Embedded Systems Lecture 14: Gaming Engines, Coding Style, Floating Point.
Binary and other number bases. Base Ten This is what we are accustomed to. Digits go from 0 – 9 Headings are represented by powers of ten ThousandsHundredsTensOnes=
The Logic of Compound Statements
1 CONSTRUCTING AN ARITHMETIC LOGIC UNIT CHAPTER 4: PART II.
Arithmetic II CPSC 321 E. J. Kim. Today’s Menu Arithmetic-Logic Units Logic Design Revisited Faster Addition Multiplication (if time permits)
1  2004 Morgan Kaufmann Publishers Chapter Three.
Arithmetic II CPSC 321 Andreas Klappenecker. Any Questions?
1 Chapter 4: Arithmetic Where we've been: –Performance (seconds, cycles, instructions) –Abstractions: Instruction Set Architecture Assembly Language and.
Computer ArchitectureFall 2008 © August 25, CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (1)
Chapter Four Arithmetic and Logic Unit
Arithmetic-Logic Units CPSC 321 Computer Architecture Andreas Klappenecker.
1 ECE369 Chapter 3. 2 ECE369 Multiplication More complicated than addition –Accomplished via shifting and addition More time and more area.
ECE 301 – Digital Electronics
1  1998 Morgan Kaufmann Publishers Chapter Four Arithmetic for Computers.
Chapter 3 Arithmetic for Computers. Arithmetic Where we've been: Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's.
1 Bits are just bits (no inherent meaning) — conventions define relationship between bits and numbers Binary numbers (base 2)
Binary Arithmetic Stephen Boyd March 14, Two's Complement Most significant bit represents sign. 0 = positive 1 = negative Positive numbers behave.
1 Modified from  Modified from 1998 Morgan Kaufmann Publishers Chapter Three: Arithmetic for Computers citation and following credit line is included:
EGRE 426 Fall 09 Chapter Three
Chapter 6-1 ALU, Adder and Subtractor
07/19/2005 Arithmetic / Logic Unit – ALU Design Presentation F CSE : Introduction to Computer Architecture Slides by Gojko Babić.
1 EGRE 426 Fall 08 Chapter Three. 2 Arithmetic What's up ahead: –Implementing the Architecture 32 operation result a b ALU.
1  1998 Morgan Kaufmann Publishers Arithmetic Where we've been: –Performance (seconds, cycles, instructions) –Abstractions: Instruction Set Architecture.
Csci 136 Computer Architecture II – Constructing An Arithmetic Logic Unit Xiuzhen Cheng
Computing Systems Designing a basic ALU.
1 Lecture 6 BOOLEAN ALGEBRA and GATES Building a 32 bit processor PH 3: B.1-B.5.
CDA 3101 Fall 2013 Introduction to Computer Organization The Arithmetic Logic Unit (ALU) and MIPS ALU Support 20 September 2013.
1  2004 Morgan Kaufmann Publishers Performance is specific to a particular program/s –Total execution time is a consistent summary of performance For.
1 ELEN 033 Lecture 4 Chapter 4 of Text (COD2E) Chapters 3 and 4 of Goodman and Miller book.
Orange Coast College Business Division Computer Science Department CS 116- Computer Architecture Arithmetic: Part II.
1  2004 Morgan Kaufmann Publishers Lets Build a Processor Almost ready to move into chapter 5 and start building a processor First, let’s review Boolean.
Computer Architecture Lecture Notes Spring 2005 Dr. Michael P. Frank Competency Area 4: Computer Arithmetic.
Addition, Subtraction, Logic Operations and ALU Design
순천향대학교 정보기술공학부 이 상 정 1 3. Arithmetic for Computers.
Prof. Hsien-Hsin Sean Lee
Arithmetic-Logic Units. Logic Gates AND gate OR gate NOT gate.
1 Arithmetic Where we've been: –Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's up ahead: –Implementing the Architecture.
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.
EE204 L03-ALUHina Anwar Khan EE204 Computer Architecture Lecture 03- ALU.
1 CPTR 220 Computer Organization Computer Architecture Assembly Programming.
1 (Based on text: David A. Patterson & John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 3 rd Ed., Morgan Kaufmann,
Computer Arthmetic Chapter Four P&H.
Arithmetic Where we've been:
Arithmetic Logical Unit
October 8 Rules for Programming Assignments ASK QUESTIONS!
Number Representation
Presentation transcript:

Rekenen en rekenschakelingen Ben Bruidegom AMSTEL Instituut FNWI UvA

Rekenen en rekenschakelingen b Binaire code b Hexadecimale code b Optellen b Two’s complement code b Aftrekken b Arithmetic Logic Unit b Sign extension b Look Ahead Carry Generation b Vermenigvuldigen

Decimale code b 235 = 2* * * 10 0 b Grondtal is 10 Binaire code b 101 = 1* * * 2 0 b Grondtal is 2

Binary code

Binary code (Unsigned Integer)

8 bit = … = …. Range: 0.. n = 8 Range 0 … n = 16 Range 0 … 2 = 32 Range 0.. Unsigned Integer

8 bit = = Range: 0.. n = 8 Range 0.. n = 16 Range 0.. n = 32 Range 0.. Unsigned Integer

8 bit = = 135 Range: 0.. n = 8 Range 0.. n = 16 Range 0.. n = 32 Range 0.. Unsigned Integer

8 bit = = 135 Range: 0.. n = 8 Range (256 –1) n = 16 Range 0.. n = 32 Range 0.. Unsigned Integer

8 bit = = 135 Range: 0.. n = 8 Range n = 16 Range n = 32 Range 0.. Unsigned Integer

8 bit = = 135 Range: 0.. n = 8 Range n = 16 Range n = 32 Range Unsigned Integer

Hexadecimale code b Verkorte schrijfwijze binaire code b Grondtal 16

Optellen       GetalDecimaalBinair A B A + B

Optellen GetalDecimaalBinair transport A B A + B onthouden

Optelschakeling GetalDecimaalBinair transport A B A + B Half adder Full adder Sum bit Carry bit

Pauze b PIDAC-practicum opgaven t/m 2.3.6

Negatieve getallen One’s complement code

Negatieve getallen Two’s complement code

Negatieve getallen Hoe genereer ik een negatief getal?

getal complement Two’s complement Controle: = -25

Negatieve getallen

8 bit = = -121 Range: 0.. n = 8 Range – n = 16 Range n = 32 Range – Signed Integer

Overflow in 4 bit systeem antwoord overflow antwoord – = Negeren 4 bit systeem antwoord overflow antwoord = -11

Two’s complement code

Aftrekken

Aftrekken : -3 – (+6) = -3 +(-6) Negeren 4 bit systeem antwoord overflow antwoord = bits inverteren bij optellen

Arithmetic-Logic Unit Carry in i Carry out i

4 bits ALU

Overflow condities: b Boek bladz. 172 b 8 bit systeem b Overflow =

Bitwise operatoren Bitwise AND-operator (&)

Bitwise operatoren: bittest Bitwise AND-operator (&)

Bitwise operatoren: bit-reset Bitwise AND-operator (&)

Opgaven b Opgaven: tot en met b Vervolg college: uur b De hierna behandelde sheets behoren niet tot de stof die voor AI-studenten is bestemd.

Arithmetic Logic Unit 32 operation result a b ALU

b Bits are just bits (no inherent meaning) — conventions define relationship between bits and numbers b Binary numbers (base 2) decimal: n -1 b Of course it gets more complicated: numbers are finite (overflow) fractions and real numbers negative numbers How do we represent negative numbers? i.e., which bit patterns will represent which numbers? Numbers

 32 bit signed numbers: two = 0 ten two = + 1 ten two = + 2 ten two = + 2,147,483,646 ten two = + 2,147,483,647 ten two = – 2,147,483,648 ten two = – 2,147,483,647 ten two = – 2,147,483,646 ten two = – 3 ten two = – 2 ten two = – 1 ten maxint minintMIPS

b Converting n bit numbers into numbers with more than n bits: MIPS 16 bit immediate gets converted to 32 bits for arithmeticMIPS 16 bit immediate gets converted to 32 bits for arithmetic copy the most significant bit (the sign bit) into the other bits > > copy the most significant bit (the sign bit) into the other bits > > "sign extension"

Conclusion b We can build an ALU to support the MIPS instruction set key idea: use multiplexor to select the output we want (fig )key idea: use multiplexor to select the output we want (fig ) we can efficiently perform subtraction using two’s complementwe can efficiently perform subtraction using two’s complement we can replicate a 1-bit ALU to produce a 32-bit ALUwe can replicate a 1-bit ALU to produce a 32-bit ALU b Important points about hardware all of the gates are always workingall of the gates are always working the speed of a gate is affected by the number of inputs to the gate???the speed of a gate is affected by the number of inputs to the gate??? the speed of a circuit is affected by the number of gates in series (on the “critical path” or the “deepest level of logic”)the speed of a circuit is affected by the number of gates in series (on the “critical path” or the “deepest level of logic”) b Our primary focus: comprehension, however, Clever changes to organization can improve performance (similar to using better algorithms in software)Clever changes to organization can improve performance (similar to using better algorithms in software) we’ll look at two examples for addition and multiplicationwe’ll look at two examples for addition and multiplication

b Is there more than one way to do addition? b Is a 32-bit ALU as fast as a 1-bit ALU? two extremes: ripple carry and sum-of-productstwo extremes: ripple carry and sum-of-products c 1 = b 0 c 0 + a 0 c 0 + a 0 b 0 c 2 = b 1 c 1 + a 1 c 1 + a 1 b 1 = = b 1 (b 0 c 0 + a 0 c 0 + a 0 b 0 )+ a 1 (b 0 c 0 + a 0 c 0 + a 0 b 0 )+ a 1 b 1 c 3 = b 2 c 2 + a 2 c 2 + a 2 b 2 c 3 = c 4 = b 3 c 3 + a 3 c 3 + a 3 b 3 c 4 = Not feasible! Why? Problem: ripple carry adder is slow

Can you see the ripple? How could you get rid of it?

b An approach in-between our two extremes b Motivation: If we didn't know the value of carry-in, what could we do? If we didn't know the value of carry-in, what could we do? When would we always generate a carry? g i = a i. b iWhen would we always generate a carry? g i = a i. b i When would we propagate the carry? p i = a i + b iWhen would we propagate the carry? p i = a i + b i b Did we get rid of the ripple? c 1 = a 0.b 0 + b 0 c 0 + a 0 c 0 = a 0.b 0 + c 0 (b 0 +a 0 ) c 1 = g 0 + p 0 c 0 c 2 = g 1 + p 1 c 1 c 2 = g 1 + p 1 (g 0 + p 0 c 0 ) c 3 = g 2 + p 2 c 2 c 3 = c 4 = g 3 + p 3 c 3 c 4 = Feasible! Why? Carry-lookahead adder

b Can’t build a 16 bit adder this way... (too big) b Could use ripple carry of 4-bit CLA adders b Better: use the CLA principle again! Use principle to build bigger adders

b More complicated than addition accomplished via shifting and additionaccomplished via shifting and addition b More time and more area  Let's look at 3 versions based on gradeschool algorithm 0010 (multiplicand) __x_1011 (multiplier) b Negative numbers: convert and multiply there are better techniques, we won’t look at themthere are better techniques, we won’t look at them Multiplication

Multiplication Multiplier