NMCNTT 3 NumeralSystems and DataStorage - Update
NMCNTT 3 NumeralSystems and DataStorage - Update
Data Storage
Content
Bits and their Storage
Bits, Gates, Flip-Flop
Main Memory
Representing Information as Bit Patterns
Text, number, images, sound
Binary System
Storing Integers
Storing Fractions
Mass Storage
Question
Bits
Gates
Flip-flop
Bits
5
Bits
Electronic implementation
0 1 0
1.1V
0.9V
0.2V
0.0V
Easily to encode:
Numeric value : 1 & 0
Boolean value : true & false
Voltage : high & low
Punched card : punched & not punched
8
Bits – Boolean Operations
9
Gates
A device that computes a Boolean operation
Often implemented as (small) electronic circuits:
Including: resistor (điện trở), transistor (bòng bán
dẫn), Capacitor (tụ điện), diot (điốt), …
0 & 1 ~ voltage
Nguồn: Wikipedia
10
A pictorial representation of
gates
11
Example – Simple circuit
12
Quiz
15
A simple flip-flop circuit
Flip-Flop
17
Flip-Flop
18
Quiz - Flip-Flop?
• If upper input is 1 and lower input is 0,
what is the output?
19
Quiz- Flip-Flop?
Source:wikipedia
20
Flip-flop - Activity
Hexadecimal Notation
We know
How machines encode information into chain
of bits
Basic storage devices
So
To store data, machines need to have a
million of circuits (a circuit stores 1 bit)
→ Place containing these bits is called Main
Memory
26
Introduction
In additional to Flip-flops, machines have
other storage devices (called external
memory)
Magnetic, optical, flash deices
Storage devices
Volatile memory (bộ nhớ khả biến)
Requires power to maintain the stored information
Non-volatile memory (bộ nhớ bất khả biến)
Can retrieve stored information even after having
been power cycled
27
Main memory cells
Cell: A unit of main memory (typically 8 bits
which is one byte)
Most significant bit: the bit at the left (high-order) end
of the conceptual row of bits in a memory cell
Least significant bit: the bit at the right (low-order)
end of the conceptual row of bits in a memory cell
Organization of a byte-size memory cell
Size 8 bits (1 byte)
Sequence of bits
28
Main memory address
29
Terminology
30
Measuring memory capacity
0
1 bit 2
1 0
2 bit 22
2 1 0
3 bit 23
n-1 5 4 3 2 1 0
n bit … 2n
0…000 → 1…111 = 2n – 1 31
Measuring memory capacity
Capacity Value
Byte B 8 bit
KiloByte KB 210 B = 1024 Byte
MegaByte MB 210 KB = 220 Byte
GigaByte GB 210 MB = 230 Byte
TeraByte TB 210 GB = 240 Byte
Peta PB 210 TB = 250 Byte
Exabyte EB 210 PB= 260 Byte
32
REPRESENTING INFORMATION
AS BIT PATTERNS
Representing Text
Display/represent: character
Need to have a map table between the
two, do the mapping between numerical
values and character values.
Non-printing/control characters
null: 0
‘ ’ (tab): 9
enter/ line feed: 10
carriage return: 13
38
ASCII
39
Unicode
40
Unicode
41
Unicode and Vietnamese
http://vietunicode.sourceforge.net/charset/
v3.htm
42
Unicode - Font
43
Representing Numeric Values
Additional table
+ 0 1
0 0 1
1 1 10
Decoding the binary representation
(Binary to base 10)
1010.112 = 1*23+0*22+1*21+0*20+1*2-1+1*2-2
1010.112 = 8+0+2+0+0.5+0.25 = 10.7510
Quiz
Binary to base 10
21.12510
STORING INTEGERS
Unsigned Integers
One’s complement :
Changing all the 0s to 1s, all the 1s to 0s.
Ex: 0110 and 1001 are complements
5 (1 byte) 0 0 0 0 0 1 0 1
One’s complement of 5 1 1 1 1 1 0 1 0
+ 1
Two’s complement of 5 1 1 1 1 1 0 1 1
+ 5 0 0 0 0 0 1 0 1
Result 1 0 0 0 0 0 0 0 0
Coding the value -6 in two’s
complement notation using 4 bits
Two’s complement notation
systems
Addition problems converted to
two’s complement notation
Quiz
64 -263 = - 263-1 =
9,223,372,036,854,775,808 +9,223,372,036,854,775,807
Min and max of unsigned integers
n Minimum Maximum
8 0 28 - 1 = 255
16 0 216 - 1 = 65,535
32 0 232 -1 = 4,294,967,295
64 0 264 - 1 = 18,446,744,073,709,551,615
Excess (K-bias)
Choose K (a positive integer) to allows
operations on the biased numbers to be the
same as for unsigned integers, but represents
both positive and negative values
The remaining n bits represents the biased
value (n is the length of bit pattern)
Excess representations are now primarily used
for the exponent of floating-point numbers
Excess (K-bias)
Ex: Suppose that n =8, K=128, how to represent a
number in binary
Positive number: N = 25 (decimal)
N+K = 25 + 128 = 153
The bit binary pattern is 10011001
Negative number: N = -25 (decimal)
N+K = -25 + 128 = 103
The bit binary pattern is 01100111
Excess
Floating-points:
Consisting of a sign bit, a mantissa field, and
an exponent field.
Radix point: used to separate integer part
and the fraction part of a number
Mantissa: also fraction/significant
Example 1
01101011
Signed bit: 0
Exponent: 110
Mantissa: 1011
.1011
110 = 2 (excess with 3-bit)
10.11 = 2 ¾
Example 2
00111100
Signed bit: 0
Exponent: 011
Mantissa: 1100
.1100
011 = -1 (excess with 3-bit)
.01100 = 3/8
Example 3
Encode 1⅛
Convert to binary 1.001
Mantissa: _ _ _ _ 1 0 0 1
From left to right, start with leftmost bit 1
Radix point: from .1001 to 1.001
→ Exponent: +1 = 101 (excess 3-bit)
Signed bit: 0
1 ⅛ = 01011001
Encoding the value 2 5⁄8
→ Truncation error
0 110 1010
21/2
Single-precision : 32 bits
s exp frac
1 8-bits 23-bits
Double-precision : 64 bits
s exp frac
1 11-bits 52-bits
S: Sign bit
F: Fraction part
E: Exponent part
127 = 2 8-1 (excess 8-bit)
Example 1
Checksum
Error-correcting code
Example:
Hamming(000000, 001111) = 4
Hamming(10101100, 01100100) = 3
Error-correcting code
Error-correcting code
Magnetic Systems
Disk
Tape
Optical Systems
CD
DVD
Flash Technology
Flash Drives
Secure Digital (SD) Memory Card
Magnetic disk storage system
Magnetic disk storage system
Seek time
Time needed to position the read/write head
over the correct track
Latency
Time for the beginning of the desired sector
to rotate under the read/write head
Transfer time
Time for the entire sector to pass under the
read/write head and have its contents read
into or written from memory
Magnetic disk storage system
Given:
Rotation speed = 7,200 rev/min=120 rev/sec = 8.33 msec/rev
Arm movement time = 0.02 msec to move to an adjacent track
On average, the read/write head must move about 300 tracks
Number of tracks/surface = 1,000
Number of sectors/track = 64
Number of bytes/sector = 1,024
Seek time
Best case = 0 msec;
Worst case = 999*0.02=19.98 msec
Average case = 300*0.02 = 6 msec
Magnetic disk storage system
Given:
Rotation speed = 7,200 rev/min=120 rev/sec = 8.33 msec/rev
Arm movement time = 0.02 msec to move to an adjacent track
On average, the read/write head must move about 300 tracks
Number of tracks/surface = 1,000
Number of sectors/track = 64
Number of bytes/sector = 1,024
Latency
Best case = 0 msec;
Worst case = 8.33 msec
Average case = 4.17 msec
Magnetic disk storage system
Given:
Rotation speed = 7,200 rev/min=120 rev/sec = 8.33 msec/rev
Arm movement time = 0.02 msec to move to an adjacent track
On average, the read/write head must move about 300 tracks
Number of tracks/surface = 1,000
Number of sectors/track = 64
Number of bytes/sector = 1,024
Transfer time
1/64 * 8.33 msec = 4.17 msec
Magnetic tape storage