0% found this document useful (0 votes)
28 views28 pages

CISC1004 CH 01

Uploaded by

playruneyou046
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views28 pages

CISC1004 CH 01

Uploaded by

playruneyou046
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

05/09/2023

Data Storage
Chapter 1

Instructor: Miguel Gomes da Costa Junior

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 and Programming
• 1.9 Data Compression*
• 1.10 Communications Errors*
2

1
05/09/2023

1.1 Bits and Their Storage


• In today’s computers information is encoded as patterns of 0s and 1s.
• These digits are called bits (short for binary digits).

• We may associate bits with numeric values, but they are really only
symbols, whose meaning depends on the application at hand.

• Bit Patterns are used to represent information.


• Such as numbers, text characters, images, sounds and others.

1.1 Bits and Their Storage Figure 1.1


Boolean Operations The possible input and output values of
Boolean operations AND, OR, and XOR
(exclusive or)
• Boolean Operation: An operation
that manipulates one or more
true/false values

• Specific operations
• AND,
• OR
• XOR (exclusive or)
• NOT

2
05/09/2023

1.1 Bits and Their Storage

Gates
• Gate: A device that computes a Boolean operation
• Can be constructed from a variety of other technologies
• Often implemented as small electronic circuits called transistors
• Provide the building blocks from which computers are constructed

1.1 Bits and Their Storage


Figure 1.2
A pictorial representation of
AND, OR, XOR, and NOT gates
as well as their input and
output values

3
05/09/2023

1.1 Bits and Their Storage

Flip-flops
• Circuits built from gates that act as fundamentals unit of computer
memory

• They produce an output value of 0 or 1


• One input line is used to set its stored value to 1
• One input line is used to set its stored value to 0
• While both input lines are 0, the most recently stored value is preserved.

Figure 1.4
1.1 Bits and Their Storage Setting the output of a flip-flop to 1
Figure 1.3
A simple flip-flop circuit

4
05/09/2023

1.1 Bits and Their Storage


Figure 1.5
Another way of constructing a flip-flop

1.1 Bits and Their Storage


Figure 1.6
Hexadecimal Notation The hexadecimal coding system

• Hexadecimal notation: A shorthand notation


for long bit patterns
• Divides a pattern into groups of four bits each
• Represents each group by a single symbol

• Example: 10110101 becomes 0xB5


• The prefix “0x” means hexadecimal

10

10

5
05/09/2023

1.2 Main Memory


• Cell: A unit of main memory (typically 8 bits which is one byte)
• Most significant bit: the bit at the left (high-order) end
• Least significant bit: the bit at the right (low-order) end

Figure 1.7 - The organization of a byte-size memory cell

11

11

1.2 Main Memory

Main Memory Addresses


• Address: A “name” that uniquely identifies
one cell in the computer’s main memory
• The names are actually numbers.
• These numbers are assigned consecutively
starting at zero.
• Numbering the cells in this manner associates an
order with the memory cells.

Figure 1.8
Memory cells arranged by address

12

12

6
05/09/2023

1.2 Main Memory

Memory Terminology
• Random Access Memory (RAM): Memory in which individual cells can
be easily accessed in any order
• Dynamic Memory (DRAM): RAM composed of volatile memory
• Synchronous DRAM (SDRAM): retrieve contents faster than DRAM

13

13

1.2 Main Memory

Measuring Memory Capacity


• Main memory systems - total number of cells is a power of two.

Note: As a general rule, terms such as kilo-, mega-, etc. refer to powers of two when used in the
context of computer measurements, but they refer to powers of a thousand when used in other
contexts.

14

14

7
05/09/2023

1.3 Mass Storage


• Additional memory devices, also called secondary storage.
• Due to the volatility and limited size of a computer’s main memory. Includes:
• Magnetic disks  Magnetic tapes
• CDs  Flash drives
• DVDs  Solid-state drives
• Advantages over main memory
• Less volatility
• Larger storage capacities
• Low cost
• In many cases can be removed

15

15

1.3 Mass Storage

Mass Storage Performance


• Bandwidth: The total amount of bits that can be transferred in a unit
of time
• Latency: The total time between the request for data transfer and its
arrival

16

16

8
05/09/2023

1.3 Mass Storage


Figure 1.9
A magnetic disk storage system

Figure 1.10
Compact disk (CD) storage – An
optical technology example.

17

17

1.3 Mass Storage

Flash Drives
• Flash Memory – circuits that traps electrons in tiny silicon dioxide
chambers.
• Repeated erasing slowly damages the media.
• Mass storage of choice for:
• Digital cameras
• Smartphone
• SD Cards provide GBs of storage
This Photo by Unknown Author is licensed under CC BY-SA

18

18

9
05/09/2023

1.4 Representing Information as Bit Patterns


• Many different kinds of information can be encoded as bit patterns.

• Systems for encoding information have been established for


• Text
• Numeric Data
• Images
• Sound
• Other data

19

19

1.4 Representing Information as Bit Patterns

