Multiplication/division



Benzer belgeler
Arithmetic ve Logical Operations

Ilgili prefixes ler. 2 nin kuvvetleri. 2 nin kuvvetleri

CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION. Prof. Dr. Mehmet Akbaba CME 221 LOGİC CİRCUITS

Unlike analytical solutions, numerical methods have an error range. In addition to this

Floating Point (Kayan Noktalı Sayılar)

Floating Point (Kayan Noktalı Sayılar)

Onluk duzende toplama. Lecture 4. Addition and Subtraction. Onluk tabanda toplama

mikroc Dili ile Mikrodenetleyici Programlama Ders Notları

SAYI SİSTEMLERİ. 1. Sayı Sistemleri. Sayı Sistemlerinde Rakamlar

BBS 514 YAPISAL PROGRAMLAMA (STRUCTURED PROGRAMMING)

BM-311 Bilgisayar Mimarisi

BLM1011 Bilgisayar Bilimlerine Giriş I

4. HAFTA BLM323 SAYISAL ANALİZ. Okt. Yasin ORTAKCI.

Week 5 Examples and Analysis of Algorithms

WEEK 4 BLM323 NUMERIC ANALYSIS. Okt. Yasin ORTAKCI.

80x86 MICROPROCESSOR Instructions

WEEK 11 CME323 NUMERIC ANALYSIS. Lect. Yasin ORTAKCI.

Java: printf() Metodu İle Çıktıyı Biçemleme

Yaz okulunda (2014 3) açılacak olan (Calculus of Fun. of Sev. Var.) dersine kayıtlar aşağıdaki kurallara göre yapılacaktır:

UBE Machine Learning. Kaya Oguz

12. HAFTA BLM323 SAYISAL ANALİZ. Okt. Yasin ORTAKCI.

DÖNEM İÇİ NOT GİRİŞİ KULLANMA KILAVUZU

BBM Discrete Structures: Midterm 2 Date: , Time: 16:00-17:30. Question: Total Points: Score:

BBS 514 YAPISAL PROGRAMLAMA (STRUCTURED PROGRAMMING)

BBM Discrete Structures: Final Exam Date: , Time: 15:00-17:00

Algoritmalar ve Programlama. DERS - 2 Yrd. Doç. Dr. Ahmet SERBES

Quiz:8086 Mikroişlemcisi Mimarisi ve Emirleri

ATILIM UNIVERSITY Department of Computer Engineering

BBS 514 YAPISAL PROGRAMLAMA (STRUCTURED PROGRAMMING)


Spatial locality nin getirdigi avantaji kullanmak

Bölüm 6. Diziler (arrays) Temel kavramlar Tek boyutlu diziler Çok boyutlu diziler

g Na2HPO4.12H2O alınır, 500mL lik balonjojede hacim tamamlanır.

Mikroişlemci ve Yapısı. Mikroişlemciler ve Mikrobilgisayarlar

Yüz Tanımaya Dayalı Uygulamalar. (Özet)

En kucuk calisabilir birime satetement denir Statements semicolon (;) ile sonlanir Yalniz basina ; null statement i ifade eder

NATURAL LANGUAGE PROCESSING

SAYISAL ELEKTRONİK. Ege Ü. Ege MYO Mekatronik Programı

Uygulama, bir öğrencinin dersi bırakıp aynı anda bir arkadaşının dersi almasına engel olacak şekilde kurgulanmıştır. Buna göre:

BBM 231 Yazmaçların Aktarımı Seviyesinde Tasarım! Hacettepe Üniversitesi Bilgisayar Müh. Bölümü

Bu derste! BBM 231 Yazmaçların Aktarımı Seviyesinde Tasarım! Yazmaç Aktarımı Düzeyi! Büyük Sayısal Sistemler! 12/25/12

Logical signals. Active high or asserted logic. Logic threshold, yaklasik 1.4 volts. Read H&P sections B.3, B.4, B.5 Read H&P sections 5.1 and 5.

