Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

48
Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins

Transcript of Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Page 1: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 1

Basiscursus InformaticaCollege 1

Brookshear H1

Richard Benjamins

Page 2: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 2

Overzicht college 1

Opslag van bits

Main memory

Mass storage

Coderen van op te slaan informatie

Binaire systeem

Opslaan van integers

Page 3: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 3

Opslag van bits

Computer slaat alle info op in bit-patronen

bit: binary digit: 0 en 1

Opslag bit vereist machine met 2 toestanden

schakelaar (aan, uit) vlag (omhoog, omlaag)

In computer: flip-flop

bestaat uit gates (poorten)

Page 4: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 4

Gates

Gates zijn operaties die bits manipuleren

1/0 boolean operaties

AND, OR, XOR (exclusive OR), NOT

input bits --> output bit

Flip-flop is opgebouwd uit deze gates

voor opslag van bits

Page 5: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 5

Gates

ANDInputs Output0 0 00 1 01 0 01 1 1

Inputs Output0 0 00 1 11 0 11 1 1

OR

XOR NOTInputs Output0 0 00 1 11 0 11 1 0

Input Output0 11 0

Page 6: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 6

Flip-flop

input

input

output

OR

AND

NOT

Page 7: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 7

Flip-flop

Circuit met een output (0 of 1)

Output is constant totdat tijdelijke puls van een ander circuit de output verandert

ouput wisselt van waarde onder invloed van tijdelijke externe stimulus

Beide inputs 0 --> output constant (0 of 1)

tijdelijk 1 op bovenste input --> output 1

tijdelijk 1 op onderste input --> output 0

Page 8: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 8

Flip-flop

0

0OR

AND

NOT

0

0

1

0

Page 9: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 9

Flip-flop

1

0

OR

AND

NOT

1

1

1

1

X0

Page 10: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 10

Flip-flop: samenvatting

Inputs waren 0, output was 0

Bovenste input tijdelijk naar 1

Output wordt 1

Boventste input terug naar 0

Output blijft 1

Analoog: tijdelijk 1 op onderste input --> 0

Page 11: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 11

Rol van flip-flop

Ideaal voor opslag van bit in computer

waarde kan gelezen en veranderd worden door andere circuits

Er passen miljoenen op een chip

Bouwstenen van een geintegreerde circuits

NOT, OR, XOR, AND

Geen geheugen als power supply uit, is informatie weg

Page 12: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 12

Abstractie

We kunnen over gates en flip-flops praten zonder ons druk te maken over hun details

Andere struktuur flip-flop mogelijk, met zelfde gedrag

Hoge/lage toon (modems) Licht/donker (glasvezel) Variaties in toestand van eiwitmoleculen

Page 13: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 13

Hexidecimale notatie

Bit strings kunnen erg lang zijn

Moeilijk voor menselijk geheugen

leidt tot veel fouten

Hexidecimaal: enkel symbool voor 4 bits

pagina 21 boek

Bit patroon Hexidecimaal

0000 00001 10010 20011 3........ ..1100 C1101 D1110 E1111 F

Page 14: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 14

Overzicht college 1

Opslag van bits

Main memory

Mass storage

Coderen van op te slaan informatie

Binaire systeem

Opslaan van integers

Page 15: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 15

Main Memory

Computergeheugen bestaat uit groot aantal circuits om data op te slaan (main memory)

Geheugen georganiseerd in cellen 1 cel = 8 bits = 1 byte

Geheugencapaciteit uitgedrukt in cel-eenheden 1 MB = 1.048.576 cellen = 220 cellen

Elke cel heeft uniek adres (0, 1, 2, 3, 4, ...)

Page 16: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 16

Groepen bits

Byte: 8 bits

Kbyte: 1024 bytes

Mbyte: 1.048.576 bytes

Gbyte: 1024 Mbytes

T(era)byte: 1024 Gigabytes

Page 17: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 17

RAM

Elke cel uit main memory kan individueel gerefereerd, bereikt en veranderd worden

“Hoge” adressen zijn net zo toegankelijk als “lage”

Random Accress Memory (RAM) gegeven een adres, direct inhoud opvragen

In tegenstelling tot “massa geheugen”

lange bit-strings manipuleren in blokken

Page 18: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 18

Organisatie binnen cel

8 bits in een byte

linker bit = most significant bit

rechter bit = least significant bit

Bytes zijn georganiseerd als een lange rij (met adres)

Een string van 16 bits opslaan in 2 naast elkaar gelegen bytes

Most Leastsignificant significantbit bit

0 1 0 1 1 0 1 0

High-order Low-orderend end

Page 19: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 19

Overzicht college 1

Opslag van bits

Main memory