Representing Text
• Each character (letter, punctuation, etc.) is assigned a unique bit
pattern.
• ASCII: Uses patterns of 7-bits to represent most symbols used in written
English text.
• ASCII is extended to an 8-bits to fit a typical byte-size memory cell.
• ISO developed a number of 8-bit extensions to ASCII, each designed to
accommodate a major language group.
• Unicode: Uses patterns up to 21-bits to represent the symbols used in
languages worldwide, 16-bits for world’s commonly used languages.

20

20

10
05/09/2023

1.4 Representing Information as Bit Patterns


ASCII - American Standard Code for Information Interchange

Source: https://www.asciitable.com/ 0-21

21

1.4 Representing Information as Bit Patterns


Figure 1.11
The message “Hello.” in ASCII or UTF-8 encoding

22

22

11
05/09/2023

1.4 Representing Information as Bit Patterns

Representing Numeric Values


• Binary notation:
• Uses bits to represent a number in base two
• All numeric values in a computer are stored in
sequences of 0s and 1s

23

23

1.4 Representing Information as Bit Patterns

Representing Images
• Bit map techniques
• Pixel: “picture element” represents one dot
• Array of pixels is known as a raster
• RGB: Red, Green, and Blue components
• Luminance and chrominance
• Problems with scaling up images
• Vector techniques
• Represent images with geometric structures
• Scalable
• TrueType and PostScript This Photo by Unknown Author is licensed under CC BY-SA

24

24

12
05/09/2023

1.4 Representing Information as Bit Patterns

Representing Sound
• Sampling techniques that record actual audio
• Long-distance telephone: 8000 samples/sec
• CD sound: 44,100 samples/sec

• MIDI stores directions for making sound Figure 1.12


• Used in music synthesizers The sound wave represented
• Encodes which instrument, note, and duration by the sequence 0, 1.5, 2.0,
1.5, 2.0, 3.0, 4.0, 3.0, 0

25

25

1.5 The Binary System


• The traditional decimal system is based on powers of ten.
• The Binary system is based on powers of two.

Figure 1.13 The base ten and binary systems

26

26

13
05/09/2023

1.5 The Binary System


Figure 1.14
Decoding the binary representation 100101

27

27

1.5 The Binary System 1.5 The Binary System


Figure 1.15 – Figure 1.16
An algorithm for finding the binary Applying the algorithm in Figure 1.15 to
representation of a positive integer obtain the binary representation of 13.

28

28

14
05/09/2023

1.5 The Binary System


Figure 1.17
The binary addiction facts

29

29

1.5 The Binary System


Figure 1.18
Decoding the binary representation 101.101

30

30

15
05/09/2023

1.6 Storing Integers


• Mathematicians’ ideas for numeric notational systems turned out to
be very compatible with the design of digital circuitry.

• Two of these notational systems:


• Two’s complement notation: The most popular means of representing integer
values
• Excess notation: Another means of representing integer values

31

31

1.6 Storing Integers

Two’s complement notation systems


• This system uses a fixed number of bits to
represent each of the values in the system.
• In today’s equipment, it is common each value
is represented by a pattern of 32 bits.
• The leftmost bit of a bit pattern indicates the
sign of the value represented - the sign bit.
• Negative values have sign bits equal to 1, while
nonnegative values have sign bits equal to 0.

Figure 1.19

32

32

16
05/09/2023

1.6 Storing Integers


Figure 1.20
Coding the value -6 in two’s complement notation using four bits

33

33

1.6 Storing Integers


Figure 1.21
Addition problems converted
to two’s complement notation

34

34

17
05/09/2023

1.6 Storing Integers

The Problem of Overflow


• There is a limit to the size of the values that can be
represented in any system
• Overflow
• occurs when a computation produces a value that falls
outside the range of values that can be represented in the
machine
• Using 3-bits patterns, we cannot represent values > 4 or values < -5
• If the resulting sign bit is incorrect, an overflow has occurred

35

35

1.6 Storing Integers

Excess Notation

• Another method of representing integer values


• Same as two’s complement notation, each of the
values is represented by a bit pattern of the same
length.
• However, the sign bits are reversed comparing to two’s
complement notation.

Figure 1.22

36

36

18
05/09/2023

1.6 Storing Integers


Figure 1.23
An excess notation system using bit patterns of length three (excess-4 notation)

To represent any excess notation system:


• Set the length of the bit pattern
• Find the pattern that represents zero
• The pattern 1 at the leftmost bit and 0s in all
other digits (halfway of the list)
• The following patterns are positive values,
while preceding patterns are negative values.
• The decimal value of the zero’s representation
represents the value of the excess notation.
• Pattern 100 represents 0 rather than usual value 4.

37

37

1.7 Storing Fractions


• We store not only the pattern of 0s and 1s representing its binary
representation but also the position of the radix point.

• Floating-point Notation:
• A popular way based on scientific notation
• Consists of a sign bit, a mantissa field, and an exponent field.

• The finite storage space in the computer limits the precision

38

38

19
05/09/2023