Yarışma Sınavı A ) 60 B ) 80 C ) 90 D ) 110 E ) 120. A ) 4(x + 2) B ) 2(x + 4) C ) 2 + ( x + 4) D ) 2 x + 4 E ) x + 4

PC is updated PS güncellenir

Formal Diller Ve Otomat Teorisi

MTM 305 MĠKROĠġLEMCĠLER

Selection Sort Insertion Sort

How many sides has the polygon?

OPERATÖRLER Alıştırmalar

Do not open the exam until you are told that you may begin.

C++ Operatörler (Operators)

Eco 338 Economic Policy Week 4 Fiscal Policy- I. Prof. Dr. Murat Yulek Istanbul Ticaret University

MIPS assembler language de branching

Instance Based Learning k-nn. YZM 3226 Makine Öğrenmesi

Engineering Mechanics: Statics in SI Units, 12e. Equilibrium of a Particle

7.Yazmaçlar (Registers), Sayıcılar (Counters)

SPPS. Verileri Düzenleme ve Değiştirme 3 - Data Menüsü. Y. Doç. Dr. İbrahim Turan Nisan 2011

CISC Complex Instruction Set Computers

L2 L= nh. L4 L= nh. C2 C= pf. Term Term1 Num=1 Z=50 Ohm. Term2 Num=2 Z=50 Oh. C3 C= pf S-PARAMETERS

KLASİK ÇARPMA ALGORİTMALARININ DONANIMSAL SİMÜLASYONLARI VE PERFORMANS DEĞERLENDİRİMİ

Keyestudio SHT31 Temperature and Humidity Module / SHT31 Sıcaklık ve Nem Modülü

Lecture 7. Assembler language nedir? Language in 3 seviyesi. Language 3 seviyesi. Nicin onu ogreniriz?


C# Diziler Sınıf metotları Erişim (kullanım hakkı) deyimleri Üyelerin ömrü(geçerlilik süresi) Hata ayıklama (debug) aracı

D-Link DSL 500G için ayarları

Görev Unvanı Alan Üniversite Yıl Prof. Dr. Elek.-Eln Müh. Çukurova Üniversitesi Eylül 2014

ELEKTRONİK ALTERNATİF YAKIT SİSTEMLERİ SAN TİC LTD ŞTİ KE 013-B BENZİN SİMULATÖR ( B TİPİ ) PETROL TANK SIMULATOR ( B TYPE )

A Y I K BOYA SOBA SOBA =? RORO MAYO MAS A A YÖS / TÖBT

Do not open the exam until you are told that you may begin.

C-Serisi PLC İleri Seviye Eğitim

İçindekiler. Glossary

HTML 4. Bölüm. Doç. Dr. İsmail Rakıp Karaş Dersin Course Page:

İstanbul Üniversitesi Elektrik Elektronik Mühendisliği GENEL KAVRAMLAR. Kaynak: C ve Sistem Programcıları Derneği Kurs Notu. Öğr.Gör.Dr.

Arýza Giderme. Troubleshooting

BİL1001 Bilgisayar Bilimlerine Giriş 1

Ozet. Review pointers (in C) Memory Addressing

Giris {\} /\ Suhap SAHIN

Pros and Cons of Pointers. Pointers. Avantajlar. Dezavantajlar

Hem lw hem de sw komutlarının ofseti 16-bitlik işaretli tamsayıdır.

Veri Yapıları ve Algoritmalar dönem

Aşk hayatımızın en güzel şeyi. İşte İngilizce de aşk üzerine söylenmiş çok güzel sözler ve onların çevirileri.

Teknoloji Servisleri; (Technology Services)

Bölüm 2 Matematik Dili

#include <stdio.h> int main(void) { float sayi; float * p; p = &sayi; printf("deger girin:"); scanf("%f", p); printf("girilen deger:%f\n", *p);

Veri Yapıları 2010 Java Programlama Diline Giriş. Doç. Dr. Aybars UĞUR

Is the P/E cycle of MLC really only 3,000 times as its datasheet said?

Lesson 45: -er, more, less Ders 45: -er, more, less

