Title: Lecture4 2.8 3.4
1Lecture-4 (2.8 3.4)
- CSCI130-03A
- Instructor Dr. Imad Rahal
2Announcements
- Quiz 1 next Friday
- Closed book/notes, no calculators, and no
computers - Assignment 1 due Tuesday 13th
- Try to finish it before quiz
- Go to
- My Computer
- N
- CS130
- Handouts
- NumberConversion.doc
3Non-numeric Data Representation
- Picture/Image Data
- Divide the screen into a grid of cells each
referred to as a pixel - 512156 image ? grid has 512 columns and 256 rows
- How many pixels?
- Pixel values and sizes depend on the type of the
image - For black white images, we can use 1 bit for
every pixel such that 1 ? black and 0 ? white - For grayscale images, we use 1 byte where 255 ?
black and 0 ? white and anything in between is
gray (higher/lower values are closer to
black/white) - For color images, we need three values per pixel
(depends on the color scheme used) - Red/Green/Blue
- We need 1 byte per value ? 3 bytes per pixel
- For an 512x256 image
- 512x256x3 384K bytes
4Assume all images have 512x256 resolution. Can
you find their sizes in bytes?
5Non-numeric Data Representation
- Image movies are built from a number of images
(or frames) that are displayed in a certain
sequence at high speeds - 30 frames per second
- 2-hr movie needs (assume previous image used)
- 384K 30 60 120 83 GB (billion) bytes!
- People use compression to reduce large movie
sizes - Usually the change between two consecutive images
is small ? store only difference between frames
(Temporal compression) - Large areas with the same color can be stored by
saving the boundary pixels only (everything
within the boundaries has the same value)
(Spatial compression)
6Non-numeric Data Representation
The heard sound depends on the altitude and
frequency
- Sound/Audio Data
- An object produces sound when it vibrates in
matter (e.g. air) - A vibrating object sends a wave of pressure
fluctuations through the atmosphere - We hear different sounds from different vibrating
objects because of variations in the sound wave
frequency - Higher wave frequency means air pressure
fluctuation switches back and forth more quickly
during a period of time - We hear this as a higher pitch (intensity)
- When there are fewer fluctuations in a period of
time, the pitch is lower - The level of air pressure in each fluctuation,
the wave's amplitude or height, determines how
loud the sound is
Volts
7Non-numeric Data Representation
- Numbers used to represent the amplitude of sound
wave - Analog is continuous and we need digital
- Digitize the sound signal
- Measure the voltage of the signal at certain
intervals (e.g. 40,000 per sec for CDs) - Reconstruct wave
- Compression can also be used for audio files
- MP3 reduces size to 1/10th
- ? faster transfer over the Internet
8Non-numeric Data Representation
- Digital image and audio have a lot of advantages
over non-digital ones - Can easily be modified by changing the bit
pattern - Image enhancement, noise/distortion removal, etc
- Superimpose one sound on another or image on
another results in newer ones
9Non-numeric Data Representation
- It makes you wonder if images can be trusted
- adapted from a course offered at BU
10Non-numeric Data Representation
11Data Storage (3.1 3.3)
12Overview of Computer Hardware
- Read 3.1 - 3.3
- What are the necessary components of a computer
- CPU, Main memory
- What are the components that we need for
convenience - Otherwise the computer wont be very practical to
use - Secondary/Auxiliary storage, I/O devices
13Overview of Computer Hardware
- CPU
- Central Processing Unit
- Single silicon chip with circuits attached to it
- Known as microprocessor
- Sits on a circuit board known as the motherboard
- Main memory
- Connects to the motherboard
- Divided into two major parts
- RAM --- Random Access Memory
- Contains the memory registers which store data
before/after CPU processing - Available for users and programs so store data in
and read data from ? very dynamic - Volatile --- does not persist when no electric
power is supplied to its circuits
14Overview of Computer Hardware
- ROM --- Read Only Memory
- Permanent
- Holds programs that are vital for the operation
of the computer (such as boot and other System
files) - As the name indicates, can be read but never
altered - Cache
- A type of memory that sits between main memory
and CPU - Faster, smaller and more expensive than main
memory - Used a lot in mobile phones
15Overview of Computer Hardware
- Input devices
- Takes data from the user and converts it into
binary - Sends it to main memory
- Mouse, touch screens, scanners, digital cameras,
etc
16Overview of Computer Hardware
- Output devices
- Devices such as monitors, speakers, printers, etc
- Monitors
- CRTs (cathode ray tubes) VS Flat-panel
- CRTS are cheaper (4-8 times less) and more used
with desktops - Three important monitor characteristics to watch
out for - Resolution number pf pixels on the screen...the
higher the better (640x480 to 1600x1200) - Dot pitch how close are the pixels to each
otherthe closer the better (.2 or .3) - Refresh rate number of times per second that a
new electric pulse is sent to each pixel to
maintain the color from fading (70Hz or higher)
17Overview of Computer Hardware
- Printers
- Two major types
- Laser VS ink-jet
- Both use small dots to form images of characters
and graphics being printed - Ink-jet however sprays smalls dots of liquid ink
onto the page from a matrix of ink jets - Laser creates an image of the page to be printed
on cylinder (photoreceptor drum) covered with
magnetically charged toner (powder ink) - The image is created on the drum as a negative
charge - Toner (positive) is spread over the drum and
sticks only to the image - Paper is given a strong negative charge passes
close to drum so that the powder leaves the drum
and sticks to the paper
18Overview of Computer Hardware
- Auxiliary Storage
- Used to store data/programs for long terms
(permanent storage) - much slower and cheaper than main memory
- Tapes, disks and CDs
- Magnetic tape
- Like VHS films or cassettes
- Was ubiquitous prior to the 80s
- Nowadays, only for backup and archiving
- Cheap, holds a lot of data and easy to store
- Binary data from RAM is stored as is
- Thin plastic tape covered with a coating that
accepts magnetic charge
19Overview of Computer Hardware
- A dot of magnetic charge is a 1, nothing is a 0
- Divided into multiple segments
- There is a directory that stores where (i.e. in
which segment) every file is stored - To access a file
- Mount tape on drive
- FF until the right segment
- Write or read
- Sequential access
- Start from the beginning and go all the way until
the desired file is found - Time consuming ? not used for storage in
Computers
20Overview of Computer Hardware
- Magnetic Disk
- Used the most for permanent storage in computers
- In principal, stores data pretty much the same
way as tapes - Magnetic coating covers the disk
- Takes magnetic charge to represent data
- Divided into tracks and sectors
- Tracks are concentric circles on the disk each
holding information that too big to fit in main
memory - Sectors divide the disk into pie-shaped areas
- Data fills all track within one sector
- All tracks can store the same number of bits!!!
- ? more compact towards the center
21(No Transcript)
22R/W Head
- R/W head can move to any position (sector, track)
on the disk ? random access
23Overview of Computer Hardware
- Comes in two forms
- Portable
- Floppy disks
- Because they are flexible (easily bent)
- 3.5
- 1.44 MB
- Zip disks
- Several 100 MBs
- Accessed by a disk drive
- Need formatting sets up tracks and sectors and
directory (where is every file) and erases
everything
24Overview of Computer Hardware
Disk Pack
- Fixed
- Hard disks
- Single (PCs) or multiple ( 10 to 12)
- Multiple GBs per disk
- Diskettes have 135 tracks per inch and 18 tracks
- HDs have 1000s of tracks per inch and 64 tracks
- R/W does not touch the surface but floats right
above it ? Rotate 100 times faster than diskettes - They are sealed so that no dirt comes between R/W
head and disk (corrupts data)
25Overview of Computer Hardware
- Compact Disks (CDs)
- Optical disk
- Data stored like magnetic disks (series of dots
on tracks) - Now we BURN the dots (rather than magnetic
charges) as pits on the surface - A laser detects those pits as 0s
- Data spans a track of the disk (not sectors)
- Pits gives the advantage of more density of
storage - 600 MB to 10 GB
- Most CDs are Read-only (because of the burning)
- Some optical drives do allow for re-burning of
surface after smoothing out the pits
26Overview of Computer Hardware
- File Management
- To process data, computers copy a fixed amount of
data from disk or tape to RAM - Called a physical block
- Copied to buffer in RAM
- A file may fit into 1 (even if less) or more
blocks (not always contiguous) - In the latter case, the RAM may need to
reassemble a file from several blocks on disk - Done in part of RAM called buffer
- Magnetic and optical disks have directories that
for every stored file - Name
- Starting location (track, sector and possibly
side) - Length
- Directory also maintains a list of empty blocks
27Overview of Computer Hardware
- FYI when you delete a file, IT IS NOT DIRECTLY
DELETED FROM DISK!!! - The files entry in the directory is erased
- Its occupied space is added to the list of empty
space - The occupied space awaits to be written over by
other data - File organization
- Hierarchical
- Folders/directors (root)
- Tree-structured file system
28Data Manipulation (3.4)
29Data Manipulation
- Recall that adding and comparing bit patterns is
sufficient to achieve an operational machines - This is done by circuits for adding and comparing
bit patterns in registers - Circuits are made up of gates
- Gates and Truth Tables
- Gates needed are NOT, AND, and OR
- NOT Gate
- Single input and single output
- Reverses input
- 1 ? 0 and 0 ? 1
- If there is electric power ? shut it off
- If there is no electric power ? turns it on
- Like a power switch
30Data Manipulation
- AND Gate
- Accepts two inputs and yields one output
- Always 0 except when both are 1s
- Requires power coming from both lines in order to
give out power
31Data Manipulation
- OR Gate
- Accepts two inputs and yields one output
- Always 1 except when both are 0s
- Requires power coming from at least one of the
input lines in order to give out power - Variant XOR
- 1 if inputs are distinct
32Data Manipulation
- These three simple gates are combined to create
circuits that perform more complicated operations - These new combinations can be expressed in three
ways - Through Expressions
- A AND B ? AB
- A OR B ? AB
- NOT A ? A
- (NOT A AND NOT B) OR (A AND B) ? AB AB