1.7 Storing Fractions


Figure 1.24
Floating-point notation components

39

39

1.7 Storing Fractions


Encoding 1 1/8

To store 1 1/8 using floating-point


• Express 1 1/8 in binary notation which is
1.001 and copy to the mantissa field from
left to right.
• The radix should move to the right, so it is
represented by positive 1 in the excess-4 1 0 0 1
notation.
• Add the sign bit 0, since the value is
1 0 1
nonnegative.

0 1 0 1 1 0 0 1

40

40

20
05/09/2023

1.7 Storing Fractions

Truncation (Round-off) Errors


• Occur when part of the value being stored is lost because the
mantissa is not large enough
• Non-terminating expansions of fractions
• This happens more often with binary notation
• Not all values can be stored exactly in binary notation
• Often these values are converted to integers

41

41

1.7 Storing Fractions


Figure 1.25
Encoding the value 2 5⁄8

42

42

21
05/09/2023

1.7 Storing Fractions

Numerical Analysis
• The study of dealing with problems when computing large values that
require significant accuracy
• The order in which values are added can lead to two different results
• Adding very small values to very large values can result in errors

43

43

1.8 Data and Programming


• A programming language is a computer system created to allow
humans to precisely express algorithms using a higher level of
abstraction.

44

44

22
05/09/2023

1.8 Data and Programming

Getting Started with Python


• Python: a popular programming language for applications, scientific
computation, and as an introductory language for students
• Created by Guido van Rossum in the late 1980s.
• Freely available from www.python.org
>>> print('Hello, World!’)
• Python is an interpreted language Hello, World!
• When typing print('Hello, World!’)
• It results in: Hello, World!

45

45

1.8 Data and Programming

Variables
• Variables: name values for later use
• Analogous to mathematic variables in algebra
• Consider the script’s version of “Hello, World”
message = 'Hello, World!'
print(message)
• Can be used to store all the types of values that Python is able to represent.
• my_integer = 5
• my_floating_point = 26.2
• my_Boolean = True
• my_string = 'characters'
• my_integer = 0xFF

46

46

23
05/09/2023

1.8 Data and Programming

Operators and Expressions


• print(3 + 4) # Prints 7
• print(5 – 6) # Prints -1
• print(7 * 8) # Prints 56
• print(45 / 4) # Prints 11.25
• print(45 / / 4) # Prints 11, which is 45 integer divided by 4
• print(45 % 4) # Prints 1, which is the remainder of 45 integer divided by 4
• print(2 ** 10) # Prints 1024

• s = 'hello' + 'world’
• t=s*4
• print(t) # Prints “helloworldhelloworldhelloworldhelloworld”

47

47

1.8 Data and Programming

Currency Conversion (Python script example)


# A converter for currency exchange.
USD_to_GBP = 0.66 # Today's exchange rate
GBP_sign = '\u00A3' # Unicode value for £
dollars = 1000 # Number dollars to convert
# Conversion calculations
pounds = dollars * USD_to_GBP
# Printing the results
print('Today, $' + str(dollars))
print('converts to ' + GBP_sign + str(pounds))
48

48

24
05/09/2023

1.8 Data and Programming

Debugging
• Syntax errors
• SyntaxError: invalid syntax
• print(5 +)
• NameError: name 'pront' is not defined
• pront(5)
• Semantic errors
• Incorrect expressions like
• total_pay = 40 + extra_hours * pay_rate
• Runtime errors
• Unintentional divide by zero

49

49

1.9 Data Compression


• Two categories: Lossless versus Lossy
• Lossless schemes are those that do not lose information in the compression
process. Lossy schemes are those that may lead to the loss of information.
Lossy techniques often provide more compression than lossless ones.
• It includes techniques such as:
• Run-length encoding (lossless)
• Frequency-dependent encoding - Huffman codes (lossless)
• Relative encoding – differential encoding (lossless and lossy)
• Dictionary encoding – including adaptive dictionary encoding such as LZW (lossy)

50

50

25
05/09/2023

1.9 Data Compression

Compressing Images
• GIF: Good for cartoons
• JPEG: Good for photographs
• TIFF: Good for image archiving

51

51

1.9 Data Compression

Compressing Audio and Video


• MPEG
• High definition television broadcast
• Video conferencing
• MP3
• Temporal masking
• Frequency masking

52

52

26
05/09/2023

1.10 Communication Errors


• Goal: To reduce errors and increase the reliability of computing
equipment
• Parity bits (even versus odd)
• Checkbyte – a collection of parity bits
• Error correcting codes
• Hamming Distance

53

53

1.10 Communication Errors


Figure 1.26
The ASCII codes for the letters A and F adjusted for odd parity

54

54

27
05/09/2023

1.10 Communication Errors


1.10 Communication Errors
Figure 1.27 Figure 1.28
An Error-correcting code Decoding the pattern 010100 using the code in Figure 1.27

55

55

Data Storage
Chapter 1

Instructor: Miguel Gomes da Costa Junior

End

56

28

You might also like