Data Representation and Gates These slides are taken from your textbook Dale & Lewis.

Slides:



Advertisements
Similar presentations
Chapter 4 Gates and Circuits.
Advertisements

Chapter 4 Gates and Circuits Nell Dale • John Lewis.
Chapter 4 Gates and Circuits.
Gates and Circuits Nell Dale & John Lewis (adaptation by Erin Chambers and Michael Goldwasser)
CS105 Introduction to Computer Concepts GATES and CIRCUITS
Quiz # 1 Chapters 1,2,3, & 4.
Chapter 4 Gates and Circuits.
Text Compression 1 Assigning 16 bits to each character in a document uses too much file space We need ways to store and transmit text efficiently Text.
Dale & Lewis Chapter 3 Data Representation. Representing color Similarly to how color is perceived in the human eye, color information is encoded in combinations.
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, Java Version, Third Edition.
Chapter 03 Data Representation
Connecting with Computer Science, 2e
Chapter 4 Gates and Circuits.
9/19/06 Hofstra University – Overview of Computer Science, CSC005 1 Chapter 4 Gates and Circuits.
9/19/06 Hofstra University – Overview of Computer Science, CSC005 1 Chapter 4 Gates and Circuits.
09/17/06 Hofstra University – Overview of Computer Science, CSC005 1 Chapter 3 Data Representation.
Chapter Chapter Goals Distinguish between analog and digital information. Explain data compression and calculate compression ratios.
Lecture 3. Boolean Algebra, Logic Gates
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 12 Data.
Chapter 3 Data Representation. 2 Data and Computers Computers are multimedia devices, dealing with many categories of information. Computers store, present,
Chapter 3 Data Representation. 2 Data and Computers Computers are multimedia devices, dealing with many categories of information. Computers store, present,
CS105 INTRODUCTION TO COMPUTER CONCEPTS DATA REPRESENTATION Instructor: Cuong (Charlie) Pham.
Chapter 3 Data Representation.
Lecture 3. Boolean Algebra, Logic Gates Prof. Sin-Min Lee Department of Computer Science 2x.
CPS120 Introduction to Computer Science Lecture 4
Chapter 3 The Information Layer: Data Representation.
(2.1) Fundamentals  Terms for magnitudes – logarithms and logarithmic graphs  Digital representations – Binary numbers – Text – Analog information 
Chapter 4 Gates and Circuits. 4–2 Chapter Goals Identify the basic gates and describe the behavior of each Describe how gates are implemented using transistors.
Chapter 4 Gates and Circuits.
Lecture 3. Error Detection and Correction, Logic Gates Prof. Sin-Min Lee Department of Computer Science 2x.
Quiz # 2 Chapters 4, 5, & 6.
Chapter 3 Data Representation.
Lecture 3 Data Representation
Computers and Scientific Thinking David Reed, Creighton University Data Representation 1.
Chapter 4 Gates and Circuits. Integrated Circuits aka CHIPS What’s in this thing???? 4–2.
Chapter 4 Gates and Circuits.
Chapter 3 Data Representation (slides modified by Erin Chambers)
Data Representation CS280 – 09/13/05. Binary (from a Hacker’s dictionary) A base-2 numbering system with only two digits, 0 and 1, which is perfectly.
Chapter 3 Data Representation. 2 Data and Computers Computers are multimedia devices, dealing with many categories of information. Computers store, present,
CPS120: Introduction to Computer Science
Chapter 3 Representation. Key Concepts Digital vs Analog How many bits? Some standard representations Compression Methods 3-2.
3-1 Data and Computers Computers are multimedia devices, dealing with a vast array of information categories. Computers store, present, and help us modify.
Chapter 03 Data Representation. 2 Chapter Goals Distinguish between analog and digital information Explain data compression and calculate compression.
Digital Logic. 4 Why is 32-bit or 64-bit significant in terms of speed, efficiency? 4 Difference between OR and XOR 4 What is a mux for? PLA 4 Two kinds.
Compsci Today’s topics l Binary Numbers  Brookshear l Slides from Prof. Marti Hearst of UC Berkeley SIMS l Upcoming  Networks Interactive.
Quiz # 1 Chapters 1,2, & 3.
Chapter 03 Data Representation. 2 Chapter Goals Distinguish between analog and digital information Explain data compression and calculate compression.
Chapter 03 Data Representation. 2 Chapter Goals Distinguish between analog and digital information Explain data compression and calculate compression.
Chapter 03 Nell Dale & John Lewis. 3-2 Chapter Goals Distinguish between analog and digital information. Explain data compression and calculate compression.
HONR101 Analytics in a Big Data World Monday, January 18,
Digital electronics 4–1 Gates and Circuits SANJAYBHAI RAJGURU COLLEGE OF ENGG.
L OGIC G ATES Computer Organization – week 3. W HAT ’ S ALU? 1. ALU stands for: Arithmetic Logic Unit 2. ALU is a digital circuit that performs Arithmetic.
Week 1: Introduction and Logic gates IT3002 – Computer Architecture
Chapter 03 Data Representation.
CSIS-110 Introduction to Computer Science
Invitation to Computer Science, C++ Version, Fourth Edition
Basics of Logic gates - Part 2
Dr.Ahmed Bayoumi Dr.Shady Elmashad
Chapter 3 - Binary Numbering System
CSIS-110 Introduction to Computer Science
Invitation to Computer Science, Java Version, Third Edition
CHAPTER 2 - DIGITAL DATA REPRESENTATION AND NUMBERING SYSTEMS
CHAPTER 2 - DIGITAL DATA REPRESENTATION AND NUMBERING SYSTEMS
Chapter 4 Gates and Circuits.
CS105 Introduction to Computer Concepts GATES and CIRCUITS
Agenda – 2/12/18 Questions? Readings: CSI 4, P
CS105 Introduction to Computer Concepts Data Representation
The Building Blocks: Binary Numbers, Boolean Logic, and Gates
Logic Gates.
Chapter 4 Gates and Circuits.
Presentation transcript:

