Download presentation

Presentation is loading. Please wait.

Published byFreddie Higbie Modified over 2 years ago

1
Rekenen en rekenschakelingen Ben Bruidegom AMSTEL Instituut FNWI UvA

2
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

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

4
Binary code

5
Binary code (Unsigned Integer)

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

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

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

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

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

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

12
Hexadecimale code b Verkorte schrijfwijze binaire code b Grondtal 16

13

14

15

16

17

18
Optellen GetalDecimaalBinair A B A + B

19
Optellen GetalDecimaalBinair transport A B A + B onthouden

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

21
Pauze b PIDAC-practicum opgaven t/m 2.3.6

22
Negatieve getallen One’s complement code

23
Negatieve getallen Two’s complement code

24
Negatieve getallen Hoe genereer ik een negatief getal?

25
getal complement Two’s complement Controle: = -25

26
Negatieve getallen

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

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

29
Two’s complement code

30
Aftrekken

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

32
Arithmetic-Logic Unit Carry in i Carry out i

33
4 bits ALU

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

35
Bitwise operatoren Bitwise AND-operator (&)

36
Bitwise operatoren: bittest Bitwise AND-operator (&)

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

38
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.

39
Arithmetic Logic Unit 32 operation result a b ALU

40
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

41
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

42
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"

43
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

44
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

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

46
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

47
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

48
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

49
Multiplication Multiplier

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google