Silesian University of Technology as Centre of Modern...

32
Course title: Arithmetic of Digital Systems (ADS) Faculty of Automatic Control, Electronics and Computer Science, Institute of Informatics Field of study: Informatics Stationary first degree studies Silesian University of Technology as Centre of Modern Education Based on Research and Innovations POWR.03.05.00-IP.08-00-PZ1/17 Project co-financed by the European Union under the European Social Fund

Transcript of Silesian University of Technology as Centre of Modern...

Page 1: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Course title: Arithmetic of Digital Systems (ADS)

Faculty of Automatic Control, Electronics and Computer Science,

Institute of Informatics

Field of study: Informatics

Stationary first degree studies

Silesian University of Technology as Centre of Modern Education

Based on Research and Innovations

POWR.03.05.00-IP.08-00-PZ1/17Project co-financed by the European Union under the European Social Fund

Page 2: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

LECTURE 1

3

Page 3: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Introduction: Course Description

• Teaching modes and hours• Semester 1: lecture 15, classes 15

• Method of assessment: tests• References

[1] Stańczyk U., Cyran K., Pochopień B. Theory of logic circuits volume 1 Fundamental issues, Publishers of the Silesian University of Technology, Gliwice 2007[2] Pochopień B. Arytmetyka komputerowa. Akademicka Oficyna Wydawnicza EXIT, Warszawa 2012[3] Pochopień B., Stańczyk U., Wróbel E.: Arytmetyka systemów cyfrowych w teorii i praktyce. Wydanie II poprawione i uzupełnione. Wydawnictwo Politechniki Śląskiej, Gliwice 2012

4

Page 4: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Important Practical Information

• Course instructors• PhD Eng. Urszula Stańczyk• PhD DSc Eng. Bartłomiej Zieliński

• Lecturer• PhD Eng. Urszula Stańczyk• Office hours: room 315• E-mail: [email protected]

• Database• zmitac.aei.polsl.pl• user accounts• access to courses and grades• more detailed information to follow in classes

5

Page 5: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Course Objectives

Getting acquainted with the theory and gaining practical skills in the scope of: principles of the implementation of basic arithmetic operations and methods of arithmetic operations in fixed-point and floating-point arithmetic and their selection, evaluation and application.

6

Page 6: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Discussed topics (1)• Number systems

• Arithmetic operations on single digits in a system with radix R

• Complements in positional number system with radix R

• Representation of numbers with sign

• Representation of numbers in digital systems

• Codes

• BCD numbers – Representation

– Complements

7

Page 7: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Discussed topics (2)• Conversions between positional number systems

with different radixes

• Arithmetic of fixed-point numbers – Binary addition and subtraction

– Binary multiplication and division

– Addition and subtraction for BCD numbers

– Multiplication and division for BCD numbers

• Floating point arithmetic– Addition and subtraction

– Multiplication and division

8

Page 8: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Discussed topics (3)• Fundamental arithmetic circuits

– Adder

– Subtractor

– Comparator

• Parallel and serial circuits

9

Page 9: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Number system• A number – an abstract entity that represents

a count or measurement

• Components of a number system

– Set of arbitrarily established symbols for representing numbers

– Set of rules dictating representation of any number by these symbols

– Set of rules for performing arithmetic operations on numbers

10

Page 10: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Number systems• Symbolic non-positional systems

– The numerical value of a digit is independent on its position within a number

– Example: Roman number system

I, II, III, IV, IX,…

• Weighted positional number systems– The numerical value of a digit is indicated by its

position, as to all specific weights are assigned

– Example: Arabic number system

1, 11, 111, 12, 212,…

11

Page 11: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Positional number system• In a weighted positional number system

(N+M)-positional non-negative number

is represented as:

12

Page 12: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Characteristics of a positional number

system• The maximal value of number A that can be

represented

• The minimal value of non-zero A number

• The number of all different numbers that can be represented in the system

• Absolute error of representation of A

13

Page 13: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Positional systems with positive radix

• The most widely used systems:

– binary

– octal

– decimal

– hexadecimal

– binary-coded decimal (BCD)

14

Page 14: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Representation of integers in systems

with various radixes

15

Page 15: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Arithmetic operations in a number

system with radix R

16

• Four basic operations:

• Addition, subtraction and multiplication on two (N+M)-positional nonnegative numbers

in a number system with radix R can be reduced to these operations on single digits

Page 16: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Arithmetic operations on single digits

in a system with radix R

17

Page 17: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Results of basic operations in binary

system

18

Page 18: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

LECTURE 2

19

Page 19: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Conversion of numbers• Converting a number X represented in a number system

with radix R

into its equivalent form in a number system with radix Smeans finding

• Methods convenient when– R=10 and S≠10– R ≠10 and S=10

• Fraction that is finite in one system can become infinite when we change radix, then we obtain rounding off error

20

Page 20: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Quotient-product method• Two parts of the conversion process

– digits of integer part of the number are found as numerators of fractional remainders obtained from division by S in the system with radix R

• Firstly we divide the integer part , then resulting quotients.

• The division stops when we reach the quotient equal 0.

– digits of fractional part of the number are found as carry digits shifted to the integer part when multiplying by S in the system with radix R

• Firstly we divide the fractional part , then resulting fractions.

• The multiplication stops when we reach the fraction equal 0, or when we find the required number of digits

• Most convenient when R=10 and S≠10

21

Page 21: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Example

22

Page 22: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Direct method• Digits of a number and radix R are

expressed by their equivalents in a number system with radix S as

• Representation of the number is found by performing operations in system with radix S

• Most convenient when R ≠10 and S=10

23

Page 23: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Example

24

For binary number find its decimal equivalent

Page 24: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Tabular version of direct method

25

Page 25: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

2nd version of direct method• Repetitive multiplication by R i and R -i

computationally expensive

• Instead nested calculations can be employed

26

Page 26: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Example

27

For binary number find its decimal equivalent(�)�= 1011.101

Page 27: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Differential method• Conversion by subtracting multiples of powers

of a radix – Firstly from the converted number we subtract the

highest multiple of the highest power of a radix that is not grater than the converted number

– Next we subtract from the obtained difference, and the powers gradually decrease

– The process stops when we reach zero or required accuracy

• Most convenient when R = 10 and S≠ 10

28

Page 28: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Example

29

Page 29: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Conversion between systems with

radix BK

• It is fairly easy to convert numbers between systems for which radixes are equal to powers of the same base

• The simplest case: powers of 2 – binary – 20

– octal – 23

– hexadecimal 24

• Conversions

30

Page 30: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Example

31

Page 31: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

Conversion accuracy• To maintain accuracy through conversion we need

to find the required number of digits in the fractional part K

• Generally an absolute error of representation of A

is

• For systems with radixes R and S

• It is common to use

32

Page 32: Silesian University of Technology as Centre of Modern ...db.zmitac.aei.polsl.pl/wyniki/1/ADS-L1.pdf · Differential method • Conversion by subtracting multiples of powers of a radix

ExampleFor a decimal number with 2 fractional digits (soK10=2) find numbers of fractional digits required to maintain accuracy for the conversions:

decimal-binary, decimal-octal, decimal-hexadecimal

33