Data Representation and Gates These slides are taken from your textbook Dale & Lewis

2 Data and Computers Computers store, present, and help us modify Numbers Text Audio Images and graphics Video

3 Data and Computers Data compression Reduction in the amount of space needed to store a piece of data Compression ratio The size of the compressed data divided by the size of the original data A data compression techniques can be lossless, which means the data can be retrieved without any loss of the original information lossy, which means some information may be lost in the process of compaction

4 Analog and Digital Information Information can be represented in one of two ways: analog or digital Analog data A continuous representation, analogous to the actual information it represents Digital data A discrete representation, breaking the information up into separate elements Analog and Digital Information

5 Computers cannot work well with analog data, so we digitize the data Digitize Breaking data into pieces and representing those pieces separately

6 Electronic Signals Important facts about electronic signals An analog signal continually fluctuates in voltage up and down A digital signal has only a high or low state, corresponding to the two binary digits

7 Electronic Signals (Cont’d) Figure 3.2 An analog and a digital signal Figure 3.3 Degradation of analog and digital signals

8 Binary Representations Counting with binary bits Figure 3.4

9 Representing Negative Values Signed-magnitude number representation The sign represents the ordering, and the digits represent the magnitude of the number

Signed binary signed-magnitude The most significant bit (MSB) is set aside to indicate the sign, zero for positive and 1 for negative. One’s-complement The MSB of a negative number will begin with a one and a positive number with a zero will represent +3 and 1100 (complement of the positive 3) will represent -3. Two’s-complement. a negative number is represented by complementing the bits of the positive number and adding a 1. a –3 is represented as 1101 (complement of 0011 is 1100, and add a 1).

Two’s complement a binary number’s MSB is a zero then it is a positive and no further action is necessary. If the MSB is 1, it is a negative number. Suppose the number is , we know it is a negative number. Complement the bits and add a 1, we get = which is 127. The sign is already determined to be negative it is –127.

12 Number Overflow What happen if the computed value won't fit? Overflow If each value is stored using eight bits, adding 127 to 3 overflows Problems occur when mapping an infinite world onto a finite machine!

13 Representing Text What must be provided to represent text? There are finite number of characters to represent, so list them all and assign each a binary string Character set A list of characters and the codes used to represent each one Computer manufacturers agreed to standardize

