Data Storage
Total Page:16
File Type:pdf, Size:1020Kb
Chapter 1: Data Storage 1.1 Bits and Their Storage 1.2 Main Memory 1.3 Mass Storage 1.4 Representing Information as Bit Patterns 1.5 The Binary System 1.6 Storing Integers 1.7 Storing Fractions 1.8 Data Compression 1.9 Communication Errors 1 HIGH Bits LOW Bit Binary Digit A symbol whose meaning depends on the application at hand. Numeric value (1 or 0) Boolean value (true or false) Voltage (high or low) For TTL, high=5V, low=0V 2 More bits? kilobit (kbit) 103 210 megabit (Mbit) 106 220 gigabit (Gbit) 109 230 terabit (Tbit) 1012 240 petabit (Pbit) 1015 250 exabit (Ebit) 1018 260 zettabit (Zbit) 1021 270 3 Bit Patterns All data stored in a computer are represented by patterns of bits: Numbers Text characters Images Sound Anything else… 4 Boolean Operations Boolean operation any operation that manipulates one or more true/false values Can be used to operate on bits Specific operations AND OR XOR NOT 5 AND, OR, XOR 6 Gates Gates devices that produce the outputs of Boolean operations when given the operations‟ input values Often implemented as electronic circuits Provide the building blocks from which computers are constructed 7 AND, OR, XOR, NOT Gates Chapter 2 8 INPUT OUTPUT A B A NAND B NAND 0 0 1 0 1 1 1 0 1 NOR 1 1 0 XNOR 9 10 Store the bit What do we mean by „storing‟ the data? Bits in the computer at the i th second = Bits in the computer at the (i + 1) th second For example If the current state of the bit is „1‟, it should be still „1‟ at the next second 11 Flip-Flops Flip-Flop a circuit built from gates that can store one bit of data Two input lines One input line sets its stored value to 1 Another input line sets its stored value to 0 When both input lines are 0, the most recently stored value is preserved 12 Flip-Flops Illustrated X Y Z X Z 0 0 -- 0 1 0 Flip-Flop 1 0 1 Y 1 1 * 13 A Simple Flip-Flop Circuit 14 Setting to 1 – Step a. 15 Setting to 1 – Step b. 16 Setting to 1 – Step c. 17 Try This Show how the output can be turned to 0 18 Another Flip-Flop Circuit 19 Flip-Flops A kind of storage Holds its value until the power is turned off 20 Types of Memory Volatile memory A.k.a. dynamic memory Holds its value until the power is turned off Non-volatile memory Holds its value even after the power is off 21 Capacitors Two metallic plates positioned in parallel Principle Tiny space between two plates Voltage thru, charge the plats Voltage off, charge remains on the plats Connect two plates, charge off the plates Many of these capacitors with their circuits on a wafer (chip) Even more volatile than flip-flops Must be replenished periodically 22 Flash Memory Originally made from EEPROM Trapping electrons in silicon dioxide SiO2 chambers Chamber very small 90 angstroms 1 angstrom is 1/10,000,000,000 of a meter Non-volatile Holds its value after the power is off 23 Types of Memory Volatile memory A.k.a. dynamic memory Holds its value until the power is turned off Examples, flip-flops, capacitors Non-volatile memory Holds its value even after the power is off Examples, flash memory, magnetic storage, compact disk, etc 24 Hexadecimal Notation Why? Things are in bit streams Stream = a long string of bits. Long bit streams E.g., 100 = 11001002 Hexadecimal notation A shorthand notation for streams of bits. More compact. 25 The Hexadecimal System 26 Chapter 1: Data Storage 1.1 Bits and Their Storage 1.2 Main Memory 1.3 Mass Storage 1.4 Representing Information as Bit Patterns 1.5 The Binary System 1.6 Storing Integers 1.7 Storing Fractions 1.8 Data Compression 1.9 Communications Errors 27 Storage Hierarchy Speed Cost Capacity Cache Main Memory e.g. Hard Disk On-line Storage Near-line Storage e.g. Optical Disk e.g. Magnetic Off-line Storage Tape low low large 28 Main Memory: Basic Cell Manageable memory unit Typically 8 bits Byte A string of 8 bits. High-order end The left end Low-order end The right end Least significant bit The last bit at the low-order end 29 A Byte-Size Memory Cell 30 Main Memory: Addresses Address A “name” to uniquely identify one cell Consecutive numbers Usually starting at zero I.e., having an order “previous cell” and “next cell” have reasonable meanings Random Access Memory Memory where any cell can be accessed independently 31 Memory Cells 32 Not Quite the Metric System K “Kilo-” normally means 1,000 Kilobyte = 210 = 1024 M “Mega-” normally means 1,000,000 Megabyte = 220 = 1,048,576 G “Giga-” normally means 1,000,000,000 Gigaabyte = 230 = 1,073,741,824 33 Mass Storage Systems Non-Volatile Data remains when computer is off Usually much bigger than main memory Usually rotating disks Hard disk, floppy disk, CD-ROM Much slower than main memory Data access must wait for seek time (head positioning) Data access must wait for rotational latency 34 Hard Disk 35 Disk arm read/write head 36 Compact Disk 37 Multi-layered CD pits 38 39 Magnetic Tape 40 Files File The unit of data stored on a mass storage system. Logical record and Field Natural groups of data within a file Physical record A block of data conforming to the physical characteristics of the storage device. 41 Logical vs. Physical Records phone num address name 42 Two more logical records might be stored in the same physical record One logical record might be split into two physical record 43 Buffers Storage area used to hold data on a temporary basis Usually during the process of being transferred from one device to another Example: Printers with memory Holding portions of a document that have transferred to the printer but not yet printed 44 Why using buffer? Device sharing E.g. 3 computers sharing the same printer Connect devices of different speeds E.g. Computer -> buffer -> printer 45 Chapter 1: Data Storage 1.1 Bits and Their Storage 1.2 Main Memory 1.3 Mass Storage 1.4 Representing Information as Bit Patterns 1.5 The Binary System 1.6 Storing Integers 1.7 Storing Fractions 1.8 Data Compression 1.9 Communications Errors 46 Bit Patterns All data stored in a computer are represented by patterns of bits: Text characters: “I love CS” Numbers: 123456 Images: JPEG, GIF, etc Sound: 47 How we interpret “0110101”? We use „coding‟ to define the meaning of binary bits Many different coding schemes ASCII EBCDIC ISO/IEC …. 48 “CODE” = translation rule What does this code say? 49 ASCII - “Hello.” 50 Representing Text Printable character Letter, punctuation, etc. Assigned a unique bit pattern. ASCII 7-bit values For most symbols used in written English text Unicode 16-bit values For most symbols used in most world languages ISO 32-bit values 51 Representing Number Binary notation Uses bits to represent a number in base two In practice Not all numbers can be represented 0.1666666666666666 Depends on the capability of your computer How many bits are used to represent a number? 52 Limitations Overflow Happens when a number is too big to be represented Truncation Happens when a number is between two representable numbers Think the real numbers.. We will hear more in a little bit 53 Representing Images Bitmap techniques Points, pixels e.g. 小畫家程式 Representing colors BMP, DIB, GIF and JPEG formats Scanners, digital cameras, computer displays Vector techniques Lines, scalable fonts, e.g., TrueType e.g. Acrobat Reader PostScript CAD systems, printers 54 Representing Sound 55 Chapter 1: Data Storage 1.1 Bits and Their Storage 1.2 Main Memory 1.3 Mass Storage 1.4 Representing Information as Bit Patterns 1.5 The Binary System 1.6 Storing Integers 1.7 Storing Fractions 1.8 Data Compression 1.9 Communications Errors 56 Decimal vs. Binary Systems 102 101 100 23 22 21 20 57 From Binary to Decimal 58 From Decimal to Binary 59 An Example 13 A23 B22 C2 D Polly Huang, NTU EE Chapter 2 60 Adding Binary Numbers 00111010 00011011 01010101 61 Fraction in Binary System 22 21 20 2-1 2-2 2-3 62 Adding Fractions 00010.011 00100.110 00111.001 63 Chapter 1: Data Storage 1.1 Bits and Their Storage 1.2 Main Memory 1.3 Mass Storage 1.4 Representing Information as Bit Patterns 1.5 The Binary System 1.6 Storing Integers 1.7 Storing Fractions 1.8 Data Compression 1.9 Communications Errors 64 Two Kinds of Integers Unsigned integers Numbers that are always positive Signed integers Numbers that can be positive or negative 65 Representing Signed Integers Two‟s complement notation The most popular representation Excess notation A less popular representation 66 Two‟s Complement Notation Chapter 2 67 Coding –6 using Four Bits 68 Adding Numbers 69 Try This 5 0101 4 Two‟s Complement ? ? ? 70 Overflow 5 0101 4 Two‟s Complement 0100 -7 1001 Decimal 71 Excess Notation 72 Floating-Point notation (8 Bits) 01101011 .10112110 10.11 2 3 4 73 Fraction to Floating Point 3/8 .0110 2100 01000110 3/8 .1100 2011 00111100 0 .0000 2000 00000000 74 Coding 2 and 5⁄8 75 Loss of Digits 2 1 1 1 10.1 0.001 0.001 2 8 8 01101010 00011000 00011000 01101010 01100000 01100000 01101010 2 1 2 76 Chapter 1: Data Storage 1.1 Bits and Their Storage 1.2 Main Memory 1.3 Mass Storage 1.4 Representing Information as Bit Patterns 1.5 The Binary System 1.6 Storing Integers 1.7 Storing Fractions 1.8 Data Compression 1.9 Communications Errors 77 Generic Data Compression Run-length encoding Relative encoding Frequency-dependent encoding Adaptive dictionary encoding 78 Run-Length Encoding Replace a sequence with The repeating value The number of times it occurs in the sequence