Mass storage

Coderen van op te slaan informatie

Binaire systeem

Opslaan van integers

Page 20: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 20

Massa-opslag

Main memory is niet voldoende

backups, power-off, technologische beperkingen

Mass storage of secondary memory

Data opslaan in grote eenheden -files

Nadelen: mechanische onderdelen (langzaam)

On-line (hard-disk) en off-line (floppy-disk)

aan computer versus los

Page 21: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 21

Disk storage (schijf)

Lees-/schrijfkoppen onder/boven schijf

Als schijf draait, lezen koppen een cirkel track opgedeeld in sectors, met data in bit-strings

Variatie per type schijf aantal tracks op oppervlak aantal sectors per track (sector = 512 of 1024

bytes)

Figuur 1.9, pagina 25

Page 22: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 22

Disk storage, vervolg

Tracks en sectoren zijn niet permanent

Worden magnetisch vastgelegd door schijf te formateren

Formateren vernietigt alle bestaande data op schijf

Floppy (slappe) disk: lage capaciteit, off-line

Hard disk: hoge capaciteit, on-line

Page 23: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 23

Schijfprestatie

Afhankelijk van aantal factoren

seek time: bewegen van de koppen tussen tracks rotation delay of latency time: gemiddelde tijd om

data op track te vinden access time: som van seek en latency time transfer rate: snelheid van data uitwisseling

tussen kop en schijf

Harde schijven doen het op alle fronten beter dan floppies Electronisch geheugen (main) nog veel beter!

Page 24: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 24

Compact disks

Optisch systeem ipv magnetisch

CD bestaat uit reflectief materiaal

data opgeslagen als variaties in oppervlakte (veranderende reflecties)

data lezen door variaties te scannen met een laserstraal

Hoge capaciteit (> 600 MB)

Page 25: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 25

Opslag op tape

Magnetische opslag (ouderwets)

vergelijk tape recorder

Grote capaciteit (tot aantal GBs)

Grootste nadeel: zeer hoge access time

OK als backup medium

Page 26: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 26

Logical en phisical records

Fysiek record op magnetische schijf elke sector wordt als geheel (een blok)

behandeld als data gelezen of gemanipuleerd wordt

Logisch record Natuurlijke opdeling van informatie in blokken

(elke student is een blok)

Deze komen niet vaak overeen aantal logische blokken in 1 fysiek blok logisch blok verdeeld over meerdere fysieke

Page 27: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 27

Overzicht college 1

Opslag van bits

Main memory

Mass storage

Coderen van op te slaan informatie

Binaire systeem

Opslaan van integers

Page 28: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 28

Symbolen representeren

ASCII (American Standard Code for Information Interchange) hoofd-, kleine letters, leestekens, cijfers 0-9 controle informatie (nieuwe regel, tabs, etc.)

Oorspronkelijk 7 bits 128 standaard codes Appendix A, pagina 433

Tegenwoordig 8 bits (extra 0 aan high-order) compatibiliteit extra 128 codes zijn (helaas) niet standaard

Page 29: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 29

ASCII voorbeeld

01001000 01100101 01101100 01101100 01101111 00101110

H e l l o .

Page 30: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 30

Getallen representeren

Getallen representeren met ASCII is inefficient

25: twee cijfers --> 2 bytes = 16 bits grootste getal met 16 bits is 99

Alternatief: binaire of “base two” representatie

alleen 0 en 1 (niet 0,1,2,3,4,5,6,7,8,9)

Page 31: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 31

Overzicht college 1

Opslag van bits

Main memory

Mass storage

Coderen van op te slaan informatie

Binaire systeem

Opslaan van integers

Page 32: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 32

Decimaal versus binair

Decimaal: positie representeert waarden

375: 5 staat voor 5; 7 staat voor 70; 3 staat voor 300

5 staat voor 5x1 100

7 staat voor 7x10 101

3 staat voor 3x100 + 102

Som = 375

In binair systeem gaat het met een factor 2 ipv 10

Page 33: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 33

Binair systeem

Representatie: 1 0 1 1

1 0 1 1acht vier twee een

23 22 21 20

1x1 + 1x2 + 0x4 + 1x8 = 11

Ook hier geeft positie waarde aan

vgl most en least significant bit

Elke positie is 2x de waarde van rechter buur

Vermenigvuldi-gen met 0 of 1

Page 34: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 34

Voorbeeld binair systeem

Representatie: 1 0 0 1 0 1

1 0 0 1 0 1twee-en zestien acht vier twee eendertig

1x1 + 0x2 + 1x4 + 0x8 + 0x16 + 1x32 = 37

0 1 10 11 100 101 110 1111000

Stel het je voor als een kilometertellerof als een digitale klok

