CS120: Lecture 2 - PowerPoint PPT Presentation

1 / 27
About This Presentation
Title:

CS120: Lecture 2

Description:

mpjohnson_at_gmail.com. 2. Agenda: data. Review ops/gates ... 0. Just use sign bit. How to add/sub? 1's comp. How to add/sub? Two 0's. 2's comp. How to add/sub? ... – PowerPoint PPT presentation

Number of Views:55
Avg rating:3.0/5.0
Slides: 28
Provided by: MJoh8
Category:
Tags: cs120 | gmail | in | lecture | sign

less

Transcript and Presenter's Notes

Title: CS120: Lecture 2


1
CS120 Lecture 2
  • MP Johnson
  • Hunter College
  • mpjohnson_at_gmail.com

2
Agenda data
  • Review ops/gates
  • Abstract storage flipflops
  • Storage methods
  • representation
  • Test
  • Images
  • Sound
  • Numbers
  • Positive
  • Negative
  • Fractions
  • Compression

3
Circuits as memory
  • Flipflop special circuit that can store data
  • 1 bit per FF

To store, send pulse in top or bottom (0 is
ddf) Go through
4
Another FF
Go through
5
circuits
  • Q where do inputs come from?
  • A other circuits!
  • Connect worker circuit to mem circuit
  • This kind of mem is in RAM or maybe CPU
  • Fast measured in ns
  • Fast everywhere random
  • But Requires constant power

6
Memory cells arranged by address
7
Metric units
  • Kilo- normally means 1,000Kilobyte 210
    1024
  • Mega- normally means 1,000,000Megabyte 220
    1,048,576
  • Giga- normally means 1,000,000,000Megabyte
    230 1,073,741,824

8
Other (perm) kinds of mem
  • Hard drive Disk spins, head moves
  • Partly mechanical!
  • Usually larger, but slower
  • Measured in ms
  • Time depends somewhat on location

9
Other (perm) kinds of mem
  • Optical CD/DVD
  • Slower, less random
  • Read-only/read-once
  • Flash USB, MP3
  • Tape very slow, sequential

10
Storage devices
  • Hardware varies a lot
  • Q what stays the same?
  • A all store bits / 1-of-2 choices
  • Q why not base 3 or base 10?
  • A easier!
  • High (voltage) v. low or pos v neg or 0 v 1
  • High v. low v. medium
  • Q why do we ever use base 10?

11
Claim data nums bits
  • Eg, letters cant write A on a HD
  • Q what to do?
  • A pick some num to rep A
  • Turns out A 65, B 66
  • ANSIs ASCII
  • Q but how to rep 65?
  • Cant write num 65 on a HD
  • A write 65 in binary

12
base
  • mathematically, any base will do
  • On machine, must use base 2
  • 65 610 51
  • 164 11
  • 125 120
  • 1000001b
  • ? 65 1 1000001 1 1000010

13
ANSI
  • ANSI only uses 7 bits (128 vals)
  • Insert a 1 at front to get 8 bits 1 byte (255)
  • Usually think in terms of bytes, not bits
  • Q what about negatives, fractions?
  • A next time

14
hex
  • Sometimes base-16 is used for as shorthand
  • 1 base-16 val 4 bits
  • Also octal

15
Reping images?
  • One way
  • Bitmaps (.bmp)
  • b/w 2-d table of brightness values
  • Pixel picture element
  • Col one table each of r/g/b
  • Size 100010003 3MB!
  • Another
  • Vector methods

16
Reping sounds?
  • One way
  • Sample soundwave ampl at intervals
  • Phones 8000/s
  • CD 44,1000/s
  • Another
  • MIDI
  • For 10s constant tone, record tone length

17
Data compression
  • NB vectors and MIDI sound smarter
  • But whatever you do, must still be stored as bits
  • Must find a way to encode these instructions as
    bits
  • Harder than storing directly!

18
Base 2 v. base 10
19
Convert base10 ? base2
  • Alg while x is not 0
  • Write x2 to right
  • Set x x/2

20
Integers with bits
  • Unsigned (non-neg) just base2
  • Signed
  • 0. Just use sign bit
  • How to add/sub?
  • 1s comp
  • How to add/sub?
  • Two 0s
  • 2s comp
  • How to add/sub?
  • See app. B for neg, add circuits
  • Also excess notation (skip?)

21
Fractions in binary (naïve)
22
IEEE floating-pt standard
23
IEEE floats
  • Used for all fractions in C/C/Java
  • Strength very large range (billions)
  • Weakness merely approximate
  • Can depend on order!

24
Compression
  • Saw MIDI for sound
  • Saw vectors for images
  • Other methods
  • Relative methods for images (why works?)
  • GIF, JPEG
  • Relative methods for video (why works?)
  • MPEG
  • Run-length encoding
  • Frequency-based (why works?)
  • LZ (zip files)

25
Recognizing errors
  • Idea include extra info
  • Parity bits

26
Correcting errors
  • Error-correcting codes
  • If only one bad bit, can recover,e.g., 010100

27
Future
  • No class Tuesday
  • Reading for Wednesday is on website
  • Hw posted soon (email/web)
Write a Comment
User Comments (0)
About PowerShow.com