Data Communications. Gazi Üniversitesi Bilgisayar Mühendisliği Bölümü. 5. Analog veri iletimi

Dr. Feza BUZLUCA İstanbul Teknik Üniversitesi Bilgisayar Mühendisliği Bölümü

SAYISAL DEVRELER. İTÜ Bilgisayar Mühendisliği Bölümündeki donanım derslerinin bağlantıları

If you have any issue in outlook mail account like spam mail, mail send or receive issues, mail delivery problem, mail sending too late and.

MODBUS MODBUS MODBUS PROTOKOLÜ

Bit, Byte ve Integer. BIL-304: Bilgisayar Mimarisi. Dersi veren öğretim üyesi: Yrd. Doç. Dr. Fatih Gökçe

Mikroçita. Mikroçita Rapor 2:

Verilog HDL e Giriş Bilg. Yük. Müh. Selçuk BAŞAK

VERILOG. Modüller

BİLGİSAYAR MİMARİSİNDE YENİ YAKLAŞIMLAR DÖNEM PROJESİ

2. SAYI SİSTEMLERİ VE KODLAR

Bilgisayar Bilimlerine Giriş 1

Transkript:

Multiplication/division Oku H&P sections 4.6-4.8 Bir kac integer multiplication algorithm Bir integer division algorithms Floating point math 10/22/2004 Bilgisayar Mimarisi 6.1 10/22/2004 Bilgisayar Mimarisi 6.2 1000 10 1001 10 ----------- 1000 0000 0000 1000 ----------- 100 10 A B ----- C multiplicand m bit multiplier n bit result (m+n) bit 111 Value = 7 in 3 bits 11 Value = 3 in 2 bits --------- 111 111 --------- 10101 Value = 21 in 5 bits 10/22/2004 Bilgisayar Mimarisi 6.3 10/22/2004 Bilgisayar Mimarisi 6.4

multiply version 1 2 3 ------ --- 0110 6 Shift left 64bits Start Multiplier0 = 1 1. Test M ultip lier0 = 0 Multiplier 1a. Add multiplicand to product and place the result in register 2. Shift the register left 1 bit 3. Shift the M ultiplier register right 1 bit First version worked Not surprising.worked in grade school too! Slow; averages 2.5 processing steps per bit Wide; 64-bit adder, 160 bits of data storage 64-bit ALU Multiplier Shift right 32bits N o: < 32 repetitions 32nd repetition? Yes: 32 repetitions Write 64bits Done Control test from H&P, pages 251-2 10/22/2004 Bilgisayar Mimarisi 6.5 10/22/2004 Bilgisayar Mimarisi 6.6 Multiply version 2 Start Shift product right Add only 32 bits Multiplier0 = 1 1. Test Multiplier0 Multiplier0 = 0 Second version better 32 bits 1a. Add multiplicand to the left half of the product and place the result in thelefthalfofthe register 2. Shift the register right 1bit Still slow; averages 2.5 processing steps per bit Narrower; 32-bit adder, 128 bits of data storage 32-bit ALU Multiplier Shift right 32 bits 3. Shift the Multiplier register right 1 bit 32nd repetition? No: < 32 repetitions Shift right Write Control test Yes: 32 repetitions 10/22/2004 64 bits Bilgisayar Mimarisi Done 6.7 10/22/2004 Bilgisayar Mimarisi 6.8

Multiply version 3 Start Baslangicta multiplier product in sag yari tarafinda 32-bit ALU 32 bits 0 =1 1. Test 0 =0 0 1a. Add multiplicand to the left half of the product and place the result in thelefthalfoftheregister 2. Shift the register right 1 bit No: < 32 repetitions 32nd repetition? Yes: 32 repetitions Done Iteration 0 1 2 3 4 Step Initial values 0000 0000 0000 0111 0111 0001 1011 0100 1011 0101 0101 0101 1010 Shift right Control Write test 10/22/2004 64 bits Bilgisayar Mimarisi 6.9 10/22/2004 Bilgisayar Mimarisi 6.10 Iteration 0 1 2 3 4 Step Initial values 0000 1111 0001 1101 0001 1000 1000 1111 0100 1101 0100 1010 Third version best yet Faster; averages 1.5 processing steps per bit Width same as version 2; 32-bit adder, 128 bits of data storage Simpler; only one register requires shifting 10/22/2004 Bilgisayar Mimarisi 6.11 10/22/2004 Bilgisayar Mimarisi 6.12