Page 35: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 35

Getallen representeren

ASCII, 8 bits (1 byte): grootste getal is 9

Binair grootste getal in 1 byte is 11111111

1+ 2+ 4+ 8+16+32+64+128 20+21+22+23 +24 +25 + 26 + 27 = 255 = 28 - 1

ASCII, 16 bits: grootste getal 99

Binaire systeem, 16 bits: 216-1= 65535

Page 36: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 36

Andere data representeren

Pictures, audio, video

Pixel = picture element, 1 bit is 1 pixel Bitmap: bit patroon is een directe

representatie van plaatje TIFF (tag image format file), GIF (graphical

interchange format), JPEG (joint photographic experts group)

Fonts: Postscript, PDF (portable document format)

Page 37: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 37

Binair optellen

Principe zelfde als decimaal optellen met “onthouden”

0011101000011011

10011101000011011 01

10011101000011011 0101

10011101000011011 010101

1 (foutje boek)0011101000011011 1010101

001110100001101101010101

+ + +

+++

582785

Page 38: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 38

Breuken in binair systeem

“Komma” invoeren: radix point

links van radix: integers (als tot nu toe) rechts van radix: breuken (1/2, 1/4, 1/8, etc)

101.101 = 1x1/8 + 0x1/4 + 1x1/2 + 5 = 5 1/8

Continuering van eerder

Elke positie is 2x de waarde van zijn rechter buur

Page 39: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 39

Optellen van breuker

Zet de radix pointen gelijk

tel normaal op

10.011100.11 111.001

2 3/84 6/87 1/8

Page 40: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 40

Overzicht college 1

Opslag van bits

Main memory

Mass storage

Coderen van op te slaan informatie

Binaire systeem

Opslaan van integers

Page 41: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 41

Ook negatieve getallen

Twee manieren

Excess notatie Two’s complement notatie

– meest gebruikte

Page 42: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 42

Excess notation

Kies bit-string lengte (bv. 4)

Schrijf alle patronen op als gewoon tellen (16)

Stel patroon 1000 als 0 (MSB is 1)

Wat volgt naar boven is 1, 2, 3, etc.

Wat voorafgaat naar beneden is -1, -2, -3, etc

MSB is het tekenbit (sign bit) 0 is negatief; 1 is positief

Page 43: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 43

Excess eight1111 71110 61101 51100 41011 31010 21001 11000 00111 -10110 -20101 -30100 -40011 -50010 -60001 -70000 -8

Waarom “excess eight”?

Bit patroon geeft 8 teveel aan

1111 is normaal 15 nu is het 7 1000 is normaal 8 nu is het 0

Hoe schrijf je -4?

-4 + 8 = 4 --> 0100

Page 44: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 44

Two’s complement notation

Kies lengte bit-patroon (bv. 4)

Stel 0000 als 0

Tel naar boven tot aan 0111 (geeft 1, 2, 3, etc.) Tel naar beneden tot aan 1000 (geeft -1, -2, etc.)

Sign bit (MSB): 0 is positief; 1 is negatief

Positieve getallen als normaal (min sign bit)

Duidelijke relatie tussen pos en neg getallen

Page 45: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 45

Voorbeeld two’s complement0111 70110 60101 50100 40011 30010 20001 10000 01111 -11110 -21101 -31100 -41011 -51010 -61001 -71000 -8

Pos en neg zijn gelijk als

lees van rechts naar links inclusief de eerste 1

Vanaf daar zijn de bit patronen elkaars complement

Complement

1 --> 0; 0 --> 1 1001 en 0110

Page 46: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 46

Optellen in two’s compl.

Zelfde systeem als gewoon binair optellen, maar antwoord nooit langer als delen

– 0101 + 0010 = 0111 soms een bit weggooien

– 0111 + 1011 = 10010 wordt 0010

Optellen wordt hetzelfde als aftrekken

= negatief maken en optellen

Page 47: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 47

Voorbeelden

3 0011+2 0010

0101 5+

7 0111+(-5) 1011

0010 2+

(-3) 1101+(-2) 1110

1011 -5

+

7 0111 0111-5 0101 1011

0010 2+-

Page 48: Basiscursus Informatica, 98-99 1 Basiscursus Informatica College 1 Brookshear H1 Richard Benjamins.

Basiscursus Informatica, 98-99 48

Overflow error

Met elke bit-lengte is er een limiet aan de waarden die gerepresenteerd kunnen worden

Bv. in two’s complement met vier bits

9 bestaat niet 4+5 is onmogelijk uit te rekenen Er zou -7 uitkomen 0100

01011001 “1” = neg; complement vanaf eerste “1” =0111 = 7