14 The ASCII Character Set ASCII stands for American Standard Code for Information Interchange ASCII originally used seven bits to represent each character, allowing for 128 unique characters Later extended ASCII evolved so that all eight bits were used How many characters could be represented?

15 ASCII Character Set Mapping

16 The ASCII Character Set The first 32 characters in the ASCII character chart do not have a simple character representation to print to the screen What do you think they are used for?

17 The Unicode Character Set Extended ASCII is not enough for international use One Unicode mapping uses 16 bits per character How many characters can this mapping represent? Unicode is a superset of ASCII The first 256 characters correspond exactly to the extended ASCII character set

18 The Unicode Character Set Figure 3.6 A few characters in the Unicode character set

19 Text Compression Assigning 16 bits to each character in a document uses too much file space We need ways to store and transmit text efficiently Text compression techniques keyword encoding run-length encoding Huffman encoding

20 Keyword Encoding Replace frequently used words with a single character

21 Keyword Encoding Given the following paragraph, We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty and the pursuit of Happiness. ム That to secure these rights, Governments are instituted among Men, deriving their just powers from the consent of the governed, ム That whenever any Form of Government becomes destructive of these ends, it is the Right of the People to alter or to abolish it, and to institute new Government, laying its foundation on such principles and organizing its powers in such form, as to them shall seem most likely to effect their Safety and Happiness.

22 Keyword Encoding The encoded paragraph is We hold # truths to be self-evident, $ all men are created equal, $ ~y are endowed by ~ir Creator with certain unalienable Rights, $ among # are Life, Liberty + ~ pursuit of Happiness. — $ to secure # rights, Governments are instituted among Men, deriving ~ir just powers from ~ consent of ~ governed, — $ whenever any Form of Government becomes destructive of # ends, it is ~ Right of ~ People to alter or to abolish it, + to institute new Government, laying its foundation on such principles + organizing its powers in such form, ^ to ~m shall seem most likely to effect ~ir Safety + Happiness.

23 Keyword Encoding What did we save? Original paragraph 656 characters Encoded paragraph 596 characters Characters saved 60 characters Compression ratio 596/656 = Could we use this substitution chart for all text?

24 Run-Length Encoding A single character may be repeated over and over again in a long sequence Replace a repeated sequence with –a flag character –repeated character –number of repetitions *n8 –* is the flag character –n is the repeated character –8 is the number of times n is repeated