Booth s algorithm for int multiply Shift isleminin add isleminden hizli oldugu durumda degerlilik kazanir Gunumuzde adder lar hizli oldugu icin bu algorithm onemini yitirdi Booth s algorithm 3. Multiply versiyonuna benzer Multiplier result in sag 32 bitinde Multiplier yine shift right islemine tabi. 3. Version daki bazi durumlarda add islemlerinden kurtulundu 10/22/2004 Bilgisayar Mimarisi 6.13 10/22/2004 Bilgisayar Mimarisi 6.14 Booth algorithm Itera tion Multip licand Original algorithm Step Booth s algorithm Step product Multiplier in simdiki (current) ve bir onceki (previous) bit lerine bakilarak asagidaki islemlerin biri gerceklenir 00 arithmetic islem yok 01 multiplicand i product in sol yarisina ekle 10 multiplicand i product in sol yarisindan cikar 11 arithmetic islem yok register 1 bit right shift yapilir 0 1 2 3 4 Initial values Prod = Prod + Mcand Prod = Prod + Mcand 0000 0110 0000 0110 0000 0001 0001 0001 0001 1000 0001 1000 0000 1100 Initial values Prod = Prod Mcand Prod = Prod + Mcand 0000 0110 0 0000 0110 0 0000 0 0 1111 0001 1 1111 0001 1 1111 1000 1 0001 1000 1 0000 1100 0 10/22/2004 Bilgisayar Mimarisi 6.15 10/22/2004 Bilgisayar Mimarisi 6.16

Integer Division Quotient = dividend / divisor with remainder Try this example: 2619 / 32 Hardest step: determine the largest quotient digit that, when multiplied times divisor, is less than the dividend. Division Version 1 64 bit divisor 64 ALU 64 bit remainder 32 bit quotient To divide 7 / 2 (each 4 bits) Divisor reg starts with 0000 Rem reg starts with 0000 0111 Quotient starts with 0000 10/22/2004 Bilgisayar Mimarisi 6.17 10/22/2004 Bilgisayar Mimarisi 6.18 Start Rem = Rem - divisor Division Version 1 Floating point representation Shift Quotient left, set LSB = 1 Remainder Shift Divisor right Repeat 33 times Rem = Rem + Divisor Shift quotient left, set LSB = 0 10/22/2004 Bilgisayar Mimarisi 6.19 Bilgisayar lar fraction a sahip sayilar icin bir gosterime sahip olmali (math islemlerini yapabilmek icin) Fraction li sayilar 3.1416 Cok kucuk sayilar.000000001 Cok buyuk sayilar 6.02 x 10 23 10/22/2004 Bilgisayar Mimarisi 6.20

Exponent siz sayilarin bilgisayarlarda saklanmasi 32 bitle 4 milyar sayi saklanabilir 64 bitle 16x10 18 sayi saklanabilir Ancak scientific hesaplarda cok daha buyuk sayilarin saklanmasina ihtiyac duyulur Floating point representation Sign, exponent, significand (-1) sign x significand x 2 exponent Bit lerin cogu significand icin kullanilirsa More accuracy Bit lerin cogu exponent icin kullanilirsa more range IEEE 754 floating point standard single precision: 8 bit exp, 23 bit significand double: 11 bit exp, 52 bit significand 10/22/2004 Bilgisayar Mimarisi 6.21 10/22/2004 Bilgisayar Mimarisi 6.22 Normalization In scientific notation: 1234000 = 1234 x 10 3 = 1.234 x 10 6 in floating point: 1010000 = 1011 x 2 3 = 1.011 x 2 6 Ilk bit 1, bunu binary point izler Ilk bit in 1 oldugu icin bunu bit kullanarak temsil etmemize gerek yok IEEE 754 standard Leading 1 is implicit Buyuk sayilar icin positive exponent lere ihtiyac Kucuk sayilar icin negative exponentlere ihtiyac Biasing kullanilarak siralama daha kolay sekle sokulur En kucuk exponent de tum bit ler 0, en buyuk exponent de butun bit ler 1 Single prcision icin bias 127, double precision icin bias 1023 10/22/2004 Bilgisayar Mimarisi 6.23 10/22/2004 Bilgisayar Mimarisi 6.24

Convert 2.75 to floating point Sign bit 0 2.75 10 10.110 2 Normalize to 1.0110 x 2 +1 Stored exp: 127 + 1 = 128 = 10000000 Final value: 010000000000000 0 Convert -6.25 to IEEE floating point..? 10/22/2004 Bilgisayar Mimarisi 6.25 Convert 010001000 0 Sign is positive Exponent is 129-127 = 2 Binary value is 1.01101 x 2 2 or 101.101 Apply weights 4 2 1.5.25.125 Result is 5.625 Convert 101111000000000.0 =? 10/22/2004 Bilgisayar Mimarisi 6.26 Special values Addition in floating point S (1 bit) E (8 bit) F (23 bit) single precision 0 [ E [ 255 e = E 127 (Biased-127) S E F Number 0/1 0 0 0 0 255 0 + 1 255 0-0/1 255 g 0 NaN 10/22/2004 Bilgisayar Mimarisi 6.27 Kucuk exponent li sayiyi shift ederek exponent ler esitlenir Significand lari topla Sonucu normalize et 4.56 x 10 3 --> 4.56 x 10 3 2.34 x 10 2 -->.234 x 10 3 ------------------------------------- 4.794 x 10 3 Already normalized 10/22/2004 Bilgisayar Mimarisi 6.28

Multiplication in floating point Multiply the significands Add the exponents Normalize the result 1.03 x 10 3 0.6 x 10 2 ------------- 0.618 x 10 5 normalize to 6.18 x 10 4 10/22/2004 Bilgisayar Mimarisi 6.29 Gizli Tehlikeler Overflow (sonuc cok buyuk) Sonucun exponen ti 8 (11) bit alanina sigmiyor Underflow Sonucun exponenti cok kucuk, ornek., 10-6 Note: too small doesn t mean zero! 10/22/2004 Bilgisayar Mimarisi 6.30 Floating point is not natural 1 ile 3 * (1/3) ayni sey degil 1/3 is a forever repeating fraction Bolme islemi belli bir adimdan sonra sonlandirilir Carpma yapildiginda, sonuc 1 den farkli Floating point addition associative degil X = -1.5 x 10 38 Y = 1.5 x 10 38 Z = 1.0 X + (Y+Z) = -1.5 x 10 38 + (1.5 x 10 38 + 1.0) = -1.5 x 10 38 + 1.5 x 10 38 = 0 (X+Y) +Z = (-1.5 x 10 38 + 1.5 x 10 38 ) + 1.0 = 0 + 1.0 = 1.0 10/22/2004 Bilgisayar Mimarisi 6.31 10/22/2004 Bilgisayar Mimarisi 6.32

There are repeating fractions in binary 0.1 in decimal is 1/16 + 1/32 + 1/256 + 1/512 + 1/4096 =.0 etc Once bolme sonra carpma yapildiginda baslangictaki sayidan farkli bir sayi elde edilir Loss of accuracy with subtraction Assume 6 digits of accuracy with A and B A = 3.03492 B = 3.03471 A - B = 0.00021 Only two accurate digits left Restate: Bill Gates net worth yesterday was 3.61 B dollars, today it is still 3.61 B dollars. I would love to have the difference. 10/22/2004 Bilgisayar Mimarisi 6.33 10/22/2004 Bilgisayar Mimarisi 6.34