25 Run-Length Encoding Original text bbbbbbbbjjjkllqqqqqq+++++ Encoded text *b8jjjkll*q6*+5 (Why isn't l encoded? J?) The compression ratio is 15/25 or.6 Encoded text *x4*p4l*k7 Original text xxxxpppplkkkkkkk This type of repetition doesn’t occur in English text; can you think of a situation where it might occur?

26 Huffman Encoding Why should the character “X" and "z" take up the same number of bits as "e" or " "? Huffman codes use variable-length bit strings to represent each character More frequently used letters have shorter strings to represent them

27 Huffman Encoding ballboard would be compression ratio 28/56 Encode roadbed

28 Representing Audio Information We perceive sound when a series of air compressions vibrate a membrane in our ear, which sends signals to our brain

29 Representing Audio Information A stereo sends an electrical signal to a speaker to produce sound This signal is an analog representation of the sound wave The voltage in the signal varies in direct proportion to the sound wave

30 Representing Audio Information Digitize the signal by sampling –periodically measure the voltage –record the numeric value How often should we sample? A sampling rate of about 40,000 times per second is enough to create a reasonable sound reproduction

31 Representing Audio Information Figure 3.8 Sampling an audio signal Some data is lost, but a reasonable sound is reproduced

32 Representing Audio Information CDs store audio information digitally On the surface of the CD are microscopic pits that represent binary digits A low intensity laser is pointed as the disc The laser light reflects strongly if the surface is smooth and poorly if the surface is pitted

33 Representing Audio Information Figure 3.9 A CD player reading binary information

34 Audio Formats –WAV, AU, AIFF, VQF, and MP3 MP3 (MPEG-2, audio layer 3 file) is dominant –analyzes the frequency spread and discards information that can’t be heard by humans –bit stream is compressed using a form of Huffman encoding to achieve additional compression Is this a lossy or lossless compression (or both)?

35 Representing Images and Graphics Color Perception of the frequencies of light that reach the retinas of our eyes Retinas have three types of color photoreceptor cone cells that correspond to the colors of red, green, and blue

36 Representing Images and Graphics Color is expressed as an RGB (red-green- blue) value--three numbers that indicate the relative contribution of each of these three primary colors An RGB value of (255, 255, 0) maximizes the contribution of red and green, and minimizes the contribution of blue, which results in a bright yellow

37 Representing Images and Graphics Figure 3.10 Three-dimensional color space

38 Digitized Images and Graphics Digitizing a picture Representing it as a collection of individual dots called pixels Resolution The number of pixels used to represent a picture Raster Graphics Storage of data on a pixel-by-pixel basis Bitmap (BMP), GIF, JPEG, and PNG are raster- grahics formats

39 Digitized Images and Graphics Bitmap format Contains the pixel color values of the image from left to right and from top to bottom GIF format (indexed color) Each image is made up of only 256 colors JPEG format Averages color hues over short distances PNG format Like GIF but achieves greater compression with wider range of color depths Which is better for line drawings? Pictures?

40 Digitized Images and Graphics Figure 3.12 A digitized picture composed of many individual pixels Whole picture

41 Digitized Images and Graphics Figure 3.12 A digitized picture composed of many individual pixels Magnified portion of the picture See the pixels?

42 Representing Video Video codec COmpressor/DECompressor Methods used to shrink the size of a movie to allow it to be played on a computer or over a network Almost all video codecs use lossy compressions to minimize the huge amounts of data associated with video

43 Representing Video Temporal compression A technique based on differences between consecutive frames: If most of an image in two frames hasn’t changed, why should we waste space to duplicate all of the similar information? Spatial compression A technique based on removing redundant information within a frame: This problem is essentially the same as that faced when compressing still images

Computers and Electricity Gate A device that performs a basic operation on electrical signals Circuits Gates combined to perform more complicated tasks

Computers and Electricity How do we describe the behavior of gates and circuits? Boolean expressions Uses Boolean algebra, a mathematical notation for expressing two-valued logic Logic diagrams A graphical representation of a circuit; each gate has its own symbol Truth tables A table showing all possible input value and the associated output values

Gates Six types of gates –NOT –AND –OR –XOR –NAND –NOR Typically, logic diagrams are black and white with gates distinguished only by their shape We use color for emphasis (and fun)

NOT Gate A NOT gate accepts one input signal (0 or 1) and returns the opposite signal as output Figure 4.1 Various representations of a NOT gate

AND Gate An AND gate accepts two input signals If both are 1, the output is 1; otherwise, the output is 0 Figure 4.2 Various representations of an AND gate

OR Gate An OR gate accepts two input signals If both are 0, the output is 0; otherwise, the output is 1 Figure 4.3 Various representations of a OR gate

XOR Gate Figure 4.4 Various representations of an XOR gate An XOR gate accepts two input signals If both are the same, the output is 0; otherwise, the output is 1

XOR Gate Note the difference between the XOR gate and the OR gate; they differ only in one input situation When both input signals are 1, the OR gate produces a 1 and the XOR produces a 0 XOR is called the exclusive OR

NAND Gate The NAND gate accepts two input signals If both are 1, the output is 0; otherwise, the output is 1 Figure 4.5 Various representations of a NAND gate

NOR Gate Figure 4.6 Various representations of a NOR gate The NOR gate accepts two input signals If both are 0, the output is 1; otherwise, the output is 0

Review of Gate Processing A NOT gate inverts its single input An AND gate produces 1 if both input values are 1 An OR gate produces 0 if both input values are 0 An XOR gate produces 0 if input values are the same A NAND gate produces 0 if both inputs are 1 A NOR gate produces a 1 if both inputs are 0

Gates with More Inputs Gates can be designed to accept three or more input values A three-input AND gate, for example, produces an output of 1 only if all input values are 1 Figure 4.7 Various representations of a three-input AND gate

Constructing Gates Transistor A device that acts either as a wire that conducts electricity or as a resistor that blocks the flow of electricity, depending on the voltage level of an input signal A transistor has no moving parts, yet acts like a switch It is made of a semiconductor material, which is neither a particularly good conductor of electricity nor a particularly good insulator

Constructing Gates A transistor has three terminals –A source –A base –An emitter, typically connected to a ground wire If the electrical signal is grounded, it is allowed to flow through an alternative route to the ground (literally) where it can do no harm Figure 4.8 The connections of a transistor

Constructing Gates The easiest gates to create are the NOT, NAND, and NOR gates Figure 4.9 Constructing gates using transistors

Circuits Combinational circuit The input values explicitly determine the output Sequential circuit The output is a function of the input values and the existing state of the circuit We describe the circuit operations using Boolean expressions Logic diagrams Truth tables Are you surprised?

Combinational Circuits Gates are combined into circuits by using the output of one gate as the input for another

Combinational Circuits Three inputs require eight rows to describe all possible input combinations This same circuit using a Boolean expression is (AB + AC)

Combinational Circuits Consider the following Boolean expression A(B + C) Does this truth table look familiar? Compare it with previous table

Combinational Circuits Circuit equivalence Two circuits that produce the same output for identical input Boolean algebra allows us to apply provable mathematical principles to help design circuits A(B + C) = AB + BC (distributive law) so circuits must be equivalent

Properties of Boolean Algebra

Adders At the digital logic level, addition is performed in binary Addition operations are carried out by special circuits called, appropriately, adders

Adders The result of adding two binary digits could produce a carry value Recall that = 10 in base two Half adder A circuit that computes the sum of two bits and produces the correct carry bit Truth table

Half Adder #include void main() { short x,y, sum, carry; bool a,b,c,d; cout > x>>y; a=x==1; b=y==1; //actually c++ assigns 0 for false and 1 for true, we could have read these directly; c=(a||b) && !(a&&b); d=(a&&b); 9 sum=c?1:0; //if c is true then sum gets 1 else sum gets 0 carry=d?1:0; cout <<x <<"+"<<y <<"="<<carry<<sum<<endl; if (a = true) cout <<"it is true"; if (a) cout << "it is ture"; }

Adders Circuit diagram representing a half adder Boolean expressions sum = A  B carry = AB

Adders Full adder A circuit that takes the carry-in value into account Figure 4.10 A full adder

Multiplexers Multiplexer A circuit that uses a few input control signals to determine which of several output data lines is routed to its output

Multiplexers The control lines S0, S1, and S2 determine which of eight other input lines (D0 … D7) are routed to the output (F) Figure 4.11 A block diagram of a multiplexer with three select control lines

Circuits as Memory Digital circuits can be used to store information These circuits form a sequential circuit, because the output of the circuit is also used as input to the circuit

Circuits as Memory An S-R latch stores a single binary digit (1 or 0) There are several ways an S-R latch circuit can be designed using various kinds of gates Figure 4.12 An S-R latch

Circuits as Memory The design of this circuit guarantees that the two outputs X and Y are always complements of each other The value of X at any point in time is considered to be the current state of the circuit Therefore, if X is 1, the circuit is storing a 1; if X is 0, the circuit is storing a 0 Figure 4.12 An S-R latch

Integrated Circuits Integrated circuit (also called a chip) A piece of silicon on which multiple gates have been embedded Silicon pieces are mounted on a plastic or ceramic package with pins along the edges that can be soldered onto circuit boards or inserted into appropriate sockets

Integrated Circuits Integrated circuits (IC) are classified by the number of gates contained in them

Integrated Circuits Figure 4.13 An SSI chip contains independent NAND gates

CPU Chips The most important integrated circuit in any computer is the Central Processing Unit, or CPU Each CPU chip has a large number of pins through which essentially all communication in a computer system occurs

University of Texas Pan Am Dr. John P. Abraham Computer Programming Languages Computers perform operations such as moving data and data manipulation by activating switches and gates. Instructions to do that also must be given in the form of 1s and 0s or on and off. When we program computers using just ones and zeros we are using the “machine language”. When a program is written using human readable code line for line of machine code, that language is called Assembly language. Human readable code is called Mnemonics. When a programmer can use mathematical symbols and familiar English words such as write (a+b) that language is called a High Level language. Each of the program line will be converted to several lines of assembly or machine code. More about it later